Copy and paste: the desktop's universal copy key works; Ctrl+C at the terminal login keeps the terminal

Omarchy's Super+C sends Ctrl+C by setting the modifier state with no Ctrl key
event while Super is held. Flutter's web engine only presses a modifier on its
own key event, so the app saw a plain "c": the chat selection was not copied
and the terminal typed the letter. A key modifier sync in front of the
framework's key handler now presses the modifiers the browser event's flags
hold (and outside Apple platforms lets go of a held Meta for Ctrl+C/V/X/A/
Insert), installed by the app's binding.

The terminal copies a selection on Ctrl+C without sending ^C, treats the
injected copy key as copy only, and pastes on Shift+Insert. A refused
clipboard write or read now shows a message instead of failing silently.

Server: before the login completes, Ctrl+C and Ctrl+\ erase the typed
password (Ctrl+U) and Ctrl+Z is dropped, so su is not killed and the terminal
no longer ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-29 17:57:28 +00:00
parent 58041e06b7
commit 3d739c3bfc
31 changed files with 2090 additions and 17 deletions
+2
View File
@@ -72,6 +72,8 @@ In JSON, a step can also set `wait` (ms), `timeout`, `name`, `ms` and `frames`.
| `labels=name` | write the visible semantics labels, keys and rects to JSON |
| `film=<target>` | screencast a click for `--film-ms` (900) and write the frames plus a contact sheet; `film=press:Alt+t` films a key chord (as `press=`) instead |
| `wait=ms` | sleep |
| `keys=[...]` | raw key events (JSON `Input.dispatchKeyEvent` params, each with an optional `after` ms), e.g. modifier flags without their key events as a compositor's injected shortcut sends them (`examples/clipboard-*.json`) |
| `grant=clipboard` | let the page read and write the clipboard (`navigator.clipboard` in `eval`) |
| `files=a.ttf[,b.ttf]` | answer the next file chooser the page opens with these files (paths relative to the working directory); put it before the click that opens the picker |
| `swipe=<target>>dx,dy` | one-finger touch swipe (needs `--touch true`, which emulates a touch screen once semantics is on) |
| `pinch=<target>>scale` | two-finger touch pinch, spreading (>1) or closing (<1) (needs `--touch true`) |
+2
View File
@@ -93,6 +93,8 @@ export async function openBrowser({ cdp, gpu = false, chromePath = process.env.C
} catch (error) { ws.close(); await cleanup(); throw error; }
return {
send: (method, params) => raw(method, params, sessionId),
/** A browser-level call (no page session), e.g. `Browser.grantPermissions`. */
sendBrowser: (method, params) => raw(method, params),
on: (method, fn) => {
listeners.set(method, [...(listeners.get(method) ?? []), fn]);
return () => listeners.set(method, listeners.get(method).filter((f) => f !== fn));
+19
View File
@@ -27,6 +27,7 @@ steps: open=<route>[@WxH] wait=<ms> shot=<name> click=<target> waitfor=<target
type=<text> press=<Enter|Escape|Tab|...> scroll=<dy> size=WxH
files=<path>[,<path>] (answers the next file chooser)
film=<target> labels=<name> tabs=<name> eval=<js> expect=<js> hover=<target>
keys=<json events> grant=clipboard
rightclick=<target> (secondary button: context menus)
drag=<target>><dx>,<dy> (JSON: drag, dx, dy, steps, gap, hold)
swipe=<target>><dx>,<dy> pinch=<target>><scale> (with --touch true)
@@ -127,6 +128,24 @@ try {
case 'type': await page.type(String(value)); await delay(step.wait ?? settle); break;
case 'compose': await page.compose(String(value)); await delay(step.wait ?? settle); break;
case 'press': await page.press(String(value)); await delay(step.wait ?? settle); break;
case 'keys': {
// Raw key events (Input.dispatchKeyEvent params), each optionally
// `after` ms after the previous: modifier flags without their key
// events, as a compositor's injected shortcut sends them.
for (const { after = 0, ...event } of Array.isArray(value) ? value : JSON.parse(String(value))) {
if (after) await delay(after);
await browser.send('Input.dispatchKeyEvent', event);
}
await delay(step.wait ?? settle);
break;
}
case 'grant': {
// `grant=clipboard` lets the page read and write the clipboard.
const origin = new URL(await page.evaluate('location.href')).origin;
const permissions = value === 'clipboard' ? ['clipboardReadWrite', 'clipboardSanitizedWrite'] : String(value).split(',');
await browser.sendBrowser('Browser.grantPermissions', { origin, permissions });
break;
}
case 'scroll': {
const at = await page.scroll(Number(value), step.at, { dx: Number(step.dx ?? 0), repeat: Number(step.repeat ?? 1), gap: Number(step.gap ?? 16) });
log(` wheel at ${Math.round(at.x)},${Math.round(at.y)}`);
@@ -0,0 +1,70 @@
{
"params": "chats=2",
"steps": [
{
"open": "/chat/perf-chat-0@1000x800"
},
{
"wait": 1500
},
{
"grant": "clipboard"
},
{
"eval": "(window.__writes=[], navigator.clipboard.writeText = (t) => { window.__writes.push(t); return Promise.reject(new DOMException('Write permission denied.', 'NotAllowedError')); }, 'clipboard writes now rejected')"
},
{
"drag": "484,267",
"dx": 110,
"dy": 0
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 30
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 800
},
{
"shot": "c2-copy-refused-message"
},
{
"eval": "JSON.stringify(window.__writes)"
},
{
"wait": 1000
},
{
"shot": "c3-later"
}
]
}
@@ -0,0 +1,224 @@
{
"params": "chats=2",
"steps": [
{
"open": "/chat/perf-chat-0@1000x800"
},
{
"wait": 1500
},
{
"grant": "clipboard"
},
{
"eval": "navigator.clipboard.writeText('SENTINEL').then(()=>'reset')"
},
{
"drag": "484,267",
"dx": 110,
"dy": 0
},
{
"shot": "physical-ctrl-c-selected"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Control",
"code": "ControlLeft",
"modifiers": 2,
"windowsVirtualKeyCode": 17
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67
},
{
"type": "keyUp",
"key": "Control",
"code": "ControlLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 17
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'physical-ctrl-c: '+JSON.stringify(t))",
"name": "physical-ctrl-c"
},
{
"click": "700,200"
},
{
"eval": "navigator.clipboard.writeText('SENTINEL').then(()=>'reset')"
},
{
"drag": "484,267",
"dx": 110,
"dy": 0
},
{
"shot": "omarchy-super-c-ctrl-only-selected"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 30
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'omarchy-super-c-ctrl-only: '+JSON.stringify(t))",
"name": "omarchy-super-c-ctrl-only"
},
{
"click": "700,200"
},
{
"eval": "navigator.clipboard.writeText('SENTINEL').then(()=>'reset')"
},
{
"drag": "484,267",
"dx": 110,
"dy": 0
},
{
"shot": "omarchy-super-c-ctrl-meta-selected"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 6,
"windowsVirtualKeyCode": 67,
"after": 30
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 6,
"windowsVirtualKeyCode": 67,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'omarchy-super-c-ctrl-meta: '+JSON.stringify(t))",
"name": "omarchy-super-c-ctrl-meta"
},
{
"click": "700,200"
},
{
"eval": "navigator.clipboard.writeText('SENTINEL').then(()=>'reset')"
},
{
"drag": "484,267",
"dx": 110,
"dy": 0
},
{
"shot": "ctrl-insert-selected"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Control",
"code": "ControlLeft",
"modifiers": 2,
"windowsVirtualKeyCode": 17
},
{
"type": "rawKeyDown",
"key": "Insert",
"code": "Insert",
"modifiers": 2,
"windowsVirtualKeyCode": 45
},
{
"type": "keyUp",
"key": "Insert",
"code": "Insert",
"modifiers": 2,
"windowsVirtualKeyCode": 45
},
{
"type": "keyUp",
"key": "Control",
"code": "ControlLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 17
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'ctrl-insert: '+JSON.stringify(t))",
"name": "ctrl-insert"
},
{
"click": "700,200"
}
]
}
@@ -0,0 +1,234 @@
{
"params": "chats=2&terminals=1&terminal=panel",
"steps": [
{
"open": "/chat/perf-chat-0@1000x800"
},
{
"wait": 2000
},
{
"grant": "clipboard"
},
{
"eval": "navigator.clipboard.writeText('SENTINEL').then(()=>'reset')"
},
{
"click": "500,720"
},
{
"drag": "96,570",
"dx": 200,
"dy": 0
},
{
"shot": "t1-selected"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 30
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'t-super-c-selection: '+JSON.stringify(t))"
},
{
"shot": "t2-after-super-c"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 30
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'t-super-c-no-selection: '+JSON.stringify(t))"
},
{
"shot": "t3-super-c-nothing-selected"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "v",
"code": "KeyV",
"modifiers": 2,
"windowsVirtualKeyCode": 86,
"after": 30
},
{
"type": "keyUp",
"key": "v",
"code": "KeyV",
"modifiers": 2,
"windowsVirtualKeyCode": 86,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 800
},
{
"shot": "t4-super-v-pasted"
},
{
"drag": "96,585",
"dx": 200,
"dy": 0
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 6,
"windowsVirtualKeyCode": 67,
"after": 30
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 6,
"windowsVirtualKeyCode": 67,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 600
},
{
"eval": "navigator.clipboard.readText().then(t=>'t-super-c-merged-meta: '+JSON.stringify(t))"
},
{
"shot": "t5-after-merged"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Control",
"code": "ControlLeft",
"modifiers": 2,
"windowsVirtualKeyCode": 17
},
{
"type": "rawKeyDown",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67
},
{
"type": "keyUp",
"key": "c",
"code": "KeyC",
"modifiers": 2,
"windowsVirtualKeyCode": 67
},
{
"type": "keyUp",
"key": "Control",
"code": "ControlLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 17
}
],
"wait": 600
},
{
"shot": "t6-ctrl-c-no-selection-interrupts"
}
]
}
@@ -0,0 +1,59 @@
{
"params": "chats=2",
"steps": [
{
"open": "/chat/perf-chat-0@1000x800"
},
{
"wait": 1500
},
{
"grant": "clipboard"
},
{
"eval": "navigator.clipboard.writeText('pasted via Super+V').then(()=>'set')"
},
{
"click": "700,747"
},
{
"keys": [
{
"type": "rawKeyDown",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 4,
"windowsVirtualKeyCode": 91
},
{
"type": "rawKeyDown",
"key": "v",
"code": "KeyV",
"modifiers": 2,
"windowsVirtualKeyCode": 86,
"after": 30
},
{
"type": "keyUp",
"key": "v",
"code": "KeyV",
"modifiers": 2,
"windowsVirtualKeyCode": 86,
"after": 50
},
{
"type": "keyUp",
"key": "Meta",
"code": "MetaLeft",
"modifiers": 0,
"windowsVirtualKeyCode": 91,
"after": 100
}
],
"wait": 800
},
{
"shot": "c1-composer-super-v"
}
]
}
+5 -1
View File
@@ -232,7 +232,11 @@ List<JsonMap> terminalFixtureFollowUps(JsonMap request) {
if (!_terminals.containsKey(terminal)) return const [];
final data = '${body['data'] ?? ''}';
final folder = terminal == 'term_build' ? '~/src/pipelines' : '~';
final echo = data.replaceAll('\r', '\r\n${_promptAt(folder)}');
// Ctrl-C echoes as a terminal with echoctl shows it, so an interrupt
// is visible in captures.
final echo = data
.replaceAll('\r', '\r\n${_promptAt(folder)}')
.replaceAll('\x03', '^C\r\n${_promptAt(folder)}');
final offset = utf8.encode(_output[terminal]!).length;
_output[terminal] = _output[terminal]! + echo;
return [
+3 -1
View File
@@ -1,3 +1,4 @@
import 'package:pipelines_app/application/pipelines_binding.dart';
import 'package:pipelines_app/core/servers/chat/chat_server_pool.dart';
import 'package:pipelines_app/core/servers/machine_access.dart';
import 'package:pipelines_app/core/servers/server_catalog.dart';
@@ -197,6 +198,7 @@ void _installUiReviewChats() {
'closed_at': null,
};
}
const List<String> _turnFileNames = [
'input.md',
'memory.md',
@@ -901,7 +903,7 @@ class _FixtureSink implements WebSocketSink {
///
/// app/tool/capture/ drives this entry generically; see its README.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
PipelinesBinding.ensureInitialized();
await Future.wait([
QuickSwitchAnimationController.instance.restore(),
AnimationSpeedController.instance.restore(),