feat(threads): persist manual active thread order - #9729
Conversation
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. |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This change introduces persistent manual active-thread ordering across the client, orchestration protocol, server projections, and database schema, with new user-visible list behavior. The capability is enabled by default and the cross-layer state and migration changes exceed a small, self-contained addition. Not approved because:
Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more. |
3c0b9d9 to
1498abc
Compare
1052255 to
d8f4d86
Compare
## What's Changed * fix(web): show Tux icon for WSL environments by @UtkarshUsername in pingdotgg/t3code#8511 * perf(web): speed up folder menu sorting by @AksharP5 in pingdotgg/t3code#10190 * style(web): fix inconsistencies in new settings layouts by @extoci in pingdotgg/t3code#10177 * feat(threads): persist manual active thread order by @juliusmarminge in pingdotgg/t3code#9729 * feat(mobile): arrange active threads from both thread lists by @juliusmarminge in pingdotgg/t3code#9730 * feat(web): drag threads across sections with consistent motion by @juliusmarminge in pingdotgg/t3code#9731 * feat(web): simplify sidebar drag destination cues by @juliusmarminge in pingdotgg/t3code#9750 * fix(mobile): keep pending tasks queued when a send fails in flight by @juliusmarminge in pingdotgg/t3code#10245 * feat(mobile): show new-task drafts alongside pending tasks in the thread list by @juliusmarminge in pingdotgg/t3code#10260 * feat(mobile): allow several new-task drafts per project by @juliusmarminge in pingdotgg/t3code#10327 * fix(mobile): slide settled threads out before collapsing by @StiensWout in pingdotgg/t3code#10345 **Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260906.1303...v0.0.39-nightly.20260906.1316 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260906.1316
Adopts upstream's manual active-thread ordering (pingdotgg#9729) in place of the fork's own implementation, per Sheehan's call. The decider now emits upstream's `thread.meta-updated` with `activeOrderKey` and its guards (reject deleted/pinned/settled, retain the snooze slot, leave updatedAt alone). The fork's `thread.active-reordered` event is no longer emitted, but its schema, projector, ProjectionPipeline and client reducer cases are deliberately RETAINED: shipped fork databases contain those events and replay must keep decoding them. Conflict resolutions worth remembering: - ProjectionSnapshotQuery: upstream's new `getTurnStartMessage` SELECT omitted the fork's message-correction columns that the shared row schema requires, so every turn start failed to decode (`MissingKey`) and took 14 orchestration tests with it. Added original_text, correction_target_message_id, correction_replacement_text and delivery_state to the SELECT. - ProviderCommandReactor: upstream moved turn-start lookups to the projection and switched the handler to a thread SHELL, which carries only a truncated objectivePreview. The fork's Goal Continuation needs the full Objective, so it re-reads the detail on that path only. `buildSendTurnRequestForThread` also loaded the whole transcript eagerly; it now uses the shell and defers the detail read to the hand-off prelude that actually needs it (this is what upstream's "without loading old message bodies" test asserts). - ProviderRuntimeIngestion: the fork's nullable Continuation messageId flowed into upstream's non-null `getThreadMessageById`; guarded. - OpenCodeAdapter: took upstream's `textPartsByMessageId` and dropped partById/emittedTextByPartId/completedAssistantPartIds (no remaining uses), keeping the fork's turns/context-window/compaction fields. - Migrations: upstream's ProjectionThreadBranchPullRequest appended as fork id 52; upstream's ProjectionThreadsActiveOrderKey NOT registered again — it is byte-identical to the fork's already-shipped id 43. - MessagesTimeline.logic: restored the fork's checkpoint-readiness guard that upstream's relocated copy lacked, so Revert stays hidden until a checkpoint is ready; the two fork tests that drove this through the removed revertTurnCountByUserMessageId prop now build a real ready-checkpoint fixture. - threadCommands: removed duplicate ReorderActiveThreadInput/reorderActiveThread declarations left by a keep-both resolution. - Re-exported helpers upstream's Knip sweep privatized but the fork imports: activeThreadAnchorTimestampMs. - Sidebar.tsx keeps the FORK's drag-and-drop subsystem (drag-to-snooze, overlay ghost, force-settle of a running thread, sidebarActiveThreadSortOrder) over upstream's pingdotgg#9731/pingdotgg#9750 rework; upstream's Sidebar.drag.ts/motion.ts are now referenced only by their own tests. - Guard script: upstream pingdotgg#10101 deleted the client-side ThreadChangeRequestSnapshot atom the linked-PR check pointed at, so the check now follows the badge to its new server-provided source. Verification: all packages typecheck; server orchestration+persistence 603/603, client-runtime 1349/1349, contracts 393/393, web unit 4427 pass. The only web failures are the two fork Goal e2e specs, confirmed failing identically on backup/mtcode-pre-upstream-sync-20260906b. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Active threads always use their default order, so clients cannot save a manual arrangement. This adds a capability-gated
thread.active.reordercommand and persisted fractional order keys, using existing thread metadata events for compatibility with older clients. Reordering leaves activity timestamps unchanged; settling clears the saved active position, while pinning and snoozing preserve it.Reordering reserves retained keys from hidden rows without writing to those rows, including when a keyless section first receives an arrangement.
Verified with 218 focused server, contract, and client-runtime tests covering command decisions, projection migration and replay, snapshots, key allocation, and ordering. This layer has no visual changes; the dependent client PRs contain the UI evidence.
Prepared with Codex.
Note
Medium Risk
Touches orchestration command handling, event projection, and a DB migration on core thread list state; behavior is heavily tested but incorrect replay or invariant gaps could mis-order threads across clients.
Overview
Adds manual ordering for active (non-pinned) threads behind a new
threadActiveReorderserver capability and athread.active.reordercommand that writes fractionalactiveOrderKeyvalues via the existingthread.meta-updatedevent (older clients can ignore the new field).Server/orchestration: The decider rejects reorder on archived, deleted, pinned, or settled threads; reorder does not advance thread activity timestamps. Settling clears
activeOrderKey; pin/snooze/metadata upserts preserve it. Projection pipeline, snapshots, and SQLite migration 048 addactive_order_keywith replay tests so lifecycle upserts do not drop saved placement.Client-runtime: Exposes
reorderActiveThread, shell/detail merge foractiveOrderKey/unsettledAt, reducer/projector parity,sortActiveThreadsByOrderKey(new/reopened threads ahead of keyed order), and widergenerateSpreadPinOrderKeysfor large active lists reusing the pinned reorder planner.Reviewed by Cursor Bugbot for commit 3c0b9d9. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Persist manual active thread order across client, server, and projection
ThreadActiveReorderCommandto the client and orchestration command unions, carrying a thread ID and a trimmed non-empty order key. The server decider emits athread.meta-updatedevent with the key while preserving the thread's existing activity timestamp; deleted, pinned, and settled threads are rejected.activeOrderKeytoOrchestrationThread,OrchestrationThreadShell, andThreadMetaUpdatedPayload. The projector andapplyThreadDetailEventinitialize it tonullon creation, clear it onthread.settled, and apply it only when present inthread.meta-updated.reorderActiveThreadin commands.ts and a serializedreorderActiveenvironment command.sortActiveThreadsByOrderKeyplaces keyless threads before keyed ones and applies deterministic thread/environment tie-breakers.generateSpreadPinOrderKeysnow widens the key space for larger lists.planPinnedReorderskips order keys held by hidden rows when inserting or materializing sections.active_order_keycolumn to projected threads; the projection repository upserts and reads it.ServerEnvironmentadvertisesthreadActiveReorderin its capability descriptor.mergeEnvironmentThreadnow takesactiveOrderKeyandunsettledAtfrom shell metadata instead of retaining cached detail values. Existing readers that relied on stale detail values for those fields will see shell-authoritative values.Macroscope summarized 1052255.