Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(speech): diagnosable smart-whisper load failures (press-to-talk Task 3)
enes48f56884c647
diff --git a/src/core/speech/speech-service.test.ts b/src/core/speech/speech-service.test.tsindex b6df3b76c..9300a530c 100644--- a/src/core/speech/speech-service.test.ts+++ b/src/core/speech/speech-service.test.ts@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'import { mkdtempSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'-import { SpeechService, type WhisperEngineHandle } from './speech-service'+import { describeWhisperLoadError, SpeechService, type WhisperEngineHandle } from './speech-service'import { WhisperModelStore } from './whisper-models'describe('SpeechService', () => {@@ -70,3 +70,36 @@ describe('SpeechService', () => {.rejects.toThrow('No speech detected.')})})++describe('describeWhisperLoadError', () => {+ it('recognizes MODULE_NOT_FOUND code', () => {+ const err = new Error('Cannot find module') as any+ err.code = 'MODULE_NOT_FOUND'+ expect(describeWhisperLoadError(err)).toBe('the smart-whisper module is not installed — run npm install')+ })++ it('recognizes ERR_MODULE_NOT_FOUND code', () => {+ const err = new Error('Module not found') as any+ err.code = 'ERR_MODULE_NOT_FOUND'+ expect(describeWhisperLoadError(err)).toBe('the smart-whisper module is not installed — run npm install')+ })++ it('recognizes NODE_MODULE_VERSION mismatch in message', () => {+ const err = new Error('The module was compiled against a different Node.js version')+ expect(describeWhisperLoadError(err)).toBe(+ 'the native module was built for a different runtime — run npm run rebuild'+ )+ })++ it('recognizes NODE_MODULE_VERSION 115 in message', () => {+ const err = new Error('NODE_MODULE_VERSION 115')+ expect(describeWhisperLoadError(err)).toBe(+ 'the native module was built for a different runtime — run npm run rebuild'+ )+ })++ it('returns the error message itself as fallback', () => {+ const err = new Error('boom')+ expect(describeWhisperLoadError(err)).toBe('boom')+ })+})diff --git a/src/core/speech/speech-service.ts b/src/core/speech/speech-service.tsindex b3dcb77ec..b10f31e2e 100644--- a/src/core/speech/speech-service.ts+++ b/src/core/speech/speech-service.ts@@ -6,6 +6,17 @@ export interface WhisperEngineHandle {free(): Promise<void>}+/** User-facing cause for a failed smart-whisper import. Pure — tested. */+export function describeWhisperLoadError(err: unknown): string {+ const code = (err as { code?: string })?.code+ const msg = err instanceof Error ? err.message : String(err)+ if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND')+ return 'the smart-whisper module is not installed — run npm install'+ if (/NODE_MODULE_VERSION|was compiled against a different Node\.js version/.test(msg))+ return 'the native module was built for a different runtime — run npm run rebuild'+ return msg+}+/** Local dictation via whisper.cpp (smart-whisper). One loaded model at a* time (they are hundreds of MB of RAM); same-model loads dedupe onto one* in-flight promise; transcriptions run FIFO on a promise chain. The Pro@@ -67,9 +78,10 @@ async function defaultEngineFactory(modelPath: string): Promise<WhisperEngineHantry {// @ts-ignore -- optional native dep: absent until installed, and @ts-ignore stays valid either way (an expect-error would break the build the moment it resolves)mod = await import('smart-whisper')- } catch {+ } catch (err) {+ console.error('[speech] smart-whisper failed to load:', err)throw new Error(- 'Local whisper is unavailable on this install (native module failed to load). Try the Cloud engine.',+ `Local whisper is unavailable (${describeWhisperLoadError(err)}). Try the Cloud engine.`,)}const whisper = new mod.Whisper(modelPath, { gpu: true })