본문으로 건너뛰기
Y

dsh-voice-shortcut

yangjz98/dsh-voice-shortcut

Adds a configurable keyboard shortcut to the built-in DSH voice input button — Alt+V starts recording and a second press stops and transcribes; Esc closes an open voice row.

설치

dsh plugin --profile web add github:yangjz98/dsh-voice-shortcut

README

dsh-voice-shortcut

English | 简体中文

Keyboard shortcuts for the built-in voice input button in the DSH (DeepSeek Harness) desktop app.

Press Alt+V to start recording, press it again to stop and transcribe. The transcript is inserted at the cursor. The plugin does not record and does not transcribe; the only UI it adds is a shortcut card on the plugin's detail page (no status-bar badge).

This plugin only translates a key press into a click on the built-in microphone button. Recording and transcription are done entirely by DSH's bundled voice-input plugin, so the behaviour is exactly what you get by clicking with a mouse.

Shortcuts

KeyIdleRecordingTranscribingUnrecognized / failed
Alt+V (configurable)Click the microphone, start recordingClick Stop and transcribe, insert text at cursorDo nothing (avoids cancelling an in-flight result)Click Record again in the row, start the next take
EscNot intercepted, passed to the appClick ×, cancel recordingClick ×, cancel transcriptionClick ×, dismiss the row

Esc is only claimed while the voice row is actually open, so the existing Esc Esc stop-generation shortcut keeps working.

The listener is attached on window in the capture phase, so it also works while the composer has focus. It fires only when code matches the binding, all four modifiers match exactly, it is not inside an IME composition, and it is not an auto-repeat.

Configuring the shortcut

Plugin manager page → dsh-voice-shortcut detail → the Voice input shortcut card. Click Change shortcut and press the new combination; it applies immediately, no restart.

  • At least one of Ctrl, Alt, or Win (⌘ on macOS) is required, otherwise plain typing would trigger it.
  • AltGr combinations and common editor shortcuts (Ctrl+V, Ctrl+C, Ctrl+Z, …) are refused — otherwise pasting would start a recording.
  • The binding lives in browser localStorage under dsh-voice-shortcut:binding and only affects this machine. If storage is unavailable the binding still applies for the session and the card says so.
  • Reset to default clears storage and returns to Alt+V.

Why buttons are selected by aria-label

Once the voice row is expanded there are two round buttons with completely different jobs:

LabelWhen it existsOn click
Cancel (×)Always, inside [data-voice-activity]cancel(): aborts the recording, sends no transcription request, returns to idle
Stop and transcribe (■)Only while phase === "recording"finish(): stop → transcribe → insert the text into the draft

So "the second Alt+V just ended everything without transcribing" means the × was clicked. This plugin therefore:

  1. reads the phase from [data-voice-activity];
  2. while recording, looks only for a button labelled Stop and transcribe / 停止并识别; when the label is unknown (another UI language) it uses the row's last button (× is always first), and clicks nothing if the row has a single button — it never degrades to clicking ×;
  3. while transcribing / requesting, swallows the key but clicks nothing;
  4. in any other open phase (feedback), tries Record again, then Start recording, then falls back to an enabled button in the row that is neither the first (cancel) one nor a menu trigger;
  5. when the row is closed, clicks span[class*="triggerAnchor"] > button (labelled Start recording, or Set up voice input when the model is not ready — that opens the setup guide rather than silently doing nothing); with an unknown label it uses the first enabled button in the same anchor.

Each press dispatches the full pointerdown → mousedown → pointerup → mouseup → click sequence, because the button's onMouseDown calls preventDefault() and a bare click may not reach React's onClick.

Install

Requires DSH 0.2.2-rc.5 or a compatible release, with the bundled @deepseek-ai/dsh-experimental-voice-input-bundle enabled (the speech model must be ready before transcription works).

# 1) Register the package as a profile dependency (either way)
#    a. link a local checkout:
cd ~/.dsh/profiles/desktop
npm install link:/absolute/path/to/dsh-voice-shortcut
#    b. or install the tarball:
npm install /absolute/path/to/dsh-voice-shortcut-1.0.0.tgz
// 2) ~/.dsh/profiles/desktop/package.json
{
  "dsh": {
    "profile": {
      "bundles": [
        // ... other bundles
        "dsh-voice-shortcut"
      ]
    }
  }
}
# 3) ~/.dsh/profiles/desktop/cordis.patch.yml — append at the end
- insert:
    - id: voice-shortcut
      name: dsh-voice-shortcut
# 4) Restart DSH. A first install always needs a restart; afterwards
#    edits to client.js are picked up by HMR after a page refresh.

Three traps (all hit while building this)

  1. Listing the package in dsh.profile.bundles alone does not load it. dsh-client-modules only scans ctx.loader.entries(), so a local package must also be inserted as a loader row in the profile's cordis.patch.yml (step 3).
  2. exports must contain "./package.json": "./package.json". The client-package scanner locates the manifest through <package>/package.json; without the export it fails with ERR_PACKAGE_PATH_NOT_EXPORTED and the plugin never reaches window.__DSH_BOOT__.
  3. Do not set dsh.client.immediately. It skips the inject dependency resolution.

Diagnostics

Open DevTools with Ctrl+Shift+I:

  • window.__VOICE_SHORTCUT__ exists ({ loaded: true, phase: 'apply', binding, label, setBinding, classifyCapture, resetBinding }) → the plugin registered; label() is the binding currently in force.
  • Debug logging is off by default. To see key-press logs, run globalThis.__VOICE_SHORTCUT_DEBUG__ = true in the console and reload. Each press then logs one line such as [voice-shortcut] stop → phase=recording action=stop target=停止并识别 rowButtons=[取消 | 停止并识别], which tells you the phase, the button that was clicked, and every button present in the row.

The desktop GUI is behind a token gateway (a cookie-less request returns dsh web authentication required), so an external browser cannot open it — the console is only reachable inside the DSH window.

Development

node tests/client-harness.mjs client.js      # or: npm test

tests/client-harness.mjs builds a fake DOM, a fake __ModuleLoader__ and a fake React inside node:vm. It covers:

loader id and inject, no status-bar badge, the settings card registration and its static render, the capture-phase listener, clicking the microphone when idle, clicking stop (not cancel) while recording, doing nothing while transcribing, clicking Record again in the feedback phase, never clicking cancel when there is no retry button, structural fallbacks when the UI language is unknown (German), Esc clicking × in feedback and while recording, Esc being passed through when no row is open, still clicking the microphone when the model is not ready, ignoring Alt+Shift+V / Ctrl+Alt+V / IME composition / auto-repeat / other keys, re-resolving the button after a DOM remount, not consuming the key when no button exists, not clicking a disabled microphone, never falling back to cancel when the stop button is missing, custom-binding validation and persistence, the binding staying active when localStorage throws, the key-capture classifier (Esc / Tab / AltGr / Ctrl+V / bare modifier / bare letter / IME), and removing the listener on teardown.

Limitations

  • Works only while the DSH desktop window has focus. A truly global hotkey (active while another window has focus) requires a change in the desktop main process and is outside the reach of a web plugin.
  • The shortcut card uses the plugins.bundle.config slot, so it lives on the bundle detail page in the plugin manager. DSH 0.2.2 only renders the apps' own tabs under Settings → Plugins (there is no settings.plugin.item slot), so the card does not appear there.
  • Depends on the built-in voice-input DOM anchors and labels (span[class*="triggerAnchor"], [data-voice-activity], 开始录音 / 停止并识别 / 重新录音 / 取消). If upstream changes the anchors or the language, update the label table at the top of client.js; when a label cannot be recognized the structural fallbacks (last button / skip the first) still avoid clicking ×.

License

MIT

관련 플러그인