@celljs/ta-meeting 4.35.0 → 4.36.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
@@ -7,13 +7,13 @@ A pi package that comes with Ta (on by default, turned off in Settings → Exten
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).
10
- - **Settings → Voice → Meetings**: how long the text is kept (30, 90, 180, 365 days, default 90) and the space it may take (10, 50, 200 MB, default 50); beyond them the oldest goes first, never the meeting being recorded nor the newest.
10
+ - **Settings → Storage → Meeting text**: how long the text is kept (30, 90, 180, 365 days or no limit, default 90) and the space it may take (10, 50, 200 MB or no limit, default 50), and clearing it; beyond them the oldest goes first, never the meeting being recorded nor the newest.
11
11
 
12
12
  ## Data and calls
13
13
 
14
- Package data (`@celljs/ta-meeting`, written by the server alone): `meetings` (the title, start and end, length, characters, size and conversation of the minutes of each), `settings` (`keepDays`, `maxMB`). The words of the meetings are in `meetings/` of the agent directory.
14
+ Package data (`@celljs/ta-meeting`, written by the server alone): `meetings` (the title, start and end, length, characters, size and conversation of the minutes of each). The words of the meetings are in `meetings/` of the agent directory.
15
15
 
16
- Server methods (the page calls them with `callHost`; only the user and members with `settings.manage` may): `list()`, `settings()`, `setSettings(change)`, `save(meeting, text)`, `get(id)`, `update(id, { title?, session? })`, `remove(id)`.
16
+ Server methods (the page calls them with `callHost`; only the user and members with `settings.manage` may): `list()`, `save(meeting, text)`, `get(id)`, `update(id, { title?, session? })`, `remove(id)`.
17
17
 
18
18
  The page writes down with `ui.voice.transcribe` (`WebVoice` of ta-web): through the Ta service when a voice service is chosen, else with the recognizer of the device; as a recognizer ends a stretch of speech, the next listening starts at once.
19
19
 
@@ -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
@@ -7,13 +7,13 @@ Ta 自带的 pi 包(默认开启,可在 设置 → 扩展 关闭):会议
7
7
  - **只留文字**:不录音、不存音频。文字每 30 秒存一次,结束时再存一次,存在本机 agent 目录的 `meetings/<id>.txt`(0600),不经中继。
8
8
  - **整理**:结束后打开一个以会议命名的对话,消息的上下文里带着会议文字,Ta 按 `meeting-notes` 技能回复:一句结论,一张卡片(待办表、重点、「要我做哪些?」的多选、折叠的完整纪要)。你选了之后:一次能做完的当场做;跨天的写成目标卡;要定时的建定时任务;发给别人的只出草稿,你说发才发。
9
9
  - **记录过的会议**:每行是标题、时间、时长和字数;点开回到它的纪要对话(还没整理的就开始整理),左滑删除文字(纪要对话保留)。
10
- - **设置 → 语音 → 会议**:文字保留天数(30、90、180、365 天,默认 90)和最多占用(10、50、200 MB,默认 50);超过的从最早的开始自动删除,正在记录的和最新的一场不删。
10
+ - **设置 → 存储空间 → 会议文字**:保留天数(30、90、180、365 天或不限,默认 90)和最多占用(10、50、200 MB 或不限,默认 50),也可一键清除;超过的从最早的开始自动删除,正在记录的和最新的一场不删。
11
11
 
12
12
  ## 数据与调用
13
13
 
14
- 包数据(`@celljs/ta-meeting`,只由服务端写):`meetings`(每场的标题、开始和结束时间、时长、字数、大小、纪要对话),`settings`(`keepDays`、`maxMB`)。会议文字在 agent 目录的 `meetings/`。
14
+ 包数据(`@celljs/ta-meeting`,只由服务端写):`meetings`(每场的标题、开始和结束时间、时长、字数、大小、纪要对话)。会议文字在 agent 目录的 `meetings/`。
15
15
 
16
- 服务端方法(页面经 `callHost` 调用;只有用户本人和有 `settings.manage` 的成员能调):`list()`、`settings()`、`setSettings(change)`、`save(meeting, text)`、`get(id)`、`update(id, { title?, session? })`、`remove(id)`。
16
+ 服务端方法(页面经 `callHost` 调用;只有用户本人和有 `settings.manage` 的成员能调):`list()`、`save(meeting, text)`、`get(id)`、`update(id, { title?, session? })`、`remove(id)`。
17
17
 
