Skip to content

fix(dashboard): keep unread state on the gateway so every device agrees - #37215

Merged
rnoack1 merged 1 commit into
mainfrom
fix/36613-server-unread-sync
Nov 19, 2026
Merged

rnoack1 merged 1 commit into
mainfrom
fix/36613-server-unread-sync

Conversation

@rnoack1

@rnoack1 rnoack1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Unread badges are right on every device and after every reconnect, including for messages that arrived while no dashboard window was open.

Unread badges lived only in each browser's localStorage and were set only by live socket frames. A message that arrived while no window was open never badged its session, because reconnect catch-up suppresses marking. A second device kept stale badges for sessions read elsewhere and missed new ones. A read sent while the socket was down, or lost when a stalled gateway's socket was killed, was gone for good.

Why it matters

Unread is the main way a person finds the sessions that need them. Today it is right only for a browser that stayed open the whole time, so a phone and a desktop disagree, and a laggy gateway can bring back badges for sessions already read.

Not a goal

What changed (motivation → approach → change)

The gateway now remembers when each session was last read, so every device can work out the same unread list.

Part Change
Gateway slot_read in dashboard/ws.py keeps the newest read time per session in dashboard/slot_read_state.py (one small file in the fenced pinned-order directory). Writes run one at a time. The read is relayed to every window at once, as before; once that time is on disk a second slot_read with stored: true follows, and only that echo lets a browser drop its kept read, so a browser never drops a read the gateway could lose.
Slot rows state_parts/slots_frame.py puts last_read_ts (the session's stored read, or null) and read_epoch (when the store was first written) on each row, typed in types/index.chat.ts; dashboard/pinned_session_order.py strips both from app and member callers like the order fields. dashboard/slot_row_memo.py and dashboard/slot_projection.py add unread_ts, the newest row the live rule would badge (a crewmate thread's newest reply; otherwise its newest saved row that is not the person's own prompt or a recycle notice: a reply, a tool or notice row, a note, an error), and unread_failed when that row is a terminal failure.
Browser After each full slot list, websocket/serverReads.ts clears badges a real read covers, and badges sessions whose unread_ts is newer than both the read and read_epoch; under "only when done or waiting" an idle chat badges on its turn's last agent row or terminal failure instead, so a later note stays quiet, as live. read_epoch never clears a badge. A terminal failure badges a muted session, as live; until the app mutes have loaded, no session an app could mute is badged, and websocket/slotList.ts runs the pass once more on the current rows when they load. A row shown on screen, live or after reconnect catch-up (websocket/attention.ts, websocket/reconnectCatchUp.ts), is sent as read in a focused window or noted as shown in lib/slotReadRelay.ts otherwise. A read of a crew conductor also covers the pending approval rows of its crew members, so the conductor's badge stays cleared on a device that never saw the prompt arrive.
Read outbox Every read is also kept in localStorage (lib/readOutbox.ts) until the gateway confirms it, and each new connection sends it again once. Until then it counts as read.

A read only moves forward on the gateway, so resending is safe. A reply older than read_epoch never badges, so an upgrade badges nothing old and keeps the badges a browser already had. Specs for the socket frame, the store directory and the websocket owners are updated.

Backwards compatibility

Compatible: slot_read keeps its frame shape and its immediate relay; the stored echo only adds a stored field, and an older browser ignores it and the new last_read_ts, read_epoch, unread_ts and unread_failed row fields.

Removes nothing: the per-window unread record stays as the fast cache; the gateway only adds a stored read time.

Tests

  • test/test_slot_row_memo.py: unread_ts follows the live badge rule: a note, a tool, system or notice row, and any error move it (a terminal failure also sets unread_failed), the person's own prompt and a recycle notice do not, and a crewmate's tool-only tail leaves its reply time alone.
  • test/test_slot_read_state.py: reads only move forward by instant, the file round-trips beside the orders, a read before the load is merged, writes coalesce and run one at a time, a failed first write publishes no epoch and is retried, rows carry only a written read and carry the epoch apart, and a read reaches the rows and survives a gateway restart.
  • test/test_eager_spawn_slot_frames.py: every slot_read is relayed at once with the sender's time, the stored echo waits for the write, a failed write still relays but sends no echo until the resend, a read during a write gets its own write, an older read echoes the newer stored time, and an unparseable time relays as sent and is never stored.
  • test/test_pinned_session_order.py and test/test_manual_session_order.py: the post-listen load publishes exactly twice (orders, then read times) and a repeated load publishes nothing.
  • website/src/hooks/websocket/serverReads.test.ts: badges a missed reply, clears what another device read, re-badges a reply newer than the read that cleared an old badge, keeps manual marks, skips on-screen and muted slots, badges a missed crewmate reply and a muted session's terminal failure, holds an app-owned session's badge until the app mutes load and then badges it with no new slot list, badges a running turn only when it waits on the user, keeps a note after the turn and a running crewmate thread quiet under that setting, badges a crew conductor whose worker waits on an approval and keeps it clear once the conductor is read in a window that never saw the prompt, the store epoch never clears a restored badge and badges no reply before it.
  • website/src/hooks/websocket/reconnectCatchUp.shownRow.test.ts: a reply shown by reconnect catch-up in a focused window is sent as read and does not badge after switching away; an unfocused window keeps it as shown here.
  • website/src/test/readOutbox.test.ts: the outbox keeps the newest read, survives a reload, forgets only on a covering ack, caps its size, and resends each kept read once.
  • website/src/test/slotReadRelay.test.tsx: through the real socket hook, the first slot list badges a missed reply, a read made while the socket was down is sent once by the next socket and cleared only by the stored echo, never by the plain relay, and a resent read never covers a later unseen permission row.

Each fix was broken on purpose and its tests went red, including the relay held back until the write, the outbox dropped by a plain relay, the overlapping writes, the unwritten epoch, the epoch clearing a badge, the resend covering a permission row and the catch-up read. New tests also ran green in a shuffled order.

Proof: not provable -- other: the fix adds a new module, so reverting it fails test collection instead of an assertion

Manual verification

N/A — unit and socket-hook tests cover the store, the row field, the derivation and the outbox; no new UI surface.

Screenshots / video

Why no screenshot: the unread dot renders exactly as before; only when it is set changes, which the socket-hook tests show.

Related Issues

Closes #36613

Sibling sweep

Swept: git grep -n "markSlotUnread" -- website/src
Siblings: none -- every automatic marker runs on live frames only; the new slot-list pass covers all of them at once

Pattern harvest

Not generalizable: this is a missing piece of state, not a repeated code shape.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@rnoack1
rnoack1 requested review from a team and KiroCrewCaptain as code owners November 14, 2026 12:25
@rnoack1
rnoack1 requested a review from CrysisDeu November 14, 2026 12:25
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing to check. The diff adds or changes no control, label or string. It only changes when the existing unread dot gets set: gateway storage, hooks and lib logic, with no TSX or i18n changes. So the missing blind read leaves no evidence gap.

[UX-REVIEWED] e9e106d

Description read

[DESCRIPTION-READ] c55850f82f89666a1381ec4ca0e6f61d8afe51b3c526d476e109fb696d4349cb

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 Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e9e106d7734c6d0e440911a312f29fa43affd19d — 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. Issue #36613 is the evidence for reversing the old ws.py pin ("the server keeps no read-state: unread is a frontend concept … and stays one"), and the description states that problem.

Notes

  • Item 9 — one consumer, generalized: summarize_rows(..., retry_kind: str) has 1 production caller (slot_projection.py:362), and it always passes _cu.TRANSIENT_RETRY_KIND. Subtraction: delete the retry_kind parameter and read the constant inside slot_row_memo.summarize_rows.

What this change ships

Inventory (9 items) — 8 justified

Intent: unread badges agree on every device and after reconnects, including messages that arrived while no window was open. This is a FIX.

  1. The gateway now remembers each session's last read time, and it survives a restart. — justified
  2. A session that got a reply while every window was closed is badged when the slot list arrives. — justified
  3. A session read on another device stops showing a badge here. — justified
  4. A read made while offline is kept in the browser and sent again on the next connection. — justified
  5. A second slot_read echo with stored: true arrives after the read is saved on the gateway. — justified
  6. Replies older than the store's creation never badge after an upgrade (read_epoch). — justified
  7. Reading a crew conductor also covers its members' pending approval prompts. — justified
  8. A reply shown during reconnect catch-up in a focused window counts as read. — justified
  9. slot_row_memo gains new row fields unread_ts/unread_failed and a retry_kind parameter. — one consumer, generalized

[FIRST-PRINCIPLES-REVIEWED] e9e106d

Description read

[DESCRIPTION-READ] 183bf5b20a244f5fdedd17534639621049610da8a119fa9a17f643228864f18c

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 Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: storing the newest read time per session on the gateway, and moving it forward only, is the right fix for unread badges that drift between devices and after reconnects.

Notes

  • slot_read_state puts in-memory state on DashboardState through a module-level WeakKeyDictionary. Making it a plain attribute on the state, like the pinned order, would make its ownership obvious and keep it out of any staticness scan.

[DESIGN-REVIEWED] e9e106d

Description read

[DESCRIPTION-READ] dbfecbb97cb8cb383988d26ca24d12bbf68cf35328cd4c5ab5b73360f6ffcbc1

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 Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] e9e106d

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

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

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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

