Skip to content

fix(ws): apply the silent-socket watchdog to the mochi and crew-companion sockets - #22652

Closed
dodgeblaster wants to merge 1 commit into
mainfrom
feat/silent-socket-watchdog-app-sockets
Closed

dodgeblaster wants to merge 1 commit into
mainfrom
feat/silent-socket-watchdog-app-sockets

Conversation

@dodgeblaster

@dodgeblaster dodgeblaster commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The Mochi pet panel and the Crew Companion recover on their own when their /api/ws socket goes quietly dead, instead of sitting stale until the page is reloaded.

Both app sockets reconnect only from onclose. A browser can keep a WebSocket whose transport is gone — a phone that changed networks, a tab the OS froze and resumed — with its readyState still OPEN and onclose never firing. The socket then delivers nothing and nobody notices: the pet's chat stream silently stops, and the companion's "tell me when sessions are done" bubble never fires again. The dashboard's own socket got a silence watchdog in #14222; these two did not.

Why it matters

A dead-but-open socket is invisible to the user: the UI looks connected while every live frame is lost, and the only fix is a manual reload. The gateway already pushes a dashboard status frame on every socket every 5s, so the liveness signal to detect this is right there — these two sockets just were not using it.

Not a goal

What changed (motivation → approach → change)

The silence check lived inside the dashboard's useWebSocket hook as inline refs and an effect, so applying it to two more sockets by copy would fork its timing constants (WS_SILENCE_MS, the 5s check cadence, the 300s cap) and its hidden-time bookkeeping across three places. Instead the whole rule is extracted once into a framework-agnostic SilenceWatchdog (website/src/utils/socketSilenceWatchdog.ts): it owns the visible-time stamps, the hidden-tab skip, the thaw grace, and the window-doubling-to-a-cap, and the host supplies only isOpen (read this socket's readyState) and onDead (replace it). All three sockets now drive that one class — the dashboard hook (website/src/hooks/useWebSocket.ts, refactored to construct it, no behaviour change), the Mochi panel bridge, and the Crew Companion session watcher — so they cannot drift. The helper sits in utils/ rather than hooks/websocket/, which is the dashboard facade's private owner directory that nothing else may import from.

The dashboard hook builds its one SilenceWatchdog once and keeps it for the hook's lifetime; its arming effect only re-points the host and re-arms the timer, so the consecutive-replacement count survives a re-run of that effect, as the inline refs did.

On a watchdog replacement the Crew Companion does not fail its in-flight turns: the socket died, not the gateway, so those turns are usually still running, and failing them raised a never-silenced "failed" bubble followed by a "done" bubble for the same turn. The fresh socket's first slots frame settles them instead (settleOnSlots in sessionWatch.ts): a slot it lists as running keeps its start and is closed by its own chat_done, and a slot it does not list is reported as failed, as a dropped socket reports it. If the fresh socket closes before that frame, onclose fails them as before. docs/system-specs/modules/learn-cron-dashboard.md names the shared helper and the two app sockets.

Backwards compatibility

Compatible: the dashboard socket's behaviour is byte-for-byte preserved (its ten existing watchdog specs pass unchanged against the refactor); the two app sockets only gain a replacement path for a state (open-but-silent) in which they previously did nothing.

Removes nothing: no path, record, validator or public function is removed or tightened; the change only adds a watchdog and extracts existing logic into a shared module that keeps re-exporting the same constants from useWebSocket.

