Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Oct 14, 2025

Problem

The Cmd+Shift+T keybind for toggling thinking would fail in new chats (before any messages were sent). User would press the key and nothing would happen, even though they could see a model selected in the UI.

Root cause: State source mismatch between what the user sees and what the keybind checks:

  • UI shows: selectedModel from localStorage (always available, shown in bottom-left selector)
  • Keybind checked: currentModel from message history (null until first message sent)

User sees "opus" selected, presses Cmd+Shift+T, nothing happens because the keybind was checking message history instead of the selected model.

Solution

Read the selected model from localStorage (using getModelKey(workspaceId)) and fall back to message history model if not set:

const selectedModel = readPersistedState<string | null>(getModelKey(workspaceId), null);
const modelToUse = selectedModel ?? currentModel;

This matches what the user sees in the UI, so the keybind now works immediately in new chats.

Testing

  • ✅ All 502 unit tests pass
  • ✅ TypeScript compilation passes
  • ✅ Lint and format checks pass
  • 🧪 Manual testing: Open new workspace, verify Cmd+Shift+T toggles thinking before sending first message

Changes

  • Net change: +5 lines (adds localStorage read, updates comments)
  • Behavior: Keybind now works in new chats (matches user's mental model)
  • Fallback: Still uses message history model if localStorage is empty (graceful degradation)

Generated with cmux

@ammar-agent ammar-agent marked this pull request as draft October 15, 2025 00:08
The toggle thinking keybind (Cmd+Shift+T) would fail in new chats because it
checked message history for the current model, which is null until the first
message is sent. However, users can see and select a model in the UI
immediately (stored in localStorage).

Root cause: State source mismatch
- UI shows: selectedModel from localStorage (always available)
- Keybind checked: currentModel from message history (null in new chats)

Fix: Read the selected model from localStorage and fall back to message
history model if not set. This matches what the user sees in the UI.

Now the keybind works immediately in new chats, matching user expectations.

_Generated with `cmux`_
@ammar-agent ammar-agent marked this pull request as ready for review October 15, 2025 00:23
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

@ammario ammario enabled auto-merge October 15, 2025 00:25
The review bot correctly identified that with empty localStorage (brand new
workspace or cleared storage), both selectedModel and currentModel would be
null, causing the keybind to still fail.

Now uses the same fallback logic as useSendMessageOptions:
  selectedModel ?? currentModel ?? defaultModel

This ensures the keybind always has a model to work with, matching what the
UI displays (which also defaults to claude-sonnet-4-5).

_Generated with `cmux`_
@ammario ammario added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit dbd7836 Oct 15, 2025
7 checks passed
@ammario ammario deleted the keybind branch October 15, 2025 00:38
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.

2 participants