dsh-voice-mode 0.7.25 → 0.7.27

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.
package/lib/client.js CHANGED
@@ -440,6 +440,7 @@ var LEVEL_CEILING = 0.25;
440
440
  var MAX_SEGMENT_MS = 3e4;
441
441
  var MIN_SPEECH_MS = 250;
442
442
  var PRE_PAD_MS = 250;
443
+ var PRE_ROLL_MS = 2e3;
443
444
  var PARTIAL_INTERVAL_MS = 100;
444
445
  var PARTIAL_MIN_S = 0.4;
445
446
  var PARTIAL_MAX_S = 30;
@@ -461,6 +462,7 @@ function createAsrEngine(config, sessionId) {
461
462
  };
462
463
  const transcriptListeners = /* @__PURE__ */ new Set();
463
464
  const partialListeners = /* @__PURE__ */ new Set();
465
+ const noticeListeners = /* @__PURE__ */ new Set();
464
466
  const levelListeners = /* @__PURE__ */ new Set();
465
467
  const telemetryListeners = /* @__PURE__ */ new Set();
466
468
  let utteranceEndAt = null;
@@ -502,6 +504,16 @@ function createAsrEngine(config, sessionId) {
502
504
  let detectSent = 0;
503
505
  let detectInFlight = false;
504
506
  let detectGeneration = 0;
507
+ const salvageEnabled = config.bargeInSalvage !== false;
508
+ let preRoll = [];
509
+ let preRollMs = 0;
510
+ let preRollStartWall = 0;
511
+ let preRollSeedWall = null;
512
+ let wasPlaying = false;
513
+ let partialFailStreak = 0;
514
+ let detectFailStreak = 0;
515
+ let salvagedSegment = false;
516
+ let yieldedSegment = false;
505
517
  const asrUrl = (final, offset, epoch) => `${location.origin}${config.basePath.replace(/\/+$/, "")}/asr?sessionId=${encodeURIComponent(sessionId)}&final=${final ? 1 : 0}` + (offset !== void 0 ? `&offset=${offset}` : "") + (epoch !== void 0 ? `&epoch=${epoch}` : "") + // 批 7N(ADR-0006):manual 模式下上传带 &manual=1,host 服务端据此放行(防御性守卫)。
506
518
  // handleAudio 入口已先在 manual + !holdActive 时 early return,所以能到这儿的帧必然
507
519
  // holdActive=true;带 manual=1 仅是冗余信号(host 拿不到 holdActive 状态)。
@@ -526,6 +538,10 @@ function createAsrEngine(config, sessionId) {
526
538
  }
527
539
  }
528
540
  };
541
+ const resetFailStreaks = () => {
542
+ partialFailStreak = 0;
543
+ detectFailStreak = 0;
544
+ };
529
545
  const sliceChunks = (chunks, from) => {
530
546
  let total = 0;
531
547
  for (const c of chunks) total += c.length;
@@ -560,17 +576,20 @@ function createAsrEngine(config, sessionId) {
560
576
  let res = await fetch(asrUrl(false, from, epoch), {
561
577
  method: "POST",
562
578
  headers: { "content-type": "application/octet-stream" },
563
- body: samples.buffer
579
+ body: samples.buffer,
580
+ signal: AbortSignal.timeout(5e3)
564
581
  });
565
582
  if (res.status === 202) {
566
- setState("loading-model");
583
+ if (state !== "wake") setState("loading-model");
567
584
  const retry = await new Promise((resolve) => {
568
585
  setTimeout(async () => {
569
586
  try {
570
587
  const r2 = await fetch(asrUrl(false, from, epoch), {
571
588
  method: "POST",
572
589
  headers: { "content-type": "application/octet-stream" },
573
- body: samples.buffer
590
+ body: samples.buffer,
591
+ signal: AbortSignal.timeout(5e3)
592
+ // I1:重试同样要超时(否则重试挂起仍锁死 partialInFlight)
574
593
  });
575
594
  resolve(r2);
576
595
  } catch {
@@ -588,14 +607,19 @@ function createAsrEngine(config, sessionId) {
588
607
  res = await fetch(asrUrl(false, 0, epoch), {
589
608
  method: "POST",
590
609
  headers: { "content-type": "application/octet-stream" },
591
- body: sliceSince(0).buffer
610
+ body: sliceSince(0).buffer,
611
+ signal: AbortSignal.timeout(5e3)
612
+ // I1:恢复重发同样要超时(挂起不 reject 会锁死 partialInFlight)
592
613
  });
593
614
  } catch {
594
615
  }
595
616
  }
596
617
  }
597
618
  if (epoch !== segmentEpoch) return;
598
- if (!res.ok) return;
619
+ if (!res.ok) {
620
+ if (res.status !== 202 && ++partialFailStreak >= 3) emit(noticeListeners, "partialFail");
621
+ return;
622
+ }
599
623
  const out = await res.json();
600
624
  if (epoch !== segmentEpoch) return;
601
625
  if (state === "wake" && wakeEnabled) {
@@ -612,13 +636,16 @@ function createAsrEngine(config, sessionId) {
612
636
  if (out.isSpeech !== void 0) config.onIsSpeech?.(out.isSpeech);
613
637
  if (state === "loading-model") setState("speech");
614
638
  uploadedSamples = Math.max(uploadedSamples, from + samples.length);
639
+ partialFailStreak = 0;
615
640
  emit(partialListeners, wakeConsumed ? stripWakePrefix(out.text ?? "", wakeWord) : out.text ?? "");
616
641
  if (config.backchannelYield !== false && // 默认 true(I10 豁免);显式 false 时跳过
617
642
  speechActive && (config.isPlaying?.() ?? false) && matchBackchannel(out.text ?? "")) {
643
+ yieldedSegment = true;
618
644
  config.onBackchannel?.();
619
645
  }
620
646
  if (out.endpoint && active && speechActive && !holdActive) finalizeSegment();
621
647
  } catch {
648
+ if (++partialFailStreak >= 3) emit(noticeListeners, "partialFail");
622
649
  } finally {
623
650
  partialInFlight = false;
624
651
  }
@@ -641,6 +668,7 @@ function createAsrEngine(config, sessionId) {
641
668
  const gen = detectGeneration;
642
669
  detectInFlight = true;
643
670
  const sentAt = Date.now();
671
+ const reqBodyStartWall = sentAt - samples.length / SAMPLE_RATE2 * 1e3;
644
672
  let rttMs = -1;
645
673
  try {
646
674
  const res = await fetch(asrUrl(false, detectSent, epoch) + "&vadOnly=1", {
@@ -656,12 +684,15 @@ function createAsrEngine(config, sessionId) {
656
684
  const out = await res.json();
657
685
  if (epoch !== segmentEpoch || gen !== detectGeneration) return;
658
686
  if (out.isSpeech !== void 0) config.onIsSpeech?.(out.isSpeech);
687
+ if (out.isSpeech === true && preRollSeedWall === null) preRollSeedWall = reqBodyStartWall - 250;
688
+ detectFailStreak = 0;
659
689
  detectSent += samples.length;
660
690
  while (detectChunks.length > 0 && detectSent >= detectChunks[0].length) {
661
691
  detectSent -= detectChunks[0].length;
662
692
  detectChunks.shift();
663
693
  }
664
694
  } catch {
695
+ if (++detectFailStreak >= 3) emit(noticeListeners, "detectFail");
665
696
  } finally {
666
697
  detectInFlight = false;
667
698
  if (fixtureRecorder.isActive) {
@@ -697,6 +728,8 @@ function createAsrEngine(config, sessionId) {
697
728
  if (cut > 0) prePad = prePad.slice(cut);
698
729
  };
699
730
  const clearWakeSegment = () => {
731
+ partialFailStreak = 0;
732
+ detectFailStreak = 0;
700
733
  segmentEpoch++;
701
734
  segment = [];
702
735
  segmentMs = 0;
@@ -704,6 +737,8 @@ function createAsrEngine(config, sessionId) {
704
737
  silenceMs = 0;
705
738
  wakeSilenceMs = 0;
706
739
  wakeConsumed = false;
740
+ salvagedSegment = false;
741
+ yieldedSegment = false;
707
742
  prePad = [];
708
743
  uploadedSamples = 0;
709
744
  void resetHostStream();
@@ -724,6 +759,10 @@ function createAsrEngine(config, sessionId) {
724
759
  const meta = { force: forcePending };
725
760
  const consumedWake = wakeConsumed;
726
761
  wakeConsumed = false;
762
+ const wasSalvaged = salvagedSegment;
763
+ salvagedSegment = false;
764
+ const wasYielded = yieldedSegment;
765
+ yieldedSegment = false;
727
766
  forcePending = false;
728
767
  speechMs = 0;
729
768
  uploadedSamples = 0;
@@ -748,13 +787,13 @@ function createAsrEngine(config, sessionId) {
748
787
  let res;
749
788
  try {
750
789
  res = await fetch(asrUrl(true, off, epochSnapshot), {
751
- signal: AbortSignal.timeout(1e4),
790
+ signal: AbortSignal.timeout(25e3),
791
+ // Issue #15 批 4:对齐 host SenseVoice race 上限 20s(asr-host.ts:598-606)——原 10s 必触发一次空转重试
752
792
  method: "POST",
753
793
  headers: { "content-type": "application/octet-stream" },
754
794
  body
755
795
  });
756
796
  } catch {
757
- restoreState();
758
797
  if (attempt === MAX_FINAL_ATTEMPTS - 1) console.warn("[dsh-voice-mode] finalize fetch failed (retries exhausted)");
759
798
  continue;
760
799
  }
@@ -765,7 +804,8 @@ function createAsrEngine(config, sessionId) {
765
804
  try {
766
805
  resolve(
767
806
  await fetch(asrUrl(true, off, epochSnapshot), {
768
- signal: AbortSignal.timeout(1e4),
807
+ signal: AbortSignal.timeout(25e3),
808
+ // Issue #15 批 4:对齐 host SenseVoice race 上限 20s(asr-host.ts:598-606)——原 10s 必触发一次空转重试
769
809
  method: "POST",
770
810
  headers: { "content-type": "application/octet-stream" },
771
811
  body
@@ -786,7 +826,8 @@ function createAsrEngine(config, sessionId) {
786
826
  if (recovered && segmentEpoch === epochSnapshot + 1) {
787
827
  try {
788
828
  res = await fetch(asrUrl(true, 0, epochSnapshot), {
789
- signal: AbortSignal.timeout(1e4),
829
+ signal: AbortSignal.timeout(25e3),
830
+ // Issue #15 批 4:对齐 host SenseVoice race 上限 20s(asr-host.ts:598-606)——原 10s 必触发一次空转重试
790
831
  method: "POST",
791
832
  headers: { "content-type": "application/octet-stream" },
792
833
  body: sliceChunks(recoverySegment, 0).buffer
@@ -795,7 +836,6 @@ function createAsrEngine(config, sessionId) {
795
836
  }
796
837
  }
797
838
  }
798
- restoreState();
799
839
  if (!res.ok) {
800
840
  if (attempt === MAX_FINAL_ATTEMPTS - 1) console.warn("[dsh-voice-mode] finalize 5xx (retries exhausted)");
801
841
  continue;
@@ -808,15 +848,23 @@ function createAsrEngine(config, sessionId) {
808
848
  continue;
809
849
  }
810
850
  if (segmentEpoch !== epochSnapshot + 1) return;
851
+ resetFailStreaks();
852
+ restoreState();
811
853
  const rawText = out.text ?? "";
812
854
  const finalText = consumedWake ? stripWakePrefix(rawText, wakeWord) : rawText;
813
855
  if (finalText) {
856
+ if ((wasSalvaged || wasYielded) && matchBackchannel(finalText)) {
857
+ emit(noticeListeners, "backchannelDropped");
858
+ if (active && wakeEnabled) setState("listening");
859
+ return;
860
+ }
814
861
  emit(transcriptListeners, finalText, meta);
815
862
  } else if (consumedWake && active && !speechActive && !holdActive) {
816
863
  setState("listening");
817
864
  }
818
865
  return;
819
866
  }
867
+ restoreState();
820
868
  emitError("recognitionFail");
821
869
  })();
822
870
  };
@@ -871,7 +919,29 @@ function createAsrEngine(config, sessionId) {
871
919
  playingTail: playingNow
872
920
  });
873
921
  }
874
- if (playingNow && !holdActive && config.mode !== "hold") detectChunks.push(data);
922
+ if (playingNow && !holdActive && config.mode !== "hold") {
923
+ detectChunks.push(data);
924
+ if (salvageEnabled) {
925
+ if (preRoll.length === 0) preRollStartWall = Date.now();
926
+ preRoll.push(data);
927
+ preRollMs += durationMs;
928
+ while (preRollMs > PRE_ROLL_MS && preRoll.length > 1) {
929
+ const dropped = preRoll.shift();
930
+ const droppedMs = dropped.length / SAMPLE_RATE2 * 1e3;
931
+ preRollMs -= droppedMs;
932
+ preRollStartWall += droppedMs;
933
+ }
934
+ }
935
+ }
936
+ if (playingNow && !wasPlaying) {
937
+ wasPlaying = true;
938
+ preRollSeedWall = null;
939
+ preRoll = [];
940
+ preRollMs = 0;
941
+ preRollStartWall = 0;
942
+ } else if (!playingNow && wasPlaying) {
943
+ wasPlaying = false;
944
+ }
875
945
  if (holdActive) {
876
946
  if (!speechActive) {
877
947
  speechActive = true;
@@ -940,6 +1010,9 @@ function createAsrEngine(config, sessionId) {
940
1010
  segmentEpoch++;
941
1011
  segment = [];
942
1012
  speechActive = false;
1013
+ salvagedSegment = false;
1014
+ yieldedSegment = false;
1015
+ resetFailStreaks();
943
1016
  speechMs = 0;
944
1017
  silenceMs = 0;
945
1018
  segmentMs = 0;
@@ -969,9 +1042,21 @@ function createAsrEngine(config, sessionId) {
969
1042
  }
970
1043
  }
971
1044
  };
1045
+ const abandonStart = async (myStream, myCtx) => {
1046
+ try {
1047
+ myStream.getTracks().forEach((t3) => t3.stop());
1048
+ } catch {
1049
+ }
1050
+ if (stream === myStream) stream = null;
1051
+ try {
1052
+ await myCtx.close();
1053
+ } catch {
1054
+ }
1055
+ if (audioCtx === myCtx) audioCtx = null;
1056
+ };
972
1057
  const startRecorder = async () => {
973
1058
  const mySeq = startSeq;
974
- stream = await navigator.mediaDevices.getUserMedia({
1059
+ const myStream = await navigator.mediaDevices.getUserMedia({
975
1060
  audio: {
976
1061
  channelCount: 1,
977
1062
  echoCancellation: true,
@@ -984,10 +1069,10 @@ function createAsrEngine(config, sessionId) {
984
1069
  }
985
1070
  });
986
1071
  if (stopRequested || mySeq !== startSeq) {
987
- stream.getTracks().forEach((t3) => t3.stop());
988
- stream = null;
1072
+ myStream.getTracks().forEach((t3) => t3.stop());
989
1073
  return;
990
1074
  }
1075
+ stream = myStream;
991
1076
  const aecOn = stream.getAudioTracks()[0]?.getSettings().echoCancellation === true;
992
1077
  if (!aecOn) {
993
1078
  console.warn("[dsh-voice-mode] native browser echoCancellation is not in effect (speakers may self-interrupt); use headphones or manual barge-in");
@@ -997,34 +1082,48 @@ function createAsrEngine(config, sessionId) {
997
1082
  }
998
1083
  config.onAecState?.(aecOn);
999
1084
  const AC = window.AudioContext ?? window.webkitAudioContext;
1000
- audioCtx = new AC({ sampleRate: SAMPLE_RATE2 });
1085
+ const myCtx = new AC({ sampleRate: SAMPLE_RATE2 });
1086
+ audioCtx = myCtx;
1001
1087
  try {
1002
1088
  await audioCtx.resume?.();
1003
1089
  } catch {
1004
1090
  }
1091
+ if (stopRequested || mySeq !== startSeq) {
1092
+ await abandonStart(myStream, myCtx);
1093
+ return;
1094
+ }
1005
1095
  ctxRate = audioCtx.sampleRate;
1006
1096
  const source = audioCtx.createMediaStreamSource(stream);
1007
1097
  if (audioCtx.audioWorklet) {
1098
+ let myWorkletNode = null;
1008
1099
  try {
1009
1100
  if (!workletBlobUrl) {
1010
1101
  workletBlobUrl = URL.createObjectURL(new Blob(['"use strict";\n(() => {\n // src/resample.ts\n function resampleLinear(src, srcRate, dstRate) {\n if (srcRate === dstRate) return src;\n if (src.length === 0) return src;\n const ratio = srcRate / dstRate;\n const outLen = Math.max(1, Math.floor(src.length / ratio));\n const out = new Float32Array(outLen);\n for (let i = 0; i < outLen; i++) {\n const pos = i * ratio;\n const i0 = Math.floor(pos);\n const i1 = Math.min(i0 + 1, src.length - 1);\n const frac = pos - i0;\n out[i] = src[i0] + (src[i1] - src[i0]) * frac;\n }\n return out;\n }\n\n // src/audio-worklet.ts\n var TARGET_RATE = 16e3;\n var CHUNK = 1024;\n var RATIO = sampleRate / TARGET_RATE;\n var NEED = Math.ceil(CHUNK * RATIO);\n var VoiceCaptureProcessor = class extends AudioWorkletProcessor {\n acc = new Float32Array(0);\n accLen = 0;\n process(inputs) {\n const ch = inputs[0]?.[0];\n if (ch && ch.length > 0) this.push(ch);\n this.drain();\n return true;\n }\n push(ch) {\n if (this.accLen + ch.length > this.acc.length) {\n let cap = this.acc.length > 0 ? this.acc.length : NEED * 2;\n while (cap < this.accLen + ch.length) cap *= 2;\n const next = new Float32Array(cap);\n next.set(this.acc.subarray(0, this.accLen));\n this.acc = next;\n }\n this.acc.set(ch, this.accLen);\n this.accLen += ch.length;\n }\n drain() {\n while (this.accLen >= NEED) {\n const src = sampleRate === TARGET_RATE ? this.acc.subarray(0, CHUNK) : resampleLinear(this.acc.subarray(0, NEED), sampleRate, TARGET_RATE);\n const chunk = new Float32Array(CHUNK);\n chunk.set(src.length >= CHUNK ? src.subarray(0, CHUNK) : src);\n this.port.postMessage(chunk, [chunk.buffer]);\n this.acc.copyWithin(0, NEED, this.accLen);\n this.accLen -= NEED;\n }\n }\n };\n registerProcessor("voice-capture", VoiceCaptureProcessor);\n})();\n'], { type: "text/javascript" }));
1011
1102
  }
1012
1103
  await audioCtx.audioWorklet.addModule(workletBlobUrl);
1013
- workletNode = new AudioWorkletNode(audioCtx, "voice-capture", { numberOfInputs: 1, numberOfOutputs: 1, outputChannelCount: [1] });
1014
- workletNode.port.onmessage = (e) => {
1104
+ if (stopRequested || mySeq !== startSeq) {
1105
+ await abandonStart(myStream, myCtx);
1106
+ return;
1107
+ }
1108
+ myWorkletNode = new AudioWorkletNode(audioCtx, "voice-capture", { numberOfInputs: 1, numberOfOutputs: 1, outputChannelCount: [1] });
1109
+ myWorkletNode.port.onmessage = (e) => {
1015
1110
  handleAudio(e.data);
1016
1111
  };
1017
- source.connect(workletNode);
1018
- workletNode.connect(audioCtx.destination);
1112
+ source.connect(myWorkletNode);
1113
+ myWorkletNode.connect(audioCtx.destination);
1114
+ workletNode = myWorkletNode;
1019
1115
  ctxRate = SAMPLE_RATE2;
1020
1116
  active = true;
1021
1117
  return;
1022
1118
  } catch {
1023
1119
  try {
1024
- workletNode?.disconnect();
1120
+ myWorkletNode?.disconnect();
1025
1121
  } catch {
1026
1122
  }
1027
- workletNode = null;
1123
+ if (stopRequested || mySeq !== startSeq) {
1124
+ await abandonStart(myStream, myCtx);
1125
+ return;
1126
+ }
1028
1127
  }
1029
1128
  }
1030
1129
  processor = audioCtx.createScriptProcessor(BUFFER_SIZE, 1, 1);
@@ -1036,6 +1135,7 @@ function createAsrEngine(config, sessionId) {
1036
1135
  active = true;
1037
1136
  };
1038
1137
  const stopRecorder = async () => {
1138
+ const myCtx = audioCtx;
1039
1139
  inFlush = true;
1040
1140
  segmentEpoch++;
1041
1141
  forcePending = false;
@@ -1047,11 +1147,18 @@ function createAsrEngine(config, sessionId) {
1047
1147
  speechMs = 0;
1048
1148
  wakeSilenceMs = 0;
1049
1149
  wakeConsumed = false;
1150
+ yieldedSegment = false;
1050
1151
  uploadedSamples = 0;
1051
1152
  prePad = [];
1052
1153
  detectChunks = [];
1053
1154
  detectSent = 0;
1054
1155
  detectGeneration++;
1156
+ preRoll = [];
1157
+ preRollMs = 0;
1158
+ preRollStartWall = 0;
1159
+ preRollSeedWall = null;
1160
+ wasPlaying = false;
1161
+ salvagedSegment = false;
1055
1162
  utteranceEndAt = null;
1056
1163
  try {
1057
1164
  processor?.disconnect();
@@ -1069,11 +1176,13 @@ function createAsrEngine(config, sessionId) {
1069
1176
  }
1070
1177
  stream = null;
1071
1178
  try {
1072
- await audioCtx?.close();
1179
+ await myCtx?.close();
1073
1180
  } catch {
1074
1181
  }
1075
- audioCtx = null;
1076
- ctxRate = SAMPLE_RATE2;
1182
+ if (audioCtx === myCtx) {
1183
+ audioCtx = null;
1184
+ ctxRate = SAMPLE_RATE2;
1185
+ }
1077
1186
  inFlush = false;
1078
1187
  };
1079
1188
  return {
@@ -1095,22 +1204,37 @@ function createAsrEngine(config, sessionId) {
1095
1204
  if (active) return;
1096
1205
  stopRequested = false;
1097
1206
  startSeq++;
1207
+ const myStartSeq = startSeq;
1098
1208
  segmentEpoch++;
1209
+ partialFailStreak = 0;
1210
+ detectFailStreak = 0;
1099
1211
  lastPollAt = 0;
1100
1212
  holdActive = false;
1101
1213
  detectChunks = [];
1102
1214
  detectSent = 0;
1103
1215
  detectGeneration++;
1216
+ preRoll = [];
1217
+ preRollMs = 0;
1218
+ preRollStartWall = 0;
1219
+ preRollSeedWall = null;
1220
+ wasPlaying = false;
1221
+ salvagedSegment = false;
1222
+ yieldedSegment = false;
1223
+ latestResidualRms = 0;
1224
+ echoFloorRms = 0;
1225
+ echoPeak = 0;
1104
1226
  setState(wakeEnabled ? "wake" : "listening");
1105
1227
  try {
1106
1228
  await startRecorder();
1107
1229
  } catch (error) {
1108
- setState("idle");
1230
+ if (startSeq === myStartSeq) setState("idle");
1109
1231
  throw error;
1110
1232
  }
1111
1233
  },
1112
1234
  async stop() {
1113
1235
  stopRequested = true;
1236
+ startSeq++;
1237
+ const myStopSeq = startSeq;
1114
1238
  const wasActive = active;
1115
1239
  active = false;
1116
1240
  if (!wasActive) {
@@ -1118,11 +1242,10 @@ function createAsrEngine(config, sessionId) {
1118
1242
  return;
1119
1243
  }
1120
1244
  await stopRecorder();
1121
- setState("idle");
1245
+ if (startSeq === myStopSeq) setState("idle");
1122
1246
  },
1123
1247
  forceSend() {
1124
- const speechS = segment.reduce((n, c) => n + c.length, 0) / SAMPLE_RATE2;
1125
- if (speechActive && speechS >= 0.25) {
1248
+ if (speechActive && speechMs >= MIN_SPEECH_MS) {
1126
1249
  forcePending = true;
1127
1250
  lastPollAt = 0;
1128
1251
  finalizeSegment();
@@ -1133,6 +1256,9 @@ function createAsrEngine(config, sessionId) {
1133
1256
  holdActive = true;
1134
1257
  segmentEpoch++;
1135
1258
  wakeConsumed = false;
1259
+ salvagedSegment = false;
1260
+ yieldedSegment = false;
1261
+ resetFailStreaks();
1136
1262
  utteranceEndAt = null;
1137
1263
  segment = [];
1138
1264
  segmentMs = 0;
@@ -1149,12 +1275,16 @@ function createAsrEngine(config, sessionId) {
1149
1275
  },
1150
1276
  discardSegment() {
1151
1277
  segmentEpoch++;
1278
+ partialFailStreak = 0;
1279
+ detectFailStreak = 0;
1152
1280
  segment = [];
1153
1281
  segmentMs = 0;
1154
1282
  speechMs = 0;
1155
1283
  silenceMs = 0;
1156
1284
  wakeSilenceMs = 0;
1157
1285
  wakeConsumed = false;
1286
+ salvagedSegment = false;
1287
+ yieldedSegment = false;
1158
1288
  speechActive = false;
1159
1289
  prePad = [];
1160
1290
  uploadedSamples = 0;
@@ -1164,8 +1294,37 @@ function createAsrEngine(config, sessionId) {
1164
1294
  utteranceEndAt = null;
1165
1295
  forcePending = false;
1166
1296
  lastPollAt = 0;
1297
+ let salvaged = false;
1298
+ if (salvageEnabled && preRoll.length > 0) {
1299
+ const seedFromWall = Math.max(preRollSeedWall ?? preRollStartWall, preRollStartWall);
1300
+ let acc = 0;
1301
+ let i = 0;
1302
+ for (; i < preRoll.length; i++) {
1303
+ const frameMs = preRoll[i].length / SAMPLE_RATE2 * 1e3;
1304
+ if (preRollStartWall + acc + frameMs > seedFromWall) break;
1305
+ acc += frameMs;
1306
+ }
1307
+ const seeded = preRoll.slice(i);
1308
+ const seededMs = seeded.reduce((n, c) => n + c.length / SAMPLE_RATE2 * 1e3, 0);
1309
+ if (seeded.length > 0 && seededMs > 0) {
1310
+ for (const c of seeded) segment.push(c);
1311
+ segmentMs = seededMs;
1312
+ speechMs = seededMs;
1313
+ silenceMs = 0;
1314
+ speechActive = true;
1315
+ uploadedSamples = 0;
1316
+ salvagedSegment = true;
1317
+ salvaged = true;
1318
+ if (wakeEnabled) wakeConsumed = true;
1319
+ }
1320
+ }
1321
+ preRoll = [];
1322
+ preRollMs = 0;
1323
+ preRollStartWall = 0;
1324
+ preRollSeedWall = null;
1325
+ if (salvaged && active) setState("speech");
1167
1326
  return resetHostStream().then(() => {
1168
- if (active) setState(wakeEnabled ? "wake" : "listening");
1327
+ if (active && !salvaged) setState(wakeEnabled ? "wake" : "listening");
1169
1328
  });
1170
1329
  },
1171
1330
  endHeld(cancel = false) {
@@ -1174,10 +1333,14 @@ function createAsrEngine(config, sessionId) {
1174
1333
  if (cancel) {
1175
1334
  segmentEpoch++;
1176
1335
  segment = [];
1336
+ salvagedSegment = false;
1337
+ yieldedSegment = false;
1338
+ resetFailStreaks();
1177
1339
  segmentMs = 0;
1178
1340
  silenceMs = 0;
1179
1341
  prePad = [];
1180
1342
  speechActive = false;
1343
+ utteranceEndAt = null;
1181
1344
  forcePending = false;
1182
1345
  setState(wakeEnabled ? "wake" : "listening");
1183
1346
  return;
@@ -1188,6 +1351,7 @@ function createAsrEngine(config, sessionId) {
1188
1351
  finalizeSegment();
1189
1352
  } else {
1190
1353
  forcePending = false;
1354
+ speechActive = false;
1191
1355
  setState(wakeEnabled ? "wake" : "listening");
1192
1356
  }
1193
1357
  },
@@ -1197,6 +1361,12 @@ function createAsrEngine(config, sessionId) {
1197
1361
  transcriptListeners.delete(fn);
1198
1362
  };
1199
1363
  },
1364
+ onNotice(fn) {
1365
+ noticeListeners.add(fn);
1366
+ return () => {
1367
+ noticeListeners.delete(fn);
1368
+ };
1369
+ },
1200
1370
  onError(fn) {
1201
1371
  errorListeners.add(fn);
1202
1372
  return () => {
@@ -1402,17 +1572,23 @@ var zh = {
1402
1572
  disabled: "\u8BED\u97F3\u6A21\u5F0F\u5DF2\u7981\u7528\uFF08\u63D2\u4EF6 enabled=false\uFF09",
1403
1573
  sendFailKept: "\u53D1\u9001\u5931\u8D25\uFF0C\u5DF2\u4FDD\u7559\u5728\u8349\u7A3F",
1404
1574
  micDenied: "\u9EA6\u514B\u98CE\u88AB\u62D2\u7EDD\uFF1A\u8BF7\u5728\u6D4F\u89C8\u5668\u5730\u5740\u680F\u5141\u8BB8\u9EA6\u514B\u98CE\u6743\u9650",
1575
+ micBusy: "\u9EA6\u514B\u98CE\u88AB\u5176\u4ED6\u7A0B\u5E8F\u5360\u7528\uFF1A\u8BF7\u5173\u95ED\u5360\u7528\u7A0B\u5E8F\u540E\u91CD\u8BD5",
1405
1576
  micUnavailable: "\u9EA6\u514B\u98CE\u4E0D\u53EF\u7528",
1406
1577
  recognizing: "\u8BC6\u522B\u4E2D\u2026",
1578
+ // UX-I1 联动态:纠错在途 / 纠错放弃回退 / 附和词忽略 / 语音按钮态文案。
1579
+ correctFixing: "\u7EA0\u9519\u4E2D\u2026",
1580
+ correctAbandoned: "\u5DF2\u4FDD\u7559\u539F\u6587\u5728\u8349\u7A3F",
1581
+ backchannelDropped: "\u5DF2\u5FFD\u7565\u9644\u548C\u8BCD\uFF0C\u4E0D\u53D1\u9001",
1582
+ buttonLoading: "\u52A0\u8F7D\u4E2D\u2026",
1583
+ buttonListening: "\u8046\u542C\u4E2D",
1407
1584
  holdToTalk: "\u6309\u4F4F\u8BF4\u8BDD",
1408
1585
  releaseToSend: "\u677E\u5F00\u53D1\u9001",
1409
- voiceDetected: "\u8BED\u97F3\u4E2D",
1410
1586
  entering: "\u8FDB\u5165\u4E2D\u2026",
1411
1587
  voiceBtn: "\u8BED\u97F3",
1412
1588
  ariaActive: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D",
1413
1589
  ariaEnter: "\u8FDB\u5165\u8BED\u97F3\u5BF9\u8BDD\u6A21\u5F0F",
1414
1590
  titleHold: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D \xB7 \u6309\u4F4F\u8BF4\u8BDD\u3001\u677E\u624B\u53D1\u9001\uFF1B\u77ED\u6309\u9000\u51FA\uFF1BEsc/\u5931\u53BB\u7126\u70B9\u653E\u5F03\uFF1BCtrl+Shift+V \u9000\u51FA",
1415
- titleToggle: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D \xB7 \u70B9\u51FB\u9000\u51FA\uFF08Ctrl+Shift+V\uFF09\xB7 \u6309\u4F4F Ctrl \u7ACB\u5373\u53D1\u9001",
1591
+ titleToggle: "\u8BED\u97F3\u6A21\u5F0F\u8FDB\u884C\u4E2D \xB7 \u70B9\u51FB\u9000\u51FA\uFF08Ctrl+Shift+V\uFF09\xB7 \u8BF4\u8BDD\u65F6\u6309\u4F4F Ctrl \u7ACB\u5373\u53D1\u9001",
1416
1592
  titleEnter: "\u8FDB\u5165\u8BED\u97F3\u5BF9\u8BDD\u6A21\u5F0F\uFF08Ctrl+Shift+V\uFF09",
1417
1593
  loadingModel: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u2026",
1418
1594
  listening: "\u8046\u542C\u4E2D\u2026",
@@ -1423,13 +1599,18 @@ var zh = {
1423
1599
  sayWake: "\u8BF4\u300C{wake}\u300D\u5F00\u59CB",
1424
1600
  reading: "\u6717\u8BFB\u4E2D\u2026",
1425
1601
  recognitionFail: "\u8BC6\u522B\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
1602
+ partialFail: "\u5B9E\u65F6\u5B57\u5E55\u6682\u65F6\u4E0D\u53EF\u7528\uFF08\u8BC6\u522B\u901A\u9053\u5F02\u5E38\uFF0C\u91CD\u8BD5\u4E2D\uFF09",
1603
+ detectFail: "\u6253\u65AD\u68C0\u6D4B\u6682\u65F6\u4E0D\u53EF\u7528\uFF08\u68C0\u6D4B\u901A\u9053\u5F02\u5E38\uFF0C\u91CD\u8BD5\u4E2D\uFF09",
1604
+ sseReconnect: "\u72B6\u6001\u540C\u6B65\u65AD\u8FDE\uFF0C\u91CD\u8FDE\u4E2D\u2026",
1605
+ diagCopy: "\u590D\u5236\u8BCA\u65AD",
1606
+ diagCopied: "\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",
1607
+ diagCopyFailed: "\u590D\u5236\u5931\u8D25\uFF08\u6D4F\u89C8\u5668\u62D2\u7EDD\u4E86\u526A\u8D34\u677F\uFF09",
1426
1608
  sessionExpired: "\u8BED\u97F3\u4F1A\u8BDD\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE\u2026",
1427
1609
  sessionExpiredFail: "\u8BED\u97F3\u4F1A\u8BDD\u91CD\u8FDE\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u5F00\u542F\u8BED\u97F3\u6A21\u5F0F",
1428
1610
  modelDownloadFail: "\u8BED\u97F3\u6A21\u578B\u4E0B\u8F7D\u5931\u8D25\uFF08{file}\uFF09\uFF1A\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u65B0\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u91CD\u8BD5",
1429
1611
  startFail: "\u8BED\u97F3\u6A21\u5F0F\u542F\u52A8\u5931\u8D25\uFF1A{err}",
1430
1612
  holdDots: "\u6309\u4F4F\u8BF4\u8BDD\u2026",
1431
1613
  exit: "\u9000\u51FA",
1432
- skip: "\u8DF3\u8FC7",
1433
1614
  configUnavailableNote: "\uFF08\u8BBE\u7F6E\u6587\u6863\u672A\u5C31\u7EEA\uFF0C\u9762\u677F\u5C31\u7EEA\u540E\u4F1A\u81EA\u52A8\u51FA\u73B0\uFF09\u3002",
1434
1615
  // settings-form
1435
1616
  previewNameFirst: "\u8BF7\u5148\u586B\u5199\u97F3\u8272\u540D\uFF08ShortName\uFF09",
@@ -1458,7 +1639,7 @@ var zh = {
1458
1639
  descVoiceKokoro: "Kokoro \u4E2D\u82F1\u97F3\u8272\uFF08103 \u4E2A\u5168\u90E8\u5217\u51FA\uFF0C\u4E0B\u62C9\u9009\u6216 \u25C0\u25B6 \u5207\u6362\uFF1B48-51 \u4E2D\u6587\u540D\uFF0C\u5176\u4F59\u6309\u7F16\u53F7+\u5B9E\u6D4B\u6027\u522B\u6807\u6CE8\uFF0C\u4E2D\u82F1\u6DF7\u8BFB\u5747\u53EF\uFF09",
1459
1640
  descRate: "\u6717\u8BFB\u8BED\u901F\u500D\u7387\uFF080.5 \u6162\u901F \uFF5E 2.0 \u5FEB\u901F\uFF0C1.1 \u9ED8\u8BA4\uFF1B\u8BA9\u56DE\u590D\u66F4\u7D27\u51D1\uFF09",
1460
1641
  descInterrupt: "\u53D1\u58F0\u6253\u65AD\u7075\u654F\u5EA6\uFF080 \u9AD8\u95E8\u69DB \u22480.3s \u786E\u8BA4 / 1 \u4E2D\u95E8\u69DB \u22480.2s / 2 \u4F4E\u95E8\u69DB \u22480.1s\uFF0C\u6700\u7075\u654F\uFF09\uFF1B\u503C\u8D8A\u4F4E\u95E8\u69DB\u8D8A\u9AD8\uFF0C\u8D8A\u96BE\u6253\u65AD",
1461
- descBargeIn: "\u6253\u65AD\u65B9\u5F0F\uFF08detect \u81EA\u52A8\u63A2\u6D4B\u672C\u673A\u56DE\u58F0\u6D88\u9664\u72B6\u6001\u3001\u672A\u751F\u6548\u65F6\u5207\u4E3A\u957F\u6309\u6253\u65AD\uFF0C\u9ED8\u8BA4\uFF1Bauto \u5F3A\u5236\u81EA\u52A8\u6253\u65AD\uFF1A\u5F00\u53E3\u5373\u6253\u65AD\uFF0C\u8033\u673A/\u5B89\u9759\u73AF\u5883\u63A8\u8350\uFF1Bmanual \u624B\u52A8\u6253\u65AD\uFF1A\u5916\u653E\u63A8\u8350\u2014\u2014\u56DE\u58F0\u4E0D\u4F1A\u8BEF\u89E6\u53D1\u81EA\u6253\u65AD\uFF0C\u6309\u4F4F\u9EA6\u514B\u98CE/Ctrl \u663E\u5F0F\u6253\u65AD\uFF09",
1642
+ descBargeIn: "\u6253\u65AD\u65B9\u5F0F\uFF08detect \u81EA\u52A8\u63A2\u6D4B\u672C\u673A\u56DE\u58F0\u6D88\u9664\u72B6\u6001\u3001\u672A\u751F\u6548\u65F6\u5207\u4E3A\u957F\u6309\u6253\u65AD\uFF0C\u9ED8\u8BA4\uFF1Bauto \u5F3A\u5236\u81EA\u52A8\u6253\u65AD\uFF1A\u5F00\u53E3\u5373\u6253\u65AD\uFF0C\u8033\u673A/\u5B89\u9759\u73AF\u5883\u63A8\u8350\uFF1Bmanual \u624B\u52A8\u6253\u65AD\uFF1A\u5916\u653E\u63A8\u8350\u2014\u2014\u56DE\u58F0\u4E0D\u4F1A\u8BEF\u89E6\u53D1\u81EA\u6253\u65AD\uFF0C\u6309\u4F4F\u9EA6\u514B\u98CE/Ctrl \u663E\u5F0F\u6253\u65AD\uFF09\u3002\u6CE8\u610F\uFF1Amanual\uFF08detect \u5728\u65E0\u539F\u751F\u56DE\u58F0\u6D88\u9664\u7684\u673A\u5668\u4E0A\u4E5F\u4F1A\u81EA\u52A8\u843D\u5165\uFF09\u4E0B\u975E\u6309\u538B\u671F\u7684\u8BED\u97F3\u4E0D\u88AB\u8BC6\u522B\u2014\u2014toggle \u6A21\u5F0F\u4EC5\u64AD\u653E\u4E2D\u53EF\u957F\u6309\u8BF4\u8BDD\uFF0C\u5F85\u673A\u65F6\u65E0\u6CD5\u8BED\u97F3\u8F93\u5165\uFF0C\u8BF7\u6539\u7528 hold \u6A21\u5F0F\u6216 auto/detect",
1462
1643
  bargeInDetect: "\u81EA\u52A8\u63A2\u6D4B",
1463
1644
  bargeInAuto: "\u81EA\u52A8",
1464
1645
  bargeInManual: "\u624B\u52A8",
@@ -1469,22 +1650,29 @@ var zh = {
1469
1650
  aecOffHint: "\u6D4F\u89C8\u5668\u539F\u751F\u56DE\u58F0\u6D88\u9664\u672A\u751F\u6548\uFF08\u5916\u653E\u53EF\u80FD\u81EA\u6253\u65AD\uFF09\uFF0C\u5EFA\u8BAE\u7528\u8033\u673A\u6216\u5207\u6362\u300C\u624B\u52A8\u6253\u65AD\u300D",
1470
1651
  // 批 7O(ADR-0006):detect 模式第一级探测降级提示(状态条)。
1471
1652
  bargeInDetectFallback: "\u672C\u673A\u56DE\u58F0\u6D88\u9664\u672A\u751F\u6548\uFF0C\u5DF2\u5207\u4E3A\u957F\u6309\u6253\u65AD",
1653
+ // R1 收尾(fix-client 直连 tk() 调用):连续 3 次回声拒断的解释出口 + 快捷键非法停用提示。
1654
+ echoRejectHint: "\u56DE\u58F0\u8F83\u5F3A\uFF0C\u6253\u65AD\u53EF\u80FD\u4E0D\u7075\u654F\u2014\u2014\u8FD9\u662F\u56DE\u58F0\u9632\u62A4\u5728\u751F\u6548\uFF0C\u53EF\u6234\u8033\u673A\u6216\u6539\u7528\u300C\u624B\u52A8\u6253\u65AD\u300D",
1655
+ shortcutInvalid: "\u5FEB\u6377\u952E\u65E0\u6548\uFF0C\u5DF2\u505C\u7528\uFF08\u53EF\u5728\u8BBE\u7F6E\u91CC\u6539\u4E3A\u5982 Ctrl+Shift+V\uFF1B\u7559\u7A7A\u8868\u793A\u53EA\u7528\u9EA6\u514B\u98CE\u6309\u94AE\uFF09",
1472
1656
  elapsedHint: "\u5F53\u524D\u8BED\u97F3\u4F1A\u8BDD\u5DF2\u7528\u65F6\u957F",
1473
1657
  botLevelsHint: "AI \u6717\u8BFB\u97F3\u91CF\uFF08\u84DD\u8272\u6761 = \u6717\u8BFB\uFF0C\u7EFF\u8272\u6761 = \u9EA6\u514B\u98CE\uFF09",
1474
1658
  interruptConfirm: "\u6253\u65AD\u786E\u8BA4",
1475
1659
  sev0: "0 \u9AD8\u95E8\u69DB",
1476
1660
  sev1: "1 \u4E2D",
1477
1661
  sev2: "2 \u4F4E",
1662
+ // 数值单位(设置卡片「当前生效值」用:中文汉字单位、英文国际缩写,避免「1500 ms」直出)
1663
+ unitMs: "\u6BEB\u79D2",
1664
+ unitMin: "\u5206\u949F",
1665
+ unitDb: "\u5206\u8D1D",
1478
1666
  descSilence: "\u8BF4\u5B8C\u6574\u4E00\u53E5\u7684\u9759\u97F3\u505C\u987F\u6BEB\u79D2\u6570\uFF08\u9ED8\u8BA4 1500 \u6BEB\u79D2\uFF0C\u7ED9\u601D\u8003\u505C\u987F\u7559\u7A7A\u95F4\uFF1B\u81F3\u5C11 250ms \u8BED\u97F3\u624D\u5224\u53E5\uFF0C\u9632\u77ED\u4FC3\u566A\u58F0\u8BEF\u89E6\u53D1\uFF09",
1479
- descIdle: "\u65E0\u6D3B\u52A8\u81EA\u52A8\u9000\u51FA\u8BED\u97F3\u6A21\u5F0F\u7684\u5206\u949F\u6570\uFF08\u9ED8\u8BA4 5\uFF1B\u6279 G \u4EFB\u52A1 2 \u5DF2\u52A0 30s \u5012\u6570\u9884\u8B66\uFF09",
1667
+ descIdle: "\u65E0\u6D3B\u52A8\u81EA\u52A8\u9000\u51FA\u8BED\u97F3\u6A21\u5F0F\u7684\u5206\u949F\u6570\uFF08\u9ED8\u8BA4 5\uFF1B\u9000\u51FA\u524D 30 \u79D2\u4F1A\u6709\u5012\u6570\u9884\u8B66\uFF09",
1480
1668
  descModelHost: "ASR \u6A21\u578B\u4E0B\u8F7D\u6E90\uFF08\u5B98\u65B9\u6E90 / \u56FD\u5185\u955C\u50CF\uFF0C\u6216\u9009\u300C\u81EA\u5B9A\u4E49\u300D\u586B\u4EFB\u610F\u955C\u50CF\uFF09",
1481
- descAutoSend: "\u9759\u97F3\u5230\u70B9\u81EA\u52A8\u53D1\u9001\uFF08\u8FDE\u7EED\u591A\u6BB5\u62FC\u6210\u4E00\u6761\uFF1B\u5173=\u53EA\u8FDB\u8349\u7A3F\uFF1B\u6309\u4F4F Ctrl / hold \u677E\u624B\u4ECD\u53D1\u9001\uFF09",
1669
+ descAutoSend: "\u9759\u97F3\u5230\u70B9\u81EA\u52A8\u53D1\u9001\uFF08\u8FDE\u7EED\u591A\u6BB5\u62FC\u6210\u4E00\u6761\uFF1B\u5173=\u53EA\u8FDB\u8349\u7A3F\uFF1B\u8BF4\u8BDD\u8FC7\u7A0B\u4E2D\u6309\u4F4F Ctrl \u53EF\u7ACB\u5373\u53D1\u9001\uFF0Chold \u6A21\u5F0F\u677E\u624B\u5373\u53D1\u9001\uFF09",
1482
1670
  // 批 7N 重做 5/5:明确「开启后下次进入语音会话即生效」——消除「点完为何不立即恢复」的预期差。
1483
1671
  descAutoResume: "\u5207\u6362\u56DE\u4E0A\u6B21\u8BED\u97F3\u4F1A\u8BDD\u65F6\u81EA\u52A8\u6062\u590D\u8BED\u97F3\u6A21\u5F0F\uFF08\u9ED8\u8BA4\u5173\uFF1B\u5F00\u542F\u540E\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u4F1A\u8BDD\u5373\u751F\u6548\u2014\u2014\u81EA\u52A8\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F + \u6062\u590D\u4E0A\u6B21\u4F1A\u8BDD\uFF1B\u5173\u95ED\u5219\u9700\u624B\u52A8\u6309 Ctrl+Shift+V \u91CD\u65B0\u8FDB\u5165\uFF09",
1484
1672
  descSpokenFormat: "\u8BED\u97F3\u4F1A\u8BDD\u6CE8\u5165\u53E3\u8BED\u5316\u63D0\u793A\u8BCD\uFF08\u56DE\u590D\u53E3\u8BED\u5316\u3001\u77ED\u53E5\u3001\u4E0D\u7528 Markdown \u6392\u7248\u7B26\u53F7\uFF0C\u6717\u8BFB\u66F4\u987A\u66F4\u5FEB\uFF1B\u9ED8\u8BA4\u5F00\uFF0C\u6539\u52A8\u5373\u65F6\u751F\u6548\uFF09",
1485
- descSenseVoice: "\u5B9A\u7A3F\u7528 SenseVoice \u91CD\u8BD1\uFF08\u5E26\u6807\u70B9 + \u6570\u5B57\u5F52\u4E00\u5316\u3001\u8BC6\u522B\u66F4\u51C6\uFF1B\u9ED8\u8BA4\u5F00\u3002\u5173\u95ED\u53EF\u7701 228MB \u6A21\u578B\uFF0C\u53EA\u8D70\u6D41\u5F0F\u8BC6\u522B\uFF09",
1673
+ descSenseVoice: "\u8BC6\u522B\u6A21\u5F0F\uFF1A\u5F00 = \u51C6\u786E\u6A21\u5F0F\uFF08SenseVoice \u5B9A\u7A3F\uFF0C\u5E26\u6807\u70B9+\u6570\u5B57\u5F52\u4E00\u5316\uFF0C\u957F\u53E5\u5728 CPU \u4E0A\u53EF\u80FD\u7B49\u6570\u79D2\uFF09\uFF1B\u5173 = \u5FEB\u901F\u6A21\u5F0F\uFF08\u6D41\u5F0F\u7ED3\u679C\u76F4\u63A5\u5B9A\u7A3F\uFF0C\u4E0D\u7B49 228MB \u91CD\u8BD1\u6A21\u578B\uFF0C\u51C6\u786E\u5EA6\u7565\u964D\uFF09",
1674
+ recognizingSec: "\u8BC6\u522B\u4E2D\u2026 {sec}s",
1486
1675
  descToolBeep: '\u5DE5\u5177\u8C03\u7528\u63D0\u793A\u97F3\uFF08\u9ED8\u8BA4\u5173\uFF09\uFF1AAI \u601D\u8003/\u8C03\u7528\u5DE5\u5177\u65F6"\u6EF4"\u4E00\u58F0\uFF1B\u5ACC\u5435\u5C31\u4FDD\u6301\u5173\u95ED',
1487
- senseITN: "\u9006\u6587\u672C\u5F52\u4E00\u5316",
1488
1676
  descSenseITN: "SenseVoice \u6570\u5B57/\u65E5\u671F/\u683C\u5F0F\u89C4\u8303\u5316\uFF08\u9ED8\u8BA4\u5F00\uFF1B\u5173\u95ED\u540E\u8F93\u51FA\u66F4\u63A5\u8FD1\u53E3\u8BED\u539F\u6587\uFF09",
1489
1677
  descCaptionFontSize: "\u6D6E\u5C42\u5B57\u5E55\u5B57\u53F7\u6863\u4F4D\uFF08\u5C0F 12 / \u6807\u51C6 14 / \u5927 18 / \u7279\u5927 24 px\uFF1B\u9ED8\u8BA4\u5C0F\u4E0E\u73B0\u72B6\u5B57\u8282\u7B49\u4EF7\uFF09",
1490
1678
  descCaptionMaxWidth: "\u6D6E\u5C42\u5B57\u5E55\u5BBD\u5EA6\u6863\u4F4D\uFF0850vw / 70vw / 90vw\uFF1B\u9ED8\u8BA4 70vw\uFF1B24px \u591A\u884C\u65F6\u53D7 30vh \u9AD8\u5EA6\u7EA6\u675F\u4E0D\u76D6\u8F93\u5165\u6846\uFF09",
@@ -1495,19 +1683,37 @@ var zh = {
1495
1683
  captionWidth50: "\u7A84",
1496
1684
  captionWidth70: "\u4E2D",
1497
1685
  captionWidth90: "\u5BBD",
1498
- skipReading: "\u8DF3\u8FC7\u5F53\u524D\u6717\u8BFB",
1499
- backchannelYield: "\u77ED\u5E94\u7B54\u8BA9\u4F4D",
1500
- descBackchannelYield: "\u6717\u8BFB\u671F\u7528\u6237\u8BF4\u300C\u55EF/\u5BF9\u300D\u7B49\u77ED\u5E94\u7B54\u65F6\u81EA\u52A8\u8BA9\u4F4D\uFF08\u8DF3\u8FC7\u5F53\u524D TTS \u53E5 + \u77ED\u6682\u4E22\u5E27 1.5s\uFF1B\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF1B\u5173 = \u4E0D\u8BA9\u4F4D\uFF0C\u884C\u4E3A\u7B49\u540C\u6539\u9020\u524D\uFF09",
1501
- // 批 G 任务 3:让位窗口时长(500-3000ms,默认 1500)。
1502
- yieldMs: "\u8BA9\u4F4D\u7A97\u53E3",
1503
- descYieldMs: "\u8BA9\u4F4D\u8BED\u4E49\u89E6\u53D1\u540E\u7B49\u5F85\u65F6\u957F\uFF08\u6BEB\u79D2\uFF0C500-3000\uFF0C\u9ED8\u8BA4 1500\uFF1B\u7A97\u53E3\u5185\u7528\u6237\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF0C\u7A97\u53E3\u5230\u70B9\u81EA\u52A8\u6062\u590D\u64AD\u653E\uFF09",
1504
- descMode: "\u4EA4\u4E92\u6A21\u5F0F\uFF08toggle \u6301\u7EED\u8046\u542C+\u9759\u97F3\u65AD\u53E5 / hold \u6309\u4F4F\u8BF4\u8BDD\uFF09",
1686
+ // 跳过按钮:只跳当前 TTS 句(非整段朗读)——UX 审查歧义修正。
1687
+ skipReading: "\u8DF3\u8FC7\u672C\u53E5",
1688
+ descBackchannelYield: "\u6717\u8BFB\u671F\u7528\u6237\u8BF4\u300C\u55EF/\u5BF9\u300D\u7B49\u77ED\u5E94\u7B54\u65F6\u81EA\u52A8\u8BA9\u4F4D\uFF08\u8DF3\u8FC7\u5F53\u524D TTS \u53E5 + \u77ED\u6682\u4E22\u5E27 1.5s\uFF1B\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF1B\u5173 = \u4E0D\u8BA9\u4F4D\uFF0C\u884C\u4E3A\u7B49\u540C\u6539\u9020\u524D\uFF09\u3002\u4EC5\u300C\u6309\u4F4F\u8BF4\u8BDD\u300D\u6A21\u5F0F\u64AD\u653E\u671F\u53EF\u89E6\u53D1\uFF1A\u300C\u6301\u7EED\u8046\u542C\u300D\u6A21\u5F0F\u64AD\u653E\u671F\u4E0D\u8BC6\u522B\u8BED\u97F3\uFF0C\u5F00\u53E3\u8BF4\u8BDD\u6309\u6253\u65AD\u5904\u7406",
1689
+ // Issue #15 批 1 / ADR-0012:打断语音抢救。
1690
+ descBargeInSalvage: "AI \u6717\u8BFB\u65F6\u4F60\u5F00\u53E3\u6253\u65AD\uFF1A\u81EA\u52A8\u4FDD\u7559\u4ECE\u5F00\u53E3\u5230\u6253\u65AD\u751F\u6548\u4E4B\u95F4\u4F60\u8BF4\u7684\u8BDD\uFF0C\u5E76\u5165\u8BC6\u522B\u7EE7\u7EED\u53D1\u9001\uFF08\u4FEE\u300C\u6253\u65AD\u5403\u53E5\u300D\uFF1B\u5173 = \u4E22\u5F03\u6253\u65AD\u524D\u8BED\u97F3\u2014\u2014\u4EC5\u5916\u653E\u4E14\u65E0\u56DE\u58F0\u6D88\u9664\u7684\u73AF\u5883\u5EFA\u8BAE\u5173\uFF09",
1691
+ descLlmCorrect: "\u53D1\u9001\u524D\u7528\u5927\u6A21\u578B\u5BF9\u6574\u6761\u8BED\u97F3\u6587\u672C\u505A\u4E00\u6B21\u7EA0\u9519\uFF08\u53EA\u6539\u9519\u522B\u5B57/\u540C\u97F3\u5B57/\u6807\u70B9\uFF0C\u4FDD\u6301\u539F\u610F\uFF1B\u9700\u5BBF\u4E3B\u5DF2\u914D\u7F6E\u9ED8\u8BA4\u6A21\u578B\uFF0C\u672A\u914D\u7F6E\u5219\u81EA\u52A8\u7528\u539F\u6587\uFF09\u3002\u5F00 = \u6BCF\u6761\u6D88\u606F\u591A\u4E00\u6B21\u7EA0\u9519\u7B49\u5F85\uFF1A\u901A\u5E38 1 \u79D2\u5185\uFF0C\u6700\u957F\u7EA6 10 \u79D2\uFF1B\u6BCF\u5206\u949F\u6700\u591A 10 \u6B21\uFF0C\u8BED\u97F3\u6A21\u5F0F\u5173\u95ED\u6216\u89E6\u53D1\u9650\u6D41\u65F6\u6309\u539F\u6587\u53D1\u9001\u3002\u7EA0\u9519\u5931\u8D25\u6216\u8F93\u51FA\u5F02\u5E38\u540C\u6837\u81EA\u52A8\u7528\u539F\u6587",
1692
+ descYieldMs: "\u8BA9\u4F4D\u8BED\u4E49\u89E6\u53D1\u540E\u7B49\u5F85\u65F6\u957F\uFF08\u6BEB\u79D2\uFF0C500-3000\uFF0C\u9ED8\u8BA4 1500\uFF1B\u7A97\u53E3\u5185\u7528\u6237\u771F\u8981\u8BF4\u5219\u539F hardBreak \u63A5\u7BA1\uFF0C\u7A97\u53E3\u5230\u70B9\u81EA\u52A8\u6062\u590D\u64AD\u653E\uFF09\u3002\u4EC5\u300C\u6309\u4F4F\u8BF4\u8BDD\u300D\u6A21\u5F0F\u64AD\u653E\u671F\u53EF\u89E6\u53D1",
1693
+ descMode: "\u4EA4\u4E92\u6A21\u5F0F\uFF08toggle \u6301\u7EED\u8046\u542C+\u9759\u97F3\u65AD\u53E5 / hold \u6309\u4F4F\u8BF4\u8BDD / once \u8BF4\u5B8C\u4E00\u6BB5\u3001\u7B49\u56DE\u590D\u6717\u8BFB\u5B8C\u518D\u81EA\u52A8\u9000\u51FA\uFF09",
1505
1694
  modeToggle: "\u6301\u7EED\u8046\u542C",
1506
1695
  modeHold: "\u6309\u4F4F\u8BF4\u8BDD",
1507
- descWakeWord: "\u5524\u9192\u8BCD\uFF08\u9ED8\u8BA4\u5173\uFF1B\u5982\u300C\u4F60\u597D\u5C0FD\u300D\uFF09\uFF1A\u8BF4\u51FA\u8BCD\u5934\u624D\u8FDB\u5165\u8BC6\u522B\uFF0C\u907F\u514D\u8BEF\u89E6\u3002\u53EF\u4E0E\u547D\u4EE4\u8FDE\u8BF4\uFF08\u300C\u4F60\u597D\u5C0FD\uFF0C\u5E2E\u6211\u67E5\u5929\u6C14\u300D\u2014\u2014\u8BCD\u5934\u4F1A\u81EA\u52A8\u5265\u6389\u3001\u4E0D\u8FDB\u6D88\u606F\uFF09\uFF1B\u6BCF\u53E5\u65AD\u53E5\u6216\u6253\u65AD\u540E\u9700\u91CD\u8BF4\uFF1B\u4EC5 toggle \u6A21\u5F0F\u751F\u6548\uFF08hold / \u624B\u52A8\u6253\u65AD\u4E0B\u4E0D\u751F\u6548\uFF09\uFF1B\u6717\u8BFB\u671F\u8BF4\u5524\u9192\u8BCD\u4E0D\u89E6\u53D1\uFF08\u6253\u65AD\u4ECD\u6309 VAD \u5F00\u53E3\u5373\u6253\u65AD\uFF09\u3002\u5339\u914D\u5E26\u5BB9\u9519\uFF08\u540C\u97F3\u5B57 / \u524D\u5BFC\u8BED\u6C14\u8BCD\uFF09\uFF0C\u5EFA\u8BAE 3-4 \u5B57\uFF1B\u975E\u4E13\u7528 KWS \u5F15\u64CE\uFF0C\u5608\u6742\u73AF\u5883\u53EF\u80FD\u5EF6\u8FDF\u6216\u8BEF\u6FC0\u6D3B",
1696
+ modeOnce: "\u8BF4\u5B8C\u5C31\u5173",
1697
+ stopReading: "\u505C\u6B62\u6717\u8BFB",
1698
+ readAloudLabel: "\u6717\u8BFB\u56DE\u590D",
1699
+ readAloudVoice: "\u8BED\u97F3\u6A21\u5F0F",
1700
+ readAloudAlways: "\u603B\u662F",
1701
+ readAloudOff: "\u5173\u95ED",
1702
+ descReadAloud: "\u8BED\u97F3\u6A21\u5F0F=\u53EA\u5728\u8BED\u97F3\u6A21\u5F0F\u91CC\u6717\u8BFB\uFF08\u9ED8\u8BA4\uFF09\uFF1B\u603B\u662F=\u5F53\u524D\u4F1A\u8BDD\u7684\u6BCF\u6761\u56DE\u590D\u90FD\u6717\u8BFB\uFF08\u542B\u6253\u5B57\u53D1\u9001\u7684\uFF09\uFF1B\u5173\u95ED=\u4ECE\u4E0D\u6717\u8BFB",
1703
+ showCaptionsLabel: "\u5B57\u5E55\u6D6E\u5C42",
1704
+ descShowCaptions: "\u6717\u8BFB\u65F6\u5728\u53F3\u4E0B\u89D2\u663E\u793A\u5F53\u524D\u53E5\u5B50\u7684\u5B57\u5E55\u6D6E\u5C42",
1705
+ showStatusBarLabel: "\u72B6\u6001\u6761",
1706
+ descShowStatusBar: "\u5728\u8F93\u5165\u6846\u4E0A\u65B9\u663E\u793A\u8BED\u97F3\u72B6\u6001\u6761\uFF08\u6CE2\u5F62\u3001\u8BC6\u522B\u6587\u5B57\u3001\u8BA1\u65F6\u3001\u63D0\u793A\u3001\u9000\u51FA\uFF09\uFF1B\u5173\u95ED\u540E\u72B6\u6001\u53EA\u5728\u9EA6\u514B\u98CE\u6309\u94AE\u4E0A\u663E\u793A",
1707
+ descWakeWord: "\u5524\u9192\u8BCD\uFF08\u9ED8\u8BA4\u5173\uFF1B\u5982\u300C\u4F60\u597D\u5C0FD\u300D\uFF09\uFF1A\u8BF4\u51FA\u8BCD\u5934\u624D\u8FDB\u5165\u8BC6\u522B\uFF0C\u907F\u514D\u8BEF\u89E6\u3002\u53EF\u4E0E\u547D\u4EE4\u8FDE\u8BF4\uFF08\u300C\u4F60\u597D\u5C0FD\uFF0C\u5E2E\u6211\u67E5\u5929\u6C14\u300D\u2014\u2014\u8BCD\u5934\u4F1A\u81EA\u52A8\u5265\u6389\u3001\u4E0D\u8FDB\u6D88\u606F\uFF09\uFF1B\u6BCF\u53E5\u65AD\u53E5\u6216\u6253\u65AD\u540E\u9700\u91CD\u8BF4\uFF1B\u4EC5 toggle \u6A21\u5F0F\u751F\u6548\uFF08hold / \u624B\u52A8\u6253\u65AD\u4E0B\u4E0D\u751F\u6548\uFF1Bdetect \u81EA\u52A8\u63A2\u6D4B\u672A\u751F\u6548\u3001\u56DE\u843D manual \u65F6\u540C\u6837\u4E0D\u751F\u6548\u2014\u2014Safari \u7B49\u65E0\u539F\u751F\u56DE\u58F0\u6D88\u9664\u7684\u673A\u5668\u4F1A\u9ED8\u8BA4\u843D\u5230\u8FD9\u4E00\u6863\uFF09\uFF1B\u6717\u8BFB\u671F\u8BF4\u5524\u9192\u8BCD\u4E0D\u89E6\u53D1\uFF08\u6253\u65AD\u4ECD\u6309 VAD \u5F00\u53E3\u5373\u6253\u65AD\uFF09\u3002\u5339\u914D\u5E26\u5BB9\u9519\uFF08\u540C\u97F3\u5B57 / \u524D\u5BFC\u8BED\u6C14\u8BCD\uFF09\uFF0C\u5EFA\u8BAE 3-4 \u5B57\uFF1B\u975E\u4E13\u7528 KWS \u5F15\u64CE\uFF0C\u5608\u6742\u73AF\u5883\u53EF\u80FD\u5EF6\u8FDF\u6216\u8BEF\u6FC0\u6D3B",
1508
1708
  wakePlaceholder: "\u5982\uFF1A\u4F60\u597D\u5C0FD",
1509
- settingsCardDesc: "\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / \u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u9759\u97F3\u505C\u987F / \u7A7A\u95F2\u8D85\u65F6 / \u6A21\u578B\u955C\u50CF / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3 / \u9006\u6587\u672C\u5F52\u4E00\u5316 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3",
1510
- settingsEffectiveNote: "\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / \u6A21\u578B\u7CBE\u5EA6 / \u53E3\u8BED\u5316\u63D0\u793A\u8BCD / \u91CD\u8BD1 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3 \u5373\u65F6\u751F\u6548\uFF1B\u9006\u6587\u672C\u5F52\u4E00\u5316 \u5373\u65F6\u751F\u6548\uFF08\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u91CD\u5EFA\u6D41\u5F0F\u8BC6\u522B\u5668\uFF09\uFF1B\u5176\u4F59\uFF08\u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u5FEB\u6377\u952E / \u9759\u97F3 / \u7A7A\u95F2 / \u955C\u50CF / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3\uFF09\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u65F6\u751F\u6548\u3002",
1709
+ settingsCardDesc: "\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / \u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u9759\u97F3\u505C\u987F / \u7A7A\u95F2\u8D85\u65F6 / \u6A21\u578B\u955C\u50CF / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3 / \u9006\u6587\u672C\u5F52\u4E00\u5316 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3 / \u6253\u65AD\u8BED\u97F3\u62A2\u6551 / LLM \u7EA0\u9519",
1710
+ settingsEffectiveNote: "\u751F\u6548\u65F6\u673A\u5206\u56DB\u6863\uFF1A\u2460 \u5373\u65F6\u2014\u2014\u6717\u8BFB\u5F15\u64CE / \u97F3\u8272 / \u8BED\u901F / Kokoro \u6A21\u578B\u7CBE\u5EA6\uFF08\u5DF2\u7F13\u5B58\u5219\u5373\u65F6\uFF0C\u5426\u5219\u4E0B\u6B21\u4E0B\u8F7D\uFF09/ \u53E3\u8BED\u5316\u63D0\u793A\u8BCD\uFF08\u5BF9\u540E\u7EED\u56DE\u590D\u751F\u6548\uFF09/ \u6717\u8BFB\u56DE\u590D / \u72B6\u6001\u6761 / \u5B57\u5E55\u6D6E\u5C42 / \u6A21\u578B\u955C\u50CF\uFF08\u4E0B\u6B21\u4E0B\u8F7D\u5C1D\u8BD5\u5373\u751F\u6548\uFF09\uFF1B\u2461 \u4E0B\u6B21\u8BC6\u522B\u65F6\u2014\u2014\u5B9A\u7A3F\u91CD\u8BD1\uFF08SenseVoice\uFF09/ \u9006\u6587\u672C\u5F52\u4E00\u5316\uFF1B\u2462 \u4E0B\u4E00\u6BB5\u8BDD\u2014\u2014\u9759\u97F3\u5224\u5B9A\u65F6\u957F\uFF08\u65AD\u53E5\u7AEF\u70B9\uFF1B\u53D1\u9001\u7B49\u5F85\u56FA\u5B9A 1.2 \u79D2\u4E0D\u53D7\u5F71\u54CD\uFF09\uFF1B\u2463 \u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u2014\u2014\u6253\u65AD\u7075\u654F\u5EA6 / \u6253\u65AD\u65B9\u5F0F / \u56DE\u58F0\u95E8\u63A7 / \u5FEB\u6377\u952E / \u81EA\u52A8\u53D1\u9001 / \u81EA\u52A8\u6062\u590D / \u4EA4\u4E92\u6A21\u5F0F / \u5524\u9192\u8BCD / \u5DE5\u5177\u63D0\u793A\u97F3 / \u5B57\u5E55\u5B57\u53F7 / \u5B57\u5E55\u5BBD\u5EA6 / \u77ED\u5E94\u7B54\u8BA9\u4F4D / \u8BA9\u4F4D\u7A97\u53E3 / \u6253\u65AD\u8BED\u97F3\u62A2\u6551 / LLM \u7EA0\u9519 / \u7A7A\u95F2\u65F6\u957F\u3002\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u624D\u751F\u6548\u7684\u9879\u4F1A\u5217\u5728\u5361\u7247\u9876\u90E8\uFF08\u542B\u5F53\u524D\u751F\u6548\u503C\uFF09\u3002",
1711
+ effectivePending: "\u6709 {count} \u9879\u4FEE\u6539\u5C06\u5728\u4E0B\u6B21\u8FDB\u5165\u8BED\u97F3\u6A21\u5F0F\u65F6\u751F\u6548\uFF1A{items}",
1712
+ valueOn: "\u5F00",
1713
+ valueOff: "\u5173",
1714
+ valueQuoted: "\u300C{value}\u300D",
1715
+ effectiveItem: "{label}\uFF08\u5F53\u524D\u751F\u6548 {value}\uFF09",
1716
+ effectiveItemSep: "\u3001",
1511
1717
  configUnavailable: "\u914D\u7F6E\u6682\u4E0D\u53EF\u7528",
1512
1718
  // telemetry(P1-5 开发模式延迟埋点状态条:各段耗时标签)
1513
1719
  telUtteranceEnd: "\u8BF4\u5B8C",
@@ -1544,7 +1750,6 @@ var zh = {
1544
1750
  ttsDownloadHint: "\u4E0B\u8F7D\u8BE5\u5F15\u64CE\u7684\u672C\u5730\u6A21\u578B\uFF1B\u4E0B\u8F7D\u5B8C\u6210\u540E\u7ACB\u5373\u5C31\u7EEA\uFF0C\u53EF\u8BD5\u542C/\u6717\u8BFB",
1545
1751
  ttsDeleteHint: "\u5220\u9664\u672C\u5730\u6A21\u578B\uFF08\u91CA\u653E\u7A7A\u95F4\uFF1B\u4E0B\u6B21\u4F7F\u7528\u4F1A\u81EA\u52A8\u91CD\u65B0\u4E0B\u8F7D\uFF09",
1546
1752
  dataFlowHint: "\u6570\u636E\u6D41\u5411\uFF1AASR \u8BC6\u522B\uFF08zipformer2+SenseVoice\uFF09\u59CB\u7EC8\u672C\u5730\uFF1BTTS \u6717\u8BFB\u53D6\u51B3\u4E8E\u5F15\u64CE\uFF08edge=\u5FAE\u8F6F\u4E91\u7AEF\uFF0Cvits/kokoro=\u672C\u5730\uFF09",
1547
- kokoroModel: "Kokoro \u6A21\u578B\u7CBE\u5EA6",
1548
1753
  kokoroModelInt8: "int8\uFF08\u9ED8\u8BA4\uFF09",
1549
1754
  kokoroModelFp32: "fp32\uFF08\u97F3\u8D28\u66F4\u597D\uFF09",
1550
1755
  descKokoroModel: "Kokoro \u6A21\u578B\u7CBE\u5EA6\uFF1Aint8 \u4F53\u79EF\u5C0F/\u52A0\u8F7D\u5FEB\uFF08\u7EAF CPU \u670D\u52A1\u5668\u6216\u4F4E\u5E26\u5BBD\u63A8\u8350\uFF0C\u9ED8\u8BA4\uFF09\uFF1Bfp32 \u97F3\u8D28\u66F4\u597D\u4F46\u7EA6 311MB\u3001\u66F4\u6162\uFF08\u6709\u72EC\u7ACB\u663E\u5361\u6216\u5927\u5185\u5B58\u673A\u5668\u63A8\u8350\uFF09\u3002\u4E24\u6863\u5171\u7528\u540C\u4E00\u5957 103 \u97F3\u8272\uFF0C\u5207\u6362\u5373\u65F6\u751F\u6548\u3002",
@@ -1555,14 +1760,17 @@ var zh = {
1555
1760
  secRecognition: "\u8BC6\u522B\u4E0E\u53E3\u8BED",
1556
1761
  secModel: "\u6A21\u578B\u4E0E\u955C\u50CF",
1557
1762
  telTotal: "\u5408\u8BA1",
1558
- // 批 C:FIELD_LABELS 镜像键(*Label 后缀;详见 settings-form.tsx 头部注释)。
1559
- // 临时双轨——与 FIELD_LABELS 并行维护同一组中文,未来整合批去掉 FIELD_LABELS,
1560
- // 统一改用 tr() 翻译键模式避免双轨漂移风险。en 段对应 stub 见下方 en 对象。
1763
+ // 字段标题镜像键(*Label 后缀):设置行标题经 settings-form 的 tr(`${name}Label`) 取值。
1764
+ // 批 C 曾与 settings-form 的 FIELD_LABELS 中文双轨并行;整合批已删 FIELD_LABELS,
1765
+ // *Label 键现在是行标题唯一真源(R1 M-2:孪生 base 键已删,防双轨漂移复发)。
1561
1766
  senseITNLabel: "\u9006\u6587\u672C\u5F52\u4E00\u5316",
1562
1767
  captionFontSizeLabel: "\u5B57\u5E55\u5B57\u53F7",
1563
1768
  captionMaxWidthLabel: "\u5B57\u5E55\u5BBD\u5EA6",
1564
1769
  backchannelYieldLabel: "\u77ED\u5E94\u7B54\u8BA9\u4F4D",
1565
- // 批 G 任务 3:让位窗口(FIELD_LABELS.yieldMs 镜像键,*Label 后缀)。
1770
+ // Issue #15 批 1 / ADR-0012:打断语音抢救(行标题键)。
1771
+ bargeInSalvageLabel: "\u6253\u65AD\u8BED\u97F3\u62A2\u6551",
1772
+ llmCorrectLabel: "LLM \u7EA0\u9519",
1773
+ // 让位窗口(行标题键)。
1566
1774
  yieldMsLabel: "\u8BA9\u4F4D\u7A97\u53E3",
1567
1775
  // 批 G 任务 2:空闲预警 + 退出提示文案。
1568
1776
  idleWarn30s: "30 \u79D2\u540E\u81EA\u52A8\u9000\u51FA\uFF08\u8BBE\u7F6E\u91CC\u53EF\u8C03\u7A7A\u95F2\u65F6\u957F\uFF09",
@@ -1638,17 +1846,23 @@ var en = {
1638
1846
  disabled: "Voice mode disabled (plugin enabled=false)",
1639
1847
  sendFailKept: "Send failed; text kept in draft",
1640
1848
  micDenied: "Microphone denied: allow mic access for this site",
1849
+ micBusy: "Microphone is in use by another program \u2014 close it and retry",
1641
1850
  micUnavailable: "Microphone unavailable",
1642
1851
  recognizing: "Recognizing\u2026",
1852
+ // UX-I1 联动态:纠错在途 / 纠错放弃回退 / 附和词忽略 / 语音按钮态文案。
1853
+ correctFixing: "Correcting\u2026",
1854
+ correctAbandoned: "Original text kept in draft",
1855
+ backchannelDropped: "Backchannel ignored, not sent",
1856
+ buttonLoading: "Loading\u2026",
1857
+ buttonListening: "Listening",
1643
1858
  holdToTalk: "Hold to talk",
1644
1859
  releaseToSend: "Release to send",
1645
- voiceDetected: "Voice active",
1646
1860
  entering: "Entering\u2026",
1647
1861
  voiceBtn: "Voice",
1648
1862
  ariaActive: "Voice mode active",
1649
1863
  ariaEnter: "Enter voice mode",
1650
1864
  titleHold: "Voice mode \xB7 hold to talk, release to send; tap to exit; Esc/blur cancels; Ctrl+Shift+V exits",
1651
- titleToggle: "Voice mode \xB7 click to exit (Ctrl+Shift+V) \xB7 hold Ctrl to send now",
1865
+ titleToggle: "Voice mode \xB7 click to exit (Ctrl+Shift+V) \xB7 hold Ctrl while speaking to send now",
1652
1866
  titleEnter: "Enter voice mode (Ctrl+Shift+V)",
1653
1867
  loadingModel: "Loading model\u2026",
1654
1868
  listening: "Listening\u2026",
@@ -1659,13 +1873,18 @@ var en = {
1659
1873
  sayWake: 'Say "{wake}" to start',
1660
1874
  reading: "Reading aloud\u2026",
1661
1875
  recognitionFail: "Recognition failed, try again",
1876
+ partialFail: "Live captions temporarily unavailable (recognition channel error, retrying)",
1877
+ detectFail: "Break-in detection temporarily unavailable (detect channel error, retrying)",
1878
+ sseReconnect: "State sync disconnected, reconnecting\u2026",
1879
+ diagCopy: "Copy diagnostics",
1880
+ diagCopied: "Diagnostics copied",
1881
+ diagCopyFailed: "Copy failed (clipboard rejected by browser)",
1662
1882
  sessionExpired: "Voice session expired, reconnecting\u2026",
1663
1883
  sessionExpiredFail: "Voice session reconnect failed; please re-enter voice mode",
1664
1884
  modelDownloadFail: "Model download failed ({file}): check network and re-enter voice mode",
1665
1885
  startFail: "Voice mode failed to start: {err}",
1666
1886
  holdDots: "Hold to talk\u2026",
1667
1887
  exit: "Exit",
1668
- skip: "Skip",
1669
1888
  configUnavailableNote: " (settings document not ready; the panel will appear when it is).",
1670
1889
  previewNameFirst: "Enter a voice ShortName first",
1671
1890
  previewDisabled: "Voice mode disabled (plugin enabled=false); preview unavailable",
@@ -1692,7 +1911,7 @@ var en = {
1692
1911
  descVoiceKokoro: "Kokoro zh-en voices (103; \u25C0\u25B6 to cycle; 48-51 named Chinese, others numbered with measured gender; mixed zh-en supported)",
1693
1912
  descRate: "Speech rate (0.5 slow \u2013 2.0 fast, 1.1 default; more compact replies)",
1694
1913
  descInterrupt: "Interrupt sensitivity (0 high \u22480.3 s confirm / 1 medium \u22480.2 s / 2 low \u22480.1 s, most responsive); lower = higher barrier = harder to interrupt",
1695
- descBargeIn: "Barge-in mode (detect: auto-probe native echo cancellation, fall back to hold-to-talk when inactive \u2014 default; auto: force interrupt by speaking \u2014 headphones/quiet; manual: for loudspeaker, no echo-triggered self-interrupt \u2014 hold mic/Ctrl to interrupt)",
1914
+ descBargeIn: "Barge-in mode (detect: auto-probe native echo cancellation, fall back to hold-to-talk when inactive \u2014 default; auto: force interrupt by speaking \u2014 headphones/quiet; manual: for loudspeaker, no echo-triggered self-interrupt \u2014 hold mic/Ctrl to interrupt). Note: in manual mode (including detect falling back to manual on machines without native echo cancellation) audio outside a press is not recognized \u2014 in toggle mode you can long-press to speak only while the agent is playing; when idle there is no voice input, so use hold mode or switch to auto/detect",
1696
1915
  bargeInDetect: "Auto-detect",
1697
1916
  bargeInAuto: "Auto",
1698
1917
  bargeInManual: "Manual",
@@ -1703,22 +1922,29 @@ var en = {
1703
1922
  aecOffHint: "Native echo cancellation is not active (speaker echo may self-interrupt); use headphones or Manual barge-in",
1704
1923
  // 批 7O(ADR-0006):detect 模式第一级探测降级提示(英文)。
1705
1924
  bargeInDetectFallback: "Native echo cancellation is off \u2014 switched to hold-to-talk barge-in",
1925
+ // R1 收尾(fix-client 直连 tk() 调用):连续 3 次回声拒断的解释出口 + 快捷键非法停用提示。
1926
+ echoRejectHint: "Strong echo detected \u2014 barge-in is limited by echo protection. Use headphones or switch to manual barge-in",
1927
+ shortcutInvalid: "Invalid shortcut, disabled. Fix it in settings (e.g. Ctrl+Shift+V); leave empty to use the mic button only",
1706
1928
  elapsedHint: "Current voice session duration",
1707
1929
  botLevelsHint: "AI playback level (blue bar = TTS playback, green bar = microphone)",
1708
1930
  interruptConfirm: "interrupt confirm",
1709
1931
  sev0: "0 high",
1710
1932
  sev1: "1 medium",
1711
1933
  sev2: "2 low",
1934
+ // 数值单位(设置卡片「当前生效值」用:中文汉字单位、英文国际缩写,避免「1500 ms」直出)
1935
+ unitMs: "ms",
1936
+ unitMin: "min",
1937
+ unitDb: "dB",
1712
1938
  descSilence: "Silence pause before a sentence is committed (default 1500 ms; at least 250 ms of speech required, guards against noise triggers)",
1713
- descIdle: "Auto-exit voice mode after idle minutes (default 5; batch G added 30 s warning before exit)",
1939
+ descIdle: "Auto-exit voice mode after idle minutes (default 5; a 30-second countdown warning appears before exit)",
1714
1940
  descModelHost: "ASR model download source (official source / mirror, or any custom URL)",
1715
- descAutoSend: "Auto-send once quiet (consecutive segments join into one message; off = draft only; Ctrl / hold still sends)",
1941
+ descAutoSend: "Auto-send once quiet (consecutive segments join into one message; off = draft only; holding Ctrl while speaking sends immediately; in hold mode, releasing sends)",
1716
1942
  // 批 7N 重做 5/5:clarify that toggling takes effect on next session entry (not the current one).
1717
1943
  descAutoResume: "Auto-resume voice mode when switching back to the last voice session (default off; takes effect on next session entry \u2014 auto-enters voice mode and restores the last session; when disabled, you must press Ctrl+Shift+V to re-enter)",
1718
1944
  descSpokenFormat: "Inject spoken-format prompt into voice replies (colloquial, short sentences, no Markdown; default on, live)",
1719
- descSenseVoice: "Re-transcribe the finalized utterance with SenseVoice (punctuation + ITN, more accurate; default on \u2014 turn off to skip the 228 MB model and keep streaming only)",
1945
+ descSenseVoice: "Recognition mode: on = accurate mode (SenseVoice finalization with punctuation + ITN; long utterances may take seconds on CPU); off = fast mode (streaming result finalized directly, skips the 228 MB re-transcription model, slightly less accurate)",
1946
+ recognizingSec: "Recognizing\u2026 {sec}s",
1720
1947
  descToolBeep: "Tool-call beep (default off): beep when the agent is thinking/calling tools; keep off if it annoys you",
1721
- senseITN: "Inverse text normalization",
1722
1948
  descSenseITN: "SenseVoice number/date/format normalization (default on; turn off to keep raw spoken form)",
1723
1949
  descCaptionFontSize: "Caption font size (Small 12 / Standard 14 / Large 18 / X-Large 24 px; default Small matches current behavior)",
1724
1950
  descCaptionMaxWidth: "Caption width (50vw / 70vw / 90vw; default 70vw; capped at 30vh height so multi-line 24px never overlaps the input box)",
@@ -1729,19 +1955,36 @@ var en = {
1729
1955
  captionWidth50: "Narrow",
1730
1956
  captionWidth70: "Medium",
1731
1957
  captionWidth90: "Wide",
1732
- skipReading: "Skip current reading",
1733
- backchannelYield: "Short-reply yielding",
1734
- descBackchannelYield: 'When the user says a short answer like "mm-hmm/right" while the agent is reading aloud, yield automatically (skip the current TTS sentence + drop frames for 1.5s; if the user really wants to speak, the existing hardBreak takes over; off = no yielding, behavior matches pre-batch-5)',
1735
- // 批 G 任务 3:让位窗口时长(500-3000ms,默认 1500)。
1736
- yieldMs: "Yield window",
1737
- descYieldMs: "How long (ms) to drop frames after a yield trigger (500-3000, default 1500; within the window the existing hardBreak takes over if the user really wants to speak; auto-resume after the window expires)",
1738
- descMode: "Interaction mode (toggle: continuous listen + auto-send / hold: press to talk)",
1958
+ skipReading: "Skip this sentence",
1959
+ descBackchannelYield: 'When the user says a short answer like "mm-hmm/right" while the agent is reading aloud, yield automatically (skip the current TTS sentence + drop frames for 1.5s; if the user really wants to speak, the existing hardBreak takes over; off = no yielding, behavior matches before this change). Only triggers in hold-to-talk mode: in continuous-listening mode speech is not recognized during playback (speaking is treated as an interrupt)',
1960
+ // Issue #15 batch 1 / ADR-0012: barge-in speech salvage.
1961
+ descBargeInSalvage: "When you speak to interrupt while the agent is reading aloud, keep what you said from speech onset to break confirmation and merge it into recognition (fixes swallowed break-in speech; off = discard pre-break audio; recommended off only on speakers without echo cancellation)",
1962
+ descLlmCorrect: "Before sending, run one LLM pass over the whole transcribed text (typos/homophones/punctuation only, meaning preserved; requires a default model configured in the host \u2014 otherwise the original text is sent as-is). On = one extra correction round trip per message: usually under 1 second, at most ~10 seconds; at most 10 times per minute \u2014 when voice mode is off or the limit is hit, the original text is sent. Failed or abnormal output also falls back to the original text",
1963
+ descYieldMs: "How long (ms) to drop frames after a yield trigger (500-3000, default 1500; within the window the existing hardBreak takes over if the user really wants to speak; auto-resume after the window expires). Hold-to-talk mode only, during playback",
1964
+ descMode: "Interaction mode (toggle: continuous listen + auto-send / hold: press to talk / once: one utterance, then exit after the reply is read aloud)",
1739
1965
  modeToggle: "Continuous listening",
1740
1966
  modeHold: "Hold to talk",
1741
- descWakeWord: 'Wake word (default off; e.g. "Hey D"): recognition starts only after you say it, to avoid accidental triggers. You may say it together with your command ("Hey D, check the weather" \u2014 the wake word is stripped and never sent); it must be repeated after each utterance split or barge-in; toggle mode only (inactive in hold / manual barge-in); saying it while the agent is reading does not trigger (barge-in stays VAD-based). Fault-tolerant matching (homophones / leading fillers); 3-4 characters recommended; not a dedicated KWS engine \u2014 noisy environments may delay or falsely trigger',
1967
+ modeOnce: "One-shot",
1968
+ stopReading: "Stop reading",
1969
+ readAloudLabel: "Read replies",
1970
+ readAloudVoice: "Voice mode",
1971
+ readAloudAlways: "Always",
1972
+ readAloudOff: "Off",
1973
+ descReadAloud: "Voice mode = read replies only in voice mode (default); Always = read every reply in the current session, typed ones included; Off = never read aloud",
1974
+ showCaptionsLabel: "Caption overlay",
1975
+ descShowCaptions: "Show a floating caption of the current sentence while reading aloud",
1976
+ showStatusBarLabel: "Status bar",
1977
+ descShowStatusBar: "Show the voice status bar above the composer (waveform, transcript, timer, notices, exit); when off, state shows only on the mic button",
1978
+ descWakeWord: 'Wake word (default off; e.g. "Hey D"): recognition starts only after you say it, to avoid accidental triggers. You may say it together with your command ("Hey D, check the weather" \u2014 the wake word is stripped and never sent); it must be repeated after each utterance split or barge-in; toggle mode only (inactive in hold / manual barge-in \u2014 and equally inactive when the detect probe fails and falls back to manual, the default on machines without native echo cancellation such as Safari); saying it while the agent is reading does not trigger (barge-in stays VAD-based). Fault-tolerant matching (homophones / leading fillers); 3-4 characters recommended; not a dedicated KWS engine \u2014 noisy environments may delay or falsely trigger',
1742
1979
  wakePlaceholder: "e.g. Hey D",
1743
- settingsCardDesc: "Engine / voice / rate / interrupt / barge-in / echo gate / silence / idle / model host / auto-send / auto-resume / mode / wake word / tool beep / ITN / caption font / caption width / yielding / yield window",
1744
- settingsEffectiveNote: "Engine / voice / rate / model precision / spoken format / re-transcribe / caption font / caption width / yielding / yield window apply immediately; ITN applies immediately (next time you enter voice mode the streaming recognizer is rebuilt); the rest (interrupt / barge-in / echo gate / shortcut / silence / idle / mirror / auto-send / auto-resume / mode / wake word / tool beep) apply next time you enter voice mode.",
1980
+ settingsCardDesc: "Engine / voice / rate / interrupt / barge-in / echo gate / silence / idle / model host / auto-send / auto-resume / mode / wake word / tool beep / ITN / caption font / caption width / yielding / yield window / barge-in salvage / LLM correction",
1981
+ settingsEffectiveNote: "When settings apply, in four tiers: \u2460 immediately \u2014 engine / voice / rate / Kokoro model precision (immediate when cached, else next download) / spoken format (applies to later replies) / read replies / status bar / caption overlay / model mirror (next download attempt); \u2461 next recognition \u2014 finalization re-transcription (SenseVoice) / ITN; \u2462 next utterance \u2014 silence threshold (endpoint; the send wait stays a fixed 1.2s); \u2463 next time you enter voice mode \u2014 interrupt sensitivity / barge-in mode / echo gate / shortcut / auto-send / auto-resume / interaction mode / wake word / tool beep / caption font / caption width / backchannel yielding / yield window / barge-in salvage / LLM correction / idle timeout. Items that take effect next time you enter voice mode are listed at the top of this card with their current effective values.",
1982
+ effectivePending: "{count} change(s) will apply next time you enter voice mode: {items}",
1983
+ valueOn: "On",
1984
+ valueOff: "Off",
1985
+ valueQuoted: '"{value}"',
1986
+ effectiveItem: "{label} (currently effective: {value})",
1987
+ effectiveItemSep: ", ",
1745
1988
  configUnavailable: "Configuration unavailable",
1746
1989
  telUtteranceEnd: "end",
1747
1990
  telEndpoint: "endpoint",
@@ -1775,7 +2018,6 @@ var en = {
1775
2018
  ttsDownloadHint: "Download this engine's local model; becomes ready immediately after",
1776
2019
  dataFlowHint: "Data flow: ASR recognition (zipformer2+SenseVoice) is always local; TTS playback depends on engine (edge=Microsoft cloud, vits/kokoro=local)",
1777
2020
  ttsDeleteHint: "Delete local models (frees space; auto re-downloads on next use)",
1778
- kokoroModel: "Kokoro model precision",
1779
2021
  kokoroModelInt8: "int8 (default)",
1780
2022
  kokoroModelFp32: "fp32 (better quality)",
1781
2023
  descKokoroModel: "Kokoro model precision: int8 is smaller/faster (CPU server or low bandwidth; default); fp32 sounds better but ~311MB and slower (GPU or large memory). Both share the same 103 voices; switches live.",
@@ -1790,7 +2032,10 @@ var en = {
1790
2032
  captionFontSizeLabel: "Caption size",
1791
2033
  captionMaxWidthLabel: "Caption width",
1792
2034
  backchannelYieldLabel: "Short-reply yielding",
1793
- // 批 G 任务 3:让位窗口(FIELD_LABELS.yieldMs 镜像键,*Label 后缀)。
2035
+ // Issue #15 batch 1 / ADR-0012: barge-in speech salvage (row title key).
2036
+ bargeInSalvageLabel: "Barge-in speech salvage",
2037
+ llmCorrectLabel: "LLM correction",
2038
+ // Yield window (row title key).
1794
2039
  yieldMsLabel: "Yield window",
1795
2040
  // 批 G 任务 2:空闲预警 + 退出提示文案。
1796
2041
  idleWarn30s: "Auto-exit in 30 seconds (adjustable in settings)",
@@ -1941,6 +2186,58 @@ function errorText(body, fallback) {
1941
2186
  return t(isHostErrorCode(code) ? ERROR_I18N_KEY[code] : fallback);
1942
2187
  }
1943
2188
 
2189
+ // src/steer-submit.ts
2190
+ function shouldSteerSubmit(running, draft) {
2191
+ return running === true && !draft.trim().startsWith("/");
2192
+ }
2193
+ async function trySteerSubmit(session, text) {
2194
+ if (typeof session?.prompt !== "function") return false;
2195
+ try {
2196
+ const r = await session.prompt([{ type: "text", text }], "steer");
2197
+ return !(r && r.ok === false);
2198
+ } catch {
2199
+ return false;
2200
+ }
2201
+ }
2202
+
2203
+ // src/draft-compose.ts
2204
+ function composeDraft(current, tail, addition) {
2205
+ const cur = String(current ?? "");
2206
+ const t3 = String(tail ?? "");
2207
+ const base = t3 && cur.endsWith(t3) ? cur.slice(0, cur.length - t3.length).replace(/\s+$/, "") : cur.trim();
2208
+ const add = String(addition ?? "").trim();
2209
+ if (!add) return base;
2210
+ return base ? `${base} ${add}` : add;
2211
+ }
2212
+ function shouldWritePartial(state) {
2213
+ return state !== "wake";
2214
+ }
2215
+
2216
+ // src/mic-gesture.ts
2217
+ function isEditingShortcut(combo, mac) {
2218
+ const primary = mac ? combo.meta && !combo.ctrl : combo.ctrl && !combo.meta;
2219
+ return primary && !combo.alt && combo.key.length === 1 && "acvxzy".includes(combo.key);
2220
+ }
2221
+ function takeToggleSlot(history, now) {
2222
+ while (history.length > 0 && now - history[0] >= 2e3) history.shift();
2223
+ if (history.length >= 2) return false;
2224
+ if (history.length > 0 && now - history[history.length - 1] < 250) return false;
2225
+ history.push(now);
2226
+ return true;
2227
+ }
2228
+ function onceFinished(o, running, ttsDrained, playing) {
2229
+ return o.sawRun && !running && ttsDrained && !playing;
2230
+ }
2231
+
2232
+ // src/runtime-boot.ts
2233
+ var runtimeBoot = null;
2234
+ function setRuntimeBoot(boot) {
2235
+ runtimeBoot = boot;
2236
+ }
2237
+ function getRuntimeBoot() {
2238
+ return runtimeBoot;
2239
+ }
2240
+
1944
2241
  // src/settings-form.tsx
1945
2242
  var import_react2 = require("react");
1946
2243
 
@@ -2630,6 +2927,34 @@ function Row({ name: name2, desc, children }) {
2630
2927
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { flexShrink: 0, maxWidth: 300 }, children })
2631
2928
  ] });
2632
2929
  }
2930
+ var NEXT_ENTRY_FIELDS = [
2931
+ { key: "interruptLevel", label: "interruptLevelLabel", fmt: (v) => t(v === 1 ? "sev1" : v === 2 ? "sev2" : "sev0") },
2932
+ { key: "bargeInMode", label: "bargeInModeLabel", fmt: (v) => t(v === "auto" ? "bargeInAuto" : v === "manual" ? "bargeInManual" : "bargeInDetect") },
2933
+ { key: "echoGateDb", label: "echoGateDbLabel", fmt: (v) => `${v} ${t("unitDb")}` },
2934
+ { key: "autoSend", label: "autoSendLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
2935
+ { key: "autoResume", label: "autoResumeLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
2936
+ { key: "mode", label: "modeLabel", fmt: (v) => t(v === "hold" ? "modeHold" : v === "once" ? "modeOnce" : "modeToggle") },
2937
+ { key: "wakeWord", label: "wakeWordLabel", fmt: (v) => v ? t("valueQuoted").replace("{value}", String(v)) : t("valueOff") },
2938
+ { key: "toolBeep", label: "toolBeepLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
2939
+ { key: "captionFontSize", label: "captionFontSizeLabel", fmt: (v) => t(v === 1 ? "captionSizeM" : v === 2 ? "captionSizeL" : v === 3 ? "captionSizeXL" : "captionSizeS") },
2940
+ { key: "captionMaxWidth", label: "captionMaxWidthLabel", fmt: (v) => t(v === 0 ? "captionWidth50" : v === 2 ? "captionWidth90" : "captionWidth70") },
2941
+ { key: "backchannelYield", label: "backchannelYieldLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
2942
+ { key: "yieldMs", label: "yieldMsLabel", fmt: (v) => `${v} ${t("unitMs")}` },
2943
+ { key: "bargeInSalvage", label: "bargeInSalvageLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
2944
+ { key: "llmCorrect", label: "llmCorrectLabel", fmt: (v) => v ? t("valueOn") : t("valueOff") },
2945
+ { key: "idleTimeoutMinutes", label: "idleTimeoutMinutesLabel", fmt: (v) => `${v} ${t("unitMin")}` },
2946
+ { key: "shortcut", label: "shortcutLabel", fmt: (v) => v ? String(v) : t("valueOff") }
2947
+ ];
2948
+ function EffectivePending({ effective, value, ready }) {
2949
+ if (!ready || !effective) return null;
2950
+ const pending = NEXT_ENTRY_FIELDS.filter((f) => effective[f.key] !== void 0 && effective[f.key] !== value[f.key]);
2951
+ if (pending.length === 0) return null;
2952
+ const items = pending.map((f) => {
2953
+ const eff = f.fmt ? f.fmt(effective[f.key]) : String(effective[f.key]);
2954
+ return t("effectiveItem").replace("{label}", t(f.label)).replace("{value}", eff);
2955
+ }).join(t("effectiveItemSep"));
2956
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-dshvm-settings": "effective-pending", style: { fontSize: 12, color: "var(--dsw-alias-label-tertiary)", padding: "8px 2px 4px", lineHeight: 1.6 }, children: t("effectivePending").replace("{count}", String(pending.length)).replace("{items}", items) });
2957
+ }
2633
2958
  function Section({ title, children }) {
2634
2959
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 2 }, children: [
2635
2960
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "10px 0 2px" }, children: [
@@ -2889,148 +3214,169 @@ function VoiceSettingsCard({ scope, defaultOpen = false }) {
2889
3214
  ] }),
2890
3215
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { ...setChevron, transform: collapsed ? "rotate(0deg)" : "rotate(180deg)" }, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 16 16", width: 14, height: 14, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: "M4 6l4 4 4-4z" }) }) })
2891
3216
  ] }),
2892
- !collapsed && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "dshvm-settings-card-body", style: setBody, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 4 }, children: [
2893
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secRead"), children: [
2894
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "ttsEngine", desc: t("descTtsEngine"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2895
- SegGroup,
2896
- {
2897
- score: scope,
2898
- field: "ttsEngine",
2899
- value: engine,
2900
- options: [
2901
- { v: "vits", label: t("engineVits") },
2902
- { v: "kokoro", label: t("engineKokoro") },
2903
- { v: "edge", label: t("engineEdge") }
2904
- ],
2905
- onSelect: (v) => {
2906
- if (v !== engine) {
2907
- void scope.set("voice", ENGINE_DEFAULT_VOICE[String(v)] ?? "zh-CN-XiaoxiaoNeural");
3217
+ !collapsed && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { id: "dshvm-settings-card-body", style: setBody, children: [
3218
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EffectivePending, { effective: getRuntimeBoot(), value, ready: snap?.status === "ready" }),
3219
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 4 }, children: [
3220
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secRead"), children: [
3221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "ttsEngine", desc: t("descTtsEngine"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3222
+ SegGroup,
3223
+ {
3224
+ score: scope,
3225
+ field: "ttsEngine",
3226
+ value: engine,
3227
+ options: [
3228
+ { v: "vits", label: t("engineVits") },
3229
+ { v: "kokoro", label: t("engineKokoro") },
3230
+ { v: "edge", label: t("engineEdge") }
3231
+ ],
3232
+ onSelect: (v) => {
3233
+ if (v !== engine) {
3234
+ void scope.set("voice", ENGINE_DEFAULT_VOICE[String(v)] ?? "zh-CN-XiaoxiaoNeural");
3235
+ }
2908
3236
  }
2909
3237
  }
2910
- }
2911
- ) }),
2912
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EngineStatusInline, {}),
2913
- engine === "kokoro" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "kokoroModel", desc: t("descKokoroModel"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2914
- SegGroup,
2915
- {
2916
- score: scope,
2917
- field: "kokoroModel",
2918
- value: value.kokoroModel,
2919
- options: [
2920
- { v: "int8", label: t("kokoroModelInt8") },
2921
- { v: "fp32", label: t("kokoroModelFp32") }
2922
- ]
2923
- }
2924
- ) }),
2925
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2926
- Row,
2927
- {
2928
- name: "voice",
2929
- desc: (engine === "edge" ? t("descVoice") : engine === "kokoro" ? t("descVoiceKokoro") : t("descVoiceLocal")) + voiceLangHint(engine, String(value.voice ?? "")),
2930
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2931
- VoiceSelect,
2932
- {
2933
- score: scope,
2934
- field: "voice",
2935
- value: value.voice ?? "",
2936
- options: voiceOptions,
2937
- placeholder: ENGINE_DEFAULT_VOICE[engine] ?? "zh-CN-XiaoxiaoNeural",
2938
- showCustom: engine === "edge",
2939
- footer: (v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePreviewButton, { voice: v, rate: Number(value.rate ?? 1.1) })
2940
- }
2941
- )
2942
- }
2943
- ),
2944
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "rate", desc: t("descRate"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "rate", value: value.rate ?? 1.1, min: 0.5, max: 2, step: 0.1 }) })
2945
- ] }),
2946
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secInterrupt"), children: [
2947
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "interruptLevel", desc: t("descInterrupt"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2948
- SegGroup,
2949
- {
2950
- score: scope,
2951
- field: "interruptLevel",
2952
- value: value.interruptLevel,
2953
- options: [
2954
- { v: 0, label: t("sev0") },
2955
- { v: 1, label: t("sev1") },
2956
- { v: 2, label: t("sev2") }
2957
- ]
2958
- }
2959
- ) }),
2960
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "bargeInMode", desc: t("descBargeIn"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2961
- SegGroup,
2962
- {
2963
- score: scope,
2964
- field: "bargeInMode",
2965
- value: value.bargeInMode,
2966
- options: [
2967
- { v: "detect", label: t("bargeInDetect") },
2968
- { v: "auto", label: t("bargeInAuto") },
2969
- { v: "manual", label: t("bargeInManual") }
2970
- ]
2971
- }
2972
- ) }),
2973
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "echoGateDb", desc: t("descEchoGate"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "echoGateDb", value: value.echoGateDb ?? 6, min: 3, max: 12, step: 1 }) })
2974
- ] }),
2975
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secInteraction"), children: [
2976
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "mode", desc: t("descMode"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2977
- SegGroup,
2978
- {
2979
- score: scope,
2980
- field: "mode",
2981
- value: value.mode,
2982
- options: [
2983
- { v: "toggle", label: t("modeToggle") },
2984
- { v: "hold", label: t("modeHold") }
2985
- ]
2986
- }
2987
- ) }),
2988
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "shortcut", desc: t("descShortcut"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextField, { score: scope, field: "shortcut", value: value.shortcut ?? "Ctrl+Shift+V", placeholder: "Ctrl+Shift+V" }) }),
2989
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "wakeWord", desc: t("descWakeWord"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextField, { score: scope, field: "wakeWord", value: value.wakeWord ?? "", placeholder: t("wakePlaceholder") }) }),
2990
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "toolBeep", desc: t("descToolBeep"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.toolBeep), onChange: (e) => void scope.set("toolBeep", e.target.checked) }) }),
2991
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "autoSend", desc: t("descAutoSend"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.autoSend), onChange: (e) => void scope.set("autoSend", e.target.checked) }) }),
2992
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "autoResume", desc: t("descAutoResume"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.autoResume), onChange: (e) => void scope.set("autoResume", e.target.checked) }) }),
2993
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "captionFontSize", desc: t("descCaptionFontSize"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2994
- SegGroup,
2995
- {
2996
- score: scope,
2997
- field: "captionFontSize",
2998
- value: value.captionFontSize ?? 0,
2999
- options: [
3000
- { v: 0, label: t("captionSizeS") },
3001
- { v: 1, label: t("captionSizeM") },
3002
- { v: 2, label: t("captionSizeL") },
3003
- { v: 3, label: t("captionSizeXL") }
3004
- ]
3005
- }
3006
- ) }),
3007
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "captionMaxWidth", desc: t("descCaptionMaxWidth"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3008
- SegGroup,
3009
- {
3010
- score: scope,
3011
- field: "captionMaxWidth",
3012
- value: value.captionMaxWidth ?? 1,
3013
- options: [
3014
- { v: 0, label: t("captionWidth50") },
3015
- { v: 1, label: t("captionWidth70") },
3016
- { v: 2, label: t("captionWidth90") }
3017
- ]
3018
- }
3019
- ) }),
3020
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "backchannelYield", desc: t("descBackchannelYield"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.backchannelYield !== false, onChange: (e) => void scope.set("backchannelYield", e.target.checked) }) }),
3021
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "yieldMs", desc: t("descYieldMs"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "yieldMs", value: value.yieldMs ?? 1500, min: 500, max: 3e3, step: 100 }) })
3022
- ] }),
3023
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secRecognition"), children: [
3024
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "senseVoice", desc: t("descSenseVoice"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.senseVoice), onChange: (e) => void scope.set("senseVoice", e.target.checked) }) }),
3025
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "senseITN", desc: t("descSenseITN"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.senseITN !== false, onChange: (e) => void scope.set("senseITN", e.target.checked) }) }),
3026
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "spokenFormat", desc: t("descSpokenFormat"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.spokenFormat), onChange: (e) => void scope.set("spokenFormat", e.target.checked) }) }),
3027
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "silenceMs", desc: t("descSilence"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "silenceMs", value: value.silenceMs ?? 1500, min: 500, max: 3e4, step: 100 }) }),
3028
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "idleTimeoutMinutes", desc: t("descIdle"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "idleTimeoutMinutes", value: value.idleTimeoutMinutes ?? 5, min: 1, max: 120, step: 1 }) })
3029
- ] }),
3030
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t("secModel"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "modelHost", desc: t("descModelHost"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, { score: scope, field: "modelHost", value: value.modelHost ?? "", options: hostOptions(), placeholder: "https://..." }) }) }),
3031
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 12, color: t2.term, lineHeight: "18px", padding: "4px 0 8px" }, children: t("settingsEffectiveNote") }),
3032
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModelStatusView, {})
3033
- ] }) })
3238
+ ) }),
3239
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EngineStatusInline, {}),
3240
+ engine === "kokoro" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "kokoroModel", desc: t("descKokoroModel"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3241
+ SegGroup,
3242
+ {
3243
+ score: scope,
3244
+ field: "kokoroModel",
3245
+ value: value.kokoroModel,
3246
+ options: [
3247
+ { v: "int8", label: t("kokoroModelInt8") },
3248
+ { v: "fp32", label: t("kokoroModelFp32") }
3249
+ ]
3250
+ }
3251
+ ) }),
3252
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3253
+ Row,
3254
+ {
3255
+ name: "voice",
3256
+ desc: (engine === "edge" ? t("descVoice") : engine === "kokoro" ? t("descVoiceKokoro") : t("descVoiceLocal")) + voiceLangHint(engine, String(value.voice ?? "")),
3257
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3258
+ VoiceSelect,
3259
+ {
3260
+ score: scope,
3261
+ field: "voice",
3262
+ value: value.voice ?? "",
3263
+ options: voiceOptions,
3264
+ placeholder: ENGINE_DEFAULT_VOICE[engine] ?? "zh-CN-XiaoxiaoNeural",
3265
+ showCustom: engine === "edge",
3266
+ footer: (v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePreviewButton, { voice: v, rate: Number(value.rate ?? 1.1) })
3267
+ }
3268
+ )
3269
+ }
3270
+ ),
3271
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "rate", desc: t("descRate"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "rate", value: value.rate ?? 1.1, min: 0.5, max: 2, step: 0.1 }) })
3272
+ ] }),
3273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secInterrupt"), children: [
3274
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "interruptLevel", desc: t("descInterrupt"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3275
+ SegGroup,
3276
+ {
3277
+ score: scope,
3278
+ field: "interruptLevel",
3279
+ value: value.interruptLevel,
3280
+ options: [
3281
+ { v: 0, label: t("sev0") },
3282
+ { v: 1, label: t("sev1") },
3283
+ { v: 2, label: t("sev2") }
3284
+ ]
3285
+ }
3286
+ ) }),
3287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "bargeInMode", desc: t("descBargeIn"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3288
+ SegGroup,
3289
+ {
3290
+ score: scope,
3291
+ field: "bargeInMode",
3292
+ value: value.bargeInMode,
3293
+ options: [
3294
+ { v: "detect", label: t("bargeInDetect") },
3295
+ { v: "auto", label: t("bargeInAuto") },
3296
+ { v: "manual", label: t("bargeInManual") }
3297
+ ]
3298
+ }
3299
+ ) }),
3300
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "echoGateDb", desc: t("descEchoGate"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "echoGateDb", value: value.echoGateDb ?? 6, min: 3, max: 12, step: 1 }) })
3301
+ ] }),
3302
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secInteraction"), children: [
3303
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "mode", desc: t("descMode"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3304
+ SegGroup,
3305
+ {
3306
+ score: scope,
3307
+ field: "mode",
3308
+ value: value.mode,
3309
+ options: [
3310
+ { v: "toggle", label: t("modeToggle") },
3311
+ { v: "hold", label: t("modeHold") },
3312
+ { v: "once", label: t("modeOnce") }
3313
+ ]
3314
+ }
3315
+ ) }),
3316
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "shortcut", desc: t("descShortcut"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextField, { score: scope, field: "shortcut", value: value.shortcut ?? "Ctrl+Shift+V", placeholder: "Ctrl+Shift+V" }) }),
3317
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "wakeWord", desc: t("descWakeWord"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextField, { score: scope, field: "wakeWord", value: value.wakeWord ?? "", placeholder: t("wakePlaceholder") }) }),
3318
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "toolBeep", desc: t("descToolBeep"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.toolBeep), onChange: (e) => void scope.set("toolBeep", e.target.checked) }) }),
3319
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "autoSend", desc: t("descAutoSend"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.autoSend), onChange: (e) => void scope.set("autoSend", e.target.checked) }) }),
3320
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "readAloud", desc: t("descReadAloud"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3321
+ SegGroup,
3322
+ {
3323
+ score: scope,
3324
+ field: "readAloud",
3325
+ value: value.readAloud ?? "voice",
3326
+ options: [
3327
+ { v: "voice", label: t("readAloudVoice") },
3328
+ { v: "always", label: t("readAloudAlways") },
3329
+ { v: "off", label: t("readAloudOff") }
3330
+ ]
3331
+ }
3332
+ ) }),
3333
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "showStatusBar", desc: t("descShowStatusBar"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.showStatusBar !== false, onChange: (e) => void scope.set("showStatusBar", e.target.checked) }) }),
3334
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "showCaptions", desc: t("descShowCaptions"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.showCaptions !== false, onChange: (e) => void scope.set("showCaptions", e.target.checked) }) }),
3335
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "autoResume", desc: t("descAutoResume"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.autoResume), onChange: (e) => void scope.set("autoResume", e.target.checked) }) }),
3336
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "captionFontSize", desc: t("descCaptionFontSize"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3337
+ SegGroup,
3338
+ {
3339
+ score: scope,
3340
+ field: "captionFontSize",
3341
+ value: value.captionFontSize ?? 0,
3342
+ options: [
3343
+ { v: 0, label: t("captionSizeS") },
3344
+ { v: 1, label: t("captionSizeM") },
3345
+ { v: 2, label: t("captionSizeL") },
3346
+ { v: 3, label: t("captionSizeXL") }
3347
+ ]
3348
+ }
3349
+ ) }),
3350
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "captionMaxWidth", desc: t("descCaptionMaxWidth"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3351
+ SegGroup,
3352
+ {
3353
+ score: scope,
3354
+ field: "captionMaxWidth",
3355
+ value: value.captionMaxWidth ?? 1,
3356
+ options: [
3357
+ { v: 0, label: t("captionWidth50") },
3358
+ { v: 1, label: t("captionWidth70") },
3359
+ { v: 2, label: t("captionWidth90") }
3360
+ ]
3361
+ }
3362
+ ) }),
3363
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "backchannelYield", desc: t("descBackchannelYield"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.backchannelYield !== false, onChange: (e) => void scope.set("backchannelYield", e.target.checked) }) }),
3364
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "bargeInSalvage", desc: t("descBargeInSalvage"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.bargeInSalvage !== false, onChange: (e) => void scope.set("bargeInSalvage", e.target.checked) }) }),
3365
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "llmCorrect", desc: t("descLlmCorrect"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.llmCorrect === true, onChange: (e) => void scope.set("llmCorrect", e.target.checked) }) }),
3366
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "yieldMs", desc: t("descYieldMs"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "yieldMs", value: value.yieldMs ?? 1500, min: 500, max: 3e3, step: 100 }) })
3367
+ ] }),
3368
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, { title: t("secRecognition"), children: [
3369
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "senseVoice", desc: t("descSenseVoice"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.senseVoice), onChange: (e) => void scope.set("senseVoice", e.target.checked) }) }),
3370
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "senseITN", desc: t("descSenseITN"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: value.senseITN !== false, onChange: (e) => void scope.set("senseITN", e.target.checked) }) }),
3371
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "spokenFormat", desc: t("descSpokenFormat"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: Boolean(value.spokenFormat), onChange: (e) => void scope.set("spokenFormat", e.target.checked) }) }),
3372
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "silenceMs", desc: t("descSilence"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "silenceMs", value: value.silenceMs ?? 1500, min: 500, max: 3e4, step: 100 }) }),
3373
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "idleTimeoutMinutes", desc: t("descIdle"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberField, { score: scope, field: "idleTimeoutMinutes", value: value.idleTimeoutMinutes ?? 5, min: 1, max: 120, step: 1 }) })
3374
+ ] }),
3375
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t("secModel"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Row, { name: "modelHost", desc: t("descModelHost"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, { score: scope, field: "modelHost", value: value.modelHost ?? "", options: hostOptions(), placeholder: "https://..." }) }) }),
3376
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: 12, color: t2.term, lineHeight: "18px", padding: "4px 0 8px" }, children: t("settingsEffectiveNote") }),
3377
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModelStatusView, {})
3378
+ ] })
3379
+ ] })
3034
3380
  ] });
3035
3381
  }
3036
3382
 
@@ -3103,7 +3449,21 @@ var TELEMETRY_VIEW = [
3103
3449
  { stage: "first-tts-chunk", key: "telFirstChunk" },
3104
3450
  { stage: "first-audio-played", key: "telFirstPlayed" }
3105
3451
  ];
3106
- var BUILD_TAG = "c0970c5";
3452
+ function telemetryDeltas(tel) {
3453
+ const out = [];
3454
+ let prev;
3455
+ for (const { stage } of TELEMETRY_VIEW) {
3456
+ const at = tel[stage];
3457
+ if (typeof at !== "number") {
3458
+ prev = void 0;
3459
+ continue;
3460
+ }
3461
+ if (prev !== void 0) out.push(`${stage}=${Math.round(at - prev)}ms`);
3462
+ prev = at;
3463
+ }
3464
+ return out;
3465
+ }
3466
+ var BUILD_TAG = "8c0368a";
3107
3467
  var TELEMETRY_FLAG = "dsh-voice-mode.telemetry";
3108
3468
  var telemetryEnabled = typeof localStorage !== "undefined" && localStorage.getItem(TELEMETRY_FLAG) === "1";
3109
3469
  console.log("[dsh-voice] build=" + BUILD_TAG);
@@ -3115,6 +3475,7 @@ var debugLog = (event, fields = {}) => {
3115
3475
  }
