@celljs/ta-meeting 4.34.0 → 4.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -3,7 +3,7 @@
3
3
  A pi package that comes with Ta (on by default, turned off in Settings → Extensions): meetings. Tap to start when a meeting starts and Ta writes down what is said; at the end, in a conversation of its own, it gives the minutes, the key points and the to-dos (who, when), and does the to-dos it can once you pick them.
4
4
 
5
5
  - **The Meetings page** (Discover → Work): a red button starts. While recording it shows the time and the words as they come; pause, resume, end and sum up, or discard. It goes on while you look elsewhere in Ta, and a row "Recording a meeting" on the double's home leads back.
6
- - **Transcription**: with a voice service chosen in Settings → Voice (OpenAI Realtime, Qwen, Hunyuan, Doubao), that service hears, its key staying in the Ta service; without one, the recognizer of the device (Apple's in the Ta app and the desktop app, the browser's own elsewhere). When the service drops or the microphone is taken, it pauses by itself and what was written down is kept.
6
+ - **Transcription**: with a voice service chosen in Settings → Voice (OpenAI Realtime, Qwen, Hunyuan, Doubao), that service hears, its key staying in the Ta service; without one, the recognizer of the device (Apple's in the Ta app and the desktop app, the browser's own elsewhere). While recording the screen stays on (the Ta app turns off auto-lock; the desktop app keeps the display awake and does not restart for an update mid-meeting). When the service drops, the network goes or the page is put away, it reconnects by itself (after 1, 2, 5, 10, 20, then 30 seconds; at once when the page shows again or the network is back), what was written down kept; only when the microphone or speech recognition is not allowed does it pause. Saving at the end is tried twice more when it fails.
7
7
  - **Text only**: no audio is recorded or kept. The text is saved every 30 seconds and once more at the end, in `meetings/<id>.txt` of the agent directory on this computer (0600), never through the relay.
8
8
  - **Summing up**: at the end a conversation named after the meeting opens, the words of the meeting in the context of its message, and Ta answers by the `meeting-notes` skill: one line, then one card (the to-dos, the key points, a multiple choice "Which should I do?", the full minutes folded). Once you pick: what can be done at once is done there; what takes days becomes a goal card; what is to happen at a time becomes a scheduled task; what goes to other people is only drafted, sent when you say so.
9
9
  - **Earlier meetings**: a row each with its title, time, length and characters; tap to go back to its minutes (or to sum it up when it was not), swipe left to remove its text (the conversation of its minutes stays).
@@ -22,4 +22,4 @@ The page writes down with `ui.voice.transcribe` (`WebVoice` of ta-web): through
22
22
  ```bash
23
23
  bun run build # tsc + bundles web/, host/
24
24
  bun run test
25
- ```
25
+ ```
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Ta 自带的 pi 包(默认开启,可在 设置 → 扩展 关闭):会议。开会时点一下开始,Ta 边听边记;结束后在一个单独的对话里给出纪要、重点和待办(谁、什么时候),你勾选后它把能做的待办接着做掉。
4
4
 
5
5
  - **会议页**(发现 → 工作):一个红色按钮开始记录。记录中显示时长、实时文字,可以暂停、继续、结束并整理或放弃。离开这页也会继续记,分身首页多一行「会议记录中」点回来。
6
- - **转写**:在 设置 → 语音 选了语音服务(OpenAI Realtime、通义、混元、豆包)时用它听写,Key 只在 Ta 服务里;没选就用本机的听写(Ta App 和桌面版用 Apple 的识别,浏览器用自带的)。服务断开或麦克风被占用时自动转为暂停,已记下的文字都在。
6
+ - **转写**:在 设置 → 语音 选了语音服务(OpenAI Realtime、通义、混元、豆包)时用它听写,Key 只在 Ta 服务里;没选就用本机的听写(Ta App 和桌面版用 Apple 的识别,浏览器用自带的)。记录时屏幕保持常亮(Ta App 关掉自动锁屏,桌面版不让显示器休眠、不在会中重启更新)。服务断开、断网或页面被切走时自动重连(1、2、5、10、20、30 秒递增,页面回到前台或网络恢复时立即重连),已记下的文字都在;只有麦克风或语音识别没有允许时才转为暂停。结束时保存失败会再试两次。
7
7
  - **只留文字**:不录音、不存音频。文字每 30 秒存一次,结束时再存一次,存在本机 agent 目录的 `meetings/<id>.txt`(0600),不经中继。
8
8
  - **整理**:结束后打开一个以会议命名的对话,消息的上下文里带着会议文字,Ta 按 `meeting-notes` 技能回复:一句结论,一张卡片(待办表、重点、「要我做哪些?」的多选、折叠的完整纪要)。你选了之后:一次能做完的当场做;跨天的写成目标卡;要定时的建定时任务;发给别人的只出草稿,你说发才发。
9
9
  - **记录过的会议**:每行是标题、时间、时长和字数;点开回到它的纪要对话(还没整理的就开始整理),左滑删除文字(纪要对话保留)。
@@ -22,4 +22,4 @@ Ta 自带的 pi 包(默认开启,可在 设置 → 扩展 关闭):会议
22
22
  ```bash
23
23
  bun run build # tsc + 打包 web/、host/
24
24
  bun run test
25
- ```
25
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-meeting",
3
- "version": "4.34.0",
3
+ "version": "4.35.0",
4
4
  "description": "A pi package for Ta: meetings written down as they are said, then minutes, key points and to-dos, and the to-dos Ta can do done once the user picks them",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,8 +27,8 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.34.0",
31
- "@celljs/ta-web": "4.34.0",
30
+ "@celljs/ta-protocol": "4.35.0",
31
+ "@celljs/ta-web": "4.35.0",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {
package/web/index.js CHANGED
@@ -47,6 +47,7 @@ var EN = {
47
47
  starting: "Starting…",
48
48
  recording: "Recording",
49
49
  paused: "Paused",
50
+ reconnecting: "Reconnecting…",
50
51
  viaService: "Heard by the service of Settings → Voice",
51
52
  viaDevice: "Heard by this device",
52
53
  listening: "Listening… what is said shows here",
@@ -66,6 +67,7 @@ var EN = {
66
67
  duration: "{n} min",
67
68
  chars: "{n} chars",
68
69
  cannotListen: "This device cannot listen. Add a voice service in Settings → Voice, or use the Ta app.",
70
+ retrying: "Listening broke off ({error}); reconnecting by itself (attempt {n}). What was written down is kept.",
69
71
  stopped: "Listening stopped ({error}); what was written down is kept. Resume or end it.",
70
72
  denied: "The microphone or speech recognition is not allowed; what was written down is kept. Allow it, then resume.",
71
73
  failed: "Failed: {error}",
@@ -88,6 +90,7 @@ var ZH = {
88
90
  starting: "正在开始…",
89
91
  recording: "记录中",
90
92
  paused: "已暂停",
93
+ reconnecting: "正在重新连接…",
91
94
  viaService: "用 设置 → 语音 里的服务转写",
92
95
  viaDevice: "用本机的听写",
93
96
  listening: "正在听…说的话会出现在这里",
@@ -107,6 +110,7 @@ var ZH = {
107
110
  duration: "{n} 分钟",
108
111
  chars: "{n} 字",
109
112
  cannotListen: "这台设备不能听写。在 设置 → 语音 添加一个语音服务,或用 Ta App。",
113
+ retrying: "听写断了({error}),正在自动重连(第 {n} 次),已记下的文字都在。",
110
114
  stopped: "听写停了({error}),已记下的文字都在。可以继续或结束。",
111
115
  denied: "麦克风或语音识别没有允许,已记下的文字都在。允许后点继续。",
112
116
  failed: "出错了:{error}",
@@ -129,6 +133,7 @@ var ZH_TW = {
129
133
  starting: "正在開始…",
130
134
  recording: "記錄中",
131
135
  paused: "已暫停",
136
+ reconnecting: "正在重新連線…",
132
137
  viaService: "用 設定 → 語音 裡的服務轉寫",
133
138
  viaDevice: "用本機的聽寫",
134
139
  listening: "正在聽…說的話會出現在這裡",
@@ -148,6 +153,7 @@ var ZH_TW = {
148
153
  duration: "{n} 分鐘",
149
154
  chars: "{n} 字",
150
155
  cannotListen: "這台裝置不能聽寫。在 設定 → 語音 新增一個語音服務,或用 Ta App。",
156
+ retrying: "聽寫斷了({error}),正在自動重連(第 {n} 次),已記下的文字都在。",
151
157
  stopped: "聽寫停了({error}),已記下的文字都在。可以繼續或結束。",
152
158
  denied: "麥克風或語音辨識沒有允許,已記下的文字都在。允許後點繼續。",
153
159
  failed: "出錯了:{error}",
@@ -170,6 +176,7 @@ var JA = {
170
176
  starting: "開始中…",
171
177
  recording: "記録中",
172
178
  paused: "一時停止中",
179
+ reconnecting: "再接続中…",
173
180
  viaService: "設定 → 音声 のサービスで書き取り",
174
181
  viaDevice: "この端末の音声入力で書き取り",
175
182
  listening: "聞いています…話した内容がここに出ます",
@@ -189,6 +196,7 @@ var JA = {
189
196
  duration: "{n} 分",
190
197
  chars: "{n} 文字",
191
198
  cannotListen: "この端末は音声入力できません。設定 → 音声 でサービスを追加するか、Ta アプリを使ってください。",
199
+ retrying: "書き取りが途切れました({error})。自動で再接続しています({n} 回目)。書き取った文字は残っています。",
192
200
  stopped: "書き取りが止まりました({error})。書き取った文字は残っています。再開か終了を選んでください。",
193
201
  denied: "マイクまたは音声認識が許可されていません。書き取った文字は残っています。許可してから再開してください。",
194
202
  failed: "失敗しました:{error}",
@@ -367,6 +375,297 @@ function bind(react) {
367
375
  React = react;
368
376
  }
369
377
 
378
+ // web-src/recorder.ts
379
+ var SAVE_MS = 30000;
380
+ var RETRY_MS = [1000, 2000, 5000, 1e4, 20000, 30000];
381
+ var STEADY_MS = 60000;
382
+ var SAVE_RETRY_MS = [1000, 3000];
383
+
384
+ class Recorder {
385
+ host;
386
+ status = "idle";
387
+ meeting;
388
+ segments = [];
389
+ interim = "";
390
+ service = false;
391
+ error;
392
+ retries = 0;
393
+ interimAt = 0;
394
+ activeMs = 0;
395
+ resumedAt;
396
+ transcribing;
397
+ runs = 0;
398
+ dirty = false;
399
+ timer;
400
+ listenedAt = 0;
401
+ connecting = false;
402
+ cancelRetry;
403
+ unwatch;
404
+ letAwakeGo;
405
+ listeners = new Set;
406
+ constructor(host) {
407
+ this.host = host;
408
+ }
409
+ subscribe(listener) {
410
+ this.listeners.add(listener);
411
+ return () => this.listeners.delete(listener);
412
+ }
413
+ elapsed() {
414
+ return this.activeMs + (this.resumedAt === undefined ? 0 : this.host.now() - this.resumedAt);
415
+ }
416
+ async start(title) {
417
+ if (this.status !== "idle") {
418
+ return false;
419
+ }
420
+ const now = this.host.now();
421
+ this.meeting = { id: MeetingUtil.newId(now), title, startedAt: now };
422
+ this.segments = [];
423
+ this.interim = "";
424
+ this.activeMs = 0;
425
+ this.error = undefined;
426
+ this.status = "starting";
427
+ this.emit();
428
+ if (!await this.listen()) {
429
+ this.reset();
430
+ return false;
431
+ }
432
+ this.timer = setInterval(() => void this.autosave(), SAVE_MS);
433
+ this.unwatch = this.host.watch?.(() => {
434
+ if (this.status === "reconnecting") {
435
+ this.reconnect();
436
+ }
437
+ });
438
+ return true;
439
+ }
440
+ pause() {
441
+ if (this.status !== "recording" && this.status !== "reconnecting") {
442
+ return;
443
+ }
444
+ this.stopRetrying();
445
+ this.halt();
446
+ this.status = "paused";
447
+ this.emit();
448
+ this.autosave(true);
449
+ }
450
+ async resume() {
451
+ if (this.status !== "paused") {
452
+ return false;
453
+ }
454
+ this.error = undefined;
455
+ this.retries = 0;
456
+ this.status = "starting";
457
+ this.emit();
458
+ if (await this.listen()) {
459
+ return true;
460
+ }
461
+ this.status = "paused";
462
+ this.emit();
463
+ return false;
464
+ }
465
+ async finish() {
466
+ if (!this.meeting || this.status === "idle" || this.status === "saving") {
467
+ return;
468
+ }
469
+ this.stopRetrying();
470
+ this.halt();
471
+ this.status = "saving";
472
+ this.emit();
473
+ const text = MeetingUtil.transcript(this.segments);
474
+ try {
475
+ const meeting = await this.saveEnd({ ...this.meeting, ms: this.elapsed() }, text);
476
+ this.reset();
477
+ return { meeting, text };
478
+ } catch (error) {
479
+ this.status = "paused";
480
+ this.emit();
481
+ throw error;
482
+ }
483
+ }
484
+ async discard() {
485
+ const meeting = this.meeting;
486
+ this.halt();
487
+ this.reset();
488
+ if (meeting) {
489
+ await this.host.remove(meeting.id).catch(() => {
490
+ return;
491
+ });
492
+ }
493
+ }
494
+ dispose() {
495
+ if (this.meeting && this.status !== "idle" && this.status !== "saving") {
496
+ this.finish().catch(() => {
497
+ return;
498
+ });
499
+ }
500
+ }
501
+ async saveEnd(meeting, text) {
502
+ for (let attempt = 0;; attempt++) {
503
+ try {
504
+ return await this.host.save(meeting, text);
505
+ } catch (error) {
506
+ if (attempt >= SAVE_RETRY_MS.length) {
507
+ throw error;
508
+ }
509
+ await new Promise((resolve) => this.later(resolve, SAVE_RETRY_MS[attempt]));
510
+ }
511
+ }
512
+ }
513
+ async listen() {
514
+ const run = ++this.runs;
515
+ let endedFirst;
516
+ const transcribing = await Promise.resolve(this.host.transcribe({
517
+ onText: (text, final) => {
518
+ if (run === this.runs) {
519
+ this.heard(text, final);
520
+ }
521
+ },
522
+ onEnd: (error) => {
523
+ if (run !== this.runs) {
524
+ return;
525
+ }
526
+ if (this.transcribing && this.status === "recording") {
527
+ this.broke(error ?? "ended");
528
+ } else if (!this.transcribing) {
529
+ endedFirst = error ?? "ended";
530
+ }
531
+ }
532
+ })).catch(() => {
533
+ return;
534
+ });
535
+ if (run !== this.runs || this.status !== "starting" && this.status !== "reconnecting") {
536
+ transcribing?.stop();
537
+ return false;
538
+ }
539
+ if (!transcribing) {
540
+ return false;
541
+ }
542
+ this.transcribing = transcribing;
543
+ this.service = transcribing.service;
544
+ this.resumedAt = this.listenedAt = this.host.now();
545
+ this.error = undefined;
546
+ this.status = "recording";
547
+ this.emit();
548
+ if (endedFirst !== undefined) {
549
+ this.broke(endedFirst);
550
+ }
551
+ return true;
552
+ }
553
+ broke(error) {
554
+ this.transcribing = undefined;
555
+ if (this.host.now() - this.listenedAt >= STEADY_MS) {
556
+ this.retries = 0;
557
+ }
558
+ this.halt();
559
+ this.error = error;
560
+ this.status = Recorder.denied(error) ? "paused" : "reconnecting";
561
+ this.emit();
562
+ this.autosave(true);
563
+ if (this.status === "reconnecting") {
564
+ this.retryLater();
565
+ }
566
+ }
567
+ static denied(error) {
568
+ return /not-allowed|denied|permission/i.test(error);
569
+ }
570
+ retryLater() {
571
+ this.cancelRetry?.();
572
+ this.cancelRetry = this.later(() => void this.reconnect(), RETRY_MS[Math.min(this.retries, RETRY_MS.length - 1)]);
573
+ }
574
+ async reconnect() {
575
+ if (this.status !== "reconnecting" || this.connecting) {
576
+ return;
577
+ }
578
+ this.cancelRetry?.();
579
+ this.cancelRetry = undefined;
580
+ this.retries++;
581
+ this.connecting = true;
582
+ this.emit();
583
+ let listening = false;
584
+ try {
585
+ listening = await this.listen();
586
+ } finally {
587
+ this.connecting = false;
588
+ }
589
+ if (!listening && this.status === "reconnecting") {
590
+ this.retryLater();
591
+ }
592
+ }
593
+ stopRetrying() {
594
+ this.cancelRetry?.();
595
+ this.cancelRetry = undefined;
596
+ }
597
+ later(run, ms) {
598
+ if (this.host.later) {
599
+ return this.host.later(run, ms);
600
+ }
601
+ const timer = setTimeout(run, ms);
602
+ return () => clearTimeout(timer);
603
+ }
604
+ heard(text, final) {
605
+ if (!this.interim) {
606
+ this.interimAt = this.elapsed();
607
+ }
608
+ if (final) {
609
+ this.segments.push({ at: this.interimAt, text });
610
+ this.interim = "";
611
+ this.dirty = true;
612
+ } else {
613
+ this.interim = text;
614
+ }
615
+ this.emit();
616
+ }
617
+ halt() {
618
+ const transcribing = this.transcribing;
619
+ this.transcribing = undefined;
620
+ transcribing?.stop();
621
+ if (this.resumedAt !== undefined) {
622
+ this.activeMs += this.host.now() - this.resumedAt;
623
+ this.resumedAt = undefined;
624
+ }
625
+ this.interim = "";
626
+ }
627
+ async autosave(force = false) {
628
+ if (!this.meeting || !this.dirty && !force) {
629
+ return;
630
+ }
631
+ this.dirty = false;
632
+ await this.host.save({ ...this.meeting, ms: this.elapsed(), recording: true }, MeetingUtil.transcript(this.segments)).catch(() => {
633
+ this.dirty = true;
634
+ });
635
+ }
636
+ reset() {
637
+ clearInterval(this.timer);
638
+ this.timer = undefined;
639
+ this.stopRetrying();
640
+ this.unwatch?.();
641
+ this.unwatch = undefined;
642
+ this.runs++;
643
+ this.status = "idle";
644
+ this.meeting = undefined;
645
+ this.segments = [];
646
+ this.interim = "";
647
+ this.activeMs = 0;
648
+ this.resumedAt = undefined;
649
+ this.dirty = false;
650
+ this.error = undefined;
651
+ this.retries = 0;
652
+ this.service = false;
653
+ this.emit();
654
+ }
655
+ emit() {
656
+ const awake = this.status === "starting" || this.status === "recording" || this.status === "reconnecting";
657
+ if (awake && !this.letAwakeGo) {
658
+ this.letAwakeGo = this.host.keepAwake?.();
659
+ } else if (!awake && this.letAwakeGo) {
660
+ this.letAwakeGo();
661
+ this.letAwakeGo = undefined;
662
+ }
663
+ for (const listener of this.listeners) {
664
+ listener();
665
+ }
666
+ }
667
+ }
668
+
370
669
  // ../ta-protocol/esm/common/message-protocol.js
371
670
  var TaMessageContext;
372
671
  (function(TaMessageContext2) {
@@ -795,7 +1094,13 @@ function Now({ context, words }) {
795
1094
  await recorder.discard();
796
1095
  }
797
1096
  };
798
- const label = status === "starting" ? words.starting : status === "saving" ? words.saving : status === "paused" ? words.paused : words.recording;
1097
+ const label = {
1098
+ starting: words.starting,
1099
+ saving: words.saving,
1100
+ paused: words.paused,
1101
+ reconnecting: words.reconnecting,
1102
+ recording: words.recording
1103
+ }[status];
799
1104
  return /* @__PURE__ */ React.createElement("section", {
800
1105
  className: "tmtg-now",
801
1106
  "data-status": status
@@ -813,7 +1118,7 @@ function Now({ context, words }) {
813
1118
  className: "tmtg-now-meta"
814
1119
  }, recorder.meeting?.title, status === "recording" ? ` · ${recorder.service ? words.viaService : words.viaDevice}` : ""), recorder.error && /* @__PURE__ */ React.createElement("div", {
815
1120
  className: "tmtg-now-error"
816
- }, /not-allowed/.test(recorder.error) ? words.denied : MeetingWords.format(words.stopped, { error: recorder.error })), /* @__PURE__ */ React.createElement("div", {
1121
+ }, status === "reconnecting" ? MeetingWords.format(words.retrying, { error: recorder.error, n: recorder.retries }) : Recorder.denied(recorder.error) ? words.denied : MeetingWords.format(words.stopped, { error: recorder.error })), /* @__PURE__ */ React.createElement("div", {
817
1122
  className: "tmtg-lines",
818
1123
  ref: lines
819
1124
  }, recorder.segments.length || recorder.interim ? /* @__PURE__ */ React.createElement(React.Fragment, null, recorder.segments.map((segment, index) => /* @__PURE__ */ React.createElement("p", {
@@ -839,7 +1144,7 @@ function Now({ context, words }) {
839
1144
  }, words.resume) : /* @__PURE__ */ React.createElement("button", {
840
1145
  type: "button",
841
1146
  className: "ta-button",
842
- disabled: busy || status !== "recording",
1147
+ disabled: busy || status !== "recording" && status !== "reconnecting",
843
1148
  onClick: () => recorder.pause()
844
1149
  }, words.pause), /* @__PURE__ */ React.createElement("button", {
845
1150
  type: "button",
@@ -891,199 +1196,6 @@ function MicIcon({ pi }) {
891
1196
  }) : null;
892
1197
  }
893
1198
 
894
- // web-src/recorder.ts
895
- var SAVE_MS = 30000;
896
-
897
- class Recorder {
898
- host;
899
- status = "idle";
900
- meeting;
901
- segments = [];
902
- interim = "";
903
- service = false;
904
- error;
905
- interimAt = 0;
906
- activeMs = 0;
907
- resumedAt;
908
- transcribing;
909
- runs = 0;
910
- dirty = false;
911
- timer;
912
- listeners = new Set;
913
- constructor(host) {
914
- this.host = host;
915
- }
916
- subscribe(listener) {
917
- this.listeners.add(listener);
918
- return () => this.listeners.delete(listener);
919
- }
920
- elapsed() {
921
- return this.activeMs + (this.resumedAt === undefined ? 0 : this.host.now() - this.resumedAt);
922
- }
923
- async start(title) {
924
- if (this.status !== "idle") {
925
- return false;
926
- }
927
- const now = this.host.now();
928
- this.meeting = { id: MeetingUtil.newId(now), title, startedAt: now };
929
- this.segments = [];
930
- this.interim = "";
931
- this.activeMs = 0;
932
- this.error = undefined;
933
- this.status = "starting";
934
- this.emit();
935
- if (!await this.listen()) {
936
- this.reset();
937
- return false;
938
- }
939
- this.timer = setInterval(() => void this.autosave(), SAVE_MS);
940
- return true;
941
- }
942
- pause() {
943
- if (this.status !== "recording") {
944
- return;
945
- }
946
- this.halt();
947
- this.status = "paused";
948
- this.emit();
949
- this.autosave(true);
950
- }
951
- async resume() {
952
- if (this.status !== "paused") {
953
- return false;
954
- }
955
- this.error = undefined;
956
- this.status = "starting";
957
- this.emit();
958
- if (await this.listen()) {
959
- return true;
960
- }
961
- this.status = "paused";
962
- this.emit();
963
- return false;
964
- }
965
- async finish() {
966
- if (!this.meeting || this.status === "idle" || this.status === "saving") {
967
- return;
968
- }
969
- this.halt();
970
- this.status = "saving";
971
- this.emit();
972
- const text = MeetingUtil.transcript(this.segments);
973
- try {
974
- const meeting = await this.host.save({ ...this.meeting, ms: this.elapsed() }, text);
975
- this.reset();
976
- return { meeting, text };
977
- } catch (error) {
978
- this.status = "paused";
979
- this.emit();
980
- throw error;
981
- }
982
- }
983
- async discard() {
984
- const meeting = this.meeting;
985
- this.halt();
986
- this.reset();
987
- if (meeting) {
988
- await this.host.remove(meeting.id).catch(() => {
989
- return;
990
- });
991
- }
992
- }
993
- dispose() {
994
- if (this.meeting && this.status !== "idle" && this.status !== "saving") {
995
- this.finish().catch(() => {
996
- return;
997
- });
998
- }
999
- }
1000
- async listen() {
1001
- const run = ++this.runs;
1002
- const transcribing = await this.host.transcribe({
1003
- onText: (text, final) => {
1004
- if (run === this.runs) {
1005
- this.heard(text, final);
1006
- }
1007
- },
1008
- onEnd: (error) => {
1009
- if (run === this.runs && this.transcribing && this.status === "recording") {
1010
- this.transcribing = undefined;
1011
- this.halt();
1012
- this.error = error ?? "ended";
1013
- this.status = "paused";
1014
- this.emit();
1015
- this.autosave(true);
1016
- }
1017
- }
1018
- });
1019
- if (run !== this.runs || this.status !== "starting") {
1020
- transcribing?.stop();
1021
- return false;
1022
- }
1023
- if (!transcribing) {
1024
- return false;
1025
- }
1026
- this.transcribing = transcribing;
1027
- this.service = transcribing.service;
1028
- this.resumedAt = this.host.now();
1029
- this.status = "recording";
1030
- this.emit();
1031
- return true;
1032
- }
1033
- heard(text, final) {
1034
- if (!this.interim) {
1035
- this.interimAt = this.elapsed();
1036
- }
1037
- if (final) {
1038
- this.segments.push({ at: this.interimAt, text });
1039
- this.interim = "";
1040
- this.dirty = true;
1041
- } else {
1042
- this.interim = text;
1043
- }
1044
- this.emit();
1045
- }
1046
- halt() {
1047
- const transcribing = this.transcribing;
1048
- this.transcribing = undefined;
1049
- transcribing?.stop();
1050
- if (this.resumedAt !== undefined) {
1051
- this.activeMs += this.host.now() - this.resumedAt;
1052
- this.resumedAt = undefined;
1053
- }
1054
- this.interim = "";
1055
- }
1056
- async autosave(force = false) {
1057
- if (!this.meeting || !this.dirty && !force) {
1058
- return;
1059
- }
1060
- this.dirty = false;
1061
- await this.host.save({ ...this.meeting, ms: this.elapsed(), recording: true }, MeetingUtil.transcript(this.segments)).catch(() => {
1062
- this.dirty = true;
1063
- });
1064
- }
1065
- reset() {
1066
- clearInterval(this.timer);
1067
- this.timer = undefined;
1068
- this.runs++;
1069
- this.status = "idle";
1070
- this.meeting = undefined;
1071
- this.segments = [];
1072
- this.interim = "";
1073
- this.activeMs = 0;
1074
- this.resumedAt = undefined;
1075
- this.dirty = false;
1076
- this.error = undefined;
1077
- this.service = false;
1078
- this.emit();
1079
- }
1080
- emit() {
1081
- for (const listener of this.listeners) {
1082
- listener();
1083
- }
1084
- }
1085
- }
1086
-
1087
1199
  // web-src/style.ts
1088
1200
  var STYLE = `
