Skip to content

Reject unknown actions to background - #106

Closed
ShryukGrandhi wants to merge 1 commit into
omlahore:mainfrom
ShryukGrandhi:fix/issue-82-background-with-an-unknown-action-lists
Closed

ShryukGrandhi wants to merge 1 commit into
omlahore:mainfrom
ShryukGrandhi:fix/issue-82-background-with-an-unknown-action-lists

Conversation

@ShryukGrandhi

@ShryukGrandhi ShryukGrandhi commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

removemacai background of (a typo for off) printed the list of background items and exited 0, so the typo went unnoticed. Only off, on or no action is valid now. Anything else fails with unknown action "of", use off or on and exits 1.

Changes

  • TweakCommands.background checks the action first, before it scans background items, and fails on anything other than off or on.
  • Because of that check, the listing branch only runs when no action is given, so its guard now just checks for a missing action.

Testing

Tested on macOS 26.5.1 (25F80), Apple silicon, with a debug build:

  • Before: removemacai background of listed the items and exited 0.
  • After: removemacai background of prints error: unknown action "of", use off or on and exits 1.
  • removemacai background still lists the items and exits 0.
  • removemacai background off with no labels still fails with name the items, as listed by: removemacai background.
  • removemacai selftest passes.

There's no selftest check for this because Term.fail exits the process. The earlier argument checks (#72, #74) don't have one either.

Fixes #82

Summary by CodeRabbit

  • Bug Fixes
    • Background item commands now report an error when the action is not on or off, instead of displaying the background item list.
    • Running the command without an action continues to display the list.

"removemacai background of" listed the background items and exited 0,
so a typo for "off" went unnoticed. Fail with "unknown action" unless
the action is off, on or missing.

Fixes omlahore#82

Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45a82d67-0b7e-4177-b100-96640e35b8a4
Commits

Reviewing files that changed from the base of the PR and between c7eb398 and e2a9c8d.

Files selected for processing: 1
  • Sources/removemacai/TweakCommands.swift

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The background command now reports an error for an unrecognized first argument. With no argument, it lists background items; off and on continue to the action flow.

Changes: Background command

Layer / File(s) Summary
Validate background action
Sources/removemacai/TweakCommands.swift
The command rejects an unrecognized first argument. No argument still lists background items, and off and on continue to the action flow.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • omlahore/RemoveMacAI#97: This PR changes the same command to reject unknown actions and adds a self-test for that case.

Suggested reviewers: omlahore, bubleg

Merge Risk: Minimal · up to e2a9c

The requested background action validation is implemented without an identified regression.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Reject unknown actions to background" matches the main change. TweakCommands.background now rejects any action other than off or on, which the linked issue #82 requests. The title is short …
Linked Issues check Passed [#82] requires that background accept only off, on, or no action. Any other action must fail with an error such as unknown action "of", use off or on, and the check must sit at the top of `Twe…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one file, Sources/removemacai/TweakCommands.swift, with about +4/-1 lines. Every changed line belongs to TweakCommands.background. The new validati…
Full details: Title check

Explanation

The title "Reject unknown actions to background" matches the main change. TweakCommands.background now rejects any action other than off or on, which the linked issue #82 requests. The title is short and specific, and it names the behavior change. Minor wording issue: "to background" is slightly awkward, since the change targets the background command, but a teammate scanning history would still understand the primary change.

Full details: Linked Issues check

Explanation

[#82] requires that background accept only off, on, or no action. Any other action must fail with an error such as unknown action "of", use off or on, and the check must sit at the top of TweakCommands.background. The reviewed head adds this check as the first statement in background in Sources/removemacai/TweakCommands.swift. It runs Term.fail("unknown action \"\(action)\", use off or on") when args.first is neither off nor on. This runs before BackgroundItems.scan() and disabledLabels(). The listing guard changed from guard let action = args.first, action == "off" || action == "on" else to guard let action = args.first else. So the listing branch runs only when no action is given. The off/on handling is unchanged. The diff shows no coding requirement from #82 left unmet. The PR description reports manual testing on macOS. The PR adds no automated test for this path. The PR states that Term.fail exits the process, so a selftest is not practical. The issue does not list an automated test as a requirement, so this does not fail the assessment.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one file, Sources/removemacai/TweakCommands.swift, with about +4/-1 lines. Every changed line belongs to TweakCommands.background. The new validation implements #82. The guard rewrite is required so the listing branch runs only when no action is given. No unrelated code, refactoring, or documentation changes appear in the diff. The PR description and objectives state the same scope.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@omlahore

Copy link
Copy Markdown
Owner

thanks for this 🙌
#97 fixes the same bug (#82) and it came in first
so i'm closing this one as a duplicate

@omlahore omlahore closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

background with an unknown action lists items instead of failing

2 participants