Tests

  • website/src/test/socketSilenceWatchdog.test.ts — the shared helper in isolation: replaces a silent OPEN socket, keeps one that delivers frames, skips a non-OPEN socket, skips while hidden, doubles the window per silent replacement and caps it, and detaches on stop().
  • website/src/apps/mochi/test/mochiSocketSilence.test.ts — the Mochi panel socket: a silent OPEN socket is replaced after the window, a socket receiving the 5s status frame is not, and a hidden page is left alone.
  • website/src/test/CrewCompanionSocketSilence.test.ts — the Crew Companion socket: the same three behaviours, plus what onDone receives on a watchdog replacement: nothing at the replacement; one success from chat_done for a turn the first slots frame lists running; one failure for a turn it lists not running, with no second report from a later frame or a stray chat_done; only the first slots frame settles; a close before that frame fails the turn. Restoring the immediate fail on replacement turns three of these red.
  • website/src/test/socketSilenceWatchdog.test.ts also pins that a stop() + start() keeps the widened window, the property the dashboard hook's single instance relies on.
  • website/src/test/useWebSocket.ownership.test.ts — updated so the facade effect-order ratchet matches the refactored watchdog effect (the effect re-points silenceHostRef in place of the former inline silenceWindowMs).
  • test/test_ws_status_cadence_contract.py — the backend pin that cross-checks the frontend silence window against the gateway's _WS_STATUS_INTERVAL now reads the constants and thaw-grace from socketSilenceWatchdog.ts (their new home); the contract it enforces is unchanged.

Determinism: every spec uses fake timers and an injected/mocked clock — no real sleeps. Each is bounded, and each asserts both directions (replaced when silent, not replaced while frames arrive). The per-socket and helper specs were proven to catch the bug: removing markFrame turns the "keeps a socket receiving frames" case red, and skipping start() turns the "replaces a silent socket" case red.

Manual verification

N/A — unit coverage is sufficient: the behaviour is a timing rule over socket state, fully driven by fake timers and a mocked clock, with no rendered output to inspect.

Screenshots / video

Why no screenshot: this changes socket-reconnect timing only; no component, layout, theme, or user-visible string renders differently.

Related Issues

Closes #14225

Pattern harvest

Rule candidate: review-prompt
Pattern: a per-connection liveness/silence watchdog copied inline into each socket instead of shared, so the timing constants drift between copies.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 12641c6a4bb589b86b6f5d1de6a980011f7a6931 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The diff only changes socket-reconnect timing and adds or changes no visible control, label or string, so the missing blind read leaves no gaps.

[UX-REVIEWED] 12641c6

Description read

[DESCRIPTION-READ] 4d8a52abdc76e86ec041df292153e2eb7764fbbb903fc138b19c6ce3f8506915

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 12641c6a4bb589b86b6f5d1de6a980011f7a6931 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. All three /api/ws sockets now share one watchdog. The only leftover is that core code and the core spec name two apps that are due to leave core.

Notes

  • Item 1 — inherited: the shared helper's docstring names "the two app sockets (apps/mochi/panel/panelBridge, apps/crew-companion/sessionWatch)", and the spec paragraph does the same. AGENTS.md says core never hard-codes a specific app, and both apps are leaving under Move every built-in app out to KiroCrewApps and forbid built-in apps #26967, so these names will go stale. Subtraction: delete the app paths from utils/socketSilenceWatchdog.ts's header and from the learn-cron-dashboard.md sentence. Keep only "every /api/ws socket drives it".

What this change ships

Inventory (5 items) — 4 justified

Intent: the Mochi panel and the Crew Companion recover on their own from an open-but-dead socket, with no reload. This is a FIX (#14225).

  1. The dashboard's silence rule moves into one shared helper, and the dashboard's behaviour stays the same — inherited (the core docs name the two apps)
  2. A dead-but-open Mochi panel socket now reconnects on its own — justified
  3. A dead-but-open Crew Companion socket now reconnects on its own — justified
  4. After a watchdog reconnect, the Companion holds in-flight turns until the first slots frame instead of failing them at once — justified
  5. The backend cadence contract test now reads its constants from the helper's file — justified

Coverage count: 3 non-test new WebSocket( sites open /api/ws (connection.ts, panelBridge.ts, sessionWatch.ts), and all 3 are wired. The other sockets (/api/ws/stt, /api/ws/terminal) do not get the status push.

[FIRST-PRINCIPLES-REVIEWED] 12641c6

Description read

[DESCRIPTION-READ] 698006dd237325f40fe393153a94adb6f6311da91135e0c4fa8d7d36b7918d85

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 12641c6a4bb589b86b6f5d1de6a980011f7a6931 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The design rests on the gateway sending its 5s dashboard frame to every socket, and ws.py sends that frame to app sockets too, so pulling the check into one shared watchdog is the right shape.

[DESIGN-REVIEWED] 12641c6

Description read

[DESCRIPTION-READ] f667d0cf14870273a84548524719b98680f368c2decc44ed2c2fc3687ef1c0d1

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 12641c6a4bb589b86b6f5d1de6a980011f7a6931 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 12641c6

Verdict parsed from the review's SHA-scoped output markers for commit 12641c6a4bb589b86b6f5d1de6a980011f7a6931.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 12641c6a4bb589b86b6f5d1de6a980011f7a6931 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on 12641c6a4bb589b86b6f5d1de6a980011f7a6931; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- website/src/apps/crew-companion/sessionWatch.ts:339 -- Reconnect preserves a predecessor’s stop flag for a new turn

if (running.has(slot)) continue
Trigger: After the watcher receives stopping: true, its socket goes silent and misses that turn’s chat_done. A new turn starts in the same slot before reconnection; the fresh slots frame lists it running, so this branch retains the predecessor’s bookkeeping.
Outcome: When the successor completes successfully, finish() reads the stale stoppedSlots entry and returns without calling onDone, suppressing its completion notification even with alerts enabled and a duration above the threshold.
Anchor: defect
Fix: Track turn identity and retain bookkeeping only when the reconnect snapshot’s turn and turn_gen match the tracked turn; otherwise discard the predecessor’s state and register the running successor as an assumed start.

[BLOCK-MERGE-DOWNGRADED] 12641c6
[GPT-REVIEWED] 12641c6

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 is downgraded: the harm is low and the real fix costs more than it prevents.

F1 — LOW. The failure needs four things to happen together:

  • a stopping: true slots frame records the stop flag (sessionWatch.ts:314);
  • the socket then goes silent for at least WS_SILENCE_MS (20s, socketSilenceWatchdog.ts:38), so the reopen at sessionWatch.ts:197-210 misses that turn's chat_done;
  • a new turn starts in the same slot during that silent window;
  • the first slots frame after the reopen lists that slot as running, so sessionWatch.ts:339 keeps the old stop flag, and finish() returns early at :233.

The only consequence is that one "done" bubble doesn't appear. Nothing self-corrects it, but no data or state is lost, failures are never silenced, and the session's own UI still shows the turn finished.

The real fix needs a new per-slot turn-identity map, compared at the reconnect check. The slots frame does carry turn/turn_gen (slot_projection.py:373), but turns started from chat_status (sessionWatch.ts:293) have no identity recorded. So the fix also needs a policy for turns whose identity is unknown, which every future reader then has to understand, all for a rare race whose only cost is a missing notification.

[ADJUDICATION] 12641c6a4bb589b86b6f5d1de6a980011f7a6931 total=1 uphold=0 downgrade=1
DOWNGRADE F1 website/src/apps/crew-companion/sessionWatch.ts:339 reason=disproportionate-remedy
[GPT-ADJUDICATED] 12641c6a4bb589b86b6f5d1de6a980011f7a6931

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 12641c6a4bb589b86b6f5d1de6a980011f7a6931 false-positive: <reason, 20 to 500 characters>

@dodgeblaster
dodgeblaster force-pushed the feat/silent-socket-watchdog-app-sockets branch from ad1b8dc to 873422a Compare October 21, 2026 03:43
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 27, 2026
@dodgeblaster
dodgeblaster force-pushed the feat/silent-socket-watchdog-app-sockets branch from 873422a to a272250 Compare October 29, 2026 22:35
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 29, 2026
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • rebutted — Item 4, re-export of WS_SILENCE_MS / WS_SILENCE_CHECK_MS / WS_SILENCE_MAX_MS from useWebSocket.ts

The three names are part of the useWebSocket facade's pinned public surface on main: website/src/test/useWebSocket.ownership.test.ts "the facade exports exactly its original names" lists all three, on origin/main and unchanged by this PR.
Dropping the re-export was tried locally: that ownership test then fails (expected 35 names, received 32), so the subtraction narrows a contract main pins rather than removing dead code.
Shrinking the facade's surface is outside this fix's goal (apply the silence watchdog to the two app sockets); the re-export keeps the facade's surface byte-identical while the constants live in the shared helper.

@dodgeblaster
dodgeblaster marked this pull request as ready for review October 29, 2026 23:21
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 29, 2026
@dodgeblaster
dodgeblaster requested review from a team and KiroCrewCaptain as code owners October 29, 2026 23:21
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 29, 2026
@dodgeblaster
dodgeblaster force-pushed the feat/silent-socket-watchdog-app-sockets branch from a272250 to dc1c020 Compare October 29, 2026 23:42
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Rebased onto main e106845 to pick up #25944 (fixes the kiroUsageRefetchInterval main red that failed Frontend Tests (1) / Coverage Gate on the previous head). PR diff unchanged (same 9 files, patch-identical); CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • rebutted — Item 4, re-export of WS_SILENCE_MS / WS_SILENCE_CHECK_MS / WS_SILENCE_MAX_MS from useWebSocket.ts

The three names are part of the useWebSocket facade's pinned public surface on main: website/src/test/useWebSocket.ownership.test.ts "the facade exports exactly its original names" lists all three, on origin/main and unchanged by this PR.
Dropping the re-export was tried locally: that ownership test then fails (expected 35 names, received 32), so the subtraction narrows a contract main pins rather than removing dead code.
Shrinking the facade's surface is outside this fix's goal (apply the silence watchdog to the two app sockets); the re-export keeps the facade's surface byte-identical while the constants live in the shared helper.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 30, 2026
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • rebutted span=d9c9f6fd13b9 — Socket silence falsely reports running turns as stopped (website/src/apps/crew-companion/sessionWatch.ts:194)

Disproportionate, and adjudication downgraded it (disproportionate-remedy). The silence path's failInFlight() is the same disconnect bookkeeping the pre-existing onclose path already runs (sessionWatch.ts:428): a socket that dies and closes already reports in-flight turns as failed today. This PR only applies that rule to a dead socket that never closed.
It needs a transport that is actually dead: 20s of visible time with no frame while the gateway pushes a status frame every 5s. The worst case is one wrong "Stopped" bubble; the gateway turn is untouched and the next socket's slots frame re-derives state.
Avoiding it needs a new mechanism that matches tracked turns against confirmed gateway state on both the close and silence paths, because failInFlight exists so turns whose chat_done was lost do not sit in startedAt forever. That is outside this fix's goal (recover a silently-dead app socket without a reload).

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 30, 2026

@buluoray buluoray 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.

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Requesting changes for one user-facing behaviour. The extraction itself looks right: the dashboard hook keeps its behaviour, and removing silence.markFrame() from the Crew Companion onmessage reddens keeps a socket that receives the 5s status frame.

On a watchdog replacement, do not report in-flight turns as failed. In sessionWatch.ts, onDead calls failInFlight(), which marks every started slot failed and runs finish() with silent: false, so the bubble ignores the notifications setting. In the case the watchdog targets (the socket died, the gateway did not), those turns are usually still running. The next slots frame re-adds them, so the person sees "failed" and then "done" for the same turn, and this PR makes that more frequent (any 20 s gap in the status push while the page is visible).

Please either skip failInFlight() on a watchdog replacement and let the new socket's chat_done close the turns, or defer the failure to the first slots frame after reconnect and fail only slots that are no longer running. Add a test asserting what onDone receives on a watchdog replacement (the current spec passes onDone: () => {}).

Docs follow-up: docs/system-specs/modules/learn-cron-dashboard.md still describes the silence watchdog as a useWebSocket feature only; it should name utils/socketSilenceWatchdog.ts and the two app sockets.

Minor: the consecutive-silent-replacement count now resets whenever the hook's watchdog effect re-runs; before, it lived in a ref and survived re-runs.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 30, 2026
…nion sockets

Both app sockets reconnected only from onclose, so a socket that stayed
OPEN with its transport gone sat stale until a reload. The dashboard's
silence rule is extracted into one framework-agnostic SilenceWatchdog
(website/src/utils/socketSilenceWatchdog.ts) that the dashboard hook,
the Mochi panel bridge and the Crew Companion session watcher all drive.

The dashboard hook keeps one watchdog instance for its lifetime, so the
consecutive-replacement streak survives a re-run of its arming effect.

On a watchdog replacement the Crew Companion leaves its in-flight turns
to the fresh socket's first slots frame: a slot still running is closed
by its own chat_done, a slot no longer running is reported as failed.
A close before that frame fails them as any dropped socket does.

Closes #14225
@dodgeblaster
dodgeblaster force-pushed the feat/silent-socket-watchdog-app-sockets branch from dc1c020 to 12641c6 Compare November 2, 2026 03:37
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

@buluoray thanks, all three points are addressed on head 12641c6 (rebased onto current main, still one commit).

In-flight turns on a watchdog replacement. I went with your second option. onDead in website/src/apps/crew-companion/sessionWatch.ts no longer calls failInFlight(). It sets settleOnSlots, and the fresh socket's first slots frame settles the turns that were in flight: a slot it lists as running keeps its original start and is closed by its own chat_done (one success, timed from the start the silent socket saw), and a slot it does not list as running is reported as failed, the same as a dropped socket reports it. Only that first frame settles. If the fresh socket closes before it arrives, onclose clears the flag and failInFlight() runs as before. I picked this over skipping the fail outright because a turn that ended while the socket was silent never gets a chat_done on the new socket, so it would have sat in startedAt forever.

New specs in website/src/test/CrewCompanionSocketSilence.test.ts assert what onDone receives (the harness now records onDone with notifications on):

  • nothing at the replacement itself;
  • a turn the first slots frame lists running: nothing at that frame, then exactly one failed: false from its chat_done;
  • a turn it lists not running: exactly one failed: true, with no second report from a later slots frame or a stray chat_done;
  • only the first slots frame settles;
  • a close before that frame: one failed: true.

Putting failInFlight() back into onDead turns three of these red.

Docs. docs/system-specs/modules/learn-cron-dashboard.md now names utils/socketSilenceWatchdog.ts, the Mochi panel socket and the Crew Companion socket, and describes the replacement settle rule.

Streak reset on effect re-run. Fixed. useWebSocket now builds its one SilenceWatchdog lazily in a ref for the hook's lifetime. The arming effect only re-points silenceHostRef (the live socket's isOpen and forceReconnect) and calls start()/stop(), so the consecutive-replacement count and the visible-time stamps survive a re-run, as the old refs did. This also closes a side case: a fresh instance had lastFrameAt = 0, so a check that landed before the next frame could have replaced a healthy open socket. website/src/test/socketSilenceWatchdog.test.ts pins that stop() + start() keeps the widened window.

Local runs: the six silence/session-watch/ownership spec files plus every useWebSocket* spec (65 files, 760 tests) pass, along with tsc, eslint, the comment-history gate, the brand gate, and black/isort/flake8/mypy plus pytest on the backend contract pin. CI is running on the new head.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Hold: active change request. Reviewed head 12641c6a4bb589b86b6f5d1de6a980011f7a6931.

@buluoray's CHANGES_REQUESTED review (on dc1c020) is still active. The author's reply says all three points are addressed on this head, and the code agrees: a watchdog replacement no longer fails in-flight turns but lets the first slots frame settle them, the spec names the shared helper, and the hook keeps one watchdog instance so the streak survives effect re-runs. I found no defect, CI is green and the merge is clean. This clears when @buluoray re-reviews or dismisses the request.

AI findings judged non-blocking:

  • GPT 6.1 (downgraded on adjudication): a stop flag from a turn whose chat_done was missed during silence can suppress the successor's done bubble (
    if (running.has(slot)) continue
    ). Judged non-blocking: needs a stop, 20 s of silence and a new turn in the same slot together, and the only cost is one missing success bubble; failures are never silenced.
  • First Principles item 1: the shared helper's header and the spec name the two app sockets that are leaving core. Does not block: comment/doc wording.

