fix(cli): wire the contexts command into the CLI program - #4369
Conversation
Found by end-to-end testing of remote mode: `omniroute contexts list/current/use`
fell through to `serve` ("too many arguments for 'serve'"). `connect` even tells
users "Switch back to local with: omniroute contexts use default" — a dead command.
Root cause: `bin/cli/commands/contexts.mjs` implements `registerContexts` (with
list/add/use/current/show/remove/rename/export/import), and it had an isolated unit
test using a FAKE program — but `registry.mjs` never imported or called it, so the
command was never wired into the real CLI. Add the import + registration alongside
the other remote-mode commands (connect/tokens/configure).
Regression test: build the REAL program via createProgram() and assert the
top-level contexts/connect/tokens/configure commands exist and that `contexts`
exposes its list/use/current subcommands (RED before, GREEN after). The previous
isolated fake-program test could not catch the missing wiring.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Code Review
This pull request registers the missing contexts command in the CLI registry and adds a regression test to verify that remote-mode commands and their subcommands are correctly wired. The feedback recommends adding an assertion to ensure the contexts command is defined before accessing its properties in the test, preventing potential TypeError exceptions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const contexts = program.commands.find((c: any) => c.name() === "contexts"); | ||
| const subs = contexts.commands.map((c: any) => c.name()); |
There was a problem hiding this comment.
The find method can return undefined if the 'contexts' command is not found. To prevent a TypeError when accessing contexts.commands and to provide a clearer test failure message, assert that contexts is defined before accessing its properties.
const contexts = program.commands.find((c: any) => c.name() === "contexts");
assert.ok(contexts, "expected 'contexts' command to be registered");
const subs = contexts.commands.map((c: any) => c.name());…apw#4369) Found by end-to-end testing of remote mode: `omniroute contexts list/current/use` fell through to `serve` ("too many arguments for 'serve'"). `connect` even tells users "Switch back to local with: omniroute contexts use default" — a dead command. Root cause: `bin/cli/commands/contexts.mjs` implements `registerContexts` (with list/add/use/current/show/remove/rename/export/import), and it had an isolated unit test using a FAKE program — but `registry.mjs` never imported or called it, so the command was never wired into the real CLI. Add the import + registration alongside the other remote-mode commands (connect/tokens/configure). Regression test: build the REAL program via createProgram() and assert the top-level contexts/connect/tokens/configure commands exist and that `contexts` exposes its list/use/current subcommands (RED before, GREEN after). The previous isolated fake-program test could not catch the missing wiring.
Found by E2E testing remote mode
omniroute contexts list/current/usefell through toserve(too many arguments for 'serve'). Worse,connectitself prints "Switch back to local with: omniroute contexts use default" — pointing users at a command that didn't exist.Root cause
bin/cli/commands/contexts.mjsfully implementsregisterContexts(subcommands:list/add/use/current/show/remove/rename/export/import) and had a unit test — but that test used a fake program object.registry.mjsnever imported or calledregisterContexts, so the command was never wired into the real CLI. The isolated fake-program test passed regardless, hiding the gap.Fix
Add the import +
registerContexts(program)call alongside the other remote-mode commands (connect/tokens/configure). One-line wiring; the command's implementation was already complete.Validation
createProgram()and assertscontexts/connect/tokens/configureare top-level commands and thatcontextsexposeslist/use/current. It fails before the fix, passes after — exactly the class the old fake-program test could not catch.omniroute contexts list/contexts currentnow render the context table instead of erroring;contexts useis available to switch back to local.Client-side only — no server change, no redeploy. Completes the remote-mode CLI UX surfaced during the item-5 E2E.