@celljs/ta-web 4.22.0 → 4.24.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/esm/browser/assistant/assistant-chat-list.js +3 -1
- package/esm/browser/assistant/assistant-conversation.js +1 -1
- package/esm/browser/assistant/assistant-initiative.d.ts +5 -1
- package/esm/browser/assistant/assistant-initiative.js +11 -3
- package/esm/browser/assistant/call-keeper.d.ts +2 -1
- package/esm/browser/assistant/call-keeper.js +4 -2
- package/esm/browser/assistant/call-screen.d.ts +1 -1
- package/esm/browser/assistant/call-turn-end.d.ts +11 -2
- package/esm/browser/assistant/call-turn-end.js +21 -5
- package/esm/browser/assistant/read-aloud.d.ts +1 -1
- package/esm/browser/assistant/realtime-voice.d.ts +1 -1
- package/esm/browser/assistant/voice-call-bar.d.ts +5 -2
- package/esm/browser/assistant/voice-call-bar.js +12 -0
- package/esm/browser/assistant/voice-call-protocol.d.ts +78 -0
- package/esm/browser/assistant/voice-call-protocol.js +2 -0
- package/esm/browser/assistant/voice-call.d.ts +17 -65
- package/esm/browser/assistant/voice-call.js +45 -1
- package/esm/browser/assistant/voice-reopen.d.ts +1 -1
- package/esm/browser/components/account-menu.js +28 -7
- package/esm/browser/components/app-shell-state.js +2 -1
- package/esm/browser/components/app-view.js +15 -7
- package/esm/browser/components/chat-home-util.d.ts +7 -0
- package/esm/browser/components/chat-home-util.js +10 -0
- package/esm/browser/components/chat-home.d.ts +3 -1
- package/esm/browser/components/chat-home.js +3 -2
- package/esm/browser/components/chat-list-util.d.ts +15 -3
- package/esm/browser/components/chat-list-util.js +26 -4
- package/esm/browser/components/chat-list.js +4 -3
- package/esm/browser/components/chat-seen.d.ts +4 -3
- package/esm/browser/components/chat-seen.js +6 -5
- package/esm/browser/components/chats-dot.d.ts +30 -0
- package/esm/browser/components/chats-dot.js +32 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/earlier-messages.d.ts +4 -0
- package/esm/browser/components/earlier-messages.js +10 -2
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/message-footer.d.ts +0 -2
- package/esm/browser/components/message-footer.js +1 -8
- package/esm/browser/components/message-images.d.ts +22 -0
- package/esm/browser/components/message-images.js +90 -1
- package/esm/browser/components/message-steps.js +9 -0
- package/esm/browser/components/message-user.js +8 -1
- package/esm/browser/components/partner-row-util.d.ts +28 -0
- package/esm/browser/components/partner-row-util.js +45 -0
- package/esm/browser/components/partner-row.d.ts +4 -3
- package/esm/browser/components/partner-row.js +21 -9
- package/esm/browser/components/profile-view.d.ts +2 -2
- package/esm/browser/components/profile-view.js +6 -3
- package/esm/browser/components/settings-files.d.ts +7 -0
- package/esm/browser/components/settings-files.js +61 -0
- package/esm/browser/components/settings-more.js +2 -0
- package/esm/browser/components/tool-view.js +23 -7
- package/esm/browser/components/web-composer.d.ts +5 -2
- package/esm/browser/components/web-composer.js +10 -5
- package/esm/browser/extension/extension-view.js +2 -2
- package/esm/browser/extension/icons.js +4 -1
- package/esm/browser/extension/web-api-call.d.ts +45 -0
- package/esm/browser/extension/web-api-call.js +2 -0
- package/esm/browser/extension/web-api-components.d.ts +37 -2
- package/esm/browser/extension/web-api-contributions.d.ts +4 -32
- package/esm/browser/extension/web-api-partners.d.ts +27 -2
- package/esm/browser/extension/web-extension-api.d.ts +9 -12
- package/esm/browser/extension/web-extension-context.d.ts +2 -3
- package/esm/browser/extension/web-extension-context.js +5 -5
- package/esm/browser/extension/web-view-util.d.ts +5 -0
- package/esm/browser/extension/web-view-util.js +8 -0
- package/esm/browser/i18n/locales.d.ts +18 -1
- package/esm/browser/i18n/messages-ja.js +17 -0
- package/esm/browser/i18n/messages-zh-tw.js +17 -0
- package/esm/browser/i18n/messages.d.ts +17 -0
- package/esm/browser/i18n/messages.js +34 -0
- package/esm/browser/partners/partners-extension.js +17 -0
- package/esm/browser/partners/partners-util.d.ts +6 -0
- package/esm/browser/partners/partners-util.js +9 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +3 -0
- package/esm/browser/style/conversation-column.d.ts +1 -1
- package/esm/browser/style/conversation-column.js +21 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +3 -2
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +8 -0
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +1 -1
- package/esm/browser/util/image-shrink.d.ts +26 -0
- package/esm/browser/util/image-shrink.js +60 -0
- package/esm/browser/util/process.d.ts +10 -4
- package/esm/browser/util/process.js +45 -18
- package/lib/browser/assistant/assistant-chat-list.js +3 -1
- package/lib/browser/assistant/assistant-conversation.js +1 -1
- package/lib/browser/assistant/assistant-initiative.d.ts +5 -1
- package/lib/browser/assistant/assistant-initiative.js +11 -3
- package/lib/browser/assistant/call-keeper.d.ts +2 -1
- package/lib/browser/assistant/call-keeper.js +4 -2
- package/lib/browser/assistant/call-screen.d.ts +1 -1
- package/lib/browser/assistant/call-turn-end.d.ts +11 -2
- package/lib/browser/assistant/call-turn-end.js +22 -6
- package/lib/browser/assistant/read-aloud.d.ts +1 -1
- package/lib/browser/assistant/realtime-voice.d.ts +1 -1
- package/lib/browser/assistant/voice-call-bar.d.ts +5 -2
- package/lib/browser/assistant/voice-call-bar.js +12 -0
- package/lib/browser/assistant/voice-call-protocol.d.ts +79 -0
- package/lib/browser/assistant/voice-call-protocol.js +3 -0
- package/lib/browser/assistant/voice-call.d.ts +17 -65
- package/lib/browser/assistant/voice-call.js +45 -1
- package/lib/browser/assistant/voice-reopen.d.ts +1 -1
- package/lib/browser/components/account-menu.js +27 -6
- package/lib/browser/components/app-shell-state.js +2 -1
- package/lib/browser/components/app-view.js +15 -7
- package/lib/browser/components/chat-home-util.d.ts +7 -0
- package/lib/browser/components/chat-home-util.js +10 -0
- package/lib/browser/components/chat-home.d.ts +3 -1
- package/lib/browser/components/chat-home.js +3 -2
- package/lib/browser/components/chat-list-util.d.ts +15 -3
- package/lib/browser/components/chat-list-util.js +26 -4
- package/lib/browser/components/chat-list.js +4 -3
- package/lib/browser/components/chat-seen.d.ts +4 -3
- package/lib/browser/components/chat-seen.js +6 -5
- package/lib/browser/components/chats-dot.d.ts +31 -0
- package/lib/browser/components/chats-dot.js +68 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/earlier-messages.d.ts +4 -0
- package/lib/browser/components/earlier-messages.js +10 -2
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/message-footer.d.ts +0 -2
- package/lib/browser/components/message-footer.js +0 -8
- package/lib/browser/components/message-images.d.ts +22 -0
- package/lib/browser/components/message-images.js +92 -2
- package/lib/browser/components/message-steps.js +9 -0
- package/lib/browser/components/message-user.js +7 -0
- package/lib/browser/components/partner-row-util.d.ts +29 -0
- package/lib/browser/components/partner-row-util.js +48 -0
- package/lib/browser/components/partner-row.d.ts +4 -3
- package/lib/browser/components/partner-row.js +21 -9
- package/lib/browser/components/profile-view.d.ts +2 -2
- package/lib/browser/components/profile-view.js +6 -3
- package/lib/browser/components/settings-files.d.ts +8 -0
- package/lib/browser/components/settings-files.js +97 -0
- package/lib/browser/components/settings-more.js +2 -0
- package/lib/browser/components/tool-view.js +23 -7
- package/lib/browser/components/web-composer.d.ts +5 -2
- package/lib/browser/components/web-composer.js +10 -5
- package/lib/browser/extension/extension-view.js +2 -2
- package/lib/browser/extension/icons.js +3 -0
- package/lib/browser/extension/web-api-call.d.ts +46 -0
- package/lib/browser/extension/web-api-call.js +3 -0
- package/lib/browser/extension/web-api-components.d.ts +37 -2
- package/lib/browser/extension/web-api-contributions.d.ts +4 -32
- package/lib/browser/extension/web-api-partners.d.ts +27 -2
- package/lib/browser/extension/web-extension-api.d.ts +9 -12
- package/lib/browser/extension/web-extension-context.d.ts +2 -3
- package/lib/browser/extension/web-extension-context.js +5 -5
- package/lib/browser/extension/web-view-util.d.ts +5 -0
- package/lib/browser/extension/web-view-util.js +8 -0
- package/lib/browser/i18n/locales.d.ts +18 -1
- package/lib/browser/i18n/messages-ja.js +17 -0
- package/lib/browser/i18n/messages-zh-tw.js +17 -0
- package/lib/browser/i18n/messages.d.ts +17 -0
- package/lib/browser/i18n/messages.js +34 -0
- package/lib/browser/partners/partners-extension.js +17 -0
- package/lib/browser/partners/partners-util.d.ts +6 -0
- package/lib/browser/partners/partners-util.js +9 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +3 -0
- package/lib/browser/style/conversation-column.d.ts +1 -1
- package/lib/browser/style/conversation-column.js +21 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +3 -2
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +8 -0
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +1 -1
- package/lib/browser/util/image-shrink.d.ts +27 -0
- package/lib/browser/util/image-shrink.js +63 -0
- package/lib/browser/util/process.d.ts +10 -4
- package/lib/browser/util/process.js +45 -18
- package/package.json +7 -7
|
@@ -1,70 +1,7 @@
|
|
|
1
1
|
import { Voice } from '../util/voice';
|
|
2
|
-
import { CallTurnEnd
|
|
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
|
|
192
|
+
var _a;
|
|
193
|
+
var _b, _c;
|
|
183
194
|
const t = (0, use_t_1.useT)();
|
|
184
|
-
const
|
|
185
|
-
const
|
|
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 = ((
|
|
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 =
|
|
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
|
}
|
|
@@ -43,6 +43,7 @@ const chat_view_1 = require("../chat/chat-view");
|
|
|
43
43
|
const back_stack_1 = require("../device/back-stack");
|
|
44
44
|
const device_1 = require("../device/device");
|
|
45
45
|
const web_tasks_1 = require("../extension/web-tasks");
|
|
46
|
+
const web_view_util_1 = require("../extension/web-view-util");
|
|
46
47
|
const files_protocol_1 = require("../files/files-protocol");
|
|
47
48
|
const hooks_1 = require("../hooks");
|
|
48
49
|
const use_t_1 = require("../i18n/use-t");
|
|
@@ -236,7 +237,7 @@ function useAppShell() {
|
|
|
236
237
|
setSettings(undefined);
|
|
237
238
|
setTabPage(undefined);
|
|
238
239
|
};
|
|
239
|
-
const tools = [...(hasCards ? [cardsTool] : []), ...
|
|
240
|
+
const tools = [...(hasCards ? [cardsTool] : []), ...web_view_util_1.WebViewUtil.tools(extensions.views)];
|
|
240
241
|
const openTool = (id) => (id === app_shell_hooks_1.CARDS_ID ? openCards() : host.openView(id));
|
|
241
242
|
// The workbench: the tabs open, or the tools that open there.
|
|
242
243
|
const editors = extensions.editors.length > 0 || tools.length > 0;
|
|
@@ -46,7 +46,6 @@ const hooks_1 = require("../hooks");
|
|
|
46
46
|
const notices_1 = require("../notices/notices");
|
|
47
47
|
const shared_link_1 = require("../share/shared-link");
|
|
48
48
|
const shared_page_1 = require("../share/shared-page");
|
|
49
|
-
const workbench_util_1 = require("../workbench-util");
|
|
50
49
|
const app_contexts_1 = require("./app-contexts");
|
|
51
50
|
const app_nav_1 = require("./app-nav");
|
|
52
51
|
const app_shell_hooks_1 = require("./app-shell-hooks");
|
|
@@ -54,9 +53,9 @@ const app_shell_state_1 = require("./app-shell-state");
|
|
|
54
53
|
const auth_view_1 = require("./auth-view");
|
|
55
54
|
const board_1 = require("./board");
|
|
56
55
|
const chat_asks_1 = require("./chat-asks");
|
|
57
|
-
const chat_icon_1 = require("./chat-icon");
|
|
58
56
|
const chat_list_util_1 = require("./chat-list-util");
|
|
59
57
|
const chat_seen_1 = require("./chat-seen");
|
|
58
|
+
const chats_dot_1 = require("./chats-dot");
|
|
60
59
|
const connection_bar_1 = require("./connection-bar");
|
|
61
60
|
const custom_host_1 = require("./custom-host");
|
|
62
61
|
const device_sign_in_page_1 = require("./device-sign-in-page");
|
|
@@ -114,6 +113,20 @@ function AppShell() {
|
|
|
114
113
|
// Where Ta's agents read the page to be, and go (docs/design/ta-app-use.md 3): set below as it renders.
|
|
115
114
|
const screenShell = (0, screen_navigator_1.useScreenNavigator)();
|
|
116
115
|
const inCall = (0, entry_holds_1.useCallGoingOn)();
|
|
116
|
+
// The chats' tab, and the double's on the rail, have the amber dot while a row of the double's list has one, as a
|
|
117
|
+
// messenger's; what waits for the user to decide is counted there until answered.
|
|
118
|
+
const { listed: listedChats, unseen: chatsUnseen } = (0, chats_dot_1.useChatsDot)({
|
|
119
|
+
sessions: workbench.sessions,
|
|
120
|
+
saved: workbench.saved,
|
|
121
|
+
removed: removedChats,
|
|
122
|
+
pinned: pinnedChats,
|
|
123
|
+
letGo: letGoAsks,
|
|
124
|
+
archiveDays: chatSettings.chatArchiveDays,
|
|
125
|
+
seen: seenChats,
|
|
126
|
+
looking,
|
|
127
|
+
extensions,
|
|
128
|
+
host,
|
|
129
|
+
});
|
|
117
130
|
if (workbench.status === 'signed-out') {
|
|
118
131
|
return workbench.leaving ? React.createElement("div", { className: "ta-signin" }) : React.createElement(workbench_view_1.SignIn, { error: workbench.error });
|
|
119
132
|
}
|
|
@@ -252,11 +265,6 @@ function AppShell() {
|
|
|
252
265
|
picked();
|
|
253
266
|
},
|
|
254
267
|
});
|
|
255
|
-
// The chats' tab, and the double's on the rail, have the amber dot of the rows listed while one said something unseen,
|
|
256
|
-
// as a messenger's, but those quiet (a call); what waits for the user to decide is counted there until answered.
|
|
257
|
-
const listedChats = chat_list_util_1.ChatListUtil.entries(workbench.sessions, workbench.saved, removedChats, undefined, workbench_util_1.WorkbenchUtil.daysAgo(Date.now(), chatSettings.chatArchiveDays), chat_list_util_1.ChatListUtil.keptFiles(workbench.saved, pinnedChats, letGoAsks), chat_icon_1.ChatIconUtil.archiveSince(extensions.chatIcons, Date.now())).listed;
|
|
258
|
-
const inFront = looking ? workbench.sessions.find(session => session.sessionId === looking) : undefined;
|
|
259
|
-
const chatsUnseen = chat_seen_1.ChatSeenUtil.anyUnseen(chat_icon_1.ChatIconUtil.loud(extensions.chatIcons, listedChats), seenChats, inFront && chat_list_util_1.ChatListUtil.file(inFront));
|
|
260
268
|
// Dragged away, the dot of the chats: all seen.
|
|
261
269
|
const seeAllChats = () => state.set(chat_seen_1.SEEN_CHATS, chat_seen_1.ChatSeenUtil.seeAll(state.get(chat_seen_1.SEEN_CHATS), listedChats, Date.now()));
|
|
262
270
|
// Dragged away, the count of the double: what the conversations ask let go; the double's own tasks wait on.
|
|
@@ -16,6 +16,8 @@ export interface ChatHome {
|
|
|
16
16
|
* list by their time as any conversation (docs/design/ta-partners.md).
|
|
17
17
|
*/
|
|
18
18
|
partners: readonly WebPartnerEntry[];
|
|
19
|
+
/** The conversations of pi that are partners' (PartnersUtil.sessions): listed once closed too, seen elsewhere till then. */
|
|
20
|
+
partnerSessions: ReadonlyMap<string, number>;
|
|
19
21
|
/** The key of the row whose page is in front, as a conversation of the list is (WebExtensionsState.pageFrom). */
|
|
20
22
|
shownItem?: string;
|
|
21
23
|
/** Opens a row: a page it shows is shown beside the list (TaWebExtensions.openHome). */
|
|
@@ -104,6 +106,11 @@ export declare namespace ChatHomeUtil {
|
|
|
104
106
|
};
|
|
105
107
|
/** It ended after the user last opened it (once the seen were kept): an amber dot, as a conversation's unread. */
|
|
106
108
|
function unseen(task: WebTaskEntry, seen: ChatSeen): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether a row of the double's list that is no conversation of pi has the amber dot: a row of its home, a
|
|
111
|
+
* conversation with a partner (a group chat, a chat of two), a task that is no conversation.
|
|
112
|
+
*/
|
|
113
|
+
function anyUnseen(items: readonly WebHomeEntry[], partners: readonly WebPartnerEntry[], tasks: readonly WebTaskEntry[], seen: ChatSeen): boolean;
|
|
107
114
|
/** Whether one of `texts` has the query (any case); all match an empty one. */
|
|
108
115
|
function matches(query: string, ...texts: (string | undefined)[]): boolean;
|
|
109
116
|
/**
|
|
@@ -103,6 +103,16 @@ var ChatHomeUtil;
|
|
|
103
103
|
return seen.since > 0 && web_tasks_1.WebTaskUtil.ended(task) && task.endedAt !== undefined && task.endedAt > ((_a = seen.at[seenKey(task)]) !== null && _a !== void 0 ? _a : seen.since);
|
|
104
104
|
}
|
|
105
105
|
ChatHomeUtil.unseen = unseen;
|
|
106
|
+
/**
|
|
107
|
+
* Whether a row of the double's list that is no conversation of pi has the amber dot: a row of its home, a
|
|
108
|
+
* conversation with a partner (a group chat, a chat of two), a task that is no conversation.
|
|
109
|
+
*/
|
|
110
|
+
function anyUnseen(items, partners, tasks, seen) {
|
|
111
|
+
return (ChatHomeUtil.items(items).some(item => item.unseen) ||
|
|
112
|
+
partners_util_1.PartnersUtil.chats(partners).some(partners_util_1.PartnersUtil.unseen) ||
|
|
113
|
+
ChatHomeUtil.tasks(tasks).rows.some(task => unseen(task, seen)));
|
|
114
|
+
}
|
|
115
|
+
ChatHomeUtil.anyUnseen = anyUnseen;
|
|
106
116
|
/** Whether one of `texts` has the query (any case); all match an empty one. */
|
|
107
117
|
function matches(query, ...texts) {
|
|
108
118
|
const needle = query.trim().toLowerCase();
|
|
@@ -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:
|
|
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' : ''}` },
|
|
@@ -5,6 +5,7 @@ import { type StateSpec } from '../state/state-protocol';
|
|
|
5
5
|
import { type LetGoAsks } from './chat-asks';
|
|
6
6
|
import type { ChatHomeRow, ChatTaskRow } from './chat-home-util';
|
|
7
7
|
import type { ChatFolderIcon } from './chat-icon';
|
|
8
|
+
import { type ChatSeen } from './chat-seen';
|
|
8
9
|
/** Where a conversation belongs: the directory of the user's own, or the package that opened it. */
|
|
9
10
|
export interface ChatSource {
|
|
10
11
|
/** `dir:<cwd>` or `pkg:<package>`. */
|
|
@@ -130,14 +131,25 @@ export declare namespace ChatListUtil {
|
|
|
130
131
|
pinned: T[];
|
|
131
132
|
rest: T[];
|
|
132
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Whether a row said something the user has not seen (ChatSeenUtil.unseen): a saved one answers no more, and what
|
|
136
|
+
* a partner's conversation said till it was seen elsewhere (PartnersUtil.sessions) is seen.
|
|
137
|
+
*/
|
|
138
|
+
function unseen(session: ChatEntry, seen: ChatSeen, shown?: string, partnerSessions?: ReadonlyMap<string, number>): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Which saved conversations of a package's group the list has (`entries`): those that fold into a folder of the
|
|
141
|
+
* list (WebChatIcon.folder), and those of partners (an agent's, PartnersUtil.sessions), the double's list having
|
|
142
|
+
* every conversation with a partner. ta serve opens either again with its group and role, from its file.
|
|
143
|
+
*/
|
|
144
|
+
function groupListed(folderOf: ((session: TaSavedSessionInfo) => unknown) | undefined, partnerSessions: ReadonlyMap<string, number> | undefined): ((session: TaSavedSessionInfo) => boolean) | undefined;
|
|
133
145
|
/**
|
|
134
146
|
* The open sessions and the saved ones, those archived and those taken out apart. A saved conversation of a
|
|
135
|
-
* package's group is not listed: its package opens it again, with its role; unless
|
|
136
|
-
*
|
|
147
|
+
* package's group is not listed: its package opens it again, with its role; unless `listed` has it (groupListed:
|
|
148
|
+
* one that folds into a folder of the list, a partner's). An open one is always listed,
|
|
137
149
|
* however old, and so is one pinned; a saved one not updated `since` is archived (a ta serve of before lists
|
|
138
150
|
* them with the others), or not updated since what `sooner` says of it (ChatIconUtil.archiveSince).
|
|
139
151
|
*/
|
|
140
|
-
function entries(sessions: TaSessionInfo[], saved: TaSavedSessionInfo[], removed: string[], archived?: TaSavedSessionInfo[], since?: number, pinned?: readonly string[], sooner?: (session: TaSavedSessionInfo) => number | undefined,
|
|
152
|
+
function entries(sessions: TaSessionInfo[], saved: TaSavedSessionInfo[], removed: string[], archived?: TaSavedSessionInfo[], since?: number, pinned?: readonly string[], sooner?: (session: TaSavedSessionInfo) => number | undefined, listed?: (session: TaSavedSessionInfo) => unknown): {
|
|
141
153
|
listed: ChatEntry[];
|
|
142
154
|
archived: ChatEntry[];
|
|
143
155
|
removed: ChatEntry[];
|
|
@@ -5,6 +5,7 @@ const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
|
5
5
|
const state_protocol_1 = require("../state/state-protocol");
|
|
6
6
|
const message_1 = require("../util/message");
|
|
7
7
|
const chat_asks_1 = require("./chat-asks");
|
|
8
|
+
const chat_seen_1 = require("./chat-seen");
|
|
8
9
|
const people_1 = require("./people");
|
|
9
10
|
const secret_text_1 = require("./secret-text");
|
|
10
11
|
/** The list by directory or package, else by day; in any browser. */
|
|
@@ -180,19 +181,40 @@ var ChatListUtil;
|
|
|
180
181
|
return { pinned: rows.filter(row => keys.has(pinKey(row))), rest: rows.filter(row => !keys.has(pinKey(row))) };
|
|
181
182
|
}
|
|
182
183
|
ChatListUtil.pinnedApart = pinnedApart;
|
|
184
|
+
/**
|
|
185
|
+
* Whether a row said something the user has not seen (ChatSeenUtil.unseen): a saved one answers no more, and what
|
|
186
|
+
* a partner's conversation said till it was seen elsewhere (PartnersUtil.sessions) is seen.
|
|
187
|
+
*/
|
|
188
|
+
function unseen(session, seen, shown, partnerSessions) {
|
|
189
|
+
const at = file(session);
|
|
190
|
+
return chat_seen_1.ChatSeenUtil.unseen({ ...session, isStreaming: isOpen(session) && session.isStreaming }, at, seen, shown, partnerSessions === null || partnerSessions === void 0 ? void 0 : partnerSessions.get(at));
|
|
191
|
+
}
|
|
192
|
+
ChatListUtil.unseen = unseen;
|
|
193
|
+
/**
|
|
194
|
+
* Which saved conversations of a package's group the list has (`entries`): those that fold into a folder of the
|
|
195
|
+
* list (WebChatIcon.folder), and those of partners (an agent's, PartnersUtil.sessions), the double's list having
|
|
196
|
+
* every conversation with a partner. ta serve opens either again with its group and role, from its file.
|
|
197
|
+
*/
|
|
198
|
+
function groupListed(folderOf, partnerSessions) {
|
|
199
|
+
if (!folderOf && !(partnerSessions === null || partnerSessions === void 0 ? void 0 : partnerSessions.size)) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
return session => !!(folderOf === null || folderOf === void 0 ? void 0 : folderOf(session)) || !!(partnerSessions === null || partnerSessions === void 0 ? void 0 : partnerSessions.has(session.sessionFile));
|
|
203
|
+
}
|
|
204
|
+
ChatListUtil.groupListed = groupListed;
|
|
183
205
|
/**
|
|
184
206
|
* The open sessions and the saved ones, those archived and those taken out apart. A saved conversation of a
|
|
185
|
-
* package's group is not listed: its package opens it again, with its role; unless
|
|
186
|
-
*
|
|
207
|
+
* package's group is not listed: its package opens it again, with its role; unless `listed` has it (groupListed:
|
|
208
|
+
* one that folds into a folder of the list, a partner's). An open one is always listed,
|
|
187
209
|
* however old, and so is one pinned; a saved one not updated `since` is archived (a ta serve of before lists
|
|
188
210
|
* them with the others), or not updated since what `sooner` says of it (ChatIconUtil.archiveSince).
|
|
189
211
|
*/
|
|
190
|
-
function entries(sessions, saved, removed, archived = [], since, pinned = [], sooner,
|
|
212
|
+
function entries(sessions, saved, removed, archived = [], since, pinned = [], sooner, listed) {
|
|
191
213
|
const open = new Set(sessions.map(session => session.sessionFile));
|
|
192
214
|
const out = new Set(removed);
|
|
193
215
|
const seen = new Set();
|
|
194
216
|
const closed = [...saved, ...archived].filter(session => {
|
|
195
|
-
if ((session.group && !(
|
|
217
|
+
if ((session.group && !(listed === null || listed === void 0 ? void 0 : listed(session))) || open.has(session.sessionFile) || seen.has(session.sessionFile)) {
|
|
196
218
|
return false;
|
|
197
219
|
}
|
|
198
220
|
seen.add(session.sessionFile);
|
|
@@ -53,7 +53,6 @@ const chat_icon_1 = require("./chat-icon");
|
|
|
53
53
|
const chat_list_hooks_1 = require("./chat-list-hooks");
|
|
54
54
|
const chat_list_row_1 = require("./chat-list-row");
|
|
55
55
|
const chat_list_util_1 = require("./chat-list-util");
|
|
56
|
-
const chat_seen_1 = require("./chat-seen");
|
|
57
56
|
const empty_state_1 = require("./empty-state");
|
|
58
57
|
const host_tag_1 = require("./host-tag");
|
|
59
58
|
const icon_1 = require("./icon");
|
|
@@ -140,9 +139,11 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
|
|
|
140
139
|
const sooner = React.useMemo(() => chat_icon_1.ChatIconUtil.archiveSince(icons.entries, now), [icons, now]);
|
|
141
140
|
// Those an extension folds into a row of their folder (WebChatIcon.folder), asked again as its icons change.
|
|
142
141
|
const folderOf = React.useMemo(() => chat_icon_1.ChatIconUtil.folderOf(icons.entries), [icons]);
|
|
142
|
+
const partnerSessions = home === null || home === void 0 ? void 0 : home.partnerSessions; // The agents' conversations, listed once closed too.
|
|
143
|
+
const groupListed = React.useMemo(() => chat_list_util_1.ChatListUtil.groupListed(folderOf, partnerSessions), [folderOf, partnerSessions]);
|
|
143
144
|
// One that waits for the user is not archived, however old, as one pinned.
|
|
144
145
|
const kept = React.useMemo(() => chat_list_util_1.ChatListUtil.keptFiles([...saved, ...(archivedSaved !== null && archivedSaved !== void 0 ? archivedSaved : [])], pinned, letGo), [saved, archivedSaved, pinned, letGo]);
|
|
145
|
-
const { listed, archived, removed } = React.useMemo(() => chat_list_util_1.ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner,
|
|
146
|
+
const { listed, archived, removed } = React.useMemo(() => chat_list_util_1.ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed]);
|
|
146
147
|
// A folder pinned holds its archived conversations too, and stays once they all are: a row pinned never goes away.
|
|
147
148
|
const { held, rest: archivedRest } = React.useMemo(() => chat_list_util_1.ChatListUtil.heldByPinned(archived, folderOf, pinned), [archived, folderOf, pinned]);
|
|
148
149
|
const sources = React.useMemo(() => chat_list_util_1.ChatListUtil.sources(listed), [listed]);
|
|
@@ -199,7 +200,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
|
|
|
199
200
|
const fold = (key) => onFolded(folded.includes(key) ? folded.filter(other => other !== key) : [...folded, key]);
|
|
200
201
|
const byKey = React.useMemo(() => new Map([...sources, ...chat_list_util_1.ChatListUtil.sources([...archived, ...removed])].map(candidate => [candidate.key, candidate])), [sources, archived, removed]);
|
|
201
202
|
const isSelected = (session) => (typeof session === 'string' ? session : chat_list_util_1.ChatListUtil.key(session)) === selected;
|
|
202
|
-
const isUnseen = (session) =>
|
|
203
|
+
const isUnseen = (session) => chat_list_util_1.ChatListUtil.unseen(session, seen, inFront, partnerSessions);
|
|
203
204
|
// What is folded or not drawn yet still has the conversation shown, and those unseen: the dot of the tab finds them.
|
|
204
205
|
const stays = (session) => isSelected(session) || isUnseen(session);
|
|
205
206
|
const taskUnseen = (task) => chat_home_util_1.ChatHomeUtil.unseen(task, seen);
|
|
@@ -21,13 +21,14 @@ export declare namespace ChatSeenUtil {
|
|
|
21
21
|
function merge(a: ChatSeen, b: ChatSeen): ChatSeen;
|
|
22
22
|
/**
|
|
23
23
|
* Whether it said something the user has not seen: it is not answering now, not the one in front, and its
|
|
24
|
-
* last message came after the user last saw it at rest (or, never seen, after `since`)
|
|
24
|
+
* last message came after the user last saw it at rest (or, never seen, after `since`), and after `seenElsewhere`
|
|
25
|
+
* (an agent's answers read in a group chat, WebPartnerChat.seenAt).
|
|
25
26
|
*/
|
|
26
27
|
function unseen(entry: {
|
|
27
28
|
updatedAt: number;
|
|
28
29
|
messageCount: number;
|
|
29
30
|
isStreaming?: boolean;
|
|
30
|
-
}, file: string, seen: ChatSeen, shown?: string): boolean;
|
|
31
|
+
}, file: string, seen: ChatSeen, shown?: string, seenElsewhere?: number): boolean;
|
|
31
32
|
/**
|
|
32
33
|
* Whether any of the conversations the list shows (ChatListUtil.entries, those listed) said something unseen:
|
|
33
34
|
* the dot on the tab of the chats. Only those: one the list leaves out (a package's, closed) has no row to find.
|
|
@@ -38,7 +39,7 @@ export declare namespace ChatSeenUtil {
|
|
|
38
39
|
isStreaming?: boolean;
|
|
39
40
|
sessionFile?: string;
|
|
40
41
|
sessionId?: string;
|
|
41
|
-
}[], seen: ChatSeen, shown?: string): boolean;
|
|
42
|
+
}[], seen: ChatSeen, shown?: string, elsewhere?: ReadonlyMap<string, number>): boolean;
|
|
42
43
|
/**
|
|
43
44
|
* Everything seen at once, as the user drags the dot of the tab away: kept since the latest of now and of what
|
|
44
45
|
* the conversations said last (the clocks of the page and the computer may differ). One answering goes on, and
|
|
@@ -73,26 +73,27 @@ var ChatSeenUtil;
|
|
|
73
73
|
ChatSeenUtil.merge = merge;
|
|
74
74
|
/**
|
|
75
75
|
* Whether it said something the user has not seen: it is not answering now, not the one in front, and its
|
|
76
|
-
* last message came after the user last saw it at rest (or, never seen, after `since`)
|
|
76
|
+
* last message came after the user last saw it at rest (or, never seen, after `since`), and after `seenElsewhere`
|
|
77
|
+
* (an agent's answers read in a group chat, WebPartnerChat.seenAt).
|
|
77
78
|
*/
|
|
78
|
-
function unseen(entry, file, seen, shown) {
|
|
79
|
+
function unseen(entry, file, seen, shown, seenElsewhere = 0) {
|
|
79
80
|
var _a;
|
|
80
81
|
return (seen.since > 0 &&
|
|
81
82
|
file !== shown &&
|
|
82
83
|
!entry.isStreaming &&
|
|
83
84
|
entry.messageCount > 0 &&
|
|
84
|
-
(entry.updatedAt > ((_a = seen.at[file]) !== null && _a !== void 0 ? _a : seen.since) || marked(seen, file)));
|
|
85
|
+
(entry.updatedAt > Math.max((_a = seen.at[file]) !== null && _a !== void 0 ? _a : seen.since, seenElsewhere) || marked(seen, file)));
|
|
85
86
|
}
|
|
86
87
|
ChatSeenUtil.unseen = unseen;
|
|
87
88
|
/**
|
|
88
89
|
* Whether any of the conversations the list shows (ChatListUtil.entries, those listed) said something unseen:
|
|
89
90
|
* the dot on the tab of the chats. Only those: one the list leaves out (a package's, closed) has no row to find.
|
|
90
91
|
*/
|
|
91
|
-
function anyUnseen(entries, seen, shown) {
|
|
92
|
+
function anyUnseen(entries, seen, shown, elsewhere) {
|
|
92
93
|
return entries.some(entry => {
|
|
93
94
|
var _a, _b;
|
|
94
95
|
const file = (_b = (_a = entry.sessionFile) !== null && _a !== void 0 ? _a : entry.sessionId) !== null && _b !== void 0 ? _b : '';
|
|
95
|
-
return !!file && unseen(entry, file, seen, shown);
|
|
96
|
+
return !!file && unseen(entry, file, seen, shown, elsewhere === null || elsewhere === void 0 ? void 0 : elsewhere.get(file));
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
ChatSeenUtil.anyUnseen = anyUnseen;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TaSavedSessionInfo, TaSessionInfo } from '@celljs/ta-protocol';
|
|
2
|
+
import type { TaWebExtensions, WebExtensionsState } from '../extension/web-extension-protocol';
|
|
3
|
+
import type { LetGoAsks } from './chat-asks';
|
|
4
|
+
import { type ChatEntry } from './chat-list-util';
|
|
5
|
+
import { type ChatSeen } from './chat-seen';
|
|
6
|
+
/** What the dot of the chats reads of the page. */
|
|
7
|
+
export interface ChatsDotInput {
|
|
8
|
+
sessions: readonly TaSessionInfo[];
|
|
9
|
+
saved: readonly TaSavedSessionInfo[];
|
|
10
|
+
removed: string[];
|
|
11
|
+
pinned: readonly string[];
|
|
12
|
+
letGo: LetGoAsks;
|
|
13
|
+
archiveDays: number;
|
|
14
|
+
seen: ChatSeen;
|
|
15
|
+
/** The conversation in front of the user, by its session id. */
|
|
16
|
+
looking?: string;
|
|
17
|
+
extensions: WebExtensionsState;
|
|
18
|
+
host: TaWebExtensions;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The amber dot of the chats' tab and of the double's entry on the rail, on while a row of the double's list has one,
|
|
22
|
+
* as a messenger's: a conversation it lists (those folded into a folder and the agents' too, but those quiet: a call),
|
|
23
|
+
* and, where the list is the double's, a row of its home, a conversation with a partner that is none of pi (a group
|
|
24
|
+
* chat, a chat of two) and a task that is no conversation. `listed`: the conversations it lists, which dragging the dot
|
|
25
|
+
* away sees; a row of the home or a partner's keeps its dot till it is opened, as on its row.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useChatsDot(input: ChatsDotInput): {
|
|
28
|
+
listed: ChatEntry[];
|
|
29
|
+
unseen: boolean;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chats-dot.d.ts.map
|