zidane-ui 9.3.1 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/dist/adapters/live.d.ts +2 -0
  2. package/dist/adapters/live.js +3 -0
  3. package/dist/adapters/server-git-host.js +5 -2
  4. package/dist/adapters/server-host.js +17 -11
  5. package/dist/adapters/server-machines-host.js +7 -0
  6. package/dist/adapters/server-session-host.js +49 -0
  7. package/dist/adapters/server-settings-sections.js +4 -1
  8. package/dist/adapters/sse-host.js +3 -0
  9. package/dist/adapters/sse-protocol.d.ts +10 -0
  10. package/dist/appearance/ZoomIndicator.js +5 -8
  11. package/dist/chat/HostTranscript.js +15 -1
  12. package/dist/chat/SessionStreamsProvider.d.ts +1 -1
  13. package/dist/chat/Transcript.d.ts +3 -2
  14. package/dist/chat/Transcript.js +26 -7
  15. package/dist/chat/composer/ComposerEditor.js +1 -1
  16. package/dist/chat/composer/ModelOptionsPicker.js +6 -2
  17. package/dist/chat/composer/ModelPicker.d.ts +1 -1
  18. package/dist/chat/composer/PlacePicker.d.ts +3 -1
  19. package/dist/chat/composer/PlacePicker.js +5 -1
  20. package/dist/chat/composer/use-draft-target.js +15 -3
  21. package/dist/chat/headless/block-runs.js +26 -1
  22. package/dist/chat/headless/chip-views.js +1 -1
  23. package/dist/chat/headless/draft-target.d.ts +28 -1
  24. package/dist/chat/headless/draft-target.js +22 -1
  25. package/dist/chat/headless/hosts.d.ts +4 -0
  26. package/dist/chat/headless/index.d.ts +25 -25
  27. package/dist/chat/headless/index.js +6 -6
  28. package/dist/chat/headless/markdown-scan.d.ts +0 -2
  29. package/dist/chat/headless/markdown-scan.js +3 -8
  30. package/dist/chat/headless/markdown-stream.js +3 -3
  31. package/dist/chat/headless/prompt-origin.d.ts +2 -0
  32. package/dist/chat/headless/prompt-origin.js +6 -2
  33. package/dist/chat/headless/sidebar/directory.d.ts +10 -1
  34. package/dist/chat/headless/sidebar/directory.js +9 -1
  35. package/dist/chat/headless/sidebar/environment.d.ts +15 -4
  36. package/dist/chat/headless/sidebar/environment.js +27 -9
  37. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  38. package/dist/chat/headless/sidebar/index.js +2 -2
  39. package/dist/chat/headless/sidebar/labels.d.ts +9 -2
  40. package/dist/chat/headless/sidebar/labels.js +8 -1
  41. package/dist/chat/headless/streams/actions.d.ts +2 -2
  42. package/dist/chat/headless/streams/actions.js +1 -1
  43. package/dist/chat/headless/streams/event-bytes.d.ts +12 -1
  44. package/dist/chat/headless/streams/event-bytes.js +13 -1
  45. package/dist/chat/headless/streams/store.d.ts +21 -5
  46. package/dist/chat/headless/streams/store.js +36 -7
  47. package/dist/chat/headless/streams/transcript-map.js +2 -5
  48. package/dist/chat/headless/streams/types.d.ts +2 -1
  49. package/dist/chat/headless/transcript/collapse.js +3 -0
  50. package/dist/chat/index.d.ts +2 -2
  51. package/dist/chat/index.js +2 -2
  52. package/dist/chat/sidebar/ProjectIcon.js +1 -1
  53. package/dist/chat/sidebar/RowChips.js +2 -2
  54. package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
  55. package/dist/chat/sidebar/SessionSidebar.js +23 -16
  56. package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
  57. package/dist/chat/sidebar/SidebarFold.js +17 -16
  58. package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
  59. package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
  60. package/dist/chat/sidebar/session-menu.d.ts +4 -0
  61. package/dist/chat/sidebar/session-menu.js +14 -2
  62. package/dist/chat/sidebar/sidebar-live.js +28 -4
  63. package/dist/chat/sidebar/useInboxRows.js +6 -6
  64. package/dist/chat/sidebar/useInboxTriage.js +50 -47
  65. package/dist/chat/sidebar/useSessionSearch.js +19 -18
  66. package/dist/chat/transcript/FileChip.js +28 -0
  67. package/dist/chat/transcript/LazyRow.d.ts +1 -1
  68. package/dist/chat/transcript/LazyRow.js +3 -4
  69. package/dist/chat/transcript/PromptEcho.js +3 -11
  70. package/dist/chat/transcript/SessionChip.d.ts +11 -0
  71. package/dist/chat/transcript/SessionChip.js +34 -0
  72. package/dist/chat/transcript/TranscriptRail.d.ts +1 -1
  73. package/dist/chat/transcript/chip-details.d.ts +11 -0
  74. package/dist/chat/transcript/chip-details.js +17 -1
  75. package/dist/chat/transcript/fold-worker.js +2 -1
  76. package/dist/chat/transcript/fold.js +11 -3
  77. package/dist/chat/transcript/index.d.ts +2 -2
  78. package/dist/chat/transcript/index.js +2 -2
  79. package/dist/chat/transcript/markdown-cache.d.ts +10 -1
  80. package/dist/chat/transcript/markdown-cache.js +37 -4
  81. package/dist/chat/transcript/markdown.js +27 -34
  82. package/dist/chat/transcript/media-gallery.js +13 -16
  83. package/dist/chat/transcript/messages.js +5 -4
  84. package/dist/chat/transcript/prompt.d.ts +1 -1
  85. package/dist/chat/transcript/row-mount.d.ts +27 -8
  86. package/dist/chat/transcript/row-mount.js +114 -80
  87. package/dist/chat/transcript/row-parking.d.ts +27 -0
  88. package/dist/chat/transcript/row-parking.js +37 -1
  89. package/dist/chat/transcript/script-input.d.ts +1 -1
  90. package/dist/chat/transcript/tool-parts.js +0 -1
  91. package/dist/chat/transcript/use-transcript-rows.d.ts +1 -1
  92. package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
  93. package/dist/chat/transcript/useHistoryBackfill.js +170 -0
  94. package/dist/chat/transcript/useTranscriptFind.js +2 -4
  95. package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
  96. package/dist/chat/transcript/useTranscriptScroll.js +12 -1
  97. package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
  98. package/dist/chat/transcript/useTranscriptSearch.js +6 -6
  99. package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
  100. package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
  101. package/dist/code/editor/FileTree.d.ts +2 -0
  102. package/dist/code/editor/FileTree.js +1 -1
  103. package/dist/code/editor/FileView.js +16 -25
  104. package/dist/code/editor/find/useFind.js +17 -17
  105. package/dist/code/editor/useCodeDocument.js +22 -19
  106. package/dist/code/editor/useDetachCleanup.js +4 -3
  107. package/dist/code/use-highlighted-html.js +12 -13
  108. package/dist/components/IconButton.d.ts +3 -1
  109. package/dist/components/IconButton.js +7 -2
  110. package/dist/components/IconButtonTip.d.ts +3 -1
  111. package/dist/components/IconButtonTip.js +2 -1
  112. package/dist/components/RowActionsMenu.js +7 -14
  113. package/dist/components/Tooltip.d.ts +4 -1
  114. package/dist/components/Tooltip.js +8 -6
  115. package/dist/components/assign-ref.d.ts +8 -0
  116. package/dist/components/assign-ref.js +12 -0
  117. package/dist/components/floating/FloatingSurface.js +2 -2
  118. package/dist/components/floating/HoverCard.js +32 -14
  119. package/dist/components/floating/Popover.js +4 -7
  120. package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
  121. package/dist/components/floating/useAnchoredPosition.js +7 -7
  122. package/dist/components/object-key.d.ts +7 -0
  123. package/dist/components/object-key.js +18 -0
  124. package/dist/components/palette/PaletteList.js +2 -7
  125. package/dist/components/tooltip-arming.d.ts +3 -0
  126. package/dist/components/tooltip-arming.js +8 -1
  127. package/dist/core.css +3 -3
  128. package/dist/dist/{index-C6-t1SS9.d.ts → index-BheVJOLc.d.ts} +1 -0
  129. package/dist/dist/index.d.ts +2 -2
  130. package/dist/files/FilesTab.js +0 -1
  131. package/dist/files/TreeColumn.d.ts +2 -4
  132. package/dist/files/TreeColumn.js +0 -5
  133. package/dist/files/headless/host.d.ts +3 -7
  134. package/dist/files/headless/labels.d.ts +0 -1
  135. package/dist/files/headless/labels.js +0 -1
  136. package/dist/files/headless/workspace-diff.js +1 -1
  137. package/dist/files/useCodeReview.js +1 -3
  138. package/dist/files/useFilesDiagnostics.d.ts +1 -1
  139. package/dist/files/useFilesDiagnostics.js +4 -11
  140. package/dist/files/useOpenFiles.js +9 -12
  141. package/dist/files/useWorkspace.d.ts +5 -7
  142. package/dist/files/useWorkspace.js +4 -15
  143. package/dist/git/GitBar.js +5 -3
  144. package/dist/git/MoveSessionDialog.d.ts +18 -8
  145. package/dist/git/MoveSessionDialog.js +32 -53
  146. package/dist/git/MoveToDialog.d.ts +61 -0
  147. package/dist/git/MoveToDialog.js +240 -0
  148. package/dist/git/SandboxManager.js +9 -4
  149. package/dist/git/SyncChip.js +11 -4
  150. package/dist/git/TeleportSessionDialog.d.ts +69 -0
  151. package/dist/git/TeleportSessionDialog.js +440 -0
  152. package/dist/git/headless/host.d.ts +14 -0
  153. package/dist/git/headless/index.d.ts +2 -1
  154. package/dist/git/headless/index.js +2 -1
  155. package/dist/git/headless/labels.d.ts +44 -1
  156. package/dist/git/headless/labels.js +50 -0
  157. package/dist/git/headless/sandboxes.d.ts +1 -1
  158. package/dist/git/headless/sandboxes.js +4 -3
  159. package/dist/git/headless/teleport.d.ts +76 -0
  160. package/dist/git/headless/teleport.js +19 -0
  161. package/dist/git/index.d.ts +4 -2
  162. package/dist/git/index.js +4 -2
  163. package/dist/git/useEnvironmentChoices.d.ts +5 -2
  164. package/dist/git/useEnvironmentChoices.js +12 -4
  165. package/dist/hooks/useLatest.d.ts +8 -0
  166. package/dist/hooks/useLatest.js +17 -0
  167. package/dist/hooks/useMinuteTick.d.ts +6 -2
  168. package/dist/hooks/useMinuteTick.js +12 -6
  169. package/dist/hooks/useNearViewport.js +11 -8
  170. package/dist/index.d.ts +3 -2
  171. package/dist/index.js +2 -1
  172. package/dist/keybindings/KeybindingsProvider.js +3 -4
  173. package/dist/keybindings/headless/catalog.d.ts +1 -1
  174. package/dist/keybindings/headless/catalog.js +18 -0
  175. package/dist/machines/AddServerForm.js +55 -3
  176. package/dist/machines/Banners.d.ts +2 -2
  177. package/dist/machines/Banners.js +3 -3
  178. package/dist/machines/DaemonMenu.js +1 -3
  179. package/dist/machines/HostsSection.js +5 -1
  180. package/dist/machines/OrganizationPanel.d.ts +25 -0
  181. package/dist/machines/OrganizationPanel.js +266 -0
  182. package/dist/machines/PersonalLayerPanel.d.ts +32 -0
  183. package/dist/machines/PersonalLayerPanel.js +360 -0
  184. package/dist/machines/headless/fixture-host.d.ts +10 -0
  185. package/dist/machines/headless/fixture-host.js +44 -0
  186. package/dist/machines/headless/host.d.ts +21 -1
  187. package/dist/machines/headless/index.d.ts +3 -1
  188. package/dist/machines/headless/index.js +3 -1
  189. package/dist/machines/headless/labels.d.ts +55 -0
  190. package/dist/machines/headless/labels.js +58 -1
  191. package/dist/machines/headless/layer.d.ts +64 -0
  192. package/dist/machines/headless/layer.js +56 -0
  193. package/dist/machines/headless/organization.d.ts +38 -0
  194. package/dist/machines/headless/organization.js +44 -0
  195. package/dist/machines/index.d.ts +3 -1
  196. package/dist/machines/index.js +3 -1
  197. package/dist/machines/testing/contract.d.ts +25 -1
  198. package/dist/machines/testing/contract.js +97 -1
  199. package/dist/motion/grow.js +12 -13
  200. package/dist/motion/swap.js +2 -5
  201. package/dist/motion/use-flip-list.d.ts +14 -0
  202. package/dist/motion/use-flip-list.js +17 -12
  203. package/dist/palette/headless/app-sources.js +37 -0
  204. package/dist/palette/headless/labels.js +3 -0
  205. package/dist/server/sse-handler.js +25 -2
  206. package/dist/session/DiffFileTree.js +1 -4
  207. package/dist/session/OpenSessionsDialog.d.ts +46 -0
  208. package/dist/session/OpenSessionsDialog.js +170 -0
  209. package/dist/session/PlanTracker.js +1 -2
  210. package/dist/session/ProjectHome.js +10 -9
  211. package/dist/session/RemindersPanel.js +10 -12
  212. package/dist/session/SecretsPanel.js +2 -1
  213. package/dist/session/SessionPeopleStack.d.ts +23 -0
  214. package/dist/session/SessionPeopleStack.js +65 -0
  215. package/dist/session/SessionPlaceMenu.js +5 -4
  216. package/dist/session/ShareSessionDialog.d.ts +32 -0
  217. package/dist/session/ShareSessionDialog.js +342 -0
  218. package/dist/session/TypingLine.d.ts +22 -0
  219. package/dist/session/TypingLine.js +31 -0
  220. package/dist/session/headless/host.d.ts +40 -1
  221. package/dist/session/headless/index.d.ts +4 -2
  222. package/dist/session/headless/index.js +3 -1
  223. package/dist/session/headless/labels.d.ts +49 -0
  224. package/dist/session/headless/labels.js +56 -0
  225. package/dist/session/headless/people.d.ts +29 -0
  226. package/dist/session/headless/people.js +53 -0
  227. package/dist/session/headless/place.d.ts +5 -0
  228. package/dist/session/headless/place.js +5 -1
  229. package/dist/session/headless/typing.d.ts +37 -0
  230. package/dist/session/headless/typing.js +60 -0
  231. package/dist/session/index.d.ts +5 -1
  232. package/dist/session/index.js +5 -1
  233. package/dist/settings/headless/search.d.ts +1 -1
  234. package/dist/settings/headless/sections-host.d.ts +7 -2
  235. package/dist/settings/section.d.ts +15 -3
  236. package/dist/settings/section.js +15 -3
  237. package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
  238. package/dist/settings/sections/keybindings/labels.d.ts +3 -0
  239. package/dist/settings/sections/keybindings/labels.js +3 -0
  240. package/dist/settings/sections/keybindings/rows.js +12 -0
  241. package/dist/settings/sections/logs/LogsSection.js +5 -8
  242. package/dist/styles.css +32 -7
  243. package/dist/terminal/HostTerminalSurface.js +28 -30
  244. package/dist/terminal/TerminalPanel.js +4 -12
  245. package/dist/terminal/TerminalProvider.d.ts +10 -2
  246. package/dist/terminal/TerminalProvider.js +10 -2
  247. package/dist/terminal/headless/labels.d.ts +0 -1
  248. package/dist/terminal/headless/labels.js +1 -2
  249. package/dist/terminal/headless/store.js +5 -1
  250. package/dist/workspace/LayoutBudget.js +1 -7
  251. package/package.json +2 -2
  252. package/src/styles/chat.css +3 -1
  253. package/src/styles/palette.css +3 -3
  254. package/src/styles/transcript.css +17 -3
  255. /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
@@ -69,6 +69,8 @@ export interface LiveState {
69
69
  tailDue: (sessionId: string) => boolean;
70
70
  /** A live event from the agent; `echo` marks the host repeating a prompt (dropped when this client echoed it). */
71
71
  apply: (sessionId: string, event: ChatEvent, echo?: boolean) => void;
72
+ /** The loop changed a turn's text after it streamed (`turn:end.text`): its streamed rows become the saved text blocks. `childId`: a subagent's turn. */
73
+ replaceTurnText: (sessionId: string, turnId: string, text: readonly string[], childId?: string) => void;
72
74
  /** Show the user's prompt at once (with its attachment previews); the host's echo of it is then dropped. */
73
75
  echoPrompt: (sessionId: string, text: string, attachments?: readonly ChatAttachment[]) => void;
74
76
  /** A run started or ended; the session's status follows (`status` overrides: `'error'`, `'idle'` after an interrupt). */
@@ -133,6 +133,9 @@ function createLiveState(options = {}) {
133
133
  ...echo ? { echo } : {}
134
134
  });
135
135
  },
136
+ replaceTurnText(sessionId, turnId, text, childId) {
137
+ store.replaceTurnText(sessionId, childId ?? "parent", turnId, text);
138
+ },
136
139
  echoPrompt(sessionId, text, attachments) {
137
140
  transcript(sessionId);
138
141
  store.appendUserPrompt(sessionId, text, void 0, attachments ?? []);
@@ -138,8 +138,11 @@ function createServerGitHost(options) {
138
138
  };
139
139
  }
