@celljs/ta-web 4.22.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/esm/browser/assistant/assistant-conversation.js +1 -1
  2. package/esm/browser/assistant/assistant-initiative.d.ts +5 -1
  3. package/esm/browser/assistant/assistant-initiative.js +11 -3
  4. package/esm/browser/assistant/call-keeper.d.ts +2 -1
  5. package/esm/browser/assistant/call-keeper.js +4 -2
  6. package/esm/browser/assistant/call-screen.d.ts +1 -1
  7. package/esm/browser/assistant/call-turn-end.d.ts +11 -2
  8. package/esm/browser/assistant/call-turn-end.js +21 -5
  9. package/esm/browser/assistant/read-aloud.d.ts +1 -1
  10. package/esm/browser/assistant/realtime-voice.d.ts +1 -1
  11. package/esm/browser/assistant/voice-call-bar.d.ts +5 -2
  12. package/esm/browser/assistant/voice-call-bar.js +12 -0
  13. package/esm/browser/assistant/voice-call-protocol.d.ts +78 -0
  14. package/esm/browser/assistant/voice-call-protocol.js +2 -0
  15. package/esm/browser/assistant/voice-call.d.ts +17 -65
  16. package/esm/browser/assistant/voice-call.js +45 -1
  17. package/esm/browser/assistant/voice-reopen.d.ts +1 -1
  18. package/esm/browser/components/account-menu.js +28 -7
  19. package/esm/browser/components/chat-home.d.ts +3 -1
  20. package/esm/browser/components/chat-home.js +3 -2
  21. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  22. package/esm/browser/components/earlier-messages.d.ts +4 -0
  23. package/esm/browser/components/earlier-messages.js +10 -2
  24. package/esm/browser/components/host-view.d.ts +1 -1
  25. package/esm/browser/components/message-footer.d.ts +0 -2
  26. package/esm/browser/components/message-footer.js +1 -8
  27. package/esm/browser/components/message-images.d.ts +22 -0
  28. package/esm/browser/components/message-images.js +90 -1
  29. package/esm/browser/components/message-steps.js +9 -0
  30. package/esm/browser/components/message-user.js +8 -1
  31. package/esm/browser/components/partner-row-util.d.ts +28 -0
  32. package/esm/browser/components/partner-row-util.js +45 -0
  33. package/esm/browser/components/partner-row.d.ts +4 -3
  34. package/esm/browser/components/partner-row.js +21 -9
  35. package/esm/browser/components/profile-view.d.ts +2 -2
  36. package/esm/browser/components/profile-view.js +6 -3
  37. package/esm/browser/components/web-composer.d.ts +5 -2
  38. package/esm/browser/components/web-composer.js +10 -5
  39. package/esm/browser/extension/extension-view.js +2 -2
  40. package/esm/browser/extension/icons.js +4 -1
  41. package/esm/browser/extension/web-api-call.d.ts +45 -0
  42. package/esm/browser/extension/web-api-call.js +2 -0
  43. package/esm/browser/extension/web-api-components.d.ts +37 -2
  44. package/esm/browser/extension/web-api-contributions.d.ts +2 -31
  45. package/esm/browser/extension/web-api-partners.d.ts +18 -1
  46. package/esm/browser/extension/web-extension-api.d.ts +9 -12
  47. package/esm/browser/extension/web-extension-context.d.ts +2 -3
  48. package/esm/browser/extension/web-extension-context.js +5 -5
  49. package/esm/browser/i18n/locales.d.ts +9 -1
  50. package/esm/browser/i18n/messages-ja.js +8 -0
  51. package/esm/browser/i18n/messages-zh-tw.js +8 -0
  52. package/esm/browser/i18n/messages.d.ts +8 -0
  53. package/esm/browser/i18n/messages.js +16 -0
  54. package/esm/browser/partners/partners-extension.js +17 -0
  55. package/esm/browser/style/chat-list.d.ts +1 -1
  56. package/esm/browser/style/chat-list.js +3 -0
  57. package/esm/browser/style/conversation-column.d.ts +1 -1
  58. package/esm/browser/style/conversation-column.js +21 -0
  59. package/esm/browser/style/conversation.d.ts +1 -1
  60. package/esm/browser/style/conversation.js +2 -2
  61. package/esm/browser/style/shell.d.ts +1 -1
  62. package/esm/browser/style/shell.js +1 -1
  63. package/esm/browser/util/image-shrink.d.ts +26 -0
  64. package/esm/browser/util/image-shrink.js +60 -0
  65. package/esm/browser/util/process.d.ts +7 -3
  66. package/esm/browser/util/process.js +18 -18
  67. package/lib/browser/assistant/assistant-conversation.js +1 -1
  68. package/lib/browser/assistant/assistant-initiative.d.ts +5 -1
  69. package/lib/browser/assistant/assistant-initiative.js +11 -3
  70. package/lib/browser/assistant/call-keeper.d.ts +2 -1
  71. package/lib/browser/assistant/call-keeper.js +4 -2
  72. package/lib/browser/assistant/call-screen.d.ts +1 -1
  73. package/lib/browser/assistant/call-turn-end.d.ts +11 -2
  74. package/lib/browser/assistant/call-turn-end.js +22 -6
  75. package/lib/browser/assistant/read-aloud.d.ts +1 -1
  76. package/lib/browser/assistant/realtime-voice.d.ts +1 -1
  77. package/lib/browser/assistant/voice-call-bar.d.ts +5 -2
  78. package/lib/browser/assistant/voice-call-bar.js +12 -0
  79. package/lib/browser/assistant/voice-call-protocol.d.ts +79 -0
  80. package/lib/browser/assistant/voice-call-protocol.js +3 -0
  81. package/lib/browser/assistant/voice-call.d.ts +17 -65
  82. package/lib/browser/assistant/voice-call.js +45 -1
  83. package/lib/browser/assistant/voice-reopen.d.ts +1 -1
  84. package/lib/browser/components/account-menu.js +27 -6
  85. package/lib/browser/components/chat-home.d.ts +3 -1
  86. package/lib/browser/components/chat-home.js +3 -2
  87. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  88. package/lib/browser/components/earlier-messages.d.ts +4 -0
  89. package/lib/browser/components/earlier-messages.js +10 -2
  90. package/lib/browser/components/host-view.d.ts +1 -1
  91. package/lib/browser/components/message-footer.d.ts +0 -2
  92. package/lib/browser/components/message-footer.js +0 -8
  93. package/lib/browser/components/message-images.d.ts +22 -0
  94. package/lib/browser/components/message-images.js +92 -2
  95. package/lib/browser/components/message-steps.js +9 -0
  96. package/lib/browser/components/message-user.js +7 -0
  97. package/lib/browser/components/partner-row-util.d.ts +29 -0
  98. package/lib/browser/components/partner-row-util.js +48 -0
  99. package/lib/browser/components/partner-row.d.ts +4 -3
  100. package/lib/browser/components/partner-row.js +21 -9
  101. package/lib/browser/components/profile-view.d.ts +2 -2
  102. package/lib/browser/components/profile-view.js +6 -3
  103. package/lib/browser/components/web-composer.d.ts +5 -2
  104. package/lib/browser/components/web-composer.js +10 -5
  105. package/lib/browser/extension/extension-view.js +2 -2
  106. package/lib/browser/extension/icons.js +3 -0
  107. package/lib/browser/extension/web-api-call.d.ts +46 -0
  108. package/lib/browser/extension/web-api-call.js +3 -0
  109. package/lib/browser/extension/web-api-components.d.ts +37 -2
  110. package/lib/browser/extension/web-api-contributions.d.ts +2 -31
  111. package/lib/browser/extension/web-api-partners.d.ts +18 -1
  112. package/lib/browser/extension/web-extension-api.d.ts +9 -12
  113. package/lib/browser/extension/web-extension-context.d.ts +2 -3
  114. package/lib/browser/extension/web-extension-context.js +5 -5
  115. package/lib/browser/i18n/locales.d.ts +9 -1
  116. package/lib/browser/i18n/messages-ja.js +8 -0
  117. package/lib/browser/i18n/messages-zh-tw.js +8 -0
  118. package/lib/browser/i18n/messages.d.ts +8 -0
  119. package/lib/browser/i18n/messages.js +16 -0
  120. package/lib/browser/partners/partners-extension.js +17 -0
  121. package/lib/browser/style/chat-list.d.ts +1 -1
  122. package/lib/browser/style/chat-list.js +3 -0
  123. package/lib/browser/style/conversation-column.d.ts +1 -1
  124. package/lib/browser/style/conversation-column.js +21 -0
  125. package/lib/browser/style/conversation.d.ts +1 -1
  126. package/lib/browser/style/conversation.js +2 -2
  127. package/lib/browser/style/shell.d.ts +1 -1
  128. package/lib/browser/style/shell.js +1 -1
  129. package/lib/browser/util/image-shrink.d.ts +27 -0
  130. package/lib/browser/util/image-shrink.js +63 -0
  131. package/lib/browser/util/process.d.ts +7 -3
  132. package/lib/browser/util/process.js +18 -18
  133. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CallTurnEnd = exports.TURN_MS = exports.FILLER_MS = exports.END_MS = exports.RETRY_MS = exports.SILENT_MS = exports.SILENT_ROUNDS = void 0;
3
+ exports.CallTurnEnd = exports.TURN_MS = exports.DRAFT_MS = exports.FILLER_MS = exports.END_MS = exports.RETRY_MS = exports.SILENT_MS = exports.SILENT_ROUNDS = void 0;
4
4
  const turn_end_1 = require("../util/turn-end");
5
5
  /** Listens heard nothing this many times in a row, and for SILENT_MS: nobody is there, the call ends. */
6
6
  exports.SILENT_ROUNDS = 4;
@@ -22,31 +22,46 @@ exports.END_MS = 1300;
22
22
  * a hesitation is dropped and a backchannel ("嗯", "好好", an answer maybe) goes as said.
23
23
  */
24
24
  exports.FILLER_MS = 3000;
25
+ /**
26
+ * The words heard stay the same this long, and may be all the user says (not sounds alone, nor a word that leads on): the
27
+ * answer to them is begun (CallPartner.draft), said only once they are done (docs/design/ta-call.md 10).
28
+ */
29
+ exports.DRAFT_MS = 400;
25
30
  /** At most this long a turn, from the first words: talk around the user that keeps the words coming ends there too. */
26
31
  exports.TURN_MS = 15000;
27
32
  /**
28
33
  * When the user is done with their turn in a call, by the words heard as they come (TurnEnd): once they stayed the same
29
34
  * a while (END_MS, sooner after a sentence, later while they hesitate, FILLER_MS for sounds alone), and at the latest
30
- * TURN_MS from the first words. It calls `done` then.
35
+ * TURN_MS from the first words. It calls `done` then; and `suspect` sooner (DRAFT_MS), where the words may end the turn.
31
36
  */
32
37
  class CallTurnEnd {
33
- constructor(times, done) {
38
+ constructor(times, done, suspect) {
34
39
  this.times = times;
35
40
  this.done = done;
41
+ this.suspect = suspect;
36
42
  /** When the words heard last changed: sounds alone wait FILLER_MS from it, over listens. */
37
43
  this.wordsAt = 0;
38
44
  }
39
45
  /** The words heard are `text` now. */
40
46
  heard(text) {
41
- var _a, _b;
47
+ var _a, _b, _c;
42
48
  this.wordsAt = Date.now();
43
49
  clearTimeout(this.endTimer);
44
- this.endTimer = setTimeout(this.done, this.waitMs(text));
50
+ const wait = this.waitMs(text);
51
+ this.endTimer = setTimeout(this.done, wait);
45
52
  (_a = this.turnTimer) !== null && _a !== void 0 ? _a : (this.turnTimer = setTimeout(this.done, (_b = this.times.turnMs) !== null && _b !== void 0 ? _b : exports.TURN_MS));
53
+ clearTimeout(this.draftTimer);
54
+ this.draftTimer = undefined;
55
+ const draftMs = (_c = this.times.draftMs) !== null && _c !== void 0 ? _c : exports.DRAFT_MS;
56
+ const suspect = this.suspect;
57
+ if (suspect && wait > draftMs && turn_end_1.TurnEnd.words(text) >= 2 && !turn_end_1.TurnEnd.sounds(text) && !turn_end_1.TurnEnd.hesitates(text)) {
58
+ this.draftTimer = setTimeout(() => suspect(text), draftMs);
59
+ }
46
60
  }
47
61
  /** A listen goes on from sounds alone the one before ended on: done once they waited FILLER_MS, unless words come. */
48
62
  hold() {
49
63
  clearTimeout(this.endTimer);
64
+ clearTimeout(this.draftTimer);
50
65
  this.endTimer = setTimeout(this.done, Math.max(0, this.fillerMs - (Date.now() - this.wordsAt)));
51
66
  }
52
67
  /** `said` is sounds alone that did not wait FILLER_MS yet: they wait on for words. */
@@ -56,7 +71,8 @@ class CallTurnEnd {
56
71
  stop() {
57
72
  clearTimeout(this.endTimer);
58
73
  clearTimeout(this.turnTimer);
59
- this.endTimer = this.turnTimer = undefined;
74
+ clearTimeout(this.draftTimer);
75
+ this.endTimer = this.turnTimer = this.draftTimer = undefined;
60
76
  }
61
77
  get fillerMs() {
62
78
  var _a;
@@ -1,5 +1,5 @@
1
1
  import { RealtimeVoice, type RealtimeVoiceHost } from './realtime-voice';
2
- import type { CallVoice } from './voice-call';
2
+ import type { CallVoice } from './voice-call-protocol';
3
3
  /** How long a voice service opened to read stays open after it read, ready for the next reply. */
4
4
  export declare const READ_IDLE_MS = 60000;
5
5
  interface OpenService {
@@ -1,6 +1,6 @@
1
1
  import { TaBargeIn, type TaVoiceEvent, type TaVoiceServer, type TaVoiceSession } from '@celljs/ta-protocol';
2
2
  import { Voice } from '../util/voice';
3
- import type { CallVoice } from './voice-call';
3
+ import type { CallVoice } from './voice-call-protocol';
4
4
  /** What a voice of a service uses of the page's connection. */
5
5
  export interface RealtimeVoiceHost {
6
6
  readonly voice: TaVoiceServer;
@@ -1,9 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import type { ComposerAction } from '../components/composer-box-protocol';
3
3
  import type { TalkCall } from '../components/voice-talk';
4
- import type { WebCallPartner, WebCallTarget } from '../extension/web-api-contributions';
4
+ import type { WebCallPartner, WebCallSession, WebCallTarget } from '../extension/web-api-call';
5
5
  import { type Translate } from '../i18n/use-t';
6
- import { type CallEnd, type CallOptions, type CallPartner, type CallState, VoiceCall } from './voice-call';
6
+ import { VoiceCall } from './voice-call';
7
+ import type { CallDraft, CallEnd, CallOptions, CallPartner, CallState } from './voice-call-protocol';
7
8
  /** What a notice says of a call that ended by itself. */
8
9
  export declare function callEndedNotice(t: Translate, reason: CallEnd, detail?: string): string;
9
10
  /**
@@ -28,6 +29,8 @@ export declare namespace CallPartnerUtil {
28
29
  * the ear); undefined when it leaves the call to the conversation.
29
30
  */
30
31
  function open(partner: WebCallPartner, target: WebCallTarget): Promise<CallPartner | undefined>;
32
+ /** An answer begun by the partner before the user was known to be done, its reply said whole. */
33
+ function draft(session: WebCallSession, text: string): CallDraft;
31
34
  /** After a failure to ask for what the partner says by itself, before it asks again. */
32
35
  const RETRY_MS = 3000;
33
36
  /** Asks for what the partner says by itself again and again, each as it comes, until the call is over. */
@@ -184,6 +184,7 @@ var CallPartnerUtil;
184
184
  const reply = await session.say(text, options);
185
185
  return reply ? spoken_1.SpokenReply.whole(reply) : undefined;
186
186
  },
187
+ ...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text) } : {}),
187
188
  news: listener => {
188
189
  if (session.next) {
189
190
  void CallPartnerUtil.follow(session.next.bind(session), () => closed, text => listener(spoken_1.SpokenReply.whole(text)));
@@ -197,6 +198,17 @@ var CallPartnerUtil;
197
198
  });
198
199
  }
199
200
  CallPartnerUtil.open = open;
201
+ /** An answer begun by the partner before the user was known to be done, its reply said whole. */
202
+ function draft(session, text) {
203
+ var _a;
204
+ const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text);
205
+ return {
206
+ reply: begun ? begun.reply.then(reply => (reply ? spoken_1.SpokenReply.whole(reply) : undefined)) : Promise.reject(new Error('No drafts.')),
207
+ keep: () => begun === null || begun === void 0 ? void 0 : begun.keep(),
208
+ drop: () => begun === null || begun === void 0 ? void 0 : begun.drop(),
209
+ };
210
+ }
211
+ CallPartnerUtil.draft = draft;
200
212
  /** After a failure to ask for what the partner says by itself, before it asks again. */
