zidane-ui 9.2.3 → 9.3.1
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/adapters/live.d.ts +6 -0
- package/dist/adapters/live.js +16 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-host.js +143 -18
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +6 -1
- package/dist/chat/SessionStreamsProvider.d.ts +8 -0
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/Transcript.d.ts +20 -11
- package/dist/chat/Transcript.js +326 -160
- package/dist/chat/composer/ComposerEditor.js +1 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/index.d.ts +7 -6
- package/dist/chat/headless/index.js +10 -9
- package/dist/chat/headless/labels.d.ts +17 -0
- package/dist/chat/headless/labels.js +17 -0
- package/dist/chat/headless/markdown-chunks.d.ts +2 -1
- package/dist/chat/headless/markdown-chunks.js +12 -20
- package/dist/chat/headless/markdown-scan.d.ts +66 -0
- package/dist/chat/headless/markdown-scan.js +124 -0
- package/dist/chat/headless/markdown-stream.d.ts +64 -0
- package/dist/chat/headless/markdown-stream.js +143 -0
- package/dist/chat/headless/output-pager.d.ts +68 -0
- package/dist/chat/headless/output-pager.js +113 -0
- package/dist/chat/headless/session-list.d.ts +10 -0
- package/dist/chat/headless/sidebar/activity.d.ts +14 -0
- package/dist/chat/headless/sidebar/activity.js +32 -0
- package/dist/chat/headless/sidebar/directory.d.ts +9 -1
- package/dist/chat/headless/sidebar/directory.js +10 -50
- package/dist/chat/headless/sidebar/labels.d.ts +11 -1
- package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
- package/dist/chat/headless/sidebar/prewarm.js +114 -0
- package/dist/chat/headless/streams/actions.d.ts +2 -0
- package/dist/chat/headless/streams/actions.js +1 -0
- package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
- package/dist/chat/headless/streams/event-bytes.js +34 -0
- package/dist/chat/headless/streams/live-events.d.ts +25 -1
- package/dist/chat/headless/streams/live-events.js +53 -2
- package/dist/chat/headless/streams/selectors.d.ts +3 -0
- package/dist/chat/headless/streams/selectors.js +8 -1
- package/dist/chat/headless/streams/session-streams.d.ts +15 -3
- package/dist/chat/headless/streams/session-streams.js +31 -3
- package/dist/chat/headless/streams/store.d.ts +24 -1
- package/dist/chat/headless/streams/store.js +51 -26
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +88 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- package/dist/chat/headless/transcript/batch.js +5 -1
- package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
- package/dist/chat/headless/transcript/blob-media.js +23 -0
- package/dist/chat/headless/transcript/collapse.d.ts +10 -0
- package/dist/chat/headless/transcript/collapse.js +32 -6
- package/dist/chat/headless/transcript/derive.d.ts +98 -0
- package/dist/chat/headless/transcript/derive.js +89 -0
- package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
- package/dist/chat/headless/transcript/exchange-media.js +8 -5
- package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
- package/dist/chat/headless/transcript/fold-attachments.js +3 -2
- package/dist/chat/headless/transcript/fold.d.ts +2 -1
- package/dist/chat/headless/transcript/fold.js +16 -6
- package/dist/chat/headless/transcript/incremental.d.ts +53 -0
- package/dist/chat/headless/transcript/incremental.js +181 -0
- package/dist/chat/headless/transcript/index.d.ts +2 -2
- package/dist/chat/headless/transcript/index.js +2 -2
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +50 -1
- package/dist/chat/headless/transcript/rail.js +165 -23
- package/dist/chat/headless/transcript/rows.d.ts +5 -1
- package/dist/chat/headless/transcript/run-failures.js +2 -1
- package/dist/chat/headless/transcript/seams.d.ts +78 -0
- package/dist/chat/headless/transcript/seams.js +116 -0
- package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
- package/dist/chat/headless/transcript/tool-media.js +27 -9
- package/dist/chat/index.d.ts +8 -7
- package/dist/chat/index.js +17 -16
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- package/dist/chat/transcript/DiffLines.d.ts +6 -1
- package/dist/chat/transcript/DiffLines.js +35 -20
- package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
- package/dist/chat/transcript/EditDiffBlock.js +89 -30
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +101 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
- package/dist/chat/transcript/TranscriptRail.js +175 -17
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +4 -3
- package/dist/chat/transcript/actions.d.ts +37 -1
- package/dist/chat/transcript/actions.js +27 -1
- package/dist/chat/transcript/clipped-output.d.ts +58 -0
- package/dist/chat/transcript/clipped-output.js +131 -0
- package/dist/chat/transcript/fold-attachments.js +10 -5
- package/dist/chat/transcript/fold-worker.js +3 -2
- package/dist/chat/transcript/fold.js +2 -1
- package/dist/chat/transcript/index.d.ts +10 -9
- package/dist/chat/transcript/index.js +9 -8
- package/dist/chat/transcript/markdown-cache.d.ts +7 -1
- package/dist/chat/transcript/markdown-cache.js +12 -1
- package/dist/chat/transcript/markdown.js +116 -54
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +10 -7
- package/dist/chat/transcript/notices.js +2 -1
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +2 -1
- package/dist/chat/transcript/root-items.d.ts +96 -0
- package/dist/chat/transcript/root-items.js +180 -0
- package/dist/chat/transcript/row-mount.d.ts +165 -0
- package/dist/chat/transcript/row-mount.js +498 -0
- package/dist/chat/transcript/row-parking.d.ts +125 -0
- package/dist/chat/transcript/row-parking.js +135 -0
- package/dist/chat/transcript/row-ui-state.d.ts +37 -0
- package/dist/chat/transcript/row-ui-state.js +53 -0
- package/dist/chat/transcript/run-rows.js +3 -2
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/tasks.js +3 -2
- package/dist/chat/transcript/tool-media.d.ts +4 -2
- package/dist/chat/transcript/tool-media.js +15 -7
- package/dist/chat/transcript/tool-parts.d.ts +27 -4
- package/dist/chat/transcript/tool-parts.js +31 -5
- package/dist/chat/transcript/tool-payload.js +26 -11
- package/dist/chat/transcript/tool-row.d.ts +2 -1
- package/dist/chat/transcript/tool-row.js +38 -19
- package/dist/chat/transcript/use-transcript-rows.d.ts +24 -7
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useStickToBottom.js +2 -3
- package/dist/chat/transcript/useTranscriptSearch.js +30 -14
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/dist/{index-E1Z0aPmi.d.ts → index-C6-t1SS9.d.ts} +2 -1
- package/dist/dist/index.d.ts +1 -1
- package/dist/session/SessionHeader.js +1 -0
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/sections/performance/PerformanceSection.js +8 -1
- package/dist/settings/sections/performance/labels.d.ts +2 -0
- package/dist/settings/sections/performance/labels.js +2 -0
- package/dist/styles.css +33 -2
- package/dist/views/headless/answers.d.ts +8 -2
- package/dist/views/headless/answers.js +58 -1
- package/dist/views/headless/placement.d.ts +78 -0
- package/dist/views/headless/placement.js +154 -44
- package/package.json +2 -2
- package/src/styles/transcript.css +33 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./execution-failure-SREfl-EZ.js";
|
|
2
2
|
import "./timeout-CmTx6V9y.js";
|
|
3
|
+
import "./sandbox-CSUihARm.js";
|
|
3
4
|
import "./oauth-callback-page-CV9oTMGy.js";
|
|
4
5
|
import "../node_modules/.bun/hookable@6.1.2/node_modules/hookable/dist/index.js";
|
|
5
6
|
import "../node_modules/.bun/@earendil-works_pi-ai@1.5.2_46b80fae64c053ae/node_modules/@earendil-works/pi-ai/dist/index.js";
|
|
@@ -1679,4 +1680,4 @@ interface Settings {
|
|
|
1679
1680
|
*/
|
|
1680
1681
|
activeIcon: string;
|
|
1681
1682
|
}
|
|
1682
|
-
export {
|
|
1683
|
+
export { ScriptLineProgress as $A, DurabilityMode as $F, TaskOutcomeCounts as AM, AnsiSpan as Dj, EditDiffDisplay as EO, OpenInTarget as FO, NewChatPlace as Fj, ToolCallDisplay as JO, MessageDelivery as MO, AnsiStyle as Oj, ScriptCallStatus as QA, SessionSort as SL, OutputStream as Sj, ApprovalMode as TO, AnsiColor as Tj, Settings as UO, SidebarLayout as WO, TranscriptDensity as XO, ViewsMcp as ZO, QueryBound as aL, ScriptProgress as aj, SessionQueryNot as bL, SessionFieldName as cL, SessionGroupBy as dL, SessionGroupOrder as fL, SessionQueryAny as gL, SessionQueryAll as hL, McpJobViewStatus as hN, FacetPath as iL, ScriptOutputLine as ij, InteractionMode as jO, TaskOutcome as kM, SecretTtl as kR, SessionFieldPath as lL, SessionQuery as mL, McpJobView as mN, QueryValue as oL, EnvironmentConfigValue as oP, Space$1 as ok, SessionCondition as sL, ThinkingLevel as sU, SpaceIcon as sk, EnvironmentSettings as wN, OutputLine as xj };
|
package/dist/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SL as SessionSort, aL as QueryBound, bL as SessionQueryNot, cL as SessionFieldName, dL as SessionGroupBy, fL as SessionGroupOrder, gL as SessionQueryAny, hL as SessionQueryAll, iL as FacetPath, lL as SessionFieldPath, mL as SessionQuery, oL as QueryValue, oP as EnvironmentConfigValue, sL as SessionCondition, sU as ThinkingLevel } from "./index-C6-t1SS9.js";
|
|
2
2
|
import "./execution-failure-SREfl-EZ.js";
|
|
3
3
|
import { d as AuthFailureKind, u as AuthFailure } from "./timeout-CmTx6V9y.js";
|
|
4
4
|
import "./index-De9AbmxS.js";
|
|
@@ -135,6 +135,7 @@ function SessionHeader({ title, titleDisplay, titleScope, cwd, projectRoot, bran
|
|
|
135
135
|
type: "button",
|
|
136
136
|
onClick: onOpenDetails,
|
|
137
137
|
onContextMenu: openMenu,
|
|
138
|
+
"data-testid": "session-title",
|
|
138
139
|
dir: "auto",
|
|
139
140
|
className: `zg-press-subtle min-w-0 max-w-full text-left bg-transparent border-0 cursor-pointer text-sm font-medium text-[var(--zg-text-muted)] whitespace-nowrap overflow-hidden px-1.5 py-1 -mx-1.5 rounded-zg-sm hover:before:bg-[var(--zg-row-hover)] hover:text-[var(--zg-text)] transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--zg-ring)] ${needsTruncate ? "text-ellipsis" : ""}`,
|
|
140
141
|
children: /* @__PURE__ */ jsx(TitleText, {
|
|
@@ -204,12 +204,14 @@ function fixturePerfSample(n, at) {
|
|
|
204
204
|
p95Ms: 90
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
|
-
channel: "chat:stream",
|
|
207
|
+
channel: "chat:stream-port",
|
|
208
208
|
direction: "push",
|
|
209
209
|
count: 3e3 + n * 40,
|
|
210
210
|
totalMs: 410 + n * 3,
|
|
211
211
|
maxMs: 6,
|
|
212
|
-
p95Ms: .4
|
|
212
|
+
p95Ms: .4,
|
|
213
|
+
bytes: 15e5,
|
|
214
|
+
bytesPerMessage: 500
|
|
213
215
|
},
|
|
214
216
|
{
|
|
215
217
|
channel: "sessions:list",
|
|
@@ -94,6 +94,10 @@ export interface PerfChannel {
|
|
|
94
94
|
maxMs: number;
|
|
95
95
|
/** 95th percentile. */
|
|
96
96
|
p95Ms: number;
|
|
97
|
+
/** Bytes carried, estimated from a sample of the messages counted while measured. Absent: not measured. */
|
|
98
|
+
bytes?: number;
|
|
99
|
+
/** The average size of a measured message, bytes. */
|
|
100
|
+
bytesPerMessage?: number;
|
|
97
101
|
}
|
|
98
102
|
/** Where long frames (over 50 ms) spent their time: one script and function, summed. */
|
|
99
103
|
export interface PerfSlowFrame {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* best first, once each, and `groupSettingsResults` groups them by page
|
|
13
13
|
* and section.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
15
|
+
import { UO as Settings } from "../../dist/index-C6-t1SS9.js";
|
|
16
16
|
import { SettingsActionId, SettingsPage } from "./layout.js";
|
|
17
17
|
import { SettingsSearchEntry, SettingsSection } from "./registry.js";
|
|
18
18
|
import { SettingSurface } from "zidane/chat/pure";
|
|
@@ -611,6 +611,7 @@ function Channels({ latest }) {
|
|
|
611
611
|
const l = usePerformanceSectionLabels();
|
|
612
612
|
const channels = latest.channels.slice(0, LIST_CAP);
|
|
613
613
|
const total = latest.channels.reduce((sum, channel) => sum + channel.totalMs, 0);
|
|
614
|
+
const bytes = channels.some((channel) => channel.bytes !== void 0);
|
|
614
615
|
return /* @__PURE__ */ jsx(Section, {
|
|
615
616
|
title: l.perfChannels,
|
|
616
617
|
badges: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -625,7 +626,8 @@ function Channels({ latest }) {
|
|
|
625
626
|
l.perfColCalls,
|
|
626
627
|
l.perfColTotal,
|
|
627
628
|
l.perfColP95,
|
|
628
|
-
l.perfColWorst
|
|
629
|
+
l.perfColWorst,
|
|
630
|
+
...bytes ? [l.perfColBytes] : []
|
|
629
631
|
] }), channels.map((channel) => /* @__PURE__ */ jsxs("div", {
|
|
630
632
|
className: ROW,
|
|
631
633
|
children: [
|
|
@@ -649,6 +651,11 @@ function Channels({ latest }) {
|
|
|
649
651
|
/* @__PURE__ */ jsx("span", {
|
|
650
652
|
className: COL,
|
|
651
653
|
children: formatDuration(channel.maxMs)
|
|
654
|
+
}),
|
|
655
|
+
bytes && /* @__PURE__ */ jsx("span", {
|
|
656
|
+
className: COL,
|
|
657
|
+
title: channel.bytesPerMessage !== void 0 ? l.perfBytesPerMessage(formatMemory(channel.bytesPerMessage)) : void 0,
|
|
658
|
+
children: channel.bytes !== void 0 ? formatMemory(channel.bytes) : "–"
|
|
652
659
|
})
|
|
653
660
|
]
|
|
654
661
|
}, `${channel.direction}\0${channel.channel}`))] })
|
|
@@ -58,6 +58,8 @@ export declare const DEFAULT_PERFORMANCE_SECTION_LABELS: {
|
|
|
58
58
|
perfColTotal: string;
|
|
59
59
|
perfColP95: string;
|
|
60
60
|
perfColWorst: string;
|
|
61
|
+
perfColBytes: string;
|
|
62
|
+
perfBytesPerMessage: (size: string) => string;
|
|
61
63
|
perfColShare: string;
|
|
62
64
|
perfColSelf: string;
|
|
63
65
|
perfReset: string;
|
|
@@ -80,6 +80,8 @@ const DEFAULT_PERFORMANCE_SECTION_LABELS = {
|
|
|
80
80
|
perfColTotal: "total",
|
|
81
81
|
perfColP95: "p95",
|
|
82
82
|
perfColWorst: "worst",
|
|
83
|
+
perfColBytes: "bytes",
|
|
84
|
+
perfBytesPerMessage: (size) => `${size} per message, measured on a sample while this page is open`,
|
|
83
85
|
perfColShare: "share",
|
|
84
86
|
perfColSelf: "self",
|
|
85
87
|
perfReset: "Reset counters",
|
package/dist/styles.css
CHANGED
|
@@ -5915,14 +5915,27 @@ html[data-motion='reduced'] .zg-arc::after {
|
|
|
5915
5915
|
transition: opacity var(--zg-motion-fade);
|
|
5916
5916
|
}
|
|
5917
5917
|
|
|
5918
|
+
/* Past its most ticks (TranscriptRail sets the height) it scrolls; an end with more ticks fades. */
|
|
5918
5919
|
.zg-prompt-rail-ticks {
|
|
5919
5920
|
display: flex;
|
|
5920
5921
|
flex-direction: column;
|
|
5921
|
-
max-height: 192px;
|
|
5922
5922
|
overflow-y: auto;
|
|
5923
|
+
overscroll-behavior: contain;
|
|
5923
5924
|
scrollbar-width: none;
|
|
5924
5925
|
}
|
|
5925
5926
|
|
|
5927
|
+
.zg-prompt-rail-ticks[data-fade-top] {
|
|
5928
|
+
mask-image: linear-gradient(to bottom, transparent, #000 24px);
|
|
5929
|
+
}
|
|
5930
|
+
|
|
5931
|
+
.zg-prompt-rail-ticks[data-fade-bottom] {
|
|
5932
|
+
mask-image: linear-gradient(to top, transparent, #000 24px);
|
|
5933
|
+
}
|
|
5934
|
+
|
|
5935
|
+
.zg-prompt-rail-ticks[data-fade-top][data-fade-bottom] {
|
|
5936
|
+
mask-image: linear-gradient(to bottom, transparent, #000 24px, #000 calc(100% - 24px), transparent);
|
|
5937
|
+
}
|
|
5938
|
+
|
|
5926
5939
|
.zg-prompt-rail-ticks::-webkit-scrollbar {
|
|
5927
5940
|
display: none;
|
|
5928
5941
|
}
|
|
@@ -5930,8 +5943,8 @@ html[data-motion='reduced'] .zg-arc::after {
|
|
|
5930
5943
|
.zg-prompt-rail-tick {
|
|
5931
5944
|
position: relative;
|
|
5932
5945
|
flex: none;
|
|
5933
|
-
width: 100%;
|
|
5934
5946
|
height: 8px;
|
|
5947
|
+
width: 100%;
|
|
5935
5948
|
padding: 0;
|
|
5936
5949
|
border: 0;
|
|
5937
5950
|
background: none;
|
|
@@ -5968,6 +5981,24 @@ html[data-motion='reduced'] .zg-arc::after {
|
|
|
5968
5981
|
background: var(--zg-text);
|
|
5969
5982
|
}
|
|
5970
5983
|
|
|
5984
|
+
/* A prompt whose history is loading for a jump to it. */
|
|
5985
|
+
.zg-prompt-rail-tick[data-pending]::before {
|
|
5986
|
+
background: var(--zg-text-muted);
|
|
5987
|
+
transform: scaleX(1);
|
|
5988
|
+
animation: zg-prompt-rail-pending 0.9s ease-in-out infinite alternate;
|
|
5989
|
+
}
|
|
5990
|
+
|
|
5991
|
+
@keyframes zg-prompt-rail-pending {
|
|
5992
|
+
to {
|
|
5993
|
+
opacity: 0.35;
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
|
|
5997
|
+
html[data-motion='off'] .zg-prompt-rail-tick[data-pending]::before,
|
|
5998
|
+
html[data-motion='reduced'] .zg-prompt-rail-tick[data-pending]::before {
|
|
5999
|
+
animation: none;
|
|
6000
|
+
}
|
|
6001
|
+
|
|
5971
6002
|
.zg-prompt-rail-tick:focus-visible {
|
|
5972
6003
|
outline: 2px solid var(--zg-ring);
|
|
5973
6004
|
outline-offset: 1px;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* draws again only when its answer changes.
|
|
11
11
|
*/
|
|
12
12
|
import { ChatEvent } from "../../chat/headless/host.js";
|
|
13
|
+
import { TranscriptEvents } from "zidane/chat/pure";
|
|
13
14
|
/** An answer the user sent from a view's input. */
|
|
14
15
|
export interface ViewAnswer {
|
|
15
16
|
/** The text the message showed. */
|
|
@@ -28,6 +29,9 @@ export declare function viewAnswerKey(viewId: string, path: readonly number[]):
|
|
|
28
29
|
export declare class ViewAnswers {
|
|
29
30
|
private map;
|
|
30
31
|
private seen;
|
|
32
|
+
private source;
|
|
33
|
+
/** A transcript store's settled answers, per chunk list. */
|
|
34
|
+
private settled;
|
|
31
35
|
private readonly changed;
|
|
32
36
|
private readonly listeners;
|
|
33
37
|
/** Number of answers held. */
|
|
@@ -35,9 +39,11 @@ export declare class ViewAnswers {
|
|
|
35
39
|
/**
|
|
36
40
|
* Reads the events. Call {@link flush} after to tell the controls whose answer changed.
|
|
37
41
|
*
|
|
38
|
-
* @param events - The session's events, oldest first.
|
|
42
|
+
* @param events - The session's events, oldest first, or its transcript store (its settled exchanges are read once).
|
|
39
43
|
*/
|
|
40
|
-
update(events: readonly ChatEvent[]): void;
|
|
44
|
+
update(events: readonly ChatEvent[] | TranscriptEvents<ChatEvent>): void;
|
|
45
|
+
private updateTranscript;
|
|
46
|
+
private updateArray;
|
|
41
47
|
/** Tells the controls whose answer changed since the last flush. */
|
|
42
48
|
flush(): void;
|
|
43
49
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { promptOriginOf } from "../../chat/headless/prompt-origin.js";
|
|
2
|
+
import { chunkFact, noteTranscriptPass } from "zidane/chat/pure";
|
|
2
3
|
// src/views/headless/answers.ts
|
|
3
4
|
/**
|
|
4
5
|
* The key of one input: its view and its node path.
|
|
@@ -13,10 +14,25 @@ function viewAnswerKey(viewId, path) {
|
|
|
13
14
|
function answerOf(event) {
|
|
14
15
|
return event.kind === "user-prompt" && event.childId === void 0 ? promptOriginOf(event)?.view : void 0;
|
|
15
16
|
}
|
|
17
|
+
/** The answers events hold, in order, each key once (the first answer of an input stands). */
|
|
18
|
+
function answersIn(events) {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const event of events) {
|
|
21
|
+
const view = answerOf(event);
|
|
22
|
+
if (view) out.push([viewAnswerKey(view.viewId, view.nodePath), {
|
|
23
|
+
text: event.text ?? "",
|
|
24
|
+
value: view.value
|
|
25
|
+
}]);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
16
29
|
/** The answers of one transcript, per input. */
|
|
17
30
|
var ViewAnswers = class {
|
|
18
31
|
map = /* @__PURE__ */ new Map();
|
|
19
32
|
seen = [];
|
|
33
|
+
source = null;
|
|
34
|
+
/** A transcript store's settled answers, per chunk list. */
|
|
35
|
+
settled = null;
|
|
20
36
|
changed = /* @__PURE__ */ new Set();
|
|
21
37
|
listeners = /* @__PURE__ */ new Map();
|
|
22
38
|
/** Number of answers held. */
|
|
@@ -26,9 +42,50 @@ var ViewAnswers = class {
|
|
|
26
42
|
/**
|
|
27
43
|
* Reads the events. Call {@link flush} after to tell the controls whose answer changed.
|
|
28
44
|
*
|
|
29
|
-
* @param events - The session's events, oldest first.
|
|
45
|
+
* @param events - The session's events, oldest first, or its transcript store (its settled exchanges are read once).
|
|
30
46
|
*/
|
|
31
47
|
update(events) {
|
|
48
|
+
if (events === this.source) return;
|
|
49
|
+
this.source = events;
|
|
50
|
+
if (!Array.isArray(events)) {
|
|
51
|
+
this.updateTranscript(events);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (this.settled) {
|
|
55
|
+
for (const key of this.map.keys()) this.changed.add(key);
|
|
56
|
+
this.map = /* @__PURE__ */ new Map();
|
|
57
|
+
this.settled = null;
|
|
58
|
+
}
|
|
59
|
+
this.updateArray(events);
|
|
60
|
+
}
|
|
61
|
+
updateTranscript(transcript) {
|
|
62
|
+
this.seen = [];
|
|
63
|
+
let settled = this.settled;
|
|
64
|
+
if (!settled || settled.chunks !== transcript.chunks) {
|
|
65
|
+
const map = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const chunk of transcript.chunks) for (const [key, answer] of chunkFact(chunk, "view-answers", answersIn)) if (!map.has(key)) map.set(key, answer);
|
|
67
|
+
settled = {
|
|
68
|
+
chunks: transcript.chunks,
|
|
69
|
+
map
|
|
70
|
+
};
|
|
71
|
+
this.settled = settled;
|
|
72
|
+
}
|
|
73
|
+
noteTranscriptPass("views:answers", transcript.tail.length);
|
|
74
|
+
const open = answersIn(transcript.tail);
|
|
75
|
+
let next = settled.map;
|
|
76
|
+
if (open.some(([key]) => !next.has(key))) {
|
|
77
|
+
next = new Map(next);
|
|
78
|
+
for (const [key, answer] of open) if (!next.has(key)) next.set(key, answer);
|
|
79
|
+
}
|
|
80
|
+
if (next === this.map) return;
|
|
81
|
+
for (const [key, answer] of next) {
|
|
82
|
+
const before = this.map.get(key);
|
|
83
|
+
if (!before || before.text !== answer.text || before.value !== answer.value) this.changed.add(key);
|
|
84
|
+
}
|
|
85
|
+
for (const key of this.map.keys()) if (!next.has(key)) this.changed.add(key);
|
|
86
|
+
this.map = next;
|
|
87
|
+
}
|
|
88
|
+
updateArray(events) {
|
|
32
89
|
if (events === this.seen) return;
|
|
33
90
|
const last = this.seen.length;
|
|
34
91
|
const grew = events.length >= last && (last === 0 || events[last - 1] === this.seen[last - 1]);
|
|
@@ -29,6 +29,49 @@ export interface ReplyViewPlace {
|
|
|
29
29
|
* @param previous - The result of the last call, or `undefined`.
|
|
30
30
|
*/
|
|
31
31
|
export declare function viewPlacements(events: readonly ChatEvent[], previous?: ReadonlyMap<string, ReplyViewPlace>): Map<string, ReplyViewPlace>;
|
|
32
|
+
/** A map read through to `base`, written to its own entries: a fold resumed from a settled state copies nothing of it. */
|
|
33
|
+
export declare class LayeredMap<K, V> {
|
|
34
|
+
readonly base: ReadonlyMap<K, V>;
|
|
35
|
+
readonly top: Map<K, V>;
|
|
36
|
+
constructor(base?: ReadonlyMap<K, V>);
|
|
37
|
+
get(key: K): V | undefined;
|
|
38
|
+
has(key: K): boolean;
|
|
39
|
+
set(key: K, value: V): this;
|
|
40
|
+
}
|
|
41
|
+
/** The state of {@link viewPlacements} part way through a transcript: resumed on the events after it. */
|
|
42
|
+
export interface PlacementFold {
|
|
43
|
+
places: Map<string, ReplyViewPlace> | LayeredMap<string, ReplyViewPlace>;
|
|
44
|
+
ordinals: Map<string, number> | LayeredMap<string, number>;
|
|
45
|
+
fencesByTurn: Map<string, number> | LayeredMap<string, number>;
|
|
46
|
+
exchangeTurns: string[];
|
|
47
|
+
finalReply: string | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A fold at the start of a transcript, or resumed after `base` (read through, never written).
|
|
51
|
+
*
|
|
52
|
+
* @param base - The fold of the events before, or none.
|
|
53
|
+
*/
|
|
54
|
+
export declare function placementFold(base?: PlacementFold): PlacementFold;
|
|
55
|
+
/**
|
|
56
|
+
* Gives the open exchange's final reply the turns whose unplaced codemode views it draws, and starts the next exchange.
|
|
57
|
+
*
|
|
58
|
+
* @param fold - The fold.
|
|
59
|
+
*/
|
|
60
|
+
export declare function closePlacementExchange(fold: PlacementFold): void;
|
|
61
|
+
/**
|
|
62
|
+
* Reads `events` into the fold (the open exchange stays open).
|
|
63
|
+
*
|
|
64
|
+
* @param fold - The fold.
|
|
65
|
+
* @param events - The events after those it read, oldest first.
|
|
66
|
+
*/
|
|
67
|
+
export declare function foldPlacements(fold: PlacementFold, events: readonly ChatEvent[]): void;
|
|
68
|
+
/**
|
|
69
|
+
* Whether two places send a reply's views to the same spots.
|
|
70
|
+
*
|
|
71
|
+
* @param a - One place.
|
|
72
|
+
* @param b - The other.
|
|
73
|
+
*/
|
|
74
|
+
export declare function sameViewPlace(a: ReplyViewPlace, b: ReplyViewPlace): boolean;
|
|
32
75
|
/**
|
|
33
76
|
* Whether a session with these events can hold a view: a reply with a `view` fence, or a tool
|
|
34
77
|
* call (a codemode script or an MCP app makes the others).
|
|
@@ -62,6 +105,41 @@ export interface TextlessExchange {
|
|
|
62
105
|
* @param events - The session's events, oldest first.
|
|
63
106
|
*/
|
|
64
107
|
export declare function textlessExchanges(events: readonly ChatEvent[]): TextlessExchange[];
|
|
108
|
+
/** The state of {@link textlessExchanges} part way through a transcript: the closed exchanges, and the open one. */
|
|
109
|
+
export interface TextlessFold {
|
|
110
|
+
/** The closed exchanges with no reply text. */
|
|
111
|
+
out: TextlessExchange[];
|
|
112
|
+
/** `out` is the base fold's: copied before the first push. */
|
|
113
|
+
shared: boolean;
|
|
114
|
+
turns: string[];
|
|
115
|
+
replied: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A fold at the start of a transcript, or resumed after `base` (its closed list is shared until one closes).
|
|
119
|
+
*
|
|
120
|
+
* @param base - The fold of the events before, or none.
|
|
121
|
+
*/
|
|
122
|
+
export declare function textlessFold(base?: TextlessFold): TextlessFold;
|
|
123
|
+
/**
|
|
124
|
+
* Reads `events` into the fold.
|
|
125
|
+
*
|
|
126
|
+
* @param fold - The fold.
|
|
127
|
+
* @param events - The events after those it read, oldest first.
|
|
128
|
+
*/
|
|
129
|
+
export declare function foldTextless(fold: TextlessFold, events: readonly ChatEvent[]): void;
|
|
130
|
+
/**
|
|
131
|
+
* The fold's exchanges with no reply text, the open one last.
|
|
132
|
+
*
|
|
133
|
+
* @param fold - The fold.
|
|
134
|
+
*/
|
|
135
|
+
export declare function textlessOf(fold: TextlessFold): TextlessExchange[];
|
|
136
|
+
/**
|
|
137
|
+
* Whether two lists name the same exchanges, turns and states.
|
|
138
|
+
*
|
|
139
|
+
* @param a - One list.
|
|
140
|
+
* @param b - The other.
|
|
141
|
+
*/
|
|
142
|
+
export declare function sameTextless(a: readonly TextlessExchange[], b: readonly TextlessExchange[]): boolean;
|
|
65
143
|
/** Container widths where a view's stored height changes, in CSS pixels. */
|
|
66
144
|
export declare const VIEW_WIDTH_STEPS: readonly [480, 720, 960];
|
|
67
145
|
/**
|
|
@@ -26,50 +26,109 @@ function samePlace(a, b) {
|
|
|
26
26
|
* @param previous - The result of the last call, or `undefined`.
|
|
27
27
|
*/
|
|
28
28
|
function viewPlacements(events, previous) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
const fold = placementFold();
|
|
30
|
+
foldPlacements(fold, events);
|
|
31
|
+
closePlacementExchange(fold);
|
|
32
|
+
const places = fold.places;
|
|
33
|
+
if (previous) for (const [rowId, place] of places) {
|
|
34
|
+
const before = previous.get(rowId);
|
|
35
|
+
if (before && samePlace(before, place)) places.set(rowId, before);
|
|
36
|
+
}
|
|
37
|
+
return places;
|
|
38
|
+
}
|
|
39
|
+
/** A map read through to `base`, written to its own entries: a fold resumed from a settled state copies nothing of it. */
|
|
40
|
+
var LayeredMap = class {
|
|
41
|
+
base;
|
|
42
|
+
top = /* @__PURE__ */ new Map();
|
|
43
|
+
constructor(base = /* @__PURE__ */ new Map()) {
|
|
44
|
+
this.base = base;
|
|
45
|
+
}
|
|
46
|
+
get(key) {
|
|
47
|
+
return this.top.has(key) ? this.top.get(key) : this.base.get(key);
|
|
48
|
+
}
|
|
49
|
+
has(key) {
|
|
50
|
+
return this.top.has(key) || this.base.has(key);
|
|
51
|
+
}
|
|
52
|
+
set(key, value) {
|
|
53
|
+
this.top.set(key, value);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A fold at the start of a transcript, or resumed after `base` (read through, never written).
|
|
59
|
+
*
|
|
60
|
+
* @param base - The fold of the events before, or none.
|
|
61
|
+
*/
|
|
62
|
+
function placementFold(base) {
|
|
63
|
+
if (!base) return {
|
|
64
|
+
places: /* @__PURE__ */ new Map(),
|
|
65
|
+
ordinals: /* @__PURE__ */ new Map(),
|
|
66
|
+
fencesByTurn: /* @__PURE__ */ new Map(),
|
|
67
|
+
exchangeTurns: [],
|
|
68
|
+
finalReply: void 0
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
places: new LayeredMap(base.places),
|
|
72
|
+
ordinals: new LayeredMap(base.ordinals),
|
|
73
|
+
fencesByTurn: new LayeredMap(base.fencesByTurn),
|
|
74
|
+
exchangeTurns: [...base.exchangeTurns],
|
|
75
|
+
finalReply: base.finalReply
|
|
44
76
|
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gives the open exchange's final reply the turns whose unplaced codemode views it draws, and starts the next exchange.
|
|
80
|
+
*
|
|
81
|
+
* @param fold - The fold.
|
|
82
|
+
*/
|
|
83
|
+
function closePlacementExchange(fold) {
|
|
84
|
+
if (fold.finalReply && fold.exchangeTurns.length > 0) {
|
|
85
|
+
const place = fold.places.get(fold.finalReply);
|
|
86
|
+
fold.places.set(fold.finalReply, {
|
|
87
|
+
...place,
|
|
88
|
+
codemodeTurns: fold.exchangeTurns
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
fold.exchangeTurns = [];
|
|
92
|
+
fold.finalReply = void 0;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads `events` into the fold (the open exchange stays open).
|
|
96
|
+
*
|
|
97
|
+
* @param fold - The fold.
|
|
98
|
+
* @param events - The events after those it read, oldest first.
|
|
99
|
+
*/
|
|
100
|
+
function foldPlacements(fold, events) {
|
|
45
101
|
for (const event of events) {
|
|
46
102
|
const top = event.childId === void 0;
|
|
47
103
|
if (event.kind === "user-prompt" && top) {
|
|
48
|
-
|
|
104
|
+
closePlacementExchange(fold);
|
|
49
105
|
continue;
|
|
50
106
|
}
|
|
51
107
|
const turnId = event.turnId;
|
|
52
108
|
if (!turnId) continue;
|
|
53
|
-
if (top && !exchangeTurns.includes(turnId)) exchangeTurns.push(turnId);
|
|
109
|
+
if (top && !fold.exchangeTurns.includes(turnId)) fold.exchangeTurns.push(turnId);
|
|
54
110
|
if (event.kind !== "markdown") continue;
|
|
55
111
|
const key = `${turnId}\u0000${event.childId ?? ""}`;
|
|
56
|
-
const ordinal = (ordinals.get(key) ?? 0) + 1;
|
|
57
|
-
ordinals.set(key, ordinal);
|
|
112
|
+
const ordinal = (fold.ordinals.get(key) ?? 0) + 1;
|
|
113
|
+
fold.ordinals.set(key, ordinal);
|
|
58
114
|
const rowId = `m-${turnId}-${ordinal}`;
|
|
59
|
-
const fenceBase = fencesByTurn.get(turnId) ?? 0;
|
|
60
|
-
fencesByTurn.set(turnId, fenceBase + fencesIn(event));
|
|
61
|
-
places.set(rowId, {
|
|
115
|
+
const fenceBase = fold.fencesByTurn.get(turnId) ?? 0;
|
|
116
|
+
fold.fencesByTurn.set(turnId, fenceBase + fencesIn(event));
|
|
117
|
+
fold.places.set(rowId, {
|
|
62
118
|
turnId,
|
|
63
119
|
fenceBase
|
|
64
120
|
});
|
|
65
|
-
if (top) finalReply = rowId;
|
|
121
|
+
if (top) fold.finalReply = rowId;
|
|
66
122
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether two places send a reply's views to the same spots.
|
|
126
|
+
*
|
|
127
|
+
* @param a - One place.
|
|
128
|
+
* @param b - The other.
|
|
129
|
+
*/
|
|
130
|
+
function sameViewPlace(a, b) {
|
|
131
|
+
return samePlace(a, b);
|
|
73
132
|
}
|
|
74
133
|
/**
|
|
75
134
|
* Whether a session with these events can hold a view: a reply with a `view` fence, or a tool
|
|
@@ -107,28 +166,79 @@ function onlyLastTextChanged(previous, next) {
|
|
|
107
166
|
* @param events - The session's events, oldest first.
|
|
108
167
|
*/
|
|
109
168
|
function textlessExchanges(events) {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
169
|
+
const fold = textlessFold();
|
|
170
|
+
foldTextless(fold, events);
|
|
171
|
+
return textlessOf(fold);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A fold at the start of a transcript, or resumed after `base` (its closed list is shared until one closes).
|
|
175
|
+
*
|
|
176
|
+
* @param base - The fold of the events before, or none.
|
|
177
|
+
*/
|
|
178
|
+
function textlessFold(base) {
|
|
179
|
+
return base ? {
|
|
180
|
+
out: base.out,
|
|
181
|
+
shared: true,
|
|
182
|
+
turns: [...base.turns],
|
|
183
|
+
replied: base.replied
|
|
184
|
+
} : {
|
|
185
|
+
out: [],
|
|
186
|
+
shared: false,
|
|
187
|
+
turns: [],
|
|
188
|
+
replied: false
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Reads `events` into the fold.
|
|
193
|
+
*
|
|
194
|
+
* @param fold - The fold.
|
|
195
|
+
* @param events - The events after those it read, oldest first.
|
|
196
|
+
*/
|
|
197
|
+
function foldTextless(fold, events) {
|
|
113
198
|
for (const event of events) {
|
|
114
199
|
if (event.childId !== void 0) continue;
|
|
115
200
|
if (event.kind === "user-prompt") {
|
|
116
|
-
if (!replied && turns.length > 0)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
201
|
+
if (!fold.replied && fold.turns.length > 0) {
|
|
202
|
+
if (fold.shared) {
|
|
203
|
+
fold.out = [...fold.out];
|
|
204
|
+
fold.shared = false;
|
|
205
|
+
}
|
|
206
|
+
fold.out.push({
|
|
207
|
+
turns: fold.turns,
|
|
208
|
+
closed: true
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
fold.turns = [];
|
|
212
|
+
fold.replied = false;
|
|
122
213
|
continue;
|
|
123
214
|
}
|
|
124
|
-
if (event.turnId && !turns.includes(event.turnId)) turns.push(event.turnId);
|
|
125
|
-
if (event.kind === "markdown" && event.turnId) replied = true;
|
|
215
|
+
if (event.turnId && !fold.turns.includes(event.turnId)) fold.turns.push(event.turnId);
|
|
216
|
+
if (event.kind === "markdown" && event.turnId) fold.replied = true;
|
|
126
217
|
}
|
|
127
|
-
|
|
128
|
-
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The fold's exchanges with no reply text, the open one last.
|
|
221
|
+
*
|
|
222
|
+
* @param fold - The fold.
|
|
223
|
+
*/
|
|
224
|
+
function textlessOf(fold) {
|
|
225
|
+
return !fold.replied && fold.turns.length > 0 ? [...fold.out, {
|
|
226
|
+
turns: fold.turns,
|
|
129
227
|
closed: false
|
|
228
|
+
}] : [...fold.out];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Whether two lists name the same exchanges, turns and states.
|
|
232
|
+
*
|
|
233
|
+
* @param a - One list.
|
|
234
|
+
* @param b - The other.
|
|
235
|
+
*/
|
|
236
|
+
function sameTextless(a, b) {
|
|
237
|
+
if (a === b) return true;
|
|
238
|
+
return a.length === b.length && a.every((x, i) => {
|
|
239
|
+
const y = b[i];
|
|
240
|
+
return x === y || x.closed === y.closed && sameTurns(x.turns, y.turns);
|
|
130
241
|
});
|
|
131
|
-
return out;
|
|
132
242
|
}
|
|
133
243
|
/** Container widths where a view's stored height changes, in CSS pixels. */
|
|
134
244
|
const VIEW_WIDTH_STEPS = [
|
|
@@ -246,4 +356,4 @@ function unplacedCodemodeViews(views, turns, options = {}) {
|
|
|
246
356
|
const apps = options.mcpApps !== false;
|
|
247
357
|
return views.filter((view) => (apps && view.anchor.kind === "mcp-app" || view.anchor.kind === "codemode" && view.placed !== true) && turns.includes(view.anchor.turnId));
|
|
248
358
|
}
|
|
249
|
-
export { VIEW_WIDTH_STEPS, eventsMayHoldViews, fenceViewOf, heightFor, onlyLastTextChanged, textlessExchanges, unplacedCodemodeViews, viewById, viewPlacements, viewVersion, widthRange, withHeight };
|
|
359
|
+
export { LayeredMap, VIEW_WIDTH_STEPS, closePlacementExchange, eventsMayHoldViews, fenceViewOf, foldPlacements, foldTextless, heightFor, onlyLastTextChanged, placementFold, sameTextless, sameViewPlace, textlessExchanges, textlessFold, textlessOf, unplacedCodemodeViews, viewById, viewPlacements, viewVersion, widthRange, withHeight };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zidane-ui",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"description": "Zidane design system and chat kit: tokens, surface primitives, theme engine, React components, the chat layer (sessions, transcript, composer) and ChatHost adapters.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -584,7 +584,7 @@
|
|
|
584
584
|
"react": "^19.3.0",
|
|
585
585
|
"react-dom": "^19.3.0",
|
|
586
586
|
"unocss": ">=66.0.0",
|
|
587
|
-
"zidane": "^9.
|
|
587
|
+
"zidane": "^9.3.1",
|
|
588
588
|
"vitest": ">=3"
|
|
589
589
|
},
|
|
590
590
|
"peerDependenciesMeta": {
|