Skip to content

sync: port upstream OpenCode, timestamps, client probe (#3608, #4112, #4132, #4134, #4006, #4137) - #171

Merged
cursor[bot] merged 7 commits into
mainfrom
codex/sync-20260720-server-client-daf2
Jul 20, 2026
Merged

sync: port upstream OpenCode, timestamps, client probe (#3608, #4112, #4132, #4134, #4006, #4137)#171
cursor[bot] merged 7 commits into
mainfrom
codex/sync-20260720-server-client-daf2

Conversation

@aaditagrawal

@aaditagrawal aaditagrawal commented Jul 20, 2026

Copy link
Copy Markdown
Owner

What changed

Ports upstream server/client/runtime fixes from after the Jul 18 ancestry merge:

  • #3608 route OpenCode missing-session errors through Effect
  • #4112 canonicalize client timestamps in the orchestration normalizer
  • #4132 increase OpenCode server startup timeout (5s → 30s)
  • #4134 delete unused agentAwareness phase predicates
  • #4006 defer active thread cache writes
  • #4137 use lightweight connection probe (contracts + client-runtime + server)

Adaptation notes

  • #4006 adapted for fork warm-cache semantics: seeding stays on synchronizing (not live), so the regression test drives live via a socket snapshot. Seed persistence is also gated with shouldPersistThread so active turns are not rewritten into cache.

Validation

  • vp check / vp run typecheck on tip of stack
  • CI re-run after fork warm-cache adaptation

Stack

1 of 6. Base: main. Next: t3-connect layer (#172).

Preserves fork multi-provider runtime, usage monitoring, and orchestration reliability.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added connection probing to verify active server sessions without reconnecting.
    • Older servers continue using the existing configuration request for compatibility.
    • Added support for server probe authorization and capability reporting.
  • Bug Fixes

    • Improved handling of missing or closed provider sessions with structured errors.
    • Reduced unnecessary thread snapshot persistence while turns are actively running.
    • Server startup now allows up to 30 seconds to become ready.
    • Command timestamps are consistently based on server receipt time.

StiensWout and others added 7 commits July 20, 2026 00:31
…gg#3608)

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit d0b9f8d)
Fork warm-cache seeding stays on synchronizing and must not re-persist
active turns. Gate the seed persistence write with shouldPersistThread
and drive the pingdotgg#4006 regression test to live via a socket snapshot.

Co-authored-by: aaditagrawal <aaditagrawal@users.noreply.github.com>
@cursor
cursor Bot merged commit 7bd7727 into main Jul 20, 2026
9 of 12 checks passed
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6e478725-7e06-4f2a-9f17-7c15791b05aa

📥 Commits

Reviewing files that changed from the base of the PR and between 66a897b and fc2520b.

📒 Files selected for processing (16)
  • apps/server/src/environment/ServerEnvironment.test.ts
  • apps/server/src/environment/ServerEnvironment.ts
  • apps/server/src/orchestration/Normalizer.test.ts
  • apps/server/src/orchestration/Normalizer.ts
  • apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
  • apps/server/src/provider/Layers/OpenCodeAdapter.ts
  • apps/server/src/provider/opencodeRuntime.ts
  • apps/server/src/ws.ts
  • packages/client-runtime/src/connection/supervisor.test.ts
  • packages/client-runtime/src/rpc/session.test.ts
  • packages/client-runtime/src/rpc/session.ts
  • packages/client-runtime/src/state/threads-sync.test.ts
  • packages/client-runtime/src/state/threads.ts
  • packages/contracts/src/environment.ts
  • packages/contracts/src/rpc.ts
  • packages/shared/src/agentAwareness.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/sync-20260720-server-client-daf2

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.

❤️ Share

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

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6e478725-7e06-4f2a-9f17-7c15791b05aa

📥 Commits

Reviewing files that changed from the base of the PR and between 66a897b and fc2520b.

📒 Files selected for processing (16)
  • apps/server/src/environment/ServerEnvironment.test.ts
  • apps/server/src/environment/ServerEnvironment.ts
  • apps/server/src/orchestration/Normalizer.test.ts
  • apps/server/src/orchestration/Normalizer.ts
  • apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
  • apps/server/src/provider/Layers/OpenCodeAdapter.ts
  • apps/server/src/provider/opencodeRuntime.ts
  • apps/server/src/ws.ts
  • packages/client-runtime/src/connection/supervisor.test.ts
  • packages/client-runtime/src/rpc/session.test.ts
  • packages/client-runtime/src/rpc/session.ts
  • packages/client-runtime/src/state/threads-sync.test.ts
  • packages/client-runtime/src/state/threads.ts
  • packages/contracts/src/environment.ts
  • packages/contracts/src/rpc.ts
  • packages/shared/src/agentAwareness.ts

📝 Walkthrough

Walkthrough

The PR adds capability-driven server probing, canonicalizes orchestration timestamps, propagates OpenCode session errors through Effect, skips persistence for active threads, increases the OpenCode startup timeout, and removes two awareness helpers.

Changes

Connection probe RPC

Layer / File(s) Summary
Probe contract and server wiring
packages/contracts/src/environment.ts, packages/contracts/src/rpc.ts, apps/server/src/environment/*, apps/server/src/ws.ts
Adds the optional connectionProbe capability, defines and registers serverProbe, authorizes it, implements its successful server response, and verifies the environment advertises the capability.
Capability-driven client probing
packages/client-runtime/src/rpc/session.ts, packages/client-runtime/src/rpc/session.test.ts, packages/client-runtime/src/connection/supervisor.test.ts
Uses serverProbe for capable servers, falls back to serverGetConfig for legacy servers, maps probe errors, and tests request ordering and activation behavior.

Orchestration timestamp canonicalization

Layer / File(s) Summary
Canonical timestamp normalization
apps/server/src/orchestration/Normalizer.ts, apps/server/src/orchestration/Normalizer.test.ts
Replaces client timestamps with the server receipt timestamp, including nested bootstrap timestamps, and propagates the canonical command through normalization.

OpenCode adapter error channel

Layer / File(s) Summary
Effect-based session validation
apps/server/src/provider/Layers/OpenCodeAdapter.ts, apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
Moves missing and closed session failures into the Effect error channel across adapter operations and tests missing-session failures for sendTurn and stopSession.

Active thread snapshot persistence

Layer / File(s) Summary
Conditional snapshot persistence
packages/client-runtime/src/state/threads.ts, packages/client-runtime/src/state/threads-sync.test.ts
Skips persistence while thread sessions are starting or running and verifies active snapshots are not saved during streaming or teardown.

OpenCode startup timeout

Layer / File(s) Summary
Default readiness timeout
apps/server/src/provider/opencodeRuntime.ts
Raises the default OpenCode server startup timeout from 5 seconds to 30 seconds.

Agent awareness exports

Layer / File(s) Summary
Remove phase classifiers
packages/shared/src/agentAwareness.ts
Removes the two exported agent awareness phase-classification helpers.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested labels: vouch:trusted, size:XXL

Suggested reviewers: juliusmarminge

Sequence Diagram(s)

sequenceDiagram
  participant ClientRuntime
  participant RPCSession
  participant WebSocketServer
  participant ServerEnvironment
  ClientRuntime->>RPCSession: probe()
  RPCSession->>WebSocketServer: serverProbe {}
  WebSocketServer->>ServerEnvironment: authorize and handle probe
  WebSocketServer-->>RPCSession: successful empty response
  RPCSession-->>ClientRuntime: probe completes
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/sync-20260720-server-client-daf2

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.

❤️ Share

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants