Skip to content

Fix /model picker confirm flow discarding correctly-resolved selections - #254

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/model-picker-confirm-flow
Aug 5, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/model-picker-confirm-flow

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

  • The reported symptom was openai-codex/luna is not found after selecting gpt-5.6-luna from the /model picker. The suspected cause was hyphen-splitting of model ids, but no such splitting exists anywhere in the codebase.
  • Actual root cause: the picker's Enter-key confirm handler (crates/forge-tui/src/overlays.rs, ConnectModelColumn::Models arm) compared the raw typed filter text against the full resolved catalogue id ("luna" vs "openai-codex/gpt-5.6-luna"). Since a substring filter is almost never byte-equal to the canonical id, the already-correctly-highlighted row was discarded and re-dispatched as free-text /model luna, which then got re-prefixed to a nonexistent openai-codex/luna.
  • Fix: trust the resolved catalogue row whenever one exists (the substring filter already resolves it correctly); only fall back to free-text /model <arg> when there is genuinely no matching row at all.
  • Introduces ModelSelection (provider/model/profile_id/effort) in forge-connect as a single structured value threaded from catalogue row → picker confirm → active app state → persistence → outbound request, via one new TuiApp::apply_selection() setter. Replaces four independently-assigned fields (runtime.model_label, runtime.provider, connect.profile, reasoning_effort.value) that could previously drift apart — which is exactly the failure mode the picker bug demonstrated. No on-disk format change; persistence still uses the existing flat TOML keys, composed into ModelSelection at the store boundary only.

Test plan

  • New unit tests in overlays.rs: typing a substring of a real catalogue id (luna for openai-codex/gpt-5.6-luna) now confirms the resolved row instead of falling back to free text; genuinely unlisted text still falls back correctly; empty-filter Enter still selects the current row.
  • New integration tests in app/tests/connect.rs: selecting the current model (no-op), switching models via a partial filter (the literal repro path), changing reasoning effort after a switch, cancelling at the Models and Effort columns (state untouched), restart/restore via restore_saved_auth, and the first outbound ModelRequest after a switch carrying the exact complete id.
  • cargo test --workspace — all green except two pre-existing, unrelated failures on this machine (documented forge-config permissions tests reading real repo files)
  • cargo clippy --workspace --all-targets clean
  • cargo fmt --all -- --check clean

The picker's Enter-key handler compared the raw typed filter text
against the full resolved catalogue id (e.g. "luna" vs
"openai-codex/gpt-5.6-luna"), which almost never matched, so an
already-correctly-resolved row was discarded and re-dispatched as
free-text "/model luna" — which then got wrongly re-prefixed to
"openai-codex/luna", a model that doesn't exist.

Trust the resolved row whenever one exists; only fall back to
free-text when the filtered row list is genuinely empty. Also
introduce ModelSelection (provider/model/profile_id/effort) as a
single structured value threaded through picker confirm, default-model
application, quick switch, and restore-on-restart, replacing four
independently-assigned fields that could drift apart.
@github-actions
github-actions Bot enabled auto-merge (squash) August 5, 2026 06:49
@github-actions
github-actions Bot merged commit 1fb9c39 into main Aug 5, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
…ns (#254)

* Fix /model picker confirm flow discarding correctly-resolved selections

The picker's Enter-key handler compared the raw typed filter text
against the full resolved catalogue id (e.g. "luna" vs
"openai-codex/gpt-5.6-luna"), which almost never matched, so an
already-correctly-resolved row was discarded and re-dispatched as
free-text "/model luna" — which then got wrongly re-prefixed to
"openai-codex/luna", a model that doesn't exist.

Trust the resolved row whenever one exists; only fall back to
free-text when the filtered row list is genuinely empty. Also
introduce ModelSelection (provider/model/profile_id/effort) as a
single structured value threaded through picker confirm, default-model
application, quick switch, and restore-on-restart, replacing four
independently-assigned fields that could drift apart.

* Remove duplicate Tokyo Night theme
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ns (#254)

* Fix /model picker confirm flow discarding correctly-resolved selections

The picker's Enter-key handler compared the raw typed filter text
against the full resolved catalogue id (e.g. "luna" vs
"openai-codex/gpt-5.6-luna"), which almost never matched, so an
already-correctly-resolved row was discarded and re-dispatched as
free-text "/model luna" — which then got wrongly re-prefixed to
"openai-codex/luna", a model that doesn't exist.

Trust the resolved row whenever one exists; only fall back to
free-text when the filtered row list is genuinely empty. Also
introduce ModelSelection (provider/model/profile_id/effort) as a
single structured value threaded through picker confirm, default-model
application, quick switch, and restore-on-restart, replacing four
independently-assigned fields that could drift apart.

* Remove duplicate Tokyo Night theme
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ns (#254)

* Fix /model picker confirm flow discarding correctly-resolved selections

The picker's Enter-key handler compared the raw typed filter text
against the full resolved catalogue id (e.g. "luna" vs
"openai-codex/gpt-5.6-luna"), which almost never matched, so an
already-correctly-resolved row was discarded and re-dispatched as
free-text "/model luna" — which then got wrongly re-prefixed to
"openai-codex/luna", a model that doesn't exist.

Trust the resolved row whenever one exists; only fall back to
free-text when the filtered row list is genuinely empty. Also
introduce ModelSelection (provider/model/profile_id/effort) as a
single structured value threaded through picker confirm, default-model
application, quick switch, and restore-on-restart, replacing four
independently-assigned fields that could drift apart.

* Remove duplicate Tokyo Night theme
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.

1 participant