Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web): generate and preserve thread handover drafts #8857

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/8857/headopened View on GitHub

When a thread reaches its context limit, the user has no way to carry the work into a fresh thread without retyping the state by hand.

This adds a handover action on web and mobile. The server generates a continuation brief through an enabled Codex instance (orchestration.generateHandover, advertised by the threadHandoverGeneration capability), and the client opens it as an unsent draft in a new thread in the same checkout, so the user can pick the model and reasoning level before sending. Other providers return a typed "not supported" error. Web persists the generated brief before navigating and shows saved state after remount. Mobile records the import in a durable per-thread draft, so restarting or retrying reopens that draft without duplicating the brief or overwriting later edits.

Depends on unmerged PRs. This branch is cumulative: its first two commits are squashed copies of #10095 (hard context admission, at 61374dce6) and #10097 (shared concurrency reservations, at 1061345fe). Merge those first. The handover delta is the last commit only. This stays a draft until both land.

Rebased linearly onto main at 211618fd9, with no merge commits. Conflict resolutions adopt upstream's composer imports, the mobile GlassBlurTargetContext wrapper, and the threadPullRequests/pullRequestStackActions capabilities. They also fit #10097's reservations into the compaction queue from #11107. Messages sent during compaction are queued ahead of the context-admission and reservation gates, so an over-limit thread no longer rejects them. They replay after compaction lowers usage, and each replay takes its own slot. A new ProviderCommandReactor test covers this.

Verification on 623afe900:

  • Server: 11 files, 446 tests pass (handover, text generation, prompts, environment descriptor, reservations, ProviderCommandReactor, the WebSocket missing-thread handover error in server.test.ts)
  • Web: 4 files, 19 tests pass. Mobile: 3 files, 69 tests pass (includes restart/retry after migrating an older draft receipt). Shared: 9 pass. Contracts: 106 pass.
  • tsc --noEmit passes for contracts, shared, client-runtime, server, web, and mobile. vp lint on changed files: 0 errors.

Still pending: before/after web and mobile screenshots, and a live provider handover run. The cross-provider (GPT-6 Astra) review was skipped because Codex weekly quota was below 10%.

Coordination trace: T3 thread 272cea79-ab91-4570-91a4-10aee73ba516

Originally implemented with GPT-6 Astra in the Codex harness; rebased and verified with Claude Opus 5 in Claude Code.

🤖 Generated with Claude Code

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Team

      Run ID: 18de1247-11e0-4db2-9fa2-dcbbbf9b44fd

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Warning

      Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Two issues in the new context-limit composer banner: it passes fields ComposerBannerStackItem does not declare (urgent, actionClassName), and its className targets Alert slots that the composer banner stack never renders, so the intended emphasis is silently dropped while py-4 overrides the banner primitive's seam padding.

      Posted via Macroscope — UI Consistency
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      components/ChatView.tsx:5019

      ComposerBannerStackItem has no urgent field — priority is expressed as priority: "urgent" | "activity" | "notice" (see ComposerBannerStack.tsx), which is what bannerPriority reads when ordering the stack. As written this is an excess property (typecheck failure) and, once removed, the banner would silently lose its explicit urgent ordering. Sibling items in this file use priority: "activity".

            priority: "urgent",

      No longer relevant as of 04737c262aa0ce35e05bf20874dca9f705e08f89

    4. Reviewed the changed TypeScript against the Effect service conventions. Two findings, both on the new handover path: a text-generation operation bolted onto the provider-snapshot registry instead of the existing TextGeneration service, and an RPC error whose message is derived from cause.message.

      Posted via Macroscope — Effect Service Conventions
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a substantial new cross-platform handover capability that changes existing send/compaction behavior, adds provider-backed generation and durable draft recovery, and introduces a new authenticated RPC. The change also touches the server authorization package, so its runtime and access-control implications require human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Two places in this PR acquire Effect services through Effect.context<never>() + a context as Context.Context<never> cast instead of yield* Foo.Foo, which erases the dependency from the layer's requirement type and turns a missing layer into a silent runtime capability downgrade.

      Posted via Macroscope — Effect Service Conventions
    7. UI consistency review of the changed web surfaces (ChatView.tsx, settings/SettingsPanels.tsx, settingsSearch.ts, usage/*, lib/contextWindow.ts).

      The shared-primitive usage is consistent: the new composer banner uses ComposerBannerStackItem with variant/priority (the earlier excess-prop and dead-slot-override issues are fixed), the usage alert uses Alert/AlertTitle/AlertDescription with an existing warning variant and controlAlignment="first-line", and the new settings row follows the established SettingsRow + NumberField (size="sm", group with decrement/input/increment, unit suffix) pattern with searchableSetting wiring.

      Two behavioral findings on the new context-limit gate are noted inline.

      Posted via Macroscope — UI Consistency
    8. Two issues in apps/web/src/components/ChatView.tsx where the new token-limit gate changes composer behavior beyond blocking a new turn. Everything else in the in-scope web files (shared Alert/Button/NumberField usage, banner stack item shape, settings row + search anchor, Tailwind ownership) looks consistent, and the earlier compaction/gear-routing points are addressed.

      Posted via Macroscope — UI Consistency
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      components/ChatView.tsx:7533

      A non-null sendDisabledReason also swallows the pending-user-input answer path, so a thread that crosses the limit mid-turn can no longer answer the agent's question. ChatComposer derives isSendDisabled from this prop (chat/ChatComposer.tsx:860-862) and submitComposer returns early on it (2146-2151) before the submissionTarget: "pending-user-input" branch — while the pending-answer button in ComposerPrimaryActions.tsx:139-151 deliberately omits isSendDisabled from its disabled, so it still renders enabled and the click (and Enter) is a silent no-op. Note line 861 already suppresses the attachment block reason while activePendingProgress is set for exactly this reason; the external reason bypasses that.

      Consider not reporting the limit while a question is awaiting an answer (activePendingProgress is in scope at line 2416):

                                      : activeThreadReachedContextLimit && activePendingProgress === null

      No longer relevant as of 9fd45859aa5c8d8839855697f4c779f26075f5c9

    9. One new finding this run (inline). The two findings posted on commit 561680f — the sendDisabledReason path also blocking pending-user-input answers, and the DEFAULT_SERVER_SETTINGS fallback making the banner claim a 250,000-token limit the thread's server never set — are unchanged at this head and are not reposted.

      Posted via Macroscope — UI Consistency
    10. Stale Bugbot comment from a previous run.

    11. Stale Bugbot comment from a previous run.

    12. Stale Bugbot comment from a previous run.

    13. Stale Bugbot comment from a previous run.

    14. Stale Bugbot comment from a previous run.

    15. Stale Bugbot comment from a previous run.

    16. Stale Bugbot comment from a previous run.

    17. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 89a2929ed976c2bc9250b0420dfdc1adc8d7b49b. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.