— crew-pr-reviewer (r141)

@bolichen97

Copy link
Copy Markdown
Contributor

@buluoray, could you take another look when you have a moment? Each point from your review looks addressed at 12641c6:

  • Watchdog replacement no longer fails in-flight turns. In sessionWatch.ts, onDead sets settleOnSlots instead of calling failInFlight(). The fresh socket's first slots frame then keeps every slot it lists as running, for its own chat_done to close, and fails only the slots it no longer lists. A close before that frame still falls back to failInFlight().
  • CrewCompanionSocketSilence.test.ts now asserts what onDone receives on a replacement: a still-running turn ends as not failed, a turn the first slots frame drops is failed once, only the first slots frame settles, and a close before that frame fails the turn.
  • learn-cron-dashboard.md now names utils/socketSilenceWatchdog.ts and the Mochi panel and Crew Companion sockets.
  • The hook keeps one SilenceWatchdog instance in a ref for its whole lifetime, so the consecutive-replacement count survives a re-run of the arming effect.

Your review is the remaining blocker. Thanks.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 5, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #32931; thanks for the start.

bolichen97 added a commit that referenced this pull request Nov 8, 2026
The Mochi panel and Crew Companion sockets reconnected only from
onclose, so a socket that stayed OPEN with its transport gone sat stale
until a reload. The dashboard's silence rule is extracted into one
framework-agnostic SilenceWatchdog (website/src/utils/
socketSilenceWatchdog.ts) that the dashboard hook, the Mochi panel
bridge and the Crew Companion session watcher all drive.

The dashboard hook keeps one watchdog instance for its lifetime, so the
consecutive-replacement streak survives a re-run of its arming effect.

On a watchdog replacement the Crew Companion leaves its in-flight turns
to the fresh socket's first slots frame: a slot still running is closed
by its own chat_done, a slot no longer running is reported as failed.
A close before that frame fails them as any dropped socket does.

Builds on #22652 by @dodgeblaster.

Closes #14225

Co-authored-by: Gary Jennings <garysjennings@gmail.com>
bolichen97 added a commit that referenced this pull request Nov 8, 2026
The Mochi panel and Crew Companion sockets reconnected only from
onclose, so a socket that stayed OPEN with its transport gone sat stale
until a reload. The dashboard's silence rule is extracted into one
framework-agnostic SilenceWatchdog (website/src/utils/
socketSilenceWatchdog.ts) that the dashboard hook, the Mochi panel
bridge and the Crew Companion session watcher all drive.

The dashboard hook keeps one watchdog instance for its lifetime, so the
consecutive-replacement streak survives a re-run of its arming effect.

On a watchdog replacement the Crew Companion leaves its in-flight turns
to the fresh socket's first slots frame: a slot still running is closed
by its own chat_done, a slot no longer running is reported as failed.
A close before that frame fails them as any dropped socket does.

