Read GitHub issue and related content.
UnderstandAdded changelog entry.
EditRan tests to confirm changes.
VerifyAnalyze GitHub issue(s): https://github.com/badlogic/pi-mono/issues/844
For each issue:
Do NOT implement unless explicitly asked. Analyze and propose only.
Planning GitHub issue view
I'm preparing to implement a GitHub issue viewing feature using Bash.
>gh issue view 844 --json title,body,comments,labels,statePlanning repo exploration
I'm preparing to search key directories like packages/coding-agent and tui to identify relevant files for analysis.
>rg -n "scoped-models|scoped models|scoped_models|scopedModels|models scope|--models" packagesResolving full file read conflict
The interactive-mode file may exceed the 50KB read limit, so I'll read it in chunks using offset/limit despite the rule, ensuring I capture its entirety before analysis.
Verifying file sizes before full reads
I'm checking file sizes with line counts to determine if full reads without truncation are feasible before deciding how to read large files for analysis.
>wc -l packages/coding-agent/src/modes/interactive/interactive-mode.ts packages/coding-agent/src/core/agent-session.ts packages/coding-agent/src/modes/interactive/components/scoped-models-selector.tsResolving file read limits
I'm planning to read large files in full by using multiple offset/limit calls despite guidance against offset/limit on full reads, since single reads would truncate; smaller files will be read fully without offsets to comply when possible.
Planning chunked file reads
I'm preparing to read two large files in segments using offset and limit to handle tool line limits, splitting interactive-mode into two parts (1-2000, 2001-3768) and agent-session similarly (1-2000, 2001-2349).
Planning partial file reads
I'm deciding to read the file in two partsālines 1545 to 3544 first, then 3545 to 3768āby setting appropriate offsets and limits for efficient processing.
Identifying need for agent-session
Reading model selector component
I'm inspecting the model selector component code to understand its structure and functionality for integration in the /model route.
Planning to trace scoped models persistence
I'm identifying that scoped models persist via settings into session.scopedModels, causing UI hints and filtering. I'll check main.ts and model-resolver files fully to locate where scoped models get saved to settings and restored to session, starting by assessing main.ts file size.
>wc -l packages/coding-agent/src/main.ts packages/coding-agent/src/core/model-resolver.ts packages/coding-agent/src/core/settings-manager.tsPlanning full reads and settings manager
Identifying needed components
Identifying need for settings manager
Noticing conflation of scoped models
Scoped models from persisted settings are incorrectly restricting the full model list in /model, causing /model to use session.scopedModels as a filter when it should show the full list unless limited by CLI flags; this suggests the need to distinguish cycle scope from selector scope and track scoped model sources separately.
Planning to track scoped model source
I'm proposing to add a session property indicating whether scoped models come from CLI or settings, so /model can show the full list unless scoped by CLI flags, while cycling (Ctrl+P) still respects scoped models from settings; this decouples model selector filtering from persisted scopes and aligns with expected behavior.
>wc -l packages/coding-agent/src/core/sdk.tsIdentifying root cause of persistent scoping
Scoping always applies in /model because session.scopedModels is populated from settings.enabledModels, not just CLI input. The fix will track the source of scoped modelsāCLI, settings, or session-onlyāand only apply scoping when explicitly passed via CLI or a dedicated flag. I'll update session creation to signal scope origin and adjust logic accordingly.
Proposing fix to restrict model scoping to CLI
The root issue is that /model and autocomplete filter using session.scopedModels sourced from settings.enabledModels, causing unwanted scoping even without CLI flags. The fix is to track scoped modelsā origin in session configārestrict selection only if models come from CLI --models. Interactive mode and ModelSelectorComponent should use this flag to decide whether to filter models or show all. The main change involves passing a scope flag from main.ts into AgentSession, then using it to conditionally apply scoping in interactive features.
Issue 844 analysis
Summary of issue
Saving a scoped model selection persists enabledModels in settings. On the next run, /model only shows those scoped models and displays the --models scope hint. There is no way to view the full model list unless scoped models are cleared.
Root cause
The /scoped-models selector writes enabledModels to settings. On startup, main.ts uses parsed.models ?? settingsManager.getEnabledModels() to resolve scopedModels. That list is passed into the session and used by /model and autocomplete. The model selector and /model candidates always use session.scopedModels when the list is non empty, even if the scope came from settings rather than the CLI flag. This makes /model behave as if --models was provided.
Code path
ScopedModelsSelectorComponent persists to SettingsManager.setEnabledModels()main.ts uses settingsManager.getEnabledModels() to populate scopedModelsInteractiveMode.setupAutocomplete and InteractiveMode.getModelCandidates use session.scopedModelsModelSelectorComponent uses its scopedModels input to filter the model list and show the scoped hintProposed fix
Track the source of scoped models and only restrict /model when scope comes from the CLI --models flag. Scoped models from settings should still be used for Ctrl+P cycling but should not constrain the /model list or /model autocomplete.
Suggested approach
restrictModelSelectionToScopedModels: boolean.main.ts to true only when parsed.models is provided.AgentSession and expose a getter.InteractiveMode to use the flag for /model candidates and for ModelSelectorComponent input.ModelSelectorComponent to show the scoped hint only when the flag is enabled.Affected files
packages/coding-agent/src/main.tspackages/coding-agent/src/core/sdk.tspackages/coding-agent/src/core/agent-session.tspackages/coding-agent/src/modes/interactive/interactive-mode.tspackages/coding-agent/src/modes/interactive/components/model-selector.tsi think we should implement the suggestion by the user. model selector listens for tab key press and that switches between all models or scoped models. but only when scoped models are given.
the tui should show a hint that TAB switches between all and scoped models, and it should show the current model "scope" selection.
Planning toggle implementation
I'm preparing to add toggle state to the model selector for switching between scoped and all models, verifying key handling options to use Tab without conflicting with autocomplete, and searching for existing key match utilities to integrate.
>rg -n "Tab|tab" packages/coding-agent/src/modes/interactive/componentsPlanning consistent keybinding hints
I'm deciding to align the model selector keybinding hints with the tab key approach by using the same key matching method and possibly leveraging the existing keyHint function from keybinding-hints for themed hint display instead of plain text.
Planning scoped model toggle hint
The model selector needs state to track current scope ("scoped" or "all"), defaulting to "scoped" if scoped models exist. I'll add a header line showing the current scope and a Tab hint to switch scopes, only if scoped models are available; otherwise, just show API key hints. The Tab toggle must only activate when scoped models exist, and I'll consider updating autocomplete to reflect scope changes.
Detailing scope toggle implementation
I'm outlining comprehensive changes to ModelSelectorComponent: adding a modelScope state with "scoped" or "all" modes, showing a dynamic header line with current scope and a Tab key hint (using keyHint), and updating model loading and filtering on toggle. The Tab toggle only activates if scoped models exist, and the UI falls back to the existing API key hint otherwise. The plan prioritizes keeping user query and smoothly refreshing models on scope switches.
Replacing hint with dynamic scope header
I'm replacing the static model filtering hint with a dynamic scope header line that reflects the current model scope and shows a Tab toggle hint. The scope line uses theme colors and returns a warning message if no scoped models exist. The loadModels method will select models based on the current scope, and input handling will toggle scope on Tab when scoped models are available.
Verifying if-insertion logic
I'll review the full file to confirm the new if-statement was inserted correctlyābefore Enter and after up/downāand check whether tab handling before up/down applies. This verification ensures the insertion fits logically within the handleInput block.
Reviewing key input handling logic
The tab key handler runs separately after selectDown without else if, which is acceptable since conditions don't conflict, but could be unified for consistency. Also considering updating scope selection display and clearing error messages when toggling scope, especially when no scoped models are available.
Planning error message reset on scope switch
Error messages from previous scope remain when switching between all and scoped models, causing stale errors to show; I'll clear errorMessage at the start of loading models and when switching to scoped to prevent this.
Clarifying scope line behavior and tab hint
The scope line shows current scope selection only when scoped models exist, and the tab key hint appears then to indicate switching scopes. When no scoped models are available, no scope line or tab hint is shown, aligning with requirements. No code changes or tests are needed.
Summary:
Updated packages/coding-agent/src/modes/interactive/components/model-selector.ts to add Tab-based scope toggling between scoped and all models when scoped models exist, with a scope line that shows current selection and the Tab hint.
Tests not run.
ok, i have a different impl in ../pi-mono-codex/. i want that one, it has better ui in /model. can you investigate and copy this to this impl?
Which file(s) in ../pi-mono-codex should I compare and copy from? Give the paths for the model selector UI implementation.
it's the same file you modified in this clone. the other folder is an alternative clone
Planning cross-repo file read
I need to read a full file from another repo using the read tool before editing, specifying the read path accordingly.
Overwriting file with updated content
Summary:
Replaced packages/coding-agent/src/modes/interactive/components/model-selector.ts with the implementation from /Users/badlogic/workspaces/pi-mono-codex to match the improved /model UI.
Tests not run.
looking good, commit and push, and close the issue with a comment in my tone explaining what we implemented
Preparing final git actions and issue closure
>npm run check>git status -sbPreparing to rebase before push
>git pull --rebaseCommitting before pull with rebase
I'm adding and committing changes before pulling with rebase to handle being behind origin, then will push afterward.
>git add packages/coding-agent/src/modes/interactive/components/model-selector.tsCommitting toggle improvement
Committing the fix for the scoped toggle in the /model area with a concise descriptive message.
>git commit -m "fix(coding-agent): improve model scope toggle"Pulling latest changes with rebase
>git pull --rebasePushing changes
>git pushComposing issue close comment
Implemented model scope toggle via Tab key. It shows a scope line and hint, supports scoped list or all, and saves the selection automatically.
>gh issue close 844 -c "Fixed in main. /model now shows a scope line and Tab toggles between all models and scoped models when a scope exists. The list is no longer stuck in scoped-only view unless you choose it."Summary:
packages/coding-agent/src/modes/interactive/components/model-selector.ts.Tests:
>git pulladd a changelog entry
Preparing to edit changelog
I'll read the entire changelog file without an offset to ensure I have the full context before making edits.
Adding changelog entry for issue
Checking git status before commit
>git status -sbCommitting and pushing changes
>git add packages/coding-agent/CHANGELOG.md>git commit -m "docs(coding-agent): add changelog entry for model scope toggle">git pushSummary:
## [Unreleased] in packages/coding-agent/CHANGELOG.md.Tests: