Skip to content

fix(link): ensure the desktop sandbox on the remoteDispatch push path - #3702

Merged
tlgimenes merged 3 commits into
mainfrom
tlgimenes/remotedispatch-404-link
Jun 8, 2026
Merged

tlgimenes merged 3 commits into
mainfrom
tlgimenes/remotedispatch-404-link

Conversation

@tlgimenes

@tlgimenes tlgimenes commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes [remoteDispatch] dispatch failed (404) when running a user-desktop CLI agent (e.g. claude-code) via decocms link.

The push (remoteDispatch) dispatch path stopped ensuring (spawning) the desktop sandbox in C-bis S4 (#3698), on the rationale that "the daemon self-ensures from WorkItem.sandbox on dequeue." That backstop only exists on the pull/work-queue path (cluster-connection-pull.ts). On the push path the link daemon's control-handler.handleStream just calls proxyPort(handle) and returns 404 "unknown handle" for a never-spawned handle (control-handler.ts:172-193). The plain-text body isn't JSON, so remote-dispatch.ts keeps its default detail → [remoteDispatch] dispatch failed (404).

This restores the warm-ensure at the push site via a small ensurePushDispatchSandboxHandle helper and dispatches the handle ensureSandbox actually provisioned — which also closes a secondary handle-drift bug (dispatch used mem.thread.branch ?? input.branch ?? "ephemeral" while the ensure would have used input.branch ?? "ephemeral", diverging on a repo-connected first message). The pull site is unchanged (its daemon self-ensure is genuine).

Why it only bites now

decidePullDispatch routes to the pull path only when message_storage_version === 2, which is canary-gated off by default (STREAM_OF_RECORD_V2_PERCENT=0). So every normal (v1) user-desktop thread takes the push path that #3698 left without an ensure.

Test plan

  • New unit tests (dispatch-sandbox.test.ts): the push helper runs the full ensure (not a pure derivation) and honors branch precedence (thread → request → "ephemeral").
  • bun test green on the touched area + siblings (dispatch-sandbox / remote-dispatch / thread-gate-workflow / control-handler).
  • bun run check, bun run lint, bun run fmt:check all green.
  • Manual e2e (not coverable in CI — no real link daemon): bun run dev --local-sandbox-provider, send a message in a user-desktop claude-code chat, confirm it streams with no [remoteDispatch] dispatch failed (404) and no [control] handleStream unknown handle=....

🤖 Generated with Claude Code


Summary by cubic

Fixes 404 errors in remoteDispatch for user-desktop CLI agents (e.g. decocms link) by ensuring the desktop sandbox is spawned on the push path and using the provisioned handle.

  • Bug Fixes
    • Added ensurePushDispatchSandboxHandle to run ensureSandbox on the push path and dispatch the handle it provisions, preventing "unknown handle" 404s and handle drift (thread branch now correctly wins over request branch, else "ephemeral").
    • Added unit tests for push-path ensure and branch precedence; pull/work-queue path remains unchanged.

Written for commit 30f70fd. Summary will update on new commits.

Review in cubic

tlgimenes and others added 3 commits June 7, 2026 21:48
The push (remoteDispatch) dispatch site stopped ensuring the sandbox in
C-bis S4 (#3698), on the rationale that the daemon self-ensures from the
work item — but that backstop exists only on the pull/work-queue path. On
the push path the link daemon's control-handler 404s "unknown handle" for
an unspawned handle, surfacing as [remoteDispatch] dispatch failed (404).
Restore the warm-ensure via ensurePushDispatchSandboxHandle and dispatch
the provisioned handle (also closing the thread-vs-input branch drift).
Pull site unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@tlgimenes
tlgimenes enabled auto-merge (squash) June 8, 2026 01:08
@tlgimenes
tlgimenes merged commit dae6e69 into main Jun 8, 2026
18 checks passed
@tlgimenes
tlgimenes deleted the tlgimenes/remotedispatch-404-link branch June 8, 2026 01:12
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.

1 participant