Skip to content

fix(ui): sync the engine chips when the mobile settings sheet opens - #105

Closed
Its-My-Work wants to merge 1 commit into
Lexus2016:mainfrom
Its-My-Work:fix/mobile-engine-chip-sync
Closed

Its-My-Work wants to merge 1 commit into
Lexus2016:mainfrom
Its-My-Work:fix/mobile-engine-chip-sync

Conversation

@Its-My-Work

Copy link
Copy Markdown
Contributor

Bug

Opening the mobile bottom-sheet settings panel always shows neither the
API nor the Subscription engine chip as selected, even right
after picking one or after defaultEngine resolves.

Root cause

syncMobSheetFromDesktop() re-derives each mobile chip's highlighted
state from the current in-memory cur* variables:

if (group === 'mode') cur = curMode;
else if (group === 'agent') cur = curAgent;
else if (group === 'model') cur = curModel;
chip.classList.toggle('on', v === cur);

There's no engine branch, so for that group cur stays '', which
never equals 'api' or 'subscription' — both chips lose their .on
class every time the sheet opens. curEngine itself and the ★
"default engine" star (synced separately by syncDefaultStar()) are
unaffected, so the underlying selection is actually correct — only the
chip highlighting is wrong, which reads as "my engine choice isn't
saved."

Fix

Add the missing branch:

else if (group === 'engine') cur = curEngine;

One line, mirrors the existing pattern for the other three groups.

🤖 Generated with Claude Code

https://claude.ai/code/session_011E2bJQ2sL9LgEWosjvydTR

syncMobSheetFromDesktop() re-derives each mobile chip's highlighted
state from the in-memory cur* variables, but its if/else chain only
covered mode/agent/model — engine was never assigned, so `cur` stayed
empty and both the API and Subscription chips lost their `.on` class
every time the sheet opened, even though curEngine (and the ★ default
star, which is synced separately) were correct underneath.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011E2bJQ2sL9LgEWosjvydTR
@Its-My-Work

Copy link
Copy Markdown
Contributor Author

Closing — the underlying symptom (402 api_key allotment exhausted while Subscription is selected) is still reproducing, so this wasn't the real fix either. Investigating further before reopening anything.

Lexus2016 added a commit that referenced this pull request Oct 7, 2026
…the first send, sync the mobile chips (#127)

Three ways the UI and the chat disagree about the engine. #103 and #105 proposed two of them and
were withdrawn because they did not cure the reported 402; verifying them in a browser found the
cause they both missed.

- checkVersion() called loadTerminalCapability() before it stored the default engine, and that helper
  lives in the last script block. A reply landing before the parser reached it threw a ReferenceError
  into checkVersion's own catch{}, skipping the configured engine, the chat defaults and loadBots().
  The default is now stored right after applyTmuxCapability(), ahead of every call that can throw.
- send() read curEngine on its 'api' placeholder before /api/version had landed. It now awaits
  engineDefaultReady(): bounded by VERSION_WAIT_MS, skipped for a user who already clicked an engine
  chip (_engineUserPicked), and tied to the local version reply only (the GitHub release lookup moved
  to _checkLatestRelease(), not awaited).
- syncMobSheetFromDesktop() had no engine branch, so opening the mobile sheet blanked both engine chips.

The wait's two extra rules came from an independent review (codex, agy) of the first version; both
defects were reproduced before they were fixed. test/render/engine-default.test.mjs: 18 tests, each
watched failing first. CLAUDE.md test counts corrected (101 = 20 + 81).
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