GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(tui): move voice capture to Ctrl+Space (#968) · Twigpine/zero@eeea330

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • internal/tui
    • commands.go
    • dictation.go
    • dictation_voice.go
    • dictation_voice_test.go
    • model.go
    • stt_key_prompt.go
    • stt_model_picker.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎internal/tui/commands.go‎

Copy file name to clipboardExpand all lines: internal/tui/commands.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var commandDefinitions = []commandDefinition{
109109
name: "/voice",
110110
usage: "/voice",
111111
group: commandGroupRuntime,
112-
description: "Toggle voice mode (hold Space to dictate).",
112+
description: "Toggle voice mode (" + voiceCaptureUsage + ").",
113113
kind: commandVoice,
114114
},
115115
{
Collapse file

‎internal/tui/dictation.go‎

Copy file name to clipboardExpand all lines: internal/tui/dictation.go
+9-14Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type dictationController struct {
8888
waveBars []int
8989
waveTick int
9090

91-
// voiceModeEnabled repurposes Space into hold-to-record (§13.9).
91+
// voiceModeEnabled repurposes Ctrl+Space into hold-to-record (§13.9).
9292
voiceModeEnabled bool
9393
// eventTypesSupported records whether the terminal confirmed key-release
9494
// reporting (Kitty protocol); eventTypesKnown gates it until the terminal has
@@ -173,7 +173,7 @@ func firstNonEmptyStr(a, b string) string {
173173
func (d dictationController) active() bool { return d.phase != dictIdle }
174174

175175
// toggleDictation starts a recording when idle and stops-and-transcribes when
176-
// recording. Invoked by the voice-mode Space gesture; a call during
176+
// recording. Invoked by the voice-mode Ctrl+Space gesture; a call during
177177
// startup/transcription is ignored (the machine is mid-transition).
178178
func (m model) toggleDictation() (model, tea.Cmd) {
179179
if !m.dictation.available() {
@@ -193,15 +193,15 @@ func (m model) toggleDictation() (model, tea.Cmd) {
193193
}
194194
}
195195

196-
// toggleVoiceMode flips the /voice hold-to-record gesture — the dictation
197-
// trigger. While on, Space records; run /voice again to type spaces normally.
196+
// toggleVoiceMode flips the /voice hold-to-record gesture. While on,
197+
// Ctrl+Space records and ordinary Space continues to type normally.
198198
func (m model) toggleVoiceMode() (model, tea.Cmd) {
199199
if !m.dictation.available() {
200200
return m.appendSystemNotice("Dictation is not configured. See docs/dictation.md to set up a local engine or a Groq/OpenAI key."), nil
201201
}
202202
m.dictation.voiceModeEnabled = !m.dictation.voiceModeEnabled
203203
if m.dictation.voiceModeEnabled {
204-
return m.showTransientNoticeInline("Voice mode on — hold Space to dictate; run /voice again to turn it off.", transientNoticeSuccess), nil
204+
return m.showTransientNoticeInline("Voice mode on — "+voiceCaptureUsage+". Run /voice again to turn it off.", transientNoticeSuccess), nil
205205
}
206206
// Turning voice off is the "done dictating" signal, so release the warm sherpa
207207
// streaming server — otherwise a loaded model keeps idling in RAM (and holding
@@ -374,7 +374,7 @@ func (m model) handleDictationStarted(msg dictationStartedMsg) (model, tea.Cmd)
374374
if m.dictation.phase == dictStarting {
375375
m.dictation.phase = dictRecording
376376
}
377-
// A voice-mode Space release that arrived mid-startup asked us to stop as soon
377+
// A voice-mode Ctrl+Space release that arrived mid-startup asked us to stop as soon
378378
// as recording began.
379379
if m.dictation.voiceStopPending && m.dictation.phase == dictRecording {
380380
m.dictation.voiceStopPending = false
@@ -480,12 +480,8 @@ func needsLeadingSpace(state composerState) bool {
480480
func (m model) dictationStatusChip() string {
481481
switch m.dictation.phase {
482482
case dictStarting, dictRecording:
483-
stop := "release Space to stop"
484-
if !m.dictation.eventTypesSupported {
485-
stop = "press Space to stop" // press-to-toggle fallback
486-
}
487483
wave := zeroTheme.amber.Render("● " + renderWaveBars(m.dictation.waveBars) + " REC")
488-
return wave + zeroTheme.muted.Render(" · "+stop+", Esc to cancel")
484+
return wave + zeroTheme.muted.Render(" · "+m.voiceCaptureStatus()+", Esc to cancel")
489485
case dictTranscribing:
490486
return zeroTheme.accent.Render("●") + " " + zeroTheme.muted.Render("transcribing…")
491487
}
@@ -601,13 +597,12 @@ func (m model) handleRecTick() (model, tea.Cmd) {
601597
return m, nil
602598
}
603599

604-
// voiceModeIndicator renders the persistent "voice mode on" hint shown while
605-
// idle so the user knows Space is repurposed to hold-to-record (§10).
600+
// voiceModeIndicator renders the current voice gesture or transcription state.
606601
func (m model) voiceModeIndicator() string {
607602
if !m.dictation.voiceModeEnabled {
608603
return ""
609604
}
610-
return zeroTheme.accent.Render("🎙 voice") + zeroTheme.muted.Render(" · "+m.dictation.currentModelLabel())
605+
return zeroTheme.accent.Render("🎙 voice") + zeroTheme.muted.Render(" · "+m.voiceCaptureStatus()+" · "+m.dictation.currentModelLabel())
611606
}
612607

613608
// dictationErrorText renders a dictation error for the transcript: a missing-
Collapse file

‎internal/tui/dictation_voice.go‎

Copy file name to clipboardExpand all lines: internal/tui/dictation_voice.go
+41-10Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import (
44
tea "charm.land/bubbletea/v2"
55
)
66

7-
// Voice mode's Space-hold gesture — the (only) dictation trigger. Two terminal
7+
const voiceCaptureUsage = "hold Ctrl+Space to record; press it to toggle where key releases are unavailable"
8+
9+
// Voice mode's Ctrl+Space gesture — the (only) dictation trigger. Two terminal
810
// tiers:
911
//
1012
// 1. The terminal confirms key-release reporting (Ghostty/Kitty/WezTerm, …):
11-
// Space press starts recording, Space release stops it — true hold-to-record,
12-
// no ambiguity.
13-
// 2. The terminal does not confirm release events: Space falls back to
13+
// Ctrl+Space press starts recording and release stops it — true
14+
// hold-to-record, with ordinary Space left available for typing.
15+
// 2. The terminal does not confirm release events: Ctrl+Space falls back to
1416
// press-to-toggle (press to start, press again to stop) — a deliberately
1517
// simpler, robust fallback than inferring release from key-repeat timing
16-
// (racy in a terminal). This works on ANY terminal, so voice mode is always
17-
// usable once enabled.
18+
// (racy in a terminal). Legacy NUL input is decoded as Ctrl+Space by the
19+
// terminal input layer, so the same matcher covers both tiers.
1820
//
1921
// Only active while voice mode is on; the rest of dispatch is built on
2022
// KeyPressMsg and is untouched.
@@ -27,8 +29,37 @@ func (m model) handleKeyboardEnhancements(msg tea.KeyboardEnhancementsMsg) model
2729
return m
2830
}
2931

30-
// handleVoiceSpacePress handles a Space press while voice mode is on.
31-
func (m model) handleVoiceSpacePress(msg tea.KeyMsg) (model, tea.Cmd) {
32+
func voiceCaptureKey(msg tea.KeyMsg) bool {
33+
mod := msg.Key().Mod &^ (tea.ModCapsLock | tea.ModNumLock)
34+
return keyIs(msg, tea.KeySpace) && mod == tea.ModCtrl
35+
}
36+
37+
// voiceCaptureReleaseKey matches either half of the held Ctrl+Space chord. A
38+
// terminal may report Ctrl releasing first, or report the later Space release
39+
// without ModCtrl because Ctrl is no longer down.
40+
func voiceCaptureReleaseKey(msg tea.KeyMsg) bool {
41+
return keyIs(msg, tea.KeySpace) || keyIs(msg, tea.KeyLeftCtrl) || keyIs(msg, tea.KeyRightCtrl)
42+
}
43+
44+
func (m model) voiceCaptureStatus() string {
45+
switch m.dictation.phase {
46+
case dictStarting, dictRecording:
47+
if m.dictation.eventTypesSupported {
48+
return "release Ctrl+Space to stop"
49+
}
50+
return "press Ctrl+Space to stop"
51+
case dictTranscribing:
52+
return "transcribing…"
53+
default:
54+
if m.dictation.eventTypesSupported {
55+
return "hold Ctrl+Space to record"
56+
}
57+
return "press Ctrl+Space to record"
58+
}
59+
}
60+
61+
// handleVoiceCapturePress handles Ctrl+Space while voice mode is on.
62+
func (m model) handleVoiceCapturePress(msg tea.KeyMsg) (model, tea.Cmd) {
3263
if !m.dictation.eventTypesSupported {
3364
// Tier 2: no release events — press-to-toggle.
3465
return m.toggleDictation()
@@ -45,8 +76,8 @@ func (m model) handleVoiceSpacePress(msg tea.KeyMsg) (model, tea.Cmd) {
4576
return m, nil // already recording; the release will stop it
4677
}
4778

48-
// handleVoiceSpaceRelease stops a hold-to-record session when Space is released.
49-
func (m model) handleVoiceSpaceRelease() (model, tea.Cmd) {
79+
// handleVoiceCaptureRelease stops a hold-to-record session when Ctrl+Space is released.
80+
func (m model) handleVoiceCaptureRelease() (model, tea.Cmd) {
5081
if !m.dictation.spaceHeld {
5182
return m, nil
5283
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.