Skip to content

fix(desktop): bound Runtime Host handler waits - #3795

Open
hqhq1025 wants to merge 1 commit into
apache:mainfrom
hqhq1025:codex/fix-followup-send-host-reconnect
Open

fix(desktop): bound Runtime Host handler waits#3795
hqhq1025 wants to merge 1 commit into
apache:mainfrom
hqhq1025:codex/fix-followup-send-host-reconnect

Conversation

@hqhq1025

Copy link
Copy Markdown
Contributor

Problem

When a Runtime Host candidate exits, its channel handlers are removed while the target epoch remains active so a replacement candidate can reconnect. Calls arriving in that interval waited indefinitely for a handler.

The composer performs a reconnectable task-readiness read before sending. If the Host never returned, that promise never settled, so the composer kept its submission guard latched and both the Send button and Enter stopped working.

Root cause

RuntimeHostReconnectingIpcMain.#waitForHandler() supported a timeout only for reconciled controls. Initial dispatches and ordinary reconnectable-read replacement waits called it without a deadline.

Fix

  • Add a configurable 5-second handler availability window.
  • Apply it to initial dispatch and non-reconciliation replacement waits.
  • Preserve same-epoch reconnect routing when a replacement arrives within the window.
  • Reject with RuntimeHostHandlerUnavailableError after the deadline so callers release pending interaction state and retain retryable input.

Tests

  • Add coverage for an active target whose command handler was removed.
  • Verify a later retry succeeds after a replacement handler registers.
  • Add coverage for a reconnectable read whose replacement never arrives.
  • npm --workspace @maka/desktop run build:main
  • node --test apps/desktop/dist/main/__tests__/runtime-host-reconnecting-ipc-main.test.js (15/15, repeated 10 times)
  • npx biome check apps/desktop/src/main/runtime-host-reconnecting-ipc-main.ts apps/desktop/src/main/__tests__/runtime-host-reconnecting-ipc-main.test.ts
  • Full Desktop main suite: 1495/1499. The four failures are pre-existing goal-dialog DOM-environment failures (getComputedStyle is not defined) and do not touch this path.

Repository baseline note

The full workspace dependency build on current main is independently blocked by three stale RuntimeHostConnection.queryTurn/stopTurn/startTurn calls in execution-host-queue.test.ts after #3784. This PR does not include that unrelated migration.

UI evidence

No visual styling or layout changes. The behavior change is covered at the IPC ownership boundary where the indefinite promise originated.

@Astro-Han Astro-Han 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.

I reviewed this head and found no blocking issues.

The reconnect handler wait now correctly times out after 5s (configurable) instead of hanging indefinitely when the Host is unavailable, with retry handling. No new authority or state.

Minor note: timeoutMs=0 edge (remaining 0ms) lacks a direct test, but the <=0 branch exists.

No P0-P2. Checks on 32fbe34c pending — code GO.

简体中文该头未发现阻断。

@hqhq1025
hqhq1025 force-pushed the codex/fix-followup-send-host-reconnect branch from 32fbe34 to 5581c57 Compare August 25, 2026 13:15
@hqhq1025

Copy link
Copy Markdown
Contributor Author

Rebased onto current main after #3796 merged, removing the inherited Runtime Host queue-test failure.

Local verification on 5581c57e2:

  • rebuilt @maka/core, @maka/storage, @maka/runtime, @maka/runtime-host, and @maka/computer-use in dependency order
  • npm --workspace @maka/desktop run build:main
  • runtime-host-reconnecting-ipc-main.test.js (15 passed)
  • git diff --check origin/main...HEAD

Please re-review the refreshed head.

@Astro-Han Astro-Han 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.

Update on 5581c57: GO, no P0-P3. Adds bounded 5s handlerWaitTimeoutMs with new RuntimeHostHandlerUnavailableError, separate from reconciliation deadline. Hosted test PASS 32852294716.

简体中文该头无阻断。

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