dsh-live-voice 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/asr/asr.worker.js +1 -1
  2. package/lib/asr/manifest.json +1 -1
  3. package/lib/client.js +6002 -5389
  4. package/lib/server.js +16 -2
  5. package/lib/vad/manifest.json +2 -2
  6. package/lib/vad/vad.worker.js +1 -1
  7. package/package.json +1 -1
  8. package/src/app/client/apply.tsx +67 -3
  9. package/src/app/client/i18n/catalogs/base.ts +24 -0
  10. package/src/app/client/i18n/catalogs/en.ts +32 -0
  11. package/src/app/client/i18n/catalogs/es.ts +32 -0
  12. package/src/app/client/i18n/catalogs/fr.ts +32 -0
  13. package/src/app/client/i18n/catalogs/hi.ts +31 -0
  14. package/src/app/client/i18n/catalogs/pt-BR.ts +32 -0
  15. package/src/app/client/i18n/catalogs/zh.ts +28 -0
  16. package/src/modules/conversation/ARCHITECTURE.md +2 -0
  17. package/src/modules/conversation/components/ConversationStatusBar.tsx +5 -1
  18. package/src/modules/conversation/components/DiagnosticsButton.tsx +46 -0
  19. package/src/modules/conversation/components/InactivityNotice.tsx +20 -0
  20. package/src/modules/conversation/components/MutedSpeechNotice.tsx +23 -0
  21. package/src/modules/conversation/models/inactivity.ts +93 -0
  22. package/src/modules/conversation/models/meeting.ts +12 -2
  23. package/src/modules/conversation/models/meetingTranscript.ts +12 -20
  24. package/src/modules/core/ARCHITECTURE.md +4 -0
  25. package/src/modules/core/coordinator.ts +22 -1
  26. package/src/modules/core/developerExtension.ts +2 -0
  27. package/src/modules/core/mutedSpeechWarning.ts +62 -0
  28. package/src/modules/core/settings.ts +18 -0
  29. package/src/modules/core/timestamp.ts +35 -0
  30. package/src/modules/recording/ARCHITECTURE.md +2 -0
  31. package/src/modules/recording/RecordingRecognition.ts +10 -0
  32. package/src/modules/recording/types.ts +1 -0
  33. package/src/modules/settings/ARCHITECTURE.md +4 -0
  34. package/src/modules/settings/models/localIdentity.ts +35 -0
  35. package/src/modules/settings/models/settingsStorage.ts +24 -2
  36. package/src/modules/settings/sections/conversation/ConversationSettingsSection.tsx +4 -0
  37. package/src/modules/settings/sections/conversation/InactivitySettings.tsx +46 -0
  38. package/src/modules/settings/sections/conversation/MeetingSourceSettings.tsx +0 -13
  39. package/src/modules/settings/sections/conversation/TimestampSettings.tsx +44 -0
  40. package/src/styles/index.ts +5 -1
@@ -97,6 +97,7 @@ const zh: LiveVoiceTranslation = {
97
97
  'dsh-live-voice.debugger.label': '诊断',
98
98
  'dsh-live-voice.debugger.local':
99
99
  '已存在本地、Git 或自定义调试器依赖。请使用原安装方式管理;此处不会替换。',
100
+ 'dsh-live-voice.debugger.popupBlocked': '无法打开诊断。请允许此站点弹出窗口后重试。',
100
101
  'dsh-live-voice.debugger.ready': '诊断已就绪。请关闭此对话框,然后点击“诊断”打开调试器。',
101
102
  'dsh-live-voice.debugger.restart':
102
103
  '调试器 {version} 已安装。DSH 管理器要求重启。请在准备好后重启 DSH,再重新加载此页面。不会自动重启。',
@@ -333,6 +334,10 @@ const zh: LiveVoiceTranslation = {
333
334
  '字词数不足的最终转写片段会被忽略,不会进入消息输入框或自动发送流程。',
334
335
  'dsh-live-voice.recognition.minimumWords.label': '每个最终片段的最少字词数',
335
336
  'dsh-live-voice.recognition.mode.label': '聆听模式',
337
+ 'dsh-live-voice.recognition.mutedWarning.body':
338
+ '此输入处于忽略模式。您的话语不会被添加到消息中。',
339
+ 'dsh-live-voice.recognition.mutedWarning.origin': 'DSH Live Voice · 警告',
340
+ 'dsh-live-voice.recognition.mutedWarning.title': '您正在静音状态下说话',
336
341
  'dsh-live-voice.recognition.planned.parakeet': 'NVIDIA Parakeet — 即将推出',
337
342
  'dsh-live-voice.recognition.planned.sherpa': 'sherpa-onnx 流式识别 — 即将推出',
338
343
  'dsh-live-voice.recognition.planned.vote': '即将推出 — 请在仓库议题中投票',
@@ -437,6 +442,19 @@ const zh: LiveVoiceTranslation = {
437
442
  '音频(包括静音和背景声音)使用有损压缩保存在此浏览器配置文件和站点的本地存储中。录制他人前请先征得同意。关闭此选项不会删除已保存的录音。',
438
443
  'dsh-live-voice.recording.status.saved': '音频已保存至 {time}',
439
444
  'dsh-live-voice.recording.title': '可恢复录音',
445
+ 'dsh-live-voice.settings.autoEnd.continue': '继续聆听',
446
+ 'dsh-live-voice.settings.autoEnd.countdown': '若无转写,语音采集将在 {seconds} 秒后结束。',
447
+ 'dsh-live-voice.settings.autoEnd.enabled': '自动结束语音采集',
448
+ 'dsh-live-voice.settings.autoEnd.ended': '语音会话因无活动而结束。',
449
+ 'dsh-live-voice.settings.autoEnd.help':
450
+ '未识别到文字时结束所有输入源。新文字或“继续聆听”会重置计时。时间以分钟计;提前提醒时间必须大于零,且不超过总时间的 50%。不会自动静音。识别任务卡住时,结束最多延后 30 秒。',
451
+ 'dsh-live-voice.settings.autoEnd.minutes': '无活动后结束(分钟)',
452
+ 'dsh-live-voice.settings.autoEnd.restart': '重新开始',
453
+ 'dsh-live-voice.settings.autoEnd.stopFailed': '部分语音资源未能停止。请检查输入控件。',
454
+ 'dsh-live-voice.settings.autoEnd.title': '自动结束',
455
+ 'dsh-live-voice.settings.autoEnd.warning':
456
+ '未检测到转写。语音采集将在 {seconds} 秒后结束。请说话或选择“继续聆听”以保持采集。',
457
+ 'dsh-live-voice.settings.autoEnd.warningMinutes': '提前提醒(分钟)',
440
458
  'dsh-live-voice.settings.autoSend.cancel': '取消自动发送',
441
459
  'dsh-live-voice.settings.autoSend.countdown': '{remaining} 后发送',
442
460
  'dsh-live-voice.settings.autoSend.delay': '静音后发送',
@@ -484,6 +502,16 @@ const zh: LiveVoiceTranslation = {
484
502
  'dsh-live-voice.settings.tabs.conversation': '对话',
485
503
  'dsh-live-voice.settings.tabs.recognition': '语音识别',
486
504
  'dsh-live-voice.settings.tabs.speak': '语音合成',
505
+ 'dsh-live-voice.settings.timestamp.alwaysName': '即使只有一个输入,也始终显示来源名称',
506
+ 'dsh-live-voice.settings.timestamp.day': '日',
507
+ 'dsh-live-voice.settings.timestamp.help':
508
+ '自定义日期、秒和标点;小时和分钟始终显示。仅影响新文本块。名称及强制显示名称的选择仅保存在此浏览器,不保存在 DSH 主机。不会导入主机旧名称。使用开始说话时的本地时间。',
509
+ 'dsh-live-voice.settings.timestamp.month': '月',
510
+ 'dsh-live-voice.settings.timestamp.preview': '格式预览',
511
+ 'dsh-live-voice.settings.timestamp.punctuation': '标点',
512
+ 'dsh-live-voice.settings.timestamp.seconds': '秒',
513
+ 'dsh-live-voice.settings.timestamp.title': '时间戳和本地名称',
514
+ 'dsh-live-voice.settings.timestamp.year': '年',
487
515
  'dsh-live-voice.settings.title': '实时语音 设置',
488
516
  'dsh-live-voice.settings.whisper.hostHelp':
489
517
  '主机级设置。仅允许无需身份验证的回环 HTTP URL(localhost、127.0.0.1、[::1])。回环地址指 DSH 主机,而非此浏览器。所有健康检查和音频请求都通过需要身份验证的后端执行。',
@@ -1,5 +1,7 @@
1
1
  # Conversation module
2
2
 
3
+ `models/inactivity.ts` owns the pure application-wide inactivity state machine; `app/client/apply.tsx` aggregates source activity and recognized text, executes existing End/disconnect cleanup, attempts non-disruptive warning playback and disposes its timer. `InactivityNotice` exposes the visual countdown, explicit continuation and ended reason/restart; Conversation settings normalize both minute values with a positive warning lead time at most half the total. Never attach independent auto-end timers to individual sources.
4
+
3
5
  Transcription status separates detected speech (`recognizing`) from unsettled speech requests (`pendingTranscriptionRequests`, with legacy fallback to `pendingTranscriptions`). Aggregate `pendingTranscriptions` also includes storage/final-drain work for safety barriers; it must not be mistaken for visible transcription activity. `pendingDeliveryTranscriptions` isolates speech-boundary bookkeeping and queued/active speech work from silent recording writes, so automatic-send countdowns in either source cannot starve on periodic persistence. Cross-source delivery gates use the same distinction; missing fields retain conservative legacy blocking. Statuses are listening, listening and transcribing, waiting without speech, transcribing queued work without speech, and waiting for a command in Ignore mode. Playback remains separate; question and delivery countdown states retain their policy. Status copy has no ellipses. The compact recording indicator precedes the waveform and shows the committed audio frontier as seconds/minutes/unbounded hours, never wall-clock elapsed time; its saved-audio explanation is available only in the localized accessible name/tooltip.
4
6
 
5
7
  Final recognition chunks join with a space. A confirmed paragraph boundary adds exactly two newlines; source changes also start a new block. Timestamp/source prefixes appear only at the first block, source change or paragraph. Recognition completion time and normal source activity/settings updates do not create timestamp boundaries. Composer text is append-only; user edits remain untouched.
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
+ import { DiagnosticsButton } from './DiagnosticsButton.js';
3
+ import { MutedSpeechNotice } from './MutedSpeechNotice.js';
2
4
  import { RecoveryFeedback } from './RecoveryFeedback.js';
3
5
  import { useLanguage } from '../../../app/client/i18n/index.js';
4
6
  import { ErrorMessage, IconButton, ToggleButton } from '../../../shared/design-system/index.js';
@@ -70,6 +72,7 @@ export function ConversationStatusBar({
70
72
  }
71
73
  style={overlay ? overlayStyle : undefined}
72
74
  >
75
+ {state.mutedSpeechWarning && <MutedSpeechNotice source={sourceLabel} />}
73
76
  {includeSpeech && <SpeechStatusBar controller={controller} />}
74
77
  {(state.conversation || capture || state.error || error) && (
75
78
  <RecognitionBar
@@ -79,6 +82,7 @@ export function ConversationStatusBar({
79
82
  status={status}
80
83
  leading={
81
84
  <>
85
+ <DiagnosticsButton controller={controller} />
82
86
  {state.conversation && !capture ? (
83
87
  <IconButton
84
88
  label={(recognition as any).microphone.takeControl()}
@@ -99,7 +103,7 @@ export function ConversationStatusBar({
99
103
  ? (commons as any).input.ignoring()
100
104
  : (commons as any).input.listening(),
101
105
  })}
102
- icon={sourceIcon}
106
+ icon={state.muted ? (sourceIcon === 'mic' ? 'micOff' : 'meetingOff') : sourceIcon}
103
107
  visibleLabel={
104
108
  state.muted
105
109
  ? (commons as any).input.ignoringBadge()
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { IconButton } from '../../../shared/design-system/index.js';
3
+ import { useLanguage } from '../../../app/client/i18n/index.js';
4
+ import {
5
+ readDeveloperExtension,
6
+ subscribeDeveloperExtension,
7
+ } from '../../core/developerExtension.js';
8
+ export function DiagnosticsButton({ controller }: { controller: any }) {
9
+ const extension = React.useSyncExternalStore(
10
+ subscribeDeveloperExtension,
11
+ readDeveloperExtension,
12
+ () => null,
13
+ );
14
+ const { scoped } = useLanguage((ctx) => ctx.debugger);
15
+ const copy = scoped as any;
16
+ const [failed, setFailed] = React.useState(false);
17
+ React.useEffect(() => setFailed(false), [extension]);
18
+ if (!extension?.open) return null;
19
+ return (
20
+ <span className="dlv-bar-diagnostics">
21
+ <IconButton
22
+ icon="bug"
23
+ className="dlv-pill-button dlv-diagnostics-shortcut"
24
+ label={copy.label()}
25
+ onClick={() => {
26
+ try {
27
+ setFailed(
28
+ extension.open!({
29
+ recordingId:
30
+ controller.recordingId?.() ??
31
+ controller.recognition?.session?.writer?.session?.id,
32
+ }) === false,
33
+ );
34
+ } catch {
35
+ setFailed(true);
36
+ }
37
+ }}
38
+ />
39
+ {failed && (
40
+ <span className="dlv-diagnostics-shortcut-error" role="alert">
41
+ {copy.popupBlocked()}
42
+ </span>
43
+ )}
44
+ </span>
45
+ );
46
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { useLanguage } from '../../../app/client/i18n/index.js';
3
+ import type { VoiceInactivity } from '../models/inactivity.js';
4
+ export function InactivityNotice({ clock, restart }: { clock: VoiceInactivity; restart(): void }) {
5
+ const state = React.useSyncExternalStore(clock.subscribe, clock.getSnapshot);
6
+ const { scoped } = useLanguage((ctx) => ctx.settings);
7
+ const copy = (scoped as any).autoEnd;
8
+ if (state.phase === 'idle') return null;
9
+ const ended = state.phase === 'ended';
10
+ return (
11
+ <div className="dlv-inactivity-notice">
12
+ <span role="status">
13
+ {ended ? copy.ended() : copy.countdown({ seconds: state.remaining })}
14
+ </span>
15
+ <button type="button" onClick={ended ? restart : clock.keepAlive}>
16
+ {ended ? copy.restart() : copy.continue()}
17
+ </button>
18
+ </div>
19
+ );
20
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { Icon } from '../../../shared/design-system/index.js';
4
+ import { useLanguage } from '../../../app/client/i18n/index.js';
5
+ export function MutedSpeechNotice({ source }: { source?: string }) {
6
+ const { scoped } = useLanguage((ctx) => ctx.recognition);
7
+ const copy = (scoped as any).mutedWarning;
8
+ const target = typeof document === 'undefined' ? null : document.body;
9
+ return target
10
+ ? createPortal(
11
+ <div className="dlv-muted-warning" role="alert" aria-live="assertive">
12
+ <Icon name="micOff" className="dlv-muted-warning-icon" />
13
+ <div className="dlv-muted-warning-content">
14
+ <span className="dlv-muted-warning-origin">{copy.origin()}</span>
15
+ <strong>{copy.title()}</strong>
16
+ <span>{copy.body()}</span>
17
+ {source && <span className="dlv-muted-warning-source">{source}</span>}
18
+ </div>
19
+ </div>,
20
+ target,
21
+ )
22
+ : null;
23
+ }
@@ -0,0 +1,93 @@
1
+ /** One application-owned clock for all sources feeding the committed composer. */
2
+ export class VoiceInactivity {
3
+ snapshot = { phase: 'idle', remaining: 0 };
4
+ listeners = new Set<() => void>();
5
+ active = false;
6
+ lastText = 0;
7
+ lastTick = 0;
8
+ deadline = 0;
9
+ busySince = 0;
10
+ warningText = '';
11
+ echoUntil = 0;
12
+ constructor(
13
+ private options: {
14
+ now?: () => number;
15
+ warn: (seconds: number) => string;
16
+ end: () => void;
17
+ },
18
+ ) {}
19
+ now = () => this.options.now?.() ?? Date.now();
20
+ getSnapshot = () => this.snapshot;
21
+ subscribe = (listener: () => void) => {
22
+ this.listeners.add(listener);
23
+ return () => {
24
+ this.listeners.delete(listener);
25
+ };
26
+ };
27
+ patch(phase: string, remaining = 0) {
28
+ if (this.snapshot.phase === phase && this.snapshot.remaining === remaining) return;
29
+ this.snapshot = { phase, remaining };
30
+ for (const listener of this.listeners) listener();
31
+ }
32
+ keepAlive = () => {
33
+ this.lastText = this.now();
34
+ this.deadline = 0;
35
+ this.busySince = 0;
36
+ this.patch('idle');
37
+ };
38
+ /** Filter only matching warning echo; unrelated replies remain eligible. */
39
+ recognized(text: string) {
40
+ const normalize = (value: string) =>
41
+ value
42
+ .toLocaleLowerCase()
43
+ .replace(/[^\p{L}\p{N}]+/gu, ' ')
44
+ .trim();
45
+ if (!text.trim()) return true;
46
+ const heard = normalize(text);
47
+ const own = normalize(this.warningText);
48
+ if (
49
+ this.now() < this.echoUntil &&
50
+ heard.length >= 24 &&
51
+ heard.length >= own.length / 2 &&
52
+ own.includes(heard)
53
+ )
54
+ return false;
55
+ this.keepAlive();
56
+ return true;
57
+ }
58
+ tick(active: boolean, busy: boolean, settings: any) {
59
+ const now = this.now();
60
+ const gap = this.lastTick && now - this.lastTick > 10000;
61
+ this.lastTick = now;
62
+ if (!settings.autoEndEnabled || !active) {
63
+ this.active = false;
64
+ if (this.snapshot.phase !== 'ended' || active) this.patch('idle');
65
+ return;
66
+ }
67
+ if (!this.active) {
68
+ this.active = true;
69
+ this.keepAlive();
70
+ }
71
+ const total = settings.autoEndMinutes * 60000;
72
+ const warning = settings.autoEndWarningMinutes * 60000;
73
+ // A delayed/background/suspended timer must provide a fresh full warning window.
74
+ if (gap && now - this.lastText >= total - warning) this.lastText = now - (total - warning);
75
+ if (now - this.lastText < total - warning) return;
76
+ if (!this.deadline || gap) {
77
+ this.deadline = Math.max(this.lastText + total, now + warning);
78
+ this.patch('warning', Math.ceil((this.deadline - now) / 1000));
79
+ this.echoUntil = now + 30000;
80
+ this.warningText = this.options.warn(this.snapshot.remaining);
81
+ }
82
+ this.patch('warning', Math.max(0, Math.ceil((this.deadline - now) / 1000)));
83
+ if (now < this.deadline) return;
84
+ // Protect speech already underway and queued recognition, but never wait forever.
85
+ if (busy) {
86
+ if (!this.busySince) this.busySince = now;
87
+ if (now - this.busySince < 30000) return;
88
+ }
89
+ this.active = false;
90
+ this.patch('ended');
91
+ this.options.end();
92
+ }
93
+ }
@@ -292,7 +292,14 @@ export class MeetingController {
292
292
  await engine.start({
293
293
  lang: settings.recognitionLang,
294
294
  signal: recognitionAbort.signal,
295
- onResult: ({ final, interim, startedAt, paragraphBefore }) => {
295
+ onResult: ({
296
+ final,
297
+ interim,
298
+ startedAt,
299
+ paragraphBefore,
300
+ onCommandRecognized,
301
+ onIgnoredMuted,
302
+ }) => {
296
303
  if (!valid()) return;
297
304
  if (job.discardResults > 0) {
298
305
  job.discardResults--;
@@ -308,6 +315,8 @@ export class MeetingController {
308
315
  ? startedAt + (engine.attendeeTimestampOffset || 0)
309
316
  : startedAt,
310
317
  paragraphBefore,
318
+ onCommandRecognized,
319
+ onIgnoredMuted,
311
320
  });
312
321
  else if (final && !engine.activityManaged) input.patch({ recognizing: false });
313
322
  if (final && !interim && !engine.activityManaged) {
@@ -318,7 +327,7 @@ export class MeetingController {
318
327
  onActivity: (active) => {
319
328
  if (!valid()) return;
320
329
  if (active) input.cancelAutoSend({ preserveIntent: true });
321
- input.patch({ recognizing: active });
330
+ input.patch({ recognizing: active, inputSpeechActive: active });
322
331
  this.onActivity?.(source, active);
323
332
  input.refreshDeliveryReadiness();
324
333
  },
@@ -478,6 +487,7 @@ export class MeetingController {
478
487
  starting: false,
479
488
  listening: false,
480
489
  recognizing: false,
490
+ inputSpeechActive: false,
481
491
  pendingTranscriptions: 0,
482
492
  pendingTranscriptionRequests: 0,
483
493
  pendingDeliveryTranscriptions: 0,
@@ -1,3 +1,4 @@
1
+ import { formatTimestamp } from '../../core/timestamp.js';
1
2
  import { defaultSettings, normalizeSourceName } from '../../core/settings.js';
2
3
 
3
4
  export type MeetingSource = 'microphone' | 'shared' | `attendee:${string}`;
@@ -27,8 +28,12 @@ export class MeetingTranscript {
27
28
  }
28
29
  constructor(
29
30
  private composer: { getDraft(): string; setDraft(text: string): void },
30
- private settings: () => { microphoneSourceName?: string; sharedSourceName?: string } = () =>
31
- defaultSettings,
31
+ private settings: () => {
32
+ microphoneSourceName?: string;
33
+ sharedSourceName?: string;
34
+ alwaysShowSourceName?: boolean;
35
+ [key: string]: unknown;
36
+ } = () => defaultSettings,
32
37
  ) {}
33
38
  setActive(source: MeetingSource, enabled: boolean) {
34
39
  if (enabled) this.active.add(source);
@@ -39,27 +44,14 @@ export class MeetingTranscript {
39
44
  if (!chunk || !this.active.has(source)) return;
40
45
  const draft = this.composer.getDraft();
41
46
  if (!draft) this.last = null;
42
- const labelled = this.active.size > 1 || source.startsWith('attendee:');
47
+ const labelled =
48
+ this.active.size > 1 ||
49
+ source.startsWith('attendee:') ||
50
+ this.settings().alwaysShowSourceName === true;
43
51
  const timestamps = this.sourceTimestamps.get(source) ?? this.timestamps;
44
52
  const changed = this.last !== source || paragraphBefore;
45
53
  const date = new Date(Number.isFinite(startedAt) ? startedAt! : Date.now());
46
- const pad = (value: number) => String(value).padStart(2, '0');
47
- const stamp =
48
- timestamps && changed
49
- ? '[' +
50
- date.getFullYear() +
51
- '/' +
52
- pad(date.getMonth() + 1) +
53
- '/' +
54
- pad(date.getDate()) +
55
- ' ' +
56
- pad(date.getHours()) +
57
- ':' +
58
- pad(date.getMinutes()) +
59
- ':' +
60
- pad(date.getSeconds()) +
61
- '] '
62
- : '';
54
+ const stamp = timestamps && changed ? formatTimestamp(date, this.settings()) + ' ' : '';
63
55
  const key = source === 'microphone' ? 'microphoneSourceName' : 'sharedSourceName';
64
56
  const name =
65
57
  this.labels.get(source) || normalizeSourceName(this.settings()[key], defaultSettings[key]);
@@ -1,5 +1,9 @@
1
1
  # Core voice domain
2
2
 
3
+ `mutedSpeechWarning.ts` owns an four-second continuous detected-speech clock per input. Coordinator patches re-evaluate it; only engine onActivity drives explicit `inputSpeechActive`, independently of result chunks and transcription backlog. Before first display, silence resets the speech timer; after display, a three-second trailing-silence debounce avoids flicker and resumed speech cancels hiding. Lifecycle transitions clear immediately. No recognized text is required or retained, and no automatic unmute occurs. Shared input policies use the same activity contract.
4
+
5
+ `timestamp.ts` owns the pure local-clock formatter and normalization: date parts, seconds and separators are optional; hours/minutes remain mandatory. Defaults preserve the legacy format.
6
+
3
7
  `core` owns policy and reusable voice-domain state, not DSH slot/route registration or provider-specific presentation. `coordinator.ts` serializes input transitions, owns conversation state and speech queues, and invalidates stale async work with generations. `ownership.ts` arbitrates microphone and speaker use between sessions and Settings self-tests. `transcript.ts` enforces append-only final recognition text (interim hypotheses never own or rewrite composer content), `microphone.ts` manages capture and activity, `filters.ts` handles voice commands and speech text filtering, and `settings.ts` normalizes persisted values and defaults.
4
8
 
5
9
  Recording-backed conversation input can be parked by `pauseInputForNavigation()` without aborting recognition or sealing its writer. Final recognition callbacks remain on the original coordinator and are queued while detached; `resumeInputFromNavigation()` delivers them only after composition reacquires hardware ownership and a current composer. Navigation generations reject obsolete resume completions. Stop/End/disposal clears that queue and releases input; native Browser recognition keeps its existing teardown path. Parked capture retains its start-time recognition configuration and does not retry acquisition in the background.
@@ -1,5 +1,6 @@
1
1
  // @ts-nocheck
2
2
  import { MAX_RECOVERY_ATTEMPTS, recoveryDelayMs, isRetryableVoiceError } from './recovery.ts';
3
+ import { MutedSpeechWarning } from './mutedSpeechWarning.js';
3
4
  import { TranscriptDraft } from './transcript.ts';
4
5
  import { normalizeSettings } from './settings.ts';
5
6
  import { SPEECH_QUEUE_PREFETCH_LIMIT } from '../speak/services/speechQueue.js';
@@ -72,6 +73,7 @@ export class VoiceCoordinator {
72
73
  conversation: false,
73
74
  listening: false,
74
75
  recognizing: false,
76
+ inputSpeechActive: false,
75
77
  pendingTranscriptions: 0,
76
78
  pendingTranscriptionRequests: undefined,
77
79
  pendingDeliveryTranscriptions: undefined,
@@ -99,6 +101,9 @@ export class VoiceCoordinator {
99
101
  settings: normalizeSettings(settings),
100
102
  timestamps: normalizeSettings(settings).timestampsEnabled,
101
103
  };
104
+ this.mutedSpeechWarning = new MutedSpeechWarning(() => {
105
+ if (!this.disposed) this.patch({});
106
+ });
102
107
  this.autoSendTimer = null;
103
108
  this.autoSendDraft = null;
104
109
  this.holdToTalkRelease = false;
@@ -120,6 +125,11 @@ export class VoiceCoordinator {
120
125
  }
121
126
  patch(next) {
122
127
  this.snapshot = { ...this.snapshot, ...next };
128
+ this.snapshot.mutedSpeechWarning =
129
+ this.mutedSpeechWarning?.update({
130
+ ...this.snapshot,
131
+ navigationPaused: this.navigationPaused,
132
+ }) ?? false;
123
133
  this._auditSpeechWait();
124
134
  for (const listener of this.listeners) {
125
135
  try {
@@ -353,6 +363,7 @@ export class VoiceCoordinator {
353
363
  listening: false,
354
364
  starting: false,
355
365
  recognizing: false,
366
+ inputSpeechActive: false,
356
367
  pendingTranscriptions: 0,
357
368
  pendingTranscriptionRequests: 0,
358
369
  pendingDeliveryTranscriptions: 0,
@@ -644,7 +655,7 @@ export class VoiceCoordinator {
644
655
  } else
645
656
  this.assistantSpeechNotBefore =
646
657
  Date.now() + this.snapshot.settings.assistantSpeechDelaySeconds * 1000;
647
- this.patch({ recognizing: active });
658
+ this.patch({ recognizing: active, inputSpeechActive: active });
648
659
  this._handleSpeechInterruption(this._speechActivity());
649
660
  if (!active) {
650
661
  this.refreshDeliveryReadiness();
@@ -685,6 +696,7 @@ export class VoiceCoordinator {
685
696
  starting: false,
686
697
  listening: false,
687
698
  recognizing: false,
699
+ inputSpeechActive: false,
688
700
  error: message(error),
689
701
  });
690
702
  }
@@ -805,12 +817,14 @@ export class VoiceCoordinator {
805
817
  startedAt,
806
818
  paragraphBefore = false,
807
819
  onCommandRecognized,
820
+ onIgnoredMuted,
808
821
  } = result;
809
822
  if (this.disposed || (!this.snapshot.listening && !this.snapshot.starting)) return;
810
823
  if (this.navigationPaused) {
811
824
  if (final) this.navigationResults.push(result);
812
825
  return;
813
826
  }
827
+ if (this.composer.onRecognizedText?.(final || interim) === false) return;
814
828
  const recognizing = this.recognition.activityManaged ? this.snapshot.recognizing : !!interim;
815
829
  if (
816
830
  this.snapshot.speaking &&
@@ -880,6 +894,10 @@ export class VoiceCoordinator {
880
894
  return;
881
895
  }
882
896
  if (this.snapshot.muted) {
897
+ if (typeof final === 'string' && final.trim()) {
898
+ if (onIgnoredMuted) onIgnoredMuted();
899
+ else this.recordingTimeline?.()?.('transcription-ignored-muted');
900
+ }
883
901
  // Discard pending recognition without rewriting the composer.
884
902
  this.transcript.reset();
885
903
  this.patch({ recognizing });
@@ -1019,6 +1037,7 @@ export class VoiceCoordinator {
1019
1037
  this.patch({
1020
1038
  listening: false,
1021
1039
  recognizing: false,
1040
+ inputSpeechActive: false,
1022
1041
  pendingTranscriptions: 0,
1023
1042
  pendingTranscriptionRequests: 0,
1024
1043
  pendingDeliveryTranscriptions: 0,
@@ -1206,6 +1225,7 @@ export class VoiceCoordinator {
1206
1225
  listening: false,
1207
1226
  starting: false,
1208
1227
  recognizing: false,
1228
+ inputSpeechActive: false,
1209
1229
  inputError: message(error),
1210
1230
  error: message(error),
1211
1231
  });
@@ -1908,6 +1928,7 @@ export class VoiceCoordinator {
1908
1928
  this.cancelAutoSend();
1909
1929
  this._cancelAssistantSpeechTimer();
1910
1930
  this.disposed = true;
1931
+ this.mutedSpeechWarning.reset();
1911
1932
  this.listeners.clear();
1912
1933
  await this.endConversation(true);
1913
1934
  }
@@ -5,6 +5,8 @@ export interface DeveloperExtension {
5
5
  version: 1;
6
6
  label(): string;
7
7
  component: ComponentType;
8
+ /** Optional direct user-gesture launcher. False means popup could not open. */
9
+ open?(request?: { recordingId?: string }): boolean;
8
10
  }
9
11
  export function readDeveloperExtension(target: any = globalThis.window): DeveloperExtension | null {
10
12
  const extension = target?.[DEVELOPER_KEY];
@@ -0,0 +1,62 @@
1
+ /** Per-input speech clock with trailing silence debounce; never retains transcript text. */
2
+ export class MutedSpeechWarning {
3
+ private speechSince: number | null = null;
4
+ private silenceSince: number | null = null;
5
+ private visible = false;
6
+ private timer: ReturnType<typeof setTimeout> | undefined;
7
+ constructor(
8
+ private changed: () => void,
9
+ private now = () => Date.now(),
10
+ ) {}
11
+ private schedule(delay: number) {
12
+ clearTimeout(this.timer);
13
+ this.timer = setTimeout(() => {
14
+ this.timer = undefined;
15
+ this.changed();
16
+ }, delay);
17
+ }
18
+ reset() {
19
+ this.speechSince = this.silenceSince = null;
20
+ this.visible = false;
21
+ clearTimeout(this.timer);
22
+ this.timer = undefined;
23
+ }
24
+ update(state: any) {
25
+ if (!state.muted || !(state.listening || state.starting) || state.navigationPaused) {
26
+ this.reset();
27
+ return false;
28
+ }
29
+ const now = this.now();
30
+ if (state.inputSpeechActive === true) {
31
+ this.silenceSince = null;
32
+ if (this.visible) {
33
+ clearTimeout(this.timer);
34
+ this.timer = undefined;
35
+ return true;
36
+ }
37
+ if (this.speechSince === null) this.speechSince = now;
38
+ const remaining = 4000 - (now - this.speechSince);
39
+ if (remaining <= 0) {
40
+ this.visible = true;
41
+ clearTimeout(this.timer);
42
+ this.timer = undefined;
43
+ return true;
44
+ }
45
+ this.schedule(remaining);
46
+ return false;
47
+ }
48
+ this.speechSince = null;
49
+ if (!this.visible) {
50
+ this.reset();
51
+ return false;
52
+ }
53
+ if (this.silenceSince === null) this.silenceSince = now;
54
+ const remaining = 3000 - (now - this.silenceSince);
55
+ if (remaining <= 0) {
56
+ this.reset();
57
+ return false;
58
+ }
59
+ this.schedule(remaining);
60
+ return true;
61
+ }
62
+ }
@@ -1,4 +1,5 @@
1
1
  // @ts-nocheck
2
+ import { timestampDefaults, normalizeTimestamp } from './timestamp.js';
2
3
  import { TRANSCRIPTION_CONTEXT_MAX_LENGTH } from '../recognition/transcriptionContext.js';
3
4
  import { resolveCodeNotice } from './speechDefaults.js';
4
5
  import { normalizeShortcut } from '../../shared/design-system/forms/keyboardShortcut.js';
@@ -47,7 +48,13 @@ export const autoSendDelayOptions = Object.freeze([0.6, 0.8, 1, 2, 3, 4, 5, 6]);
47
48
 
48
49
  export const recordingBitrateOptions = Object.freeze([24000, 32000, 48000, 64000, 96000]);
49
50
 
51
+ // Finite positive minute values; no arbitrary product-level maximum.
52
+ const positiveMinutes = (value, fallback) =>
53
+ Number.isFinite(value) && value > 0 && Number.isFinite(value * 60000) ? value : fallback;
54
+
50
55
  export const defaultSettings = Object.freeze({
56
+ ...timestampDefaults,
57
+ alwaysShowSourceName: false,
51
58
  engine: 'browser',
52
59
  recognitionEngine: 'browser',
53
60
  browserWhisperModel: 'whisper-small',
@@ -79,6 +86,9 @@ export const defaultSettings = Object.freeze({
79
86
  interruptSpeechOnUserMessage: false,
80
87
  sendingMode: 'manual',
81
88
  dshBusyEnterBehavior: 'queue',
89
+ autoEndEnabled: true,
90
+ autoEndMinutes: 5,
91
+ autoEndWarningMinutes: 1,
82
92
  autoSendDelaySeconds: 4,
83
93
  assistantSpeechDelaySeconds: 1.5,
84
94
  mode: 'speaker',
@@ -165,6 +175,8 @@ export const voiceDetectionSilenceMs = (settings) =>
165
175
  export function normalizeSettings(value) {
166
176
  const source = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
167
177
  return {
178
+ ...normalizeTimestamp(source),
179
+ alwaysShowSourceName: source.alwaysShowSourceName === true,
168
180
  engine: ['browser', 'say', 'qwen-http', 'chatterbox-http'].includes(source.engine)
169
181
  ? source.engine
170
182
  : defaultSettings.engine,
@@ -317,6 +329,12 @@ export function normalizeSettings(value) {
317
329
  : ['manual', 'queue', 'steer'].includes(source.sendingMode)
318
330
  ? source.sendingMode
319
331
  : defaultSettings.sendingMode,
332
+ autoEndEnabled: typeof source.autoEndEnabled === 'boolean' ? source.autoEndEnabled : true,
333
+ autoEndMinutes: positiveMinutes(source.autoEndMinutes, 5),
334
+ autoEndWarningMinutes: Math.min(
335
+ positiveMinutes(source.autoEndWarningMinutes, 1),
336
+ positiveMinutes(source.autoEndMinutes, 5) / 2,
337
+ ),
320
338
  autoSendDelaySeconds: autoSendDelayOptions.includes(source.autoSendDelaySeconds)
321
339
  ? source.autoSendDelaySeconds
322
340
  : defaultSettings.autoSendDelaySeconds,
@@ -0,0 +1,35 @@
1
+ export const timestampDefaults = {
2
+ timestampDay: true,
3
+ timestampMonth: true,
4
+ timestampYear: true,
5
+ timestampSeconds: true,
6
+ timestampPunctuation: true,
7
+ };
8
+ export function normalizeTimestamp(value: any) {
9
+ return Object.fromEntries(
10
+ Object.entries(timestampDefaults).map(([key, fallback]) => [
11
+ key,
12
+ typeof value?.[key] === 'boolean' ? value[key] : fallback,
13
+ ]),
14
+ );
15
+ }
16
+ /** Fixed local-clock order preserves the legacy default; hours and minutes are mandatory. */
17
+ export function formatTimestamp(date: Date, settings: any = {}) {
18
+ const s = { ...timestampDefaults, ...normalizeTimestamp(settings) };
19
+ const pad = (n: number) => String(n).padStart(2, '0');
20
+ const day = [
21
+ s.timestampYear ? String(date.getFullYear()) : '',
22
+ s.timestampMonth ? pad(date.getMonth() + 1) : '',
23
+ s.timestampDay ? pad(date.getDate()) : '',
24
+ ]
25
+ .filter(Boolean)
26
+ .join(s.timestampPunctuation ? '/' : '');
27
+ const time = [
28
+ pad(date.getHours()),
29
+ pad(date.getMinutes()),
30
+ s.timestampSeconds ? pad(date.getSeconds()) : '',
31
+ ]
32
+ .filter(Boolean)
33
+ .join(s.timestampPunctuation ? ':' : '');
34
+ return '[' + (day ? day + ' ' : '') + time + ']';
35
+ }