Repository navigation
fix(tui): handle /model list and /model status as commands - #51270
dinakars777 wants to merge 5 commits into
Conversation
Greptile SummaryThis PR fixes a parsing bug in the Key changes:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/tui/tui-command-handlers.test.ts
Line: 223-231
Comment:
**Missing test for "session not loaded" fallback**
The `else` branch added for `/model status` — `chatLog.addSystem("model: unknown (session not loaded)")` — is never exercised by the new tests. The PR description specifically calls out "Guard against undefined session info" as one of the goals, but the corresponding test only covers the happy path where both `modelProvider` and `model` are populated.
Consider adding a test where `sessionInfo` is left as the default empty object `{}` (or has neither field set) and asserting that the `"model: unknown (session not loaded)"` message is emitted:
```ts
it("handles /model status when session info is not loaded", async () => {
const harness = createHarness();
// sessionInfo stays as {} (default)
const { handleCommand, addSystem } = harness;
await handleCommand("/model status");
expect(addSystem).toHaveBeenCalledWith("model: unknown (session not loaded)");
});
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/tui/tui-command-handlers.test.ts
Line: 214-216
Comment:
**Unnecessary `sessionInfo` assignment in `/model list` test**
`harness.state.sessionInfo` is set to `{ modelProvider: "openai", model: "gpt-4" }` here, but `openModelSelector` never reads `state.sessionInfo` — it only calls `client.listModels()` and then conditionally calls `client.patchSession()` (which is only triggered by an overlay selection that never happens in this test). The extra setup adds noise without adding coverage.
```suggestion
const harness = createHarness({ client });
const { handleCommand } = harness;
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "fix(tui): guard /mod..." |
| it("handles /model status by showing current model", async () => { | ||
| const harness = createHarness(); | ||
| harness.state.sessionInfo = { modelProvider: "anthropic", model: "claude-3" }; | ||
| const { handleCommand, addSystem } = harness; | ||
|
|
||
| await handleCommand("/model status"); | ||
|
|
||
| expect(addSystem).toHaveBeenCalledWith("model: anthropic/claude-3"); | ||
| }); |
There was a problem hiding this comment.
Missing test for "session not loaded" fallback
The else branch added for /model status — chatLog.addSystem("model: unknown (session not loaded)") — is never exercised by the new tests. The PR description specifically calls out "Guard against undefined session info" as one of the goals, but the corresponding test only covers the happy path where both modelProvider and model are populated.
Consider adding a test where sessionInfo is left as the default empty object {} (or has neither field set) and asserting that the "model: unknown (session not loaded)" message is emitted:
it("handles /model status when session info is not loaded", async () => {
const harness = createHarness();
// sessionInfo stays as {} (default)
const { handleCommand, addSystem } = harness;
await handleCommand("/model status");
expect(addSystem).toHaveBeenCalledWith("model: unknown (session not loaded)");
});Prompt To Fix With AI
This is a comment left during a code review.
Path: src/tui/tui-command-handlers.test.ts
Line: 223-231
Comment:
**Missing test for "session not loaded" fallback**
The `else` branch added for `/model status` — `chatLog.addSystem("model: unknown (session not loaded)")` — is never exercised by the new tests. The PR description specifically calls out "Guard against undefined session info" as one of the goals, but the corresponding test only covers the happy path where both `modelProvider` and `model` are populated.
Consider adding a test where `sessionInfo` is left as the default empty object `{}` (or has neither field set) and asserting that the `"model: unknown (session not loaded)"` message is emitted:
```ts
it("handles /model status when session info is not loaded", async () => {
const harness = createHarness();
// sessionInfo stays as {} (default)
const { handleCommand, addSystem } = harness;
await handleCommand("/model status");
expect(addSystem).toHaveBeenCalledWith("model: unknown (session not loaded)");
});
```
How can I resolve this? If you propose a fix, please make it concise.| const harness = createHarness({ client }); | ||
| harness.state.sessionInfo = { modelProvider: "openai", model: "gpt-4" }; | ||
| const { handleCommand } = harness; |
There was a problem hiding this comment.
Unnecessary
sessionInfo assignment in /model list test
harness.state.sessionInfo is set to { modelProvider: "openai", model: "gpt-4" } here, but openModelSelector never reads state.sessionInfo — it only calls client.listModels() and then conditionally calls client.patchSession() (which is only triggered by an overlay selection that never happens in this test). The extra setup adds noise without adding coverage.
| const harness = createHarness({ client }); | |
| harness.state.sessionInfo = { modelProvider: "openai", model: "gpt-4" }; | |
| const { handleCommand } = harness; | |
| const harness = createHarness({ client }); | |
| const { handleCommand } = harness; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/tui/tui-command-handlers.test.ts
Line: 214-216
Comment:
**Unnecessary `sessionInfo` assignment in `/model list` test**
`harness.state.sessionInfo` is set to `{ modelProvider: "openai", model: "gpt-4" }` here, but `openModelSelector` never reads `state.sessionInfo` — it only calls `client.listModels()` and then conditionally calls `client.patchSession()` (which is only triggered by an overlay selection that never happens in this test). The extra setup adds noise without adding coverage.
```suggestion
const harness = createHarness({ client });
const { handleCommand } = harness;
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f21b078b5c
ℹ️ 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".
| if (!args || args === "list") { | ||
| await openModelSelector(); |
There was a problem hiding this comment.
Keep
/model list routed through the agent-aware command path
In the TUI, /model list now aliases to openModelSelector(), which ultimately calls models.list. That RPC is global-only (src/gateway/server-methods/models.ts) and does not receive the current agentId, agentDir, or sessionEntry, while the previous text command path in src/auto-reply/reply/commands-models.ts:379-395 resolved the catalog against the active agent/session. In multi-agent setups with agent-specific model fallbacks or provider config, typing /model list in the TUI can now show the wrong catalog and suggestions for the selected agent.
Useful? React with 👍 / 👎.
| } else if (args === "status") { | ||
| const { modelProvider, model } = state.sessionInfo; | ||
| if (modelProvider && model) { | ||
| chatLog.addSystem(`model: ${modelProvider}/${model}`); | ||
| } else { | ||
| chatLog.addSystem("model: unknown (session not loaded)"); |
There was a problem hiding this comment.
Preserve the full
/model status diagnostic output
This branch now short-circuits /model status to a single state.sessionInfo line, but the existing command handler in src/auto-reply/reply/directive-handling.model.ts:242-357 returned much richer diagnostics: selected vs active runtime model, default model, agent, auth file, and per-provider auth state. After this change, TUI users lose that troubleshooting output entirely, and before session info is loaded they can even get model: unknown even though the gateway could still answer the command correctly.
Useful? React with 👍 / 👎.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open, but this PR is not merge-ready: it targets a real TUI Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, at source level. Current main sends non-empty TUI Is this the best way to solve the issue? No. Reserving Security review: Security review cleared: The diff only touches TUI command handling and colocated tests; I found no dependency, CI, secret, permission, packaging, or supply-chain change. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 578e73f66763. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
/model listbeing parsed as model ID "list" instead of opening model selector/model statusbeing parsed as model ID "status" instead of showing current model/model statuslistModelsis actually calledIssue
Fixes #51126
Testing