Keep browser input from submitting Paseo prompts (#1982)

* fix(desktop): keep browser input out of the composer

Unhandled webview keys could be redispatched into the active host window, allowing agent Enter to submit a draft prompt. Give pages first refusal for ordinary shortcuts and contain automation at the guest boundary.

* fix(desktop): tighten browser shortcut validation

* fix(desktop): respect browser shortcut ownership

* fix(desktop): retain browser keys across windows

* fix(desktop): scope browser webviews by host

* Reshape browser shortcut ownership

Use the browser webview registry as the single guest identity authority, scope browser operations to their host window, publish chord continuations only while pending, and restore focus to the originating browser after command center dismissal.

* Fix host-scoped browser shortcut follow-ups

* Fix browser keyboard review follow-ups

* Fix browser keyboard lifecycle regressions

* Fix browser shortcut review regressions

* Fix desktop browser review regressions

* Fix browser shortcut frame regressions

* Fix rebase integration regressions

* Preserve browser-native shortcut ownership

* Isolate browser shortcuts and automation by context
This commit is contained in:
Mohamed Boudra
2026-07-17 14:29:19 +08:00
committed by GitHub
parent 9f5f5fce62
commit 04d1ebdce0
32 changed files with 3481 additions and 451 deletions
@@ -7,10 +7,11 @@ import {
resolveKeyboardShortcut,
type ChordState,
type KeyboardShortcutContext,
type KeyboardShortcutInput,
type ParsedShortcutBinding,
} from "./keyboard-shortcuts";
function keyboardEvent(overrides: Partial<KeyboardEvent>): KeyboardEvent {
function keyboardInput(overrides: Partial<KeyboardShortcutInput>): KeyboardShortcutInput {
return {
key: "",
code: "",
@@ -20,7 +21,7 @@ function keyboardEvent(overrides: Partial<KeyboardEvent>): KeyboardEvent {
shiftKey: false,
repeat: false,
...overrides,
} as KeyboardEvent;
};
}
function shortcutContext(
@@ -44,14 +45,14 @@ function initialChordState(): ChordState {
}
function resolveShortcut(input: {
event: Partial<KeyboardEvent>;
event: Partial<KeyboardShortcutInput>;
context?: Partial<KeyboardShortcutContext>;
chordState?: ChordState;
onChordReset?: () => void;
bindings?: readonly ParsedShortcutBinding[];
}) {
return resolveKeyboardShortcut({
event: keyboardEvent(input.event),
event: keyboardInput(input.event),
context: shortcutContext(input.context),
chordState: input.chordState ?? initialChordState(),
onChordReset: input.onChordReset ?? (() => undefined),
@@ -60,7 +61,7 @@ function resolveShortcut(input: {
}
function expectShortcutResolution(input: {
event: Partial<KeyboardEvent>;
event: Partial<KeyboardShortcutInput>;
context?: Partial<KeyboardShortcutContext>;
action: string;
payload?: unknown;
@@ -83,7 +84,7 @@ function expectShortcutResolution(input: {
}
function expectNoShortcutResolution(input: {
event: Partial<KeyboardEvent>;
event: Partial<KeyboardShortcutInput>;
context?: Partial<KeyboardShortcutContext>;
}) {
const result = resolveShortcut({
@@ -98,7 +99,7 @@ function expectNoShortcutResolution(input: {
interface MatchingShortcutCase {
name: string;
event: Partial<KeyboardEvent>;
event: Partial<KeyboardShortcutInput>;
context?: Partial<KeyboardShortcutContext>;
action: string;
payload?: unknown;
@@ -108,7 +109,7 @@ interface MatchingShortcutCase {
interface NonMatchingShortcutCase {
name: string;
event: Partial<KeyboardEvent>;
event: Partial<KeyboardShortcutInput>;
context?: Partial<KeyboardShortcutContext>;
}
@@ -548,6 +549,14 @@ describe("keyboard-shortcuts", () => {
expect(secondResult.nextChordState).toEqual(initialChordState());
});
it("resolves a browser-origin shortcut with browser focus instead of host focus", () => {
expectShortcutResolution({
event: { key: "t", code: "KeyT", ctrlKey: true },
context: { isDesktop: true, focusScope: "browser" },
action: "workspace.tab.new",
});
});
it("schedules a chord reset timeout for advancing candidates", () => {
vi.useFakeTimers();