Skip to content

fix(monitor): let the owner clear a stopped automation record - #9788

Merged
chenmingwei23 merged 2 commits into
mainfrom
fix/clear-retained-monitor-evidence
Sep 10, 2026
Merged

chenmingwei23 merged 2 commits into
mainfrom
fix/clear-retained-monitor-evidence

Conversation

@bolichen97

@bolichen97 bolichen97 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A session that stops watching one pull request can never watch another one.

monitor_stop retains its outcome, and _stopped_row_is_replaceable refuses to let a re-arm displace a consumer-recorded stop. That rule is deliberate. The way out it names -- its owner must clear it first -- did not exist:

  • monitor_watch / add_monitor: refused with the session's stopped automation is retained as evidence. The rule working.
  • DELETE /api/autonudge/{loop_id}: routed a structured monitor into stop_monitor, which returns an already-terminal loop UNCHANGED, then answered {"ok": true}. The goal popover's own button reported success and removed nothing.
  • POST /api/monitors/{id}/restart: revives the SAME monitor, so it can only re-watch the subject the user stopped watching.

Observed: an agent session called monitor_watch for a pull request, got Failed to start structured monitor: the session's stopped automation is retained as evidence and is not replaceable by a re-arm; its owner must clear it first, and the stopped row could not be cleared from anywhere in the product.

Why it matters

The slot is permanently spent. Every later monitor_watch on that session is refused, the dashboard's Clear/Stop button silently no-ops, and the only remaining instruction to the user is one the product cannot carry out. The user's workaround is to abandon the chat session.

It also makes the button lie: stop() calls onChange(null) on a 200, so the popover empties itself while the row is still on disk and returns on the next fetch.

What changed (motivation -> approach -> change)

Root cause: one HTTP verb served two different operations and only implemented one. stop_monitor is correctly idempotent (an already-terminal record is returned unchanged), so routing every structured-monitor DELETE through it made the second press unreachable.

DELETE /api/autonudge/{loop_id} now splits by state:

  • live monitor -> unchanged: authorize_and_stop_monitor, which writes the evidence.
  • already-terminal monitor -> new authorize_and_clear_monitor, which REMOVES the row.

The new authorizer lives in autonudge_authz.py beside its siblings (the security chokepoint is transport-agnostic by design) and is owner-gated, audited as monitor_clear with critical=True audit-or-deny, and refuses:

  • a LIVE monitor (409) -- clearing a running watch would delete it with no record it existed, so stopping stays the only way to end one.
  • a future-version record (409) -- the same rule the arm path applies: a downgrade may not delete state it cannot read.
  • a wake in flight (409) -- mirrors the arm path's guard, since a terminal record can still own an accepted wake whose completion needs the row.
  • an unknown id (404) rather than a silent ok.

The removal is CONDITIONAL. AutoNudgeService.clear_terminal_monitor re-takes the terminal-state decision inside the same _lock hold that removes the row, because the audit hands off to a thread and yields the event loop: a restore_monitor_after_failed_session_close landing in that window would otherwise meet an unconditional delete and lose a live watch. The row moving on answers 409, not a silent success.

The DELETE also accepts an optional intent=stop|clear and 409s on a mismatch, so the verb's meaning comes from the label the user pressed rather than from whatever state the record reached in flight. Optional, so an older bundle keeps working.

The retained-evidence rule itself is untouched. Clearing is an owner action in the browser, not something an agent can reach: monitor_watch is still refused, and its message now names where to clear.

Frontend, structured surface (the one a stuck user actually sees): the session-automation popover's terminal state offered only Restart monitor, which revives the same subject, so the panel had no way to free the session at all. It now offers Clear stopped monitor beside Restart, behind the same confirm the stop control uses, plus a line naming both exits and the finality of this one.

Frontend, legacy goal view: once the loop is inactive the popover's left button reads Clear stopped goal instead of Stop loop, the status line reads Stopped rather than the resumable-sounding Paused, and a help line names both exits (Start loop resumes this goal. Clear stopped goal removes it for good.) because the erase has no undo. The label names the goal rather than an internal noun: a blind reader refused to press "Clear record" since the popover shows nothing called a record. Correct for legacy loops too, where DELETE already removed the row.

Tests

New test/test_monitor_clear_retained.py (18 tests) against the REAL AutoNudgeService:

  • the whole bug in one test: arm, stop, re-arm refused, clear, re-arm on a different pull request succeeds.
  • the clear is audited as monitor_clear, critical=True, with the owning slot key.
  • an unavailable audit sink refuses the clear (503) and leaves the row.
  • refusals pinned: live monitor, future-version record, wake in flight, unknown id.
  • a monitor RESTORED during the audit window is refused (409) and survives -- the fixture restores the row from inside the audit's own to_thread, and asserts it reached that window at all.
  • the HTTP route itself, both branches: a stopped monitor's row is gone; a live monitor's row survives with USER_STOP retained.
  • the structured POST /api/monitors/{id}/clear route: it frees the slot, refuses a live monitor (409), refuses a non-owner (403), and 404s on an unknown id.
  • intent preconditions both ways: a stop-intent press against a just-terminal record is refused rather than erasing it, a clear-intent press against a live monitor is refused rather than stopping it, an unknown intent is a 400, and a request with no intent still clears (older bundles).

website/src/test/AutoNudgePopover.test.tsx: the label, the status wording and the help line are asserted in both directions, plus that each press sends its own intent. website/src/test/SessionAutomationPopover.test.tsx: the clear is offered on a stopped monitor and absent on a live one, one press only asks, the confirm calls monitorClear, and Cancel erases nothing.

Negative controls, both verified:

  • with autonudge_authz.py and handlers/autonudge.py reverted to origin/main, 8 of the original 9 tests fail on the row still being present. Restored, all pass.
  • with the conditional removal alone reverted (svc.clear_terminal_monitor back to svc.remove), the restore-window test fails (assert True is False) and passes again once restored -- so that test measures the lock hold, not the guards above it.

Local runs: 1126 backend tests matching autonudge or monitor pass; 1967 vitest files pass; npm run typecheck, lint, jscpd, 1837 electron tests, npm run i18n:check all green. Two pre-existing environment failures unrelated to this diff (test_autonudge.py::TestSentinelPathRepair::test_unnormalized_path_escaping_legacy_is_preserved fails identically on pristine origin/main; test_transcribe.py cannot import imageio_ffmpeg).

Gates run locally: black baseline, comment-history, sync-io-in-async, builtin-skill-scope, docs-lint, brand, error-code contract, feature-map (FEATURE_MAP_BASE_REF).

Manual verification

Reproduced against the running gateway's own store: the retained row (outcome: user_stop) blocked every monitor_watch on its slot, and the popover's button left it in place.

The screenshot harness below is not a still: frame 2 PRESSES the button and asserts the DELETE was issued and the popover closed, so the press is proven to do something.

Screenshots / video

node website/scripts/capture-goal-clear-record.mjs drives the real built SPA with stubbed /api/** and exits non-zero unless each frame renders what this PR claims.

Stopped monitor -- the clear sits beside Restart, and the exits line says what each one does:

stopped monitor offers Clear stopped monitor

One press only asks, because the erase has no undo:

the clear asks for confirmation

The two control frames

Live monitor -- no clear control at all:

live monitor has no clear

Stopped legacy goal loop -- the goal view's own button, status and help line:

stopped legacy loop shows Clear stopped goal

Related Issues

No existing issue. Adjacent but different: #9194 (an arm that returns success without arming -- here the tool returned a clear failure and the refusal was correct) and #7410 (an armed loop has no visible running state).

Pattern harvest

Rule candidate: review-prompt
Pattern: an idempotent no-op reached through a route that promises a state change -- the handler returns success because the service call is legitimately idempotent, so the caller cannot tell "already done" from "cannot be done here". Worth asking of any DELETE/stop/cancel route that dispatches into a state machine: is there a state in which this verb is unreachable, and does the response say so?

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (spec paragraph + the babysit built-in skill)
  • No secrets, credentials, or internal references in the diff

Round 1 review fixes (4a7d393b9)

Lane Finding Fix
GPT 5.6 (blocking) the terminal-state checks ran before the audit's to_thread, which yields, so a concurrent close-rollback restore met an unconditional svc.remove new clear_terminal_monitor re-takes the decision inside the removal's own _lock hold; 409 when the row moved on
UX (blocking) a blind reader would not press "Clear record" -- the popover shows nothing called a record, so the control that unsticks the session went unpressed label names the object ("Clear stopped goal"), status reads "Stopped", help line names both exits and the finality
Design (concerns) the verb's meaning was decided by server state, so a stale "Stop loop" press could erase a just-terminal record intent=stop|clear travels with the DELETE; 409 on mismatch
First principles (subtractions) cleared: true and data-testid="auto-nudge-stop" had zero consumers both removed

Round 2 (faca57826)

Rebased onto current main, which is what the review lanes needed: the round-1 patch artifact was 203 files of base drift (First Principles flagged it, and GPT's only blocking finding was in platform/governance.py, a file this PR does not touch). The rebase brings the diff back to its own 30 files.

The rebase also moved the surface under the fix. main now renders SessionAutomationPopover in the composer, and its terminal branch offered Restart monitor alone, so the stuck case this PR exists to fix had NO exit in the UI a user actually reaches. Added there:

  • POST /api/monitors/{id}/clear, the sibling of /stop and /restart, routing to the same authorize_and_clear_monitor.
  • api.monitorClear and a Clear stopped monitor control in the terminal branch, behind its own confirm.
  • A line where the terminal reason is described, naming both exits and the finality of the clear.

Also took the two UX suggestions from round 1: the wake-in-flight and intent-mismatch refusals no longer render internal vocabulary ("wake", "automation") into the popover's error notice.

Round 3 (faca57826): added POST /api/monitors/{id}/clear to the feature map's Monitor loops row, the one genuine GPT finding on the previous head.

Round 4 (d9bdf18bb): an intent-less DELETE no longer clears. A pre-upgrade tab had no clear control, so it can only have meant stop; inferring clear from the record state for such a request reopened the same hazard the intent closes, by the legacy path. Clearing now requires an explicit intent=clear, and an old bundle keeps its old harmless no-op.

@bolichen97
bolichen97 requested review from a team and patrigao September 9, 2026 22:34
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of d9bdf18bb06daadd5f6c33d2698cfc52c9897ef4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

The change is well-scoped and I've verified the conventions it relies on (temp-screenshots/ and dual-surface monitor routes are established patterns on base). The design gate raises no surviving findings: the missing "clear" operation is the root cause the retention rule itself presupposed, the authorizer sits at the existing transport-agnostic chokepoint, the TOCTOU is closed at the service's own lock rather than papered over in the handler, the new surface is additive, and the old-bundle intent-less DELETE deliberately degrades to the harmless no-op rather than the erase hazard.

Design-Verdict: PASS

Builds the exact operation the retention rule always presupposed, at the existing authz chokepoint, with the race closed where the state lives.

[DESIGN-REVIEWED] d9bdf18

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of d9bdf18bb06daadd5f6c33d2698cfc52c9897ef4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence reviewed: blind read reconciled against the diff, all four screenshots inspected, backend error strings checked, and the legacy goal button confirmed to fire the irreversible DELETE directly with no confirmation step.

UX-Verdict: CONCERNS

The monitor clear is understood and guarded; the legacy goal's identical irreversible erase is one unguarded, grey, single click.

Watch

  • "Clear stopped goal" erases permanently with no confirm and no danger styling. onClick={stop} fires the DELETE directly (AutoNudgePopover.tsx), while the same operation on the monitor surface gets a confirm, red text and a trash icon. The blind reader: "this delete button is plain grey with no warning colour, which makes it easier to hit by mistake" and "I cannot tell whether 'Clear stopped goal' deletes instantly with no 'are you sure?'". Low frequency (legacy view, stopped state) × permanent loss of the goal text × every clear — reuse the monitor's confirm pattern and danger styling here.
  • The clear confirmation shows no question — only the buttons swap. shot-02 renders "Cancel" / "Yes, clear it" with nothing stating what is being confirmed; the reader: "If I hadn't seen shot-01 first, I wouldn't know what 'clear it' refers to." Rare action but the ambiguity hits every confirm — add one line ("Remove this monitor for good?") above the buttons, or relabel confirm_clear to restate the object: "Clear monitor for good".

Suggestions

  • confirm_clear "Yes, clear it" → "Clear monitor for good": confirm buttons should restate the action and object, not answer an unrendered question.

[UX-REVIEWED] d9bdf18

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of d9bdf18bb06daadd5f6c33d2698cfc52c9897ef4 — 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/CONCERNS are advisory.

All counts I need are run. Assembling the review.

First-Principles-Verdict: PASS

The relabels rest on "a blind reader refused to press it" — an observation asserted in the description only; confirm that read actually happened.

What this change ships

Inventory (10 items) — 10 justified

Intent: let the owner remove a stopped monitor's retained record so the session can watch something else — a FIX (repro in description; negative controls show 8/9 new tests fail on base).

  1. The goal popover's button on a stopped record now actually removes it, instead of answering ok and removing nothing — justified
  2. New "Clear stopped monitor" control, behind a confirm, in the session-automation popover's terminal state — justified
  3. New POST /api/monitors/{id}/clear route and api.monitorClear (1 consumer counted: SessionAutomationPopover.tsx:195) — justified
  4. DELETE /api/autonudge/{id} takes optional intent=stop|clear, 409 on mismatch; absent intent never erases — justified
  5. Clears audited as monitor_clear, critical, audit-or-deny — justified
  6. Legacy popover's button reads "Clear stopped goal" once the loop is inactive — justified
  7. Status reads "Stopped" not "Paused", plus a help line naming both exits, 12 locales — justified
  8. Re-arm refusal and the babysit skill now name where to clear and say not to retry — justified
  9. Removal re-takes the terminal check inside the removing lock hold; a mid-audit restore answers 409 — justified
  10. New capture harness plus 4 committed PNGs — justified (repo convention: 461 sibling capture-*.mjs scripts, ~1579 committed screenshots)

Watch

  • Items 6–7 relabel shipped wording on the strength of an unlinked UX read ("a blind reader refused to press 'Clear record'… took 'Paused' as resumable"). The label split is independently derived — the press now erases, so "Stop loop" would misdescribe it — but the Paused→Stopped rewording and help line lean on that anecdote alone.
    Clears when: a maintainer confirms the blind-read review occurred, or accepts the erase-control-adjacency rationale as sufficient.

Subtractions

  • _remove_unserialized's precondition: Callable[[NudgeLoop], bool] has exactly one caller ever passing it (clear_terminal_monitor, autonudge.py; grepped precondition — 1 passing site). Inline the terminal check or take a boolean; the callable generality buys nothing yet.

[FIRST-PRINCIPLES-REVIEWED] d9bdf18

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] d9bdf18

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable d9bdf18bb06daadd5f6c33d2698cfc52c9897ef4: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of d9bdf18bb06daadd5f6c33d2698cfc52c9897ef4 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- website/src/components/SessionAutomationPopover.tsx:695 -- Self-armed crew/member monitors can stop, but "sessionModeUnsupported" disables Clear and leaves the slot permanently occupied -> Fix: disable Clear only while busy.

[GPT-REVIEWED] d9bdf18

False positive or not applicable? A repository writer can comment:
/ai-review override gpt d9bdf18bb06daadd5f6c33d2698cfc52c9897ef4: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 9, 2026
A user-stopped monitor record is retained as evidence and refuses a re-arm,
which is deliberate. The way out that refusal names did not exist: DELETE
/api/autonudge/{loop_id} routed a structured monitor into stop_monitor, which
returns an already-terminal loop unchanged, then answered ok. The dashboard's
own button reported success and removed nothing, and the restart route only
revives the same subject. A session that stopped watching one pull request
could never watch another one.

DELETE now splits by state. A live monitor is still stopped, retaining its
outcome. An already-terminal one is cleared through a new
authorize_and_clear_monitor: owner-gated, audited as monitor_clear, and
refusing a live monitor, a future-version record and a wake in flight.

The popover's button says Clear record instead of Stop loop once the loop is
inactive, since that press removes the row rather than stopping anything.
@bolichen97
bolichen97 force-pushed the fix/clear-retained-monitor-evidence branch from 4a7d393 to b566180 Compare September 10, 2026 01:15
@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 10, 2026
@bolichen97
bolichen97 force-pushed the fix/clear-retained-monitor-evidence branch from b566180 to faca578 Compare September 10, 2026 01:31
@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 10, 2026
Review round 1 on the clear path.

GPT (blocking): the terminal-state checks ran before the audit, and the audit's
to_thread yields the event loop, so a close-rollback restore landing in that
window met an unconditional remove and lost a live watch. The removal now
re-takes the decision inside the service's own lock hold via a new
clear_terminal_monitor, and refuses with 409 when the row moved on.

UX (blocking): a blind reader would not press "Clear record" because the popover
shows nothing called a record, so the one control that unsticks the session went
unpressed. The label names the object ("Clear stopped goal"), the status reads
"Stopped" instead of the resumable-sounding "Paused", and a help line names both
exits because the erase has no undo.

Design (concerns): the verb's meaning was decided by server state, so a stale
"Stop loop" press could erase a record that went terminal in between. The DELETE
now carries the pressed intent and the server 409s on a mismatch.

First principles (subtractions): dropped the zero-consumer `cleared: true`
response key and the unused `auto-nudge-stop` test id.
@bolichen97
bolichen97 force-pushed the fix/clear-retained-monitor-evidence branch from faca578 to d9bdf18 Compare September 10, 2026 01:50
@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 10, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 10, 2026
@chenmingwei23
chenmingwei23 merged commit 048bc64 into main Sep 10, 2026
69 of 75 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/clear-retained-monitor-evidence branch September 10, 2026 03:06
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 10, 2026
bolichen97 added a commit that referenced this pull request Sep 10, 2026
Follow-through on the UX review of #9788, which merged with the finding open.

Both surfaces now erase a stopped automation for good, but only the monitor's
was guarded: the legacy goal view's "Clear stopped goal" fired the DELETE on one
plain grey click. A blind reader named it: "this delete button is plain grey with
no warning colour, which makes it easier to hit by mistake" and "I cannot tell
whether it deletes instantly with no are-you-sure".

The legacy control is now danger-coloured unconditionally (not on :hover, which
a touch viewport never produces) and asks first, reusing the monitor surface's
two-step. The confirmation replaces the primary CTA rather than sitting beside
it, so the row keeps its two-control cap.

Both confirm labels now restate the action and its object, because neither
confirm row renders a question: "Yes, clear it" answered one that was never
asked. They read "Clear goal for good" and "Clear monitor for good".
bolichen97 added a commit that referenced this pull request Sep 10, 2026
Follow-through on the UX review of #9788, which merged with the finding open.

Both surfaces now erase a stopped automation for good, but only the monitor's
was guarded: the legacy goal view's "Clear stopped goal" fired the DELETE on one
plain grey click. A blind reader named it: "this delete button is plain grey with
no warning colour, which makes it easier to hit by mistake" and "I cannot tell
whether it deletes instantly with no are-you-sure".

The legacy control is now danger-coloured unconditionally (not on :hover, which
a touch viewport never produces) and asks first, reusing the monitor surface's
two-step. The confirmation replaces the primary CTA rather than sitting beside
it, so the row keeps its two-control cap.

Both confirm labels now restate the action and its object, because neither
confirm row renders a question: "Yes, clear it" answered one that was never
asked. They read "Clear goal for good" and "Clear monitor for good".
iamwhatever pushed a commit that referenced this pull request Sep 10, 2026
Follow-through on the UX review of #9788, which merged with the finding open.

Both surfaces now erase a stopped automation for good, but only the monitor's
was guarded: the legacy goal view's "Clear stopped goal" fired the DELETE on one
plain grey click. A blind reader named it: "this delete button is plain grey with
no warning colour, which makes it easier to hit by mistake" and "I cannot tell
whether it deletes instantly with no are-you-sure".

The legacy control is now danger-coloured unconditionally (not on :hover, which
a touch viewport never produces) and asks first, reusing the monitor surface's
two-step. The confirmation replaces the primary CTA rather than sitting beside
it, so the row keeps its two-control cap.

Both confirm labels now restate the action and its object, because neither
confirm row renders a question: "Yes, clear it" answered one that was never
asked. They read "Clear goal for good" and "Clear monitor for good".
iamwhatever pushed a commit that referenced this pull request Sep 12, 2026
Reverts #5185 and its three follow-ups (#9788, #9845, #10190), which replaced
the composer's generic monitor/auto-nudge popover with a pull-request-only
"Bounded pull request monitor" form.

The composer trigger opens AutoNudgePopover again, so a session can arm a goal
loop for any target from the dashboard instead of being asked for a GitHub pull
request URL. The frontend automation-record layer #5185 introduced goes with it:
SessionAutomationPopover, MonitorRadar, the monitoring/automation normalizer and
its contract.json, the per-slot REST automation snapshots in ChatPage /
ChatSidebar / chatSlice / useWebSocket, and the sessionAutomationPopover catalog
block in all 13 i18n catalogs. The follow-ups' clear-a-stopped-record path goes
with it too, since both surfaces it guarded were part of that layer.

The monitor_watch MCP tool and the src/kiro_crew/monitoring structured-monitor
engine are untouched: agents can still arm, inspect and stop a bounded monitor.
Only the fields and routes #5185 itself added for the dashboard surface are
removed with it.

Conflict resolutions worth naming, all preserving post-#5185 unrelated work:

- The 13 i18n catalogs plus en.manual.json keep every key intervening commits
  added; only the sessionAutomation / bounded-monitor keys are removed.
- ChatSidebar keeps its pending_decision status row and ChatPage its extended
  dependency list; ChatSliceCoverage keeps the fetchSlots import a later commit
  started using.
- learn-cron-dashboard.md keeps the provider-evidence and legacy-cap paragraphs
  that landed after #5185, and drops the AutomationRecord SPA spec block.
- The babysit skill no longer points at the removed Clear stopped monitor
  control.
- The throwaway temp-screenshots evidence files from #9845 and #10190 are
  deleted rather than restored.
iamwhatever pushed a commit that referenced this pull request Sep 12, 2026
Reverts the dashboard layer of #5185 and its follow-ups (#9788, #9845,
with a pull-request-only "Bounded pull request monitor" form.

The composer trigger opens AutoNudgePopover again, so a session can arm a
goal loop for any target from the dashboard instead of being asked for a
GitHub pull request URL. The frontend automation-record layer #5185
introduced goes with it: SessionAutomationPopover, MonitorRadar, the
monitoring/automation normalizer and its contract.json, the per-slot REST
automation snapshots in ChatPage / ChatSidebar / chatSlice / useWebSocket,
and the sessionAutomationPopover catalog block in all 13 i18n catalogs.

The generic popover keeps the clear-stopped-record control #9788 and #9845
added: a stopped record is cleared with a confirm two-step that sends
DELETE ?intent=clear, so an agent-armed monitor that was stopped by a
session close or user stop still has an exit from the dashboard.

Nothing under src/kiro_crew/ or test/ changes. The monitor_watch MCP tool,
the src/kiro_crew/monitoring engine, the backend clear route and the
retention refusal are all as on main.

A committed capture harness, website/scripts/capture-goal-popover-generic.mjs,
opens the built SPA, clicks "Set a goal" and fails if the popover carries a
pull request URL field or a "legacy goal loop" call to action.
iamwhatever pushed a commit that referenced this pull request Sep 13, 2026
Reverts the dashboard layer of #5185 and its follow-ups (#9788, #9845,
with a pull-request-only "Bounded pull request monitor" form.

The composer trigger opens AutoNudgePopover again, so a session can arm a
goal loop for any target from the dashboard instead of being asked for a
GitHub pull request URL. The frontend automation-record layer #5185
introduced goes with it: SessionAutomationPopover, MonitorRadar, the
monitoring/automation normalizer and its contract.json, the per-slot REST
automation snapshots in ChatPage / ChatSidebar / chatSlice / useWebSocket,
and the sessionAutomationPopover catalog block in all 13 i18n catalogs.

The generic popover keeps the clear-stopped-record control #9788 and #9845
added: a stopped record is cleared with a confirm two-step that sends
DELETE ?intent=clear, so an agent-armed monitor that was stopped by a
session close or user stop still has an exit from the dashboard.

Nothing under src/kiro_crew/ or test/ changes. The monitor_watch MCP tool,
the src/kiro_crew/monitoring engine, the backend clear route and the
retention refusal are all as on main.

A committed capture harness, website/scripts/capture-goal-popover-generic.mjs,
opens the built SPA, clicks "Set a goal" and fails if the popover carries a
pull request URL field or a "legacy goal loop" call to action.
iamwhatever pushed a commit that referenced this pull request Sep 13, 2026
Reverts the dashboard layer of #5185 and its follow-ups (#9788, #9845,
#10190), which replaced the generic goal-loop popover with a
pull-request-only "Bounded pull request monitor" form.

The composer trigger opens AutoNudgePopover again, so a session can arm a
goal loop for any target from the dashboard instead of being asked for a
GitHub pull request URL. The frontend automation-record layer #5185
introduced goes with it: SessionAutomationPopover, MonitorRadar, the
monitoring/automation normalizer, the per-slot REST automation snapshots
in ChatPage / ChatSidebar / chatSlice / useWebSocket, the dead
api.monitorClear client method, and the sessionAutomationPopover catalog
block in all 13 i18n catalogs. website/src/monitoring/contract.json stays:
test/test_monitor_persistence.py reads it as the backend parity artifact.

Two fixes #5185 carried incidentally stay in the restored wiring. The
goal-loop seed and the autonudge_state frame fold channel slot keys
(slack:<ts>) to the dashboard filename form (slack_<ts>) through
website/src/utils/dashboardSlotKey.ts, matching _normalize_slot_key on the
backend, so a channel-bound loop lights its sidebar row. Every seed takes
its own generation, so two overlapping reconnect seeds cannot let the older
snapshot overwrite the newer one, and ChatPage's per-slot loop fetch is
dropped when a live autonudge_state frame for that slot lands first. The
popover keeps the viewport-fit classes (max-h / overflow-y-auto, stacked
number fields on narrow widths).

The generic popover keeps the clear-stopped-record control #9788 and #9845
added: a stopped record is cleared with a confirm two-step that sends
DELETE ?intent=clear, so an agent-armed monitor that was stopped by a
session close or user stop still has an exit from the dashboard.

The popover's fresh-state defaults change in two small ways: Max cycles
starts at 24 (0 still means no cap, and an existing loop's 0 is shown as
0), and the helper text says a Stop loop button appears while the loop runs
and that the stop-file name in the goal is filled in at start
(components.autoNudgePopover.stop_loop_hint, all 14 catalogs).

Nothing under src/kiro_crew/ or test/ changes. The monitor_watch MCP tool,
the src/kiro_crew/monitoring engine, the backend clear route and the
retention refusal are all as on main.

A committed capture harness, website/scripts/capture-goal-popover-generic.mjs,
opens the built SPA, clicks the composer trigger in three stubbed states (no
loop, active loop, stopped record plus its confirm row) and fails if the
popover carries a pull request URL field or a "legacy goal loop" call to
action. Its frames are committed under temp-screenshots/goal-popover-generic/.
iamwhatever pushed a commit that referenced this pull request Sep 13, 2026
Reverts the dashboard layer of #5185 and its follow-ups (#9788, #9845,
#10190), which replaced the generic goal-loop popover with a
pull-request-only "Bounded pull request monitor" form.

The composer trigger opens AutoNudgePopover again, so a session can arm a
goal loop for any target from the dashboard instead of being asked for a
GitHub pull request URL. The frontend automation-record layer #5185
introduced goes with it: SessionAutomationPopover, MonitorRadar, the
monitoring/automation normalizer, the per-slot REST automation snapshots
in ChatPage / ChatSidebar / chatSlice / useWebSocket, the dead
api.monitorClear client method and its stale test mock, and the
sessionAutomationPopover catalog block in all 13 i18n catalogs.
website/src/monitoring/contract.json stays: test/test_monitor_persistence.py
reads it as the backend parity artifact.

Three behaviours #5185 carried incidentally stay in the restored wiring.
The goal-loop seed, the autonudge_state frame and ChatPage's per-slot
listener fold channel slot keys (slack:<ts>) to the dashboard filename form
(slack_<ts>) through website/src/utils/dashboardSlotKey.ts, matching
_normalize_slot_key on the backend, so a channel-bound loop lights its
sidebar row and its live frames reach the open popover, and a monitor's
frame feeds the sidebar the same agent-turn accounting the REST seed does.
Every seed takes
its own generation, so two overlapping reconnect seeds cannot let the older
snapshot overwrite the newer one, and ChatPage's per-slot loop fetch is
dropped when a live autonudge_state frame for that slot lands first. When
that fetch fails, the popover says so and withholds Save / Start / Trigger
behind a Retry loading button instead of offering an empty editor whose
Start the existing loop would refuse. The popover keeps the viewport-fit
classes (max-h / overflow-y-auto, stacked number fields on narrow widths).

A structured monitor armed through the MCP monitor tools reaches the legacy
slot read as a reduced row with no message, banner or stop-file path. The
popover recognises both transports of that row (the REST read withholds
message; the live autonudge_state frame carries a monitor object, so
isReducedMonitorRow keys on either) and shows only what the backend will
honour:
a notice that an agent armed a bounded monitor, the schedule line, Stop
loop while it runs, and the clear-stopped-record two-step once it stops.
Save, Start and Trigger, which the backend refuses for that row with
structured_monitor_requires_monitor_api, are not rendered for it.
AutoNudgeLoop.message is optional to say so; the one other reader
(MembersPage's patrol row) falls back to an empty string.

The generic popover keeps the clear-stopped-record control #9788 and #9845
added: a stopped record is cleared with a confirm two-step that sends
DELETE ?intent=clear, so an agent-armed monitor that was stopped by a
session close or user stop still has an exit from the dashboard.

The popover's fresh-state defaults change in two small ways: Max cycles
starts at 24 (0 still means no cap, and an existing loop's 0 is shown as
0), and the helper text says a Stop loop button appears while the loop runs
and that {{STOP_FILE}} in the goal is replaced with a real file path at
start (components.autoNudgePopover.stop_loop_hint; the moustache is passed
as an interpolation value so i18next renders it literally). The three new
strings and the reworded hint are translated in all 11 human catalogs;
en-XA is regenerated.

Nothing under src/kiro_crew/ or test/ changes. The monitor_watch MCP tool,
the src/kiro_crew/monitoring engine, the backend clear route and the
retention refusal are all as on main.

A committed capture harness, website/scripts/capture-goal-popover-generic.mjs,
opens the built SPA, clicks the composer trigger in five stubbed states (no
loop, active loop, stopped record plus its confirm row, reduced monitor
row, failed slot snapshot), fails if the popover carries a pull request URL
field or a "legacy goal loop" call to action, and clips each frame under
2000px. Its frames are attached to the pull request, not committed. The two
harnesses that photographed the removed surface, capture-goal-clear-record.mjs
and capture-monitor-trigger-centering.mjs, go with it; the clear-record flow
is state 03 of the generic harness.
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…tdev#9788)

* fix(monitor): let the owner clear a stopped automation record

A user-stopped monitor record is retained as evidence and refuses a re-arm,
which is deliberate. The way out that refusal names did not exist: DELETE
/api/autonudge/{loop_id} routed a structured monitor into stop_monitor, which
returns an already-terminal loop unchanged, then answered ok. The dashboard's
own button reported success and removed nothing, and the restart route only
revives the same subject. A session that stopped watching one pull request
could never watch another one.

DELETE now splits by state. A live monitor is still stopped, retaining its
outcome. An already-terminal one is cleared through a new
authorize_and_clear_monitor: owner-gated, audited as monitor_clear, and
refusing a live monitor, a future-version record and a wake in flight.

The popover's button says Clear record instead of Stop loop once the loop is
inactive, since that press removes the row rather than stopping anything.

* fix(monitor): close the clear's TOCTOU and name what it erases

Review round 1 on the clear path.

GPT (blocking): the terminal-state checks ran before the audit, and the audit's
to_thread yields the event loop, so a close-rollback restore landing in that
window met an unconditional remove and lost a live watch. The removal now
re-takes the decision inside the service's own lock hold via a new
clear_terminal_monitor, and refuses with 409 when the row moved on.

UX (blocking): a blind reader would not press "Clear record" because the popover
shows nothing called a record, so the one control that unsticks the session went
unpressed. The label names the object ("Clear stopped goal"), the status reads
"Stopped" instead of the resumable-sounding "Paused", and a help line names both
exits because the erase has no undo.

Design (concerns): the verb's meaning was decided by server state, so a stale
"Stop loop" press could erase a record that went terminal in between. The DELETE
now carries the pressed intent and the server 409s on a mismatch.

First principles (subtractions): dropped the zero-consumer `cleared: true`
response key and the unused `auto-nudge-stop` test id.
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…otdev#9845)

Follow-through on the UX review of kirodotdev#9788, which merged with the finding open.

Both surfaces now erase a stopped automation for good, but only the monitor's
was guarded: the legacy goal view's "Clear stopped goal" fired the DELETE on one
plain grey click. A blind reader named it: "this delete button is plain grey with
no warning colour, which makes it easier to hit by mistake" and "I cannot tell
whether it deletes instantly with no are-you-sure".

The legacy control is now danger-coloured unconditionally (not on :hover, which
a touch viewport never produces) and asks first, reusing the monitor surface's
two-step. The confirmation replaces the primary CTA rather than sitting beside
it, so the row keeps its two-control cap.

Both confirm labels now restate the action and its object, because neither
confirm row renders a question: "Yes, clear it" answered one that was never
asked. They read "Clear goal for good" and "Clear monitor for good".
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.

2 participants