Skip to content

fix(dashboard): keep voice ownership through a mode flip under a live batch capture - #22603

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
kc-wt-14163
Oct 30, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
kc-wt-14163

Conversation

@dodgeblaster

@dodgeblaster dodgeblaster commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A live voice capture keeps its session owner when the streaming preference is flipped mid-recording, so the mic never reads idle while it is still recording.

In useVoiceInput, an effect clears voice session ownership whenever the streaming preference is on and no stream session is in flight. The condition reads the saved preference (streamEnabled) as a stand-in for "this hook owns a stream" — but that is equally true of a live BATCH capture while the preference says streaming. Flipping the setting to streaming under a live batch capture fires the effect and nulls the owner of a recording that is still running.

Why it matters

useComposerVoice gates voiceRecording on ownership, and ChatInput reads voiceRecording for the pulsing red mic button, the recording_click_mic_to_stop placeholder, the Escape-to-cancel handler and the dictation panel's recording prop. With the owner nulled, every one of those reads idle while the microphone is still capturing — a privacy-relevant UI state where the interface reports no recording during a live capture.

Not a goal

  • Changing whether voiceRecording is owner-gated at all, or the cross-slot attribution semantics of ownership.
  • Pinning the reachability closures (single setting writer / navigation unmounts the composer / unmount stops the recorder); this fix removes the defect at its source rather than guarding the closures that make it unreachable today.

What changed (motivation → approach → change)

The mic button read idle during a live batch capture after the streaming setting was flipped. The root cause is the ownership-clear effect in website/src/hooks/useVoiceInput.ts routing on the saved preference (streamEnabled), which describes the transport the next utterance will take, not the one in flight — the same class of defect stop(), cancel() and isRecording already avoid by routing on the transport in flight. The change conjoins the first-hand batch recorder flag: the effect now clears the owner only when streamEnabled && !streamRecording && !streamDraining && !recording && !startingRef.current, so a live batch recorder keeps its owner. The effect only ever touched sessionOwner, so this never stops a capture; it only stops the owner being nulled under one.

Backwards compatibility

Compatible: the effect still clears a genuinely stale owner in every case it did before; the added !recording term only withholds the clear while this hook's own batch recorder is live, which is exactly the capture whose owner must not be dropped.

Removes nothing: no path, record, key or function is removed, hidden or renamed — one AND term is added to an existing effect's guard.

Tests

Added a regression case to useVoiceInput.transportAnchoredCancel.test.tsx, whose flip harness already drives this scenario: it starts a batch capture owned by slot-A, flips the streaming setting ON while the recorder is live, and asserts the owner is still slot-A, the recorder is still recording, and the recording flag the mic button reads is still true. Proven to catch the bug: with the production guard reverted the new test fails with expected null to be 'slot-A', and passes with the fix. Deterministic — driven by awaited React state via renderHook/act/waitFor, no timers or sleeps.

Manual verification

N/A — unit coverage sufficient. The flip window is not reachable in the product today (navigation unmounts the composer, which stops the recorder), so the behaviour is exercised at the hook with the test harness that reproduces the flip directly.

Screenshots / video

Why no screenshot: The change is a hook-state guard that keeps sessionOwner/voiceRecording at their correct values in a window not reachable in the product today; it renders no new or changed markup, layout or styles, so there is no visual delta to capture.

Related Issues

Fixes #14163

Pattern harvest

Rule candidate: an effect or handler that clears/routes in-flight capture state must gate on a first-hand signal of what is actually in flight (recording / streamRecording / streamDraining), never on the saved preference (streamEnabled), which describes the next utterance's transport — the same anchoring stop(), cancel() and isRecording already apply.
Pattern: useEffect clearing/deciding live-capture state off a settings flag instead of the first-hand in-flight flag.

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing to check. The diff adds one condition to a hook's ownership-clear effect plus a test. It adds or changes no control, string or markup, so no screenshot or recording is needed.

[UX-REVIEWED] a961005

Description read

[DESCRIPTION-READ] c437d701552bb4914a67fc7a59ee5e1c260cc7cc3d6a042f0713a41b5d5aca66

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

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a9610054a3e35cdd5044e70b6bf51597cb53f3dc — 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

This is a one-term fix at the mechanism level for a linked issue (#14163). It ships a regression test that fails on the base, and it adds no new surface.

What this change ships

Inventory (2 items) — 2 justified

Intent: keep the mic showing "recording" for a live capture when the user flips the streaming setting mid-recording. This is a FIX.

  1. A live batch recording now keeps its owning chat slot when streaming is turned on mid-capture, so the mic button, placeholder, Escape-to-cancel and dictation panel stay in the recording state. — justified
  2. A regression test drives the setting flip under a live batch recorder and asserts that the owner and the recording state survive. — justified

[FIRST-PRINCIPLES-REVIEWED] a961005

Description read

[DESCRIPTION-READ] 6be6532d29e950b70a2c8289187c3a1316184b741e4f71a3428501346967affb

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 20, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a961005

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

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The guard now checks the recorder that is actually running, not the saved setting, which is the cause of the bug, and the change is one added condition.

Notes

  • Adding recording to the dependencies makes the effect run again when a batch capture stops while streaming is on, so the owner is cleared before the transcription runs show. The show handler sets the owner back to request.sessionId, and before this change the owner was already cleared at the flip, so this is no regression. Mention it in the comment so a later reader doesn't take it for a lost-owner window.

[DESIGN-REVIEWED] a961005

Description read

[DESCRIPTION-READ] 563be40bedd5916f71a507493f57adf6e4dc9c16143bb9bf2b837580a45e8e07

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 20, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a961005

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

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

@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Frontend Tests (1) / Frontend Coverage Merge red on 1d6a292 is main's, not this PR's: src/test/kiroUsageRefetchInterval.test.ts > maps an explicit unavailable answer to a terminal sentinel (expected 'none' to be 'api-key') fails on a clean origin/main 7e09632 tree too; this PR does not touch that file. Fix pending in #25944. Will rebase onto it once it merges.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto #25944 (main now carries the kiroUsageRefetchInterval test fix): 1d6a292 -> a961005. Diff unchanged (same 2 files); CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@dodgeblaster
dodgeblaster marked this pull request as ready for review October 30, 2026 00:29
@dodgeblaster
dodgeblaster requested review from a team and KiroCrewCaptain as code owners October 30, 2026 00:29
@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 Oct 30, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 30, 2026 02:05

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: useVoiceInput's ownership-clear effect now also requires the batch recorder to be idle, so turning streaming on in Settings during a live batch capture no longer clears the owner of that recording; a test reproduces the mode flip.

@KiroCrewCaptain
KiroCrewCaptain merged commit 122005d into main Oct 30, 2026
97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the kc-wt-14163 branch October 30, 2026 02:06
@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.

dashboard: the voice ownership-clear effect nulls the owner of a live batch capture on a mode flip, so the mic button reads idle while it records

2 participants