Skip to content

fix(app): bound the new-workspace wait to 20 s and send the prompt after it (Refs #1073) - #2207

Draft
bc037 wants to merge 1 commit into
mainfrom
fix/1073-new-workspace-hang
Draft

bc037 wants to merge 1 commit into
mainfrom
fix/1073-new-workspace-hang

Conversation

@bc037

@bc037 bc037 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Refs #1073

Finding

The issue says nothing calls Worktree.ready(). That is not true on current main:

  • handleWorktreeLifecycleEvent (notification-toasts.ts) calls it when worktree.ready arrives.
  • I ran the real engine (1.18.30) in WSL and created a worktree. It sent worktree.ready about 25 ms after the create call returned. The event's directory is the worktree path, the same key the app uses.
  • If worktree.ready comes before pending(), pending() does nothing, so that order is safe.

I could not reproduce a hang in the real app. The hang can still happen when the event is lost (the event stream reconnects, or the listener is not mounted). The old wait then lasted 5 minutes and failed the send.

Change

  • New worktree-wait.ts: waitForWorktreeReady waits at most 20 s. It returns ready, timeout or aborted. It throws the engine's message on worktree.failed. It clears its timer and its abort listener.
  • submit.ts: the inline 5-minute wait uses the helper. On timeout the prompt is sent, and the worktree is marked ready so later prompts do not wait again.
  • Overlay manifest refreshed.

Not done

The issue asks to remove the wait. I kept a bounded wait: without it the first prompt always races git reset --hard in the new worktree. The "no wait" option stays open if the maintainers prefer it.

Test

  • worktree-wait.test.ts: 11 tests pass (ready, timeout, failed, abort, abort before start, timer cleanup, and checks that submit.ts uses the helper).
  • App tsgo -b typecheck passes. Drift gate passes.
  • prompt-input tests: 1 failure, "keeps auto-accept bound to the submission server". It fails the same way on unchanged main.

🤖 Generated with Claude Code

…ter it (Refs #1073)

A new-workspace chat holds its first prompt until the engine's
worktree.ready event arrives. If the event is lost, the wait lasted 5
minutes and then failed the send, so the prompt showed in the UI and no
agent answered.

Move the wait into waitForWorktreeReady with a 20 s limit. A time-out
now sends the prompt and marks the worktree ready, so later prompts do
not wait again. A worktree.failed event still stops the send, and a
cancel still restores the input. Refresh the overlay manifest.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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.

2 participants