Skip to content

fix: retire expired approvals from the notifications feed - #14739

Closed
jeeshofone wants to merge 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/14711-feed-expired-approval
Closed

jeeshofone wants to merge 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/14711-feed-expired-approval

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An expired tool approval stops sitting in the Notifications panel with dead Approve and Reject buttons, and a failed press or dismissal on a feed row says why.

An expired cron approval stayed in the feed with live Approve and Reject; each press 404'd.

Why it matters

Cron and sub-agent approvals expire fast.

Not a goal

Design

  • One decision lifecycle per approval row in notificationsSlice.ts: idle -> deciding -> settled. decideApprovalRow, the one decide path for feed and panel, marks the row deciding, sends its target and settles on the response. A frame that ends the request calls endApprovalRow: an idle row leaves, a deciding row stays until its response lands. A terminal refusal retires the row. A landed decision whose stored-note DELETE fails settles as dismissFailed (decided): controls withdrawn, an info StatusNotice (decision_recorded) above a block ErrorNotice (decided_clear_failed). A retryable failure keeps the buttons unless a frame ended the request meanwhile.
  • Snapshots, clears and the ring cap keep a deciding row: refetch and clear-all go through replaceRows, and every growth path through ONE cap, capRows. A settled row is evicted like any note.
  • Plain failure copy (decisionFailedCopy): a 4xx reason is quoted; a 5xx or no response hedges with the chat approval card's own components.approvalCard.decision_failed, on a live row and on one a frame ended meanwhile.
  • A row leaves only through its close X. On a stored note that is the feed's one-note clearNotes clear (feat(notifications): stack notes by sender, clear by group #22744): a failed DELETE keeps the row under the one clear_failed notice. A local row leaves through dismissApprovalRow (dismissLocalApprovalRow). A close X or clear-all on a deciding row marks it dismissed, apart from a frame's ended: on a retryable failure the row leaves, and only a frame-ended row says "no longer pending". Why no Dismiss in the detail panel: its Close is one press from the row's X, as for every other note.
  • Why keep a row whose request ended: a press in flight would lose its refusal.

What changed (motivation → approach → change)

  • An approval_resolved frame ends the instance-matched feed row (hooks/websocket/approvals.ts), so an expired cron approval leaves the feed. The frame names the record's instance (interaction_coordinator.py, state_parts/dashboard_services.py).
  • A live approval frame, or a reconnect listing a new instance under an id, ends the live row bound to another instance; the reconnect still adds the listed request's row beside an ended chat row. A read a newer one overtook changes nothing.
  • A row carries its request's approval_instance (types/index.chat.ts) and decides with the coordinator target (api/client/approvals.ts), so the server refuses a stale instance. A slotless row (cron, autonudge, task runner) sends an empty slot, matched only against a record with no slot (handlers/sessions_parts/live_turn.py).
  • A refused press keeps its row, retired, with approval_no_longer_pending through ErrorNotice and its close X visible. A withdrawn panel hides the read toggle; Close only closes and takes the lost focus. A row that leaves after a landed decision hands lost focus to the feed list. A retryable failure says why on the row.
  • A settled row is read in this tab only, dimmed and out of the unread count, through a refetch or a late unread receipt.
  • New notificationFeed keys decision_recorded and decided_clear_failed (it names the row's dismiss control by its accessible name) in every catalog (website/src/i18n/locales/).
  • Spec: learn-cron-dashboard.md; api-reference.md (approval_resolved). coverage-baselines/frontend.txt drops NotificationDetailPanel.tsx, now over the per-file floor.

Backwards compatibility

Compatible: approval_resolved gains an optional instance. The decide route's coordinator target also accepts an empty slot for a record with no slot. Who may decide is unchanged: only the owner's browser session, which alone could decide a slotless record, may use the empty slot (bare_approval_decide_allowed), so AttentionCard.tsx's slotless decides stop getting 400; the internal secret, a peer-verified subprocess with no app claim and no claim get 403 approval_owner_required (pinned in test_chat_mode_security.py).

  • Readers: ChatEmbed.tsx ignores instance; kirocrew_client uses the bare-id route; mochi reads approved; crew-companion releases on any resolution.

Tests

Proof: not provable -- other: prove.py exits 2 applying this diff's committed PNG stills

Frontend, in website/src/test/:

  • notificationsSlice: end frames, ring fills and a local close X keep a deciding row; a refetch and a late unread receipt keep a settled row read; a refused DELETE keeps the decided mark; a row closed or cleared mid-flight leaves on a retryable failure instead of retiring; a 500-seed property test.
  • NotificationFeed.retiredApproval: 5xx hedged on the row; an approve racing the expiry frame shows the refusal; a 503 or no response after it retires the row; a decided row's failed DELETE shows the status and the one alert; settled rows leave the unread count; a landed decision hands focus to the named list; 404.
  • NotificationDetailPanel.approvalRefusal: the same, panel open; Close only closes and takes lost focus; no panel Dismiss; a retired row's failed DELETE claims no decision; a failed feed close X shows one clear_failed; expiry, snapshot or clear-all mid-decision keeps the row.
  • UseWebSocketCoverage: a reconnect's new instance adds its row; the tracked one does not; an overtaken first-connect read changes nothing. hooks/websocket/approvals.overtakenRead: an older read answering after or before a newer one changes nothing. 10 shuffled runs pass.
  • Also useWebSocket.frameTrace, NotificationDetailPanel.readAndRelated; server: test_dashboard_approval_denials.py, test_chat_mode_security.py, test_state_parts_dashboard_state.py.
  • Mutation checks: each lifecycle line, the decided gates, both lost-focus guards, the list's tabIndex, role and name, the copy's control name and the reconcile's instance terms and generation check turn a test red.

Manual verification

website/scripts/capture-notification-approval-refusal.mjs drives the built SPA and asserts each frame's state before writing it; all frames passed on 539e80febf; frames 04 and 20 count only the detail panel's own Approve and Reject.

Commits

This PR has two commits. The first retires expired approvals from the feed, and #16481 carries it on its own. So unackNotificationByTs checks the settled state inline there, and the commit builds and passes without isSettledApprovalRow, which arrives with the second commit. Switching that check to the helper once both commits are on main is #25227.

Screenshots / video

In temp-screenshots/notification-approval-refusal/: 01, 05, 09 404 retired; 03, 04, 06, 10 503 or no response; 13, 15 expiry removes the row; 17, 17b (light), 18 decision lands, DELETE fails; 19, 20 400 quoted; 21, 22 slotless cron approval and its expiry; 24, 25 expiry during the press, then 503.

Related Issues

Closes #14711

Sibling sweep

Sibling: website/src/components/chat-input/approval.ts -- tracked in #16389
Sibling: website/src/pages/chat/ActivityViewer.tsx -- tracked in #16389
Sibling: website/src/pages/chat/page/transcriptRendering.tsx -- tracked in #16389
Sibling: website/src/hooks/useSceneInteraction.tsx -- tracked in #16389
Sibling: website/src/pages/ProjectDetailPage.tsx -- tracked in #16389
Sibling: website/src/pages/chat/command-center/AttentionCard.tsx -- not affected -- it already sends the coordinator target

Pattern harvest

Rule candidate: review-prompt
Pattern: a row a concurrent frame, snapshot or cap can remove needs one per-row hold before its press can report a refusal.

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

Contribution License Agreement

@jeeshofone
jeeshofone requested a review from a team September 28, 2026 16:12
@jeeshofone
jeeshofone requested a review from a team as a code owner September 28, 2026 16:12
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 7d61167fe7e4432a128d860cbf2abb4edb43b6fc via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the patch removes nothing, rendered evidence of this revision is committed, and slotless decides use the same owner check as the bare-id route.

Notes

  • The coordinator-target branch now resolves through shared_decisions.resolve_state_approval, which records the responder and makes a second collaborator's press get 409 already_resolved. The visible description does not mention this behaviour change; state it, or move it to its own PR.
  • The lifecycle is now spread across three fields: approvalDecisions, retiredApprovals and dismissFailed. Folding them into one per-row phase record (refactor(notifications): one per-row phase record for approval rows #20618) should land before more surfaces attach to them.

[DESIGN-REVIEWED] 7d61167

Description read

[DESCRIPTION-READ] 292d2504a695c8d1254c405cb1578a770336754391318cc9cb219322fcb3673c

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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 7d61167fe7e4432a128d860cbf2abb4edb43b6fc via the fork AI-review pipeline — 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

Every item traces to issue #14711 or to an invariant the spec already records. The one leftover is a single-value map type, which is a note and does not block.

Notes

  • Item 9 — one consumer, generalized: dismissFailed?: Record<string, 'decided'> has exactly one constructed value ((state.dismissFailed ??= {})[ts] = 'decided', the only writer in notificationsSlice.ts), and readers test === 'decided' or bare presence. Subtraction: replace the one-literal value type with a presence-only set keyed by ts, or let refactor(notifications): one per-row phase record for approval rows #20618's per-row phase record absorb it without carrying the literal.

What this change ships

Inventory (10 items) — 9 justified

Intent: an expired tool approval should stop sitting in the Notifications panel with dead Approve/Reject, and a failed press should say why. FIX.

  1. When an approval expires or is decided elsewhere, its feed row leaves (the frame now names the request's instance) — justified
  2. A press the server refuses keeps the row, without buttons, under "no longer pending", with the close X always visible — justified
  3. A retryable failure (5xx, offline, or a quoted 4xx) shows on the row and in the detail panel, and the buttons stay — justified
  4. A decision that lands but whose stored-note delete fails shows "decision recorded" plus the clear-failed notice — justified
  5. A finished row is dimmed, loses its unread dot and critical border, and drops out of the unread count — justified
  6. Feed and panel decide with the coordinator target, so a press on a stale card is refused instead of settling a newer request — justified
  7. A slotless (cron) approval decides with an empty slot, owner-only; AttentionCard's slotless decides stop getting 400 — justified
  8. A coordinator-target decide records the verified responder in the Shared Crew registry — undeclared, rides along
  9. A row with a decision in flight survives refetch, clear-all and the ring cap until the response arrives — one consumer, generalized
  10. After the pressed button disappears, focus moves to the row's close X, the panel's Close, or the named feed list; the panel's mark-unread is hidden — justified

[FIRST-PRINCIPLES-REVIEWED] 7d61167

Description read

[DESCRIPTION-READ] 95acbdda4b48d5cce92e08db8167e6eabd2715a5edc7da773c2aecab74a86731

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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — 🔴 changes requested (blocking)

Reviewed 7d61167fe7e4432a128d860cbf2abb4edb43b6fc via the fork AI-review pipeline; updated in place on each push.

1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- src/kiro_crew/dashboard/handlers/sessions_parts/live_turn.py:188 -- Concurrent target decisions erase the winning responder (origin: validation)

target_reply = shared_decisions.resolve_state_approval(
Trigger: Two tabs decide the same coordinator instance concurrently. After the first resolves its future, api_approval_resolve still finds the pending record before ApprovalCoordinator.request finishes cleanup and calls this helper again.
Outcome: The helper’s DecisionRegistry.open() reopens the settled decision before discovering that its future is done. The waiter’s settle_after_wait() then overwrites the winning person with an Unknown responder and settled_by="host", corrupting the authoritative decision returned by /api/shared-crew/decisions.
Anchor: residual/crash-data-loss-corruption
Fix: Mirror resolve_approval_by_id’s non-done-future guard before calling the helper; classify late responses without reopening the settled record.

[BLOCK-MERGE] 7d61167
[GPT-REVIEWED] 7d61167

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

F1 (fenced): the harm is a corrupted attribution record for who decided an approval. I confirmed every condition in code and could not argue it is rare enough to FLAG.

  • How the record gets reopened. The waiter gets the result at interaction_coordinator.py:126. It removes the pending record later, at :145. In between, the new handler can run: it awaits request.json() (patch line 97) and then re-checks the still-present record (patch line 111). It then calls resolve_state_approval, whose registry.open() at decisions.py:202-215 starts a fresh PENDING revision because the earlier decision is already RESOLVED. The decision is left PENDING, because apply returns False at decisions.py:274-275 when the future is already done.

  • How the winner is overwritten. The waiter's settle_after_wait at interaction_coordinator.py:147 then finds a PENDING decision. At decisions.py:400-408 it resolves it with an Unknown responder and settled_by=host, replacing the person who actually won. Nothing corrects this afterwards.

  • Why this is not an extreme scenario. It needs two collaborators deciding the same card at once, which is exactly what the shared-decision registry exists for. The by-id path avoids this with a done-future guard at decisions.py:632-634, which this new caller lacks.

    [ADJUDICATION] 7d61167 total=0 uphold=0 downgrade=0
    [GPT-ADJUDICATED] 7d61167

    [ADJUDICATION-FENCED] 7d61167 fenced=1 flagged=0
    UPHOLD-FENCED F1 src/kiro_crew/dashboard/handlers/sessions_parts/live_turn.py:188 -- Two collaborators deciding the same card at once is the normal shared-crew case; the new caller has no done-future guard, so open() at decisions.py:202 reopens the settled decision and settle_after_wait at decisions.py:400 overwrites the winning responder with Unknown/host, with no later correction.
    [GPT-ADJUDICATED-FENCED] 7d61167

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 7d61167fe7e4432a128d860cbf2abb4edb43b6fc via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

The 17 committed stills cover every new state: retired, the 5xx hedge, quoted 400, decided with a failed DELETE (dark and light), slotless cron, and expiry during a press. The expiry removal has a recording. No blind reader has read them; pushing the branch to this repo runs one.

Notes

  • The 03/04/10 stills show the 5xx copy as "This decision may not have been recorded because the request failed. Try again." But the shipped decision_failed string is "…recorded — the request failed." (still 24 shows it). Recapture those frames so the evidence matches what users will see.
  • The decided-but-DELETE-failed pair (decision_recorded + decided_clear_failed) appears only in the page feed and the detail panel (17, 18). Add a bell-popover (mac variant) frame, since that row puts its notice through footer with different padding.

[UX-REVIEWED] 7d61167

Description read

[DESCRIPTION-READ] d762e1b5dc299403fc7bc68865c8f0058abf714f0284fd6f0d416798e3bdd2a5

That sha256 names everything this verdict read: the PR description, plus the 20 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 added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 7d61167fe7e4432a128d860cbf2abb4edb43b6fc via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7d61167

@jeeshofone
jeeshofone force-pushed the fix/14711-feed-expired-approval branch from c874f8f to b1a071f Compare September 28, 2026 17:52
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 28, 2026
@jeeshofone
jeeshofone force-pushed the fix/14711-feed-expired-approval branch from b1a071f to 7b4b205 Compare September 28, 2026 20:29
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Dispositions for the review findings on b1a071fc0, addressed in new head 7b4b20504 (rebased onto main 699083f90):

  • Opus finding 1 / UX Watch 1 (feed notice not tied to a row): fixed. approvalNotice in NotificationFeed.tsx now stores { ts, title, kind, reason }, and the notice leads with that notification's title (ErrorNotice title), so with several approvals listed it names the one that was pressed. A retryable-failure notice hides once its row is no longer in the store. New tests: "the notice names the approval it is about..." (two approvals, asserts the pressed title is shown and the other is not) and "a retryable-failure notice goes away once its row leaves the feed". Both fail without the component change.
  • Opus finding 2 (non-terminal refusal drops the server's reason): fixed on both surfaces. An ApiError with a message now renders components.approvalCard.decision_not_recorded_error with that message, and a response-less failure keeps decision_failed. This is the same split ApprovalCard.tsx makes. New 403 + authRequired tests in both suites fail without the change.
  • GPT (downgraded to advisory): a failed deleteNotification after a 404 leaves the row under a "gone" notice: no change, holding position. As the adjudication says, this needs a second failure after the terminal refusal, the leftover row matches the server's real state, and the notice text stays true. Awaiting the maintainer if they want it changed.
  • UX Watch 2 (no blind read on a fork PR): a maintainer-side step. The lane states that only a same-repo push gets the blind read.

Local checks on 7b4b20504: npm run i18n:check (19 checks, PASS, which clears the [added-lines]/[vs-base] reds from b1a071fc0), eslint on the four touched files, npx tsc -b, and vitest on all notification suites (31 files, 362 tests, pass).

@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 Sep 28, 2026
@jeeshofone
jeeshofone force-pushed the fix/14711-feed-expired-approval branch from 7b4b205 to eff33de Compare September 28, 2026 21:46
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Dispositions for the findings on 7b4b20504, addressed in new head eff33dedc (rebased onto current main):

  • GPT 5.6 BLOCKING, upheld (NotificationFeed.tsx:218, a failed DELETE after a 404 leaves dead controls and goes unreported): fixed. The terminal branch now unwraps deleteNotification(n.ts). On rejection the row's ts goes into retiredApprovals, which removes that row's Approve/Reject (its dismiss control stays), and the notice switches to the new components.notifications.notificationFeed.approval_gone_row_not_removed: "This approval has expired or was already decided, but its notification could not be removed. Dismiss it to clear it." The key is in all 13 catalogs and en-XA was regenerated. New test "a 404 whose row cannot be removed withdraws its buttons and says the row was left behind" fails on 7b4b20504 and passes here.
  • UX suggestion (messagePlacement): applied. The feed notice now uses messagePlacement="below".
  • UX BLOCK (screenshots predate the titled notice and show no server-reason state): I re-captured every state at this head from the built SPA with scripts/lib/stub-dashboard-api.mjs: the titled 404 notice, the 403 server-reason notice in the feed and in the detail panel, the DELETE-failure notice with the row's buttons withdrawn, and the 500 notice in light theme. I could not attach them in this run because editing the PR body was denied here. They need to be attached to the body (drag-in or gh pr edit --attach) before the UX lane can read them.

Local checks on eff33dedc: npm run i18n:check (PASS), npx tsc -b, eslint on the touched files, and vitest on the notification suites plus src/i18n (762 tests, pass).

@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 Sep 28, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the GPT 5.6 blocking finding on eff33dedc (NotificationFeed.tsx:227, a notice dismissed before the DELETE rejects leaves the row with no buttons and no explanation). Fixed in 4112d9038 as the adjudication proposed: when the DELETE fails, the stuck notice is set with this notification's own ts and title, no longer through the cur.ts === n.ts guard. New test "a gone notice dismissed before the DELETE fails is replaced by the left-behind notice" fails on eff33dedc and passes here.

Still open and needing a body edit I cannot make in this run: the UX BLOCK (screenshots of this revision; captures are ready) and the Design/First-Principles CONCERNS that the description still says "No new catalog strings" and "four new tests". The diff now adds approval_gone_row_not_removed in 13 catalogs, the stuck-row flow, the server-reason notice, and nine new tests. On First Principles' subtraction: GPT's lane blocked on a failed DELETE leaving dead Approve/Reject controls, under the blocking errors-use-error-notice rule. A re-press alone would still show those buttons, so the fallback stays unless a maintainer prefers the subtraction.

@jeeshofone
jeeshofone force-pushed the fix/14711-feed-expired-approval branch from eff33de to 4112d90 Compare September 28, 2026 23:28
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 28, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Note 3: "Your decision was recorded." does not say which decision

Held. The slice does not keep which button landed: dismissFailed holds the single value 'decided', narrowed to one state in an earlier round of this PR. Naming the decision would widen that record again and add a sentence per decision in every catalog.
The state is rare (a stored approval-kind note whose clean-up DELETE failed after the decision landed), and the decision itself reached the server. #20618 is where this per-row record gets its final shape.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Verdict line: no first-time reader has seen the new states, because this fork lane has no blind read

Held for a maintainer. A fork PR cannot run the blind read, so a maintainer's cold read of the stills and the recording is the check that remains.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • fixed span=4909fb4f6619: an older reconnect response replaces the current approval (website/src/hooks/websocket/approvals.ts:203)

Fixed in b5aa5fed9e: each reconcilePending read takes the next generation when it starts (reconcileGenerationRef). After await api.approvals(), an answer whose generation is no longer the newest returns before it retires or adopts anything.
The first connect and every reconnect catch-up reach reconcilePending only through syncPendingApprovals, so the one check covers both paths. A newer read that fails leaves the tab as it was until the next connect, as a single failed read does.
approvals.overtakenRead.test.ts (an older read answering after, and before, a newer one) and a UseWebSocketCoverage case (the first connect's read answering after the reconnect read) fail on edbf0db7a and pass here. Dropping the check turns all three red.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Agreed, no change in this PR. #20618, linked under "Not a goal", folds the three maps into one per-row phase record, and it lands after this PR and before #16481 restacks.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Note 2: a stored approval note with no approval_instance decides by bare id, so an expired one can still 404

Held. That 404 is the refusal this PR retires a row on: isTerminalApprovalRefusal reads it as "no longer pending", so the press withdraws the row's Approve and Reject and shows approval_no_longer_pending through ErrorNotice.
A stored approval-kind note comes from a caller that publishes a note of that kind, such as an app's notify, not from the coordinator registry, so it has no instance to send. Binding every other approval surface to its request is #16389, listed under "Not a goal".

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Item 7: the empty-slot branch in the decide route reaches past the Goal

Held. On the bare-id route state.resolve_approval settles whichever request holds the id when the press lands. The id is the caller's and recurs, so a press on a slotless cron row made before this tab hears the takeover would approve or reject the request that replaced it, which the user never saw.
Item 3 removes the ended row only once a frame or a reconnect listing reaches this tab, so it cannot close that window. The empty-slot target names the instance, and the route keeps the owner-only rule (bare_approval_decide_allowed), so it changes which request a press settles, not who may press.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Item 8: the in-flight hold in capRows and replaceRows is oversized

Held, as on earlier heads. Without it, a reconnect refetch, a clear-all or a cap eviction during a press removes the row, and a refusal that lands next has no row to show on, so the failed press goes silent. endApprovalRow holds a row only against its request ending, not against a list replacement or the cap.
The hold is one check in the one list replacement and the one cap, and a settled row is evicted like any other note.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Note 1: decided_clear_failed names "Dismiss notification" while the control shows only ×

Held, as on 657fc260a (issuecomment-6455466712). The sentence names the control by its accessible name, read from the button label's own key, so it matches what a screen reader announces. One sentence serves the feed row and the detail panel, which has no dismiss control of its own.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Note 2: when a 503 races the expiry, two red lines stack; show only "no longer pending"

Held, as on 657fc260a (issuecomment-6455467160). "No longer pending" does not settle whether the user's own press landed, because the expiry frame does not say. Dropping the failure line would make that failed press silent, which errors-use-error-notice rules out.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Verdict line: this lane has no blind read, and pushing the branch to this repository runs one

Held for a maintainer. This PR comes from a fork, which cannot push its branch to this repository, so a maintainer's cold read of the stills and the recording, or a same-repository push, is the check that remains.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • fixed span=fd947f8234fd: an unread broadcast puts a settled approval row back in the unread counts (website/src/store/notificationsSlice.ts:471)

Fixed in b034d6ce49. unackNotificationByTs returns early for a row that isSettledApprovalRow names (retired, or decided with a failed DELETE). Another view's notification_unack therefore leaves that row read, and the fetch merge keeps its read state. The merge line is unchanged.

Test: notificationsSlice.test.ts, "leaves a refused (retired) / dismiss_failed (decided with a failed DELETE) row read through the broadcast and the refetch". Both cases fail on b5aa5fed9e and when the guard is removed. An existing feed test used this broadcast to clear a retired row's read flag, to show that the mark alone hides the unread dot. It now seeds that state directly and still pins the same thing.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • fixed span=b99c8286b17b: a successful panel retry leaves the feed's earlier failure visible (website/src/components/notifications/NotificationFeed.tsx:609)

Fixed in b034d6ce49. The feed shows a retryable decision failure only on a row that is not settled. settled is the feed's existing rule: a retired row, or an approval row decided with a failed DELETE. That is the detail panel's buttonsWithdrawn rule. Once the panel's retry lands, the feed's earlier "try again" notice is gone, also when the clean-up DELETE fails.

Test: NotificationFeed.retiredApproval.test.tsx, "a retry from outside the feed that lands and its DELETE fails / is refused as no longer pending hides the feed's retryable failure". The first case fails on b5aa5fed9e. Removing either half of the check fails one of the two cases.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Note: the three per-row maps (approvalDecisions, retiredApprovals, dismissFailed) can drift apart

Holding position, as on edbf0db7ad. #20618 merges them into one phase record. It lands after this PR and before #16481 restacks. The two fixes in b034d6ce49 read the maps only through the existing isSettledApprovalRow and the feed's settled, so #20618 gets no new access pattern to fold.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Item 5: a settled row is read in this tab only, dimmed and out of the unread count

Holding position. On this head the repository's adjudication upheld the GPT lane's finding about the unread counts: a settled row asks for nothing, so it must stay out of the bell, desktop badge and page unread counts. Dropping the settled gate from the unread count would reopen that finding. The gate stays, and b034d6ce49 extends it to another view's unread broadcast.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Item 7: three parallel per-row maps; ship one per-row phase map here

Holding position, as on edbf0db7ad. Folding the three maps into one record is #20618, which lands after this PR and before #16481 restacks.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Item 4: the detail panel hides its read toggle on a withdrawn row

Holding position. Shown on a settled row, Mark unread would put the row back in the unread counts through the panel's own press. That is the outcome the GPT finding upheld on this head rules out.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Note: the three per-row mark maps (approvalDecisions, retiredApprovals, dismissFailed) carry one lifecycle between them

Holding position, as on b5aa5fed9e. #20618 folds the three maps into one phase record and is planned to land after this PR and before #16481 restacks on it, the order this note asks for. The next head is this branch rebased onto current main with no code change, so the maps stay as reviewed here.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Item 6: dismissFailed is oversized; send the failed DELETE through the existing clear_failed notice

Holding position. When a decision lands and the stored note's DELETE then fails, the request has already ended. The dismissFailed mark withdraws that row's Approve and Reject and treats the row as settled (dimmed and read), and its notice says the decision was recorded. Without the mark the row would show Approve and Reject again for an ended request, and the feed's clear_failed notice says only that the clear failed, so a user could take the press as failed and press again. Both GPT findings fixed in b034d6ce49 (spans fd947f8234fd and b99c8286b17b) cover this settled state, and deleting the map would undo them.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • held Item 7: the hold-back that keeps a deciding row through the ring cap, a snapshot or a clear-all (capRows, replaceRows) is oversized

Holding position. A press's response lands on its row: a refusal is shown there, and a landed decision removes the row. If a cap eviction, a clear-all or a snapshot drops the row while the press is in flight, a refusal has nowhere to show and the press fails silently, which is the silent-failure half of #14711. Only rows this tab is deciding are held back, so the list can exceed the cap by those rows and no more. The slice tests pin a full ring arriving during a decision and 500 seeded interleavings of presses, snapshots, clears and ring fills. The panel tests pin an expiry frame during one.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Holding position. Both guard this PR's reconnect reconcile, the step that retires a row whose approval ended while the socket was down. GPT 6.1 blocked edbf0db7ad on the overtaken read (span 4909fb4f6619), and the repo's adjudication upheld it: an older answer that landed last removed the current instance's live row and adopted the ended one, so Approve and Reject returned 404. liveApprovalIdsRef keeps a snapshot fetched before a live approval frame from replacing or retiring the newer row under the same id. Deferring either one would ship this PR's reconcile with those defects.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • fixed Blocker: decision_failed_retry is a second wording of decision_failed

Fixed in the next push. decision_failed_retry is deleted from all 14 catalogs. The feed row and the detail panel now share one decisionFailedCopy(reason) in notifMeta.tsx. It quotes the decide route's reason when there is one and otherwise shows components.approvalCard.decision_failed, the sentence the chat approval surfaces already use. That covers a live row and one a frame ended meanwhile, so endedDecisionFailedCopy is gone too. The tests and the capture script assert decision_failed.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • fixed span=9d6abf380538 notificationsSlice.ts:433: a row closed or cleared mid-flight retires as "no longer pending" on a retryable failure

Fixed in the next push, in the first commit. A deciding row's record now has its own dismissed flag, kept apart from ended. The row's close X sets it through a new dismissApprovalRow (dismissLocalApprovalRow dispatches it in place of endApprovalRow), and a clear sets it in replaceRows. When the last press settles with a retryable failure on a dismissed row that no frame ended, the row is removed, which is what the user asked for. It retires with { failed } and "no longer pending" only when a frame ended the request. A refusal or a failed DELETE still claims the row, as before.

Class sweep: every caller of endApprovalRow. The three in hooks/websocket/approvals.ts are server frames (resolved, superseded, reconnect instance change). The one in pages/chat/page/sessionPicks.ts is a decision made on another surface. The other two sites were local user actions: the close X and the clear in replaceRows, and both now set dismissed.

New slice tests fail on the previous head and pass now. They cover the close X and Clear all, and check that a frame-ended row still retires with its failure even after a close X. The 500-seed property test now models a clear as a dismissal, and it checks that a row no frame ended never retires with { failed }.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 539e80f for maintainer review.

The backend diff is line-identical to the 89be338 head I held in r123, and I still found no defect in it. The empty-slot target (live_turn.py#L150-L173) needs an exact instance, runs the same owner gate as the bare-id path, and matches only a record whose own slot is empty. GPT and Opus report no findings, and CI is green.

What holds it:

  1. This changes which requests can decide a tool approval, so a human maintainer has to review it. The second commit, 539e80f, comes from this reviewer's account, so that maintainer must be someone else.
  2. Two UX notes on this head have no reply yet. They do not block: the copy names the X button as "Dismiss notification", which is its accessible name but not visible text, and screenshot 24 shows two red errors on one retired row.

— crew-pr-reviewer (r133)

The feed and detail panel Approve/Reject buttons sent every rejection
from resolveApproval to the console and left the row in place, so an
approval that had already expired stayed listed with buttons that could
never succeed.

An approval_resolved frame removes the row. A decide this tab sent that
the server refused as no longer pending failed, so it now retires the row in the
notifications slice: the row stays listed without Approve/Reject, keeps
its close X (shown without a hover), and renders through the shared
ErrorNotice the sentence the chat card, tool group, Subagents panel and
command center already show for a refused press. Retiring also marks
the row read in this tab (the server holds no approval note, so nothing
is sent) and drops the critical border and unread dot. A retired row
recedes through its title and controls only; its notice keeps full
contrast, and the row open in the detail panel leaves that sentence to
the panel. The page
feed, the bell popover and the detail panel read the same marks, and
being read, a retired row leaves every unread count. A decision that lands removes the row, as
before. An approval row is this tab's own copy (the server keeps no
approval note), so a landed decision and the row's close X remove it
locally and send no DELETE: there is no request left to fail.

A retryable decide failure keeps Approve/Reject and says why on that
row through the shared ErrorNotice, so no failed action is silent. A retired row's close X stays at
near full strength while its title recedes, and the detail panel offers no read
toggle on a retired row.

A coordinator approval's id is the caller's and recurs, so each feed
row carries the server-issued instance of the request it was raised
for, and every coordinator approval_resolved frame names the instance
it resolved, so an earlier request's retired row under the same id is
not the one removed.

A request that takes over an id ends the one it replaced with no frame,
so the approval frame and the reconnect reconcile remove any live row
under that id bound to another instance, and a row that names its
request (slot and instance) decides with that coordinator target, so
the server refuses a stale instance instead of settling the request that
replaced it.

When the pressed button is withdrawn, keyboard focus moves to the
row's close X (or the detail panel's Close), the one thing left to do
with it, instead of falling to the page body.

A row whose decide is still in flight survives a notifications
snapshot (the reconnect refetch) and a clear-all, with its marks, so a
late refusal still renders on it. A clear-all or the row's close X marks
it dismissed, not ended: the request may still be pending, so the row
leaves once the response settles unless a refusal claims it, and a
retryable failure never shows it as no longer pending. Only a frame ends
the request.
Both go through one list replacement in the slice.

A 5xx or a missing response comes from the layer between the tab and
the decide route, so the row says the decision may not have been
recorded, in the chat approval card's own words, instead of quoting that layer's text; the
route's own 4xx refusals are still quoted. A slotless approval (cron,
autonudge, task runner) is decided with an empty slot and its instance,
and only from the owner's browser session, as before. Only an approval row withdraws the detail panel's
controls for a failed DELETE, since only it carries the notice, and the
open approval row leaves that notice to the panel instead of showing it
twice. The notice names the retry, the row's dismiss control in the feed,
by that control's own accessible name, and the panel has no Dismiss of its
own: a row leaves through its close X in the feed. On a
retired row the notice sits under "no longer pending" and claims no
recorded decision, in the panel, the page feed and the bell popover alike.

Closes kirodotdev#14711
@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles note (item 10, duplicate settled-row predicate): acknowledged, deferred as the description states. This push is a rebase onto current main with no behaviour change; the inline check in unackNotificationByTs and isSettledApprovalRow sit in different commits, and commit 1 is carried unchanged by a stacked PR, so folding them now would break that stack. Once both commits are on main, the inline copy is replaced with a call to isSettledApprovalRow in the follow-up the description names.

A retired or decided approval row is marked read in this tab only. Two
paths made it unread again and relit the badge: the reconnect refetch
reinstalled the server's unread flag, and an unread request sent before
the settlement landed after it because the settle wrote no ack stamp.
The fetch merge now keeps the local read state for a settled row, and
each settle branch stamps the ack.

A decide that names its coordinator target (slot and instance) settles
through the decision registry, as a decide by id does, so the decision
records the verified person who pressed it instead of an unknown
responder settled by the host.
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Moved to #27509: same commits, now on a branch of this repo so CI uses the CodeBuild fleet. Review history stays here.

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

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

notifications: an expired tool approval stays in the Notifications feed, and its Approve/Reject buttons silently fail with 404

3 participants