Builds on #22652 by @dodgeblaster.

Closes #14225

Co-authored-by: Gary Jennings <garysjennings@gmail.com>
bolichen97 added a commit that referenced this pull request Nov 8, 2026
The Mochi panel and Crew Companion sockets reconnected only from
onclose, so a socket that stayed OPEN with its transport gone sat stale
until a reload. The dashboard's silence rule is extracted into one
framework-agnostic SilenceWatchdog (website/src/utils/
socketSilenceWatchdog.ts) that the dashboard hook, the Mochi panel
bridge and the Crew Companion session watcher all drive.

The dashboard hook keeps one watchdog instance for its lifetime, so the
consecutive-replacement streak survives a re-run of its arming effect.

On a watchdog replacement the Crew Companion leaves its in-flight turns
to the fresh socket's first slots frame: a slot still running is closed
by its own chat_done, a slot no longer running is reported as failed.
A close before that frame fails them as any dropped socket does.

Builds on #22652 by @dodgeblaster.

Closes #14225

Co-authored-by: Gary Jennings <garysjennings@gmail.com>
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Closing as superseded: #32931 (bolichen97, merged 2026-11-08) builds on this PR's silent-socket watchdog and closed #14225, so the work now lives on main. The branch is kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply the silent-socket watchdog to the mochi and crew-companion /api/ws sockets

4 participants