Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): mark unvisited thread completions unread #15607

Mergedmaria-rcksmerged 9 commits intomain fromrefs/pull/15607/headmerged by juliusmarminge View on GitHub

maria-rckscommented

A never-opened background thread could finish without showing Done because its visit watermark was null. The first nonmaintenance message now initializes that watermark one millisecond before dispatch. Opening the thread clears unread status; untouched imported history and native maintenance commands keep their null watermark.

Closes #3131. Original fix by @maria-rcks, maintained in #15607 with contributor history preserved and main merged.

Verification at dd9511bd00:

  • Minimal regression in the existing control-read suite; launch maintenance and legacy-import assertions cover null preservation. Test selection remains 91 cases across three existing files. Without the implementation: 90 pass, the unread regression fails. With it: all 91 pass.
  • Updated the existing cancellation test to wait for an event after cancellation, so the new initial metadata event cannot satisfy its cleanup barrier. No production cancellation changes.
  • Server typecheck, scoped lint, formatting and diff checks pass; lint reports only existing warnings outside the changed lines.
  • Headless Linux live app: real Codex completions on actual main 9077e818d8 and the candidate. Main retained null and omitted Done; the candidate showed Done, and opening it cleared the badge and advanced its watermark. Disposable API-created project/threads; the copied real-data snapshot was rejected for incompatible migration history. A browser-only local font workaround made captures readable.
  • One independent full-diff review round (Claude Opus 5.5 and Codex GPT-6 Sol) returned no findings. Current-head CI passes, including build/typecheck, lint and all eight server shards; configured bot checks pass. Skipped jobs remain skipped. One canceled fingerprint attempt is superseded by a successful fingerprint run on this head.
  • macOS, Windows, iOS, Android, and Electron desktop were not run. Native mobile rendering remains unverified.
Before: main, no unread completionAfter: first completion shows Done
Before: completed background thread has no Done badgeAfter: completed background thread shows Done

Opening the completed thread clears Done:

Opening the background completion clears Done

