Skip to content

feat(tui): Ctrl+S in /model picker selects the swarm model; coordinator identity falls back to config default (closes #981) - #1706

Open
alecuba16 wants to merge 1 commit into
1jehuang:masterfrom
alecuba16:fix/swarm-model-picker
Open

alecuba16 wants to merge 1 commit into
1jehuang:masterfrom
alecuba16:fix/swarm-model-picker

Conversation

@alecuba16

Copy link
Copy Markdown
Contributor

Closes #981.

Ctrl+S inside the /model picker opens the swarm model sub-picker, so the swarm model is discoverable from the main model flow instead of only via the agents.swarm_model config. With no override saved, spawned agents inherit the current session model.

Also fixes the coordinator identity root cause from #981: when the persisted session cannot be loaded and resolve_coordinator_spawn_identity has no model, spawn identity now falls back to the config default model instead of silently resolving to a provider default.

Tests: comm_session_tests covers the identity fallback (37/37 pass), TUI tests cover Ctrl+S opening the swarm sub-picker from the model picker and not firing outside it, and provider-init tests are isolated from user env vars so they pass on machines with provider profiles configured. Single commit rebased onto current master.

@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium impact] Adds keyboard shortcut for swarm model selection in the UI.

The PR should not merge until the outstanding late-refresh selection issue is fixed: a catalog refresh can replace the user's chosen model, causing Enter to save the wrong swarm override.

Findings

  1. P1 Refresh drops swarm choices ▶
Fix with agent prompt
### Issue 1
crates/jcode-tui/src/tui/app/inline_interactive/openers.rs:348-353
When the catalog finishes loading after the two-second wait, `retag_picker_for_agent_model_target` drops the `inherit` choice and any saved override missing from the catalog. It also replaces the filtered results with all entries and resets the selection, while leaving the search text visible. Users can no longer clear the override in that picker, and Enter can save a different model from the one they selected.

The delayed-refresh test reproduced this: searching for `gpt-5.5` left that search visible, but completion selected `claude-fable-5`, and Enter saved it as the swarm override. Reuse the full agent-picker setup during refresh, then restore the search and selected choice before merging.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds Ctrl+S to /model so users can choose a swarm model or clear its override.

  • Ctrl+S in /model opens a picker for the swarm model.
  • Spawned agents use the config model when the coordinator session is unavailable.
  • Provider and TUI test setup is more isolated, with formatting cleaned up.

Reviews (8) · Last reviewed commit: "feat(tui): Ctrl+S in /model picker selec..." · Reviewed by Greptile