201
213
  CallPartnerUtil.RETRY_MS = 3000;
202
214
  /** Asks for what the partner says by itself again and again, each as it comes, until the call is over. */
@@ -0,0 +1,79 @@
1
+ import type { Voice } from '../util/voice';
2
+ import type { CallTurnTimes } from './call-turn-end';
3
+ /** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
4
+ export type CallPhase = 'connecting' | 'listening' | 'thinking' | 'speaking';
5
+ export interface CallState {
6
+ active: boolean;
7
+ phase: CallPhase;
8
+ /** What the user has said so far, while Ta listens. */
9
+ heard: string;
10
+ /** What the user said last, kept while Ta works on it and answers, until they say more: the captions. */
11
+ said?: string;
12
+ /** The answer being read, by sentences, and the one being read now: the captions. Kept after, until the user says more. */
13
+ reading?: {
14
+ pieces: string[];
15
+ at: number;
16
+ };
17
+ /** The page is hidden (another app in front, the screen locked): Ta neither listens nor speaks until it shows again. */
18
+ paused?: boolean;
19
+ /** A partner answers in this call (CallPartner), and tells the news of the work itself. */
20
+ partnered?: boolean;
21
+ /** Its voice hears the user cut in while Ta speaks: no need to tap. */
22
+ bargeIn?: boolean;
23
+ }
24
+ /** What a call uses of the page's voice: Voice by default, a service of voices.json (RealtimeVoice), a fake in tests. */
25
+ export interface CallVoice {
26
+ listen: typeof Voice.listen;
27
+ speak(text: string, language: string, onEnd: () => void, voice?: string, onPiece?: (pieces: string[], index: number) => void): void;
28
+ hush(): void;
29
+ /** It hears the user begin to speak even while Ta reads: the call stops reading and listens (barge-in). */
30
+ onSpeech?(listener: () => void): () => void;
31
+ /** false: the user chose to stop Ta with a tap only, not by speaking (TaBargeIn.tap). */
32
+ readonly cutsIn?: boolean;
33
+ /** The call ended: it lets go of what it holds (the microphone, the service). */
34
+ stop?(): void;
35
+ }
36
+ /**
37
+ * Who answers in a call in place of the conversation itself: a front that only talks, handing the work to the
38
+ * conversation (docs/design/ta-call.md), opened as the call starts and closed as it ends.
39
+ */
40
+ export interface CallPartner {
41
+ /** What the user said; the reply, as said aloud. `sent`: it went to the conversation already (let go over 通话). */
42
+ say(text: string, options?: {
43
+ sent?: boolean;
44
+ }): Promise<string | undefined>;
45
+ /** What it says by itself (news of the work), told as it comes, until it closes: the call announces it. */
46
+ news?(listener: (text: string) => void): void;
47
+ /**
48
+ * Answers what the user said so far, as they paused where they may be done (WebCallSession.draft): said only once
49
+ * kept, as they were done with these words; dropped as they say more.
50
+ */
51
+ draft?(text: string): CallDraft;
52
+ /** Whether it ended the call (WebCallSession.ending): Ta hangs up once its reply is said. */
53
+ ending?(): boolean;
54
+ close(): void;
55
+ }
56
+ /** An answer begun before the user was known to be done (CallPartner.draft). */
57
+ export interface CallDraft {
58
+ /** The reply, as said aloud; undefined once dropped. */
59
+ reply: Promise<string | undefined>;
60
+ keep(): void;
61
+ drop(): void;
62
+ }
63
+ /** Why a call ended by itself. */
64
+ export type CallEnd = 'silent' | 'denied' | 'unavailable' | 'failed';
65
+ export interface CallOptions extends CallTurnTimes {
66
+ language(): string;
67
+ voice(): string | undefined;
68
+ /** Sends what the user said to the conversation. */
69
+ send(text: string): Promise<unknown>;
70
+ /** The call ended by itself: why, for a notice; `detail` what the voice service said. */
71
+ ended?(reason: CallEnd, detail?: string): void;
72
+ /** The voice of a service the call opens as it starts; undefined for that of the device. */
73
+ openVoice?(): Promise<CallVoice | undefined> | undefined;
74
+ /** Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. */
75
+ openPartner?(): Promise<CallPartner | undefined> | undefined;
76
+ /** How long nobody may speak before the call ends by itself; default SILENT_MS. */
77
+ silentMs?: number;
78
+ }
79
+ //# sourceMappingURL=voice-call-protocol.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=voice-call-protocol.js.map
@@ -1,70 +1,7 @@
1
1
  import { Voice } from '../util/voice';
