Skip to content

🤖 feat: backend fork copies AI settings and sends persist auto-routing flags - #5894

Closed
ibetitsmike wants to merge 2 commits into
mike/server-side-prefs-backup-cdnfrom
mike/server-side-ai-backend
Closed

ibetitsmike wants to merge 2 commits into
mike/server-side-prefs-backup-cdnfrom
mike/server-side-ai-backend

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The backend now holds every per-workspace AI pick that a fork or a send needs, so later layers can drop the renderer's localStorage copies of them.

  • A fork copies the parent's agentId, aiSettings and aiSettingsByAgent into the new workspace's metadata. Before, only the renderer's copy of the localStorage keys carried them over.
  • Each aiSettingsByAgent entry gains two optional flags, autoModelRouting and autoThinkingLevel (WorkspaceAgentAISettingsSchema). A send saves them for its agent, and a flag the send leaves out means off. A send can instead name the choices to save in the new savedAutoRouting option, so a plan handoff can run unrouted and still keep the agent's Auto choices. Picker updates never carry the flags and keep the stored values.
  • A sub-agent reawakening (applyAgentTaskTurnAiSnapshot) keeps the child's saved Auto flags. The reawaken inputs key ignores them because planning does not read them, so a flag-only change cannot refuse a reawaken.

Stack