Comment thread crates/jcode-tui/src/tui/app/inline_interactive.rs
Comment thread crates/jcode-tui/src/tui/app/inline_interactive.rs
Comment thread crates/jcode-app-core/src/server/comm_session_tests.rs Outdated
Comment thread src/cli/provider_init_tests.rs Outdated
@alecuba16
alecuba16 force-pushed the fix/swarm-model-picker branch from 80fc100 to e93f4e6 Compare October 9, 2026 08:15
Comment on lines +348 to +353
picker.filtered = (0..picker.entries.len()).collect();
picker.selected = picker
.entries
.iter()
.position(|entry| entry.is_current)
.unwrap_or(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Refresh drops swarm choices

When the catalog finishes loading after the two-second wait, retag_picker_for_agent_model_target drops the inherit choice and any saved override missing from the catalog. It also replaces the filtered results with all entries and resets the selection, while leaving the search text visible. Users can no longer clear the override in that picker, and Enter can save a different model from the one they selected.

The delayed-refresh test reproduced this: searching for gpt-5.5 left that search visible, but completion selected claude-fable-5, and Enter saved it as the swarm override. Reuse the full agent-picker setup during refresh, then restore the search and selected choice before merging.

Knowledge Base Used: Terminal user interface

Artifacts

Executed regression runner — swarm-refresh-run.py

  • The runner temporarily gates actual catalog construction, executes the scoped cargo test, and restores tracked source files; the actual completion logic remains unchanged.

Passing regression test — swarm-refresh-regression.rs

  • The executed Rust test exercises delayed completion with inherit, saved override, and active search scenarios; all three demonstrate incorrect Enter persistence.

Passing head execution — swarm-refresh-02-after.log

  • The captured cargo output includes the command, working directory, exit code, terminal rendering, picker state, and saved configuration; all three candidate behaviors are confirmed.

Rendered terminal frames — swarm-refresh-02-after-frames.json

  • Actual Ratatui buffer frames and observed state were captured before completion, after completion, and after Enter; they show the disappearing choices and search-selection mismatch.

Earlier search fixture source — swarm-refresh-search-first-test.rs

  • This previously executed test used the original search fixture and stopped at a pre-completion assertion; its source is retained for complete execution provenance.

Earlier search fixture output — swarm-refresh-search-first-run.log

  • The captured failed run confirms inherit and saved-row loss before its search setup assertion fails; the successful retry supersedes that fixture limitation.

Initial unconfigured-route test — swarm-refresh-unconfigured-first-test.rs

  • The initial executed test used unavailable catalog routes; its source explains why that run could not establish override persistence.

Initial unconfigured-route output — swarm-refresh-unconfigured-first-run.log

  • The captured output shows inherit disappearing but Enter rejecting an unavailable route; this was a fixture limitation rather than a separate finding.

Executed upload script — swarm-refresh-upload.py

  • The executed script uploads every proof file through presigned slots, records HTTP results and hashes, and checks tracked restoration; uploads completed successfully.

Upload receipts and restoration check — swarm-refresh-upload.log

  • The captured upload output records successful HTTP responses, exact artifact references, file hashes, and an empty tracked diff; evidence is uploaded and tracked changes are restored.

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-tui/src/tui/app/inline_interactive/openers.rs
Line: 348-353

Comment:
**Refresh drops swarm choices**

When the catalog finishes loading after the two-second wait, `retag_picker_for_agent_model_target` drops the `inherit` choice and any saved override missing from the catalog. It also replaces the filtered results with all entries and resets the selection, while leaving the search text visible. Users can no longer clear the override in that picker, and Enter can save a different model from the one they selected.

The delayed-refresh test reproduced this: searching for `gpt-5.5` left that search visible, but completion selected `claude-fable-5`, and Enter saved it as the swarm override. Reuse the full agent-picker setup during refresh, then restore the search and selected choice before merging.

**Knowledge Base Used:** [Terminal user interface](https://app.greptile.com/solo-systems/-/custom-context/knowledge-base/1jehuang/jcode/-/docs/terminal-user-interface.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ca7c749. Open and the late-refresh retag now share one entry-setup path, so the inherit row and a saved override missing from the catalog always survive the rebuild. The retag also restores the active filter and the selected row after rebuilding, so Enter persists the entry the user actually selected. Regression test covers a saved override with an active search and a moved selection across the refresh landing.

@greptile-apps

This comment has been minimized.

@alecuba16
alecuba16 force-pushed the fix/swarm-model-picker branch 3 times, most recently from a79dcda to 023dc4b Compare October 9, 2026 20:04
Comment thread crates/jcode-tui/src/tui/app/inline_interactive/openers.rs
Ctrl+S inside the /model picker opens the swarm model sub-picker, so the swarm model is discoverable from the main model flow instead of only via agents.swarm_model. With no override saved, spawned agents inherit the current session model. Also fixes the coordinator identity root cause: when the persisted session cannot be loaded and spawn identity has no model, it falls back to the config default model instead of silently resolving to a provider default.

A late catalog load rebuilt the ordinary model picker on completion and agent pickers lost their tags, so Enter could switch the session model instead of saving the override; open and retag now share one entry-setup helper and the retag restores the inherit row, saved overrides missing from the catalog, the filter and the selection. Provider-init tests stop discarding the env values they clear, the Ollama restore list gains the three profile vars it was missing, and the model config literal drops a no-op ..Default::default() that clippy flags since every field is already spelled out. The remote-save concern needs server-side config sync to fix properly and stays a follow-up.

Closes 1jehuang#981.
@alecuba16
alecuba16 force-pushed the fix/swarm-model-picker branch from 023dc4b to a5cf17e Compare October 9, 2026 20:53
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.

Swarm agents use hardcoded/random model instead of inheriting current session model

1 participant