← Back to Pull requests

A cancel outlives the page, and the hub remembers it for a request of that message still on its way #2678

Open
unknown opened this pull request with 620 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 29, 2026 04:53 UTC
Author

Summary

Stacked on #2666 (feat/send-experience). This branch contains that PR's commits, so the diff from main shows both; what is new here is the one commit "A cancel outlives the page, and the hub remembers it for a request of that message still on its way". It is a pull request of its own because it is the one part that changes the hub.

#2666 makes a send cancelled while its request is on the wire final on the device: the abort is remembered, and the reconciler asks the hub about it. Two gaps were left in that, and this closes them.

  • The page goes away first. Closed, reloaded, or swiped into the background on a phone: nothing was left to ask, and the message the user cancelled was queued and delivered all the same; the next opening of the app could only report it as too late. At the moment of leaving (pagehide, and visibilitychange to hidden, which is how a phone leaves), the page now tells the hub of every cancel still unsettled: one request each, by local id, marked to outlive the page (keepalive) and not waited on. A row the hub holds is dropped where it stands. Nothing is settled by it; the ledger keeps its entries for the next opening.

  • The request lands after the cancel. The hub now remembers a cancel that stood, by session and local id, for ten minutes, in memory, and a message of that local id arriving meanwhile is not taken in: no row, nothing to the CLI. That is for two kinds of request. One is the request cancelled on the wire, whose row did not exist yet when the cancel came. The other is a later attempt of a message whose row the cancel removed: a retry sent before the cancel and still on its way was stored as a new row once the first was gone, and the cancelled message went out after all. (The hub translates a prompt before it takes it as the same message, so that request can be seconds behind.) A request is asked about the remembered cancel once more where it would be stored, since it can wait for its turn to be translated and be cancelled in the meantime.

  • Asked about such a send (queued-state), the hub says so (cancelledBeforeArrivalLocalIds), and the device settles the cancel at once as cancelled, instead of asking for ten minutes.
  • Docs: two lines in the Queue section of docs/guide/composer.md.

    Verification

  • bun run typecheck: clean. bun run test:hub: 2308 passed. bun run test:shared: 635 passed. bun run test:web: 431 files, 5167 passed (+1 existing it.fails). bun run gen:fixtures: no diff. bun run --cwd docs docs:build: passes.

  • New tests on the hub (5): a cancel that comes before its message is answered as cancelled, and the message is not taken in when its request lands; it counts for that message only; it is left by a cancel that finds its row too, so a later attempt of that message is not taken in once the row is gone; it does not outstay its span; and a request cancelled while it waited for its translation is not taken in (that one fails without the second ask).

  • New tests on the page (7): the last word on pagehide and on hidden, for every unsettled cancel of every chat, out at once and marked to outlive the page, settling nothing; the probe that settles at once on the hub's answer; and listUnsettledAbortedSends.

  • In a real browser against a throwaway hub built from this branch, with scripted agents: 8 checks for leaving the page, in both moments (the hub already has the message; the request lands after the page is gone). On #2666's head 2 of the 8 fail — the hub still holds the message — and here all 8 pass. The 17, 11, 10 and 21 checks of #2666 pass again on this branch, with the late-retry one now expecting no second cancel: the retry reached the hub and was not taken in, and the cancel was settled at its first question.
  • Notes

  • The record is in memory: a hub restart forgets it, and a request more than ten minutes behind is not covered. It is about requests on the wire, not about history. At most 200 are kept per session.

  • A request of a cancelled local id is answered like any other ({ ok: true }). So a page that replays a message cancelled on another client shows it as on its way until its next reconciliation with the hub, as for any row the hub does not know; before, that replay recreated the prompt and it was delivered. Telling that page at once would need the answer to say so, and is left for a follow-up.

  • The web client never sends a message again under a local id whose cancel stood. A client that wants to send a message again after cancelling it has to use a new local id.

  • This is the piece the last review of #2666 and #2667 asked for from the hub ("a cancel that covers delayed POSTs with the same session and local ID"). With it, the cancel of a retried send no longer depends on the reconciler racing a free agent.
  • 🤖 Generated with Claude Code — agent framework run through HAPI, powered by GLM glm-5.4 (Z.ai).

    Diff: 620 lines (+465 / -155) across 7 files Reviewer: github-actions[bot] Review duration: 9m
    All Vouch review confidence checks passed
    Residual risk 0.34 = Change Risk (0.50) × (1 − Review Confidence (0.33)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 620 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 60% · Reviewer familiarity: 35%
    33%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.385
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2678"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 33% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 33% · Lower = rushed or shallow review
    33%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 33.7% · Safe to merge
    33.7%
    Repository