1089
1201
  .tmtg-page { height: 100%; overflow-y: auto; box-sizing: border-box; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); background: var(--ta-side); color: var(--ta-text); font-size: calc(14px * var(--ta-font-scale)); line-height: 1.5; }
@@ -1106,8 +1218,9 @@ var STYLE = `
1106
1218
  .tmtg-now-head { display: flex; align-items: center; gap: 8px; }
1107
1219
  .tmtg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ta-muted); }
1108
1220
  .tmtg-now[data-status='recording'] .tmtg-dot { background: var(--tmtg-rec); animation: tmtg-pulse 1.4s ease-in-out infinite; }
1221
+ .tmtg-now[data-status='reconnecting'] .tmtg-dot { background: #f59e0b; animation: tmtg-pulse 0.9s ease-in-out infinite; }
1109
1222
  @keyframes tmtg-pulse { 50% { opacity: 0.35; } }
1110
- @media (prefers-reduced-motion: reduce) { .tmtg-now[data-status='recording'] .tmtg-dot { animation: none; } }
1223
+ @media (prefers-reduced-motion: reduce) { .tmtg-now .tmtg-dot { animation: none !important; } }
1111
1224
  .tmtg-now-label { font-weight: 600; }
1112
1225
  .tmtg-clock { font-size: calc(22px * var(--ta-font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
1113
1226
  .tmtg-now-meta { margin-top: 2px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -1148,7 +1261,19 @@ function activate(pi) {
1148
1261
  transcribe: (listener) => pi.ui.voice.transcribe?.(listener),
1149
1262
  save: (meeting, text) => store.call("save", meeting, text),
1150
1263
  remove: (id) => store.call("remove", id),
1151
- now: Date.now
1264
+ now: Date.now,
1265
+ keepAwake: () => pi.ui.keepAwake?.() ?? (() => {
1266
+ return;
1267
+ }),
1268
+ watch: (again) => {
1269
+ const shown = () => document.visibilityState === "visible" && again();
1270
+ document.addEventListener("visibilitychange", shown);
1271
+ window.addEventListener("online", again);
1272
+ return () => {
1273
+ document.removeEventListener("visibilitychange", shown);
1274
+ window.removeEventListener("online", again);
1275
+ };
1276
+ }
1152
1277
  });
1153
1278
  const context = { pi, store, recorder };
1154
1279
  pi.registerView("home", {