2
- import { CallTurnEnd, type CallTurnTimes } from './call-turn-end';
2
+ import { CallTurnEnd } from './call-turn-end';
3
+ import type { CallDraft, CallEnd, CallOptions, CallPartner, CallState, CallVoice } from './voice-call-protocol';
3
4
  import { VoiceReopen } from './voice-reopen';
4
- /** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
5
- export type CallPhase = 'connecting' | 'listening' | 'thinking' | 'speaking';
6
- export interface CallState {
7
- active: boolean;
8
- phase: CallPhase;
9
- /** What the user has said so far, while Ta listens. */
10
- heard: string;
11
- /** What the user said last, kept while Ta works on it and answers, until they say more: the captions. */
12
- said?: string;
13
- /** The answer being read, by sentences, and the one being read now: the captions. Kept after, until the user says more. */
14
- reading?: {
15
- pieces: string[];
16
- at: number;
17
- };
18
- /** The page is hidden (another app in front, the screen locked): Ta neither listens nor speaks until it shows again. */
19
- paused?: boolean;
20
- /** A partner answers in this call (CallPartner), and tells the news of the work itself. */
21
- partnered?: boolean;
22
- /** Its voice hears the user cut in while Ta speaks: no need to tap. */
23
- bargeIn?: boolean;
24
- }
25
- /** What a call uses of the page's voice: Voice by default, a service of voices.json (RealtimeVoice), a fake in tests. */
26
- export interface CallVoice {
27
- listen: typeof Voice.listen;
28
- speak(text: string, language: string, onEnd: () => void, voice?: string, onPiece?: (pieces: string[], index: number) => void): void;
29
- hush(): void;
30
- /** It hears the user begin to speak even while Ta reads: the call stops reading and listens (barge-in). */
31
- onSpeech?(listener: () => void): () => void;
32
- /** false: the user chose to stop Ta with a tap only, not by speaking (TaBargeIn.tap). */
33
- readonly cutsIn?: boolean;
34
- /** The call ended: it lets go of what it holds (the microphone, the service). */
35
- stop?(): void;
36
- }
37
- /**
38
- * Who answers in a call in place of the conversation itself: a front that only talks, handing the work to the
39
- * conversation (docs/design/ta-call.md), opened as the call starts and closed as it ends.
40
- */
41
- export interface CallPartner {
42
- /** What the user said; the reply, as said aloud. `sent`: it went to the conversation already (let go over 通话). */
43
- say(text: string, options?: {
44
- sent?: boolean;
45
- }): Promise<string | undefined>;
46
- /** What it says by itself (news of the work), told as it comes, until it closes: the call announces it. */
47
- news?(listener: (text: string) => void): void;
48
- /** Whether it ended the call (WebCallSession.ending): Ta hangs up once its reply is said. */
49
- ending?(): boolean;
50
- close(): void;
51
- }
52
- /** Why a call ended by itself. */
53
- export type CallEnd = 'silent' | 'denied' | 'unavailable' | 'failed';
54
- export interface CallOptions extends CallTurnTimes {
55
- language(): string;
56
- voice(): string | undefined;
57
- /** Sends what the user said to the conversation. */
58
- send(text: string): Promise<unknown>;
59
- /** The call ended by itself: why, for a notice; `detail` what the voice service said. */
60
- ended?(reason: CallEnd, detail?: string): void;
61
- /** The voice of a service the call opens as it starts; undefined for that of the device. */
62
- openVoice?(): Promise<CallVoice | undefined> | undefined;
63
- /** Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. */
64
- openPartner?(): Promise<CallPartner | undefined> | undefined;
65
- /** How long nobody may speak before the call ends by itself; default SILENT_MS. */
66
- silentMs?: number;
67
- }
68
5
  /**
69
6
  * A call with a conversation (the double's, or any other), by the voice of the page: Ta listens until the user pauses, sends what they said, reads
70
7
  * its answer out, then listens again, until the user hangs up or says nothing for a while. With the voice of the device
@@ -99,6 +36,13 @@ export declare class VoiceCall {
99
36
  protected partner?: CallPartner;
100
37
  /** Its voice service opening again (revoice). */
