Skip to content

Fix Space key activating header buttons instead of PTT in voice mode - #321164

Merged
Megan Rogge (meganrogge) merged 1 commit into
mainfrom
meganrogge/fix-space-miniview
Jun 12, 2026
Merged

Megan Rogge (meganrogge) merged 1 commit into
mainfrom
meganrogge/fix-space-miniview

Conversation

@meganrogge

Copy link
Copy Markdown
Collaborator

When a header button (mini-view, feedback, etc.) had keyboard focus, pressing Space triggered the browser's native click on that button instead of activating push-to-talk. This happened because role="button" elements fire click on Space keydown by default.

Adds a keydown listener on the voice widget container that prevents the default Space behavior, ensuring Space always maps to PTT via the agentsVoice.pushToTalk keybinding. Buttons remain keyboard-navigable and activatable via Enter.

Copilot AI review requested due to automatic review settings June 12, 2026 14:51
@meganrogge
Megan Rogge (meganrogge) marked this pull request as draft June 12, 2026 14:52
@meganrogge
Megan Rogge (meganrogge) force-pushed the meganrogge/fix-space-miniview branch from 3335202 to 7352170 Compare June 12, 2026 14:53

Copilot AI 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.

Pull request overview

Fixes an input-handling conflict in the Agents Voice widget where pressing Space could trigger the browser’s native “click” behavior on focused header controls instead of reliably mapping to push-to-talk (PTT).

Changes:

  • Adds a keydown handler on the widget container to preventDefault() for Space (outside of text inputs) so Space won’t activate focused header buttons.
  • Keeps PTT release behavior on keyup as before, relying on the agentsVoice.pushToTalk keybinding for the keydown behavior.
Show a summary per file
File Description
src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.ts Prevents Space default behavior within the voice widget so Space consistently maps to PTT rather than activating header controls.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.ts:177

  • The new keydown listener is added directly via addEventListener but never removed on widget disposal. Since this widget’s dispose() keeps the container element around (it just re-renders nothing), the handler can leak this.callbacks/widget state and may cause duplicate handling if the widget is re-created on the same container. Consider registering both the keydown and keyup handlers for disposal (same issue applies to the existing keyup listener).
			this.container.addEventListener('keydown', (e: KeyboardEvent) => {
				if (e.code === 'Space' && !_isTextInput(e.target)) {
					e.preventDefault();
				}
			});
			// keyup listener for hold-to-talk release — the keydown is
			// handled by the registered Space keybinding (agentsVoice.pushToTalk).
			this.container.addEventListener('keyup', (e: KeyboardEvent) => {
				if (e.code === 'Space' && !_isTextInput(e.target)) {
					e.preventDefault();
					this.callbacks.pttUp();
				}
			});
  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@meganrogge
Megan Rogge (meganrogge) marked this pull request as ready for review June 12, 2026 14:55
@meganrogge Megan Rogge (meganrogge) added this to the 1.125.0 milestone Jun 12, 2026
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) June 12, 2026 14:55
@meganrogge
Megan Rogge (meganrogge) marked this pull request as draft June 12, 2026 14:55
auto-merge was automatically disabled June 12, 2026 14:55

Pull request was converted to draft

Three issues caused Space to misbehave in voice mode:

1. The pushToTalk action called toggleWindow() to open the aux window.
   Since the keybinding only fires when AGENTS_VOICE_WIDGET_FOCUSED,
   the UI is already visible. Removed the toggleWindow() call.

2. When a header button had keyboard focus, pressing Space triggered
   the browser's native click on that button. Added keydown/keyup
   listeners that track the PTT key and preventDefault on it.

3. The keyup handler was hardcoded to Space, so rebinding PTT to
   another key would break hold-to-talk release. Now captures the
   actual key code from the document keydown (capture phase) when
   pttDown fires, and matches that code on keyup.

Co-authored-by: Copilot <[email protected]>
@meganrogge
Megan Rogge (meganrogge) force-pushed the meganrogge/fix-space-miniview branch from 7352170 to fa39ce7 Compare June 12, 2026 14:58
@meganrogge
Megan Rogge (meganrogge) marked this pull request as ready for review June 12, 2026 15:02
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) June 12, 2026 15:02
@meganrogge
Megan Rogge (meganrogge) merged commit be93ed6 into main Jun 12, 2026
25 checks passed
@meganrogge
Megan Rogge (meganrogge) deleted the meganrogge/fix-space-miniview branch June 12, 2026 15:34
Megan Rogge (meganrogge) added a commit that referenced this pull request Jun 12, 2026
- Remove toggleWindow() call from pushToTalk action (prevents Space from
  opening the mini aux window)
- Add dynamic PTT key tracking: captures last keydown code at document
  level, snapshots it on pttDown, matches on keyup — works with any
  rebound key, not just hardcoded Space
- Add keydown preventDefault to block role='button' click activation
  during hold-to-talk

Co-authored-by: Copilot <[email protected]>
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants