Skip to content

[codex] Fold completed turn work in chat history#2962

Draft
t3dotgg wants to merge 64 commits into
mainfrom
t3code/8154f93e
Draft

[codex] Fold completed turn work in chat history#2962
t3dotgg wants to merge 64 commits into
mainfrom
t3code/8154f93e

Conversation

@t3dotgg
Copy link
Copy Markdown
Member

@t3dotgg t3dotgg commented Jun 5, 2026

Stack

Summary

  • preserve Codex assistant commentary and final_answer phases through runtime ingestion, projection events, and persisted thread messages
  • expose compact historical turn summaries in detailed thread snapshots and keep them synchronized in live client reducers
  • collapse completed-turn commentary and tool activity into an expandable Worked for ... row while keeping the final assistant status visible; retain legacy fallbacks for providers without explicit phase metadata and keep non-completed turns expanded

Verification

  • vp check passes with 9 existing warnings in unrelated files
  • git diff --check
  • pnpm --filter t3 typecheck
  • pnpm --filter @t3tools/web typecheck
  • pnpm --filter @t3tools/client-runtime typecheck
  • pnpm --filter @t3tools/contracts typecheck
  • pnpm --filter t3 test (134 files passed, 1 skipped; 1124 tests passed, 4 skipped)
  • web unit suite (98 files, 1020 tests)
  • client-runtime unit suite (24 files, 177 tests)
  • contracts unit suite (10 files, 148 tests)

Known repository blocker

  • vp run typecheck still fails outside this diff: packages/shared reports missing test-helper exports from vite-plus/test, and effect-codex-app-server#typecheck exits 137. This branch does not modify either package.

Visual verification

  • The Codex in-app Browser surface was unavailable in this session (Browser is not available: iab), so the fold interaction was verified through timeline component logic tests rather than a localhost visual pass.

Note

Fold completed turns in chat history and introduce T3 Cloud relay infrastructure

  • Completed turns in the web chat timeline are now collapsed into a single expandable turn-fold row showing elapsed time; users can toggle details by clicking the row's chevron button, implemented in MessagesTimeline.logic.ts and MessagesTimeline.tsx.
  • An assistantPhase field (commentary | final_answer) is propagated through contracts, projector, reducer, and store to correctly identify the terminal assistant message per turn and drive fold boundaries.
  • A turns array is now tracked on thread state end-to-end (contracts → server projector → client-runtime reducer → web store), enabling turn-level history reconciliation.
  • Introduces a full T3 Cloud relay deployment: a Cloudflare Worker relay with DPoP token issuance and verification, APNs live activity delivery, managed Cloudflare tunnel provisioning, and an Alchemy-based infra stack under infra/relay/.
  • Adds DPoP-bound session support to the server auth layer, including proof verification, replay protection via ServerSecretStore, and dpop-access-token session method.
  • Wires Clerk authentication into mobile (via CloudAuthProvider), web (via ManagedRelayAuthProvider), and desktop (via DesktopCloudAuth IPC bridge and encrypted token store).
  • Mobile agent awareness gains iOS Live Activity sync, APNs push token registration, and relay device registration; the use-remote-environment-registry module is refactored to use Effect for connection lifecycle and supports relay-managed DPoP connections.
  • Risk: The PR is very large and touches auth session handling, WebSocket transport, and persistence migrations (032, 033); DPoP replay protection adds a ServerSecretStore write on every authenticated request.
📊 Macroscope summarized 1184961. 20 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

juliusmarminge and others added 30 commits June 4, 2026 14:02
Co-authored-by: codex <codex@users.noreply.github.com>
refactor: remove cloudflare settings from RelayConfigurationShape and related tests

test: clean up tests by removing cloudflare settings from configuration

feat: implement ManagedEndpointDnsClient for DNS operations with Cloudflare

refactor: simplify ManagedEndpointProvider by removing HTTP client dependencies

fix: update ManagedEndpointProvider to use new DNS client for CNAME record management

chore: adjust Api to use new DNS binding and remove deprecated cloudflare settings

refactor: streamline ManagedEndpointZone creation by removing unnecessary token generation
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge and others added 23 commits June 4, 2026 14:03
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

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: Pro

Run ID: 29b2ba12-c6ba-4fbf-9df8-3cdd610f0bb1

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/8154f93e

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Jun 5, 2026
@t3dotgg t3dotgg changed the base branch from main to codex/relay-managed-tunnels-auth-infra June 5, 2026 01:38
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint a4d508e15be7d8e9790b03e0ebe61fdf29d21234 6c654a51122a41d17f99f247e3d03caeaab0c30a
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: a4d508e15be7d8e9790b03e0ebe61fdf29d21234
App version: 0.1.0
Git commit: 00f9129dc051908b7a7b3cb6c877de1863fdc59c
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 6c654a51122a41d17f99f247e3d03caeaab0c30a
App version: 0.1.0
Git commit: 00f9129dc051908b7a7b3cb6c877de1863fdc59c
Update Details Update Permalink
DetailsBranch: pr-2962
Runtime version: a4d508e15be7d8e9790b03e0ebe61fdf29d21234
Git commit: 00f9129dc051908b7a7b3cb6c877de1863fdc59c
Update Permalink
DetailsBranch: pr-2962
Runtime version: 6c654a51122a41d17f99f247e3d03caeaab0c30a
Git commit: 00f9129dc051908b7a7b3cb6c877de1863fdc59c
Update QR

Comment thread apps/web/src/store.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium

return {

In the thread.reverted case, latestTurn is rebuilt from latestCheckpoint but is never upserted into the turns array. This leaves the entry for latestCheckpoint.turnId with stale values (different state, requestedAt, startedAt, completedAt) while thread.latestTurn has fresh values. Consider using upsertThreadTurn(thread.turns, latestTurn) to maintain consistency with other event handlers.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/store.ts around line 1633:

In the `thread.reverted` case, `latestTurn` is rebuilt from `latestCheckpoint` but is never upserted into the `turns` array. This leaves the entry for `latestCheckpoint.turnId` with stale values (different `state`, `requestedAt`, `startedAt`, `completedAt`) while `thread.latestTurn` has fresh values. Consider using `upsertThreadTurn(thread.turns, latestTurn)` to maintain consistency with other event handlers.

Evidence trail:
apps/web/src/store.ts lines 1606-1656 (thread.reverted case) — latestTurn built at 1641-1653, turns filtered at 1639, no upsertThreadTurn call. Compare with lines 1384, 1482, 1516, 1601 where upsertThreadTurn IS called. upsertThreadTurn defined at lines 890-901.

Base automatically changed from codex/relay-managed-tunnels-auth-infra to main June 5, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants