feat: keybar function captions + Ctrl+R/L/D, plus ⌨ shortcut cheat-sheet

keybar:
- add Ctrl+R (搜历史/\x12), Ctrl+L (重绘/\x0c), Ctrl+D (退出/\x04)
- each key now shows a short function caption under the glyph (self-documenting
  on touch where tooltips don't appear); 17 keys total
- test/keybar.test.ts updated to 17 keys

cheat-sheet (new public/shortcuts.ts):
- ⌨ toolbar button opens a grouped reference of common Claude Code shortcuts
  (general / editing / multiline / macOS / prefixes), each labeled with what it
  does; keys also on the bottom bar are tagged 键栏
- Esc / click-outside to close; styled card with sticky header + accent tags

216 tests green; tsc + build clean.
This commit is contained in:
Yaojia Wang
2026-06-19 09:41:58 +02:00
parent 524f2073a0
commit cc3e7b8450
5 changed files with 265 additions and 29 deletions

View File

@@ -80,12 +80,15 @@ describe('keybar', () => {
it('Claude Code control keys map to the right bytes', () => {
expect(KEY_MAP.escEsc).toBe('\x1b\x1b') // rewind / clear draft
expect(KEY_MAP.ctrlR).toBe('\x12') // reverse history search
expect(KEY_MAP.ctrlO).toBe('\x0f') // expand transcript
expect(KEY_MAP.ctrlL).toBe('\x0c') // redraw screen
expect(KEY_MAP.ctrlT).toBe('\x14') // task list
expect(KEY_MAP.ctrlB).toBe('\x02') // background
expect(KEY_MAP.ctrlD).toBe('\x04') // exit (EOF)
})
it('all 14 keys are defined', () => {
it('all 17 keys are defined', () => {
const keys = Object.keys(KEY_MAP)
expect(keys).toEqual([
'esc',
@@ -97,9 +100,12 @@ describe('keybar', () => {
'arrowRight',
'enter',
'ctrlC',
'ctrlR',
'ctrlO',
'ctrlL',
'ctrlT',
'ctrlB',
'ctrlD',
'tab',
'slash',
])
@@ -107,8 +113,8 @@ describe('keybar', () => {
it('all mapped bytes are unique strings', () => {
const bytes = Object.values(KEY_MAP)
expect(bytes).toHaveLength(14)
expect(new Set(bytes).size).toBe(14) // all unique
expect(bytes).toHaveLength(17)
expect(new Set(bytes).size).toBe(17) // all unique
})
it('ANSI arrow sequences use correct format', () => {