Tests: Codex gpt-6-astra (high). Implementation: Codex gpt-6.1-sol (high). Coordination and live proof: gpt-6.1-sol (high), Codex harness through T3 Code. Independent full-diff reviews: Claude claude-opus-5-5 and Codex gpt-6-sol.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 35067c5b-62fb-42c9-99ad-e6a9aa685d93
      📥 Commits

      Reviewing files that changed from the base of the PR and between 17c0878941ab8ab19108fb639c5138d92a89e919 and 050e127e4094cd2e517a5773217a2a9993d56aea.

      📒 Files selected for processing (5)
      • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
      • apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts
      • apps/server/src/orchestration-v2/Orchestrator.ts
      • apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
      • apps/server/src/orchestration-v2/ThreadLaunchService.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

      📝 Walkthrough

      The orchestrator initializes a missing read watermark on a thread’s first non-maintenance dispatch. Codex request handlers reorder two emitted events. Branch-rename metadata updates include the expected worktree path, with tests covering these changes.

      Changes: Read watermark initialization

      Layer / File(s)Summary
      Initialize watermark on first conversation dispatch
      apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts, apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
      A first non-maintenance dispatch sets a missing lastVisitedAt to one millisecond before the current time. Tests cover rejected and accepted dispatches, completion timestamps, retries, unread marking, explicit visit times, and thread launch state.

      Codex request event ordering

      Layer / File(s)Summary
      Order request events
      apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
      Eight request handlers now emit turn_item.updated before runtime_request.updated. Event payloads and other handler behavior remain unchanged.

      Worktree branch rename metadata

      Layer / File(s)Summary
      Constrain branch-rename metadata update
      apps/server/src/orchestration-v2/ThreadLaunchService.ts, apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
      The branch-rename metadata update includes expectedWorktreePath. The cancellation test delays branch-name generation and waits for the rename failure log or stored event before checking run and worktree state.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 050e1

      No actionable merge-blocking risk remains from the reviewed changes; merge after normal checks.

      Security architecture risk: 🔵 Low · up to 050e1

      The changes preserve existing operations and approval controls while improving event ordering and rejecting stale worktree updates. No privilege expansion was established, but some concurrent cancellation and recovery cases remain partially verified.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The assessed security-relevant scope is existing provider approval and input flows plus project worktree metadata. The changes do not establish a new external operation or credential authority. Broader tenant and deployment isolation were not established by the available evidence.

      Trust Boundaries and Controls

      • observed — The existing response control obtains request context using thread and request identity, rejects missing or non-pending requests, rejects non-resumable requests, and verifies the required live provider session exists. These preconditions are not removed by the event-order change.

      Resilience and Maintainability Implications

      • inferred — The expected-path precondition improves containment of stale metadata updates after cancellation, but it is not a generation check or an atomic transaction with Git. Physical renaming still precedes metadata dispatch. Same-path rebinding and reconciliation after rejection remain unresolved; this is bounded uncertainty, not evidence that the PR introduced a security failure.
      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Out of Scope Changes checkWarningThe CodexAdapterV2 changes reorder approval/input timeline updates and actionable requests. The ThreadLaunchService change guards against a late branch rename restoring a cancelled setup worktree. The…Move the CodexAdapterV2 ordering changes and the ThreadLaunchService worktree guard to separately scoped changes, or link issues that require these behaviors.
      Passed Passed checks: 3 passed
      Check nameStatusExplanation
      Linked Issues checkPassedIssue #3131 requires newly started background threads to show unread completion while historical threads remain read. Orchestrator.dispatchMessage now writes a watermark one millisecond before the f…
      Title checkPassedThe title clearly and concisely describes the primary server-side change: marking completions in previously unvisited threads as unread.
      Description checkPassedThe description explains the problem, implementation, linked issue, verification results, screenshots, test coverage, and known platform limitations. It does not use the template headings or provide a…
      Full details: Linked Issues check

      Explanation

      Issue #3131 requires newly started background threads to show unread completion while historical threads remain read. Orchestrator.dispatchMessage now writes a watermark one millisecond before the first non-maintenance dispatch when no visit time exists, then updates the in-memory projection. Completion after that dispatch is newer than the watermark. Existing visit times and maintenance dispatches are unchanged. The added tests cover accepted and rejected dispatches, retries, queued dispatches, and visit-watermark behavior. No change alters the existing handling of settled non-completed turns.

      Full details: Description check

      Explanation

      The description explains the problem, implementation, linked issue, verification results, screenshots, test coverage, and known platform limitations. It does not use the template headings or provide an explicit maintainer approval comment, but the required information is otherwise substantially complete.

      Full details: Out of Scope Changes check

      Explanation

      The CodexAdapterV2 changes reorder approval/input timeline updates and actionable requests. The ThreadLaunchService change guards against a late branch rename restoring a cancelled setup worktree. These changes address approval ordering and setup cancellation, not issue #3131's unread completion status. The PR description connects them to races exposed during implementation, but it does not establish that they are needed for the linked issue.

      Resolution

      Move the CodexAdapterV2 ordering changes and the ThreadLaunchService worktree guard to separately scoped changes, or link issues that require these behaviors.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at dd9511b

      Macroscope's review found this PR approvable — The PR is a focused server bug fix that initializes a read watermark for the first ordinary dispatch on never-visited threads, allowing same-millisecond completions to appear unread without changing imported history or maintenance commands. Targeted tests cover the new behavior and related event-ordering cases.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge added labelsmacroscope-review

    5. Taking over this one. I'll rebuild it on current main, trim the tests to the regression, and push to this branch.

    6. juliusmarminge assignedjuliusmarminge

    7. juliusmarminge merged this818c71d

    8. juliusmarminge closed this

Sign in to join this conversation.