140
140
  },
141
- async environments({ cwd }) {
142
- return client.call("environments.list", cwd ? { cwd } : {});
141
+ async environments({ cwd, machineOnly }) {
142
+ return client.call("environments.list", {
143
+ ...cwd ? { cwd } : {},
144
+ ...machineOnly ? { machineOnly: true } : {}
145
+ });
143
146
  },
144
147
  subscribeEnvironments(_query, onChange) {
145
148
  const offSignal = client.onSignal((signal) => {
@@ -129,6 +129,16 @@ function createServerHost(options) {
129
129
  const listChanges = createRecentChanges();
130
130
  /** Each session's folder, from its rows: a message's relative media path resolves against it. */
131
131
  const folders = /* @__PURE__ */ new Map();
132
+ const refresh = async () => {
133
+ const reading = listChanges.begin();
134
+ try {
135
+ const rows = await client.call("sessions.list", { archive: "all" });
136
+ for (const row of rows) folders.set(row.id, row.cwd ?? row.projectRoot ?? "");
137
+ state.sessions.set(listChanges.end(reading, rows.map(toChatSession), (list, session, id) => session ? withSession(list, session) : withoutSession(list, id)));
138
+ } finally {
139
+ listChanges.drop(reading);
140
+ }
141
+ };
132
142
  const changed = /* @__PURE__ */ new Set();
133
143
  const facetListeners = /* @__PURE__ */ new Set();
134
144
  const onSignal = (signal, meta) => {
@@ -140,7 +150,7 @@ function createServerHost(options) {
140
150
  });
141
151
  return;
142
152
  }
143
- if ((signal.kind === "event" || signal.kind === "run:start" || signal.kind === "run:end" || signal.kind === "history:changed") && hydrating.has(signal.sessionId)) {
153
+ if ((signal.kind === "event" || signal.kind === "run:start" || signal.kind === "run:end" || signal.kind === "turn:end" || signal.kind === "history:changed") && hydrating.has(signal.sessionId)) {
144
154
  hydrating.get(signal.sessionId).push({
145
155
  signal,
146
156
  ...meta ? { meta } : {}
@@ -160,6 +170,9 @@ function createServerHost(options) {
160
170
  if (state.takeRefetchDue(signal.sessionId) && watched.has(signal.sessionId)) reread(signal.sessionId);
161
171
  }
162
172
  return;
173
+ case "turn:end":
174
+ if (signal.text) state.replaceTurnText(signal.sessionId, signal.turnId, signal.text, signal.childId);
175
+ return;
163
176
  case "interaction:request":
164
177
  state.addInteraction(signal.sessionId, signal.request);
165
178
  return;
@@ -192,6 +205,9 @@ function createServerHost(options) {
192
205
  for (const listener of [...changed]) listener(change);
193
206
  return;
194
207
  }
208
+ case "members:changed":
209
+ refresh().catch(() => {});
210
+ return;
195
211
  case "history:changed": if (watched.has(signal.sessionId) && state.applyHistory(signal.sessionId, signal)) reread(signal.sessionId);
196
212
  }
197
213
  };
@@ -423,16 +439,6 @@ function createServerHost(options) {
423
439
  };
424
440
  /** Each session's transcript, one object per readable the state holds (readers memo on it; an evicted one goes with it). */
425
441
  const transcripts = /* @__PURE__ */ new WeakMap();
426
- const refresh = async () => {
427
- const reading = listChanges.begin();
428
- try {
429
- const rows = await client.call("sessions.list", { archive: "all" });
430
- for (const row of rows) folders.set(row.id, row.cwd ?? row.projectRoot ?? "");
431
- state.sessions.set(listChanges.end(reading, rows.map(toChatSession), (list, session, id) => session ? withSession(list, session) : withoutSession(list, id)));
432
- } finally {
433
- listChanges.drop(reading);
434
- }
435
- };
436
442
  /** A session's row from a change signal, in place (a new one first). */
437
443
  function upsertSession(session) {
438
444
  return state.sessions.set((all) => withSession(all, session));
@@ -1,4 +1,6 @@
1
1
  import { machinesError } from "../machines/headless/host.js";
2
+ import { serverLayerOver } from "../machines/headless/layer.js";
3
+ import { organizationStatusOf, serverOrganizationOver } from "../machines/headless/organization.js";
2
4
  import { createPresenceStore } from "../machines/headless/presence.js";
3
5
  import { createMachineLists, createOnlineMachines, lazyReadable } from "../machines/headless/stores.js";
4
6
  import { createHostSyncReads } from "../machines/headless/sync.js";
@@ -141,6 +143,11 @@ function createServerMachinesHost(options) {
141
143
  install: (_hostId) => guard("update", () => client.call("server.update.install", {})),
142
144
  configure: (_hostId, enabled) => guard("update", () => client.call("server.update.configure", { enabled }))
143
145
  },
146
+ organization: serverOrganizationOver(async () => organizationStatusOf(client.hello()), (_hostId, method, params) => client.call(method, params)),
147
+ layer: serverLayerOver(async (_hostId, method, params) => client.hello()?.identity ? {
148
+ signedIn: true,
149
+ result: await client.call(method, params)
150
+ } : { signedIn: false }),
144
151
  tokens: {
145
152
  list: (_hostId) => guard("tokens", () => client.call("tokens.list", {})),
146
153
  create: (_hostId, name) => guard("tokens", () => client.call("tokens.create", { name })),
@@ -1,9 +1,11 @@
1
1
  import { createArtifactsState, groupArtifactRows, plainArtifactRow } from "../session/headless/artifacts.js";
2
+ import { createSessionPeople } from "../session/headless/people.js";
2
3
  import { createPlansState } from "../session/headless/plans.js";
3
4
  import { createQueueState } from "../session/headless/queue.js";
4
5
  import { createRunningWorkState } from "../session/headless/running-work.js";
5
6
  import { createSchedulesState } from "../session/headless/schedules.js";
6
7
  import { createSecretsState } from "../session/headless/secrets.js";
8
+ import { createSessionTyping } from "../session/headless/typing.js";
7
9
  // src/adapters/server-session-host.ts
8
10
  /**
9
11
  * Creates a {@link SessionHost} over a zidane-server client.
@@ -27,6 +29,52 @@ function createServerSessionHost(options) {
27
29
  })
28
30
  });
29
31
  const work = createRunningWorkState((sessionId) => client.call("chat.listWork", { sessionId }));
32
+ const sharing = client.hello()?.identity && client.can("members.get") ? {
33
+ get: (sessionId) => client.call("members.get", { sessionId }),
34
+ invite: (sessionId, user, grant) => client.call("members.invite", {
35
+ sessionId,
36
+ user,
37
+ ...grant ? { grant } : {}
38
+ }),
39
+ setGrant: (sessionId, userId, grant) => client.call("members.setGrant", {
40
+ sessionId,
41
+ userId,
42
+ grant
43
+ }),
44
+ remove: (sessionId, userId) => client.call("members.remove", {
45
+ sessionId,
46
+ userId
47
+ }),
48
+ setOpen: (sessionId, open, defaultGrant) => client.call("members.setOpen", {
49
+ sessionId,
50
+ open,
51
+ ...defaultGrant ? { defaultGrant } : {}
52
+ }),
53
+ transfer: (sessionId, userId) => client.call("members.transfer", {
54
+ sessionId,
55
+ userId
56
+ }),
57
+ leave: (sessionId) => client.call("members.leave", { sessionId }),
58
+ users: () => client.call("members.users", {}),
59
+ directory: () => client.call("members.directory", {}),
60
+ join: (sessionId) => client.call("members.join", { sessionId }),
61
+ setNotify: (sessionId, notify) => client.call("members.setNotify", {
62
+ sessionId,
63
+ notify
64
+ }),
65
+ onChanged: (listener) => client.onSignal((signal) => {
66
+ if (signal.kind === "members:changed" || signal.kind === "members:directory") listener();
67
+ }),
68
+ people: createSessionPeople({
69
+ list: () => client.call("presence.list", {}),
70
+ onChanged: (listener) => client.onSignal((signal) => {
71
+ if (signal.kind === "presence:changed") listener(signal.sessions);
72
+ })
73
+ }),
74
+ typing: createSessionTyping((listener) => client.onSignal((signal) => {
75
+ if (signal.kind === "members:typing") listener(signal);
76
+ }))
77
+ } : void 0;
30
78
  const artifacts = createArtifactsState(async (sessionId) => groupArtifactRows((await client.call("sessions.artifacts", { sessionId })).map(plainArtifactRow)));
31
79
  const secrets = createSecretsState((sessionId) => client.call("secrets.list", { sessionId }));
32
80
  const schedules = client.can("schedules.status") ? createSchedulesState({
@@ -68,6 +116,7 @@ function createServerSessionHost(options) {
68
116
  }
69
117
  })];
70
118
  return {
119
+ ...sharing ? { sharing } : {},
71
120
  plans: {
72
121
  snapshot: plans.snapshot,
73
122
  refresh: plans.refresh,
@@ -123,7 +123,10 @@ function serverSettingsSections(client) {
123
123
  })
124
124
  } } : {},
125
125
  environments: {
126
- list: (cwd) => call("environments.list", cwd ? { cwd } : {}),
126
+ list: (cwd, options) => call("environments.list", {
127
+ ...cwd ? { cwd } : {},
128
+ ...options?.machineOnly ? { machineOnly: true } : {}
129
+ }),
127
130
  update: async (change) => {
128
131
  await call("environments.update", change);
129
132
  },
@@ -131,6 +131,9 @@ function createSseHost(options) {
131
131
  case "history":
132
132
  if (state.applyHistory(sessionId, record.data)) reread(sessionId);
133
133
  return true;
134
+ case "turn-text":
135
+ state.replaceTurnText(sessionId, record.data.turnId, record.data.text, record.data.childId);
136
+ return true;
134
137
  case "reset": return false;
135
138
  default: return true;
136
139
  }
@@ -27,6 +27,9 @@
27
27
  * transcript is at. `history` records (version 2) go only to a stream whose
28
28
  * request announces version 2 or later. A version 1 client gets only the
29
29
  * records it knows.
30
+ * A `turn-text` record says the loop changed a turn's text after it streamed
31
+ * (zidane's `turn:end.text`): the client's streamed rows of that turn become
32
+ * the saved text blocks, as a hydrate shows them.
30
33
  * A client ignores a record type it does not know (a later version's).
31
34
  * `seq` counts a session's records from 1 within one server process
32
35
  * (`epoch`). A client reconnecting with `Last-Event-ID` gets every record
@@ -100,6 +103,13 @@ export type StreamRecord = {
100
103
  } | {
101
104
  type: 'history';
102
105
  data: HistoryChange;
106
+ } | {
107
+ type: 'turn-text';
108
+ data: {
109
+ turnId: string;
110
+ childId?: string;
111
+ text: string[];
112
+ };
103
113
  } | {
104
114
  type: 'reset';
105
115
  data: Record<string, never>;
@@ -23,17 +23,14 @@ function ZoomIndicator({ durationMs = 3e3, avoid, className = "", style }) {
23
23
  const transition = useWithFade("pop");
24
24
  const [shown, setShown] = useState(false);
25
25
  const [hovered, setHovered] = useState(false);
26
- const last = useRef(scale);
27
26
  const box = useRef(null);
28
27
  const [lift, setLift] = useState(0);
29
- useEffect(() => {
30
- if (last.current === scale) return;
31
- last.current = scale;
28
+ const [seenScale, setSeenScale] = useState(scale);
29
+ if (seenScale !== scale) {
30
+ setSeenScale(scale);
32
31
  if (enabled) setShown(true);
33
- }, [scale, enabled]);
34
- useEffect(() => {
35
- if (!enabled) setShown(false);
36
- }, [enabled]);
32
+ }
33
+ if (!enabled && shown) setShown(false);
37
34
  useEffect(() => {
38
35
  if (!shown || hovered) return void 0;
39
36
  const id = setTimeout(setShown, durationMs, false);
@@ -2,9 +2,11 @@ import { Skeleton } from "../components/Skeleton.js";
2
2
  import { useSettingsHost } from "../settings/SettingsProvider.js";
3
3
  import { useChatHost } from "./ChatProvider.js";
4
4
  import { useReadable } from "./headless/store.js";
5
+ import { eventsBytes, transcriptBytes } from "./headless/streams/event-bytes.js";
5
6
  import { DEFAULT_TRANSCRIPT_OPTIONS, Transcript } from "./Transcript.js";
6
7
  import { TranscriptActionsProvider } from "./transcript/actions.js";
7
8
  import { useRailOutline } from "./transcript/TranscriptRail.js";
9
+ import { useHistoryBackfill } from "./transcript/useHistoryBackfill.js";
8
10
  import { useChatLabels } from "./useChatLabels.js";
9
11
  import { useMemo } from "react";
10
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -25,6 +27,18 @@ function HostTranscript({ sessionId, onOpenSession, onRunInTerminal, onOpenSetti
25
27
  const transcript = useMemo(() => host.transcript(sessionId), [host, sessionId]);
26
28
  const state = useReadable(transcript);
27
29
  useRailOutline(transcript, Boolean(state.hasEarlier));
30
+ const rows = state.transcript ?? state.events;
31
+ useHistoryBackfill(sessionId, {
32
+ ready: state.hydrated,
33
+ hasMore: Boolean(state.hasEarlier && transcript.loadEarlier),
34
+ loading: Boolean(state.loadingEarlier),
35
+ loaded: rows.length,
36
+ load: () => transcript.loadEarlier?.(),
37
+ bytes: () => {
38
+ const { transcript: held, events } = transcript.get();
39
+ return held ? transcriptBytes(held) : eventsBytes(events);
40
+ }
41
+ });
28
42
  const actions = useMemo(() => ({
29
43
  sessionId,
30
44
  ...host.toolOutput ? { toolOutput: (callId) => host.toolOutput(sessionId, callId) } : {},
@@ -122,7 +136,7 @@ function HostTranscript({ sessionId, onOpenSession, onRunInTerminal, onOpenSetti
122
136
  })
123
137
  }), /* @__PURE__ */ jsx(Transcript, {
124
138
  ...props,
125
- events: state.transcript ?? state.events,
139
+ events: rows,
126
140
  streaming: state.running,
127
141
  sessionId
128
142
  })]
@@ -9,10 +9,10 @@
9
9
  * dispatch hooks return the bound writes of `createSessionStreamActions`:
10
10
  * stable functions that never subscribe their caller.
11
11
  */
12
- import { ChatEvent } from "./headless/host.js";
13
12
  import { SessionFallbackModel, SessionPageState, SessionRetryState } from "./headless/streams/types.js";
14
13
  import { SessionStreams } from "./headless/streams/session-streams.js";
15
14
  import { SessionStreamActions } from "./headless/streams/actions.js";
15
+ import { ChatEvent } from "./headless/host.js";
16
16
  import "./headless/streams/index.js";
17
17
  import { ReactNode } from "react";
18
18
  import { TranscriptEvents } from "zidane/chat/pure";
@@ -20,8 +20,9 @@
20
20
  * memoized `TranscriptRow` with one shared `RowContext`, and a root row whose
21
21
  * inputs did not change reuses its element (React skips it without a props
22
22
  * compare). The settled exchanges' elements are made once per settled list
23
- * and sit behind one memoized fiber (`RowRun`), so a stream tick walks the
24
- * open exchange only.
23
+ * and sit behind memoized fibers of {@link RUN_ROWS} rows each (`RowRun`), so
24
+ * a stream tick walks the open exchange only, and a row mounting walks its
25
+ * run and the list of runs, not every row of a long history.
25
26
  *
26
27
  * The extensions' `transcript.turn-end` items draw after the turn they name
27
28
  * (`turnId`: after the last root row holding it; none holds it, not drawn),
@@ -52,12 +52,22 @@ function tailKeys(settled, open, sizeOf) {
52
52
  return out;
53
53
  }
54
54
  /**
55
- * The root rows before the transcript's flat run, behind one memoized fiber: a render that changes none of them
56
- * (a stream tick) never walks them. The flat run after them starts where the open exchange started when the
57
- * conversation showed, so a row never moves between the two (that would remount it).
55
+ * Root rows before the transcript's flat run, behind memoized fibers: a render that changes none of them (a stream
56
+ * tick) never walks them, and a render for one row (it mounts, it parks) walks its run only. React walks every child
57
+ * of a fiber it renders through, and each child it skips looks up its context providers: one run of every history
58
+ * row made each row's mount cost the whole history. The flat run after them starts where the open exchange started
59
+ * when the conversation showed, so a row never moves between the two (that would remount it).
58
60
  */
59
- const RowRun = memo(({ rows }) => /* @__PURE__ */ jsx(Fragment$1, { children: rows }));
61
+ const RowRun = memo(({ rows }) => /* @__PURE__ */ jsx(Fragment$1, { children: rows }), (a, b) => a.rows.length === b.rows.length && a.rows.every((row, i) => row === b.rows[i]));
60
62
  RowRun.displayName = "RowRun";
63
+ /** Rows per {@link RowRun}. */
64
+ const RUN_ROWS = 64;
65
+ /** The rows in runs of {@link RUN_ROWS}, counted from the end: history prepended adds runs in front, and a row never changes runs. */
66
+ function rowRuns(rows) {
67
+ const runs = [];
68
+ for (let end = rows.length, k = 0; end > 0; end -= RUN_ROWS, k++) runs.push(/* @__PURE__ */ jsx(RowRun, { rows: rows.slice(Math.max(0, end - RUN_ROWS), end) }, `\u0000run${k}`));
69
+ return runs.reverse();
70
+ }
61
71
  /** Whether a transcript can hold a view (`eventsMayHoldViews`), each settled exchange read once. */
62
72
  function mayHoldViews(transcript) {
63
73
  return eventsMayHoldViews(transcript.tail) || transcript.chunks.some((chunk) => chunkFact(chunk, "may-hold-views", eventsMayHoldViews));
@@ -265,7 +275,16 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
265
275
  const groupCache = useRef(/* @__PURE__ */ new WeakMap());
266
276
  const renderClustersRef = useRef(() => []);
267
277
  const showRunReceipt = o.showRunReceipt;
268
- const foldEpoch = useMemo(() => ({}), [
278
+ const foldEpoch = useMemo(() => ({
279
+ rowCtx,
280
+ selectedTurnId,
281
+ stops,
282
+ resumableId,
283
+ showThinking,
284
+ collapseSubagents,
285
+ streaming,
286
+ showRunReceipt
287
+ }), [
269
288
  rowCtx,
270
289
  selectedTurnId,
271
290
  stops,
@@ -536,11 +555,11 @@ const Transcript = memo(({ events, streaming, sessionId, options, selection, tur
536
555
  }, [settledItems, runKey]);
537
556
  if (runKey !== null && foundAt < 0 && !openItems.some((item) => item.key === runKey)) runStart.current.key = openItems[0]?.key ?? null;
538
557
  const runAt = foundAt < 0 ? settledItems.length : foundAt;
539
- const prefixEls = useMemo(() => runAt === settledEls.length ? settledEls : settledEls.slice(0, runAt), [settledEls, runAt]);
558
+ const prefixRuns = useMemo(() => rowRuns(runAt === settledEls.length ? settledEls : settledEls.slice(0, runAt)), [settledEls, runAt]);
540
559
  const flatSettled = useMemo(() => runAt === settledEls.length ? [] : settledEls.slice(runAt), [settledEls, runAt]);
541
560
  renderClustersRef.current = renderClusters;
542
561
  const rootRows = [
543
- /* @__PURE__ */ jsx(RowRun, { rows: prefixEls }, "\0run"),
562
+ ...prefixRuns,
544
563
  ...flatSettled,
545
564
  ...openEls
546
565
  ];
@@ -2,8 +2,8 @@ import { plainTextToDocJson } from "./prompt-history-nav.js";
2
2
  import { suggestionExtension } from "./suggestion-extension.js";
3
3
  import { useLayoutEffect } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { EditorContent, useEditor } from "@tiptap/react";
6
5
  import Placeholder from "@tiptap/extension-placeholder";
6
+ import { EditorContent, useEditor } from "@tiptap/react";
7
7
  import StarterKit from "@tiptap/starter-kit";
8
8
  // src/chat/composer/ComposerEditor.tsx
9
9
  /** Builds the composer's editor and renders its view. */
@@ -3,7 +3,7 @@ import { MetaChip } from "../../components/Form.js";
3
3
  import { Menu, MenuRow, MenuSection, MenuSeparator } from "../../components/Menu.js";
4
4
  import { useChatLabels } from "../useChatLabels.js";
5
5
  import { PickerPill } from "./PickerPill.js";
6
- import { useCallback, useEffect, useState } from "react";
6
+ import { useCallback, useState } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  // src/chat/composer/ModelOptionsPicker.tsx
9
9
  /** Every reasoning effort level the agent knows, in the TUI picker's order. */
@@ -123,7 +123,11 @@ function OptionsPillLabel({ supportsReasoning, effort, options, enabled }) {
123
123
  function ModelOptionsMenu({ supportsReasoning, options, effort, enabled, onEffort, onOptions, levels, effortHints }) {
124
124
  const labels = useChatLabels();
125
125
  const [local, setLocal] = useState(enabled);
126
- useEffect(() => setLocal(enabled), [enabled]);
126
+ const [answered, setAnswered] = useState(enabled);
127
+ if (answered !== enabled) {
128
+ setAnswered(enabled);
129
+ setLocal(enabled);
130
+ }
127
131
  const toggle = useCallback(async (id) => {
128
132
  const next = {
129
133
  ...local,
@@ -18,8 +18,8 @@
18
18
  * Values are `provider/model` keys; a bare model id (a session's
19
19
  * `modelId`) matches too.
20
20
  */
21
- import { ChatModel, ChatModelProvider } from "../headless/host.js";
22
21
  import { ImageModelRow, ModelCatalogRow, ModelPickRef } from "../headless/composer/models.js";
22
+ import { ChatModel, ChatModelProvider } from "../headless/host.js";
23
23
  import "./ImageModelList.js";
24
24
  import "./model-catalog.js";
25
25
  import { CSSProperties, ReactNode } from "react";
@@ -4,7 +4,9 @@
4
4
  * machines, the isolation) and the folder picker of the place (a machine's
5
5
  * folders, a server's), over a `NewChatPlace` instead of a draft. Each pick
6
6
  * is a new place at once. A place on this computer has no folder here: a new
7
- * chat there opens in the app's folder.
7
+ * chat there opens in the app's folder. Without a folder, the isolations
8
+ * offered are what the host can run in any folder (`machineOnly`): one a new
9
+ * chat's folder can't serve falls back to the host's default there.
8
10
  *
9
11
  * <PlacePicker value={place} onChange={save} hosts={hosts} serverMachines={machines} />
10
12
  */
@@ -9,6 +9,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { LOCAL_HOST_KEY, machineKind, placeEnvironmentKind, placeOfPick, samePlace } from "zidane/chat/pure";
10
10
  // src/chat/composer/PlacePicker.tsx
11
11
  const OFFLINE_WAITS = { offlineWaits: true };
12
+ const ANY_FOLDER = {
13
+ offlineWaits: true,
14
+ machineOnly: true
15
+ };
12
16
  const NO_PROJECTS = [];
13
17
  /**
14
18
  * Renders the where pill and the place's folder picker; each pick calls `onChange` with the new place.
@@ -30,7 +34,7 @@ function PlacePicker({ value, inherited, onChange, hosts, local = true, hiddenMa
30
34
  ]);
31
35
  const host = listed.find((h) => h.id === shown.hostId);
32
36
  const reachable = hostReachable(host);
33
- const descriptors = useEnvironmentChoices(shown.machine ? "" : shown.folder ?? "", onServer ? shown.hostId : void 0, OFFLINE_WAITS);
37
+ const descriptors = useEnvironmentChoices(shown.machine ? "" : shown.folder ?? "", onServer ? shown.hostId : void 0, shown.folder ? OFFLINE_WAITS : ANY_FOLDER);
34
38
  const kind = placeEnvironmentKind(shown);
35
39
  const environment = useMemo(() => kind ? {
36
40
  kind,
@@ -3,7 +3,7 @@ import { resolveDraftDescriptor } from "../../git/headless/environment.js";
3
3
  import { resolveRemoteClone } from "../../git/headless/remote-clone.js";
4
4
  import { useImportRepo } from "../../git/ImportRepoDialog.js";
5
5
  import { useEnvironmentChoices } from "../../git/useEnvironmentChoices.js";
6
- import { draftFolderPath, draftLocalFolder, recentHostFolders, recentLocalFolders } from "../headless/draft-target.js";
6
+ import { draftFolderPath, draftLocalFolder, recentHostFolders, recentLocalFolders, unavailablePlaceIssue } from "../headless/draft-target.js";
7
7
  import { useEffect, useMemo, useState } from "react";
8
8
  import { LOCAL_HOST_KEY, placeEnvironmentKind, placeOfPick } from "zidane/chat/pure";
9
9
  // src/chat/composer/use-draft-target.ts
@@ -136,6 +136,15 @@ function useDraftTarget(options) {
136
136
  setPlaceCheck(null);
137
137
  } else if (!placeCheck.folder) setPlaceCheck(null);
138
138
  }
139
+ const placeKind = isNewSession && place && placeSaved && place.hostId === hostId ? placeEnvironmentKind(place) : void 0;
140
+ const fallbackIssue = unavailablePlaceIssue(placeKind, environment?.kind, environmentChoices, descriptor);
141
+ const fallbackKey = fallbackIssue ? JSON.stringify([
142
+ placeKind,
143
+ folderPath,
144
+ remoteFolder
145
+ ]) : null;
146
+ const [dismissedFallback, setDismissedFallback] = useState(null);
147
+ const shownFallback = fallbackIssue && fallbackKey !== dismissedFallback ? fallbackIssue : null;
139
148
  const localFolder = draftLocalFolder({
140
149
  ...folderState,
141
150
  onMachine: Boolean(machine)
@@ -304,8 +313,11 @@ function useDraftTarget(options) {
304
313
  machineFolder,
305
314
  setMachineFolder,
306
315
  machineHost,
307
- placeIssue,
308
- dismissPlaceIssue: () => setPlaceIssue(null),
316
+ placeIssue: placeIssue ?? shownFallback,
317
+ dismissPlaceIssue: () => {
318
+ if (placeIssue) setPlaceIssue(null);
319
+ else setDismissedFallback(fallbackKey);
320
+ },
309
321
  here,
310
322
  error,
311
323
  setError
@@ -15,6 +15,7 @@ const LINE_CHARS = 2e3;
15
15
  */
16
16
  function createChatBlockRuns(transport) {
17
17
  const stores = /* @__PURE__ */ new Map();
18
+ const views = /* @__PURE__ */ new Map();
18
19
  /** The last read asked for, per session: an older answer never overwrites a newer one. */
19
20
  const reads = /* @__PURE__ */ new Map();
20
21
  const refresh = (sessionId) => {
@@ -36,6 +37,30 @@ function createChatBlockRuns(transport) {
36
37
  }
37
38
  return store;
38
39
  };
40
+ const viewOf = (sessionId) => {
41
+ let view = views.get(sessionId);
42
+ if (!view) {
43
+ const store = runsOf(sessionId);
44
+ let watchers = 0;
45
+ let stale = false;
46
+ view = {
47
+ get: store.get,
48
+ subscribe(onChange) {
49
+ if (watchers++ === 0 && stale) refresh(sessionId);
50
+ const off = store.subscribe(onChange);
51
+ let on = true;
52
+ return () => {
53
+ if (!on) return;
54
+ on = false;
55
+ off();
56
+ if (--watchers === 0) stale = true;
57
+ };
58
+ }
59
+ };
60
+ views.set(sessionId, view);
61
+ }
62
+ return view;
63
+ };
39
64
  const lives = /* @__PURE__ */ new Map();
40
65
  const stops = /* @__PURE__ */ new Map();
41
66
  const liveOf = (sessionId) => {
@@ -55,7 +80,7 @@ function createChatBlockRuns(transport) {
55
80
  });
56
81
  };
57
82
  return {
58
- runs: runsOf,
83
+ runs: viewOf,
59
84
  run: (sessionId, request, options) => transport.run(sessionId, request, options),
60
85
  remove: (sessionId, key) => transport.remove(sessionId, key),
61
86
  live: liveOf,
@@ -42,7 +42,7 @@ const normalizeId = (id) => id.replace(/-/g, "").toLowerCase();
42
42
  * @param token - The chip's text (`#3f2a`).
43
43
  */
44
44
  function sessionForToken(sessions, token) {
45
- const needle = token.replace(/^#/, "").toLowerCase();
45
+ const needle = normalizeId(token.replace(/^#/, ""));
46
46
  if (!needle) return null;
47
47
  const hits = sessions.filter((s) => normalizeId(s.id).startsWith(needle));
48
48
  return hits.length === 1 ? hits[0] : null;
@@ -10,6 +10,8 @@
10
10
  * The draft starts on this computer.
11
11
  * - `machine-gone`: the machine is no longer one of the server's. The draft starts on the server itself.
12
12
  * - `folder-gone`: the folder is not there any more. The draft starts in the usual folder.
13
+ * - `unavailable`: the place's isolation can't run in the draft's folder (`label`, and its `reason`). The draft
14
+ * starts in `fallback`, the host's default (or Local), and starts in the isolation again in a folder it serves.
13
15
  */
14
16
  export type DraftPlaceIssue = {
15
17
  kind: 'unsaved';
@@ -22,7 +24,31 @@ export type DraftPlaceIssue = {
22
24
  } | {
23
25
  kind: 'folder-gone';
24
26
  folder: string;
27
+ } | {
28
+ kind: 'unavailable';
29
+ label: string;
30
+ reason?: string;
31
+ fallback: string;
25
32
  };
33
+ /** A descriptor as {@link unavailablePlaceIssue} reads it. */
34
+ interface PlaceKindDescriptor {
35
+ kind: string;
36
+ label: string;
37
+ enabled: boolean;
38
+ available: boolean;
39
+ reason?: string;
40
+ }
41
+ /**
42
+ * The `unavailable` issue of a new chat whose default place asks for `placeKind`: when the draft still asks
43
+ * for it (`draftKind`), the host lists it, and it can't run in the draft's folder, so the draft resolved to
44
+ * `resolved` instead. `null` otherwise: it runs there, the draft picked something else, or the list is not in yet.
45
+ *
46
+ * @param placeKind - The default place's isolation (`placeEnvironmentKind`); absent: the host's default.
47
+ * @param draftKind - What the draft asks for now.
48
+ * @param descriptors - What the draft's host lists for its folder.
49
+ * @param resolved - What the draft resolved to (`resolveDraftDescriptor`).
50
+ */
51
+ export declare function unavailablePlaceIssue(placeKind: string | undefined, draftKind: string | undefined, descriptors: readonly PlaceKindDescriptor[], resolved: Pick<PlaceKindDescriptor, 'kind' | 'label'> | undefined): DraftPlaceIssue | null;
26
52
  /** A session row as {@link recentLocalFolders} reads it. */
27
53
  export interface DraftFolderSource {
28
54
  /** The session's folder (`''`: none). */
@@ -72,4 +98,5 @@ export declare function draftFolderPath(state: DraftFolderState): string | null;
72
98
  *
73
99
  * @param state - The draft's picks (`sessionCwd` set: not a draft, `null`).
74
100
  */
75
- export declare function draftLocalFolder(state: DraftFolderState): string | null;
101
+ export declare function draftLocalFolder(state: DraftFolderState): string | null;
102
+ export {};
@@ -1,5 +1,26 @@
1
1
  // src/chat/headless/draft-target.ts
2
2
  /**
3
+ * The `unavailable` issue of a new chat whose default place asks for `placeKind`: when the draft still asks
4
+ * for it (`draftKind`), the host lists it, and it can't run in the draft's folder, so the draft resolved to
5
+ * `resolved` instead. `null` otherwise: it runs there, the draft picked something else, or the list is not in yet.
6
+ *
7
+ * @param placeKind - The default place's isolation (`placeEnvironmentKind`); absent: the host's default.
8
+ * @param draftKind - What the draft asks for now.
9
+ * @param descriptors - What the draft's host lists for its folder.
10
+ * @param resolved - What the draft resolved to (`resolveDraftDescriptor`).
11
+ */
12
+ function unavailablePlaceIssue(placeKind, draftKind, descriptors, resolved) {
13
+ if (!placeKind || draftKind !== placeKind || !resolved || resolved.kind === placeKind) return null;
14
+ const wanted = descriptors.find((d) => d.kind === placeKind);
15
+ if (!wanted || wanted.enabled && wanted.available) return null;
16
+ return {
17
+ kind: "unavailable",
18
+ label: wanted.label,
19
+ ...wanted.reason ? { reason: wanted.reason } : {},
20
+ fallback: resolved.label
21
+ };
22
+ }
23
+ /**
3
24
  * This computer's recent folders, most recent first (the rows' order), each once.
4
25
  *
5
26
  * @param sessions - The session rows, most recently updated first.
@@ -55,4 +76,4 @@ function draftLocalFolder(state) {
55
76
  if (state.sessionCwd !== void 0 || state.onServer || state.onMachine || state.folderless) return null;
56
77
  return draftFolderPath(state) || null;
57
78
  }
58
- export { draftFolderPath, draftLocalFolder, recentHostFolders, recentLocalFolders };
79
+ export { draftFolderPath, draftLocalFolder, recentHostFolders, recentLocalFolders, unavailablePlaceIssue };