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.
Files changed (151) hide show
  1. package/dist/adapters/live.d.ts +6 -0
  2. package/dist/adapters/live.js +16 -8
  3. package/dist/adapters/server-composer-host.js +22 -9
  4. package/dist/adapters/server-host.js +143 -18
  5. package/dist/adapters/server-media.d.ts +9 -1
  6. package/dist/adapters/server-media.js +14 -1
  7. package/dist/chat/HostTranscript.d.ts +0 -12
  8. package/dist/chat/HostTranscript.js +6 -1
  9. package/dist/chat/SessionStreamsProvider.d.ts +8 -0
  10. package/dist/chat/SessionStreamsProvider.js +11 -2
  11. package/dist/chat/Transcript.d.ts +20 -11
  12. package/dist/chat/Transcript.js +326 -160
  13. package/dist/chat/composer/ComposerEditor.js +1 -1
  14. package/dist/chat/headless/host.d.ts +43 -7
  15. package/dist/chat/headless/index.d.ts +7 -6
  16. package/dist/chat/headless/index.js +10 -9
  17. package/dist/chat/headless/labels.d.ts +17 -0
  18. package/dist/chat/headless/labels.js +17 -0
  19. package/dist/chat/headless/markdown-chunks.d.ts +2 -1
  20. package/dist/chat/headless/markdown-chunks.js +12 -20
  21. package/dist/chat/headless/markdown-scan.d.ts +66 -0
  22. package/dist/chat/headless/markdown-scan.js +124 -0
  23. package/dist/chat/headless/markdown-stream.d.ts +64 -0
  24. package/dist/chat/headless/markdown-stream.js +143 -0
  25. package/dist/chat/headless/output-pager.d.ts +68 -0
  26. package/dist/chat/headless/output-pager.js +113 -0
  27. package/dist/chat/headless/session-list.d.ts +10 -0
  28. package/dist/chat/headless/sidebar/activity.d.ts +14 -0
  29. package/dist/chat/headless/sidebar/activity.js +32 -0
  30. package/dist/chat/headless/sidebar/directory.d.ts +9 -1
  31. package/dist/chat/headless/sidebar/directory.js +10 -50
  32. package/dist/chat/headless/sidebar/labels.d.ts +11 -1
  33. package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
  34. package/dist/chat/headless/sidebar/prewarm.js +114 -0
  35. package/dist/chat/headless/streams/actions.d.ts +2 -0
  36. package/dist/chat/headless/streams/actions.js +1 -0
  37. package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
  38. package/dist/chat/headless/streams/event-bytes.js +34 -0
  39. package/dist/chat/headless/streams/live-events.d.ts +25 -1
  40. package/dist/chat/headless/streams/live-events.js +53 -2
  41. package/dist/chat/headless/streams/selectors.d.ts +3 -0
  42. package/dist/chat/headless/streams/selectors.js +8 -1
  43. package/dist/chat/headless/streams/session-streams.d.ts +15 -3
  44. package/dist/chat/headless/streams/session-streams.js +31 -3
  45. package/dist/chat/headless/streams/store.d.ts +24 -1
  46. package/dist/chat/headless/streams/store.js +51 -26
  47. package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
  48. package/dist/chat/headless/streams/transcript-map.js +88 -0
  49. package/dist/chat/headless/streams/transcript.d.ts +4 -2
  50. package/dist/chat/headless/streams/transcript.js +19 -7
  51. package/dist/chat/headless/transcript/batch.js +5 -1
  52. package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
  53. package/dist/chat/headless/transcript/blob-media.js +23 -0
  54. package/dist/chat/headless/transcript/collapse.d.ts +10 -0
  55. package/dist/chat/headless/transcript/collapse.js +32 -6
  56. package/dist/chat/headless/transcript/derive.d.ts +98 -0
  57. package/dist/chat/headless/transcript/derive.js +89 -0
  58. package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
  59. package/dist/chat/headless/transcript/exchange-media.js +8 -5
  60. package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
  61. package/dist/chat/headless/transcript/fold-attachments.js +3 -2
  62. package/dist/chat/headless/transcript/fold.d.ts +2 -1
  63. package/dist/chat/headless/transcript/fold.js +16 -6
  64. package/dist/chat/headless/transcript/incremental.d.ts +53 -0
  65. package/dist/chat/headless/transcript/incremental.js +181 -0
  66. package/dist/chat/headless/transcript/index.d.ts +2 -2
  67. package/dist/chat/headless/transcript/index.js +2 -2
  68. package/dist/chat/headless/transcript/nesting.js +2 -1
  69. package/dist/chat/headless/transcript/rail.d.ts +50 -1
  70. package/dist/chat/headless/transcript/rail.js +165 -23
  71. package/dist/chat/headless/transcript/rows.d.ts +5 -1
  72. package/dist/chat/headless/transcript/run-failures.js +2 -1
  73. package/dist/chat/headless/transcript/seams.d.ts +78 -0
  74. package/dist/chat/headless/transcript/seams.js +116 -0
  75. package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
  76. package/dist/chat/headless/transcript/tool-media.js +27 -9
  77. package/dist/chat/index.d.ts +8 -7
  78. package/dist/chat/index.js +17 -16
  79. package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
  80. package/dist/chat/sidebar/SidebarFooter.js +6 -6
  81. package/dist/chat/testing/contract.d.ts +5 -3
  82. package/dist/chat/testing/contract.js +66 -1
  83. package/dist/chat/transcript/DiffLines.d.ts +6 -1
  84. package/dist/chat/transcript/DiffLines.js +35 -20
  85. package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
  86. package/dist/chat/transcript/EditDiffBlock.js +89 -30
  87. package/dist/chat/transcript/LazyRow.d.ts +40 -40
  88. package/dist/chat/transcript/LazyRow.js +101 -149
  89. package/dist/chat/transcript/MermaidDiagram.js +2 -1
  90. package/dist/chat/transcript/SubagentBlock.js +3 -2
  91. package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
  92. package/dist/chat/transcript/TranscriptRail.js +175 -17
  93. package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
  94. package/dist/chat/transcript/TranscriptRow.js +4 -3
  95. package/dist/chat/transcript/actions.d.ts +37 -1
  96. package/dist/chat/transcript/actions.js +27 -1
  97. package/dist/chat/transcript/clipped-output.d.ts +58 -0
  98. package/dist/chat/transcript/clipped-output.js +131 -0
  99. package/dist/chat/transcript/fold-attachments.js +10 -5
  100. package/dist/chat/transcript/fold-worker.js +3 -2
  101. package/dist/chat/transcript/fold.js +2 -1
  102. package/dist/chat/transcript/index.d.ts +10 -9
  103. package/dist/chat/transcript/index.js +9 -8
  104. package/dist/chat/transcript/markdown-cache.d.ts +7 -1
  105. package/dist/chat/transcript/markdown-cache.js +12 -1
  106. package/dist/chat/transcript/markdown.js +116 -54
  107. package/dist/chat/transcript/media-gallery.d.ts +3 -2
  108. package/dist/chat/transcript/media-gallery.js +10 -7
  109. package/dist/chat/transcript/notices.js +2 -1
  110. package/dist/chat/transcript/prompt.js +6 -4
  111. package/dist/chat/transcript/prose.js +2 -1
  112. package/dist/chat/transcript/root-items.d.ts +96 -0
  113. package/dist/chat/transcript/root-items.js +180 -0
  114. package/dist/chat/transcript/row-mount.d.ts +165 -0
  115. package/dist/chat/transcript/row-mount.js +498 -0
  116. package/dist/chat/transcript/row-parking.d.ts +125 -0
  117. package/dist/chat/transcript/row-parking.js +135 -0
  118. package/dist/chat/transcript/row-ui-state.d.ts +37 -0
  119. package/dist/chat/transcript/row-ui-state.js +53 -0
  120. package/dist/chat/transcript/run-rows.js +3 -2
  121. package/dist/chat/transcript/script-input.d.ts +1 -1
  122. package/dist/chat/transcript/tasks.js +3 -2
  123. package/dist/chat/transcript/tool-media.d.ts +4 -2
  124. package/dist/chat/transcript/tool-media.js +15 -7
  125. package/dist/chat/transcript/tool-parts.d.ts +27 -4
  126. package/dist/chat/transcript/tool-parts.js +31 -5
  127. package/dist/chat/transcript/tool-payload.js +26 -11
  128. package/dist/chat/transcript/tool-row.d.ts +2 -1
  129. package/dist/chat/transcript/tool-row.js +38 -19
  130. package/dist/chat/transcript/use-transcript-rows.d.ts +24 -7
  131. package/dist/chat/transcript/use-transcript-rows.js +28 -46
  132. package/dist/chat/transcript/useStickToBottom.js +2 -3
  133. package/dist/chat/transcript/useTranscriptSearch.js +30 -14
  134. package/dist/chat/transcript/view-scope.d.ts +26 -6
  135. package/dist/chat/transcript/view-scope.js +106 -20
  136. package/dist/dist/{index-E1Z0aPmi.d.ts → index-C6-t1SS9.d.ts} +2 -1
  137. package/dist/dist/index.d.ts +1 -1
  138. package/dist/session/SessionHeader.js +1 -0
  139. package/dist/settings/headless/fixture-performance.js +4 -2
  140. package/dist/settings/headless/performance.d.ts +4 -0
  141. package/dist/settings/headless/search.d.ts +1 -1
  142. package/dist/settings/sections/performance/PerformanceSection.js +8 -1
  143. package/dist/settings/sections/performance/labels.d.ts +2 -0
  144. package/dist/settings/sections/performance/labels.js +2 -0
  145. package/dist/styles.css +33 -2
  146. package/dist/views/headless/answers.d.ts +8 -2
  147. package/dist/views/headless/answers.js +58 -1
  148. package/dist/views/headless/placement.d.ts +78 -0
  149. package/dist/views/headless/placement.js +154 -44
  150. package/package.json +2 -2
  151. 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 { AnsiColor as $A, SecretTtl as $L, QueryValue as AI, SessionQueryAny as BI, DurabilityMode as CF, ScriptLineProgress as DA, ScriptCallStatus as EA, ViewsMcp as EO, SessionGroupBy as FI, SpaceIcon as FO, McpJobView as HM, SessionGroupOrder as II, SessionSort as KI, ScriptOutputLine as MA, SessionFieldName as MI, ScriptProgress as NA, SessionFieldPath as NI, FacetPath as OI, Space$1 as PO, EnvironmentSettings as QM, SessionQuery as RI, TranscriptDensity as TO, McpJobViewStatus as UM, SessionQueryNot as WI, OutputStream as XA, OutputLine as YA, EnvironmentConfigValue as _N, Settings as bO, InteractionMode as cO, OpenInTarget as fO, TaskOutcomeCounts as iM, ThinkingLevel as jH, SessionCondition as jI, QueryBound as kI, MessageDelivery as lO, NewChatPlace as lj, ApprovalMode as nO, AnsiStyle as nj, TaskOutcome as rM, EditDiffDisplay as rO, AnsiSpan as tj, ToolCallDisplay as wO, SidebarLayout as xO, SessionQueryAll as zI };
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 };
@@ -1,4 +1,4 @@
1
- import { AI as QueryValue, BI as SessionQueryAny, FI as SessionGroupBy, II as SessionGroupOrder, KI as SessionSort, MI as SessionFieldName, NI as SessionFieldPath, OI as FacetPath, RI as SessionQuery, WI as SessionQueryNot, jH as ThinkingLevel, jI as SessionCondition, kI as QueryBound, zI as SessionQueryAll } from "./index-E1Z0aPmi.js";
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 { bO as Settings } from "../../dist/index-E1Z0aPmi.js";
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 places = /* @__PURE__ */ new Map();
30
- const ordinals = /* @__PURE__ */ new Map();
31
- const fencesByTurn = /* @__PURE__ */ new Map();
32
- let exchangeTurns = [];
33
- let finalReply;
34
- const closeExchange = () => {
35
- if (finalReply && exchangeTurns.length > 0) {
36
- const place = places.get(finalReply);
37
- places.set(finalReply, {
38
- ...place,
39
- codemodeTurns: exchangeTurns
40
- });
41
- }
42
- exchangeTurns = [];
43
- finalReply = void 0;
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
- closeExchange();
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
- closeExchange();
68
- if (previous) for (const [rowId, place] of places) {
69
- const before = previous.get(rowId);
70
- if (before && samePlace(before, place)) places.set(rowId, before);
71
- }
72
- return places;
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 out = [];
111
- let turns = [];
112
- let replied = false;
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) out.push({
117
- turns,
118
- closed: true
119
- });
120
- turns = [];
121
- replied = false;
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
- if (!replied && turns.length > 0) out.push({
128
- turns,
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.2.3",
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.2.3",
587
+ "zidane": "^9.3.1",
588
588
  "vitest": ">=3"
589
589
  },
590
590
  "peerDependenciesMeta": {