Skip to content

fix(channel): ask the per-agent clear through the in-page dialog - #25951

Merged
bolichen97 merged 1 commit into
mainfrom
crew/issue-triage/fix-25179-agent-clear-confirm
Oct 30, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
crew/issue-triage/fix-25179-agent-clear-confirm

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The per-agent Clear context button in a channel's agents panel asks in the same in-page dialog as the channel-wide clear, instead of the browser's native popup.

In a channel's agents panel, the row's Clear context button still asks with the browser's native confirm(). The channel-wide Clear Context already uses the shared in-page dialog (#11157). So the two clears in the same panel ask in two different ways, and the native popup freezes the page and cannot be themed.

Why it matters

Anyone who resets one agent's session in a channel gets an unthemed OS popup that blocks the whole renderer, next to a button that asks in-page. The native popup also cannot follow the row: if the agent leaves while it is open, saying yes still sends the clear.

Not a goal

What changed (motivation → approach → change)

The per-agent clear now asks through useConfirm(), the hook the channel-wide clear already uses.

Before After
How it asks native confirm() in-page dialog, title and button "Clear context", body names the role
Agent or channel leaves mid-dialog clear still sent on yes dialog closes itself, nothing is sent
Row spinner — shows only after yes, not behind the open dialog

The page pins the agent and channel when the dialog opens, and the existing withdraw effect now cancels the dialog when either is gone, or when the agent's state turns done. The row's onClearContext takes a begin callback, so the row marks itself busy only once the request starts.

Overlap: open PR #21276 also changes this line (without the withdraw-on-leave part). Whichever lands second can keep or drop the hunk.

Backwards compatibility

Compatible: same strings, same API call (channelClearContext(id, 'agent', agentId)); only the way the browser asks changes.

Removes nothing: the confirm step stays; only its surface moves from the native popup to the in-page dialog.

Tests

website/src/test/ChannelPage.clearContext.test.tsx:

  • still ASKS before a per-agent clear, and does nothing when that is declined: the in-page dialog opens with the role, window.confirm is never called, the row is not busy behind it, and Cancel sends nothing.
  • withdraws the per-agent confirmation when its agent leaves under it: a channel_agent_left event closes the dialog and sends nothing.
  • The existing per-agent tests now answer the in-page dialog instead of stubbing window.confirm. The focus test waits for the dialog to hand focus back to the pressed row button.

Proof: not provable -- frontend test (prove.py runs Python only)

Checked by hand instead: with this test file on origin/main (2ad709c), 10 of 35 tests fail, all the per-agent ones. On this head all 35 pass, and 5 runs with --sequence.shuffle (seeds 1-5) all pass. The four related ChannelPage test files pass on this head (52 tests). tsc -p tsconfig.app.json, eslint on both files, semgrep and the flake ratchet pass.

Manual verification

Rendered the existing capture page website/capture/channel-clear-context.html in Chromium (dark and light), opened the agents panel and pressed a row's Clear context. On origin/main the press raised the native dialog "Reset Researcher's LLM session. The channel's shared message history is preserved." On this head no native dialog fires and the in-page dialog shows.

Screenshots / video

After (dark): the in-page dialog.

after, dark

After (light), and before

after, light

Before (dark): no in-page dialog; the press raised the browser's native popup, which a page screenshot cannot show.

before, dark

Related Issues

Closes #25179

Sibling sweep

Swept: git grep -n "confirm(" -- website/src/pages/ChannelPage.tsx
Sibling: website/src/pages/ChannelPage.tsx -- not affected -- the remaining hit is the channel Close button, a different action; open PR #21276 migrates it.

Pattern harvest

Not generalizable: #11157 moved the channel-wide clear and left this one on purpose to keep that PR small; this finishes the same panel, and the repo-wide native-dialog migration is #21276's scope.

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

🤖 AI-assisted PR 🤖

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 29, 2026 20:55
@iamwhatever iamwhatever mentioned this pull request Oct 29, 2026
5 tasks done
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Local Opus review (head b1a5b4318ad9, same diff as 37f5abe) noted, at Low: clearTargetLive withdraws the dialog for a done agent but not a failed one. Left as is: it is Low, the row already hides its Clear context button for a failed agent, and it can be a one-word follow-up if a reviewer asks.

🤖 AI-assisted comment 🤖

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change moves the per-agent clear onto the channel-wide clear's existing useConfirm dialog, and renders of this revision are attached.

Notes

  • After the await, askClearAgent re-checks against the channels it captured when the dialog opened, not the current list. It works because the withdraw effect cancels the dialog when the agent leaves. askClearAll does the same thing.

[DESIGN-REVIEWED] cb55540

Description read

[DESCRIPTION-READ] bdc2d80352c44cd96be7c8d124c10edff5388c791bab76a28ee2b29a9156db12

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing blocks. The change moves an existing confirm from the browser's native popup into the in-page dialog the product already uses. The dark and light screenshots show the dialog, and the blind reader read it correctly.

Notes

  • Body copy "Reset Researcher's LLM session…": the blind reader said "I don't know what 'LLM session' means". In a follow-up, reword it in task terms, e.g. "Researcher forgets this conversation. The channel's messages stay."
  • In the dialog, the red "Clear context" button was read correctly but rated only "a guess", and the reader "would hesitate". Naming the agent in the button ("Clear Researcher's context") would show that only one agent is affected.
  • The blind reader couldn't tell the top "Clear Context" from the row's "Clear context": they share one icon and one name with different casing. In a later PR, give the channel-wide button a distinct label, e.g. "Clear all agents".

[UX-REVIEWED] cb55540

Description read

[DESCRIPTION-READ] 56515fb783c64e2dc7782be5bed44df417ed572cd5aef0b7811466aee4f2f5dc

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of cb5554022b863d8666542630066238510488b6eb — 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: the fix closes #25179 by reusing the existing useConfirm() hook, and both riders are declared changes to the same dialog.

What this change ships

Inventory (4 items) — 4 justified

Intent: resetting one agent's session in a channel asks in the same themed, non-blocking in-page dialog as the channel-wide clear. This is a FIX.

  1. The per-agent Clear context button asks in the in-page dialog instead of the browser's native popup — justified
  2. That dialog closes itself, and nothing is sent, if the agent leaves, finishes (done) or the channel goes while it is open — justified
  3. The row's spinner shows only after the user says yes, not behind the open dialog — justified
  4. The single pendingClearAllRef now records the agent as well as the channel, and the clear-all path uses it too — justified

[FIRST-PRINCIPLES-REVIEWED] cb55540

Description read

[DESCRIPTION-READ] ad59131cdf9472c50756374e1430d1dba2247cfa2495fe38cc19a6990de1e814

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] cb55540

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

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of cb5554022b863d8666542630066238510488b6eb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] cb55540

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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Frontend Tests (1) is red on src/test/kiroUsageRefetchInterval.test.ts (expected 'none' to be 'api-key', job log). This PR does not touch that file: it is the red on main tracked in #25941, fixed by #25944. No push or rerun here; this PR rebases once after the fix merges.

🤖 AI-assisted comment 🤖

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

Good to ship. The per-agent Clear context now asks through useConfirm, the same hook the channel-wide clear uses.

Head reviewed: 37f5abe.

What I checked:

  • The row button renders only for live agents, so the new state !== 'done' check in clearTargetLive cannot close a dialog the moment it opens.
  • The shared pendingClearRef keeps the channel-wide withdraw behaviour unchanged. With no agentId it checks the channel only.
  • begin() runs only after yes, so the row is not busy behind the open dialog. The finally block still resets it on every path.
  • main has not changed ChannelPage.tsx, its clear-context test or ConfirmDialog.tsx since the merge base.
  • I ran src/test/ChannelPage.clearContext.test.tsx at this head: 35 of 35 pass. A mutation that drops the agent check from clearTargetLive turns the new withdraw test red, so the test pins the guard.

0 must-fix, 0 should-fix.

Not approving yet: Frontend Tests (1) is red at this head. The failure is kiroUsageRefetchInterval.test.ts > maps an explicit unavailable answer to a terminal sentinel (expected 'none' to be 'api-key'), a file this PR does not touch. A re-run should clear it. I will approve once that check and readiness pass on this head.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Thanks @bolichen97 for the review at 37f5abeabcc2.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Backend Tests (Windows) (2) is red on the 3 main tests tracked in #25937 (fix: #25947): test_no_lock_file_is_created_with_a_nonexclusive_open, test_the_package_stays_within_its_line_budget and test_hook_time_is_not_charged_to_the_first_prompt_watchdog (job log). Frontend Coverage Merge fails only on the #25941 test already noted above. This PR touches none of these files. No push, rerun or override; it rebases once after the fixes merge.

🤖 AI-assisted comment 🤖

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 29, 2026
@bolichen97
bolichen97 force-pushed the crew/issue-triage/fix-25179-agent-clear-confirm branch from 37f5abe to fec2bfe Compare October 29, 2026 22:19
@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 Oct 29, 2026
@bolichen97
bolichen97 force-pushed the crew/issue-triage/fix-25179-agent-clear-confirm branch from fec2bfe to cb55540 Compare October 29, 2026 23:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 29, 2026

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

Approving at cb55540.

This head is a rebase of the head reviewed earlier (37f5abe). The range diff shows the PR commit unchanged and the patch id matches, so the earlier review still holds: no findings.

Gates checked at this head: readiness passed, every check green including Frontend Tests and Coverage Gate, all five AI lanes pass, no change request, mergeable, two files.

@bolichen97
bolichen97 merged commit e15f49c into main Oct 30, 2026
94 checks passed
@bolichen97
bolichen97 deleted the crew/issue-triage/fix-25179-agent-clear-confirm branch October 30, 2026 00:27
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 30, 2026
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.

Channel: move the per-agent Clear context confirm onto the shared in-page dialog

2 participants