Skip to content

fix(happy-app): persist session model and effort selections locally#1151

Open
nto2020 wants to merge 2 commits intoslopus:mainfrom
nto2020:fix/happy-app-persist-session-model-effort
Open

fix(happy-app): persist session model and effort selections locally#1151
nto2020 wants to merge 2 commits intoslopus:mainfrom
nto2020:fix/happy-app-persist-session-model-effort

Conversation

@nto2020
Copy link
Copy Markdown

@nto2020 nto2020 commented Apr 21, 2026

Summary

This PR fixes a mobile session UI/state issue where model and effort selections could revert back to default model and xhigh after a session refresh or metadata update.

Root cause

modelMode and effortLevel were only stored in the in-memory session object on the app side.

Two things caused the visible regression:

  • session refresh/metadata merge in applySessions() preserved draft and permissionMode, but did not preserve local modelMode / effortLevel
  • unlike permissionMode, session-level modelMode and effortLevel were not persisted locally

Additionally, effort initialization in SessionView did not consider metadata.currentThoughtLevelCode, so once local state was lost, the UI fell back to the default Codex effort (xhigh).

Changes

  • preserve local modelMode and effortLevel when merging refreshed sessions
  • add local MMKV persistence for session model and effort selections
  • factor local session state resolution into a helper
  • include metadata.currentThoughtLevelCode in effort initialization priority
  • add minimal regression tests for persistence and local session state behavior

Validation

Manually confirmed that:

  • changing the model to gpt-5.2-codex persists in the session UI
  • changing the effort to medium persists in the session UI
  • the values no longer revert to default model / xhigh after refresh/re-entry

Also ran:

  • pnpm vitest run sources/components/modelModeOptions.test.ts sources/sync/persistence.test.ts sources/sync/sessionLocalState.test.ts sources/sync/messageMeta.test.ts sources/sync/storageTypes.spec.ts

Scope

This PR only fixes UI/local persistence and merge behavior.

It does not change the CLI or message meta schema, and it does not make effortLevel affect the actual downstream Codex turn execution yet.

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: cd2d671314

ℹ️ 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 +21 to +23
const started = await waitForDaemonReady()
if (!started) {
throw new Error('Happy daemon failed to become ready')
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 Remove hard 5s daemon startup cutoff

ensureDaemonRunning() now fails if waitForDaemonReady() does not succeed within its default 5 seconds, but daemon startup performs async setup before it can report readiness (notably startDaemon() awaits authAndSetupMachineIfNeeded() before writing daemon state and serving control endpoints). In slow environments (cold disk, delayed config I/O, machine setup latency), this can make normal CLI commands (happy, happy codex, etc.) throw Happy daemon failed to become ready even though the daemon finishes starting moments later.

Useful? React with 👍 / 👎.

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