Skip to content

feat: keyboard-first translation window (⌘1/⌘2/⌘3, ⌘R) - #32

Merged
iuhoay merged 1 commit into
mainfrom
feat/keyboard-mode-shortcuts
Jun 14, 2026
Merged

feat: keyboard-first translation window (⌘1/⌘2/⌘3, ⌘R)#32
iuhoay merged 1 commit into
mainfrom
feat/keyboard-mode-shortcuts

Conversation

@iuhoay

@iuhoay iuhoay commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Closes #22.

Rounds out the floating translation window's keyboard story so the mouse is optional. The window already had ⌘↵ (run), Esc (close), and ⇥ (paste-and-translate); this adds mode switching and regenerate, and fixes a couple of labels that the new shortcuts exposed.

Changes

  • ⌘1 / ⌘2 / ⌘3 — switch to Translate / Polish / Summary via setMode(_:). Wired through hidden buttons (a segmented Picker can't host per-segment .keyboardShortcut); they stay in the view tree so the shortcuts fire even while the input field holds focus.
  • ⌘R — regenerate the current mode, gated by the same disabled rule as the action button (inert on empty input or mid-stream).
  • Segment hints — each mode segment now shows its shortcut: Translate ⌘1 | Polish ⌘2 | Summary ⌘3, since the picker can't carry a per-segment tooltip.
  • Action button "Translate" → "Run" — the button runs the selected mode, so a fixed "Translate" was wrong in Polish/Summary. "Run" is correct in every mode (and pairs with ⌘R). Tooltip and zh-Hans localization updated.
  • "Summarize" → "Summary" — shortens the segment so the wider (now hinted) picker still fits the window's 440pt minimum, and matches the result label, which already read "Summary".

Verification

Built (Debug) and driven in the running Dev app:

  • Toolbar fits at the 440pt minimum with the close button fully visible (not clipped under the rounded-glass mask).
  • ⌘2 selects Polish; ⌘R re-runs the current mode.
  • Action button reads "Run" in Polish mode.

No automated tests in this repo. The var id reformat in TranslationMode.swift is the project's swift-format hook.

🤖 Generated with Claude Code

Round out the window's keyboard story so the mouse is optional:

- ⌘1 / ⌘2 / ⌘3 switch to Translate / Polish / Summary via setMode, with
  hidden shortcut buttons (a segmented Picker can't host per-segment
  shortcuts) that fire even while the input field holds focus.
- ⌘R regenerates the current mode, gated by the same disabled rule as the
  action button.
- Each mode segment shows its ⌘-number hint, since the picker can't carry a
  per-segment tooltip.
- The action button is now mode-agnostic "Run" instead of always
  "Translate", which was wrong in Polish and Summary modes.
- Rename the "Summarize" mode to the shorter "Summary" so the wider picker
  still fits the window's 440pt minimum width; this also matches the result
  label, which already read "Summary".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iuhoay
iuhoay merged commit 4682608 into main Jun 14, 2026
1 check passed
@iuhoay
iuhoay deleted the feat/keyboard-mode-shortcuts branch June 14, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard-first result window (⌘1/⌘2/⌘3 mode switch, ⌘R regenerate)

1 participant