feat(extension): add get_status request to hub WS protocol#439
Open
ykswang wants to merge 2 commits intoalibaba:mainfrom
Open
feat(extension): add get_status request to hub WS protocol#439ykswang wants to merge 2 commits intoalibaba:mainfrom
ykswang wants to merge 2 commits intoalibaba:mainfrom
Conversation
The hub-WS protocol previously offered no signal between `execute` and
the final `result`/`error`, forcing callers to choose between a long
wall-clock timeout (false positives on slow tasks) and a short one
(false negatives when the hub is actually alive and progressing).
Send `{ type: "heartbeat", at: number }` every 5s while a task is
running so callers can reset an idle-based deadline on each tick and
detect a dead hub (throttled tab, blocked main thread) without
guessing a total-duration budget up front.
Backward-compatible: existing callers (e.g. packages/mcp/hub-bridge.js)
silently ignore unknown message types.
Collaborator
|
Thanks for your contribution!
|
Per maintainer feedback on PR alibaba#439: 1. The "heartbeat" name overlaps with WS-level ping/pong and is confusing — the protocol's own framing already provides connection-level liveness. 2. A `get_status` request/response can let callers achieve the same "is the hub still working" check without the hub pushing periodic messages every task. This drops the periodic heartbeat in favor of a pull model: Inbound: { type: "get_status" } Outbound: { type: "status", busy: boolean } Recommended caller usage (kept in JSDoc): - WS-level ping/pong (browsers auto-respond at the protocol layer) is the primary dead-connection check. No protocol changes needed; the WS server can just call `ws.ping()`. - `get_status` is for application-level state-drift checks — e.g. when a `result` was lost and both sides disagree on whether a task is still running. Callers send it on demand, not periodically. Net protocol change vs main: one inbound type, one outbound type. Existing callers that ignore unknown types are unaffected.
Author
|
Pivoted in e063960 — heartbeat is gone, replaced with The JSDoc now spells out the recommended layering for callers:
Title and description updated; both commits kept so this thread reads in order. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The hub-WS protocol currently has no way for a caller to confirm the hub's view of "is a task still running". A caller can be stuck waiting for
resultwhile the hub already considers itself idle (e.g. theresultmessage was lost, or local state on the caller drifted). There is no protocol affordance to verify.Recommended caller layering (from JSDoc)
ws.ping()— browsers auto-respond at protocol layerget_status(this PR) — sent on demand, not periodicallyLayer 1 already works for any caller — the WS server can call
ws.ping()and rely on the browser's automatic pong. So this PR only adds layer 2, and only the bits the protocol needs.Protocol additions
busyreflects the hub's#busyflag — true while a task is in flight, false otherwise.Compatibility
Purely additive. Existing callers (e.g.
packages/mcp/src/hub-bridge.js) silently ignore unknown message types and are unaffected.Commit history
feat(extension): emit periodic heartbeat from hub while task is running— initial heartbeat-push proposalrefactor(extension): replace heartbeat push with get_status request— pivot to pull-based per discussion belowTest plan
npm run typecheckpassesnpx eslintclean{type:'get_status'}while hub idle → receive{type:'status', busy:false}{type:'get_status'}mid-task → receive{type:'status', busy:true}