zidane-ui 9.1.13 → 9.1.16

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 (290) hide show
  1. package/dist/adapters/index.d.ts +2 -2
  2. package/dist/adapters/index.js +2 -2
  3. package/dist/adapters/live.d.ts +29 -3
  4. package/dist/adapters/live.js +9 -1
  5. package/dist/adapters/server-composer-host.js +17 -2
  6. package/dist/adapters/server-extensions-host.d.ts +0 -1
  7. package/dist/adapters/server-extensions-host.js +4 -15
  8. package/dist/adapters/server-git-host.js +7 -16
  9. package/dist/adapters/server-host.js +181 -43
  10. package/dist/adapters/server-machines-host.d.ts +2 -0
  11. package/dist/adapters/server-machines-host.js +22 -23
  12. package/dist/adapters/server-onboarding-host.d.ts +1 -1
  13. package/dist/adapters/server-onboarding-host.js +3 -4
  14. package/dist/adapters/server-session-host.js +22 -3
  15. package/dist/adapters/server-settings-accounts.js +2 -2
  16. package/dist/adapters/server-settings-host.js +2 -2
  17. package/dist/adapters/server-settings-performance.js +7 -9
  18. package/dist/adapters/server-settings-sections.js +13 -14
  19. package/dist/adapters/server-sidebar-host.js +2 -2
  20. package/dist/adapters/sse-host.js +68 -3
  21. package/dist/adapters/sse-protocol.d.ts +12 -2
  22. package/dist/adapters/sse-protocol.js +4 -2
  23. package/dist/app/AppHostProvider.js +4 -3
  24. package/dist/app/ModalProvider.d.ts +13 -3
  25. package/dist/app/ModalProvider.js +103 -24
  26. package/dist/app/NoticeStack.d.ts +33 -0
  27. package/dist/app/NoticeStack.js +90 -0
  28. package/dist/app/index.d.ts +3 -2
  29. package/dist/app/index.js +3 -2
  30. package/dist/chat/SessionFilterMenu.d.ts +1 -1
  31. package/dist/chat/SessionFilterMenu.js +2 -1
  32. package/dist/chat/composer/Composer.js +10 -8
  33. package/dist/chat/composer/ModelChainList.js +17 -8
  34. package/dist/chat/composer/ModelChainTooltip.js +5 -2
  35. package/dist/chat/composer/use-draft-target.d.ts +20 -1
  36. package/dist/chat/composer/use-draft-target.js +121 -5
  37. package/dist/chat/composer/use-new-session-defaults.d.ts +5 -1
  38. package/dist/chat/composer/use-new-session-defaults.js +17 -4
  39. package/dist/chat/headless/chip-labels.d.ts +1 -0
  40. package/dist/chat/headless/chip-labels.js +1 -0
  41. package/dist/chat/headless/composer/labels-editor.d.ts +0 -2
  42. package/dist/chat/headless/composer/labels-editor.js +0 -2
  43. package/dist/chat/headless/draft-target.d.ts +21 -1
  44. package/dist/chat/headless/fixture-host.js +17 -2
  45. package/dist/chat/headless/host.d.ts +3 -3
  46. package/dist/chat/headless/index.d.ts +9 -9
  47. package/dist/chat/headless/index.js +2 -2
  48. package/dist/chat/headless/labels.d.ts +13 -6
  49. package/dist/chat/headless/labels.js +10 -9
  50. package/dist/chat/headless/session-list.d.ts +20 -8
  51. package/dist/chat/headless/session-list.js +1 -0
  52. package/dist/chat/headless/sidebar/directory.d.ts +56 -14
  53. package/dist/chat/headless/sidebar/directory.js +149 -70
  54. package/dist/chat/headless/sidebar/index.d.ts +3 -3
  55. package/dist/chat/headless/sidebar/index.js +2 -2
  56. package/dist/chat/headless/sidebar/labels.d.ts +15 -8
  57. package/dist/chat/headless/sidebar/types.d.ts +3 -1
  58. package/dist/chat/headless/sidebar/view.d.ts +13 -5
  59. package/dist/chat/headless/sidebar/view.js +31 -11
  60. package/dist/chat/headless/streams/actions.d.ts +5 -3
  61. package/dist/chat/headless/streams/actions.js +3 -2
  62. package/dist/chat/headless/streams/index.d.ts +3 -3
  63. package/dist/chat/headless/streams/merge.d.ts +6 -10
  64. package/dist/chat/headless/streams/merge.js +7 -21
  65. package/dist/chat/headless/streams/session-streams.d.ts +29 -4
  66. package/dist/chat/headless/streams/session-streams.js +86 -0
  67. package/dist/chat/headless/streams/store.d.ts +162 -16
  68. package/dist/chat/headless/streams/store.js +334 -38
  69. package/dist/chat/headless/streams/types.d.ts +10 -7
  70. package/dist/chat/headless/transcript-labels.d.ts +1 -0
  71. package/dist/chat/interactions/PlanCard.js +10 -3
  72. package/dist/chat/interactions/QuestionForm.js +7 -3
  73. package/dist/chat/interactions/card-ui.d.ts +5 -3
  74. package/dist/chat/interactions/card-ui.js +9 -7
  75. package/dist/chat/rich-composer/RichComposer.js +1 -7
  76. package/dist/chat/rich-composer/composer-extensions.d.ts +0 -2
  77. package/dist/chat/rich-composer/composer-extensions.js +2 -2
  78. package/dist/chat/rich-composer/use-composer-editor.d.ts +0 -2
  79. package/dist/chat/rich-composer/use-composer-editor.js +1 -2
  80. package/dist/chat/sidebar/SessionSidebar.js +5 -5
  81. package/dist/chat/sidebar/SidebarFilterMenu.js +3 -1
  82. package/dist/chat/sidebar/SidebarFrame.d.ts +4 -0
  83. package/dist/chat/sidebar/SidebarFrame.js +27 -9
  84. package/dist/chat/sidebar/SidebarGroupHeader.js +1 -1
  85. package/dist/chat/sidebar/SidebarHostProvider.d.ts +8 -5
  86. package/dist/chat/sidebar/SidebarHostProvider.js +13 -9
  87. package/dist/chat/sidebar/SidebarToggleButton.js +7 -3
  88. package/dist/chat/sidebar/index.d.ts +2 -2
  89. package/dist/chat/sidebar/session-menu.js +4 -4
  90. package/dist/chat/sidebar/useSaveViewAsSpace.js +2 -2
  91. package/dist/chat/testing/contract.js +2 -2
  92. package/dist/chat/transcript/AuthFailureCard.js +11 -8
  93. package/dist/chat/transcript/BadgeMenu.js +13 -2
  94. package/dist/chat/transcript/MermaidDiagram.js +7 -3
  95. package/dist/chat/transcript/fold.d.ts +4 -0
  96. package/dist/chat/transcript/fold.js +53 -22
  97. package/dist/chat/transcript/script-input.d.ts +1 -1
  98. package/dist/chat/transcript/shell-block.js +7 -3
  99. package/dist/chat/transcript/useStickToBottom.js +12 -0
  100. package/dist/components/BrowserSignIn.js +23 -21
  101. package/dist/components/Form.d.ts +6 -4
  102. package/dist/components/Form.js +16 -8
  103. package/dist/components/LoadError.d.ts +4 -2
  104. package/dist/components/LoadError.js +13 -9
  105. package/dist/components/Notice.d.ts +29 -0
  106. package/dist/components/Notice.js +63 -0
  107. package/dist/components/PanelEmpty.d.ts +1 -1
  108. package/dist/components/PanelEmpty.js +4 -2
  109. package/dist/components/Restricted.d.ts +1 -1
  110. package/dist/components/palette/PaletteList.js +8 -1
  111. package/dist/components/palette/PalettePanel.js +14 -6
  112. package/dist/core.css +24 -5
  113. package/dist/dist/{index-Bq87OcGy.d.ts → index-BZM8tu4L.d.ts} +28 -3
  114. package/dist/dist/index.d.ts +2 -2
  115. package/dist/dist/{timeout-B5pO5I5a.d.ts → timeout-Cyx3VGPz.d.ts} +1 -1
  116. package/dist/extensions/ExtensionSettingsPage.js +1 -4
  117. package/dist/extensions/ExtensionSettingsSection.js +4 -3
  118. package/dist/extensions/ExtensionSettingsSidebar.js +2 -6
  119. package/dist/extensions/SettingsWireForm.d.ts +1 -7
  120. package/dist/extensions/SettingsWireForm.js +7 -5
  121. package/dist/extensions/headless/fixture-host.d.ts +1 -5
  122. package/dist/extensions/headless/fixture-host.js +1 -4
  123. package/dist/extensions/headless/host.d.ts +1 -11
  124. package/dist/extensions/headless/index.d.ts +3 -3
  125. package/dist/extensions/headless/index.js +2 -2
  126. package/dist/extensions/headless/select.d.ts +1 -11
  127. package/dist/extensions/headless/select.js +1 -18
  128. package/dist/files/EditorColumn.js +12 -1
  129. package/dist/files/TreeColumn.js +13 -20
  130. package/dist/files/useOpenFiles.js +2 -0
  131. package/dist/git/BranchMenu.js +5 -3
  132. package/dist/git/ImportRepoDialog.js +18 -9
  133. package/dist/git/MoveSessionDialog.js +15 -7
  134. package/dist/git/RemoteFolderPicker.js +34 -16
  135. package/dist/git/SyncChip.js +17 -17
  136. package/dist/git/WherePicker.d.ts +16 -1
  137. package/dist/git/WherePicker.js +80 -36
  138. package/dist/git/headless/environment.d.ts +33 -3
  139. package/dist/git/headless/environment.js +33 -5
  140. package/dist/git/headless/index.d.ts +2 -2
  141. package/dist/git/headless/index.js +2 -2
  142. package/dist/git/headless/labels.d.ts +15 -2
  143. package/dist/git/headless/labels.js +17 -4
  144. package/dist/git/useEnvironmentChoices.d.ts +3 -1
  145. package/dist/git/useEnvironmentChoices.js +6 -3
  146. package/dist/index.d.ts +2 -1
  147. package/dist/index.js +2 -1
  148. package/dist/labels.d.ts +5 -0
  149. package/dist/labels.js +5 -0
  150. package/dist/machines/AddMachineDialog.d.ts +34 -0
  151. package/dist/machines/AddMachineDialog.js +464 -0
  152. package/dist/machines/Banners.d.ts +33 -4
  153. package/dist/machines/Banners.js +64 -3
  154. package/dist/machines/DaemonMenu.js +27 -4
  155. package/dist/machines/HostCapabilities.d.ts +1 -3
  156. package/dist/machines/HostCapabilities.js +24 -45
  157. package/dist/machines/HostSyncPanel.js +123 -129
  158. package/dist/machines/HostsSection.d.ts +4 -1
  159. package/dist/machines/HostsSection.js +30 -7
  160. package/dist/machines/MachinesExplainer.d.ts +17 -0
  161. package/dist/machines/MachinesExplainer.js +71 -0
  162. package/dist/machines/MachinesProvider.d.ts +14 -2
  163. package/dist/machines/MachinesProvider.js +35 -1
  164. package/dist/machines/ServerAddedCard.d.ts +31 -0
  165. package/dist/machines/ServerAddedCard.js +72 -0
  166. package/dist/machines/ServerCard.js +91 -215
  167. package/dist/machines/ServerMachinesPanel.d.ts +2 -2
  168. package/dist/machines/ServerMachinesPanel.js +184 -323
  169. package/dist/machines/ServerUpdatePanel.js +51 -40
  170. package/dist/machines/ShareThisComputerForm.d.ts +19 -0
  171. package/dist/machines/ShareThisComputerForm.js +133 -0
  172. package/dist/machines/TokensPanel.d.ts +5 -3
  173. package/dist/machines/TokensPanel.js +98 -78
  174. package/dist/machines/headless/fixture-host.d.ts +19 -3
  175. package/dist/machines/headless/fixture-host.js +42 -5
  176. package/dist/machines/headless/fixtures.js +4 -6
  177. package/dist/machines/headless/host.d.ts +40 -19
  178. package/dist/machines/headless/index.d.ts +3 -3
  179. package/dist/machines/headless/index.js +2 -2
  180. package/dist/machines/headless/labels.d.ts +63 -20
  181. package/dist/machines/headless/labels.js +88 -25
  182. package/dist/machines/headless/messages.js +8 -0
  183. package/dist/machines/headless/stores.d.ts +9 -2
  184. package/dist/machines/headless/stores.js +28 -1
  185. package/dist/machines/index.d.ts +7 -3
  186. package/dist/machines/index.js +8 -4
  187. package/dist/machines/testing/contract.d.ts +15 -3
  188. package/dist/machines/testing/contract.js +68 -14
  189. package/dist/motion/grow.d.ts +8 -1
  190. package/dist/motion/grow.js +10 -4
  191. package/dist/onboarding/demos/index.js +1 -1
  192. package/dist/onboarding/headless/labels.d.ts +13 -0
  193. package/dist/onboarding/headless/labels.js +8 -0
  194. package/dist/onboarding/index.js +3 -3
  195. package/dist/onboarding/sources/SourceBrowser.js +11 -7
  196. package/dist/onboarding/steps/ConnectorsStep.js +1 -1
  197. package/dist/onboarding/steps/ImportStep.js +4 -1
  198. package/dist/onboarding/steps/ReadyStep.js +9 -2
  199. package/dist/onboarding/steps/SkillsStep.js +1 -1
  200. package/dist/onboarding/steps/connect/KeyForm.js +6 -2
  201. package/dist/onboarding/steps/connect/ProviderPanel.js +6 -2
  202. package/dist/onboarding/steps/connect/ProviderReady.js +25 -20
  203. package/dist/onboarding/steps/tasks.js +17 -14
  204. package/dist/server/sse-handler.js +141 -19
  205. package/dist/session/ArtifactsPanel.js +39 -17
  206. package/dist/session/PlanTracker.js +12 -7
  207. package/dist/session/ProjectHome.js +13 -11
  208. package/dist/session/RemindersPanel.js +34 -16
  209. package/dist/session/RunningWorkDialog.js +6 -2
  210. package/dist/session/SecretsPanel.js +29 -10
  211. package/dist/session/SessionDetailsDialog.d.ts +1 -1
  212. package/dist/session/SessionDetailsDialog.js +18 -10
  213. package/dist/session/SideChat.js +10 -7
  214. package/dist/session/TurnDetailsDialog.js +19 -5
  215. package/dist/session/UsagePanel.js +10 -4
  216. package/dist/session/headless/host.d.ts +2 -0
  217. package/dist/session/headless/labels.d.ts +19 -1
  218. package/dist/session/headless/labels.js +15 -1
  219. package/dist/session/headless/queue.js +2 -1
  220. package/dist/session/headless/reminder-labels.d.ts +4 -0
  221. package/dist/session/headless/reminder-labels.js +4 -0
  222. package/dist/settings/SettingsRestricted.d.ts +1 -1
  223. package/dist/settings/SettingsRestricted.js +4 -4
  224. package/dist/settings/SettingsShell.d.ts +7 -0
  225. package/dist/settings/SettingsShell.js +6 -1
  226. package/dist/settings/headless/fixture-performance.d.ts +1 -1
  227. package/dist/settings/headless/host.d.ts +2 -2
  228. package/dist/settings/headless/labels.d.ts +3 -3
  229. package/dist/settings/headless/labels.js +3 -3
  230. package/dist/settings/headless/performance.d.ts +3 -4
  231. package/dist/settings/headless/search.d.ts +1 -1
  232. package/dist/settings/index.d.ts +2 -1
  233. package/dist/settings/index.js +2 -1
  234. package/dist/settings/sections/editor/EditorSection.js +7 -4
  235. package/dist/settings/sections/editor/labels.d.ts +1 -0
  236. package/dist/settings/sections/editor/labels.js +1 -0
  237. package/dist/settings/sections/environments/EnvironmentsSection.js +19 -12
  238. package/dist/settings/sections/environments/labels.d.ts +1 -0
  239. package/dist/settings/sections/environments/labels.js +2 -1
  240. package/dist/settings/sections/extensions/ExtensionConfigRows.d.ts +1 -3
  241. package/dist/settings/sections/extensions/ExtensionConfigRows.js +20 -19
  242. package/dist/settings/sections/extensions/ExtensionOptionsSection.js +2 -1
  243. package/dist/settings/sections/extensions/options-labels.d.ts +2 -1
  244. package/dist/settings/sections/extensions/options-labels.js +2 -1
  245. package/dist/settings/sections/index.d.ts +2 -1
  246. package/dist/settings/sections/index.js +2 -1
  247. package/dist/settings/sections/logs/LogsSection.d.ts +2 -2
  248. package/dist/settings/sections/logs/LogsSection.js +2 -2
  249. package/dist/settings/sections/mcp/McpSection.d.ts +1 -1
  250. package/dist/settings/sections/mcp/McpSection.js +12 -6
  251. package/dist/settings/sections/mcp/McpServerRow.js +20 -13
  252. package/dist/settings/sections/mcp/labels.d.ts +8 -2
  253. package/dist/settings/sections/mcp/labels.js +8 -2
  254. package/dist/settings/sections/models/ModelRows.js +1 -1
  255. package/dist/settings/sections/models/NewChatPlaceRow.d.ts +26 -0
  256. package/dist/settings/sections/models/NewChatPlaceRow.js +78 -0
  257. package/dist/settings/sections/models/SpacesDefaultsSection.js +15 -3
  258. package/dist/settings/sections/models/labels.d.ts +7 -0
  259. package/dist/settings/sections/models/labels.js +7 -0
  260. package/dist/settings/sections/models/model-test.js +7 -4
  261. package/dist/settings/sections/performance/PerformanceSection.js +16 -6
  262. package/dist/settings/sections/performance/labels.d.ts +1 -1
  263. package/dist/settings/sections/performance/labels.js +1 -1
  264. package/dist/settings/sections/providers/ProvidersSection.d.ts +1 -1
  265. package/dist/settings/sections/providers/ProvidersSection.js +14 -7
  266. package/dist/settings/sections/providers/ServerProvidersSection.d.ts +1 -1
  267. package/dist/settings/sections/providers/ServerProvidersSection.js +11 -5
  268. package/dist/settings/sections/providers/labels.d.ts +2 -2
  269. package/dist/settings/sections/providers/labels.js +2 -2
  270. package/dist/settings/sections/skills/SkillList.js +1 -1
  271. package/dist/settings/sections/skills/SkillsSection.js +1 -1
  272. package/dist/settings/testing/performance.contract.js +8 -12
  273. package/dist/styles.css +32 -3
  274. package/dist/terminal/HostTerminalSurface.js +15 -5
  275. package/dist/terminal/TerminalPanel.js +30 -17
  276. package/dist/terminal/TerminalSurface.js +11 -4
  277. package/dist/terminal/headless/labels.d.ts +5 -0
  278. package/dist/terminal/headless/labels.js +5 -0
  279. package/dist/terminal/headless/store.d.ts +1 -1
  280. package/dist/terminal/headless/store.js +6 -3
  281. package/dist/workspace/LayoutBudget.d.ts +5 -1
  282. package/dist/workspace/LayoutBudget.js +14 -1
  283. package/dist/workspace/PanelContentView.d.ts +1 -1
  284. package/dist/workspace/PanelContentView.js +17 -6
  285. package/dist/workspace/WorkspaceProvider.js +3 -2
  286. package/dist/workspace/headless/labels.d.ts +1 -0
  287. package/dist/workspace/headless/labels.js +1 -0
  288. package/package.json +3 -3
  289. package/src/styles/motion.css +8 -0
  290. package/src/styles/primitives.css +7 -0
