Skip to content

fix: E2E test seed session, cancel deadlock, and user_created_thread - #27

Merged
lukemarsden merged 4 commits into
mainfrom
fix/e2e-test-seed-session-and-cancel
Mar 25, 2026
Merged

fix: E2E test seed session, cancel deadlock, and user_created_thread#27
lukemarsden merged 4 commits into
mainfrom
fix/e2e-test-seed-session-and-cancel

Conversation

@lukemarsden

Copy link
Copy Markdown

Summary

Fixes the Zed WebSocket sync E2E test which has been failing in CI since the upstream merge (ZED_COMMIT=85dc484c6e).

Three root causes identified and fixed:

  1. Seed session: The E2E test server didn't create a session in the store before Zed connected. In production, sessions always exist before the agent connects. Without a seed session, handleUserCreatedThread failed with "session not found" when Zed sent spontaneous user_created_thread events on startup. Fixed by creating a ses_-prefixed seed session matching HELIX_SESSION_ID.

  2. Cancel deadlock: AcpThread::cancel() awaited the old turn's send_task via cx.background_spawn(), which required the ACP agent to respond to CancelNotification. Claude Code has multiple bugs where cancel doesn't cause the prompt to return (#442, #423), causing cancel() to block indefinitely. Fixed by dropping send_task instead — this triggers the existing tx-dropped handler in run_turn which emits Stopped(Cancelled). The cancel notification is still sent as a courtesy.

  3. Thread tracking: Spontaneous user_created_thread events from Zed startup were being mixed into threadIDs[] alongside thread_created events from chat_message responses. Phase 2's follow-up was sent to the wrong thread. Fixed by only tracking thread_created in threadIDs.

Additional improvements:

  • Disabled local claude-agent-acp mount — let Zed auto-install latest from npm (matches production)
  • Log claude-agent-acp version at test start for debugging
  • Updated porting guide with Critical Fix Upstream merge (Feb 24) + streaming throttle + E2E test infra #8, 10-phase E2E test docs, rebase checklist
  • Added CLAUDE.md to e2e-test dir documenting binary freshness requirements
  • Adjusted expected interaction count from 6→5 to match production behavior

Test plan

  • E2E_AGENTS="zed-agent" — all 10 phases pass
  • E2E_AGENTS="zed-agent,claude" — all 10 phases pass for both agents
  • Store validation passes (sessions, interactions, accumulation, structured entries)
  • cargo check -p acp_thread compiles clean

🤖 Generated with Claude Code

lukemarsden and others added 4 commits March 24, 2026 22:32
…handling

Three fixes for the Zed WebSocket sync E2E tests:

1. Seed session: Create a session in the store before Zed connects, matching
   HELIX_SESSION_ID (now ses_-prefixed). This mirrors production where sessions
   always exist before the agent connects, fixing handleUserCreatedThread
   "session not found" errors.

2. Cancel deadlock: In AcpThread::cancel(), drop the old send_task instead of
   awaiting it. The previous approach (cx.background_spawn(turn.send_task))
   would deadlock if the ACP agent never responded to CancelNotification.
   Dropping the task triggers the existing tx-dropped handler in run_turn
   which emits Stopped(Cancelled). This fixes Phase 8 timeout with Claude Code.

3. Thread tracking: Only track thread_created events in threadIDs (not
   user_created_thread). Spontaneous threads from Zed startup shouldn't be
   used for test phase follow-ups. Adjusted expected interaction count from
   6 to 5 to match production behavior where follow-ups update existing
   interactions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ions

- cancel(): drop send_task instead of awaiting it to avoid deadlock when
  ACP agents don't respond to CancelNotification (claude-agent-acp#442, zed-industries#423)
- Disable local claude-agent-acp mount in E2E test — let Zed auto-install
  latest from npm to match production behavior
- Log claude-agent-acp version (local or npm) for debugging test failures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Update E2E test section: 10 phases (was 7), seed session requirement,
  claude-agent-acp auto-install from npm, both agent rounds
- Add Critical Fix #8: cancel() must drop send_task not await it
- Add rebase checklist item #31 for cancel fix
- Add commit history entries for seed session and cancel fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Even after claude-agent-acp cancel bugs are fixed, the drop approach
protects against any ACP agent that doesn't properly handle
CancelNotification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lukemarsden
lukemarsden merged commit e0ee12c into main Mar 25, 2026
17 checks passed
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