18
18
  页面用 `ui.voice.transcribe`(ta-web 的 `WebVoice`)连续听写:选了语音服务就由 Ta 服务转写,否则用本机的识别;识别器断句结束后立即接着听。
19
19
 
@@ -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/host/index.mjs CHANGED
@@ -8,9 +8,10 @@ var PAGE = `${NAME}/home`;
8
8
  var Keys;
9
9
  ((Keys) => {
10
10
  Keys.MEETINGS = "meetings";
11
- Keys.SETTINGS = "settings";
12
11
  })(Keys ||= {});
13
- var DEFAULT_SETTINGS = { keepDays: 90, maxMB: 50 };
12
+ var DEFAULT_LIMITS = { keepDays: 90, maxMB: 50 };
13
+ var KEEP_DAYS = [30, 90, 180, 365, 0];
14
+ var MAX_MB = [10, 50, 200, 0];
14
15
 
15
16
  // web-src/meeting-util.ts
16
17
  var DAY = 86400000;
@@ -26,15 +27,6 @@ var MeetingUtil;
26
27
  return `m${now.toString(36)}${Math.random().toString(36).slice(2, 8)}`;
27
28
  }
28
29
  MeetingUtil.newId = newId;
29
- function settings(raw) {
30
- const value = raw ?? {};
31
- const number = (n, min, max, fallback) => typeof n === "number" && Number.isFinite(n) ? Math.min(max, Math.max(min, Math.round(n))) : fallback;
32
- return {
33
- keepDays: number(value.keepDays, 1, 3650, DEFAULT_SETTINGS.keepDays),
34
- maxMB: number(value.maxMB, 1, 1024, DEFAULT_SETTINGS.maxMB)
35
- };
36
- }
37
- MeetingUtil.settings = settings;
38
30
  function meetings(raw) {
39
31
  if (!Array.isArray(raw)) {
40
32
  return [];
@@ -42,17 +34,17 @@ var MeetingUtil;
42
34
  return raw.filter((one) => !!one && validId(one.id) && typeof one.title === "string" && typeof one.startedAt === "number").sort((a, b) => b.startedAt - a.startedAt);
43
35
  }
44
36
  MeetingUtil.meetings = meetings;
45
- function prune(meetings2, settings2, now) {
37
+ function prune(meetings2, limits, now) {
46
38
  const removed = new Set;
47
39
  const oldFirst = [...meetings2].sort((a, b) => a.startedAt - b.startedAt);
48
40
  for (const one of oldFirst) {
49
- if (!one.recording && now - (one.endedAt ?? one.startedAt) > settings2.keepDays * DAY) {
41
+ if (limits.keepDays && !one.recording && now - (one.endedAt ?? one.startedAt) > limits.keepDays * DAY) {
50
42
  removed.add(one.id);
51
43
  }
52
44
  }
53
45
  let bytes = meetings2.filter((one) => !removed.has(one.id)).reduce((sum, one) => sum + (one.bytes || 0), 0);
54
46
  for (const one of oldFirst.slice(0, -1)) {
55
- if (bytes <= settings2.maxMB * MB) {
47
+ if (!limits.maxMB || bytes <= limits.maxMB * MB) {
56
48
  break;
57
49
  }
58
50
  if (!one.recording && !removed.has(one.id)) {
@@ -103,28 +95,48 @@ class MeetingHost {
103
95
  host;
104
96
  now;
105
97
  queue = Promise.resolve();
98
+ stored;
106
99
  constructor(host, now = Date.now) {
107
100
  this.host = host;
108
101
  this.now = now;
109
102
  }
110
- dispose() {}
103
+ dispose() {
104
+ this.stored?.dispose();
105
+ }
111
106
  begin() {
107
+ this.stored = this.host.storage?.register({
108
+ name: "meetings",
109
+ title: { "zh-CN": "会议文字", "zh-TW": "會議文字", "en-US": "Meeting text", "ja-JP": "会議の文字" },
110
+ hint: {
111
+ "zh-CN": "会议记下的文字;正在记录的和最近一场不会删,整理纪要的对话保留。",
112
+ "zh-TW": "會議記下的文字;正在記錄的和最近一場不會刪,整理紀要的對話保留。",
113
+ "en-US": "What meetings wrote down; never the one being recorded nor the newest. Conversations of the minutes stay.",
114
+ "ja-JP": "会議で書き取った文字。記録中と最新のものは消えません。議事録の会話は残ります。"
115
+ },
116
+ defaults: DEFAULT_LIMITS,
117
+ choices: { days: KEEP_DAYS, mb: MAX_MB },
118
+ order: 40
119
+ }, {
120
+ dir: this.dir(),
121
+ prune: (limits) => this.serial(async () => this.prune(await this.meetings(), limits)),
122
+ clear: () => this.clear()
123
+ });
112
124
  return this.serial(async () => {
113
- await this.prune(await this.meetings(), await this.settings());
125
+ await this.prune(await this.meetings(), this.limits());
114
126
  });
115
127
  }
116
128
  list() {
117
129
  return this.meetings();
118
130
  }
119
- async settings() {
120
- return MeetingUtil.settings(await this.data(Keys.SETTINGS));
121
- }
122
- setSettings(change) {
131
+ clear() {
123
132
  return this.serial(async () => {
124
- const settings = MeetingUtil.settings({ ...await this.settings(), ...change ?? {} });
125
- await this.host.setExtensionData(NAME, Keys.SETTINGS, settings);
126
- await this.prune(await this.meetings(), settings);
127
- return settings;
133
+ const meetings = await this.meetings();
134
+ const gone = meetings.filter((one) => !one.recording);
135
+ for (const one of gone) {
136
+ rmSync(this.file(one.id), { force: true });
137
+ }
138
+ await this.host.setExtensionData(NAME, Keys.MEETINGS, meetings.filter((one) => one.recording));
139
+ return gone.reduce((sum, one) => sum + (one.bytes || 0), 0);
128
140
  });
129
141
  }
130
142
  save(change, text) {
@@ -145,7 +157,7 @@ class MeetingHost {
145
157
  ...before?.session ? { session: before.session } : {}
146
158
  };
147
159
  const all = [meeting, ...meetings.filter((one) => one.id !== id)];
148
- await this.prune(all, await this.settings());
160
+ await this.prune(all, this.limits());
149
161
  return meeting;
150
162
  });
151
163
  }
@@ -185,8 +197,11 @@ class MeetingHost {
185
197
  await this.host.setExtensionData(NAME, Keys.MEETINGS, meetings.filter((one) => one.id !== checked));
186
198
  });
187
199
  }
188
- async prune(meetings, settings) {
189
- const removed = new Set(MeetingUtil.prune(meetings, settings, this.now()));
200
+ limits() {
201
+ return this.stored?.limits() ?? DEFAULT_LIMITS;
202
+ }
203
+ async prune(meetings, limits) {
204
+ const removed = new Set(MeetingUtil.prune(meetings, limits, this.now()));
190
205
  for (const id of removed) {
191
206
  rmSync(this.file(id), { force: true });
192
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-meeting",
3
- "version": "4.35.0",
3
+ "version": "4.36.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.35.0",
31
- "@celljs/ta-web": "4.35.0",
30
+ "@celljs/ta-protocol": "4.36.0",
31
+ "@celljs/ta-web": "4.36.0",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {
package/web/index.js CHANGED
@@ -70,16 +70,11 @@ var EN = {
70
70
  retrying: "Listening broke off ({error}); reconnecting by itself (attempt {n}). What was written down is kept.",
71
71
  stopped: "Listening stopped ({error}); what was written down is kept. Resume or end it.",
72
72
  denied: "The microphone or speech recognition is not allowed; what was written down is kept. Allow it, then resume.",
73
+ micBusy: "The microphone is in use (a call?); it goes on by itself once it is free. What was written down is kept.",
73
74
  failed: "Failed: {error}",
74
75
  prompt: "Sum up this meeting: the minutes, the key points and the to-dos, and let me pick what you can do.",
75
76
  homeRecording: "Recording a meeting",
76
- homeSince: "Since {time}",
77
- keepDays: "Keep meeting text",
78
- keepDaysHint: "Older text is removed by itself; the conversations of the minutes stay.",
79
- keepDaysValue: "{n} days",
80
- maxMB: "Space for meeting text",
81
- maxMBHint: "Beyond it, the oldest text goes first.",
82
- maxMBValue: "{n} MB"
77
+ homeSince: "Since {time}"
83
78
  };
84
79
  var ZH = {
85
80
  title: "会议",
@@ -113,16 +108,11 @@ var ZH = {
113
108
  retrying: "听写断了({error}),正在自动重连(第 {n} 次),已记下的文字都在。",
114
109
  stopped: "听写停了({error}),已记下的文字都在。可以继续或结束。",
115
110
  denied: "麦克风或语音识别没有允许,已记下的文字都在。允许后点继续。",
111
+ micBusy: "麦克风被占用(可能在通话),空出来后自动接着记,已记下的文字都在。",
116
112
  failed: "出错了:{error}",
117
113
  prompt: "整理这场会议:纪要、重点和待办,能替我做的列出来让我选。",
118
114
  homeRecording: "会议记录中",
119
- homeSince: "{time} 开始",
120
- keepDays: "会议文字保留",
121
- keepDaysHint: "超过天数的文字自动删除,整理纪要的对话保留。",
122
- keepDaysValue: "{n} 天",
123
- maxMB: "会议文字最多占用",
124
- maxMBHint: "超过后先删最早的。",
125
- maxMBValue: "{n} MB"
115
+ homeSince: "{time} 开始"
126
116
  };
127
117
  var ZH_TW = {
128
118
  title: "會議",
@@ -156,16 +146,11 @@ var ZH_TW = {
156
146
  retrying: "聽寫斷了({error}),正在自動重連(第 {n} 次),已記下的文字都在。",
157
147
  stopped: "聽寫停了({error}),已記下的文字都在。可以繼續或結束。",
158
148
  denied: "麥克風或語音辨識沒有允許,已記下的文字都在。允許後點繼續。",
149
+ micBusy: "麥克風被佔用(可能在通話),空出來後自動接著記,已記下的文字都在。",
159
150
  failed: "出錯了:{error}",
160
151
  prompt: "整理這場會議:紀要、重點和待辦,能替我做的列出來讓我選。",
161
152
  homeRecording: "會議記錄中",
162
- homeSince: "{time} 開始",
163
- keepDays: "會議文字保留",
164
- keepDaysHint: "超過天數的文字自動刪除,整理紀要的對話保留。",
165
- keepDaysValue: "{n} 天",
166
- maxMB: "會議文字最多佔用",
167
- maxMBHint: "超過後先刪最早的。",
168
- maxMBValue: "{n} MB"
153
+ homeSince: "{time} 開始"
169
154
  };
170
155
  var JA = {
171
156
  title: "会議",
@@ -199,16 +184,11 @@ var JA = {
199
184
  retrying: "書き取りが途切れました({error})。自動で再接続しています({n} 回目)。書き取った文字は残っています。",
200
185
  stopped: "書き取りが止まりました({error})。書き取った文字は残っています。再開か終了を選んでください。",
201
186
  denied: "マイクまたは音声認識が許可されていません。書き取った文字は残っています。許可してから再開してください。",
187
+ micBusy: "マイクが使用中です(通話中かもしれません)。空いたら自動で続けます。書き取った文字は残っています。",
202
188
  failed: "失敗しました:{error}",
203
189
  prompt: "この会議をまとめて:議事録・要点・ToDo。あなたができるものは選べるようにして。",
204
190
  homeRecording: "会議を記録中",
205
- homeSince: "{time} から",
206
- keepDays: "会議の文字の保存期間",
207
- keepDaysHint: "過ぎた文字は自動で削除されます。議事録の会話は残ります。",
208
- keepDaysValue: "{n} 日",
209
- maxMB: "会議の文字の上限",
210
- maxMBHint: "超えたら古いものから削除します。",
211
- maxMBValue: "{n} MB"
191
+ homeSince: "{time} から"
212
192
  };
213
193
  var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
214
194
  var MeetingWords;
@@ -229,11 +209,7 @@ var PAGE = `${NAME}/home`;
229
209
  var Keys;
230
210
  ((Keys) => {
231
211
  Keys.MEETINGS = "meetings";
232
- Keys.SETTINGS = "settings";
233
212
  })(Keys ||= {});
234
- var DEFAULT_SETTINGS = { keepDays: 90, maxMB: 50 };
235
- var KEEP_DAYS = [30, 90, 180, 365];
236
- var MAX_MB = [10, 50, 200];
237
213
 
238
214
  // web-src/meeting-util.ts
239
215
  var DAY = 86400000;
@@ -249,15 +225,6 @@ var MeetingUtil;
249
225
  return `m${now.toString(36)}${Math.random().toString(36).slice(2, 8)}`;
250
226
  }
251
227
  MeetingUtil.newId = newId;
252
- function settings(raw) {
253
- const value = raw ?? {};
254
- const number = (n, min, max, fallback) => typeof n === "number" && Number.isFinite(n) ? Math.min(max, Math.max(min, Math.round(n))) : fallback;
255
- return {
256
- keepDays: number(value.keepDays, 1, 3650, DEFAULT_SETTINGS.keepDays),
257
- maxMB: number(value.maxMB, 1, 1024, DEFAULT_SETTINGS.maxMB)
258
- };
259
- }
260
- MeetingUtil.settings = settings;
261
228
  function meetings(raw) {
262
229
  if (!Array.isArray(raw)) {
263
230
  return [];
@@ -265,17 +232,17 @@ var MeetingUtil;
265
232
  return raw.filter((one) => !!one && validId(one.id) && typeof one.title === "string" && typeof one.startedAt === "number").sort((a, b) => b.startedAt - a.startedAt);
266
233
  }
267
234
  MeetingUtil.meetings = meetings;
268
- function prune(meetings2, settings2, now) {
235
+ function prune(meetings2, limits, now) {
269
236
  const removed = new Set;
270
237
  const oldFirst = [...meetings2].sort((a, b) => a.startedAt - b.startedAt);
271
238
  for (const one of oldFirst) {
272
- if (!one.recording && now - (one.endedAt ?? one.startedAt) > settings2.keepDays * DAY) {
239
+ if (limits.keepDays && !one.recording && now - (one.endedAt ?? one.startedAt) > limits.keepDays * DAY) {
273
240
  removed.add(one.id);
274
241
  }
275
242
  }
276
243
  let bytes = meetings2.filter((one) => !removed.has(one.id)).reduce((sum, one) => sum + (one.bytes || 0), 0);
277
244
  for (const one of oldFirst.slice(0, -1)) {
278
- if (bytes <= settings2.maxMB * MB) {
245
+ if (!limits.maxMB || bytes <= limits.maxMB * MB) {
279
246
  break;
280
247
  }
281
248
  if (!one.recording && !removed.has(one.id)) {
@@ -323,7 +290,6 @@ var MeetingUtil;
323
290
  class MeetingStore {
324
291
  pi;
325
292
  meetings = [];
326
- settings = DEFAULT_SETTINGS;
327
293
  loaded = false;
328
294
  listeners = new Set;
329
295
  offChange;
@@ -334,7 +300,7 @@ class MeetingStore {
334
300
  this.listeners.add(listener);
335
301
  if (!this.offChange) {
336
302
  this.offChange = this.pi.storage.onChange((keys) => {
337
- if (keys.includes(Keys.MEETINGS) || keys.includes(Keys.SETTINGS)) {
303
+ if (keys.includes(Keys.MEETINGS)) {
338
304
  this.load();
339
305
  }
340
306
  });
@@ -343,16 +309,9 @@ class MeetingStore {
343
309
  return () => this.listeners.delete(listener);
344
310
  }
345
311
  async load() {
346
- const [meetings, settings] = await Promise.all([
347
- this.pi.storage.get(Keys.MEETINGS).catch(() => {
348
- return;
349
- }),
350
- this.pi.storage.get(Keys.SETTINGS).catch(() => {
351
- return;
352
- })
353
- ]);
354
- this.meetings = MeetingUtil.meetings(meetings);
355
- this.settings = MeetingUtil.settings(settings);
312
+ this.meetings = MeetingUtil.meetings(await this.pi.storage.get(Keys.MEETINGS).catch(() => {
313
+ return;
314
+ }));
356
315
  this.loaded = true;
357
316
  this.emit();
358
317
  }
@@ -379,6 +338,10 @@ function bind(react) {
379
338
  var SAVE_MS = 30000;
380
339
  var RETRY_MS = [1000, 2000, 5000, 1e4, 20000, 30000];
381
340
  var STEADY_MS = 60000;
341
+ var AWAY_MS = 3000;
342
+ var SILENT_MS = 30000;
343
+ var WATCH_MS = 5000;
344
+ var BUSY_RETRY_MS = 2000;
382
345
  var SAVE_RETRY_MS = [1000, 3000];
383
346
 
384
347
  class Recorder {
@@ -397,7 +360,10 @@ class Recorder {
397
360
  runs = 0;
398
361
  dirty = false;
399
362
  timer;
363
+ watching;
400
364
  listenedAt = 0;
365
+ heardAt = 0;
366
+ awayAt;
401
367
  connecting = false;
402
368
  cancelRetry;
403
369
  unwatch;
@@ -430,10 +396,9 @@ class Recorder {
430
396
  return false;
431
397
  }
432
398
  this.timer = setInterval(() => void this.autosave(), SAVE_MS);
433
- this.unwatch = this.host.watch?.(() => {
434
- if (this.status === "reconnecting") {
435
- this.reconnect();
436
- }
399
+ this.watching = setInterval(() => this.watchdog(), WATCH_MS);
400
+ this.unwatch = this.host.watch?.(() => this.again(), () => {
401
+ this.awayAt = this.host.now();
437
402
  });
438
403
  return true;
439
404
  }
@@ -542,6 +507,7 @@ class Recorder {
542
507
  this.transcribing = transcribing;
543
508
  this.service = transcribing.service;
544
509
  this.resumedAt = this.listenedAt = this.host.now();
510
+ this.awayAt = undefined;
545
511
  this.error = undefined;
546
512
  this.status = "recording";
547
513
  this.emit();
@@ -564,12 +530,37 @@ class Recorder {
564
530
  this.retryLater();
565
531
  }
566
532
  }
533
+ again() {
534
+ if (this.status === "reconnecting") {
535
+ this.reconnect();
536
+ } else if (this.status === "recording" && this.awayAt !== undefined && this.heardAt < this.awayAt && this.host.now() - this.awayAt >= AWAY_MS) {
537
+ this.restart();
538
+ }
539
+ }
540
+ watchdog() {
541
+ if (this.status === "recording" && !this.connecting && this.host.now() - Math.max(this.heardAt, this.listenedAt) >= SILENT_MS) {
542
+ this.restart();
543
+ }
544
+ }
545
+ restart() {
546
+ this.awayAt = undefined;
547
+ this.halt();
548
+ this.retries = 0;
549
+ this.error = undefined;
550
+ this.status = "reconnecting";
551
+ this.emit();
552
+ this.reconnect();
553
+ }
567
554
  static denied(error) {
568
555
  return /not-allowed|denied|permission/i.test(error);
569
556
  }
557
+ static busy(error) {
558
+ return /interrupted|audio-capture/i.test(error);
559
+ }
570
560
  retryLater() {
571
561
  this.cancelRetry?.();
572
- this.cancelRetry = this.later(() => void this.reconnect(), RETRY_MS[Math.min(this.retries, RETRY_MS.length - 1)]);
562
+ const ms = this.error && Recorder.busy(this.error) ? BUSY_RETRY_MS : RETRY_MS[Math.min(this.retries, RETRY_MS.length - 1)];
563
+ this.cancelRetry = this.later(() => void this.reconnect(), ms);
573
564
  }
574
565
  async reconnect() {
575
566
  if (this.status !== "reconnecting" || this.connecting) {
@@ -602,6 +593,7 @@ class Recorder {
602
593
  return () => clearTimeout(timer);
603
594
  }
604
595
  heard(text, final) {
596
+ this.heardAt = this.host.now();
605
597
  if (!this.interim) {
606
598
  this.interimAt = this.elapsed();
607
599
  }
@@ -635,7 +627,8 @@ class Recorder {
635
627
  }
636
628
  reset() {
637
629
  clearInterval(this.timer);
638
- this.timer = undefined;
630
+ clearInterval(this.watching);
631
+ this.timer = this.watching = undefined;
639
632
  this.stopRetrying();
640
633
  this.unwatch?.();
641
634
  this.unwatch = undefined;
@@ -649,6 +642,7 @@ class Recorder {
649
642
  this.dirty = false;
650
643
  this.error = undefined;
651
644
  this.retries = 0;
645
+ this.awayAt = undefined;
652
646
  this.service = false;
653
647
  this.emit();
654
648
  }
@@ -1118,16 +1112,18 @@ function Now({ context, words }) {
1118
1112
  className: "tmtg-now-meta"
1119
1113
  }, recorder.meeting?.title, status === "recording" ? ` · ${recorder.service ? words.viaService : words.viaDevice}` : ""), recorder.error && /* @__PURE__ */ React.createElement("div", {
1120
1114
  className: "tmtg-now-error"
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", {
1115
+ }, status === "reconnecting" ? Recorder.busy(recorder.error) ? words.micBusy : 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", {
1122
1116
  className: "tmtg-lines",
1123
1117
  ref: lines
1118
+ }, /* @__PURE__ */ React.createElement("div", {
1119
+ className: "tmtg-thread"
1124
1120
  }, recorder.segments.length || recorder.interim ? /* @__PURE__ */ React.createElement(React.Fragment, null, recorder.segments.map((segment, index) => /* @__PURE__ */ React.createElement("p", {
1125
1121
  key: index
1126
1122
  }, /* @__PURE__ */ React.createElement("time", null, MeetingUtil.clock(segment.at)), segment.text)), recorder.interim && /* @__PURE__ */ React.createElement("p", {
1127
1123
  className: "tmtg-interim"
1128
1124
  }, recorder.interim)) : /* @__PURE__ */ React.createElement("p", {
1129
1125
  className: "tmtg-placeholder"
1130
- }, words.listening)), /* @__PURE__ */ React.createElement("div", {
1126
+ }, words.listening))), /* @__PURE__ */ React.createElement("div", {
1131
1127
  className: "tmtg-actions"
1132
1128
  }, /* @__PURE__ */ React.createElement("button", {
1133
1129
  type: "button",
@@ -1265,13 +1261,15 @@ function activate(pi) {
1265
1261
  keepAwake: () => pi.ui.keepAwake?.() ?? (() => {
1266
1262
  return;
1267
1263
  }),
1268
- watch: (again) => {
1269
- const shown = () => document.visibilityState === "visible" && again();
1264
+ watch: (again, away) => {
1265
+ const shown = () => document.visibilityState === "visible" ? again() : away?.();
1270
1266
  document.addEventListener("visibilitychange", shown);
1271
1267
  window.addEventListener("online", again);
1268
+ document.addEventListener("pointerdown", again, true);
1272
1269
  return () => {
1273
1270
  document.removeEventListener("visibilitychange", shown);
1274
1271
  window.removeEventListener("online", again);
1272
+ document.removeEventListener("pointerdown", again, true);
1275
1273
  };
1276
1274
  }
1277
1275
  });
@@ -1307,38 +1305,12 @@ function activate(pi) {
1307
1305
  },
1308
1306
  subscribe: (listener) => recorder.subscribe(listener)
1309
1307
  });
1310
- pi.registerSettings(settings(pi, store));
1311
1308
  return () => {
1312
1309
  recorder.dispose();
1313
1310
  store.dispose();
1314
1311
  removeStyle();
1315
1312
  };
1316
1313
  }
1317
- function settings(pi, store) {
1318
- const words = () => MeetingWords.of(pi.ui.language);
1319
- const picker = (key, values, label) => function Picker() {
1320
- useSubscribed(store);
1321
- const value = store.settings[key];
1322
- const choices = values.includes(value) ? values : [...values, value].sort((a, b) => a - b);
1323
- return /* @__PURE__ */ React.createElement("select", {
1324
- className: "ta-select",
1325
- value,
1326
- onChange: (event) => void store.call("setSettings", { [key]: Number(event.target.value) }).catch((error) => failed(pi, error))
1327
- }, choices.map((n) => /* @__PURE__ */ React.createElement("option", {
1328
- key: n,
1329
- value: n
1330
- }, MeetingWords.format(words()[label], { n }))));
1331
- };
1332
- return {
1333
- title: () => words().title,
1334
- icon: pi.ui.icons.Mic,
1335
- group: "voice",
1336
- rows: [
1337
- { key: "keepDays", label: () => words().keepDays, description: () => words().keepDaysHint, render: picker("keepDays", KEEP_DAYS, "keepDaysValue") },
1338
- { key: "maxMB", label: () => words().maxMB, description: () => words().maxMBHint, render: picker("maxMB", MAX_MB, "maxMBValue") }
1339
- ]
1340
- };
1341
- }
1342
1314
  export {
1343
1315
  activate as default
1344
1316
  };