GPT 6.1 flagged blocking issues on e9e106d7734c6d0e440911a312f29fa43affd19d; 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 -- src/kiro_crew/dashboard/slot_row_memo.py:186 -- A deferred note hides an unread terminal failure

last_unread_ts, unread_failed = message.get("ts") or "", failed
Trigger: While no dashboard is connected, a muted non-member session fails with a note held during its turn. _on_error appends the error; turn finalization reaches _finish_queue_cycle → flush_deferred_notes, which appends an inject row. summarize_rows selects that newer note and sets unread_failed to false.
Outcome: On reconnect, badgeMissed suppresses the muted session, leaving the unseen terminal failure without an unread badge. The live path retains the failure exemption through the same note.
Anchor: defect
Fix: Track the terminal failure timestamp separately from the newest ordinary unread row, and recover its badge when neither the read watermark nor the epoch covers it.
Sites: src/kiro_crew/dashboard/slot_projection.py:622; website/src/hooks/websocket/serverReads.ts:19; website/src/hooks/websocket/serverReads.ts:67.

[BLOCK-MERGE-DOWNGRADED] e9e106d
[GPT-REVIEWED] e9e106d

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

F1 — LOW harm. Every condition has to hold at once:

  • The session is muted and not a member: serverReads.ts:67 and slot_projection.py:622 ("unread_failed": slot.mode != "member" and …).
  • A note was held during the failed turn and is flushed after the error row, at queue_drain.py:663 / slot_buffers.py:1165.
  • That flushed note becomes the newest non-user row, so slot_row_memo.py:186 reads it and clears failed.
  • No dashboard is connected at that moment.

