Files
pipelines/app/notes/clipboard-keys.md
T
alan 3d739c3bfc 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>
2026-11-29 17:57:28 +00:00

71 lines
4.1 KiB
Markdown

# Clipboard keys (copy/paste everywhere, Omarchy universal copy, terminal Ctrl+C)
Operator report: copying out of the web app was unreliable; the desktop's
universal copy key (Omarchy SUPER+C) worked everywhere but Pipelines; Ctrl+C
should not end the terminal session.
## Root causes
- **Universal copy/paste (confirmed in Chromium over CDP).** Omarchy's
SUPER+C (`/usr/share/omarchy/default/hypr/bindings/clipboard.lua`) sends
Ctrl+C with Hyprland `send_key_state`: the key event carries `ctrlKey`, but
no Ctrl key event is ever sent, while Super is physically held. Flutter's
web engine learns a modifier is down only from that modifier's own key
event (it synthesizes *releases* from the flags, never presses), so the
framework saw a plain `c`: the chat selection was not copied and the
terminal typed the letter. If the browser also reports Meta for the chord,
Ctrl+Meta+C matched no copy shortcut either. Physical Ctrl+C / Ctrl+Insert
worked. Paste into text fields mostly worked because the browser's own
paste follows the event flags.
- **Ctrl+C ending a terminal (confirmed with util-linux su 2.42).** Before
the login completes the terminal is `su -l <user>`: Ctrl+C at the
password prompt kills su with SIGINT and the terminal ends ("The login did
not complete"). After login, su 2.42 runs the shell in its own pty, so
Ctrl+C reaches the shell and the session survives (checked with real su in
a user namespace). No client path closes a tab on Ctrl+C.
## Fixes
- `lib/core/keyboard/key_modifier_sync.dart`: on the web, a sync in front of
the framework's key data handler reads the browser event's own modifier
flags (`window.event`) and presses (synthesized) the modifiers the flags
hold that the framework does not, releasing them with the chord's key.
Outside Apple platforms a held/merged Meta is released for Ctrl+C/V/X/A/
Insert and pressed again afterwards. Installed by `PipelinesBinding`
(`lib/application/pipelines_binding.dart`) once the services binding has
set its key handler.
- Terminal (`chat_shell_terminal_view.dart`): Ctrl+C with a selection
copies and clears it, never ^C; without one it is ^C; an injected Ctrl+C
(no Ctrl key held: the desktop's copy key) only ever copies. Shift+Insert
pastes (`chat_shell_terminal_shortcuts.dart`).
- Copy never fails silently: `ClipboardReportingMessenger`
(`lib/application/clipboard_failures.dart`) reports a refused
`Clipboard.setData`/`getData` reply as a snackbar ("Could not copy: …").
- Server (`internal/server/terminal_login.go`, `terminal_process.go`):
before the login completes Ctrl+C and Ctrl+\ are sent as Ctrl+U (erase the
typed password) and Ctrl+Z is dropped, so su is not killed or stopped.
## Evidence
Widget tests: `test/core/keyboard/`, `test/features/chat/ui/transcript/
chat_injected_clipboard_keys_test.dart`, `test/features/chat/conversation/
chat_composer_injected_paste_test.dart`, `test/features/chat/shell/
chat_shell_terminal_clipboard_keys_test.dart`, `test/application/
clipboard_failures_test.dart`; Go `TestTerminalCtrlCAtLoginPromptKeepsTheTerminal`.
Browser (headless Chromium, `--semantics false`, clipboard read back with
`navigator.clipboard.readText()`), scripts in `tool/capture/examples/
clipboard-*.json`: before the fix the Super+C sequences (Meta down, `c` with
Ctrl flags and no Ctrl key, both with and without Meta in the flags) left
the clipboard unchanged in the chat and the terminal; after it they copy
"Answer 19" / the terminal selection, Super+C with nothing selected sends no
^C, Super+V pastes once into the terminal and the composer, physical Ctrl+C
without a selection still sends ^C, and a rejected `writeText` shows "Could
not copy: the browser refused access to the clipboard".
Not verified: the real Hyprland session (whether it reports Meta with the
chord is covered both ways); text fields when the browser reports Ctrl and
Meta together (the browser's native paste may not run then). With Flutter
semantics enabled, copying the transcript after typing in the composer did
not copy before or after this change (semantics off works); not addressed.