101
38
  protected reopening?: VoiceReopen;
39
+ /** The answer begun on what the user said so far (CallPartner.draft), and those words. */
40
+ protected drafted?: {
41
+ text: string;
42
+ draft: CallDraft;
43
+ };
44
+ /** A partner whose draft failed (an older Ta): it answers once the user is done only. */
45
+ protected draftless?: CallPartner;
102
46
  constructor(options: CallOptions, device?: CallVoice);
103
47
  subscribe(listener: () => void): () => void;
104
48
  /**
@@ -181,6 +125,14 @@ export declare class VoiceCall {
181
125
  protected heard(said: string, error: string | undefined, waited?: boolean): void;
182
126
  /** What the user said goes to the partner, or to the conversation. */
183
127
  protected take(said: string): void;
128
+ /**
129
+ * The words heard stayed the same a little, and may be all the user says: the partner begins its answer, said only
130
+ * should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
131
+ */
132
+ protected suspect(text: string): void;
133
+ /** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
134
+ protected kept(draft: CallDraft, said: string): void;
135
+ protected dropDraft(): void;
184
136
  /** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
185
137
  protected open(direct: boolean): Promise<[CallVoice | undefined, CallPartner | undefined]> | undefined;
186
138
  /** The partner answers what the user said; its reply is read as a turn's is. */
@@ -30,7 +30,7 @@ class VoiceCall {
30
30
  /** What waits to be said that the user did not ask for (a dialog, a task that ended), in order. */
31
31
  this.announcements = [];
32
32
  this.voice = device;
33
- this.turnEnd = new call_turn_end_1.CallTurnEnd(options, () => this.quiet());
33
+ this.turnEnd = new call_turn_end_1.CallTurnEnd(options, () => this.quiet(), text => this.suspect(text));
34
34
  }
35
35
  subscribe(listener) {
36
36
  this.listeners.add(listener);
@@ -145,6 +145,7 @@ class VoiceCall {
145
145
  if (!this.state.active) {
146
146
  return;
147
147
  }
148
+ this.dropDraft();
148
149
  (_a = this.partner) === null || _a === void 0 ? void 0 : _a.close();
149
150
  this.partner = undefined;
150
151
  this.calls++;
@@ -192,6 +193,7 @@ class VoiceCall {
192
193
  return;
193
194
  }
194
195
  this.stopListening();
196
+ this.dropDraft();
195
197
  if (this.state.phase === 'speaking') {
196
198
  this.voice.hush();
197
199
  this.pending = this.speaking;
@@ -294,6 +296,7 @@ class VoiceCall {
294
296
  */
295
297
  listen(announce = true, held) {
296
298
  this.stopListening();
299
+ this.dropDraft();
297
300
  if (this.state.paused) {
298
301
  return;
299
302
  }
@@ -313,6 +316,10 @@ class VoiceCall {
313
316
  // The user says more: the captions are of what they say now, the last exchange gone.
314
317
  this.set(text.trim() ? { heard: text, said: undefined, reading: undefined } : { heard: text });
315
318
  if (more && text.trim()) {
319
+ // They say more than the answer begun was to: it goes.
320
+ if (this.drafted && this.drafted.text !== text.trim()) {
321
+ this.dropDraft();
322
+ }
316
323
  this.turnEnd.heard(text);
317
324
  }
318
325
  }
@@ -402,6 +409,13 @@ class VoiceCall {
402
409
  this.silent = 0;
403
410
  this.spoke = Date.now();
404
411
  this.set({ phase: 'thinking', heard: said, said, reading: undefined });
412
+ const drafted = this.drafted;
413
+ this.drafted = undefined;
414
+ if (this.partner && (drafted === null || drafted === void 0 ? void 0 : drafted.text) === said) {
415
+ this.kept(drafted.draft, said);
416
+ return;
417
+ }
418
+ drafted === null || drafted === void 0 ? void 0 : drafted.draft.drop();
405
419
  if (this.partner) {
406
420
  this.ask(said);
407
421
  }
@@ -409,6 +423,36 @@ class VoiceCall {
409
423
  this.options.send(said).catch(() => this.state.active && this.unsent());
410
424
  }
411
425
  }
426
+ /**
427
+ * The words heard stayed the same a little, and may be all the user says: the partner begins its answer, said only
428
+ * should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
429
+ */
430
+ suspect(text) {
431
+ var _a;
432
+ const said = text.trim();
433
+ const partner = this.partner;
434
+ if (!(partner === null || partner === void 0 ? void 0 : partner.draft) || this.draftless === partner || this.listened() !== said || ((_a = this.drafted) === null || _a === void 0 ? void 0 : _a.text) === said) {
435
+ return;
436
+ }
437
+ this.dropDraft();
438
+ const draft = partner.draft(said);
439
+ draft.reply.catch(() => {
440
+ this.draftless = partner;
441
+ });
442
+ this.drafted = { text: said, draft };
443
+ }
444
+ /** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
445
+ kept(draft, said) {
446
+ const call = this.calls;
447
+ const partner = this.partner;
448
+ draft.keep();
449
+ draft.reply.then(reply => call === this.calls && this.turnEnded(reply), () => call === this.calls && this.state.active && this.partner === partner && this.ask(said));
450
+ }
451
+ dropDraft() {
452
+ const drafted = this.drafted;
453
+ this.drafted = undefined;
454
+ drafted === null || drafted === void 0 ? void 0 : drafted.draft.drop();
455
+ }
412
456
  /** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
413
457
  open(direct) {
414
458
  var _a, _b, _c, _d, _e;
@@ -1,4 +1,4 @@
1
- import type { CallVoice } from './voice-call';
1
+ import type { CallVoice } from './voice-call-protocol';
2
2
  /**
3
3
  * Opens the voice service of a call again once it went (ta serve restarted, the connection dropped): tries until it
4
4
  * opens or MS passed, waiting RETRY_MS between tries; a voice that opens too late is let go.
@@ -177,25 +177,46 @@ function AccountFigure({ size, className }) {
177
177
  return (React.createElement("span", { className: className },
178
178
  React.createElement(face_1.Face, { double: true, size: size })));
179
179
  }
180
+ /**
181
+ * The name and account last shown for each computer, so that the page opens with them rather than with the user of
182
+ * the computer and no account until they are read again.
183
+ */
184
+ const SHOWN = {
185
+ key: 'account.shown',
186
+ tier: 'device',
187
+ initial: {},
188
+ parse: value => (value && typeof value === 'object' && !Array.isArray(value) ? value : undefined),
189
+ };
180
190
  /** Who the user is (their name, their account), the machine in use (as named on this device), and whether the page is connected to it. */
181
191
  function useAccount() {
182
- var _a, _b, _c;
192
+ var _a;
193
+ var _b, _c;
183
194
  const t = (0, use_t_1.useT)();
184
- const identity = (0, profile_view_1.useIdentity)();
185
- const account = (0, profile_view_1.useAccountLine)();
195
+ const read = (_a = (0, profile_view_1.useIdentity)()) === null || _a === void 0 ? void 0 : _a.name;
196
+ const line = (0, profile_view_1.useAccountLine)();
186
197
  const [{ status, server, offlineShown, hosts, host }] = (0, hooks_1.useWorkbench)();
198
+ const [shown, keepShown] = (0, hooks_1.usePersisted)(SHOWN);
199
+ const key = host !== null && host !== void 0 ? host : '';
200
+ const last = shown[key];
201
+ const name = read !== null && read !== void 0 ? read : last === null || last === void 0 ? void 0 : last.name;
202
+ const account = line === undefined ? last === null || last === void 0 ? void 0 : last.account : line;
203
+ React.useEffect(() => {
204
+ if ((read !== undefined || line !== undefined) && (name !== (last === null || last === void 0 ? void 0 : last.name) || account !== (last === null || last === void 0 ? void 0 : last.account))) {
205
+ keepShown(previous => ({ ...previous, [key]: { name, account } }));
206
+ }
207
+ }, [read, line, name, account, last, key, keepShown]);
187
208
  const online = status === 'online';
188
209
  const state = online ? t('ta.online') : t('ta.reconnecting');
189
210
  const inUse = hosts.find(one => one.id === host);
190
- const machine = ((_a = inUse === null || inUse === void 0 ? void 0 : inUse.name) !== null && _a !== void 0 ? _a : server === null || server === void 0 ? void 0 : server.host) || undefined;
211
+ const machine = ((_b = inUse === null || inUse === void 0 ? void 0 : inUse.name) !== null && _b !== void 0 ? _b : server === null || server === void 0 ? void 0 : server.host) || undefined;
191
212
  return {
192
213
  server,
193
214
  machine,
194
215
  online,
195
216
  offlineShown,
196
217
  state,
197
- name: (_c = (_b = identity === null || identity === void 0 ? void 0 : identity.name) !== null && _b !== void 0 ? _b : server === null || server === void 0 ? void 0 : server.user) !== null && _c !== void 0 ? _c : t('ta.account'),
198
- account,
218
+ name: (_c = name !== null && name !== void 0 ? name : server === null || server === void 0 ? void 0 : server.user) !== null && _c !== void 0 ? _c : t('ta.account'),
219
+ account: account !== null && account !== void 0 ? account : undefined,
199
220
  service: server && online ? `${state} · v${server.version}` : state,
200
221
  };
201
222
  }
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import type { WebTaskEntry } from '../extension/web-extension-api';
3
3
  import { type ChatHome, type ChatHomeCounts, type ChatHomeRow } from './chat-home-util';
4
4
  /** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
5
- export declare function RowText({ title, time, line, unseen, flag, busy, tag, }: {
5
+ export declare function RowText({ title, time, line, unseen, flag, busy, tag, badge, }: {
6
6
  title: string;
7
7
  time: string;
8
8
  line: React.ReactNode;
@@ -12,6 +12,8 @@ export declare function RowText({ title, time, line, unseen, flag, busy, tag, }:
12
12
  busy?: boolean;
13
13
  /** Before the title: Double, for what it does. */
14
14
  tag?: React.ReactNode;
15
+ /** Just after the title, a small label of what it is: Friends, of a group chat with them. */
16
+ badge?: string;
15
17
  }): React.JSX.Element;
16
18
  /**
17
19
  * The double at the top of its list, as a messenger's pinned conversation: its face, what needs the user and goes on
@@ -49,11 +49,12 @@ const partner_row_1 = require("./partner-row");
49
49
  const swipe_row_1 = require("./swipe-row");
50
50
  const ta_avatar_1 = require("./ta-avatar");
51
51
  /** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
52
- function RowText({ title, time, line, unseen, flag, busy, tag, }) {
52
+ function RowText({ title, time, line, unseen, flag, busy, tag, badge, }) {
53
53
  return (React.createElement("span", { className: "ta-chat-text" },
54
54
  React.createElement("span", { className: "ta-chat-line" },
55
55
  tag,
56
- React.createElement("span", { className: "ta-chat-title" }, title),
56
+ React.createElement("span", { className: `ta-chat-title${badge ? ' ta-badged' : ''}` }, title),
57
+ badge && React.createElement("span", { className: "ta-chat-badge" }, badge),
57
58
  React.createElement("span", { className: "ta-chat-time" }, time)),
58
59
  React.createElement("span", { className: "ta-chat-line" },
59
60
  React.createElement("span", { className: `ta-chat-sub${unseen ? ' ta-unseen' : ''}` },