@@ -1,10 +1,19 @@
1
1
  import { ChatAttachment, ChatEvent } from "../host.js";
2
- import { FrameScheduler } from "./scheduler.js";
3
2
  import { OtherStreamSignal, SessionFallbackModel, SessionPageState, SessionRetryState, SessionStreamPage, SessionStreamSignal } from "./types.js";
4
3
  import { DrainPlan } from "./pacer.js";
5
- import { MarkdownDeltaOptions, PromptSegmentRef } from "zidane/chat/pure";
4
+ import { FrameScheduler } from "./scheduler.js";
5
+ import { HistoryChange, HistorySince, MarkdownDeltaOptions, PromptSegmentRef } from "zidane/chat/pure";
6
6
  import { SystemMdFile } from "zidane/chat";
7
7
  //#region src/chat/headless/streams/store.d.ts
8
+ /** A prompt this client appended optimistically, awaiting its host echo (`SessionStreamStore.pendingEchoes`). */
9
+ interface PendingEcho {
10
+ /** The prompt text. */
11
+ text: string;
12
+ /** The id the send gave the message, when it gave one. */
13
+ clientMessageId?: string;
14
+ /** The row the client appended. The echo gives it its turn id. */
15
+ event: ChatEvent;
16
+ }
8
17
  /** Options for {@link SessionStreamStore}. */
9
18
  interface SessionStreamStoreOptions {
10
19
  /** Frames and timers for batched notifications. Default: {@link defaultFrameScheduler}. */
@@ -86,15 +95,17 @@ declare class SessionStreamStore<K extends string = string> {
86
95
  private _runSeq;
87
96
  private _pages;
88
97
  /**
89
- * Texts of user prompts THIS window appended optimistically that still
90
- * await their host echo. The host stamps `echo: true` on the broadcast
91
- * of the sender's own prompt (send / steer paths) for EVERY peer — it
92
- * cannot know which window originated the send — so the dedupe lives
93
- * here: one pending entry consumes one echo (keeping the local copy,
94
- * which carries refs + attachments the canonical event doesn't).
98
+ * User prompts THIS window appended optimistically that still await their
99
+ * host echo. The host stamps `echo: true` on the broadcast of the sender's
100
+ * own prompt (send / steer paths) for EVERY peer. It cannot know which
101
+ * window sent the prompt, so the dedupe lives here. One pending entry
102
+ * consumes one echo and keeps the local copy, which carries refs and
103
+ * attachments that the canonical event does not.
95
104
  * Echo-tagged prompts with NO pending match are genuine remote sends
96
105
  * (another window, a daemon-drained queued prompt) and must render.
97
- * Leftovers (failed sends) are cleared at `run:end`.
106
+ * The echo matches by the sender's message id when both carry one, else
107
+ * by text, and gives the local row its turn id. Leftovers (failed sends)
108
+ * are cleared at `run:end`.
98
109
  */
99
110
  private _pendingEcho;
100
111
  /**
@@ -102,6 +113,39 @@ declare class SessionStreamStore<K extends string = string> {
102
113
  * the prompt shows up in the transcript (see `prompt-previews.ts`).
103
114
  */
104
115
  private _promptPreviews;
116
+ /** The history position each window applied last (`applyHistory`). It is the window's bookmark in the session's history. */
117
+ private _historyPos;
118
+ /** The numbering of each window's `_historyPos` (`HistoryPosition.historyId`), when known. */
119
+ private _historyId;
120
+ /** Windows to fetch again when their run ends (`takeRefetchDue`, `markRefetchDue`). */
121
+ private _refetchDue;
122
+ /**
123
+ * Windows whose rows are behind their history position. A write asked for a
124
+ * tail read that has not landed yet (in flight, failed, or waiting for the
125
+ * run's end). The position stays the newest write seen, so a read older than
126
+ * it is stale. But it is not a bookmark. The reconnect ladder reads the tail,
127
+ * and a later write also reads the tail instead of applying in place.
128
+ */
129
+ private _tailDue;
130
+ /** Per window, the numberings it left for another numbering. A read in one of them is older than the window. */
131
+ private _retiredHistoryIds;
132
+ /**
133
+ * Windows that saw their current run start (`run:start`, live or replayed).
134
+ * If a run ends in a hydrated window that never saw it start, the window
135
+ * missed the run's first rows. This happens after a drop that main could not
136
+ * replay, or when the window opened mid-run. The rows it read meanwhile also
137
+ * sit below the rows it streamed since. So it reads its tail at the run's
138
+ * end (`takeRefetchDue`).
139
+ */
140
+ private _runStarted;
141
+ /**
142
+ * Windows that streamed rows since their last run boundary (a run's start or
143
+ * end, a page read). With `_running`, it tells a run whose start went by
144
+ * apart from a send that the host refused before it started. A refused send
145
+ * streams nothing, and its error row lives only in this store. Reading the
146
+ * tail drops that row.
147
+ */
148
+ private _runActivity;
105
149
  private _listenersBySession;
106
150
  private _listenersForHas;
107
151
  /**
@@ -194,14 +238,98 @@ declare class SessionStreamStore<K extends string = string> {
194
238
  */
195
239
  getPageSnapshot(sessionId: K | null): SessionPageState;
196
240
  /**
197
- * Hydrate one replay page as the session's full window — the
198
- * `loadEvents` (tail page) path. One notify covers both the events
199
- * swap and the page-state swap.
241
+ * Hydrate one replay page as the session's full window (the
242
+ * `loadEvents` tail page path). One notify covers both the events
243
+ * swap and the page-state swap. Returns `false` and changes nothing
244
+ * when the page is older than a write the window applied since.
200
245
  *
201
246
  * @param sessionId - The session.
202
247
  * @param page - The persisted page.
203
248
  */
204
- setEventsPage(sessionId: K, page: SessionStreamPage): void;
249
+ setEventsPage(sessionId: K, page: SessionStreamPage): boolean;
250
+ /**
251
+ * Applies one history write (`history:changed`) to the session's window.
252
+ * It uses the shared rule (`applyHistoryOp`, `zidane/chat/pure`). A
253
+ * streamed append changes nothing. An append that never streamed adds the
254
+ * rows it carries. A rewrite or a missed write asks for a fetch.
255
+ *
256
+ * Returns `true` when the caller must fetch the session's tail now and
257
+ * replace the window with it (`setEventsPage`). A window whose run streams
258
+ * fetches at the run's end instead (`takeRefetchDue`), and a window never
259
+ * hydrated is left to its first read.
260
+ *
261
+ * @param sessionId - The session.
262
+ * @param change - The write, as the signal carries it.
263
+ */
264
+ applyHistory(sessionId: K, change: HistoryChange): boolean;
265
+ /**
266
+ * Applies a shared history rule's answer to the window. Its position moves
267
+ * first. Then its rows change, or it asks for a tail read. It returns `true`
268
+ * for a read now. While the run streams, the read waits for the run's end.
269
+ * A window whose rows are behind (`_tailDue`) reads its tail on any write
270
+ * that moves it. It does not apply the write to rows that miss the earlier one.
271
+ */
272
+ private _applyHistoryResult;
273
+ /**
274
+ * Applies the reconnect ladder's second step to the session's window. That
275
+ * step brings the rows of the turns appended after its position
276
+ * (`sessions.historySince`, the shared `applyHistorySince`). Returns `true`
277
+ * when the caller must fetch the tail now (as {@link applyHistory} does).
278
+ *
279
+ * @param sessionId - The session.
280
+ * @param since - The rows and the position they bring the window to.
281
+ */
282
+ applyHistorySince(sessionId: K, since: HistorySince<ChatEvent>): boolean;
283
+ /**
284
+ * Moves the window to `pos` after an adapter's own hydrate replaced it with
285
+ * a tail read at `pos`. Returns `stale` if the read is older than a write
286
+ * the window applied since. The adapter then reads it again.
287
+ *
288
+ * @param sessionId - The session.
289
+ * @param pos - The read's position, when the host named one.
290
+ * @param historyId - The numbering `pos` counts in, when the host named one.
291
+ */
292
+ adoptHistoryPos(sessionId: K, pos: number | undefined, historyId?: string): 'fresh' | 'stale';
293
+ /** `readFreshness` against what the window applied, and the numberings it left. */
294
+ private _freshness;
295
+ /** What the window applied last, for the shared history rules. */
296
+ private _historyContext;
297
+ /** Sets the window at `pos` of numbering `historyId`. If the numbering is unknown, none is kept. */
298
+ private _setHistoryPos;
299
+ /**
300
+ * Whether the session's window must be fetched again now that its run ended
301
+ * (see `applyHistory`, `markRefetchDue`). Clears the flag.
302
+ *
303
+ * @param sessionId - The session.
304
+ */
305
+ takeRefetchDue(sessionId: K): boolean;
306
+ /**
307
+ * Asks for the session's window to be read again at its run's end (`takeRefetchDue`). It is for a read dropped
308
+ * because a run streamed when it came back, or for a read that kept coming back older than the window.
309
+ *
310
+ * @param sessionId - The session.
311
+ */
312
+ markRefetchDue(sessionId: K): void;
313
+ /**
314
+ * Whether the session's rows are behind its history position. This is so
315
+ * when a write asked for a tail read that has not landed (in flight, failed,
316
+ * or waiting for the run's end). The reconnect ladder then reads the tail.
317
+ *
318
+ * @param sessionId - The session.
319
+ */
320
+ isTailDue(sessionId: K): boolean;
321
+ /**
322
+ * The history position the session's window applied last. It is `undefined` before its first `history:changed` or positioned page.
323
+ *
324
+ * @param sessionId - The session.
325
+ */
326
+ getHistoryPosSnapshot(sessionId: K): number | undefined;
327
+ /**
328
+ * The numbering of {@link getHistoryPosSnapshot}'s position, when known.
329
+ *
330
+ * @param sessionId - The session.
331
+ */
332
+ getHistoryIdSnapshot(sessionId: K): string | undefined;
205
333
  /**
206
334
  * Splice an OLDER page in front of the hydrated window (lazy scrollback).
207
335
  *
@@ -306,8 +434,9 @@ declare class SessionStreamStore<K extends string = string> {
306
434
  * @param text - The prompt text.
307
435
  * @param refs - The completions the prompt used (skills, files), for its chips.
308
436
  * @param rawAttachments - The prompt's attachments. Omitted for a pushed queued prompt, which takes the previews this client remembered for it.
437
+ * @param clientMessageId - The id the send gave the message (`SendOptions.clientMessageId`). The store matches the echo by it.
309
438
  */
310
- appendUserPrompt(sessionId: K, text: string, refs?: readonly PromptSegmentRef[], rawAttachments?: readonly ChatAttachment[]): void;
439
+ appendUserPrompt(sessionId: K, text: string, refs?: readonly PromptSegmentRef[], rawAttachments?: readonly ChatAttachment[], clientMessageId?: string): void;
311
440
  /**
312
441
  * Unwind ONE pending echo after a FAILED send — a refused/errored send
313
442
  * produces no run, so the `run:end` sweep never fires and the stale
@@ -324,7 +453,7 @@ declare class SessionStreamStore<K extends string = string> {
324
453
  *
325
454
  * @param sessionId - The session.
326
455
  */
327
- pendingEchoes(sessionId: K): string[];
456
+ pendingEchoes(sessionId: K): PendingEcho[];
328
457
  /**
329
458
  * Low-level write: sets any of a session's events, run flag and page state
330
459
  * in one notification, with none of the signal rules (no finalize, no
@@ -366,6 +495,23 @@ declare class SessionStreamStore<K extends string = string> {
366
495
  private _notifySoon;
367
496
  /** Deliver notifications `_notifySoon` held back (also called before anything that must be immediate). */
368
497
  flushNotifications(): void;
498
+ /**
499
+ * Returns `live` without the prompts that this client appended and that the
500
+ * page already holds. These prompts still await their echo. They match by the
501
+ * send's message id, which the saved prompt carries (`origin.messageId`).
502
+ * Their pending entries stay, so the echo is still consumed. It binds
503
+ * nothing, because the row is gone.
504
+ */
505
+ private _withoutSavedLocalPrompts;
506
+ /**
507
+ * Puts the host's exchange separator before the oldest prompt that this
508
+ * client appended and whose echo has not come yet (`appendUserPrompt`).
509
+ * Returns false when no such prompt is on show. The separator then appends
510
+ * like any event.
511
+ */
512
+ private _separateLocalPrompt;
513
+ /** Gives this client's optimistic prompt row the turn id its echo carries. A row that a reload replaced is left alone. */
514
+ private _bindLocalPrompt;
369
515
  /** Drop a stalled attempt's reasoning lane: the retry (or next model) streams its own, and the saved turn never holds it. */
370
516
  private _discardThinking;
371
517
  /**
@@ -382,4 +528,4 @@ declare class SessionStreamStore<K extends string = string> {
382
528
  private _notifyHas;
383
529
  }
384
530
  //#endregion
385
- export { SessionStreamStore, SessionStreamStoreOptions, SessionStreamWrite };
531
+ export { PendingEcho, SessionStreamStore, SessionStreamStoreOptions, SessionStreamWrite };