ac5f28bb83
Allow Ctrl+K and Alt+K to switch to Chat from any destination, while preserving terminal Ctrl+K behavior and focusing the active composer. Register the shortcuts in help and cover matching, navigation, terminal handling, and composer focus with regression tests.
33 lines
3.2 KiB
Markdown
33 lines
3.2 KiB
Markdown
# Ctrl+K / Alt+K open Chat
|
|
|
|
Run 391 (ctrl-k-and-alt-k-open-chat), stage 01-implement. Not committed.
|
|
|
|
## Behaviour
|
|
- Ctrl+K, or Alt+K (Option+K on Apple platforms, matched by physical key so the dead-key symbol still counts), switches the shell to the Chat destination from any destination, then calls `AdaptiveShell.onOpenChat`.
|
|
- The app passes `_focusOpenChatComposer`, which requests the composer of the last workspace chat (`_chatWorkspaceRoute`) through `ChatRuntime.composerFocus`.
|
|
- Ctrl+K is left to the terminal while the terminal has the keyboard (`primaryFocusIsTypingSurface`). Alt+K still switches there.
|
|
- Shift, Meta, or Ctrl+Alt together do not match. Repeats are swallowed; only the first key-down acts.
|
|
- The help page has an "Open Chat" entry: `Option+K, Ctrl+K` on macOS, `Alt+K, Ctrl+K` elsewhere.
|
|
|
|
## Changed paths
|
|
- `app/lib/shell/shell_chat_shortcut.dart` (new): `shellChatShortcut`, `shellChatShortcutLabels`.
|
|
- `app/lib/shell/adaptive_shell.dart`: key handling, `_openChat`, `onOpenChat` parameter.
|
|
- `app/lib/application/pipelines_app.dart`: `_focusOpenChatComposer`, wired as `onOpenChat`.
|
|
- `app/lib/features/settings/keyboard_shortcuts_registry.dart`: "Open Chat" entry.
|
|
- `app/test/shell/shell_chat_shortcut_test.dart` (new): matcher, switch from another destination, controlled shell callback, terminal exception.
|
|
- `app/test/application/chat_open_shortcut_test.dart` (new): the full `PipelinesApp` opens `/chat/s1`, moves to Runs, then Alt+K and Ctrl+K each return to `/chat/s1` and put the keyboard in the `s1` composer (primary focus).
|
|
- `app/test/features/settings/keyboard_shortcuts_help_test.dart`: "Open Chat" help entry test.
|
|
|
|
## Focused results
|
|
- Review follow-up (composer focus), `tool/memwatch/full.sh 'test/application/chat_open_shortcut_test.dart test/shell/shell_chat_shortcut_test.dart test/features/settings/keyboard_shortcuts_help_test.dart'`: PASS, 12 passed, 0 failed, peak 1306 MB, 5s, exit 0. Run after `dart format` on the new test.
|
|
- Mutation check: with the `_focusOpenChatComposer` request removed from `pipelines_app.dart`, `chat_open_shortcut_test.dart` fails on the composer focus expectation. The source was restored afterwards; `git diff` shows the original wiring.
|
|
- Earlier stage run (not repeated here): `test/shell/destination_shortcuts_test.dart`, `test/shell/search_shortcuts_test.dart`, `test/features/chat/workspace/chat_float_shortcut_test.dart` passed with the shell test and help test (21 passed, 0 failed, peak 1062 MB).
|
|
- `tool/analyze.sh`: clean.
|
|
- Tests that press K chords: none outside the new files. The new shell check returns false for every other key, so the earlier typing-surface and search paths keep their order.
|
|
|
|
## Not covered
|
|
- The composer-focus test drives the real app with a fake channel; it does not cover a chat opened only through a route with no history yet.
|
|
- No UI capture or device run (ui-review owns that).
|
|
- Ctrl+Y: the float chord is not left to the terminal. `chatFloatShortcut` matches Ctrl+Y on every platform, and `chat_floating_pane_test.dart` covers Ctrl+Y from the terminal on macOS. Ctrl+K was made the only terminal exception, as the task asked.
|
|
- On web, the browser may keep Ctrl+K (address/search focus); the help caveat says so.
|