Repository navigation
fix(ui): treat /model status|list|info as info queries, not model names - #47069
lagutinl613-alt wants to merge 2 commits into
Conversation
The WebUI slash-command handler only distinguished between '/model' (no args) and '/model <name>'. Subcommands like 'status', 'list', and 'info' were passed straight through as literal model names to sessions.patch, causing errors like 'model not allowed: openai-codex/status'. Add a set of recognized info subcommands (status, list, info) that route to the model-info display path instead of attempting to set the model. Fixes openclaw#46894
Greptile SummaryThis PR fixes a bug where
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/ui/chat/slash-command-executor.node.test.ts
Line: 233-326
Comment:
**Missing regression test for the model-setting path**
The new suite verifies that `status`, `list`, and `info` no longer reach `sessions.patch`, but there is no test confirming that a real model name (e.g. `/model gpt-4.1`) *still* calls `sessions.patch` with the correct payload. Since the PR touches the branch that routes to `sessions.patch`, a complementary regression test would lock down both sides of the condition and prevent future regressions in the same function.
Consider adding a case to this describe block that passes a non-subcommand argument (e.g. `"gpt-4.1"`), confirms `sessions.patch` is called with `{ key: ..., model: "gpt-4.1" }`, and checks the returned content reads `Model set to \`gpt-4.1\`.`.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: aa20da5 |
| describe("executeSlashCommand /model subcommands", () => { | ||
| it("treats /model status as an info query, not a model name", async () => { | ||
| const request = vi.fn(async (method: string, _payload?: unknown) => { | ||
| if (method === "sessions.list") { | ||
| return { | ||
| defaults: { model: "default-model" }, | ||
| sessions: [ | ||
| row("agent:main:main", { | ||
| model: "openai-codex/gpt-5.4", | ||
| }), | ||
| ], | ||
| }; | ||
| } | ||
| if (method === "models.list") { | ||
| return { | ||
| models: [{ id: "openai-codex/gpt-5.4" }], | ||
| }; | ||
| } | ||
| throw new Error(`unexpected method: ${method}`); | ||
| }); | ||
|
|
||
| const result = await executeSlashCommand( | ||
| { request } as unknown as GatewayBrowserClient, | ||
| "main", | ||
| "model", | ||
| "status", | ||
| ); | ||
|
|
||
| // Should show current model info, NOT try to set the model to "status" | ||
| expect(result.content).toContain("Current model:"); | ||
| expect(result.content).toContain("openai-codex/gpt-5.4"); | ||
| // Ensure sessions.patch was never called | ||
| expect(request).not.toHaveBeenCalledWith( | ||
| "sessions.patch", | ||
| expect.objectContaining({ model: "status" }), | ||
| ); | ||
| }); | ||
|
|
||
| it("treats /model list as an info query", async () => { | ||
| const request = vi.fn(async (method: string, _payload?: unknown) => { | ||
| if (method === "sessions.list") { | ||
| return { | ||
| defaults: { model: "default-model" }, | ||
| sessions: [row("agent:main:main", { model: "gpt-4.1" })], | ||
| }; | ||
| } | ||
| if (method === "models.list") { | ||
| return { models: [{ id: "gpt-4.1" }, { id: "gpt-4.1-mini" }] }; | ||
| } | ||
| throw new Error(`unexpected method: ${method}`); | ||
| }); | ||
|
|
||
| const result = await executeSlashCommand( | ||
| { request } as unknown as GatewayBrowserClient, | ||
| "main", | ||
| "model", | ||
| "list", | ||
| ); | ||
|
|
||
| expect(result.content).toContain("Current model:"); | ||
| expect(request).not.toHaveBeenCalledWith( | ||
| "sessions.patch", | ||
| expect.objectContaining({ model: "list" }), | ||
| ); | ||
| }); | ||
|
|
||
| it("treats /model info as an info query", async () => { | ||
| const request = vi.fn(async (method: string, _payload?: unknown) => { | ||
| if (method === "sessions.list") { | ||
| return { | ||
| defaults: { model: "default-model" }, | ||
| sessions: [row("agent:main:main", { model: "gpt-4.1" })], | ||
| }; | ||
| } | ||
| if (method === "models.list") { | ||
| return { models: [{ id: "gpt-4.1" }] }; | ||
| } | ||
| throw new Error(`unexpected method: ${method}`); | ||
| }); | ||
|
|
||
| const result = await executeSlashCommand( | ||
| { request } as unknown as GatewayBrowserClient, | ||
| "main", | ||
| "model", | ||
| "info", | ||
| ); | ||
|
|
||
| expect(result.content).toContain("Current model:"); | ||
| expect(request).not.toHaveBeenCalledWith( | ||
| "sessions.patch", | ||
| expect.objectContaining({ model: "info" }), | ||
| ); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Missing regression test for the model-setting path
The new suite verifies that status, list, and info no longer reach sessions.patch, but there is no test confirming that a real model name (e.g. /model gpt-4.1) still calls sessions.patch with the correct payload. Since the PR touches the branch that routes to sessions.patch, a complementary regression test would lock down both sides of the condition and prevent future regressions in the same function.
Consider adding a case to this describe block that passes a non-subcommand argument (e.g. "gpt-4.1"), confirms sessions.patch is called with { key: ..., model: "gpt-4.1" }, and checks the returned content reads Model set to \gpt-4.1`.`.
Prompt To Fix With AI
This is a comment left during a code review.
Path: ui/src/ui/chat/slash-command-executor.node.test.ts
Line: 233-326
Comment:
**Missing regression test for the model-setting path**
The new suite verifies that `status`, `list`, and `info` no longer reach `sessions.patch`, but there is no test confirming that a real model name (e.g. `/model gpt-4.1`) *still* calls `sessions.patch` with the correct payload. Since the PR touches the branch that routes to `sessions.patch`, a complementary regression test would lock down both sides of the condition and prevent future regressions in the same function.
Consider adding a case to this describe block that passes a non-subcommand argument (e.g. `"gpt-4.1"`), confirms `sessions.patch` is called with `{ key: ..., model: "gpt-4.1" }`, and checks the returned content reads `Model set to \`gpt-4.1\`.`.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa20da59c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| args: string, | ||
| ): Promise<SlashCommandResult> { | ||
| if (!args) { | ||
| if (!args || MODEL_INFO_SUBCOMMANDS.has(args.trim().toLowerCase())) { |
There was a problem hiding this comment.
Preserve ability to set models named reserved subcommands
/model now routes status, list, and info to the info path unconditionally, so sessions.patch is never called for those exact model IDs. Since model IDs are user/provider-defined strings (for example configured provider models can use any non-empty id), this introduces a regression for environments where a real model is named one of those values: /model status can no longer select that model and instead always prints model info.
Useful? React with 👍 / 👎.
Addresses review feedback from Greptile — ensures that real model names (e.g. /model gpt-4.1) still correctly call sessions.patch.
|
Codex review: needs real behavior proof before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. Source inspection on current main shows PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge Security Review findings
Review detailsBest possible solution: Land or replace one canonical Control UI fix that routes Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows Is this the best way to solve the issue? No. Avoiding the bad Label justifications:
Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3d96111a5afe. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
Closing this in favor of a narrower, refreshed PR against current Reasons:
Replacement plan (will open under a new PR):
Thanks to all reviewers for the detailed feedback. |
Summary
The WebUI slash-command handler only distinguished between
/model(no args) and/model <name>. Subcommands likestatus,list, andinfowere passed through as literal model names tosessions.patch, causing errors like:Changes
MODEL_INFO_SUBCOMMANDSset (status,list,info) inslash-command-executor.ts/modelreceives one of these subcommands, it routes to the info display path instead of setting the model/model status,/model list, and/model infoshow model info without callingsessions.patchTest Plan
/model status→ shows current model + available models/model list→ shows current model + available models/model gpt-5.2→ still sets the model as before (no regression)Fixes #46894