Skip to content

macOS: add chat model selector and persist thinking#42314

Merged
vincentkoc merged 6 commits intoopenclaw:mainfrom
ImLukeF:split/macos-model-selector
Mar 11, 2026
Merged

macOS: add chat model selector and persist thinking#42314
vincentkoc merged 6 commits intoopenclaw:mainfrom
ImLukeF:split/macos-model-selector

Conversation

@ImLukeF
Copy link
Copy Markdown
Contributor

@ImLukeF ImLukeF commented Mar 10, 2026

Split from #41560.\n\nScope:\n- macOS chat model selector UX\n- Persist and restore thinking selection in chat state\n- Session-aware picker/chat wiring in OpenClawKit\n- Related macOS/shared UI tests\n\nNo opencode-go provider/onboarding changes in this PR.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR adds a macOS chat model selector and thinking-level persistence for OpenClawKit, introducing listModels, setSessionModel, and setSessionThinking to OpenClawChatTransport, wiring them in MacGatewayChatTransport, and implementing careful model-selection state machine in OpenClawChatViewModel with handling of in-flight race conditions. Thinking-level selection is persisted to UserDefaults and synced to the server.

One verified bug: The persistedThinkingLevel() allowlist in WebChatSwiftUI.swift (lines 313–316) only accepts four levels (["off", "low", "medium", "high"]), but normalizedThinkingLevel() in ChatViewModel.swift (line 938) accepts seven (["off", "minimal", "low", "medium", "high", "xhigh", "adaptive"]). If the server returns an extended level, it can be selected by the user and persisted to UserDefaults, but will be silently dropped on the next launch when persistedThinkingLevel() returns nil. This causes data loss for users who encounter extended thinking levels.

The model-selection race-condition handling (session switches, rapid re-selections, send-gating) is well-designed and thoroughly tested. The PR is accompanied by thorough async unit tests.

Confidence Score: 3/5

  • Safe to merge with one data-loss bug: the thinking-level allowlist mismatch between persistedThinkingLevel() and normalizedThinkingLevel() silently drops extended levels.
  • The PR is well-structured with comprehensive race-condition handling and thorough test coverage. The model-selection state machine is carefully reasoned. However, there is one concrete bug: extended thinking levels ("minimal", "xhigh", "adaptive") can be persisted to UserDefaults but will be silently dropped when the app restarts. This only affects users who encounter server-side extended thinking levels and attempt to persist them across launches, but it is a real data-loss scenario.
  • apps/macos/Sources/OpenClaw/WebChatSwiftUI.swift — the persistedThinkingLevel() allowlist (lines 313–316) must be aligned with the set of levels accepted by normalizedThinkingLevel() in ChatViewModel.swift (line 938).

Last reviewed commit: 70723da

Copy link
Copy Markdown

@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.

Reviewed commit: 70723da3ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Copy Markdown

@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.

Reviewed commit: 0605d2b700

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@vincentkoc vincentkoc force-pushed the split/macos-model-selector branch from 0605d2b to a7f7c52 Compare March 11, 2026 04:36
@vincentkoc vincentkoc merged commit 061b825 into openclaw:main Mar 11, 2026
21 checks passed
Copy link
Copy Markdown

@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.

Reviewed commit: a7f7c5227b

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +551 to +553
guard requestID == self.latestModelSelectionRequestIDsBySession[sessionKey] else {
self.applySuccessfulModelSelection(next, sessionKey: sessionKey, syncSelection: false)
return
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 Badge Ignore stale model-patch completions

When two selectModel requests overlap for the same session (e.g. user picks A, then B quickly), this stale-completion branch still applies the older selection after it returns. If B completes first and A completes later, applySuccessfulModelSelection(next, ...) here rewrites local session model state to A without reapplying B, so the backend and UI can drift to the wrong model under normal network reordering. This causes subsequent sends to run on an older model despite the picker showing the newer choice.

Useful? React with 👍 / 👎.

@ImLukeF ImLukeF deleted the split/macos-model-selector branch March 11, 2026 04:46
frankekn pushed a commit to MoerAI/openclaw that referenced this pull request Mar 11, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
frankekn pushed a commit to Effet/openclaw that referenced this pull request Mar 11, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
frankekn pushed a commit to ImLukeF/openclaw that referenced this pull request Mar 11, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Treedy2020 pushed a commit to Treedy2020/openclaw that referenced this pull request Mar 11, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
mrosmarin added a commit to mrosmarin/openclaw that referenced this pull request Mar 11, 2026
* main: (49 commits)
  fix(agents): add nodes to owner-only tool policy fallbacks
  fix(gateway): propagate real gateway client into plugin subagent runtime
  fix(gateway): enforce caller-scope subsetting in device.token.rotate
  fix(terminal): stabilize skills table width across Terminal.app and iTerm (openclaw#42849)
  fix(models): guard optional model input capabilities  (openclaw#42096)
  macOS/onboarding: prompt for remote gateway auth tokens (openclaw#43100)
  fix(macos): use foundationValue when serializing browser proxy POST body (openclaw#43069)
  feat(ios): add local beta release flow (openclaw#42991)
  docs(changelog): update context pruning PR reference
  fix(context-pruning): cover image-only tool-result pruning
  fix(context-pruning): prune image-containing tool results instead of skipping them (openclaw#41789)
  fix(agents): include azure-openai in Responses API store override (openclaw#42934)
  fix(telegram): fall back on ambiguous first preview sends
  fix(telegram): prevent duplicate messages with slow LLM providers (openclaw#41932)
  Providers: add Opencode Go support (openclaw#42313)
  fix(sandbox): sanitize Docker env before marking OPENCLAW_CLI (openclaw#42256)
  macOS: add chat model selector and persist thinking (openclaw#42314)
  fix: clear pnpm prod audit vulnerabilities
  fix(build): restore full gate
  fix(gateway): split conversation reset from admin reset
  ...
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
ahelpercn pushed a commit to ahelpercn/openclaw that referenced this pull request Mar 12, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Ruijie-Ysp pushed a commit to Ruijie-Ysp/clawdbot that referenced this pull request Mar 12, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
leozhengliu-pixel pushed a commit to leozhengliu-pixel/openclaw that referenced this pull request Mar 13, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
plabzzxx pushed a commit to plabzzxx/openclaw that referenced this pull request Mar 13, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
wdskuki pushed a commit to wdskuki/openclaw that referenced this pull request Mar 16, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
t--becker pushed a commit to t--becker/openclaw that referenced this pull request Mar 19, 2026
* feat(macos): add chat model selector and thinking persistence UX

* Chat UI: carry session model providers

* Docs: add macOS model selector changelog

* macOS: persist extended thinking levels

* Chat UI: keep model picker state in sync

* Chat UI tests: cover model selection races

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants