Skip to content

fix: preserve composer settings on thread creation - #503

Merged
chuks-qua merged 1 commit into
mainfrom
fix/composer-reset-on-new-thread
May 23, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
fix/composer-reset-on-new-thread

Conversation

@chuks-qua

@chuks-qua chuks-qua commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

What

Fix composer model and reasoning settings resetting during new-thread and branch-thread creation.

Why

The app returned or rendered a stale thread row while the first send was still persisting composer settings. That let the composer briefly hydrate from defaults or the parent thread, which changed the selected model, provider, reasoning level, and related configuration before the run started.

Key Changes

  • Persist selected composer settings on server-created new and branched threads before the background send starts.
  • Carry selected model, provider, reasoning, permission, mode, context window, thinking, Codex fast mode, and Copilot agent through optimistic placeholder threads.
  • Preserve the pending composer settings when replacing placeholders with returned thread rows.
  • Add regression coverage for new-thread and branch-thread placeholder hydration.

Verification:

  • bun run typecheck passed: 5 successful, 5 total.
  • cd apps/web && bun run test -- src/__tests__/workspace-behavior.test.ts passed: 1 file, 19 tests.
  • cd apps/server && bun run test -- src/services/__tests__/agent-service-gate.test.ts passed: 1 file, 1 test.
  • git diff --check passed.

Note: bun run test still has unrelated Windows-sensitive server failures in orphan-cleanup, skill-watcher-service, and snapshot-service.integration.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed inconsistent persistence of thread settings (reasoning level, interaction mode, permission mode, context window, and provider-specific options) during thread creation and branching operations.
    • Improved optimistic UI updates to more accurately reflect selected thread configurations before server confirmation.

Review Change Stack

@chuks-qua

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 23, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b25b31fd-ed95-4ce1-8139-e9fdc22e302b

📥 Commits

Reviewing files that changed from the base of the PR and between a2122d7 and c96dc87.

📒 Files selected for processing (4)
  • apps/server/src/services/agent-service.ts
  • apps/web/src/__tests__/workspace-behavior.test.ts
  • apps/web/src/lib/workspace-thread.ts
  • apps/web/src/stores/workspaceStore.ts

📝 Walkthrough

Walkthrough

Server consolidates thread composer settings (reasoning level, interaction modes, context window, thinking, provider-specific flags) into a single updateSettings call and returns normalized thread objects. Client extends placeholder building to accept metadata parameters, passes them through placeholder creation, and hydrates server-resolved threads by merging responses with pending creation parameters. Tests verify the expanded API contract across placeholder and post-resolution phases.

Changes

Thread Composition Settings and Optimistic Hydration

Layer / File(s) Summary
Server-side thread settings consolidation
apps/server/src/services/agent-service.ts
createAndSend consolidates composer-level settings into a unified updateSettings call and returns a thread with normalized permission_mode. createBranchedThread resolves codex_fast_mode earlier, eliminates duplicate updates, and forwards the resolved value to sendMessage.
Client placeholder building with extended metadata
apps/web/src/lib/workspace-thread.ts
buildPlaceholderWorkspaceThread extends its parameter signature to accept optional model, provider, reasoning/interaction/permission/context-window levels and modes, thinking, codex fast mode, and copilot agent. Placeholder fields are now populated from these parameters instead of hardcoded defaults.
Client placeholder creation with metadata forwarding
apps/web/src/stores/workspaceStore.ts
createAndSendMessage and branchThread now pass through additional thread metadata and provider-gated fields when creating optimistic placeholders, enabling later hydration to recover these fields from pending parameters.
Client optimistic success hydration with pending metadata
apps/web/src/stores/workspaceStore.ts
applyOptimisticSuccess retrieves the pending thread-creation payload and constructs a hydratedThread that merges server results with pending metadata, overriding placeholder defaults before inserting into local state. Warnings are attached to the hydrated thread.
Test validation for settings and hydration
apps/web/src/__tests__/workspace-behavior.test.ts
createAndSendMessage and branchThread tests verify that placeholders preserve composer settings before RPC resolution and that final thread rows reflect these settings after hydration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Mzeey-Empire/mcode#437: Both PRs modify AgentService.createBranchedThread settings persistence and thread field handling.
  • Mzeey-Empire/mcode#487: Both PRs wire and persist the Codex fast-mode flag through AgentService methods and thread repository updates.

Poem

🐰 A thread now blooms with settings galore,
From server store to client's door,
Placeholders dance with metadata bright,
Hydrated whole when server writes right,
Composer modes take flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main objective: preserving composer settings during thread creation, which is the primary focus of all changes across the codebase.
Description check ✅ Passed The description follows the template with all required sections completed: What, Why, Key Changes, Config Changes, and includes thorough verification details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chuks-qua
chuks-qua merged commit fee810c into main May 23, 2026
7 checks passed
@chuks-qua
chuks-qua deleted the fix/composer-reset-on-new-thread branch May 23, 2026 22:32
@mze-bot mze-bot Bot mentioned this pull request Jun 9, 2026
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