Skip to content

ipc: surface early runner.send rejections to caller in thread:send - #61

Merged
BunsDev merged 2 commits into
TypeSafeAI:mainfrom
Yash990-bit:fix-thread-send-error
Oct 3, 2026
Merged

BunsDev merged 2 commits into
TypeSafeAI:mainfrom
Yash990-bit:fix-thread-send-error

Conversation

@Yash990-bit

@Yash990-bit Yash990-bit commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #57

Summary

Surfaces early runner.send() rejections (e.g., thread busy, missing working directory, unknown thread, or thread being deleted) back to the caller in thread:send IPC as { ok: false, error: string } instead of unconditionally returning { ok: true }.

User-Visible Behaviour Change

  • Early launch rejections move from inline notices to toast alerts: Previously, early synchronous/tick-0 rejections in runner.send() were caught and emitted as an inline error notice item inside the thread transcript, while the IPC handler returned { ok: true }. Now, early rejections are surfaced to the renderer via { ok: false, error }, triggering the existing if (!r.ok) setError(...) in App.tsx and displaying as an app toast banner.
  • Asynchronous errors remain notices: Rejections and failures that arrive after the first tick (once the turn has begun) continue to be emitted as notice items in the thread.

Tests

  • Runner test (apps/desktop/test/runner.test.ts): Verified that calling runner.send() on a busy thread rejects with /still working/, records no error notice item, and does not record the second user prompt.
  • E2E test (apps/desktop/e2e/app.spec.ts): Added an assertion in the approval workflow ensuring bridge.invoke("thread:send", ...) while a turn is in flight resolves to { ok: false, error: /still working/ } and leaves 0 notice items in the thread.

@Yash990-bit

Copy link
Copy Markdown
Contributor Author

Hi @BunsDev, whenever you have a moment, could you please review this thread:send error handling fix? Built, tested locally, and signed. Thanks!

@BunsDev BunsDev left a comment

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.

Thanks! Returning early runner.send rejections means the renderer's existing if (!r.ok) setError(...) in App.tsx finally runs for them. These are the rejections runner.send / runTurn raise before the turn starts: the thread is still working, it's unknown, or its working directory is missing. All three happen before the user's message is recorded, so showing them as the app toast instead of a notice item inside the thread fits.

A few notes:

  1. Please mention the behaviour change in the PR description. These errors move from an inline notice in the thread to the toast. Rejections that arrive after the first tick still become notices. It's a reasonable change, but it's visible to users.
  2. Test. Nothing covers the new path yet. A runner-level or e2e test of "send while a turn is running" that expects { ok: false, error: /still working/ } and no new notice item would pin it down.
  3. Optional follow-up, not introduced here. Composer clears its text right after onSend (Composer.tsx:73-74), so after an early failure the typed message is gone. Now that thread:send reports the failure, the composer could put the text back when ok is false.

Before merge

  • GitHub shows 399558d as unverified (unknown_key), and main requires verified signatures. Add the SSH key you sign with as a Signing key under Settings → SSH and GPG keys. The rebase below then produces a verified commit.
  • main requires branches to be up to date, so please rebase onto the current main.

CI passed on the last run of this branch.

@Yash990-bit
Yash990-bit force-pushed the fix-thread-send-error branch from 399558d to 3a8e661 Compare October 2, 2026 06:30
@Yash990-bit
Yash990-bit requested a review from BunsDev October 2, 2026 06:51
@Yash990-bit

Copy link
Copy Markdown
Contributor Author

Thanks for the clear feedback and review, @BunsDev!

I've updated the PR accordingly:

Behaviour Change in Description: Updated the PR description explaining that pre-turn rejections (busy, missing cwd, deleting) now surface via the app toast (setError) rather than inline notice items, while later turn failures continue to be emitted as thread notices.
Tests Added:
Added a runner-level test in runner.test.ts confirming concurrent send rejects with /still working/ and creates no notice or extra user items.
Added an e2e assertion in app.spec.ts verifying that thread:send during an in-flight turn returns { ok: false, error: /still working/ } and leaves no notice items.
Verified Commit & Rebase: Added my SSH signing key to GitHub, rebased onto current main, and signed the commit (verified badge confirmed).
Great suggestion on having the composer restore the typed message on early send failures — happy to open that as a focused follow-up PR once this lands!

@BunsDev BunsDev left a comment

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.

Reviewed and verified locally on top of current main.

  • runner.send throws every early rejection (busy, unknown/deleting thread, project removal, shutdown, missing cwd) before its first await, so each one lands inside the one-tick window and is returned as { ok: false, error }. Once a turn has started, runTurn turns backend failures into notice items itself, so late errors keep their existing path.
  • The new e2e assertion fails against main's handler ({ ok: true } returned for a busy thread) and passes with this change: app.spec.ts 14/14.
  • npm run build && npm test: 148/148.

Two nits, neither blocking: a stray double blank line in each test file, and the outer try/catch can no longer fire since runner.send is async. Thanks for the fix.

🤖 Generated with Claude Code

@BunsDev
BunsDev merged commit 95e7459 into TypeSafeAI:main Oct 3, 2026
1 check passed
BunsDev added a commit that referenced this pull request Oct 3, 2026
…67)

The three contributor bug fixes landed today: send rejections reach the
caller (#61), staged renames diff as renames (#60, with its follow-ups
noted), and worktree.sh survives a failed fetch (#62). #39's branding
images merged yesterday. Drop all four from "Open contributor PRs".

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

thread:send IPC handler always returns { ok: true } even when launch fails

2 participants