3116
3476
  console.log("[dsh-voice]", event, JSON.stringify(out));
3117
3477
  };
3478
+ var tk = (key) => t(key);
3118
3479
  var beepCtx = null;
3119
3480
  function playToolBeep() {
3120
3481
  try {
@@ -3134,24 +3495,35 @@ function playToolBeep() {
3134
3495
  }
3135
3496
  var SAMPLE_RATE_16K = 16e3;
3136
3497
  var ECHO_DELAY_MS = 0;
3498
+ var AUTO_SEND_EXTRA_MS = 1200;
3137
3499
  var ECHO_TAIL_MS = 400;
3138
3500
  var HOLD_CLEAR_FRAMES = 2;
3139
3501
  var WAVE_BARS = 14;
3140
3502
  var BASE_PATH2 = "/voice-mode";
3141
- function getTabId() {
3503
+ function displaySettings(c) {
3504
+ return {
3505
+ readAloud: c.readAloud === "always" || c.readAloud === "off" ? c.readAloud : "voice",
3506
+ showCaptions: c.showCaptions !== false,
3507
+ showStatusBar: c.showStatusBar !== false
3508
+ };
3509
+ }
3510
+ var STOP_READING_LINE = Number.MAX_SAFE_INTEGER;
3511
+ function getTabId(fresh = false) {
3512
+ const KEY = "dshvm-tabId";
3513
+ const make = () => typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
3142
3514
  try {
3143
- const KEY = "dshvm-tabId";
3144
- let id = sessionStorage.getItem(KEY);
3515
+ let id = fresh ? null : sessionStorage.getItem(KEY);
3145
3516
  if (!id) {
3146
- id = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
3517
+ id = make();
3147
3518
  sessionStorage.setItem(KEY, id);
3148
3519
  }
3149
3520
  return id;
3150
3521
  } catch {
3151
- return Math.random().toString(36).slice(2) + Date.now().toString(36);
3522
+ return make();
3152
3523
  }
3153
3524
  }
3154
3525
  var TAB_ID = getTabId();
3526
+ var BUS_GEN_KEY = "__dshvmBusGen";
3155
3527
  function parseShortcut(s) {
3156
3528
  const parts = (s || "").split("+");
3157
3529
  const mods = { ctrl: false, shift: false, alt: false, meta: false };
@@ -3193,6 +3565,55 @@ function apply(ctx) {
3193
3565
  document.addEventListener("pointerdown", resumeAudio, { passive: true });
3194
3566
  document.addEventListener("keydown", resumeAudio, { passive: true });
3195
3567
  }
3568
+ const activity = { declared: false, mounted: 0, listeners: /* @__PURE__ */ new Set() };
3569
+ const activityChanged = () => activity.listeners.forEach((fn) => fn());
3570
+ const ActivityMic = (props) => {
3571
+ (0, import_react3.useEffect)(() => {
3572
+ activity.mounted++;
3573
+ activityChanged();
3574
+ return () => {
3575
+ activity.mounted--;
3576
+ activityChanged();
3577
+ };
3578
+ }, []);
3579
+ return React.createElement(MicButton, props);
3580
+ };
3581
+ const RightMic = (props) => {
3582
+ const [show, setShow] = (0, import_react3.useState)(() => !activity.declared);
3583
+ (0, import_react3.useEffect)(() => {
3584
+ let timer;
3585
+ const evaluate = () => {
3586
+ clearTimeout(timer);
3587
+ if (!activity.declared) setShow(true);
3588
+ else if (activity.mounted > 0) setShow(false);
3589
+ else timer = setTimeout(() => setShow(!activity.declared || activity.mounted === 0), 1500);
3590
+ };
3591
+ activity.listeners.add(evaluate);
3592
+ evaluate();
3593
+ return () => {
3594
+ activity.listeners.delete(evaluate);
3595
+ clearTimeout(timer);
3596
+ };
3597
+ }, []);
3598
+ return show ? React.createElement(MicButton, props) : null;
3599
+ };
3600
+ ctx.slots.inject("conversation.input.activity", () => {
3601
+ activity.declared = true;
3602
+ activityChanged();
3603
+ const dispose = ctx.slots.register(
3604
+ {
3605
+ name: "conversation.input.activity",
3606
+ id: "voice-mode",
3607
+ inject: () => ({ bus, scope })
3608
+ },
3609
+ ActivityMic
3610
+ );
3611
+ return () => {
3612
+ activity.declared = false;
3613
+ activityChanged();
3614
+ dispose?.();
3615
+ };
3616
+ });
3196
3617
  ctx.slots.inject(
3197
3618
  "conversation.input.right",
3198
3619
  () => ctx.slots.register(
@@ -3200,9 +3621,9 @@ function apply(ctx) {
3200
3621
  name: "conversation.input.right",
3201
3622
  id: "voice-mode",
3202
3623
  order: 80,
3203
- inject: () => ({ bus })
3624
+ inject: () => ({ bus, scope })
3204
3625
  },
3205
- MicButton
3626
+ RightMic
3206
3627
  )
3207
3628
  );
3208
3629
  ctx.slots.inject(
@@ -3239,7 +3660,9 @@ function apply(ctx) {
3239
3660
  id: "voice-mode",
3240
3661
  key: "voice-mode",
3241
3662
  order: 100,
3242
- label: t("stateVoiceMode")
3663
+ // M13:函数形式(与下方 settings.section 注册一致)——注册时求值会把
3664
+ // 切换语言前的旧文案冻在菜单里;函数形式每次渲染读当前语言。
3665
+ label: () => t("stateVoiceMode")
3243
3666
  },
3244
3667
  () => React.createElement(VoiceSettingsCard, { scope })
3245
3668
  )
@@ -3265,6 +3688,8 @@ function createAudioEngine(setUi, onPlayed, onPlaybackRef, onAllPlayed) {
3265
3688
  let fallback = false;
3266
3689
  let ctx = null;
3267
3690
  let duckGain = null;
3691
+ let analyser = null;
3692
+ let levelBuf = null;
3268
3693
  let nextEndAt = 0;
3269
3694
  const activeSrcs = /* @__PURE__ */ new Set();
3270
3695
  let decoding = false;
@@ -3279,7 +3704,15 @@ function createAudioEngine(setUi, onPlayed, onPlaybackRef, onAllPlayed) {
3279
3704
  ctx = new AC();
3280
3705
  duckGain = ctx.createGain();
3281
3706
  duckGain.gain.value = 1;
3282
- duckGain.connect(ctx.destination);
3707
+ try {
3708
+ analyser = ctx.createAnalyser();
3709
+ analyser.fftSize = 256;
3710
+ duckGain.connect(analyser);
3711
+ analyser.connect(ctx.destination);
3712
+ } catch {
3713
+ analyser = null;
3714
+ duckGain.connect(ctx.destination);
3715
+ }
3283
3716
  void ctx.resume?.();
3284
3717
  } catch {
3285
3718
  ctx = null;
@@ -3411,11 +3844,33 @@ function createAudioEngine(setUi, onPlayed, onPlaybackRef, onAllPlayed) {
3411
3844
  const now = ctx.currentTime;
3412
3845
  duckGain.gain.cancelScheduledValues(now);
3413
3846
  duckGain.gain.setTargetAtTime(1, now, 0.035);
3847
+ },
3848
+ level() {
3849
+ if (!analyser) return 0;
3850
+ if (!levelBuf || levelBuf.length !== analyser.fftSize) levelBuf = new Float32Array(analyser.fftSize);
3851
+ analyser.getFloatTimeDomainData(levelBuf);
3852
+ let sum = 0;
3853
+ for (const v of levelBuf) sum += v * v;
3854
+ return Math.min(1, Math.sqrt(sum / levelBuf.length) / 0.2);
3414
3855
  }
3415
3856
  };
3416
3857
  }
3417
3858
  function createVoiceBus(basePath = BASE_PATH2, ctx) {
3418
3859
  let activeSessionId = null;
3860
+ let focusedSessionId = null;
3861
+ let focusOwnerTab = null;
3862
+ let voiceActive = null;
3863
+ let voiceOwnerTab = null;
3864
+ const busGen = globalThis[BUS_GEN_KEY] = (globalThis[BUS_GEN_KEY] ?? 0) + 1;
3865
+ const postFocus = (sessionId) => {
3866
+ void fetch(`${location.origin}${basePath}/focus`, {
3867
+ method: "POST",
3868
+ headers: { "content-type": "application/json" },
3869
+ body: JSON.stringify({ sessionId, tabId: TAB_ID }),
3870
+ signal: AbortSignal.timeout(3e3)
3871
+ }).catch(() => {
3872
+ });
3873
+ };
3419
3874
  const DEFAULT_BOOT = {
3420
3875
  basePath: BASE_PATH2,
3421
3876
  silenceMs: 1500,
@@ -3424,6 +3879,9 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3424
3879
  autoSend: true,
3425
3880
  autoResume: false,
3426
3881
  mode: "toggle",
3882
+ readAloud: "voice",
3883
+ showCaptions: true,
3884
+ showStatusBar: true,
3427
3885
  // 批 7O(ADR-0006):默认 detect(与 src/index.ts VOICE_SETTINGS_DEFAULTS 对齐)。
3428
3886
  bargeInMode: "detect",
3429
3887
  echoGateDb: 6,
@@ -3433,11 +3891,15 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3433
3891
  captionFontSize: 0,
3434
3892
  captionMaxWidth: 1,
3435
3893
  backchannelYield: true,
3894
+ // Issue #15 批 1 / ADR-0012:打断语音抢救默认 true(与 VOICE_SETTINGS_DEFAULTS 对齐)。
3895
+ bargeInSalvage: true,
3896
+ llmCorrect: false,
3436
3897
  yieldMs: 1500,
3437
3898
  // 批 B:5 ASR 字段默认值,与 src/index.ts VOICE_SETTINGS_DEFAULTS 对齐(plan §12 批 B 周全修复)。
3438
3899
  senseITN: true,
3439
3900
  senseVoice: true
3440
3901
  };
3902
+ let noticeTimer = null;
3441
3903
  const ui = {
3442
3904
  state: "idle",
3443
3905
  partial: "",
@@ -3454,7 +3916,8 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3454
3916
  turn: "idle",
3455
3917
  wakeWord: "",
3456
3918
  // 批 H 任务 4:autoResume 引导提示(一次会话内一次)。
3457
- notice: null
3919
+ notice: null,
3920
+ sseDown: false
3458
3921
  };
3459
3922
  const listeners = /* @__PURE__ */ new Set();
3460
3923
  const audioListeners = /* @__PURE__ */ new Set();
@@ -3475,7 +3938,6 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3475
3938
  }
3476
3939
  };
3477
3940
  const resetTelemetry = () => {
3478
- if (!telemetryEnabled) return;
3479
3941
  for (const k of Object.keys(telemetryStages)) delete telemetryStages[k];
3480
3942
  ui.telemetry = null;
3481
3943
  ui.interruptConfirmMs = void 0;
@@ -3592,11 +4054,13 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3592
4054
  // A2.5 双讲冻结:用户说话时暂停 NLMS 自适应。
3593
4055
  setFrozen: (frozen) => aec.setFrozen(frozen)
3594
4056
  };
4057
+ const setUi = (patch) => {
4058
+ if (patch.playing === false && ui.playing === true) playingEndAt = Date.now();
4059
+ Object.assign(ui, patch);
4060
+ notify();
4061
+ };
3595
4062
  const engine = createAudioEngine(
3596
- (patch) => {
3597
- Object.assign(ui, patch);
3598
- notify();
3599
- },
4063
+ setUi,
3600
4064
  () => stampTelemetry("first-audio-played"),
3601
4065
  (pcm, sampleRate, wallMs) => {
3602
4066
  pushRef(pcm, sampleRate, wallMs);
@@ -3623,12 +4087,55 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3623
4087
  source.addEventListener("open", () => {
3624
4088
  rejectSeqUpTo.clear();
3625
4089
  lastFinalSeq.clear();
4090
+ curSentenceId = null;
4091
+ curChunks = [];
4092
+ curBytes = 0;
4093
+ curChunkCount = 0;
4094
+ if (ui.sseDown) {
4095
+ ui.sseDown = false;
4096
+ notify();
4097
+ }
4098
+ if (focusedSessionId && (typeof document === "undefined" || document.visibilityState === "visible")) {
4099
+ postFocus(focusedSessionId);
4100
+ }
4101
+ });
4102
+ source.addEventListener("replaced", () => {
4103
+ source?.close();
4104
+ source = null;
4105
+ if (globalThis[BUS_GEN_KEY] !== busGen) {
4106
+ ui.sseDown = true;
4107
+ notify();
4108
+ return;
4109
+ }
4110
+ TAB_ID = getTabId(true);
4111
+ connect();
4112
+ });
4113
+ source.addEventListener("display", (e) => {
4114
+ try {
4115
+ ui.boot = { ...ui.boot, ...displaySettings(JSON.parse(e.data)) };
4116
+ notify();
4117
+ } catch {
4118
+ }
4119
+ });
4120
+ source.addEventListener("focus", (e) => {
4121
+ try {
4122
+ focusOwnerTab = JSON.parse(e.data).tabId ?? null;
4123
+ } catch {
4124
+ }
4125
+ });
4126
+ source.addEventListener("error", () => {
4127
+ if (!ui.sseDown) {
4128
+ ui.sseDown = true;
4129
+ notify();
4130
+ }
3626
4131
  });
3627
4132
  source.addEventListener("mode", (e) => {
3628
4133
  try {
3629
4134
  const data = JSON.parse(e.data);
3630
4135
  const active = data.active ?? null;
3631
4136
  const ownerTabId = data.ownerTabId ?? null;
4137
+ voiceActive = active;
4138
+ voiceOwnerTab = ownerTabId;
3632
4139
  const preempted = active !== activeSessionId || ownerTabId !== null && activeSessionId !== null && ownerTabId !== TAB_ID;
3633
4140
  if (activeSessionId !== null && preempted) {
3634
4141
  const prev = activeSessionId;
@@ -3657,8 +4164,22 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3657
4164
  source.addEventListener("turn", (e) => {
3658
4165
  try {
3659
4166
  const ev = JSON.parse(e.data);
4167
+ if (ev.state === "agent-speaking" && ev.sessionId && rejectSeqUpTo.get(ev.sessionId) === STOP_READING_LINE && !stopUntilRun.has(ev.sessionId)) {
4168
+ rejectSeqUpTo.delete(ev.sessionId);
4169
+ }
3660
4170
  if (ev.sessionId === activeSessionId && ev.state) {
3661
4171
  ui.turn = ev.state;
4172
+ if (ev.state === "agent-speaking") ui.ttsDrained = false;
4173
+ notify();
4174
+ }
4175
+ } catch {
4176
+ }
4177
+ });
4178
+ source.addEventListener("tts-idle", (e) => {
4179
+ try {
4180
+ const ev = JSON.parse(e.data);
4181
+ if (ev.sessionId === activeSessionId && !ui.ttsDrained) {
4182
+ ui.ttsDrained = true;
3662
4183
  notify();
3663
4184
  }
3664
4185
  } catch {
@@ -3688,6 +4209,7 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3688
4209
  source.addEventListener("asr-error", (e) => {
3689
4210
  try {
3690
4211
  const p = JSON.parse(e.data);
4212
+ if (!activeSessionId) return;
3691
4213
  ui.error = t("modelDownloadFail").replace("{file}", p.file ?? "");
3692
4214
  ui.model = null;
3693
4215
  notify();
@@ -3743,13 +4265,21 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3743
4265
  };
3744
4266
  connect();
3745
4267
  const rejectSeqUpTo = /* @__PURE__ */ new Map();
4268
+ const stopUntilRun = /* @__PURE__ */ new Set();
3746
4269
  const lastFinalSeq = /* @__PURE__ */ new Map();
3747
4270
  let curSentenceId = null;
3748
4271
  let curChunks = [];
3749
4272
  let curBytes = 0;
3750
4273
  let curChunkCount = 0;
3751
4274
  audioListeners.add((frame) => {
3752
- if (frame.sessionId !== activeSessionId) return;
4275
+ if (frame.sessionId === activeSessionId && ui.ttsDrained) {
4276
+ ui.ttsDrained = false;
4277
+ notify();
4278
+ }
4279
+ const readAloud = ui.boot.readAloud ?? "voice";
4280
+ if (readAloud === "off") return;
4281
+ const alwaysHere = readAloud === "always" && frame.sessionId === focusedSessionId && focusOwnerTab === TAB_ID && !(voiceActive === frame.sessionId && voiceOwnerTab !== null && voiceOwnerTab !== TAB_ID);
4282
+ if (frame.sessionId !== activeSessionId && !alwaysHere) return;
3753
4283
  const rejectLine = rejectSeqUpTo.get(frame.sessionId);
3754
4284
  if (rejectLine !== void 0 && frame.sentenceId <= rejectLine) return;
3755
4285
  if (backchannelHoldUntil && Date.now() < backchannelHoldUntil) {
@@ -3809,7 +4339,7 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3809
4339
  curChunkCount += 1;
3810
4340
  });
3811
4341
  const doSkipAudio = (sidArg) => {
3812
- const sid = sidArg ?? activeSessionId;
4342
+ const sid = sidArg ?? activeSessionId ?? focusedSessionId;
3813
4343
  if (sid) {
3814
4344
  rejectSeqUpTo.set(sid, Math.max(lastFinalSeq.get(sid) ?? -1, curSentenceId ?? -1));
3815
4345
  }
@@ -3829,16 +4359,24 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3829
4359
  ui,
3830
4360
  subscribe(fn) {
3831
4361
  listeners.add(fn);
3832
- fn({ active: activeSessionId, ui: { ...ui, levels: [...ui.levels] } });
4362
+ fn({ active: activeSessionId, ui: { ...ui, levels: [...ui.levels], botLevels: [...ui.botLevels] } });
3833
4363
  return () => {
3834
4364
  listeners.delete(fn);
3835
4365
  };
3836
4366
  },
3837
- setUi(patch) {
3838
- if (patch.playing === false && ui.playing === true) playingEndAt = Date.now();
3839
- Object.assign(ui, patch);
4367
+ setNotice(hint) {
4368
+ ui.notice = hint;
3840
4369
  notify();
4370
+ if (noticeTimer) clearTimeout(noticeTimer);
4371
+ noticeTimer = setTimeout(() => {
4372
+ noticeTimer = null;
4373
+ if (ui.notice === hint) {
4374
+ ui.notice = null;
4375
+ notify();
4376
+ }
4377
+ }, 5e3);
3841
4378
  },
4379
+ setUi,
3842
4380
  /** isPlaying 尾音截止墙钟:playing 或尾音宽限期内均视为「AI 正在朗读」。 */
3843
4381
  playingTailUntil() {
3844
4382
  return playingEndAt + ECHO_TAIL_MS + refDelaySamples / SAMPLE_RATE_16K * 1e3;
@@ -3852,6 +4390,7 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3852
4390
  });
3853
4391
  const out = await res.json();
3854
4392
  activeSessionId = out.active === sessionId ? sessionId : null;
4393
+ playingEndAt = 0;
3855
4394
  notify();
3856
4395
  if (!res.ok) return { ok: false, error: errorText(out, "enterFail") };
3857
4396
  if (out.active === sessionId) setLastVoiceSession(sessionId);
@@ -3864,10 +4403,12 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3864
4403
  return { ok: false, error: t("enterFail") };
3865
4404
  }
3866
4405
  },
3867
- async exit(sessionId) {
4406
+ async exit(sessionId, keepAudio) {
3868
4407
  resetTelemetry();
3869
4408
  ui.turn = "idle";
3870
- doSkipAudio();
4409
+ if (!keepAudio) {
4410
+ doSkipAudio();
4411
+ }
3871
4412
  try {
3872
4413
  const res = await fetch(`${location.origin}${basePath}/toggle`, {
3873
4414
  method: "POST",
@@ -3911,10 +4452,50 @@ function createVoiceBus(basePath = BASE_PATH2, ctx) {
3911
4452
  } catch {
3912
4453
  }
3913
4454
  },
4455
+ steerSubmit(sessionId, text) {
4456
+ try {
4457
+ const session = ctx?.sessions?.binding?.(sessionId)?.session;
4458
+ return trySteerSubmit(session, text);
4459
+ } catch {
4460
+ return Promise.resolve(false);
4461
+ }
4462
+ },
3914
4463
  stampTelemetry,
3915
4464
  resetTelemetry,
3916
4465
  warmAudio() {
3917
4466
  engine.warm();
4467
+ },
4468
+ playbackLevel() {
4469
+ return engine.level();
4470
+ },
4471
+ runStarted(sessionId) {
4472
+ if (rejectSeqUpTo.get(sessionId) === STOP_READING_LINE) rejectSeqUpTo.delete(sessionId);
4473
+ stopUntilRun.delete(sessionId);
4474
+ },
4475
+ setFocusedSession(sessionId) {
4476
+ if (sessionId === null) {
4477
+ if (focusedSessionId === null) return;
4478
+ focusedSessionId = null;
4479
+ if (focusOwnerTab === TAB_ID) postFocus(null);
4480
+ return;
4481
+ }
4482
+ focusedSessionId = sessionId;
4483
+ if (typeof document === "undefined" || document.visibilityState === "visible") postFocus(sessionId);
4484
+ },
4485
+ stopReading(untilNextRun = false) {
4486
+ const sid = activeSessionId ?? focusedSessionId;
4487
+ doSkipAudio(sid);
4488
+ if (!sid) return;
4489
+ rejectSeqUpTo.set(sid, STOP_READING_LINE);
4490
+ if (untilNextRun) stopUntilRun.add(sid);
4491
+ else stopUntilRun.delete(sid);
4492
+ void fetch(`${location.origin}${basePath}/cancel`, {
4493
+ method: "POST",
4494
+ headers: { "content-type": "application/json" },
4495
+ body: JSON.stringify({ sessionId: sid, keepAsr: true }),
4496
+ signal: AbortSignal.timeout(3e3)
4497
+ }).catch(() => {
4498
+ });
3918
4499
  }
3919
4500
  };
3920
4501
  }
@@ -3941,12 +4522,124 @@ html.dshvm-holding, html.dshvm-holding * {
3941
4522
  }
3942
4523
  /* \u6279 3\uFF1A\u5B57\u5E55\u4E2D\u6587\u957F\u8BCD/URL \u6362\u884C\uFF08\u5916\u5C42 maxHeight:30vh + overflow:hidden \u63A7\u5236\u9AD8\u5EA6\u4E0D\u6EA2\u51FA\uFF09\u3002 */
3943
4524
  .dshvm-caption { word-break: break-word; overflow-wrap: anywhere; }
4525
+ /* \u9EA6\u514B\u98CE\u6309\u94AE\uFF08PR #16 by dyguests\uFF09\uFF1A\u72B6\u6001\u5168\u5728\u6309\u94AE\u4E0A\u2014\u2014\u989C\u8272\u533A\u5206\u6A21\u5F0F\uFF0C\u7AD6\u6761\u8DDF\u968F\u7535\u5E73\uFF0C
4526
+ \u7B49\u5F85\u8F6C\u5708\u3001\u6536\u5C3E\u5BF9\u52FE\u3001\u53F3\u4E0A\u6A59\u70B9=\u68C0\u6D4B\u5230\u8BF4\u8BDD\u3001\u5DE6\u4E0A\u7EA2\u70B9=\u51FA\u9519\u3002\u989C\u8272\u8D70 dsw \u53D8\u91CF\uFF0C\u65E7\u5BBF\u4E3B\u65E0\u53D8\u91CF\u65F6\u7528\u515C\u5E95\u8272\u3002 */
4527
+ .dshvm-mic {
4528
+ position: relative; flex: none; width: 34px; height: 34px; padding: 0;
4529
+ display: grid; place-items: center; border: none; border-radius: 999px;
4530
+ background: transparent; color: var(--dsw-alias-label-secondary, #8b949e); cursor: pointer;
4531
+ transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
4532
+ touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
4533
+ }
4534
+ .dshvm-mic:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(139,148,158,.14)); }
4535
+ .dshvm-mic:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #58a6ff); outline-offset: -2px; }
4536
+ .dshvm-mic svg { display: block; }
4537
+ .dshvm-mic[data-state="pending"] { --c: var(--dsw-alias-state-business-primary, #58a6ff); }
4538
+ .dshvm-mic[data-state="on"] { --c: var(--dsw-alias-state-success-primary, #2ea043); }
4539
+ .dshvm-mic[data-state="hold"] { --c: var(--dsw-alias-state-business-primary, #58a6ff); }
4540
+ .dshvm-mic[data-state="holding"] { --c: var(--dsw-alias-state-error-primary, #f85149); }
4541
+ .dshvm-mic[data-state="reading"] { --c: var(--dsw-alias-state-business-primary, #58a6ff); }
4542
+ .dshvm-mic[data-state="waiting"], .dshvm-mic[data-state="ending"] { --c: var(--dsw-alias-label-tertiary, #8b949e); }
4543
+ .dshvm-mic[data-state]:not([data-state="off"]) { color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
4544
+ .dshvm-mic[data-state="on"], .dshvm-mic[data-state="reading"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 10%, transparent); }
4545
+ .dshvm-mic[data-state]:not([data-state="off"]):hover { background: color-mix(in srgb, var(--c) 20%, transparent); }
4546
+ .dshvm-eq { display: inline-flex; align-items: center; justify-content: center; gap: 2px; width: 16px; height: 16px; pointer-events: none; }
4547
+ .dshvm-eq i { display: block; width: 3px; border-radius: 2px; background: currentColor; }
4548
+ .dshvm-eq-out { gap: 1.5px; }
4549
+ .dshvm-eq-out i { width: 2px; }
4550
+ .dshvm-mic-dot { position: absolute; top: 0; width: 7px; height: 7px; border-radius: 999px; pointer-events: none;
4551
+ box-shadow: 0 0 0 2px var(--dsw-specific-input-major, transparent); }
4552
+ .dshvm-mic-dot[data-kind="vad"] { right: 0; background: var(--dsw-alias-state-warn-primary, #d29922); }
4553
+ .dshvm-mic-dot[data-kind="error"] { left: 0; background: var(--dsw-alias-state-error-primary, #f85149); }
4554
+ .dshvm-mic-timer { position: absolute; left: 50%; top: calc(100% + 2px); transform: translateX(-50%); padding: 0 3px; border-radius: 4px;
4555
+ background: var(--dsw-specific-input-major, transparent); font-size: 9.5px; line-height: 12px; color: var(--dsw-alias-label-tertiary, #8b949e);
4556
+ font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
4557
+ .dshvm-spin { animation: dshvm-spin 0.9s linear infinite; }
4558
+ .dshvm-menu { display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: 10px;
4559
+ background: var(--dsw-alias-bg-layer-3, #fff); border: 1px solid var(--dsw-alias-border-l2, rgba(139,148,158,.35));
4560
+ box-shadow: 0 8px 24px rgba(15, 17, 21, 0.14); color: var(--dsw-alias-label-primary, inherit);
4561
+ font-family: inherit; font-size: 12px; animation: dshvm-fadein 0.12s ease; }
4562
+ .dshvm-menu-label { padding: 2px 8px 4px; font-size: 11px; color: var(--dsw-alias-label-tertiary, #8b949e); }
4563
+ .dshvm-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 5px 8px;
4564
+ border: none; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: 12px; text-align: left; }
4565
+ .dshvm-menu-item:hover, .dshvm-menu-item:focus-visible { background: var(--dsw-alias-interactive-bg-hover, rgba(139,148,158,.14)); outline: none; }
4566
+ .dshvm-menu-check { color: var(--dsw-alias-state-business-primary, #58a6ff); font-size: 11px; }
4567
+ .dshvm-menu-sep { height: 1px; margin: 4px 2px; background: var(--dsw-alias-border-l1, rgba(139,148,158,.25)); }
4568
+ @media (prefers-reduced-motion: reduce) { .dshvm-spin, .dshvm-menu { animation: none; } }
3944
4569
  `;
3945
4570
  document.head.appendChild(el);
3946
4571
  }, []);
3947
4572
  }
4573
+ var IS_MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent || "");
4574
+ var ONCE_SETTLE_MS = 1200;
4575
+ var ONCE_NO_START_MS = 3e4;
4576
+ var ONCE_STALL_MS = 1e4;
4577
+ function MicMenu({ scope, anchor, onClose }) {
4578
+ const [snap, setSnap] = (0, import_react3.useState)(() => scope.getSnapshot());
4579
+ (0, import_react3.useEffect)(() => scope.subscribe(() => setSnap({ ...scope.getSnapshot() })), [scope]);
4580
+ const menuRef = (0, import_react3.useRef)(null);
4581
+ (0, import_react3.useEffect)(() => {
4582
+ menuRef.current?.querySelector("button")?.focus();
4583
+ const onDown = (e) => {
4584
+ if (e.target instanceof Node && menuRef.current?.contains(e.target)) return;
4585
+ onClose(false);
4586
+ };
4587
+ const onKey = (e) => {
4588
+ if (e.key === "Escape") {
4589
+ e.preventDefault();
4590
+ onClose(true);
4591
+ return;
4592
+ }
4593
+ if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
4594
+ e.preventDefault();
4595
+ const items = Array.from(menuRef.current?.querySelectorAll("button") ?? []);
4596
+ const i = items.indexOf(document.activeElement);
4597
+ items[(i + (e.key === "ArrowDown" ? 1 : items.length - 1)) % items.length]?.focus();
4598
+ };
4599
+ document.addEventListener("pointerdown", onDown, true);
4600
+ document.addEventListener("keydown", onKey, true);
4601
+ return () => {
4602
+ document.removeEventListener("pointerdown", onDown, true);
4603
+ document.removeEventListener("keydown", onKey, true);
4604
+ };
4605
+ }, [onClose]);
4606
+ const v = snap.value ?? {};
4607
+ const width = 208;
4608
+ const r = anchor?.getBoundingClientRect();
4609
+ const below = !r || r.top < 340;
4610
+ const pos = {
4611
+ position: "fixed",
4612
+ zIndex: 9999,
4613
+ width,
4614
+ left: r ? Math.max(8, Math.min(window.innerWidth - width - 8, Math.round(r.right - width))) : 8,
4615
+ ...below ? { top: r ? Math.round(r.bottom + 8) : 96 } : { bottom: Math.round(window.innerHeight - r.top + 8) }
4616
+ };
4617
+ const item = (role, checked, label, onPick) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role, "aria-checked": checked, className: "dshvm-menu-item", onClick: onPick, children: [
4618
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label }),
4619
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshvm-menu-check", children: checked ? "\u2713" : "" })
4620
+ ] }, label);
4621
+ const set = (field, value) => void scope.set(field, value);
4622
+ const mode = v.mode === "hold" || v.mode === "once" ? v.mode : "toggle";
4623
+ const read = v.readAloud === "always" || v.readAloud === "off" ? v.readAloud : "voice";
4624
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: menuRef, className: "dshvm-menu", role: "menu", "aria-label": t("stateVoiceMode"), style: pos, children: [
4625
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dshvm-menu-label", children: t("modeLabel") }),
4626
+ ["toggle", "hold", "once"].map(
4627
+ (m) => item("menuitemradio", mode === m, t(m === "toggle" ? "modeToggle" : m === "hold" ? "modeHold" : "modeOnce"), () => set("mode", m))
4628
+ ),
4629
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dshvm-menu-sep" }),
4630
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dshvm-menu-label", children: t("readAloudLabel") }),
4631
+ ["voice", "always", "off"].map(
4632
+ (m) => item("menuitemradio", read === m, t(m === "voice" ? "readAloudVoice" : m === "always" ? "readAloudAlways" : "readAloudOff"), () => set("readAloud", m))
4633
+ ),
4634
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dshvm-menu-sep" }),
4635
+ item("menuitemcheckbox", v.showCaptions !== false, t("showCaptionsLabel"), () => set("showCaptions", v.showCaptions === false)),
4636
+ item("menuitemcheckbox", v.showStatusBar !== false, t("showStatusBarLabel"), () => set("showStatusBar", v.showStatusBar === false)),
4637
+ item("menuitemcheckbox", v.autoSend !== false, t("autoSendLabel"), () => set("autoSend", v.autoSend === false))
4638
+ ] });
4639
+ }
3948
4640
  function MicButton({
3949
4641
  bus,
4642
+ scope,
3950
4643
  sessionId,
3951
4644
  useSession,
3952
4645
  useInput,
@@ -3957,6 +4650,7 @@ function MicButton({
3957
4650
  const localRef = (0, import_react3.useRef)("off");
3958
4651
  const sidRef = (0, import_react3.useRef)(sessionId);
3959
4652
  const engineRef = (0, import_react3.useRef)(null);
4653
+ const micReadyRef = (0, import_react3.useRef)(false);
3960
4654
  const actionsRef = (0, import_react3.useRef)(inputActions);
3961
4655
  const submitTimerRef = (0, import_react3.useRef)(null);
3962
4656
  const autoSendTimerRef = (0, import_react3.useRef)(null);
@@ -3970,6 +4664,10 @@ function MicButton({
3970
4664
  const manualHoldRef = (0, import_react3.useRef)(false);
3971
4665
  const breakRef = (0, import_react3.useRef)(null);
3972
4666
  const pausedForHiddenRef = (0, import_react3.useRef)(false);
4667
+ const onceRef = (0, import_react3.useRef)(null);
4668
+ const [onceWaiting, setOnceWaiting] = (0, import_react3.useState)(false);
4669
+ const [onceEnding, setOnceEnding] = (0, import_react3.useState)(false);
4670
+ const toggleHistRef = (0, import_react3.useRef)([]);
3973
4671
  const bootNow = () => bus.ui.boot ?? {
3974
4672
  basePath: "/voice-mode",
3975
4673
  silenceMs: 1500,
@@ -3978,6 +4676,9 @@ function MicButton({
3978
4676
  autoSend: true,
3979
4677
  autoResume: false,
3980
4678
  mode: "toggle",
4679
+ readAloud: "voice",
4680
+ showCaptions: true,
4681
+ showStatusBar: true,
3981
4682
  // 批 7O(ADR-0006):bootNow 兜底默认与 VOICE_SETTINGS_DEFAULTS 对齐为 detect。
3982
4683
  bargeInMode: "detect",
3983
4684
  echoGateDb: 6,
@@ -3987,6 +4688,9 @@ function MicButton({
3987
4688
  captionFontSize: 0,
3988
4689
  captionMaxWidth: 1,
3989
4690
  backchannelYield: true,
4691
+ // Issue #15 批 1 / ADR-0012:打断语音抢救默认 true。
4692
+ bargeInSalvage: true,
4693
+ llmCorrect: false,
3990
4694
  yieldMs: 1500,
3991
4695
  // 批 B:5 ASR 字段默认值,与 src/index.ts VOICE_SETTINGS_DEFAULTS 对齐(plan §12 批 B 周全修复)。
3992
4696
  senseITN: true,
@@ -3994,8 +4698,12 @@ function MicButton({
3994
4698
  };
3995
4699
  useVoiceCss();
3996
4700
  const [, bumpUi] = (0, import_react3.useState)(0);
4701
+ const uiKeyRef = (0, import_react3.useRef)("");
3997
4702
  (0, import_react3.useEffect)(
3998
- () => bus.subscribe(() => {
4703
+ () => bus.subscribe(({ active, ui: u }) => {
4704
+ const key = `${active}|${u.state}|${u.error ?? ""}|${u.notice ?? ""}|${u.mode}|${u.wakeWord}|${u.ttsNotice ?? ""}|${u.playing}|${u.turn}|${u.sseDown}|${u.idleWarn}|${u.boot?.showStatusBar}`;
4705
+ if (key === uiKeyRef.current) return;
4706
+ uiKeyRef.current = key;
3999
4707
  bumpUi((t3) => t3 + 1);
4000
4708
  }),
4001
4709
  [bus]
@@ -4017,7 +4725,8 @@ function MicButton({
4017
4725
  idleTimeoutMinutes: c.idleTimeoutMinutes ?? cur.idleTimeoutMinutes,
4018
4726
  autoSend: c.autoSend ?? cur.autoSend,
4019
4727
  autoResume: c.autoResume === true,
4020
- mode: c.mode === "hold" ? "hold" : "toggle",
4728
+ mode: c.mode === "hold" || c.mode === "once" ? c.mode : "toggle",
4729
+ ...displaySettings(c),
4021
4730
  bargeInMode: c.bargeInMode === "manual" ? "manual" : c.bargeInMode === "detect" ? "detect" : "auto",
4022
4731
  echoGateDb: typeof c.echoGateDb === "number" ? Math.min(12, Math.max(3, c.echoGateDb)) : cur.echoGateDb,
4023
4732
  shortcut: typeof c.shortcut === "string" ? c.shortcut : cur.shortcut,
@@ -4028,6 +4737,9 @@ function MicButton({
4028
4737
  captionMaxWidth: c.captionMaxWidth === 0 || c.captionMaxWidth === 2 ? c.captionMaxWidth : 1,
4029
4738
  // 批 5:同模式(plan §7.2 表漏列 fetchConfig 字段透传,类批 3 captionFontSize 集成层补丁)
4030
4739
  backchannelYield: c.backchannelYield !== false,
4740
+ // Issue #15 批 1 / ADR-0012:打断语音抢救透传(同 backchannelYield 模式)。
4741
+ bargeInSalvage: c.bargeInSalvage !== false,
4742
+ llmCorrect: c.llmCorrect === true,
4031
4743
  // 批 G 任务 3:让位窗口时长(500-3000ms);类型校验严格 + 默认值兜底。
4032
4744
  yieldMs: typeof c.yieldMs === "number" && c.yieldMs >= 500 && c.yieldMs <= 3e3 ? c.yieldMs : 1500,
4033
4745
  // 批 B:5 ASR 字段透传(host /config handler 在 c2120d9 已透传 4 字段,本批补 senseVoice + 客户端白名单对齐)。
@@ -4035,7 +4747,9 @@ function MicButton({
4035
4747
  senseITN: c.senseITN === false ? false : true,
4036
4748
  senseVoice: c.senseVoice === false ? false : true
4037
4749
  };
4750
+ if (next.shortcut && !parseShortcut(next.shortcut)) bus.setNotice(tk("shortcutInvalid"));
4038
4751
  bus.setUi({ boot: next, mode: next.mode, wakeWord: next.wakeWord });
4752
+ setRuntimeBoot(next);
4039
4753
  return next;
4040
4754
  } catch {
4041
4755
  return bootNow();
@@ -4074,16 +4788,16 @@ function MicButton({
4074
4788
  const sid = sidRef.current;
4075
4789
  if (localRef.current === "on" && sid) {
4076
4790
  const quitMsg = t("idleTimeoutQuit");
4077
- bus.setUi({
4078
- error: bus.ui.error ?? quitMsg
4791
+ void exitModeRef.current("idle").then(() => {
4792
+ bus.setUi({ error: bus.ui.error ?? quitMsg });
4793
+ const prevClearError = idleClearErrorRef.current;
4794
+ if (prevClearError) clearTimeout(prevClearError);
4795
+ idleClearErrorRef.current = setTimeout(() => {
4796
+ idleClearErrorRef.current = null;
4797
+ if (bus.ui.error === quitMsg) bus.setUi({ error: null });
4798
+ }, 3e3);
4799
+ }).catch(() => {
4079
4800
  });
4080
- const prevClearError = idleClearErrorRef.current;
4081
- if (prevClearError) clearTimeout(prevClearError);
4082
- idleClearErrorRef.current = setTimeout(() => {
4083
- idleClearErrorRef.current = null;
4084
- if (bus.ui.error === quitMsg) bus.setUi({ error: null });
4085
- }, 3e3);
4086
- void exitModeRef.current("idle");
4087
4801
  }
4088
4802
  }, idleMs);
4089
4803
  };
@@ -4097,13 +4811,22 @@ function MicButton({
4097
4811
  cancelPendingSubmit();
4098
4812
  cancelAutoSend();
4099
4813
  clearBreakTimer();
4814
+ if (breakDotsTimerRef.current) {
4815
+ clearTimeout(breakDotsTimerRef.current);
4816
+ breakDotsTimerRef.current = null;
4817
+ }
4100
4818
  setHolding(false);
4101
4819
  isSpeechTrueCount = 0;
4820
+ isSpeechFalseRun = 0;
4821
+ submitInFlightRef.current = false;
4822
+ correctCycleRef.current++;
4823
+ clearOnce();
4102
4824
  breakRef.current = null;
4103
4825
  manualHoldRef.current = false;
4104
4826
  holdCtrlRef.current = false;
4105
4827
  const engine = engineRef.current;
4106
4828
  engineRef.current = null;
4829
+ micReadyRef.current = false;
4107
4830
  if (engine) void engine.stop();
4108
4831
  bus.resetTelemetry();
4109
4832
  bus.setUi({ state: "idle", partial: "", levels: [], botLevels: [], error: null, model: null, ttsNotice: null, isSpeech: void 0 });
@@ -4122,56 +4845,192 @@ function MicButton({
4122
4845
  autoSendTimerRef.current = null;
4123
4846
  }
4124
4847
  };
4848
+ const correctDraft = async (text) => {
4849
+ const hint = t("correctFixing");
4850
+ bus.setUi({ notice: hint });
4851
+ try {
4852
+ const r = await fetch(`${location.origin}${BASE_PATH2}/correct`, {
4853
+ method: "POST",
4854
+ headers: { "content-type": "application/json" },
4855
+ body: JSON.stringify({ text, lang: activeLocale() === "en" ? "en" : "zh" }),
4856
+ signal: AbortSignal.timeout(12e3)
4857
+ // 上限 12s——超时按原文发,不等纠错
4858
+ });
4859
+ if (bus.ui.notice === hint) bus.setUi({ notice: null });
4860
+ if (!r.ok) return text;
4861
+ const out = await r.json();
4862
+ const corrected = typeof out.text === "string" ? out.text.trim() : "";
4863
+ return corrected || text;
4864
+ } catch (e) {
4865
+ if (bus.ui.notice === hint) bus.setUi({ notice: null });
4866
+ if (e instanceof DOMException && e.name === "TimeoutError") bus.setNotice(t("correctAbandoned"));
4867
+ return text;
4868
+ }
4869
+ };
4125
4870
  const submitDraftNow = (expectedText) => {
4126
4871
  cancelPendingSubmit();
4127
4872
  const actions = actionsRef.current;
4128
4873
  const submitFn = actions?.submit;
4129
- if (typeof submitFn !== "function") return;
4874
+ if (typeof submitFn !== "function") {
4875
+ submitInFlightRef.current = false;
4876
+ return;
4877
+ }
4130
4878
  const draftSnapshot = (expectedText ?? draftRef.current).trim();
4131
- if (!draftSnapshot) return;
4132
- const doSubmit = () => {
4133
- try {
4134
- const r = submitFn();
4135
- if (r && typeof r.then === "function") {
4136
- r.catch(() => {
4137
- bus.setUi({ error: t("sendFailKept") });
4138
- });
4879
+ if (!draftSnapshot) {
4880
+ submitInFlightRef.current = false;
4881
+ return;
4882
+ }
4883
+ const runSubmit = (submitText) => {
4884
+ submitInFlightRef.current = true;
4885
+ if (bootNow().mode === "once") beginOnceWait();
4886
+ const snapshot = submitText.trim() || draftSnapshot;
4887
+ let wroteBack = false;
4888
+ if (snapshot !== draftSnapshot && typeof actions?.setDraft === "function") {
4889
+ try {
4890
+ actions.setDraft(snapshot);
4891
+ wroteBack = true;
4892
+ } catch {
4139
4893
  }
4140
- } catch {
4141
- bus.setUi({ error: t("sendFailKept") });
4142
4894
  }
4143
- };
4144
- doSubmit();
4145
- let retryCount = 0;
4146
- submitTimerRef.current = setInterval(() => {
4147
- retryCount++;
4148
- const phase = phaseRef.current;
4149
- if (retryCount > 3 || phase === "submitting" || phase === "adjudicating" || draftRef.current.trim() !== draftSnapshot) {
4150
- cancelPendingSubmit();
4895
+ const submitViaQueue = () => {
4896
+ const doSubmit = () => {
4897
+ try {
4898
+ const r = submitFn();
4899
+ if (r && typeof r.then === "function") {
4900
+ r.catch(() => {
4901
+ bus.setUi({ error: t("sendFailKept") });
4902
+ });
4903
+ }
4904
+ } catch {
4905
+ bus.setUi({ error: t("sendFailKept") });
4906
+ }
4907
+ };
4908
+ doSubmit();
4909
+ let retryCount = 0;
4910
+ submitTimerRef.current = setInterval(() => {
4911
+ retryCount++;
4912
+ const phase = phaseRef.current;
4913
+ if (retryCount > 3 || phase === "submitting" || phase === "adjudicating" || draftRef.current.trim() !== (wroteBack ? snapshot : draftSnapshot)) {
4914
+ cancelPendingSubmit();
4915
+ return;
4916
+ }
4917
+ doSubmit();
4918
+ }, 500);
4919
+ };
4920
+ const sid = sidRef.current;
4921
+ if (sid && shouldSteerSubmit(runningRef.current, snapshot)) {
4922
+ void bus.steerSubmit(sid, snapshot).then((delivered) => {
4923
+ if (delivered) {
4924
+ if (draftRef.current.trim() === (wroteBack ? snapshot : draftSnapshot)) {
4925
+ try {
4926
+ actions?.setDraft?.("");
4927
+ } catch {
4928
+ }
4929
+ }
4930
+ return;
4931
+ }
4932
+ submitViaQueue();
4933
+ }).catch(() => submitViaQueue());
4151
4934
  return;
4152
4935
  }
4153
- doSubmit();
4154
- }, 500);
4936
+ submitViaQueue();
4937
+ };
4938
+ if (bootNow().llmCorrect === true && !draftSnapshot.startsWith("/")) {
4939
+ const myCycle = ++correctCycleRef.current;
4940
+ void correctDraft(draftSnapshot).then((finalText) => {
4941
+ if (correctCycleRef.current !== myCycle) return;
4942
+ if (submitInFlightRef.current) return;
4943
+ if (draftRef.current.trim() !== draftSnapshot) return;
4944
+ if (engineRef.current?.state === "speech") return;
4945
+ runSubmit(finalText);
4946
+ });
4947
+ return;
4948
+ }
4949
+ runSubmit(draftSnapshot);
4155
4950
  };
4156
4951
  const scheduleAutoSend = () => {
4157
4952
  cancelAutoSend();
4158
- const delay = bootNow().silenceMs;
4159
4953
  autoSendTimerRef.current = setTimeout(() => {
4160
4954
  autoSendTimerRef.current = null;
4161
4955
  const eng = engineRef.current;
4162
4956
  if (eng && (eng.state === "speech" || eng.holding)) return;
4163
4957
  if (bus.ui.playing) return;
4164
- if (bootNow().autoSend === false) return;
4958
+ if (bootNow().autoSend === false) {
4959
+ if (bootNow().mode === "once") void exitModeRef.current("manual");
4960
+ return;
4961
+ }
4165
4962
  submitDraftNow();
4166
- }, delay);
4963
+ }, AUTO_SEND_EXTRA_MS);
4964
+ };
4965
+ const clearOnce = () => {
4966
+ const o = onceRef.current;
4967
+ if (!o) return;
4968
+ onceRef.current = null;
4969
+ clearTimeout(o.noStart);
4970
+ if (o.settle) clearTimeout(o.settle);
4971
+ if (o.stall) clearTimeout(o.stall);
4972
+ setOnceWaiting(false);
4973
+ setOnceEnding(false);
4974
+ };
4975
+ const checkOnce = () => {
4976
+ const o = onceRef.current;
4977
+ if (!o) return;
4978
+ const running = useSession ? runningRef.current : bus.ui.turn === "agent-speaking";
4979
+ if (running) o.sawRun = true;
4980
+ const quiet = o.sawRun && !running && !bus.ui.playing;
4981
+ const done = onceFinished(o, running, bus.ui.ttsDrained === true, bus.ui.playing);
4982
+ if (done && !o.settle) {
4983
+ setOnceEnding(true);
4984
+ o.settle = setTimeout(() => {
4985
+ if (onceRef.current === o) void exitModeRef.current("manual");
4986
+ }, ONCE_SETTLE_MS);
4987
+ } else if (!done && o.settle) {
4988
+ setOnceEnding(false);
4989
+ clearTimeout(o.settle);
4990
+ o.settle = null;
4991
+ }
4992
+ if (quiet && !o.stall) {
4993
+ o.stall = setTimeout(() => {
4994
+ if (onceRef.current === o) void exitModeRef.current("manual");
4995
+ }, ONCE_STALL_MS);
4996
+ } else if (!quiet && o.stall) {
4997
+ clearTimeout(o.stall);
4998
+ o.stall = null;
4999
+ }
4167
5000
  };
4168
- const exitMode = async (_reason) => {
5001
+ const beginOnceWait = () => {
5002
+ if (onceRef.current || localRef.current !== "on") return;
5003
+ cancelAutoSend();
5004
+ clearIdle();
5005
+ const o = {
5006
+ sawRun: false,
5007
+ settle: null,
5008
+ stall: null,
5009
+ noStart: setTimeout(() => {
5010
+ if (onceRef.current === o && !o.sawRun) void exitModeRef.current("manual");
5011
+ }, ONCE_NO_START_MS)
5012
+ };
5013
+ onceRef.current = o;
5014
+ setOnceWaiting(true);
5015
+ void engineRef.current?.stop();
5016
+ bus.setUi({ partial: "", levels: [], isSpeech: void 0 });
5017
+ checkOnce();
5018
+ };
5019
+ const exitMode = async (reason) => {
4169
5020
  if (localRef.current === "off") return;
4170
5021
  setLocalMode("off");
5022
+ clearOnce();
4171
5023
  clearIdle();
4172
5024
  cancelPendingSubmit();
4173
5025
  cancelAutoSend();
5026
+ submitInFlightRef.current = false;
5027
+ correctCycleRef.current++;
4174
5028
  isSpeechTrueCount = 0;
5029
+ isSpeechFalseRun = 0;
5030
+ if (breakDotsTimerRef.current) {
5031
+ clearTimeout(breakDotsTimerRef.current);
5032
+ breakDotsTimerRef.current = null;
5033
+ }
4175
5034
  fixtureRecorder.save("exit");
4176
5035
  breakRef.current = null;
4177
5036
  manualHoldRef.current = false;
@@ -4179,16 +5038,19 @@ function MicButton({
4179
5038
  setHolding(false);
4180
5039
  const engine = engineRef.current;
4181
5040
  engineRef.current = null;
5041
+ micReadyRef.current = false;
4182
5042
  if (engine) await engine.stop();
4183
5043
  bus.resetTelemetry();
4184
5044
  bus.setUi({ state: "idle", partial: "", levels: [], error: null, model: null, ttsNotice: null, isSpeech: void 0 });
4185
5045
  const sid = sidRef.current;
4186
- if (sid) await bus.exit(sid);
5046
+ if (sid) await bus.exit(sid, reason === "typing");
4187
5047
  };
4188
5048
  const enterMode = async () => {
4189
5049
  const sid = sidRef.current;
4190
5050
  if (!sid || localRef.current !== "off") return;
4191
5051
  isSpeechTrueCount = 0;
5052
+ isSpeechFalseRun = 0;
5053
+ micReadyRef.current = false;
4192
5054
  setLocalMode("pending");
4193
5055
  try {
4194
5056
  const entered = await bus.enter(sid);
@@ -4211,6 +5073,7 @@ function MicButton({
4211
5073
  const interruptLevel = cfg.interruptLevel;
4212
5074
  const confirmFrames = INT_CONFIRM_FRAMES[interruptLevel] ?? 2;
4213
5075
  let bargeInMode = cfg.bargeInMode;
5076
+ let echoRejectStreak = 0;
4214
5077
  debugLog("enter", {
4215
5078
  build: BUILD_TAG,
4216
5079
  mode: cfg.mode,
@@ -4223,6 +5086,9 @@ function MicButton({
4223
5086
  const hardBreak = async () => {
4224
5087
  bus.skipAudio();
4225
5088
  bus.unduckAudio();
5089
+ cancelAutoSend();
5090
+ submitInFlightRef.current = false;
5091
+ correctCycleRef.current++;
4226
5092
  bus.setBackchannelHold(0);
4227
5093
  if (runningRef.current && sidRef.current) {
4228
5094
  bus.cancelTurn(sidRef.current);
@@ -4238,13 +5104,19 @@ function MicButton({
4238
5104
  if (engineRef.current && !engineRef.current.holding) await engineRef.current.discardSegment();
4239
5105
  await cancelP;
4240
5106
  bus.setUi({ partial: "\u2026" });
5107
+ if (breakDotsTimerRef.current) clearTimeout(breakDotsTimerRef.current);
5108
+ breakDotsTimerRef.current = setTimeout(() => {
5109
+ breakDotsTimerRef.current = null;
5110
+ if (bus.ui.partial === "\u2026") bus.setUi({ partial: "" });
5111
+ }, 3e3);
4241
5112
  };
4242
5113
  breakRef.current = hardBreak;
4243
5114
  const engine = createAsrEngine(
4244
5115
  {
4245
5116
  silenceMs,
4246
5117
  basePath,
4247
- mode: cfg.mode,
5118
+ // once 的采音/断句/唤醒词与 toggle 完全一致,区别只在定稿后的收尾(见 onSegment)
5119
+ mode: cfg.mode === "hold" ? "hold" : "toggle",
4248
5120
  wakeWord: cfg.wakeWord,
4249
5121
  echoGateDb: cfg.echoGateDb,
4250
5122
  // 批 7N(ADR-0006):打断方式透传——manual 时 handleAudio 仅在 holdActive 期间入流。
@@ -4262,6 +5134,7 @@ function MicButton({
4262
5134
  if (!bus.ui.playing) {
4263
5135
  isSpeechTrueCount = 0;
4264
5136
  interruptFirstAt = 0;
5137
+ echoRejectStreak = 0;
4265
5138
  bus.setUi({ isSpeech: speech, echoDelayMs: bus.echoDelayMs(), echoLevels: engineRef.current?.echoLevels() });
4266
5139
  return;
4267
5140
  }
@@ -4291,6 +5164,7 @@ function MicButton({
4291
5164
  });
4292
5165
  isSpeechTrueCount = 0;
4293
5166
  interruptFirstAt = 0;
5167
+ if (++echoRejectStreak === 3) bus.setNotice(tk("echoRejectHint"));
4294
5168
  return;
4295
5169
  }
4296
5170
  const confirmMs = interruptFirstAt > 0 ? Date.now() - interruptFirstAt : 0;
@@ -4304,6 +5178,7 @@ function MicButton({
4304
5178
  });
4305
5179
  interruptFirstAt = 0;
4306
5180
  isSpeechTrueCount = 0;
5181
+ echoRejectStreak = 0;
4307
5182
  fixtureRecorder.mark("interrupt", `confirmMs=${confirmMs}`);
4308
5183
  resetIdle();
4309
5184
  bus.resetTelemetry();
@@ -4344,6 +5219,9 @@ function MicButton({
4344
5219
  bus.setUi({ boot: { ...bus.ui.boot, bargeInMode }, bargeInDetectFallback: !on2 });
4345
5220
  }
4346
5221
  },
5222
+ // TODO(Issue #15 UX M10,产品决策待 PM 登记):待机期(非播放期)附和词
5223
+ // 无护栏——matchBackchannel 只在朗读期让位路径消费,待机期用户说「嗯/对」
5224
+ // 会正常入段累积发送。是否加待机期短应答护栏需产品决策,此处只登记不改行为。
4347
5225
  // 批 5 / ADR-0008 Phase 1:backchannel 命中回调——
4348
5226
  // 立即 skipAudio 终止当前朗读 + 置 cfg.yieldMs hold 窗口,期间 TTS 帧丢(字幕同帧丢)。
4349
5227
  // 关 backchannelYield = 不挂回调,行为等同改造前(I10 豁免由 §7.0 ADR-0008 接受)。
@@ -4352,7 +5230,9 @@ function MicButton({
4352
5230
  bus.setBackchannelHold(Date.now() + (cfg.yieldMs ?? 1500));
4353
5231
  } : void 0,
4354
5232
  // 批 F:传 backchannelYield 给 ASR 引擎,让 asr.ts:379 守卫短路 matchBackchannel。
4355
- backchannelYield: cfg.backchannelYield
5233
+ backchannelYield: cfg.backchannelYield,
5234
+ // Issue #15 批 1 / ADR-0012:打断语音抢救透传给 ASR 引擎(预录环+hardBreak 并入)。
5235
+ bargeInSalvage: cfg.bargeInSalvage
4356
5236
  },
4357
5237
  sid
4358
5238
  );
@@ -4375,29 +5255,63 @@ function MicButton({
4375
5255
  engine.onState((s) => {
4376
5256
  bus.setUi({ state: s });
4377
5257
  if (s === "speech") cancelAutoSend();
4378
- if (s === "idle") resetIdle();
5258
+ if (s === "idle" && !onceRef.current) resetIdle();
4379
5259
  });
4380
5260
  engine.onError((key) => {
4381
5261
  bus.setUi({ error: t(key) });
4382
5262
  });
5263
+ engine.onNotice((key) => {
5264
+ if (engineRef.current !== engine) return;
5265
+ if (key === "backchannelDropped") {
5266
+ if (lastPartialRef.current) {
5267
+ const composed = composeDraft(draftRef.current, lastPartialRef.current, "");
5268
+ lastPartialRef.current = "";
5269
+ try {
5270
+ actionsRef.current?.setDraft?.(composed);
5271
+ } catch {
5272
+ }
5273
+ }
5274
+ bus.setUi({ partial: "" });
5275
+ }
5276
+ bus.setNotice(t(key));
5277
+ });
4383
5278
  engine.onLevel((l) => {
4384
5279
  const cur = bus.ui.levels;
4385
5280
  const next = cur.length < WAVE_BARS ? [...cur, l] : [...cur.slice(1), l];
4386
5281
  bus.setUi({ levels: next });
4387
5282
  });
4388
- engine.onPartial((text) => bus.setUi({ partial: text }));
5283
+ engine.onPartial((text) => {
5284
+ if (engineRef.current !== engine || onceRef.current) return;
5285
+ bus.setUi({ partial: text });
5286
+ if (!text) return;
5287
+ if (submitInFlightRef.current) {
5288
+ if (draftRef.current === "") submitInFlightRef.current = false;
5289
+ else return;
5290
+ }
5291
+ if (!shouldWritePartial(engineRef.current?.state ?? "")) return;
5292
+ cancelAutoSend();
5293
+ const partialActions = actionsRef.current;
5294
+ if (typeof partialActions?.setDraft !== "function") return;
5295
+ const composed = composeDraft(draftRef.current, lastPartialRef.current, text);
5296
+ if (!composed) return;
5297
+ lastPartialRef.current = text.trim();
5298
+ try {
5299
+ partialActions.setDraft(composed);
5300
+ } catch {
5301
+ }
5302
+ });
4389
5303
  engine.onSegment((text, meta) => {
5304
+ if (onceRef.current) return;
4390
5305
  resetIdle();
5306
+ submitInFlightRef.current = false;
4391
5307
  bus.setUi({ partial: "" });
4392
5308
  const actions = actionsRef.current;
4393
5309
  const trimmed = text.trim();
4394
5310
  if (!trimmed) return;
4395
- let nextDraft = trimmed;
5311
+ let nextDraft = composeDraft(draftRef.current, lastPartialRef.current, trimmed);
5312
+ lastPartialRef.current = "";
4396
5313
  try {
4397
- const curText = draftRef.current;
4398
- nextDraft = curText ? `${curText} ${trimmed}` : trimmed;
4399
5314
  if (typeof actions?.setDraft === "function") actions.setDraft(nextDraft);
4400
- else if (typeof actions?.setDraft === "function") actions.setDraft(nextDraft);
4401
5315
  } catch {
4402
5316
  try {
4403
5317
  actions?.setDraft?.(trimmed);
@@ -4411,7 +5325,7 @@ function MicButton({
4411
5325
  }
4412
5326
  if (bootNow().mode === "hold") return;
4413
5327
  if (bus.ui.playing) return;
4414
- if (bootNow().autoSend === false) return;
5328
+ if (bootNow().autoSend === false && bootNow().mode !== "once") return;
4415
5329
  scheduleAutoSend();
4416
5330
  });
4417
5331
  bus.setUi({ state: "idle", partial: "", levels: [], botLevels: [], error: null, model: null, ttsNotice: null });
@@ -4429,24 +5343,32 @@ function MicButton({
4429
5343
  }
4430
5344
  if (bus.activeSessionId !== sid) {
4431
5345
  engineRef.current = null;
5346
+ micReadyRef.current = false;
4432
5347
  await engine.stop();
4433
5348
  return;
4434
5349
  }
5350
+ micReadyRef.current = true;
4435
5351
  setLocalMode("on");
4436
5352
  resetIdle();
4437
5353
  } catch (e) {
4438
5354
  setLocalMode("off");
4439
- const msg = e instanceof DOMException ? e.name === "NotAllowedError" ? t("micDenied") : t("micUnavailable") : t("startFail").replace("{err}", String(e instanceof Error ? e.message : e));
5355
+ const msg = e instanceof DOMException ? e.name === "NotAllowedError" ? t("micDenied") : (
5356
+ // UX:NotReadableError = 麦克风被占用(其他程序/标签页)——与「不可用」
5357
+ // 混同时用户无从下手,分原因给可行动文案。
5358
+ e.name === "NotReadableError" ? t("micBusy") : t("micUnavailable")
5359
+ ) : t("startFail").replace("{err}", String(e instanceof Error ? e.message : e));
4440
5360
  bus.setUi({ error: msg });
4441
5361
  const sid2 = sidRef.current;
4442
5362
  if (sid2) void bus.exit(sid2);
4443
5363
  }
4444
5364
  };
4445
- const toggleGuardRef = (0, import_react3.useRef)(0);
5365
+ const readingOutside = () => localRef.current === "off" && bus.ui.playing;
4446
5366
  const toggle = () => {
4447
- const now = Date.now();
4448
- if (now - toggleGuardRef.current < 2e3) return;
4449
- toggleGuardRef.current = now;
5367
+ if (readingOutside()) {
5368
+ bus.stopReading(!!useSession);
5369
+ return;
5370
+ }
5371
+ if (!takeToggleSlot(toggleHistRef.current, Date.now())) return;
4450
5372
  if (localRef.current === "on") void exitModeRef.current("manual");
4451
5373
  else if (localRef.current === "off") void enterMode();
4452
5374
  };
@@ -4489,17 +5411,45 @@ function MicButton({
4489
5411
  })();
4490
5412
  }, [sessionId]);
4491
5413
  const runningSel = useSession ? useSession((s) => s === void 0 ? void 0 : s.running) : void 0;
5414
+ const prevRunningRef = (0, import_react3.useRef)(false);
4492
5415
  (0, import_react3.useEffect)(() => {
4493
5416
  runningRef.current = runningSel === true;
5417
+ if (runningSel === true && !prevRunningRef.current && sessionId) bus.runStarted(sessionId);
5418
+ prevRunningRef.current = runningSel === true;
5419
+ checkOnce();
4494
5420
  }, [runningSel]);
5421
+ (0, import_react3.useEffect)(() => bus.subscribe(() => checkOnce()), [bus]);
5422
+ (0, import_react3.useEffect)(() => {
5423
+ if (!sessionId) return;
5424
+ bus.setFocusedSession(sessionId);
5425
+ const onVis = () => {
5426
+ if (document.visibilityState === "visible") bus.setFocusedSession(sessionId);
5427
+ };
5428
+ document.addEventListener("visibilitychange", onVis);
5429
+ return () => {
5430
+ document.removeEventListener("visibilitychange", onVis);
5431
+ bus.setFocusedSession(null);
5432
+ };
5433
+ }, [bus, sessionId]);
4495
5434
  (0, import_react3.useEffect)(() => {
4496
5435
  mountedRef.current = true;
4497
5436
  return () => {
4498
5437
  mountedRef.current = false;
5438
+ clearOnce();
4499
5439
  clearIdle();
4500
5440
  cancelPendingSubmit();
4501
5441
  cancelAutoSend();
5442
+ submitInFlightRef.current = false;
5443
+ correctCycleRef.current++;
5444
+ micReadyRef.current = false;
4502
5445
  isSpeechTrueCount = 0;
5446
+ isSpeechFalseRun = 0;
5447
+ clearBreakTimer();
5448
+ breakRef.current = null;
5449
+ if (breakDotsTimerRef.current) {
5450
+ clearTimeout(breakDotsTimerRef.current);
5451
+ breakDotsTimerRef.current = null;
5452
+ }
4503
5453
  if (autoResumeHintTimerRef.current) {
4504
5454
  clearTimeout(autoResumeHintTimerRef.current);
4505
5455
  autoResumeHintTimerRef.current = null;
@@ -4543,7 +5493,7 @@ function MicButton({
4543
5493
  if (combo && !e.repeat && (e.key.toLowerCase() === combo.key || codeKey === combo.key) && e.ctrlKey === combo.ctrl && e.shiftKey === combo.shift && e.altKey === combo.alt && e.metaKey === combo.meta) {
4544
5494
  const el = e.target;
4545
5495
  const editable = el instanceof HTMLElement && (el.tagName === "TEXTAREA" || el.tagName === "INPUT" || el.isContentEditable);
4546
- if (!editable && !e.isComposing) {
5496
+ if (!e.isComposing && !(editable && isEditingShortcut(combo, IS_MAC))) {
4547
5497
  e.preventDefault();
4548
5498
  cancelCtrl();
4549
5499
  toggleRef.current();
@@ -4551,7 +5501,7 @@ function MicButton({
4551
5501
  return;
4552
5502
  }
4553
5503
  const eng = engineRef.current;
4554
- if (e.key === "Control" && !e.shiftKey && !e.altKey && !e.metaKey && !e.repeat && eng) {
5504
+ if (e.key === "Control" && !e.shiftKey && !e.altKey && !e.metaKey && !e.repeat && eng && !onceRef.current) {
4555
5505
  ctrlHoldStart = Date.now();
4556
5506
  otherKeyDuringCtrl = false;
4557
5507
  if (bootNow().mode === "hold") {
@@ -4623,7 +5573,7 @@ function MicButton({
4623
5573
  };
4624
5574
  const onVisibility = () => {
4625
5575
  if (document.hidden) {
4626
- if (localRef.current === "on" && engineRef.current) {
5576
+ if (localRef.current === "on" && engineRef.current && !onceRef.current) {
4627
5577
  if (bootNow().mode === "hold") {
4628
5578
  engineRef.current?.endHeld(true);
4629
5579
  holdCtrlRef.current = false;
@@ -4635,7 +5585,7 @@ function MicButton({
4635
5585
  } else if (pausedForHiddenRef.current && localRef.current === "on") {
4636
5586
  pausedForHiddenRef.current = false;
4637
5587
  void engineRef.current?.start().catch(() => {
4638
- setLocalMode("off");
5588
+ void exitModeRef.current("manual");
4639
5589
  });
4640
5590
  }
4641
5591
  };
@@ -4651,7 +5601,7 @@ function MicButton({
4651
5601
  const sid = sidRef.current;
4652
5602
  if (localRef.current === "pending" || localRef.current === "on") {
4653
5603
  if (bus.activeSessionId === sid) {
4654
- setLocalMode("on");
5604
+ if (localRef.current === "on" || micReadyRef.current) setLocalMode("on");
4655
5605
  } else if (localRef.current === "pending") {
4656
5606
  setLocalMode("off");
4657
5607
  }
@@ -4664,15 +5614,27 @@ function MicButton({
4664
5614
  const liveDraft = useInput ? useInput((s) => s?.draft ?? "") : "";
4665
5615
  const draftRef = (0, import_react3.useRef)("");
4666
5616
  draftRef.current = liveDraft;
5617
+ const lastPartialRef = (0, import_react3.useRef)("");
5618
+ const submitInFlightRef = (0, import_react3.useRef)(false);
5619
+ const correctCycleRef = (0, import_react3.useRef)(0);
4667
5620
  const livePhase = useInput ? useInput((s) => s?.phase ?? "") : "";
4668
5621
  const phaseRef = (0, import_react3.useRef)("");
4669
5622
  phaseRef.current = livePhase;
4670
5623
  const [holding, setHolding] = (0, import_react3.useState)(false);
4671
- const label = on ? busy ? t("recognizing") : holdMode ? holding ? t("releaseToSend") : t("holdToTalk") : bus.ui.state === "wake" ? t("sayWake").replace("{wake}", bus.ui.wakeWord || t("wakeWord")) : t("voiceDetected") : local === "pending" ? t("entering") : t("voiceBtn");
5624
+ const reading = local === "off" && bus.ui.playing;
5625
+ const showTurn = onceWaiting || bootNow().showStatusBar === false && bus.ui.state !== "speech" && (bus.ui.playing || bus.ui.turn === "agent-speaking");
5626
+ const label = on && showTurn ? bus.ui.playing ? t("reading") : t("thinking") : reading ? t("stopReading") : on ? busy ? (
5627
+ // UX:loading-model 是加载/下载模型而非识别——「识别中…」与状态不符。
5628
+ bus.ui.state === "loading-model" ? t("buttonLoading") : t("recognizing")
5629
+ ) : holdMode ? holding ? t("releaseToSend") : t("holdToTalk") : bus.ui.state === "wake" ? t("sayWake").replace("{wake}", bus.ui.wakeWord || t("wakeWord")) : (
5630
+ // UX:纯聆听态「语音中」与状态不符(并未在说话)→「聆听中」。
5631
+ t("buttonListening")
5632
+ ) : local === "pending" ? t("entering") : t("voiceBtn");
4672
5633
  const holdPtrRef = (0, import_react3.useRef)(null);
4673
5634
  const toggleHoldRef = (0, import_react3.useRef)(false);
4674
5635
  const suppressClickUntilRef = (0, import_react3.useRef)(0);
4675
5636
  const breakTimerRef = (0, import_react3.useRef)(null);
5637
+ const breakDotsTimerRef = (0, import_react3.useRef)(null);
4676
5638
  const clearBreakTimer = () => {
4677
5639
  if (breakTimerRef.current !== null) {
4678
5640
  clearTimeout(breakTimerRef.current);
@@ -4740,7 +5702,7 @@ function MicButton({
4740
5702
  }, 250);
4741
5703
  }
4742
5704
  }
4743
- } else if (localRef.current === "on" && bus.ui.playing) {
5705
+ } else if (localRef.current === "on" && bus.ui.playing && !onceRef.current) {
4744
5706
  toggleHoldRef.current = true;
4745
5707
  setHolding(true);
4746
5708
  const eng = engineRef.current;
@@ -4784,9 +5746,11 @@ function MicButton({
4784
5746
  return;
4785
5747
  }
4786
5748
  if (ms < 250) {
4787
- const now = Date.now();
4788
- if (now - toggleGuardRef.current < 2e3) return;
4789
- toggleGuardRef.current = now;
5749
+ if (readingOutside()) {
5750
+ bus.stopReading(!!useSession);
5751
+ return;
5752
+ }
5753
+ if (!takeToggleSlot(toggleHistRef.current, Date.now())) return;
4790
5754
  if (localRef.current === "on") {
4791
5755
  engineRef.current?.endHeld(true);
4792
5756
  void exitModeRef.current("manual");
@@ -4804,71 +5768,119 @@ function MicButton({
4804
5768
  setHolding(false);
4805
5769
  engineRef.current?.endHeld(true);
4806
5770
  };
4807
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4808
- "button",
4809
- {
4810
- onClick: (e) => {
4811
- if (Date.now() < suppressClickUntilRef.current) return;
4812
- if (holdMode) {
4813
- if (e.detail !== 0) return;
4814
- }
4815
- toggle();
4816
- },
4817
- onPointerDown,
4818
- onPointerMove,
4819
- onPointerUp,
4820
- onPointerCancel,
4821
- onContextMenu: (e) => e.preventDefault(),
4822
- ref: btnRef,
4823
- "data-dshvm": "mic",
4824
- "aria-label": on ? t("ariaActive") : t("ariaEnter"),
4825
- "aria-pressed": on,
4826
- title: on ? holdMode ? t("titleHold") : t("titleToggle") : t("titleEnter"),
4827
- style: {
4828
- border: holding ? "1px solid rgba(248, 81, 73, 0.6)" : on ? holdMode ? "1px solid rgba(88, 166, 255, 0.45)" : "1px solid rgba(63, 185, 80, 0.45)" : "1px solid rgba(139, 148, 158, 0.35)",
4829
- background: holding ? "rgba(248, 81, 73, 0.2)" : on ? holdMode ? "rgba(88, 166, 255, 0.16)" : "rgba(63, 185, 80, 0.16)" : local === "pending" ? "rgba(88, 166, 255, 0.14)" : "rgba(139, 148, 158, 0.08)",
4830
- cursor: "pointer",
4831
- padding: "5px 10px",
4832
- borderRadius: 8,
4833
- display: "flex",
4834
- alignItems: "center",
4835
- gap: 6,
4836
- fontSize: 12,
4837
- fontFamily: "system-ui, sans-serif",
4838
- color: holding ? "#f85149" : on ? holdMode ? "#58a6ff" : "#2ea043" : local === "pending" ? "#58a6ff" : "#8b949e",
4839
- // 批 H 任务 3:toggle 模式「语音中」绿字加深(#3fb950 → #2ea043)+ fontWeight:600 双保险,
4840
- // 浅色主题下与浅绿底 (rgba 63,185,80,.16) 对比度 ≥ 4.5:1(WCAG AA 文本级)。
4841
- fontWeight: on && !holdMode ? 600 : void 0,
4842
- transition: "background 0.15s ease, color 0.2s ease, border-color 0.15s ease",
4843
- touchAction: "none",
4844
- // 触摸设备上让 pointer 事件独占(滑出取消可用)
4845
- userSelect: "none",
4846
- WebkitUserSelect: "none",
4847
- // iOS Safari 前缀,防长按选中文字
4848
- WebkitTouchCallout: "none"
4849
- // iOS 长按弹出「拷贝/选择」菜单
4850
- },
4851
- children: [
4852
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, "aria-hidden": "true", children: [
4853
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4854
- "path",
4855
- {
4856
- fill: "currentColor",
4857
- d: "M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3Z"
4858
- }
4859
- ),
4860
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4861
- "path",
4862
- {
4863
- fill: "currentColor",
4864
- d: "M17.3 11a.9.9 0 0 0-1.8 0 3.5 3.5 0 0 1-7 0 .9.9 0 0 0-1.8 0 5.3 5.3 0 0 0 4.4 5.2v1.9h-1.7a.9.9 0 0 0 0 1.8h5.2a.9.9 0 0 0 0-1.8h-1.7v-1.9A5.3 5.3 0 0 0 17.3 11Z"
4865
- }
4866
- )
4867
- ] }),
4868
- label
4869
- ]
5771
+ const statusBarShown = bootNow().showStatusBar !== false;
5772
+ const micHint = bus.activeSessionId !== sessionId ? bus.ui.error ?? bus.ui.notice ?? "" : statusBarShown ? "" : bus.ui.error ?? (bus.ui.sseDown ? t("sseReconnect") : null) ?? bus.ui.notice ?? (bus.ui.idleWarn ? t("idleWarn30s") : null) ?? bus.ui.ttsNotice ?? "";
5773
+ const visual = holding ? "holding" : bus.ui.playing ? "reading" : on && onceEnding ? "ending" : on && onceWaiting ? "waiting" : on ? holdMode ? "hold" : "on" : local === "pending" ? "pending" : "off";
5774
+ const eqKind = visual === "reading" ? "out" : visual === "on" || visual === "holding" ? "in" : null;
5775
+ (0, import_react3.useEffect)(() => {
5776
+ const el = btnRef.current;
5777
+ if (!el || !eqKind) return;
5778
+ const bars = Array.from(el.querySelectorAll(".dshvm-eq i"));
5779
+ const base = eqKind === "out" ? [6, 10, 14, 10, 6] : [6, 12, 8];
5780
+ const paint = (lv) => bars.forEach((b, i) => b.style.height = `${Math.max(3, base[i] * (0.35 + 0.65 * lv)).toFixed(1)}px`);
5781
+ if (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches) {
5782
+ paint(1);
5783
+ return;
4870
5784
  }
4871
- );
5785
+ let smooth = 0;
5786
+ let raf = 0;
5787
+ const tick = () => {
5788
+ const raw = eqKind === "out" ? bus.playbackLevel() : bus.ui.levels[bus.ui.levels.length - 1] ?? 0;
5789
+ smooth = Math.max(Math.min(1, Math.max(0, raw)), smooth * 0.82);
5790
+ paint(smooth);
5791
+ raf = requestAnimationFrame(tick);
5792
+ };
5793
+ tick();
5794
+ return () => cancelAnimationFrame(raf);
5795
+ }, [eqKind, bus]);
5796
+ const showTimer = on && !statusBarShown && !onceWaiting;
5797
+ const [elapsed, setElapsed] = (0, import_react3.useState)(0);
5798
+ (0, import_react3.useEffect)(() => {
5799
+ setElapsed(0);
5800
+ if (!showTimer) return;
5801
+ const id = setInterval(() => setElapsed((n) => n + 1), 1e3);
5802
+ return () => clearInterval(id);
5803
+ }, [showTimer]);
5804
+ const [menuOpen, setMenuOpen] = (0, import_react3.useState)(false);
5805
+ const closeMenu = React.useCallback((refocus) => {
5806
+ setMenuOpen(false);
5807
+ if (refocus) btnRef.current?.focus();
5808
+ }, []);
5809
+ const title = bus.ui.error ? String(bus.ui.error) : reading ? t("stopReading") : on ? holdMode ? t("titleHold") : t("titleToggle") : t("titleEnter");
5810
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
5811
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
5812
+ "button",
5813
+ {
5814
+ type: "button",
5815
+ className: "dshvm-mic",
5816
+ "data-state": visual,
5817
+ onClick: (e) => {
5818
+ if (Date.now() < suppressClickUntilRef.current) return;
5819
+ if (holdMode && !readingOutside()) {
5820
+ if (e.detail !== 0) return;
5821
+ }
5822
+ toggle();
5823
+ },
5824
+ onPointerDown,
5825
+ onPointerMove,
5826
+ onPointerUp,
5827
+ onPointerCancel,
5828
+ onContextMenu: (e) => {
5829
+ e.preventDefault();
5830
+ const pt = e.nativeEvent.pointerType;
5831
+ if (scope && pt !== "touch" && pt !== "pen") setMenuOpen(true);
5832
+ },
5833
+ ref: btnRef,
5834
+ "data-dshvm": "mic",
5835
+ "aria-label": reading ? t("stopReading") : on ? `${t("ariaActive")} \xB7 ${label}` : local === "pending" ? label : t("ariaEnter"),
5836
+ "aria-pressed": on,
5837
+ "aria-haspopup": scope ? "menu" : void 0,
5838
+ "aria-expanded": scope ? menuOpen : void 0,
5839
+ title,
5840
+ children: [
5841
+ visual !== "waiting" && bus.ui.isSpeech === true && on && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshvm-mic-dot", "data-kind": "vad", title: t("vadDetected") }),
5842
+ bus.ui.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshvm-mic-dot", "data-kind": "error" }),
5843
+ visual === "waiting" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, "aria-hidden": "true", className: "dshvm-spin", children: [
5844
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: 12, cy: 12, r: 8, fill: "none", stroke: "currentColor", strokeWidth: 2, opacity: 0.25 }),
5845
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 4a8 8 0 0 1 8 8", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round" })
5846
+ ] }) : visual === "ending" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M5.5 12.5l4.2 4.2 8.8-8.8", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }) }) : eqKind ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: eqKind === "out" ? "dshvm-eq dshvm-eq-out" : "dshvm-eq", "aria-hidden": "true", children: (eqKind === "out" ? [6, 10, 14, 10, 6] : [6, 12, 8]).map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", { style: { height: h } }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, "aria-hidden": "true", children: [
5847
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { fill: "currentColor", d: "M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3Z" }),
5848
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5849
+ "path",
5850
+ {
5851
+ fill: "currentColor",
5852
+ d: "M17.3 11a.9.9 0 0 0-1.8 0 3.5 3.5 0 0 1-7 0 .9.9 0 0 0-1.8 0 5.3 5.3 0 0 0 4.4 5.2v1.9h-1.7a.9.9 0 0 0 0 1.8h5.2a.9.9 0 0 0 0-1.8h-1.7v-1.9A5.3 5.3 0 0 0 17.3 11Z"
5853
+ }
5854
+ )
5855
+ ] }),
5856
+ showTimer && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dshvm-mic-timer", "aria-hidden": "true", children: [
5857
+ String(Math.floor(elapsed / 60)).padStart(2, "0"),
5858
+ ":",
5859
+ String(elapsed % 60).padStart(2, "0")
5860
+ ] })
5861
+ ]
5862
+ }
5863
+ ),
5864
+ menuOpen && scope && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MicMenu, { scope, anchor: btnRef.current, onClose: closeMenu }),
5865
+ micHint && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5866
+ "span",
5867
+ {
5868
+ "data-dshvm": "mic-hint",
5869
+ role: "status",
5870
+ "aria-live": "polite",
5871
+ title: micHint,
5872
+ style: {
5873
+ fontSize: 11,
5874
+ color: "var(--dsw-alias-state-error-primary, #f85149)",
5875
+ maxWidth: 240,
5876
+ overflow: "hidden",
5877
+ textOverflow: "ellipsis",
5878
+ whiteSpace: "nowrap"
5879
+ },
5880
+ children: micHint
5881
+ }
5882
+ )
5883
+ ] });
4872
5884
  }
4873
5885
  function VoiceStatusBar({ bus, sessionId }) {
4874
5886
  useLang();
@@ -4885,9 +5897,37 @@ function VoiceStatusBar({ bus, sessionId }) {
4885
5897
  const id = setInterval(() => setElapsedSec((s) => s + 1), 1e3);
4886
5898
  return () => clearInterval(id);
4887
5899
  }, [b.active, sessionId]);
5900
+ const copyDiagnostics = async () => {
5901
+ const tel2 = b.ui.telemetry ?? {};
5902
+ const boot = b.ui.boot;
5903
+ const lines = [
5904
+ `dsh-voice-mode build=${BUILD_TAG}`,
5905
+ `state=${b.ui.state}${b.ui.error ? " error=" + b.ui.error : ""}${b.ui.sseDown ? " sse=down" : ""}`,
5906
+ boot ? `settings silenceMs=${boot.silenceMs} senseVoice=${boot.senseVoice} llmCorrect=${boot.llmCorrect} bargeInSalvage=${boot.bargeInSalvage} mode=${boot.mode} wakeWord=${boot.wakeWord ? "set" : "none"}` : "settings=unavailable",
5907
+ // telemetry 存的是各阶段绝对时刻(Date.now())——输出**相邻阶段差值**(与状态条同算法),
5908
+ // 不把绝对 epoch 当「ms 耗时」输出(审查 M1)。
5909
+ ...telemetryDeltas(tel2)
5910
+ ];
5911
+ const text = lines.join("\n");
5912
+ try {
5913
+ await navigator.clipboard.writeText(text);
5914
+ bus.setNotice(t("diagCopied"));
5915
+ } catch {
5916
+ bus.setNotice(t("diagCopyFailed"));
5917
+ }
5918
+ };
5919
+ const [transcribingSec, setTranscribingSec] = (0, import_react3.useState)(0);
5920
+ (0, import_react3.useEffect)(() => {
5921
+ if (b.ui.state !== "transcribing") {
5922
+ setTranscribingSec(0);
5923
+ return;
5924
+ }
5925
+ const id = setInterval(() => setTranscribingSec((s) => s + 1), 1e3);
5926
+ return () => clearInterval(id);
5927
+ }, [b.ui.state]);
4888
5928
  const isActive = b.active === sessionId;
4889
- if (!isActive) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, {});
4890
- const stateText = b.ui.state === "loading-model" ? t("loadingModel") : b.ui.state === "transcribing" ? t("recognizing") : b.ui.state === "wake" ? t("sayWake").replace("{wake}", b.ui.wakeWord || t("wakeWord")) : b.ui.state === "speech" ? b.ui.mode === "hold" ? t("holdDots") : t("listening") : b.ui.playing ? t("reading") : b.ui.turn === "agent-speaking" ? t("thinking") : b.ui.mode === "hold" ? t("barHold") : t("barListening");
5929
+ if (!isActive || b.ui.boot?.showStatusBar === false) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, {});
5930
+ const stateText = b.ui.state === "loading-model" ? t("loadingModel") : b.ui.state === "transcribing" ? transcribingSec >= 2 ? t("recognizingSec").replace("{sec}", String(transcribingSec)) : t("recognizing") : b.ui.state === "wake" ? t("sayWake").replace("{wake}", b.ui.wakeWord || t("wakeWord")) : b.ui.state === "speech" ? b.ui.mode === "hold" ? t("holdDots") : t("listening") : b.ui.playing ? t("reading") : b.ui.turn === "agent-speaking" ? t("thinking") : b.ui.mode === "hold" ? t("barHold") : t("barListening");
4891
5931
  const bars = Array.from({ length: WAVE_BARS }, (_, i) => b.ui.levels[i] ?? 0);
4892
5932
  const botBars = Array.from({ length: WAVE_BARS }, (_, i) => b.ui.botLevels[i] ?? 0);
4893
5933
  const telParts = [];
@@ -4904,7 +5944,7 @@ function VoiceStatusBar({ bus, sessionId }) {
4904
5944
  const end = tel["first-audio-played"];
4905
5945
  if (begin !== void 0 && end !== void 0) telParts.push(`${t("telTotal")} ${fmt(end - begin)}`);
4906
5946
  }
4907
- if (b.ui.interruptConfirmMs !== void 0) {
5947
+ if (telemetryEnabled && b.ui.interruptConfirmMs !== void 0) {
4908
5948
  telParts.push(`${t("interruptConfirm")} ${fmt(b.ui.interruptConfirmMs)}`);
4909
5949
  }
4910
5950
  if (telemetryEnabled && b.ui.echoLevels) {
@@ -4916,6 +5956,8 @@ function VoiceStatusBar({ bus, sessionId }) {
4916
5956
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4917
5957
  "div",
4918
5958
  {
5959
+ role: "status",
5960
+ "aria-live": "polite",
4919
5961
  style: {
4920
5962
  display: "flex",
4921
5963
  flexDirection: "column",
@@ -4968,7 +6010,27 @@ function VoiceStatusBar({ bus, sessionId }) {
4968
6010
  },
4969
6011
  i
4970
6012
  )) }),
4971
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flexGrow: 1 }, children: b.ui.error ? b.ui.error : b.ui.notice ? b.ui.notice : b.ui.idleWarn ? t("idleWarn30s") : b.ui.state === "loading-model" || b.ui.model ? b.ui.model ? `${t("loadingModel")} ${b.ui.model.file} ${b.ui.model.percent}%` : stateText : b.ui.playing || b.ui.turn === "agent-speaking" ? stateText : b.ui.state === "wake" && b.ui.partial ? `${stateText} \xB7 ${b.ui.partial}` : b.ui.partial ? b.ui.partial : b.ui.ttsNotice ? b.ui.ttsNotice : stateText }),
6013
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flexGrow: 1 }, children: b.ui.error ? b.ui.error : b.ui.sseDown ? t("sseReconnect") : b.ui.notice ? b.ui.notice : b.ui.idleWarn ? t("idleWarn30s") : b.ui.state === "loading-model" || b.ui.model ? b.ui.model ? `${t("loadingModel")} ${b.ui.model.file} ${b.ui.model.percent}%` : stateText : b.ui.playing || b.ui.turn === "agent-speaking" ? stateText : b.ui.state === "wake" && b.ui.partial ? `${stateText} \xB7 ${b.ui.partial}` : b.ui.partial ? b.ui.partial : b.ui.ttsNotice ? b.ui.ttsNotice : stateText }),
6014
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
6015
+ "button",
6016
+ {
6017
+ type: "button",
6018
+ "data-dshvm": "diag",
6019
+ title: t("diagCopy"),
6020
+ "aria-label": t("diagCopy"),
6021
+ onClick: () => void copyDiagnostics(),
6022
+ style: {
6023
+ flexShrink: 0,
6024
+ border: "none",
6025
+ background: "transparent",
6026
+ color: "var(--dsw-alias-label-tertiary)",
6027
+ cursor: "pointer",
6028
+ padding: "0 4px",
6029
+ fontSize: 11
6030
+ },
6031
+ children: t("diagCopy")
6032
+ }
6033
+ ),
4972
6034
  b.ui.isSpeech === true && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
4973
6035
  "span",
4974
6036
  {
@@ -4986,6 +6048,27 @@ function VoiceStatusBar({ bus, sessionId }) {
4986
6048
  children: t("vadDetected")
4987
6049
  }
4988
6050
  ),
6051
+ b.ui.ttsNotice && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
6052
+ "span",
6053
+ {
6054
+ title: b.ui.ttsNotice,
6055
+ style: {
6056
+ flexShrink: 0,
6057
+ maxWidth: 200,
6058
+ padding: "0 6px",
6059
+ borderRadius: 8,
6060
+ fontSize: 10,
6061
+ lineHeight: "16px",
6062
+ overflow: "hidden",
6063
+ textOverflow: "ellipsis",
6064
+ whiteSpace: "nowrap",
6065
+ color: "#ffa657",
6066
+ background: "rgba(255, 166, 87, 0.15)",
6067
+ border: "1px solid rgba(255, 166, 87, 0.35)"
6068
+ },
6069
+ children: b.ui.ttsNotice
6070
+ }
6071
+ ),
4989
6072
  elapsedSec > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
4990
6073
  "span",
4991
6074
  {
@@ -5066,7 +6149,7 @@ function VoiceOverlay({ bus }) {
5066
6149
  (0, import_react3.useEffect)(() => {
5067
6150
  return bus.subscribe(setB);
5068
6151
  }, [bus]);
5069
- if (!b.ui.playing) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, {});
6152
+ if (!b.ui.playing || b.ui.boot?.showCaptions === false) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, {});
5070
6153
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
5071
6154
  "div",
5072
6155
  {
@@ -5156,7 +6239,7 @@ function VoiceOverlay({ bus }) {
5156
6239
  pointerEvents: "auto"
5157
6240
  // 仅此按钮可点
5158
6241
  },
5159
- children: t("skip")
6242
+ children: t("skipReading")
5160
6243
  }
5161
6244
  )
5162
6245
  ]