fix(server): persist automatic thread settlement - #5402
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Effect service conventions: the new ThreadSettlementReactor service is introduced with a standalone ...Shape interface, split across Services/ and Layers/, and non-canonical make/layer export names. Inline comments describe the expected shape (canonical single module, inline interface, make/layer, Foo["Service"]), which is the pattern used elsewhere in this repo (for example apps/server/src/workspace/WorkspacePaths.ts, apps/server/src/serverSettings.ts). The settlement policy module, its tests, and the mechanical reactor/harness wiring look fine.
Posted via Macroscope — Effect Service Conventions
There was a problem hiding this comment.
Effect service conventions review: the new ThreadSettlementReactor service is introduced in the older split Services/ + Layers/ shape, rather than as one canonical module with an inline service interface and make/layer exports. Two inline comments below; the rest of the diff (pure threadSettlement.ts helpers, contracts/settings changes, client consumers, test/harness Layer.succeed seams) looks consistent with the conventions.
Posted via Macroscope — Effect Service Conventions
|
Effect service conventions — findings (inline comments could not be attached, posting here): 1. The new service is split across a 2. This is the single implementation of the service and the module is named for it, so the canonical export names are plain export const layer = Layer.effect(ThreadSettlementReactor, make);
No other convention issues found: dependencies are acquired via Posted via Macroscope — Effect Service Conventions |
ApprovabilityVerdict: Needs human review This PR migrates thread auto-settlement from client-computed to server-persisted state, introducing a new You can customize Macroscope's approvability policy. Learn more. |
c2d1810 to
0785884
Compare
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
0785884 to
d2417d3
Compare
d2417d3 to
0631f00
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0631f00. Configure here.

Thread settlement was partly inferred in each client from local clocks and row-level PR state. That let web and mobile disagree, and pinned threads could appear settled for inactivity or a closed PR.
This moves automatic settlement into a server reactor that persists the existing thread settlement event. Pinned threads now ignore inactivity and closed PRs; a merged PR is their only automatic settlement path. Clients render the projected settled timestamp directly, and the inactivity setting is server-owned.
Tested with 203 focused tests plus targeted lint and typechecks across server, contracts, client runtime, web, mobile, and desktop.
Made with GPT-5.6 Sol in T3 Code via the Codex harness.
Note
High Risk
Changes core thread lifecycle and cross-client consistency via a new background reactor, PR/VCS polling, and a settings migration that drops prior client preferences.
Overview
Automatic settlement is now server-owned. A new
ThreadSettlementReactorperiodically reconciles threads and dispatchesthread.settlefor inactivity or merged PRs, usingthreadSettlement.tspolicy (pinned threads skip inactivity; merge settlement respectsthreadAutoSettleOnMerge; closed PRs no longer auto-settle).VcsStatusBroadcasteradds cache-onlypeekStatusand boundedpollStatusfor PR verification without thrashing forge caches.Clients stop inferring settled state. Web, mobile, and desktop drop
effectiveSettled, per-row PR state maps, and client settingssidebarAutoSettleAfterDays/sidebarAutoSettleOnMerge. Lists and banners treat a thread as settled whensettledAtis set; settled-tail ordering uses that timestamp. Auto-settle toggles live in server settings (threadAutoSettleAfterDays,threadAutoSettleOnMerge); mobile writes them across environments viaupdateServerSettings. Old client-only auto-settle keys are stripped on decode and are not migrated.Reviewed by Cursor Bugbot for commit 1eb582b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Persist automatic thread settlement on the server instead of computing it client-side
ThreadSettlementReactoron the server, which periodically reconciles all threads and dispatchesthread.settlecommands when inactivity or PR-merged conditions are met, using server settingsthreadAutoSettleAfterDaysandthreadAutoSettleOnMerge.threadAutoSettleAfterDays,threadAutoSettleOnMerge) fromClientSettingstoServerSettings; client-side sidebar-prefixed settings are removed.settledAttimestamp; client-sideeffectiveSettled,changeRequestAutoSettles, andthreadLastActivityAtutilities are removed.peekStatusandpollStatustoVcsStatusBroadcasterfor cache reads without I/O and partial PR-cache-preserving refreshes; all refresh paths are serialized per working directory.sidebarAutoSettleAfterDays/sidebarAutoSettleOnMergeclient settings will lose those values; settlement behavior is now controlled server-side with defaults of 3 days and merge-settle enabled.Macroscope summarized 1eb582b.