Skip to content

fix(agent): error on an unrecognized command instead of opening the desktop app - #1549

Merged
AnthonyRonning merged 2 commits into
masterfrom
fix/agent-unknown-command
Nov 10, 2026
Merged

AnthonyRonning merged 2 commits into
masterfrom
fix/agent-unknown-command

Conversation

@w3irdrobot

@w3irdrobot w3irdrobot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What happened

While pairing a remote node that has no GUI, I ran maple-agent begin-pairing. The real command is maple-agent remote begin-pairing. Instead of an error, the binary treated the word as a launcher argument and tried to start the desktop app, which on a headless machine is confusing and gives no hint about what went wrong.

Change

Following the review suggestion, this removes the launcher-argument catch-all rather than carving exceptions out of it:

  • Drop %U from both Linux Exec= lines (scripts/linux-install.py, scripts/linux-release-appimage.py). Maple Work registers no MimeType or URL scheme, so it advertised a capability the app doesn't have.
  • Remove desktop_args and its conflicts_with references. Nothing read it.
  • Clap now rejects unknown input itself, with exit status 2 and its built-in suggestion for top-level typos.
  • One small add-on: clap only suggests at the current level, so an unknown word that names a nested command gets its full path as the tip. Hidden commands are not suggested.
$ maple-agent begin-pairing
error: unrecognized subcommand 'begin-pairing'

  tip: did you mean 'maple-agent remote begin-pairing'?

$ maple-agent remot
error: unrecognized subcommand 'remot'

  tip: a similar subcommand exists: 'remote'

$ maple-agent --unknown
error: unexpected argument '--unknown' found

Behavior change to be aware of

Every unknown argument is now an error, including unknown flags, URLs and file paths.

Existing Linux user installs keep their old .desktop entry with %U: linux-install.py writes it once and refuses to replace it, and I found nothing in the in-app updater that rewrites it. Launching from the menu expands %U to nothing, so that still opens the window. Dropping a file onto the launcher icon would now exit with an error instead of opening the app. I did not add a transitional tolerance for absolute paths; say so if that case matters.

Merging is optional

The previous catch-all was deliberate and may be the desired behavior. This PR is a proposal that came out of one confusing headless pairing session; close it if ignoring unknown arguments is intended.

Testing

Run on Linux through the Agent Nix shell, after rebasing on master:

  • cargo test -p maple-agent-app --locked --bin maple-agent: 1389 passed, 0 failed, 4 ignored
  • Startup smoke test: launched the debug binary with no arguments on a virtual X display (Xvfb) with throwaway XDG_* roots. The "Maple Work Debug" window opened. On the same display, maple-agent begin-pairing exited 2 with the tip and opened no window.
  • Ran the debug binary with begin-pairing, frobnicate, remot, --unknown and /tmp/x.txt: all exit 2 with the expected messages

Run before the rebase and not repeated since: just ci-lint (passed) and just python-test (26 tests OK, 1 skipped).

Not run:

  • A packaged launch: no AppImage or installed .desktop entry was built or started. The smoke test covers what those do after this change, which is start the binary with no arguments.
  • macOS and Windows launch. From source, the NSIS installer starts maple-agent.exe with no arguments and the macOS Info.plist declares no document or URL types, but neither was launched.
  • The full workspace just ci-test and the headless feature-set tests.

🤖 Generated with Claude Code

@AnthonyRonning

Copy link
Copy Markdown
Contributor

Agreed that a mistyped command shouldn't open the desktop app. An alternative to consider that removes the catch-all instead of carving exceptions out of it:

Why the catch-all exists. desktop_args only absorbs what the Linux .desktop entries append through %U (linux-install.py:209, linux-release-appimage.py:296). Maple Work registers no MimeType or URL scheme (the scheme handlers in the repo belong to Research), and nothing reads desktop_args. So %U advertises a file/URL capability the app doesn't have, and the catch-all exists only to swallow it.

Suggested change

  1. Drop %U from both Exec= lines.
  2. Remove desktop_args and its conflicts_with references.
  3. Let clap reject unknown input as usual: error: unrecognized subcommand 'stauts', its built-in "did you mean" for top-level typos, exit 2.

This is net-negative code and leaves no heuristic about which arguments look like a launcher's to maintain.

Things to check

  • Existing installs keep the old .desktop with %U. Launching from the menu expands it to nothing, so that still works; only dropping a file onto the icon would now error. If that matters, either confirm updates rewrite the entry or tolerate absolute paths for one release.
  • clap only suggests at the current level, so begin-pairing wouldn't point at remote begin-pairing. If you want that hint, nested_command_path could be kept as a small add-on to clap's error.
  • Smoke test on Linux (menu and AppImage launch still open the window), and confirm macOS and Windows launch with no arguments.

@w3irdrobot

Copy link
Copy Markdown
Contributor Author

@AnthonyRonning yeah i considered this but i assumed we'd want to avoid breaking existing behavior, but i can remove it instead.

w3irdrobot and others added 2 commits November 10, 2026 20:26
…esktop app

`maple-agent begin-pairing` (the real command is `maple-agent remote
begin-pairing`) was swallowed by the launcher-argument catch-all and
started the desktop app. A leading bare word that is not a known command
is now an error with exit status 2, with a hint when it names a nested
command. Flags, URLs and file paths appended by a desktop launcher are
still ignored.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ng it

Maple Work registers no MimeType or URL scheme and nothing read
`desktop_args`; it only swallowed what `%U` in the Linux desktop entries
appended. Drop `%U` from both `Exec=` lines, remove `desktop_args`, and
let clap reject unknown input. Clap suggests only at the current level,
so an unknown word naming a nested command (`begin-pairing`) still gets
its full path as the tip.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@w3irdrobot
w3irdrobot force-pushed the fix/agent-unknown-command branch from 9dbfbbc to d426770 Compare November 10, 2026 20:46
@w3irdrobot

Copy link
Copy Markdown
Contributor Author

@AnthonyRonning this is ready for another look. I went with your direction:

  • %U is dropped from both Exec= lines and desktop_args is gone, so clap rejects unknown input itself.
  • I kept nested_command_path as the small add-on you mentioned, so maple-agent begin-pairing points at maple-agent remote begin-pairing.
  • Existing Linux installs keep their old .desktop entry with %U (the installer writes it once and I found nothing in the updater that rewrites it). Menu launch still works; dropping a file on the icon would now error. I didn't add the one-release tolerance for absolute paths, so say if you want it.

Rebased on master. Smoke tested on Linux under Xvfb: a no-argument launch opens the window, and begin-pairing exits 2 without one. No packaged AppImage launch and nothing on macOS or Windows; details are in the description.

@AnthonyRonning
AnthonyRonning merged commit fbe8399 into master Nov 10, 2026
23 checks passed
@AnthonyRonning
AnthonyRonning deleted the fix/agent-unknown-command branch November 10, 2026 23:27
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.

2 participants