The only loss is the badge. There is no automatic recovery for it, but the failure isn't lost: the error row stays in the transcript, and a connected client still exempts it live. It affects only a session the user chose to mute. The real fix is costly: a second timestamp field and a failure flag carried through the summary, the projection and the frontend candidate and floor logic, all to serve one rare path.

[ADJUDICATION] e9e106d7734c6d0e440911a312f29fa43affd19d total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/dashboard/slot_row_memo.py:186 reason=disproportionate-remedy
[GPT-ADJUDICATED] e9e106d7734c6d0e440911a312f29fa43affd19d

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

@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 Nov 14, 2026
@KiroCrewCaptain

KiroCrewCaptain commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 25% chance that this change introduces a defect, above the 12% limit for approving on its own.

The gateway now saves each session's last read time in the fenced pinned-order directory. Only the owner can write it, it only moves forward and writes run one at a time. The time and an upgrade floor go out on every slot row and are stripped for app and member callers via PIN_ORDER_FIELDS. The browser works out missed badges after each slot list and keeps reads the gateway hasn't confirmed in an outbox, resending them on reconnect. I checked the trust gate, field stripping, how saving and loading behave on failure and on repeat, resend on socket open, and the live-arrival paths, and found no regression. Tests are thorough and CI is green. The one confirmed gap (a muted session's failure followed by a held note while no dashboard is open) is a rare path; I left it as a non-blocking note.

Tier: 2, held for a person: changes requested.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit e9e106d773 · 1570 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@rnoack1
rnoack1 force-pushed the fix/36613-server-unread-sync branch from 5bb32d0 to 544fb0f Compare November 14, 2026 21:49
@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 Nov 14, 2026
@rnoack1

rnoack1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=298f7e49e53c Reads are acknowledged before persistence succeeds

fixed in 544fb0f: _handle_slot_read in dashboard/ws.py no longer echoes on receipt; the save task in dashboard/slot_read_state.py sends the echo only after the read time is written, and a failed write stays dirty and sends no echo.
Tests: test_eager_spawn_slot_frames.py::TestSlotReadFrame::test_the_echo_waits_for_the_write and test_a_failed_write_sends_no_echo_and_the_resend_retries_it; both fail on the old ws.py.

@rnoack1

rnoack1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e Clearing an old badge skips the newer unread reply

fixed in 544fb0f: in websocket/serverReads.ts, clearing an automatic badge no longer continues; the row falls through to the newer-reply check. Manual unread still skips.
Test: serverReads.test.ts "re-badges a reply newer than the read that cleared the old badge"; fails with the old continue.

@rnoack1

rnoack1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e A quick reconnect strands an unconfirmed read

fixed in 544fb0f: resetServerReadsForConnection in websocket/serverReads.ts clears the resend times, and slotList.ts resetForConnection calls it, so an unconfirmed read is resent on the first list of a new connection.
Test: serverReads.test.ts "is sent again on the first list of a new connection"; fails without the call.

@rnoack1

rnoack1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=2129a419e30e Exact publication-count assertions are loosened

fixed in 544fb0f: test_pinned_session_order.py::test_the_post_listen_load_publishes_the_ranks and test_manual_session_order.py::test_a_manual_order_survives_a_gateway_restart pin call_count == 2 (orders, then read times), before and after the repeated load.
Removing the read-state loader's if reads.loaded: return makes the pinned test fail.

@rnoack1

rnoack1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=1749dc811eff slot_patch re-derives badges from older list times

fixed in 544fb0f: slotList.ts onSlotPatch passes clearOnly: true to applyServerReads, so a patch can clear a badge a kept read covers but never adds one; patch rows carry no read or agent times, so they have nothing new to badge with.
Tests: serverReads.test.ts "a slot_patch frame" › "never badges from the older read and agent times its rows keep" (fails without clearOnly) and "still clears a badge a kept read covers".

@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=177359c37691 A transient write failure strands reads on an idle connection

Rebutted: disproportional. After a failed write _dirty stays set (slot_read_state.py), so the next advance for any slot reschedules the save and rewrites the whole map; the next changed slot frame and every reconnect (resetServerReadsForConnection) also resend the outbox entry.
The residual is a stale badge on another device until the next slot change after a rare storage failure; a heartbeat-driven resend path would exist only for that case. The adjudicator downgraded it (disproportionate-remedy).

@rnoack1
rnoack1 force-pushed the fix/36613-server-unread-sync branch from 544fb0f to c50d52b Compare November 14, 2026 22:14
@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=f8994bf00e5d a resent kept read merges unseen permission rows

fixed in c50d52b: applyServerReads in websocket/serverReads.ts resends a kept read through the new resendSlotRead (lib/slotReadRelay.ts), which sends the kept time as-is and never adds unsavedRowTs; the on-screen gesture path emitSlotRead is unchanged.
Test: slotReadRelay.test.tsx resend case with a later permission row; fails with emitSlotRead.

@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e Resending a read acknowledges unseen permission rows

fixed in c50d52b: the resend in websocket/serverReads.ts goes through resendSlotRead (lib/slotReadRelay.ts), which sends the queued watermark without the unsaved-row merge.
Test: slotReadRelay.test.tsx resend case with a later permission row; fails with emitSlotRead.

@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e Waiting approvals are incorrectly treated as routine running activity

fixed in c50d52b: unreadCandidateTs in websocket/serverReads.ts skips a running turn only when it is not waiting on the user (pending_approval or needs_input), matching the live rule that badges approval and question cards.
Test: serverReads.test.ts running-but-waiting case; fails on the old condition.

@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=3f8aef3f9649 Startup writes can overwrite an acknowledged read

fixed in c50d52b: ReadState.save_now in dashboard/slot_read_state.py holds one asyncio.Lock for every write, initialization included, and takes its snapshot inside the lock, so an older snapshot can never land over a newer one.
Test: test_slot_read_state.py stalled-startup-save case driven by an event; fails without the lock.

@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=3f8aef3f9649 Failed initialization publishes an unwritten baseline

fixed in c50d52b: rows carry a read only once written_epoch is set by a successful write; load_read_state_after_listen publishes only after save_now returns True, and a repeat load retries a failed first write.
Test: test_slot_read_state.py failed-first-write case; fails on the old loader.

@rnoack1

rnoack1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e An already-read tool timestamp hides a later elicitation prompt

Rebutted: disproportional. It needs a read tool row, then a disconnect, then an elicitation; the pending prompt still shows its own waiting dot and reconnect re-syncs approvals and questions, so the session still shows it needs the user.
Closing it would add a new gateway row field for this one path; the adjudicator downgraded it (disproportionate-remedy).

@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 Nov 14, 2026
@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 Nov 16, 2026
@rnoack1
rnoack1 force-pushed the fix/36613-server-unread-sync branch from 397069f to f22a8f1 Compare November 16, 2026 14:30
@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • span=e0d9a0dc5038 a crewmate thread's unread reply gets no badge when its newest rows are a prompt then tool rows

fixed in f22a8f1: the newest-first scan in summarize_rows (slot_row_memo.py:209) now stops only once last_reply_ts is set too, so it reads past the prompt to the older assistant reply. The cost is bounded: it stops at the first older assistant row, and the memo tail cap already bounds a transcript with none.
last_unread_ts was never cut short by the old break: any row that sets last_agent_ts also sets it.
Test: test_slot_row_memo.py:514, the user case now carries content so it reaches the break; it fails on 397069f (got ('', '2', False)) and passes on f22a8f1.

@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 Nov 16, 2026
@rnoack1
rnoack1 force-pushed the fix/36613-server-unread-sync branch from f22a8f1 to d27222b Compare November 16, 2026 15:23
@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 Nov 16, 2026
@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author
  • span=f8994bf00e5d relayed slot_read did not mark the row shown here

fixed in d27222b: website/src/hooks/useWebSocket.ts:699 now runs else noteShownHere(r.slot, readTs) for a plain relayed slot_read, so this device stops badging a row another device already read. Rows still publish only persisted reads.

@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author
  • span=e58ee26efa2a spec sentence did not match the read-relay behaviour

fixed in d27222b: docs/system-specs/modules/learn-cron-dashboard.md:2423 (the ws.py entry) is rewritten to describe what the code does now.

@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author
  • span=920df7efc3da row marked shown while not rendered visibly

fixed in d27222b: website/src/hooks/websocket/attention.ts:139-140 (recordShown) now requires isSlotRenderedVisibly(slot) (defined at line 109) before it emits a read or calls noteShownHere. Covered by website/src/hooks/websocket/reconnectCatchUp.shownRow.test.ts.

@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author
  • span=687ca3e84e5b Slack-paused inbound user row (downgraded)

not changed in d27222b: the lane downgraded this one. A fix needs a new provenance field carried across several modules, which is out of proportion to the effect. The badge recovers once Resume runs, and the message is visible in Slack the whole time.

@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author
  • span=687ca3e84e5b approval prompt that arrived offline gets no unread badge (downgraded)

Rebutted: disproportionate remedy, as the lane's own downgrade says. The prompt stays visible after reconnect: the replay adds it to the notification bell (website/src/hooks/websocket/approvals.ts:353) and the row keeps pending_approval (src/kiro_crew/dashboard/slot_projection.py:588). A badge would need a new projected prompt timestamp through backend projection, frontend types, recovery and conductor read coverage, which is wider than this PR's goal.

@rnoack1

rnoack1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e recovery treats the retained session as on screen while Settings shows (downgraded)

Rebutted: disproportionate remedy, as the lane's own downgrade says. Recovery (website/src/hooks/websocket/serverReads.ts:48,69) uses the same isSlotOnScreen rule as the live arrival path (website/src/hooks/websocket/attention.ts:132), so both agree. The reply shows as soon as the user returns to that session. Changing what "on screen" means for live and recovery together is wider than this PR.

@rnoack1
rnoack1 requested a review from bolichen97 November 16, 2026 15:50
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 16, 2026
@rnoack1
rnoack1 force-pushed the fix/36613-server-unread-sync branch from d27222b to e999845 Compare November 16, 2026 16:30
@github-actions github-actions Bot removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 16, 2026
@rnoack1

rnoack1 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author
  • span=3f8aef3f9649 evicted reads kept their waiting callbacks

fixed in 3aac109: advance drops _waiting entries for evicted reads (src/kiro_crew/dashboard/slot_read_state.py), whether or not a save ever lands; test test_waits_stay_within_the_kept_reads fails with the line removed and passes with it.

@rnoack1

rnoack1 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 could you take another look when you have a moment? The blocking point from your review is addressed in ce98ff6 in the shape you suggested: every valid owner slot_read is rebroadcast at once as on main, and a separate stored: true echo follows once the read is on disk, so the outbox drops an entry only on that echo or a row's last_read_ts. Current head is 3aac109, readiness: passed. Thanks!

@rnoack1

rnoack1 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author
  • span=0a0653d097c4 cross-window writes delete unconfirmed reads

fixed in 2a22928: queueRead and ackRead in website/src/lib/readOutbox.ts now run their whole load, change and store inside one navigator.locks.request('mc-read-outbox', ...) callback that every window shares, so no window writes between another's load and store; without Web Locks it runs at once. website/src/test/readOutbox.test.ts interleaves a second window's queueRead inside ackRead's load: it loses the read on the old code and keeps it on the new code.

@rnoack1

rnoack1 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author
  • span=b164ede1c47e reconnect re-badges replies already read through a session switch

fixed in 3497f47: both successful return paths of switchSlot (website/src/store/chat/slotSwitch.ts) now emit newerTs(_newestSlotTs(), newestServerRowTs(<fetched rows>)), so the read watermark is the newest gateway-minted row the fetch rendered, not the stale sidebar last_ts. newestServerRowTs moved to website/src/lib/slotReadRelay.ts and reconnect catch-up uses the same helper. A new test in website/src/test/slotReadRelay.test.tsx fails on the old slotSwitch.ts and passes on the new one.

@rnoack1

rnoack1 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author
  • span=0a0653d097c4 reconnect replay skips reads awaiting the outbox lock

fixed in fa44454: resendKeptReads in website/src/lib/readOutbox.ts now loads and sends inside the same navigator.locks.request('mc-read-outbox', ...) as the writes, through a shared locked() helper; Web Locks grant in request order, so the resend runs after any write queued before it. A read still waiting on the lock is kept in an in-memory pending map that queuedReads merges, so the synchronous readers in serverReads.ts see it too. website/src/test/readOutbox.test.ts queues a read while the lock is held and checks both the resend and queuedReads: it fails on the old code and passes on the new.

The gateway stores each session's newest read; rows carry it as last_read_ts.
Browsers derive badges from it and keep unconfirmed reads until acknowledged.

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

Re-reviewed on e9e106d: my blocking point is fixed. _handle_slot_read rebroadcasts every valid owner slot_read at once, as on main, and the stored: true echo follows only after after_persisted, so other windows get the same immediate relay and the sender drops a kept read only on that echo. The outbox work since (one shared navigator.locks section for queue, ack and resend; the switch-slot watermark from the fetched rows) also reads right, with a test that fails on the old code for each.

I'm dismissing my earlier change request. What is left is the maintainer design sign-off the Captain asked for (this changes how unread badges behave across devices); I've put it in front of a maintainer and will approve once that is recorded.

AI-assisted, sent by Bolin Review bot

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

Maintainer design sign-off on head e9e106d773: approved. Keeping each session's read point on the gateway, owner-only and forward-only, is the design we want, so unread state agrees across devices. Readiness passed and CI is green.

AI-assisted, sent by Bolin Review bot

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.

Unread badges are per-browser, so they miss messages that arrive while no window is open and never sync across devices

3 participants