Milestone M4 of the server-side settings stack, on top of M3 (#5869 to #5879): per-workspace AI picks (model, thinking level, reasoning mode, agent and Auto routing) are stored in workspace metadata in config.json instead of per-browser localStorage keys, so every browser shows the same picks. An unsent picker change stays in memory in its tab until a send saves it, and a reload before sending drops it, as the plan accepts. Layer 1 of 20.

The stack moves one pick at a time: this layer adds the backend fields, #5895 adds the renderer resolver, #5896 lets it resolve custom agents' inherited defaults anywhere, #5897 carries unsent picks into forks, #5901 to #5907 move model, thinking level and reasoning mode onto it, #5908 to #5912 move the agent and Auto routing and delete their keys, and #5913 deletes keys that had no live reader.

Testing

  • "fork keeps the parent's AI selection and marks the new workspace as pending auto-title when a continue message is queued" (workspaceService.fork.test.ts): the fork's saved metadata carries the parent's agent, settings and per-agent settings with both Auto flags.
  • The send persistence test in workspaceService.aiSettings.test.ts sends both Auto flags and expects them in the agent's saved entry.
  • "a send saves the Auto choices it carries: %j" (same file): a send without Auto clears saved flags, and savedAutoRouting wins over the send's own flags in both directions. "a picker update keeps the saved Auto choices": updateAgentAISettings leaves them alone.
  • "keeps the child's saved Auto choices" and "ignores Auto flags, which planning does not read" (agentTaskReawakenAi.test.ts): a reawaken keeps the flags, and a flag-only change leaves the inputs key unchanged.
  • make static-check and the touched test suites pass at the top of the stack; CI checks each layer on its own.

Review record

…flags

The backend now holds every per-workspace AI pick a fork or send needs, so later
layers can drop the renderer's localStorage copies of them.

Stack-Layer: A1
…kening

A send can carry savedAutoRouting, which the backend saves for the agent instead of the
send's own Auto flags, so a plan handoff can send unrouted and still keep the target
agent's Auto choices. A sub-agent reawakening keeps the saved Auto flags, and its inputs
key ignores them. Adds tests for a send without Auto clearing saved flags and for picker
updates keeping them.

Stack-Layer: A1
@ibetitsmike
ibetitsmike added this pull request to stack #5868 October 8, 2026 21:03
@ibetitsmike ibetitsmike changed the title mike/server side ai backend 🤖 feat: backend fork copies AI settings and sends persist auto-routing flags Oct 8, 2026
@ibetitsmike
ibetitsmike marked this pull request as ready for review October 8, 2026 21:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T21:35:21.213437Z d7dcafd Draft marked ready
🔒 Security Review ✅ Completed 2026-10-08T21:34:44.294239Z d7dcafd Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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

ℹ️ 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 thread src/node/services/workspaceService.ts
@ibetitsmike

Copy link
Copy Markdown
Contributor Author

Landed in #5916 (7b9899d), which collapsed this stack into one squash merge.

@ibetitsmike ibetitsmike closed this Oct 9, 2026
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Oct 9, 2026
…der#5916)

## Summary

Lands the server-side preferences work in one squash merge. Every user
preference and every per-workspace AI choice now lives only on the
server (`config.json` `userPreferences` and workspace metadata);
browsers keep no copies in localStorage. This PR replaces the reviewed
stacks coder#5844-coder#5879 (preferences) and coder#5894-coder#5913 (workspace AI picks),
so the merge queue runs once. Experiments landed earlier in #5833.

## What changes

- **Preferences** (appearance, terminal, review, notifications, AI and
provider defaults, compaction thresholds, sidebar, usage and analytics
choices, tutorial state, power mode, git status mode) follow the user
across browsers and update live. Edits go to the server as per-key merge
patches (`config.updateUserPreferences`); `config.saveConfig` no longer
accepts `userPreferences`. Old localStorage keys are never read again
(`uiTheme` stays as a first-paint cache); formerly browser-local values
reset once.
- **Workspace AI picks** (model, thinking, reasoning mode, agent, Auto
routing) resolve from workspace metadata plus an unsent in-memory pick,
which the next send saves. Forks copy the source's AI settings and
unsent picks. Retired workspace AI keys are deleted at startup, in the
desktop app and the VS Code webview.
- No import of old local values and no downgrade handling, by design.

## Review record

- Per layer: Codex reviewed the preference layers over 7 rounds and the
AI-pick layers over 2 rounds; every finding was fixed or answered on its
thread.
- On this PR: Codex rounds 1 (3 findings), 2 (5), 3 (3), 4 (4), 5
(none), 6 (4), 7 (none) and 8 (1), plus the 6 AI-pick layer findings
still open after their round 2, are fixed here or answered on their
threads. Declined with reasons: importing old local preference values,
keeping the `userPreferencesInitialized` marker and mapping legacy theme
names (the plan rules out migration and downgrade handling and resets
legacy themes), clearing cached agent bases during a reload, pruning
project-keyed preferences of removed projects (the plan keeps them), a
timeout for the startup telemetry event (it can only be sent once
connected), having a send wait only for the compaction threshold write
(the plan has it wait for all pending preference writes, which share one
request), and refusing an initial `/goal` when the creation settings
save is rejected (same on main; follow-up below).
- Remote UAT: PASS at fed9ae5 (round 1). FAIL at 8cbf748 (round
2): a default model save cut off by a lost connection said "Settings
could not be saved" although it landed, and a model pick sent with Auto
on never ended, so the next send wrote it back over another window's
change. Both fixed in f7db7b4. PASS at f7db7b4 (round 3): both
fixes, the startup gate (frozen backend, token prompt) and a regression
smoke. FAIL at 453a1e7 (round 4): the round 6 fixes (fork start
message, full-width toggle, Auto choices while the experiment is off)
passed, but when two windows sent within about 200 ms, the first kept
showing its own pick and its next send wrote it back over the other
window's choice. Fixed in ed42346. PASS at ed42346 (round 5, the
final head): the two-window send race in 19 timed runs, the other pick
kinds, the single-window send without races, and a smoke of the earlier
fixes.
- Pixel / Review snapshots need a human reviewer.

## Testing

- `make static-check` on the final head; Bun suites for the touched
areas (renderer, workspace and task services, backup and context); Jest
UI suites for the composer and plan flows; VS Code extension suite (162
tests).
- Red-green for every review fix: removing the fix, or unwiring its call
site, fails its test.

## Follow-ups

- VS Code webview: forward project and global AI defaults, limited to
the projects of the shown workspaces. Until then it falls back to
per-agent and app defaults, as on main.
- Workspace creation with an initial `/goal`: refuse or recover the goal
setup when the creation AI settings save is rejected, instead of letting
the kickoff use the previously saved settings (as on main).

## Risks

Broad but mostly deletion (+6.2k/-9.8k). Highest-risk areas: first paint
before the config snapshot arrives, concurrent edits from two windows
(last write per key wins), and the AI pick lifecycle around sends,
creation, forks and reloads.
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