diff --git a/knip.json b/knip.json index e2377ab07a..82c837383b 100644 --- a/knip.json +++ b/knip.json @@ -54,6 +54,7 @@ "project": [ "bin/**/*.js", "server/**/*.{js,mjs,cjs}", + "server/lib/routing/runtime.ts", "src/**/*.{ts,tsx}" ] }, diff --git a/packages/electron/DOCUMENTATION.md b/packages/electron/DOCUMENTATION.md index 92a4065c03..d50aaa8488 100644 --- a/packages/electron/DOCUMENTATION.md +++ b/packages/electron/DOCUMENTATION.md @@ -65,6 +65,7 @@ Electron owns native windows, privileged IPC, desktop host credentials, browser- - Panel driver scripts and annotation bindings run in isolated worlds, including cross-origin frames. Only the top overlay's own world holds the microphone binding, so page scripts cannot call it. Annotation cancellation can precede session creation; cleanup from the previous session can still be running when the next starts. - Dialog handling stays available while Page.enable is pending because a dialog can block that command's response. Actions return when they open a dialog, and agent tabs answer dialogs immediately with the action's chosen response to avoid blocking the whole app window. Recorded dialog history is bounded because a page can loop on alerts. - Pointer input uses the debugger session that owns the target frame and coordinates relative to that session. Sending cross-origin input to the top page makes hidden-panel hit testing depend on app layout. HTML-draggable elements use scripted drag events because native HTML drag starts a system session the guest cannot intercept. +- Browser press maps Shift with US digit and punctuation keys to the shifted character. The unmodified text remains the base character, and Control, Meta, and Alt chords insert no text. - Focus emulation keeps agent pages' controls and clipboard usable without taking the user's keyboard focus. It is reapplied before focusing actions because navigation replaces page state. Colour-scheme emulation is per page; changing `nativeTheme.themeSource` would change the app too. A white base canvas prevents transparent pages from showing the app behind them or capturing black. - Only shell-staged upload files enter a page. Each file has its own folder and a single-segment filename so duplicate names survive and paths cannot escape staging. Files remain for a day because a form can read them later; age-based cleanup preserves files another app instance still uses. - Favicons are fetched with the page's own session and returned as bounded data URLs. This preserves login cookies and avoids third-party requests from the app origin. Space views receive no shell-fetched favicon because that request could reach the user's resources on the space's behalf. diff --git a/packages/electron/browser-panel-driver.mjs b/packages/electron/browser-panel-driver.mjs index 045026c952..8c91de4a97 100644 --- a/packages/electron/browser-panel-driver.mjs +++ b/packages/electron/browser-panel-driver.mjs @@ -36,6 +36,11 @@ const NAMED_KEYS = { const MODIFIER_BITS = { Alt: 1, Control: 2, Meta: 4, Shift: 8 }; +const SHIFTED_US_KEYS = { + '1': '!', '2': '@', '3': '#', '4': '$', '5': '%', '6': '^', '7': '&', '8': '*', '9': '(', '0': ')', + '`': '~', '-': '_', '=': '+', '[': '{', ']': '}', '\\': '|', ';': ':', "'": '"', ',': '<', '.': '>', '/': '?', +}; + // external: https://www.electronjs.org/docs/latest/api/web-contents#contentssendinputeventinputevent macOS editing shortcuts require the corresponding edit command as well as synthesized keys. const EDITING_COMMANDS = { a: 'selectAll', c: 'copy', v: 'paste', x: 'cut', z: 'undo' }; @@ -60,7 +65,9 @@ export const keyEventsFor = (combo, platform = process.platform) => { keyCode = named.keyCode; text = named.text; } else if ([...keyName].length === 1) { - key = (modifiers & MODIFIER_BITS.Shift) && /[a-z]/.test(keyName) ? keyName.toUpperCase() : keyName; + key = (modifiers & MODIFIER_BITS.Shift) + ? (SHIFTED_US_KEYS[keyName] ?? (/[a-z]/.test(keyName) ? keyName.toUpperCase() : keyName)) + : keyName; const upper = keyName.toUpperCase(); if (/[A-Z]/.test(upper)) { code = `Key${upper}`; @@ -87,7 +94,7 @@ export const keyEventsFor = (combo, platform = process.platform) => { const down = { ...base, type: text ? 'keyDown' : 'rawKeyDown' }; if (text) { down.text = text; - down.unmodifiedText = text; + down.unmodifiedText = named ? text : keyName; } if (command) down.commands = [command]; return [down, { ...base, type: 'keyUp' }]; diff --git a/packages/electron/browser-panel-driver.test.mjs b/packages/electron/browser-panel-driver.test.mjs index db4a1cb83a..7d949abe47 100644 --- a/packages/electron/browser-panel-driver.test.mjs +++ b/packages/electron/browser-panel-driver.test.mjs @@ -25,6 +25,24 @@ test('keyEventsFor maps a letter to its code and types it, upper case with Shift assert.equal(down.text, 'A'); }); +test('keyEventsFor maps shifted US digits and punctuation while retaining unmodified text', () => { + for (const [base, shifted] of Object.entries({ + '1': '!', '2': '@', '3': '#', '4': '$', '5': '%', '6': '^', '7': '&', '8': '*', '9': '(', '0': ')', + '`': '~', '-': '_', '=': '+', '[': '{', ']': '}', '\\': '|', ';': ':', "'": '"', ',': '<', '.': '>', '/': '?', + })) { + const [down, up] = keyEventsFor(`Shift+${base}`, 'linux'); + assert.equal(down.key, shifted); + assert.equal(down.text, shifted); + assert.equal(down.unmodifiedText, base); + assert.equal(up.key, shifted); + } + const [letter] = keyEventsFor('Shift+a', 'linux'); + assert.equal(letter.unmodifiedText, 'a'); + const [chord] = keyEventsFor('Control+Shift+7', 'linux'); + assert.equal(chord.key, '&'); + assert.equal(chord.text, undefined); +}); + test('keyEventsFor turns the platform shortcut into an editing command and types nothing', () => { const [mac] = keyEventsFor('Meta+a', 'darwin'); assert.deepEqual(mac.commands, ['selectAll']);