@flamingo-stack/openframe-frontend-core 0.0.692 → 0.0.693-snapshot.20261002144836
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/dist/chat-protocol/events.d.ts +3 -0
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/frames.d.ts +6 -0
- package/dist/chat-protocol/frames.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +26 -1
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.d.ts +1 -0
- package/dist/chat-protocol/index.d.ts.map +1 -1
- package/dist/chat-protocol/index.js +23 -2
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/leading-frames.d.ts.map +1 -1
- package/dist/chat-protocol/progress.d.ts +35 -0
- package/dist/chat-protocol/progress.d.ts.map +1 -0
- package/dist/{chunk-GDZ7IC5B.js → chunk-234IIQIS.js} +2 -2
- package/dist/{chunk-KDCIYRZV.cjs → chunk-2EQED5SZ.cjs} +34 -34
- package/dist/{chunk-KDCIYRZV.cjs.map → chunk-2EQED5SZ.cjs.map} +1 -1
- package/dist/{chunk-JUNOY5HK.js → chunk-2HX6AADM.js} +15 -17
- package/dist/chunk-2HX6AADM.js.map +1 -0
- package/dist/{chunk-X5XFKI6N.js → chunk-33L2IR62.js} +3 -3
- package/dist/{chunk-A5NHAHV6.js → chunk-42LIHMRA.js} +4 -4
- package/dist/{chunk-MIZU2OTO.cjs → chunk-63BLVGXZ.cjs} +4 -4
- package/dist/{chunk-MIZU2OTO.cjs.map → chunk-63BLVGXZ.cjs.map} +1 -1
- package/dist/{chunk-TEIHEFXP.js → chunk-6ZSDKDOV.js} +8 -8
- package/dist/{chunk-UVUNBXS6.js → chunk-7IINE3MK.js} +48 -5
- package/dist/chunk-7IINE3MK.js.map +1 -0
- package/dist/{chunk-N3526CTH.cjs → chunk-7TO3CWPM.cjs} +3 -3
- package/dist/{chunk-N3526CTH.cjs.map → chunk-7TO3CWPM.cjs.map} +1 -1
- package/dist/{chunk-TXFGG47A.js → chunk-7VO6NC67.js} +4 -4
- package/dist/{chunk-SC44YJCF.js → chunk-A7RKT5SO.js} +2 -2
- package/dist/{chunk-Y7ZEVTLC.js → chunk-BW6YBATM.js} +141 -71
- package/dist/chunk-BW6YBATM.js.map +1 -0
- package/dist/{chunk-GZRU2A4L.cjs → chunk-C27F6GBZ.cjs} +790 -720
- package/dist/chunk-C27F6GBZ.cjs.map +1 -0
- package/dist/{chunk-DVSPRY2V.cjs → chunk-ESMDIJIN.cjs} +3 -3
- package/dist/{chunk-DVSPRY2V.cjs.map → chunk-ESMDIJIN.cjs.map} +1 -1
- package/dist/{chunk-EXWS2QSD.cjs → chunk-FNGX5WZM.cjs} +497 -474
- package/dist/chunk-FNGX5WZM.cjs.map +1 -0
- package/dist/{chunk-RK47E3PP.js → chunk-GWQCUC53.js} +4 -4
- package/dist/{chunk-AVAZ6BD6.js → chunk-HBMGSGZY.js} +6 -6
- package/dist/{chunk-HM7ZGABI.js → chunk-HEBLLLLD.js} +2 -2
- package/dist/{chunk-7BNWMOPM.cjs → chunk-HJZ3UTUE.cjs} +83 -83
- package/dist/{chunk-7BNWMOPM.cjs.map → chunk-HJZ3UTUE.cjs.map} +1 -1
- package/dist/{chunk-ATREVNIN.cjs → chunk-JB25CCOB.cjs} +47 -47
- package/dist/{chunk-ATREVNIN.cjs.map → chunk-JB25CCOB.cjs.map} +1 -1
- package/dist/{chunk-Q25VYAEL.cjs → chunk-JISKS7RJ.cjs} +26 -26
- package/dist/{chunk-Q25VYAEL.cjs.map → chunk-JISKS7RJ.cjs.map} +1 -1
- package/dist/{chunk-WTYQCT4A.cjs → chunk-K5GSLGV2.cjs} +18 -18
- package/dist/{chunk-WTYQCT4A.cjs.map → chunk-K5GSLGV2.cjs.map} +1 -1
- package/dist/{chunk-CG7OWW7X.cjs → chunk-K5K2FRQK.cjs} +19 -19
- package/dist/{chunk-CG7OWW7X.cjs.map → chunk-K5K2FRQK.cjs.map} +1 -1
- package/dist/{chunk-CKUPANVU.cjs → chunk-KBSL4FCL.cjs} +9 -9
- package/dist/{chunk-CKUPANVU.cjs.map → chunk-KBSL4FCL.cjs.map} +1 -1
- package/dist/{chunk-SDORFSFK.cjs → chunk-KDUDL4PB.cjs} +37 -37
- package/dist/{chunk-SDORFSFK.cjs.map → chunk-KDUDL4PB.cjs.map} +1 -1
- package/dist/{chunk-5XPK2QGU.cjs → chunk-KJHIFF6H.cjs} +16 -16
- package/dist/{chunk-5XPK2QGU.cjs.map → chunk-KJHIFF6H.cjs.map} +1 -1
- package/dist/{chunk-MCNQKS6I.js → chunk-LHYOESIQ.js} +4 -4
- package/dist/{chunk-DUURFYGS.cjs → chunk-LPFU6U7O.cjs} +5 -5
- package/dist/{chunk-DUURFYGS.cjs.map → chunk-LPFU6U7O.cjs.map} +1 -1
- package/dist/{chunk-ZAV2F4VX.js → chunk-N7HFUBOV.js} +3 -3
- package/dist/{chunk-53O6PQ3F.cjs → chunk-NDLFK57D.cjs} +7 -7
- package/dist/{chunk-53O6PQ3F.cjs.map → chunk-NDLFK57D.cjs.map} +1 -1
- package/dist/{chunk-PKZGXRU2.js → chunk-NOMECDMA.js} +11 -9
- package/dist/chunk-NOMECDMA.js.map +1 -0
- package/dist/{chunk-Z7QCNCBN.js → chunk-O4RDXDVS.js} +12 -12
- package/dist/{chunk-F6LXGP6S.cjs → chunk-Q2B2MGFU.cjs} +7 -7
- package/dist/{chunk-F6LXGP6S.cjs.map → chunk-Q2B2MGFU.cjs.map} +1 -1
- package/dist/{chunk-CKO6NKNE.js → chunk-QP54LMXJ.js} +38 -15
- package/dist/{chunk-CKO6NKNE.js.map → chunk-QP54LMXJ.js.map} +1 -1
- package/dist/{chunk-QRA2JXE4.cjs → chunk-RE6PGOSS.cjs} +6 -8
- package/dist/chunk-RE6PGOSS.cjs.map +1 -0
- package/dist/{chunk-C2SVJVEB.js → chunk-SH5GPYSV.js} +2 -2
- package/dist/{chunk-KQZMM3QJ.cjs → chunk-SJFB4Z4L.cjs} +105 -105
- package/dist/{chunk-KQZMM3QJ.cjs.map → chunk-SJFB4Z4L.cjs.map} +1 -1
- package/dist/{chunk-DKJDO7YM.cjs → chunk-SYLLPIGU.cjs} +47 -45
- package/dist/chunk-SYLLPIGU.cjs.map +1 -0
- package/dist/{chunk-7EPGJOKN.js → chunk-TA3JJFEO.js} +4 -4
- package/dist/{chunk-LYJJH4D6.js → chunk-TBR3UTFY.js} +6 -6
- package/dist/{chunk-USKQURNF.cjs → chunk-TG3VBMDG.cjs} +3 -3
- package/dist/{chunk-USKQURNF.cjs.map → chunk-TG3VBMDG.cjs.map} +1 -1
- package/dist/{chunk-IQTQIBZ3.js → chunk-TV5SZJ3N.js} +12 -12
- package/dist/{chunk-RLNNV46K.js → chunk-TXSQLORA.js} +6 -6
- package/dist/{chunk-LYQULSK4.js → chunk-UCXZRJIE.js} +7 -7
- package/dist/{chunk-I27PWVWE.cjs → chunk-WT4HURQN.cjs} +46 -3
- package/dist/chunk-WT4HURQN.cjs.map +1 -0
- package/dist/{chunk-XAOAYDGR.js → chunk-WZJWIZVH.js} +4 -4
- package/dist/{chunk-LNKLB7GM.cjs → chunk-XNTQHC26.cjs} +28 -28
- package/dist/{chunk-LNKLB7GM.cjs.map → chunk-XNTQHC26.cjs.map} +1 -1
- package/dist/{chunk-2YVTGPM7.js → chunk-XZILGCXJ.js} +2 -2
- package/dist/{chunk-FTK3S57R.cjs → chunk-ZCPMWXIB.cjs} +25 -25
- package/dist/{chunk-FTK3S57R.cjs.map → chunk-ZCPMWXIB.cjs.map} +1 -1
- package/dist/{chunk-RTKF5AYA.cjs → chunk-ZUGAHQDB.cjs} +7 -7
- package/dist/{chunk-RTKF5AYA.cjs.map → chunk-ZUGAHQDB.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +21 -21
- package/dist/components/case-studies/index.js +8 -8
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/chat-typing-indicator.d.ts.map +1 -1
- package/dist/components/chat/cycling-phrase.d.ts.map +1 -1
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-unified-chat.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +5 -5
- package/dist/components/chat/index.js +4 -4
- package/dist/components/chat/stream/chat-dialog-store.d.ts.map +1 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts +4 -0
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/types/component.types.d.ts +2 -0
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +5 -0
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +9 -9
- package/dist/components/contact/index.js +8 -8
- package/dist/components/docs/index.cjs +12 -12
- package/dist/components/docs/index.js +11 -11
- package/dist/components/embeds/index.cjs +9 -9
- package/dist/components/embeds/index.js +8 -8
- package/dist/components/faq/index.cjs +10 -10
- package/dist/components/faq/index.js +9 -9
- package/dist/components/features/index.cjs +8 -8
- package/dist/components/features/index.js +7 -7
- package/dist/components/help-center-pages/index.cjs +107 -107
- package/dist/components/help-center-pages/index.js +22 -22
- package/dist/components/index.cjs +69 -69
- package/dist/components/index.js +22 -22
- package/dist/components/meeting-scheduler/index.cjs +59 -59
- package/dist/components/meeting-scheduler/index.js +9 -9
- package/dist/components/navigation/app-layout-drawer.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +11 -11
- package/dist/components/navigation/index.js +10 -10
- package/dist/components/onboarding-guides/index.cjs +12 -12
- package/dist/components/onboarding-guides/index.js +11 -11
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/related-content/index.js +5 -5
- package/dist/components/tickets/index.cjs +13 -13
- package/dist/components/tickets/index.js +12 -12
- package/dist/components/ui/index.cjs +8 -8
- package/dist/components/ui/index.js +7 -7
- package/dist/components/ui/markdown/engine.d.ts +0 -21
- package/dist/components/ui/markdown/engine.d.ts.map +1 -1
- package/dist/hooks/index.cjs +6 -6
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/use-authed-asset-src.d.ts.map +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -12
- package/dist/tailwind.config.cjs +14 -1
- package/dist/tailwind.config.cjs.map +1 -1
- package/dist/tailwind.config.js +14 -1
- package/dist/tailwind.config.js.map +1 -1
- package/eslint-config/README.md +13 -0
- package/eslint-config/base.js +15 -0
- package/eslint-config/webview-performance.js +75 -0
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/progress.test.ts +39 -0
- package/src/chat-protocol/events.ts +3 -0
- package/src/chat-protocol/frames.ts +7 -0
- package/src/chat-protocol/index.ts +2 -0
- package/src/chat-protocol/leading-frames.ts +4 -1
- package/src/chat-protocol/progress.ts +55 -0
- package/src/components/chat/chat-message-enhanced.tsx +1 -1
- package/src/components/chat/chat-message-list.tsx +65 -15
- package/src/components/chat/chat-typing-indicator.tsx +18 -29
- package/src/components/chat/cycling-phrase.tsx +1 -11
- package/src/components/chat/embeddable-chat.tsx +14 -6
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +2 -0
- package/src/components/chat/hooks/use-unified-chat.ts +1 -0
- package/src/components/chat/stream/__tests__/chat-stream-reducer-progress.test.ts +40 -0
- package/src/components/chat/stream/chat-dialog-store.ts +1 -0
- package/src/components/chat/stream/chat-stream-reducer.ts +13 -0
- package/src/components/chat/types/component.types.ts +2 -0
- package/src/components/chat/types/unified-chat-state.types.ts +6 -0
- package/src/components/navigation/app-layout-drawer.tsx +53 -7
- package/src/components/navigation/navigation-sidebar-item.tsx +1 -1
- package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +29 -29
- package/src/components/ui/markdown/engine.tsx +56 -12
- package/src/hooks/use-authed-asset-src.ts +58 -6
- package/tailwind.config.ts +13 -0
- package/dist/chunk-DKJDO7YM.cjs.map +0 -1
- package/dist/chunk-EXWS2QSD.cjs.map +0 -1
- package/dist/chunk-GZRU2A4L.cjs.map +0 -1
- package/dist/chunk-I27PWVWE.cjs.map +0 -1
- package/dist/chunk-JUNOY5HK.js.map +0 -1
- package/dist/chunk-PKZGXRU2.js.map +0 -1
- package/dist/chunk-QRA2JXE4.cjs.map +0 -1
- package/dist/chunk-UVUNBXS6.js.map +0 -1
- package/dist/chunk-Y7ZEVTLC.js.map +0 -1
- /package/dist/{chunk-GDZ7IC5B.js.map → chunk-234IIQIS.js.map} +0 -0
- /package/dist/{chunk-X5XFKI6N.js.map → chunk-33L2IR62.js.map} +0 -0
- /package/dist/{chunk-A5NHAHV6.js.map → chunk-42LIHMRA.js.map} +0 -0
- /package/dist/{chunk-TEIHEFXP.js.map → chunk-6ZSDKDOV.js.map} +0 -0
- /package/dist/{chunk-TXFGG47A.js.map → chunk-7VO6NC67.js.map} +0 -0
- /package/dist/{chunk-SC44YJCF.js.map → chunk-A7RKT5SO.js.map} +0 -0
- /package/dist/{chunk-RK47E3PP.js.map → chunk-GWQCUC53.js.map} +0 -0
- /package/dist/{chunk-AVAZ6BD6.js.map → chunk-HBMGSGZY.js.map} +0 -0
- /package/dist/{chunk-HM7ZGABI.js.map → chunk-HEBLLLLD.js.map} +0 -0
- /package/dist/{chunk-MCNQKS6I.js.map → chunk-LHYOESIQ.js.map} +0 -0
- /package/dist/{chunk-ZAV2F4VX.js.map → chunk-N7HFUBOV.js.map} +0 -0
- /package/dist/{chunk-Z7QCNCBN.js.map → chunk-O4RDXDVS.js.map} +0 -0
- /package/dist/{chunk-C2SVJVEB.js.map → chunk-SH5GPYSV.js.map} +0 -0
- /package/dist/{chunk-7EPGJOKN.js.map → chunk-TA3JJFEO.js.map} +0 -0
- /package/dist/{chunk-LYJJH4D6.js.map → chunk-TBR3UTFY.js.map} +0 -0
- /package/dist/{chunk-IQTQIBZ3.js.map → chunk-TV5SZJ3N.js.map} +0 -0
- /package/dist/{chunk-RLNNV46K.js.map → chunk-TXSQLORA.js.map} +0 -0
- /package/dist/{chunk-LYQULSK4.js.map → chunk-UCXZRJIE.js.map} +0 -0
- /package/dist/{chunk-XAOAYDGR.js.map → chunk-WZJWIZVH.js.map} +0 -0
- /package/dist/{chunk-2YVTGPM7.js.map → chunk-XZILGCXJ.js.map} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createSseFrameDecoder } from '../decode';
|
|
3
|
+
import { chatProgressLabel, chatProgressOf } from '../progress';
|
|
4
|
+
|
|
5
|
+
const frame = (o: unknown) => new TextEncoder().encode(`${JSON.stringify(o)}\0`);
|
|
6
|
+
|
|
7
|
+
describe('chat progress: the stage a turn reports before its first token', () => {
|
|
8
|
+
it('a status frame with a stage decodes to a status event carrying it', () => {
|
|
9
|
+
const d = createSseFrameDecoder();
|
|
10
|
+
expect(d.push(frame({ status: 'thinking', stage: 'searching', count: 28 }))).toEqual([
|
|
11
|
+
{ type: 'status', phase: 'thinking', progress: { stage: 'searching', count: 28 } },
|
|
12
|
+
]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('a plain status frame, and one whose stage this client does not know, is a plain "thinking"', () => {
|
|
16
|
+
const d = createSseFrameDecoder();
|
|
17
|
+
expect(d.push(frame({ status: 'thinking' }))).toEqual([{ type: 'status', phase: 'thinking' }]);
|
|
18
|
+
expect(d.push(frame({ status: 'thinking', stage: 'a-stage-from-the-future' }))).toEqual([
|
|
19
|
+
{ type: 'status', phase: 'thinking' },
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('keeps only a real count', () => {
|
|
24
|
+
expect(chatProgressOf({ stage: 'reading', count: 0 })).toEqual({ stage: 'reading' });
|
|
25
|
+
expect(chatProgressOf({ stage: 'reading', count: '12' })).toEqual({ stage: 'reading' });
|
|
26
|
+
expect(chatProgressOf({ stage: 'reading', count: 12.7 })).toEqual({ stage: 'reading', count: 12 });
|
|
27
|
+
expect(chatProgressOf({ stage: 'nope' })).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('words each stage, specific when a count is known', () => {
|
|
31
|
+
expect(chatProgressLabel({ stage: 'understanding' })).toBe('Understanding your question');
|
|
32
|
+
expect(chatProgressLabel({ stage: 'searching', count: 28 })).toBe('Searching 28 sources');
|
|
33
|
+
expect(chatProgressLabel({ stage: 'searching', count: 1 })).toBe('Searching 1 source');
|
|
34
|
+
expect(chatProgressLabel({ stage: 'searching' })).toBe('Searching');
|
|
35
|
+
expect(chatProgressLabel({ stage: 'searching_again' })).toBe('Searching more broadly');
|
|
36
|
+
expect(chatProgressLabel({ stage: 'reading', count: 43 })).toBe('Reading 43 results');
|
|
37
|
+
expect(chatProgressLabel({ stage: 'reading' })).toBe('Reading the results');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -17,6 +17,7 @@ import type { AskOptionData, ChatSource } from '../components/chat/types/message
|
|
|
17
17
|
// The wire-frame shapes these events carry through are defined ONCE in
|
|
18
18
|
// `./frames.ts` — reuse them here rather than restating their fields.
|
|
19
19
|
import type { ApprovalRequestField, DecisionResolvedFrame, UsageTelemetry } from './frames';
|
|
20
|
+
import type { ChatProgress } from './progress';
|
|
20
21
|
|
|
21
22
|
/** Optional envelope on every event. `seq` carries the transport's
|
|
22
23
|
* stream sequence (JetStream `streamSeq` on NATS; unused on SSE). */
|
|
@@ -72,6 +73,8 @@ export interface AskEvent extends ChatStreamEventBase {
|
|
|
72
73
|
export interface StatusEvent extends ChatStreamEventBase {
|
|
73
74
|
type: 'status';
|
|
74
75
|
phase: 'thinking';
|
|
76
|
+
/** What the turn is doing right now, when the server says (`./progress`). */
|
|
77
|
+
progress?: ChatProgress;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
/** NATS tool execution progress (EXECUTING_TOOL / EXECUTED_TOOL). */
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* Server-safe: no React, no browser APIs beyond TextEncoder/TextDecoder.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import type { ChatProgressStage } from './progress';
|
|
22
|
+
|
|
21
23
|
// =============================================================================
|
|
22
24
|
// Sentinel constants
|
|
23
25
|
// =============================================================================
|
|
@@ -82,6 +84,11 @@ export interface RoutedAnswerBreakdown {
|
|
|
82
84
|
* within ~200ms, before any upstream byte arrives. */
|
|
83
85
|
export interface StatusThinkingFrame {
|
|
84
86
|
status: 'thinking';
|
|
87
|
+
/** What the turn is doing right now (`./progress`): a fixed vocabulary, shown
|
|
88
|
+
* as one line while the user waits. May be sent again as the stage moves. */
|
|
89
|
+
stage?: ChatProgressStage;
|
|
90
|
+
/** How many of the thing the stage works on (sources searched, results read). */
|
|
91
|
+
count?: number;
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
/** Per-turn metadata frame. The emitter sends `options.metadata`
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
export * from './frames';
|
|
13
13
|
export * from './events';
|
|
14
|
+
// The stages a turn reports before its first answer token, and their copy.
|
|
15
|
+
export * from './progress';
|
|
14
16
|
export * from './encode';
|
|
15
17
|
export * from './decode';
|
|
16
18
|
export * from './nats-decoder';
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type { ChatStreamEvent } from './events';
|
|
13
|
+
import { chatProgressOf } from './progress';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Escape `<` so markdown renderers that pass HTML through (rehypeRaw)
|
|
@@ -50,7 +51,9 @@ export function frameNum(value: unknown): number | undefined {
|
|
|
50
51
|
*/
|
|
51
52
|
export function mapLeadingFrame(meta: Record<string, unknown>, out: ChatStreamEvent[]): void {
|
|
52
53
|
if (meta.status === 'thinking') {
|
|
53
|
-
|
|
54
|
+
// The frame may name the stage the turn is in; an unknown stage is a plain "thinking".
|
|
55
|
+
const progress = chatProgressOf(meta);
|
|
56
|
+
out.push(progress ? { type: 'status', phase: 'thinking', progress } : { type: 'status', phase: 'thinking' });
|
|
54
57
|
} else if (meta.kind === 'thinking-delta' && typeof meta.text === 'string') {
|
|
55
58
|
// Wire is ALREADY delta — emit verbatim, append-only contract.
|
|
56
59
|
out.push({ type: 'thinking-delta', text: meta.text });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a turn is doing before its first answer token: the named stages a server
|
|
3
|
+
* reports while it works, and the line a client shows for each.
|
|
4
|
+
*
|
|
5
|
+
* A retrieval chat spends seconds before any text exists (reading the question,
|
|
6
|
+
* searching, reading what it found). A generic spinner for that whole time says
|
|
7
|
+
* nothing; a line naming the real step ("Searching 28 sources") does, and people
|
|
8
|
+
* wait more willingly for it. The stage is a FIXED vocabulary on the wire (never
|
|
9
|
+
* model text, a rewritten query or a source name), so it is safe on a public
|
|
10
|
+
* chat and the wording stays the client's: `chatProgressLabel` is the one place
|
|
11
|
+
* the copy lives.
|
|
12
|
+
*
|
|
13
|
+
* Wire: the existing `{ status: 'thinking' }` leading frame, with an optional
|
|
14
|
+
* `stage` and `count`. A client that predates the stage reads the frame exactly
|
|
15
|
+
* as before; a client that knows it shows the line. A stage it does not know is
|
|
16
|
+
* dropped (the frame is still a plain "thinking").
|
|
17
|
+
*
|
|
18
|
+
* Server-safe: no React, no browser APIs.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const CHAT_PROGRESS_STAGES = ['understanding', 'searching', 'searching_again', 'reading'] as const;
|
|
22
|
+
|
|
23
|
+
export type ChatProgressStage = (typeof CHAT_PROGRESS_STAGES)[number];
|
|
24
|
+
|
|
25
|
+
export interface ChatProgress {
|
|
26
|
+
stage: ChatProgressStage;
|
|
27
|
+
/** How many of the thing the stage works on: sources searched, results read. */
|
|
28
|
+
count?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isChatProgressStage(value: unknown): value is ChatProgressStage {
|
|
32
|
+
return typeof value === 'string' && (CHAT_PROGRESS_STAGES as readonly string[]).includes(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A parsed status frame's progress, or null when it carries no stage this client knows. */
|
|
36
|
+
export function chatProgressOf(frame: { stage?: unknown; count?: unknown }): ChatProgress | null {
|
|
37
|
+
if (!isChatProgressStage(frame.stage)) return null;
|
|
38
|
+
const count =
|
|
39
|
+
typeof frame.count === 'number' && Number.isFinite(frame.count) && frame.count > 0
|
|
40
|
+
? Math.floor(frame.count)
|
|
41
|
+
: undefined;
|
|
42
|
+
return count === undefined ? { stage: frame.stage } : { stage: frame.stage, count };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const PROGRESS_LABEL: Record<ChatProgressStage, (count: number | undefined) => string> = {
|
|
46
|
+
understanding: () => 'Understanding your question',
|
|
47
|
+
searching: count => (count ? `Searching ${count} ${count === 1 ? 'source' : 'sources'}` : 'Searching'),
|
|
48
|
+
searching_again: () => 'Searching more broadly',
|
|
49
|
+
reading: count => (count ? `Reading ${count} ${count === 1 ? 'result' : 'results'}` : 'Reading the results'),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** The one line shown for a stage. Specific when the server gave a real count, never an invented one. */
|
|
53
|
+
export function chatProgressLabel(progress: ChatProgress): string {
|
|
54
|
+
return PROGRESS_LABEL[progress.stage](progress.count);
|
|
55
|
+
}
|
|
@@ -625,7 +625,7 @@ const ChatMessageEnhanced = forwardRef<HTMLDivElement, ChatMessageEnhancedProps>
|
|
|
625
625
|
))}
|
|
626
626
|
<span
|
|
627
627
|
className={cn(
|
|
628
|
-
'flex-1 !font-mono !font-medium text-h3',
|
|
628
|
+
'min-w-0 flex-1 truncate !font-mono !font-medium text-h3',
|
|
629
629
|
authorType === 'system'
|
|
630
630
|
? 'text-ods-open-yellow'
|
|
631
631
|
: authorType === 'admin'
|
|
@@ -51,6 +51,15 @@ const BOTTOM_THRESHOLD_PX = 70;
|
|
|
51
51
|
* finishing against the target captured when the call was made. */
|
|
52
52
|
const FOLLOW_RETAIN_MS = 350;
|
|
53
53
|
|
|
54
|
+
/** How long the scrollHeight poll keeps running after the thread last grew,
|
|
55
|
+
* in ms. Long enough for the async growth that lands after a message —
|
|
56
|
+
* images settling, entity cards resolving out of their skeletons — and
|
|
57
|
+
* short enough that an idle open drawer stops waking the page every frame. */
|
|
58
|
+
const GROWTH_WATCH_IDLE_MS = 10_000;
|
|
59
|
+
|
|
60
|
+
/** Media events after which the thread's height can have changed. */
|
|
61
|
+
const MEDIA_SETTLE_EVENTS = ['load', 'error', 'loadedmetadata'] as const;
|
|
62
|
+
|
|
54
63
|
/*
|
|
55
64
|
* Stick-to-bottom: `use-stick-to-bottom` (stackblitz-labs)
|
|
56
65
|
*
|
|
@@ -122,6 +131,7 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
122
131
|
dialogId,
|
|
123
132
|
isLoading = false,
|
|
124
133
|
isTyping = false,
|
|
134
|
+
typingMessage,
|
|
125
135
|
autoScroll = true,
|
|
126
136
|
overscrollContain = true,
|
|
127
137
|
pinBottom = false,
|
|
@@ -251,6 +261,9 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
251
261
|
// because that call also re-sets the library's `isAtBottom`, a lost
|
|
252
262
|
// lock self-heals instead of being permanent.
|
|
253
263
|
const followBottomRef = useRef(false);
|
|
264
|
+
// Restarts the follow effect's scrollHeight poll; null while it is not
|
|
265
|
+
// installed.
|
|
266
|
+
const kickGrowthWatchRef = useRef<(() => void) | null>(null);
|
|
254
267
|
|
|
255
268
|
// Drives the jump-to-bottom affordance. Derived from GEOMETRY, not
|
|
256
269
|
// from the library's `isAtBottom`: that flag is the one this list
|
|
@@ -424,11 +437,7 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
424
437
|
measure();
|
|
425
438
|
};
|
|
426
439
|
|
|
427
|
-
|
|
428
|
-
ro.observe(content); // tokens, entity cards, images
|
|
429
|
-
ro.observe(scroller); // streaming loader / source chips below it
|
|
430
|
-
|
|
431
|
-
// GROWTH WATCH — the load-bearing one, because the ResizeObserver above
|
|
440
|
+
// GROWTH WATCH — the load-bearing one, because the ResizeObserver below
|
|
432
441
|
// is not reliable for this list.
|
|
433
442
|
//
|
|
434
443
|
// `content` is a SNAPSHOT taken when this effect installed, and the deps
|
|
@@ -442,20 +451,42 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
442
451
|
// A poll on `scrollHeight` sidesteps the whole question of WHICH node is
|
|
443
452
|
// live: it reads the scroller (always mounted, it owns the listeners)
|
|
444
453
|
// and reacts to growth from any source — tokens, images settling, cards
|
|
445
|
-
// resolving.
|
|
446
|
-
//
|
|
447
|
-
//
|
|
454
|
+
// resolving. It stops once the thread has not grown for
|
|
455
|
+
// GROWTH_WATCH_IDLE_MS — polled every frame forever it kept an idle open
|
|
456
|
+
// drawer rendering at 60fps (~5% of a core in WebKit) — and `kick`
|
|
457
|
+
// restarts it on everything that can grow the thread: new messages and
|
|
458
|
+
// typing-state changes (the effect below), scroll, the observer, and
|
|
459
|
+
// media inside the thread settling (an image loading or failing, a video
|
|
460
|
+
// learning its size) — that can land well after the last message, when
|
|
461
|
+
// the observer may be watching a detached node.
|
|
448
462
|
let growthRaf = 0;
|
|
449
463
|
let lastScrollHeight = scroller.scrollHeight;
|
|
450
|
-
|
|
464
|
+
let lastGrowthAt = performance.now();
|
|
465
|
+
const watchGrowth = (now: number) => {
|
|
466
|
+
const height = scroller.scrollHeight;
|
|
467
|
+
if (height !== lastScrollHeight) {
|
|
468
|
+
lastScrollHeight = height;
|
|
469
|
+
lastGrowthAt = now;
|
|
470
|
+
reassert();
|
|
471
|
+
} else if (now - lastGrowthAt > GROWTH_WATCH_IDLE_MS) {
|
|
472
|
+
growthRaf = 0;
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
451
475
|
growthRaf = requestAnimationFrame(watchGrowth);
|
|
476
|
+
};
|
|
477
|
+
const kick = () => {
|
|
478
|
+
lastGrowthAt = performance.now();
|
|
479
|
+
if (!growthRaf) growthRaf = requestAnimationFrame(watchGrowth);
|
|
480
|
+
};
|
|
481
|
+
kick();
|
|
482
|
+
kickGrowthWatchRef.current = kick;
|
|
452
483
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
lastScrollHeight = height;
|
|
484
|
+
const ro = new ResizeObserver(() => {
|
|
485
|
+
kick();
|
|
456
486
|
reassert();
|
|
457
|
-
};
|
|
458
|
-
|
|
487
|
+
});
|
|
488
|
+
ro.observe(content); // tokens, entity cards, images
|
|
489
|
+
ro.observe(scroller); // streaming loader / source chips below it
|
|
459
490
|
|
|
460
491
|
// --- user-intent disarm ---------------------------------------
|
|
461
492
|
// Only a deliberate move AWAY from the bottom releases the lock.
|
|
@@ -542,6 +573,7 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
542
573
|
rearmIfAtBottom();
|
|
543
574
|
};
|
|
544
575
|
const onScroll = () => {
|
|
576
|
+
kick();
|
|
545
577
|
const st = scroller.scrollTop;
|
|
546
578
|
if (pointerDown && st < lastScrollTop) disarm();
|
|
547
579
|
lastScrollTop = st;
|
|
@@ -577,6 +609,8 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
577
609
|
scroller.addEventListener('touchmove', onTouchMove, { passive: true });
|
|
578
610
|
window.addEventListener('pointerdown', onPointerDown, winCapture);
|
|
579
611
|
scroller.addEventListener('scroll', onScroll, { passive: true });
|
|
612
|
+
// Media events do not bubble — capture them from the elements inside.
|
|
613
|
+
for (const type of MEDIA_SETTLE_EVENTS) scroller.addEventListener(type, kick, { capture: true, passive: true });
|
|
580
614
|
window.addEventListener('pointerup', endPointer, winCapture);
|
|
581
615
|
window.addEventListener('pointercancel', endPointer, winCapture);
|
|
582
616
|
// Bubble phase, NOT capture — see the note above.
|
|
@@ -585,6 +619,7 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
585
619
|
return () => {
|
|
586
620
|
ro.disconnect();
|
|
587
621
|
cancelAnimationFrame(growthRaf);
|
|
622
|
+
kickGrowthWatchRef.current = null;
|
|
588
623
|
scroller.removeEventListener('wheel', onWheel);
|
|
589
624
|
scroller.removeEventListener('keydown', onKeyDown);
|
|
590
625
|
scroller.removeEventListener('touchstart', onTouchStart);
|
|
@@ -592,6 +627,7 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
592
627
|
// `capture` must match the add call or the listener is not removed.
|
|
593
628
|
window.removeEventListener('pointerdown', onPointerDown, { capture: true });
|
|
594
629
|
scroller.removeEventListener('scroll', onScroll);
|
|
630
|
+
for (const type of MEDIA_SETTLE_EVENTS) scroller.removeEventListener(type, kick, { capture: true });
|
|
595
631
|
window.removeEventListener('pointerup', endPointer, { capture: true });
|
|
596
632
|
window.removeEventListener('pointercancel', endPointer, { capture: true });
|
|
597
633
|
// Added WITHOUT capture — the remove must match.
|
|
@@ -610,6 +646,12 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
610
646
|
// observing and listening on DETACHED nodes.
|
|
611
647
|
}, [autoScroll, scrollRef, contentRef, scrollToBottom, stopScroll, isLoading]);
|
|
612
648
|
|
|
649
|
+
// Restart the growth watch (see GROWTH WATCH above) whenever the thread
|
|
650
|
+
// can be about to grow; it stops itself again once growth settles.
|
|
651
|
+
useEffect(() => {
|
|
652
|
+
kickGrowthWatchRef.current?.();
|
|
653
|
+
}, [messages, isTyping]);
|
|
654
|
+
|
|
613
655
|
// ---- Passive-demo hard pin (pinBottom) ---------------------------
|
|
614
656
|
// Scripted in-page replays (the Fae/Mingo demos) have no human at the
|
|
615
657
|
// keyboard, so the newest streamed content must ALWAYS sit at the
|
|
@@ -1080,7 +1122,15 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
1080
1122
|
aria-live="polite"
|
|
1081
1123
|
>
|
|
1082
1124
|
<DotsLoaderIcon className="h-6 w-6" />
|
|
1083
|
-
|
|
1125
|
+
{/* What the turn is actually doing, when the host knows; the
|
|
1126
|
+
cycling phrase when it does not. One line, updated in place. */}
|
|
1127
|
+
{typingMessage ? (
|
|
1128
|
+
<span className="text-h6" aria-atomic="true">
|
|
1129
|
+
{typingMessage}
|
|
1130
|
+
</span>
|
|
1131
|
+
) : (
|
|
1132
|
+
<CyclingPhrase words={STREAMING_WORDS} className="text-h6" />
|
|
1133
|
+
)}
|
|
1084
1134
|
</div>
|
|
1085
1135
|
)}
|
|
1086
1136
|
|
|
@@ -16,44 +16,33 @@ const ChatTypingIndicator = forwardRef<HTMLDivElement, ChatTypingIndicatorProps>
|
|
|
16
16
|
lg: 'h-8',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const dotAnimation = `
|
|
20
|
-
@keyframes dotPulse {
|
|
21
|
-
0%, 80%, 100% {
|
|
22
|
-
transform: scale(1);
|
|
23
|
-
opacity: 0.7;
|
|
24
|
-
}
|
|
25
|
-
40% {
|
|
26
|
-
transform: scale(1.5);
|
|
27
|
-
opacity: 1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
19
|
return (
|
|
33
20
|
<div ref={ref} className={cn('flex items-center gap-2', className)} {...props}>
|
|
34
|
-
<style dangerouslySetInnerHTML={{ __html: dotAnimation }} />
|
|
35
21
|
{showText && <span className="text-ods-text-secondary text-h6">Assistant is typing</span>}
|
|
36
22
|
<div className={cn('inline-flex items-center justify-center gap-1', containerSizeClasses[size])}>
|
|
37
23
|
<div
|
|
38
|
-
className={cn(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
24
|
+
className={cn(
|
|
25
|
+
dotSizeClasses[size],
|
|
26
|
+
'animate-dot-pulse rounded-full',
|
|
27
|
+
dotClassName || 'bg-ods-text-primary',
|
|
28
|
+
)}
|
|
29
|
+
style={{ animationDelay: '0ms' }}
|
|
43
30
|
/>
|
|
44
31
|
<div
|
|
45
|
-
className={cn(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
32
|
+
className={cn(
|
|
33
|
+
dotSizeClasses[size],
|
|
34
|
+
'animate-dot-pulse rounded-full',
|
|
35
|
+
dotClassName || 'bg-ods-text-primary',
|
|
36
|
+
)}
|
|
37
|
+
style={{ animationDelay: '200ms' }}
|
|
50
38
|
/>
|
|
51
39
|
<div
|
|
52
|
-
className={cn(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
40
|
+
className={cn(
|
|
41
|
+
dotSizeClasses[size],
|
|
42
|
+
'animate-dot-pulse rounded-full',
|
|
43
|
+
dotClassName || 'bg-ods-text-primary',
|
|
44
|
+
)}
|
|
45
|
+
style={{ animationDelay: '400ms' }}
|
|
57
46
|
/>
|
|
58
47
|
</div>
|
|
59
48
|
</div>
|
|
@@ -14,14 +14,6 @@ interface CyclingPhraseProps {
|
|
|
14
14
|
holdMs?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Idempotent keyframe — multiple component instances share the same
|
|
18
|
-
// CSS rule, no duplication issues.
|
|
19
|
-
const BLINK_KEYFRAMES = `
|
|
20
|
-
@keyframes cyclingCursorBlink {
|
|
21
|
-
50% { opacity: 0; }
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
17
|
/**
|
|
26
18
|
* Terminal-style cycling word: a fixed-size block cursor walks left-
|
|
27
19
|
* to-right through the word, overwriting the previous word's char at
|
|
@@ -99,21 +91,19 @@ export function CyclingPhrase({ words, className, charMs = 60, holdMs = 4500 }:
|
|
|
99
91
|
const cursorBlock = (
|
|
100
92
|
<span
|
|
101
93
|
aria-hidden
|
|
102
|
-
className="inline-block bg-current align-baseline"
|
|
94
|
+
className="inline-block animate-cursor-blink bg-current align-baseline"
|
|
103
95
|
style={{
|
|
104
96
|
width: '0.6em',
|
|
105
97
|
height: '1em',
|
|
106
98
|
verticalAlign: '-0.1em',
|
|
107
99
|
marginLeft: '1px',
|
|
108
100
|
marginRight: '1px',
|
|
109
|
-
animation: 'cyclingCursorBlink 1s steps(1) infinite',
|
|
110
101
|
}}
|
|
111
102
|
/>
|
|
112
103
|
);
|
|
113
104
|
|
|
114
105
|
return (
|
|
115
106
|
<span className={cn('relative inline-block whitespace-nowrap', className)}>
|
|
116
|
-
<style dangerouslySetInnerHTML={{ __html: BLINK_KEYFRAMES }} />
|
|
117
107
|
{/* Invisible placeholder — pins width to longest word + "..." */}
|
|
118
108
|
<span aria-hidden className="invisible">
|
|
119
109
|
{placeholder}...
|
|
@@ -37,6 +37,7 @@ import { usePreventScroll } from '@react-aria/overlays';
|
|
|
37
37
|
import { isIOS } from '@react-aria/utils';
|
|
38
38
|
import { MessageSquare } from 'lucide-react';
|
|
39
39
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
40
|
+
import { chatProgressLabel } from '../../chat-protocol/progress';
|
|
40
41
|
import { useRequiredChatRuntime } from '../../contexts/chat-runtime-context';
|
|
41
42
|
import { useRouter } from '../../embed-shims/next-navigation';
|
|
42
43
|
import { useIsHydrated } from '../../hooks/ui/use-is-hydrated';
|
|
@@ -1219,6 +1220,7 @@ function EmbeddableChatInner({
|
|
|
1219
1220
|
const {
|
|
1220
1221
|
messages: rawMessages,
|
|
1221
1222
|
isLoading: chatLoading,
|
|
1223
|
+
streamingProgress,
|
|
1222
1224
|
sendMessage: sendMessageRaw,
|
|
1223
1225
|
discussRef,
|
|
1224
1226
|
stopMessage,
|
|
@@ -1930,16 +1932,20 @@ function EmbeddableChatInner({
|
|
|
1930
1932
|
// Measured off the panel NODE (state), not a ref read once on mount. In the
|
|
1931
1933
|
// `drawer` shell the panel body does not exist until the drawer opens, so a
|
|
1932
1934
|
// mount-time ref read saw `null`, bailed, and — with `[]` deps — never ran
|
|
1933
|
-
// again:
|
|
1935
|
+
// again: the width stayed 0, `canSplit` stayed false, and EVERY drawer
|
|
1934
1936
|
// host was silently pinned to the stacked single-column list no matter how
|
|
1935
1937
|
// wide it was. Only `shell="none"` hosts (the panel is inline and present at
|
|
1936
1938
|
// mount) ever reached the split layout.
|
|
1937
|
-
|
|
1939
|
+
//
|
|
1940
|
+
// Only the split threshold is state, not the width: the observer fires on
|
|
1941
|
+
// every pixel of a drawer drag, and a width in state re-rendered this whole
|
|
1942
|
+
// component each frame for a value that changes at one width.
|
|
1943
|
+
const [canSplit, setCanSplit] = useState(false);
|
|
1938
1944
|
useEffect(() => {
|
|
1939
1945
|
if (!panelBoundary || typeof ResizeObserver === 'undefined') return undefined;
|
|
1940
1946
|
const ro = new ResizeObserver(entries => {
|
|
1941
1947
|
const w = entries[0]?.contentRect?.width;
|
|
1942
|
-
if (typeof w === 'number')
|
|
1948
|
+
if (typeof w === 'number') setCanSplit(w >= SPLIT_MIN_WIDTH);
|
|
1943
1949
|
});
|
|
1944
1950
|
ro.observe(panelBoundary);
|
|
1945
1951
|
return () => ro.disconnect();
|
|
@@ -1957,7 +1963,7 @@ function EmbeddableChatInner({
|
|
|
1957
1963
|
// a reactive (non-mount-only) effect.
|
|
1958
1964
|
const setPanelNode = useCallback((node: HTMLDivElement | null) => {
|
|
1959
1965
|
setPanelBoundary(node);
|
|
1960
|
-
if (node)
|
|
1966
|
+
if (node) setCanSplit(node.clientWidth >= SPLIT_MIN_WIDTH);
|
|
1961
1967
|
}, []);
|
|
1962
1968
|
|
|
1963
1969
|
// Rail collapse toggle (Figma ⟶| control), persisted so it survives the
|
|
@@ -2003,7 +2009,6 @@ function EmbeddableChatInner({
|
|
|
2003
2009
|
// right chat block stays put), and only falls back to the full-panel archive
|
|
2004
2010
|
// when stacked/collapsed.
|
|
2005
2011
|
const splitEligible = historyListMode;
|
|
2006
|
-
const canSplit = panelWidth >= SPLIT_MIN_WIDTH;
|
|
2007
2012
|
// Embedded previews (hero demo tabs) always use the compact single-column
|
|
2008
2013
|
// header, never the two-column split — so `previewMode` opts out of `wideMingo`.
|
|
2009
2014
|
const wideMingo = splitEligible && canSplit && !previewMode;
|
|
@@ -2284,7 +2289,7 @@ function EmbeddableChatInner({
|
|
|
2284
2289
|
// expand toggle + the chat-block header (the fill column shows
|
|
2285
2290
|
// the chat / new-chat welcome). No back chevron — chat-list
|
|
2286
2291
|
// navigation is the rail toggle. Shown whenever the panel is wide
|
|
2287
|
-
// enough to split (
|
|
2292
|
+
// enough to split (width ≥ `SPLIT_MIN_WIDTH`), NOT gated on
|
|
2288
2293
|
// the viewport `md` breakpoint — otherwise a 720–799px panel on a
|
|
2289
2294
|
// sub-`md` viewport would split the body yet drop to the mobile
|
|
2290
2295
|
// single-bar header (no rail search / collapse controls).
|
|
@@ -2522,6 +2527,9 @@ function EmbeddableChatInner({
|
|
|
2522
2527
|
<ChatMessageList
|
|
2523
2528
|
messages={messages}
|
|
2524
2529
|
isTyping={chatLoading}
|
|
2530
|
+
// The stage the turn reports while the user waits
|
|
2531
|
+
// ("Searching 28 sources"); the generic phrase otherwise.
|
|
2532
|
+
typingMessage={streamingProgress ? chatProgressLabel(streamingProgress) : undefined}
|
|
2525
2533
|
// Sticky footer for approvals the host lifted out of the
|
|
2526
2534
|
// thread — see the prop's docblock.
|
|
2527
2535
|
pendingApprovals={pendingApprovals}
|
|
@@ -859,6 +859,8 @@ export function useSseChatAdapter(
|
|
|
859
859
|
stopMessage,
|
|
860
860
|
clearMessages,
|
|
861
861
|
streamingPhase,
|
|
862
|
+
/** The stage the pending turn reports before its first token, or null. */
|
|
863
|
+
streamingProgress: state.streamingProgress,
|
|
862
864
|
/** True while the mount-time rebuild from the server transcript runs. */
|
|
863
865
|
isHydratingHistory,
|
|
864
866
|
/** Provider key for the lib's `<ModelDisplay>` icon. */
|
|
@@ -214,6 +214,7 @@ export function useUnifiedChat(options: UseUnifiedChatOptions): UnifiedChatState
|
|
|
214
214
|
messages: activeState.messages,
|
|
215
215
|
isLoading: activeState.isLoading,
|
|
216
216
|
streamingPhase: activeState.streamingPhase,
|
|
217
|
+
streamingProgress: activeState.streamingProgress ?? null,
|
|
217
218
|
sendMessage,
|
|
218
219
|
stopMessage,
|
|
219
220
|
clearMessages,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stage a pending turn reports ("searching 28 sources") lives in reducer
|
|
3
|
+
* state only while the turn is still thinking: it is replaced as the stage
|
|
4
|
+
* moves, kept through a plain status frame, gone once text streams, and never
|
|
5
|
+
* carried into the next turn.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, it } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { createChatStreamReducer } from '../chat-stream-reducer';
|
|
10
|
+
|
|
11
|
+
describe('SSE kernel: the stage a pending turn reports', () => {
|
|
12
|
+
it('follows the stage, keeps it through a plain status frame, and drops it when text starts', () => {
|
|
13
|
+
const r = createChatStreamReducer({ transport: 'sse' });
|
|
14
|
+
r.beginSseSend({ text: 'what is the price', assistantName: 'Mingo AI' });
|
|
15
|
+
expect(r.state.streamingProgress).toBeNull();
|
|
16
|
+
|
|
17
|
+
r.apply({ type: 'status', phase: 'thinking', progress: { stage: 'understanding' } });
|
|
18
|
+
expect(r.state.streamingProgress).toEqual({ stage: 'understanding' });
|
|
19
|
+
|
|
20
|
+
r.apply({ type: 'status', phase: 'thinking', progress: { stage: 'searching', count: 28 } });
|
|
21
|
+
expect(r.state.streamingProgress).toEqual({ stage: 'searching', count: 28 });
|
|
22
|
+
|
|
23
|
+
// The model stream's own first frame carries no stage: the last one stands.
|
|
24
|
+
r.apply({ type: 'status', phase: 'thinking' });
|
|
25
|
+
expect(r.state.streamingProgress).toEqual({ stage: 'searching', count: 28 });
|
|
26
|
+
|
|
27
|
+
r.apply({ type: 'turn-start' });
|
|
28
|
+
expect(r.state.streamingPhase).toBe('streaming');
|
|
29
|
+
expect(r.state.streamingProgress).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('a new turn starts with no stage', () => {
|
|
33
|
+
const r = createChatStreamReducer({ transport: 'sse' });
|
|
34
|
+
r.beginSseSend({ text: 'first', assistantName: 'Mingo AI' });
|
|
35
|
+
r.apply({ type: 'status', phase: 'thinking', progress: { stage: 'reading', count: 12 } });
|
|
36
|
+
r.beginSseSend({ text: 'second', assistantName: 'Mingo AI' });
|
|
37
|
+
expect(r.state.streamingPhase).toBe('thinking');
|
|
38
|
+
expect(r.state.streamingProgress).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -199,6 +199,7 @@ export interface EvictedReducerState {
|
|
|
199
199
|
const EMPTY_STATE: ChatReducerState = Object.freeze({
|
|
200
200
|
messages: Object.freeze([]) as unknown as ChatReducerState['messages'],
|
|
201
201
|
streamingPhase: 'idle',
|
|
202
|
+
streamingProgress: null,
|
|
202
203
|
turnMeta: Object.freeze({
|
|
203
204
|
meta: new Map(),
|
|
204
205
|
sources: new Map(),
|
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
type ParticipantEvent,
|
|
61
61
|
type UsageEvent,
|
|
62
62
|
} from '../../../chat-protocol/events';
|
|
63
|
+
import type { ChatProgress } from '../../../chat-protocol/progress';
|
|
63
64
|
import { mergeSourceMetadata, type SourceMetadata } from '../../../chat-protocol/source-metadata';
|
|
64
65
|
import type {
|
|
65
66
|
ApprovalBatchSegment,
|
|
@@ -154,6 +155,9 @@ export interface ChatTurnMetaState {
|
|
|
154
155
|
export interface ChatReducerState {
|
|
155
156
|
messages: UnifiedChatMessage[];
|
|
156
157
|
streamingPhase: StreamingPhase;
|
|
158
|
+
/** What the pending turn is doing, while it is still thinking and the server
|
|
159
|
+
* has said (`chat-protocol/progress`). Null once text streams or the turn ends. */
|
|
160
|
+
streamingProgress: ChatProgress | null;
|
|
157
161
|
turnMeta: ChatTurnMetaState;
|
|
158
162
|
dialogTokenUsage?: DialogTokenUsage | null;
|
|
159
163
|
liveModel?: {
|
|
@@ -529,6 +533,7 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
529
533
|
// ── Mutable internals ──────────────────────────────────────────────────
|
|
530
534
|
let messages: UnifiedChatMessage[] = [];
|
|
531
535
|
let streamingPhase: StreamingPhase = 'idle';
|
|
536
|
+
let streamingProgress: ChatProgress | null = null;
|
|
532
537
|
let dialogTokenUsage: DialogTokenUsage | null = null;
|
|
533
538
|
let liveModel: ChatReducerState['liveModel'] = null;
|
|
534
539
|
let approvalStatuses: Record<string, ChatApprovalStatus> = {
|
|
@@ -688,6 +693,8 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
688
693
|
stateCache = {
|
|
689
694
|
messages,
|
|
690
695
|
streamingPhase,
|
|
696
|
+
// A stage describes the wait before the first token only.
|
|
697
|
+
streamingProgress: streamingPhase === 'thinking' ? streamingProgress : null,
|
|
691
698
|
turnMeta: { meta: metaMap, sources: sourcesMap, sendCount },
|
|
692
699
|
dialogTokenUsage,
|
|
693
700
|
liveModel,
|
|
@@ -1581,6 +1588,10 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
1581
1588
|
const sendIdx = sendCount - 1;
|
|
1582
1589
|
switch (event.type) {
|
|
1583
1590
|
case 'status':
|
|
1591
|
+
if (event.progress) {
|
|
1592
|
+
streamingProgress = event.progress;
|
|
1593
|
+
invalidate();
|
|
1594
|
+
}
|
|
1584
1595
|
setPhaseInternal('thinking');
|
|
1585
1596
|
break;
|
|
1586
1597
|
case 'thinking-delta':
|
|
@@ -1901,6 +1912,7 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
1901
1912
|
{ id: nextId('assistant'), role: 'assistant', content: '', segments: [] },
|
|
1902
1913
|
];
|
|
1903
1914
|
streamingPhase = 'thinking';
|
|
1915
|
+
streamingProgress = null;
|
|
1904
1916
|
invalidate();
|
|
1905
1917
|
},
|
|
1906
1918
|
clearThread() {
|
|
@@ -1948,6 +1960,7 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
1948
1960
|
sendCount += 1;
|
|
1949
1961
|
sseCurrentText = '';
|
|
1950
1962
|
streamingPhase = 'thinking';
|
|
1963
|
+
streamingProgress = null;
|
|
1951
1964
|
invalidate();
|
|
1952
1965
|
},
|
|
1953
1966
|
endSseTurn() {
|
|
@@ -255,6 +255,8 @@ export interface ChatMessageListProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
255
255
|
dialogId?: string;
|
|
256
256
|
isLoading?: boolean;
|
|
257
257
|
isTyping?: boolean;
|
|
258
|
+
/** The line shown beside the pending-turn loader: what the turn is doing right
|
|
259
|
+
* now ("Searching 28 sources"). Omitted, the loader cycles its generic phrases. */
|
|
258
260
|
typingMessage?: string;
|
|
259
261
|
smoothScroll?: boolean;
|
|
260
262
|
autoScroll?: boolean;
|