@tangle-network/agent-app 0.60.114 → 0.60.116

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 (84) hide show
  1. package/dist/VaultPane-OWOPGPXP.js +7 -0
  2. package/dist/assistant/index.js +8 -8
  3. package/dist/chat-react/index.js +2 -2
  4. package/dist/chat-routes/index.js +2 -2
  5. package/dist/{chunk-Y4WLCFDZ.js → chunk-2FLSODOX.js} +6 -6
  6. package/dist/chunk-BTEVD7HG.js +198 -0
  7. package/dist/chunk-BTEVD7HG.js.map +1 -0
  8. package/dist/chunk-FVI2MHUL.js +1152 -0
  9. package/dist/chunk-FVI2MHUL.js.map +1 -0
  10. package/dist/{chunk-RQSYR4AV.js → chunk-GHUQ5HXU.js} +4 -4
  11. package/dist/{chunk-Q7M3GVLL.js → chunk-JCSHTJT6.js} +36 -2
  12. package/dist/chunk-JCSHTJT6.js.map +1 -0
  13. package/dist/{chunk-OGDEUCNW.js → chunk-JGLK5RDK.js} +176 -1
  14. package/dist/chunk-JGLK5RDK.js.map +1 -0
  15. package/dist/{chunk-AB63T2LM.js → chunk-KBJZMR4E.js} +8 -1
  16. package/dist/chunk-KBJZMR4E.js.map +1 -0
  17. package/dist/{chunk-RQSNTJTW.js → chunk-MO7PDQRZ.js} +526 -187
  18. package/dist/chunk-MO7PDQRZ.js.map +1 -0
  19. package/dist/{chunk-MEUNTJL5.js → chunk-N3CYCSKK.js} +6 -1
  20. package/dist/chunk-N3CYCSKK.js.map +1 -0
  21. package/dist/{chunk-56GPDCOJ.js → chunk-TSGWACTC.js} +5 -5
  22. package/dist/eval/index.d.ts +2 -0
  23. package/dist/eval/index.js +64 -0
  24. package/dist/eval/index.js.map +1 -1
  25. package/dist/eval/parity.d.ts +74 -0
  26. package/dist/journeys/cli.d.ts +2 -0
  27. package/dist/journeys/cli.js +165 -0
  28. package/dist/journeys/cli.js.map +1 -0
  29. package/dist/journeys/config.d.ts +96 -0
  30. package/dist/journeys/index.d.ts +18 -0
  31. package/dist/journeys/index.js +731 -0
  32. package/dist/journeys/index.js.map +1 -0
  33. package/dist/journeys/journey.d.ts +173 -0
  34. package/dist/journeys/page-reading.d.ts +42 -0
  35. package/dist/journeys/report.d.ts +51 -0
  36. package/dist/journeys/score.d.ts +115 -0
  37. package/dist/journeys/scrub.d.ts +21 -0
  38. package/dist/journeys/send.d.ts +46 -0
  39. package/dist/journeys/session.d.ts +27 -0
  40. package/dist/journeys/trace-zip.d.ts +28 -0
  41. package/dist/journeys/video.d.ts +53 -0
  42. package/dist/public-consultation/index.d.ts +1 -1
  43. package/dist/runtime/index.js +9 -3
  44. package/dist/runtime/index.js.map +1 -1
  45. package/dist/runtime/router-turn.d.ts +8 -1
  46. package/dist/runtime/router-turn.js +9 -3
  47. package/dist/runtime/turn-knowledge.d.ts +50 -0
  48. package/dist/sandbox/index.d.ts +2 -0
  49. package/dist/sandbox/index.js +13 -1
  50. package/dist/sandbox/sandbox-exec-tool.d.ts +68 -0
  51. package/dist/sandbox/sandbox-run-tool.d.ts +70 -0
  52. package/dist/studio-react/index.js +2 -2
  53. package/dist/teams/index.js +10 -6
  54. package/dist/teams/invitations-api.js +6 -3
  55. package/dist/teams/invitations-api.js.map +1 -1
  56. package/dist/teams/invitations.d.ts +4 -0
  57. package/dist/teams/members-api.js +2 -1
  58. package/dist/teams-react/components/InviteForm.d.ts +20 -0
  59. package/dist/teams-react/contracts.d.ts +2 -0
  60. package/dist/teams-react/index.js +196 -217
  61. package/dist/teams-react/index.js.map +1 -1
  62. package/dist/vault/VaultContentResults.d.ts +29 -0
  63. package/dist/vault/VaultHistoryPanel.d.ts +20 -0
  64. package/dist/vault/VaultPane.d.ts +3 -1
  65. package/dist/vault/contracts.d.ts +38 -0
  66. package/dist/vault/index.js +1 -1
  67. package/dist/vault/lazy.js +1 -1
  68. package/dist/web-react/index.js +22 -22
  69. package/dist/workspace-export/index.js +4 -193
  70. package/dist/workspace-export/index.js.map +1 -1
  71. package/dist/workspace-react/index.js +9 -7
  72. package/dist/workspace-react/index.js.map +1 -1
  73. package/dist/workspace-react/workspace-list.d.ts +7 -1
  74. package/package.json +8 -2
  75. package/dist/VaultPane-JUSNGOV7.js +0 -7
  76. package/dist/chunk-AB63T2LM.js.map +0 -1
  77. package/dist/chunk-MEUNTJL5.js.map +0 -1
  78. package/dist/chunk-OGDEUCNW.js.map +0 -1
  79. package/dist/chunk-Q7M3GVLL.js.map +0 -1
  80. package/dist/chunk-RQSNTJTW.js.map +0 -1
  81. /package/dist/{VaultPane-JUSNGOV7.js.map → VaultPane-OWOPGPXP.js.map} +0 -0
  82. /package/dist/{chunk-Y4WLCFDZ.js.map → chunk-2FLSODOX.js.map} +0 -0
  83. /package/dist/{chunk-RQSYR4AV.js.map → chunk-GHUQ5HXU.js.map} +0 -0
  84. /package/dist/{chunk-56GPDCOJ.js.map → chunk-TSGWACTC.js.map} +0 -0
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  Component,
4
4
  forwardRef,
5
- useCallback,
6
- useEffect as useEffect2,
5
+ useCallback as useCallback2,
6
+ useEffect as useEffect3,
7
7
  useImperativeHandle,
8
8
  useLayoutEffect,
9
- useId,
9
+ useId as useId3,
10
10
  useMemo,
11
11
  useRef as useRef2,
12
- useState
12
+ useState as useState2
13
13
  } from "react";
14
- import { Download, FileText, Folder, Plus, RefreshCw, Trash2 } from "lucide-react";
14
+ import { Download, FileText as FileText2, Folder, History as History2, Plus, RefreshCw, Trash2 } from "lucide-react";
15
15
 
16
16
  // src/vault/ConfirmDialog.tsx
17
17
  import { useEffect, useRef } from "react";
@@ -145,11 +145,238 @@ function recordRecentFile(key, path) {
145
145
  return next;
146
146
  }
147
147
 
148
+ // src/vault/VaultContentResults.tsx
149
+ import { useId } from "react";
150
+ import { FileText } from "lucide-react";
151
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
152
+ function highlight(text, query) {
153
+ const needle = query.toLowerCase();
154
+ const haystack = text.toLowerCase();
155
+ const parts = [];
156
+ let from = 0;
157
+ for (let at = haystack.indexOf(needle); needle && at >= 0; at = haystack.indexOf(needle, from)) {
158
+ if (at > from) parts.push(text.slice(from, at));
159
+ parts.push(
160
+ /* @__PURE__ */ jsx2("mark", { className: "rounded-sm bg-[var(--surface-warning-bg)] px-0.5 text-[var(--surface-warning-text)]", children: text.slice(at, at + needle.length) }, at)
161
+ );
162
+ from = at + needle.length;
163
+ }
164
+ if (from < text.length) parts.push(text.slice(from));
165
+ return parts;
166
+ }
167
+ function VaultContentResults({
168
+ state,
169
+ selectedPath,
170
+ onOpen,
171
+ onRetry
172
+ }) {
173
+ const headingId = useId();
174
+ return /* @__PURE__ */ jsxs2("section", { "aria-labelledby": headingId, "data-vault-content-results": true, className: "mt-2 border-t border-border px-1.5 pt-3", children: [
175
+ /* @__PURE__ */ jsx2("h3", { id: headingId, className: "px-1.5 text-sm font-medium text-foreground", children: "In file contents" }),
176
+ state.status === "error" ? /* @__PURE__ */ jsxs2("div", { role: "alert", className: "mt-2 space-y-2 px-1.5 text-sm text-[var(--surface-danger-text)]", children: [
177
+ /* @__PURE__ */ jsxs2("p", { children: [
178
+ "Couldn't search file contents. ",
179
+ state.message
180
+ ] }),
181
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
182
+ ] }) : state.matches.length === 0 ? /* @__PURE__ */ jsx2("p", { role: "status", className: "mt-2 px-1.5 text-sm text-muted-foreground", children: state.status === "loading" ? "Searching file contents\u2026" : `No file contains \u201C${state.query}\u201D.` }) : /* @__PURE__ */ jsx2("ul", { className: "mt-1.5 space-y-0.5", "aria-busy": state.status === "loading", children: state.matches.map((match) => {
183
+ const slash = match.path.lastIndexOf("/");
184
+ const selected = match.path === selectedPath;
185
+ return /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs2(
186
+ "button",
187
+ {
188
+ type: "button",
189
+ onClick: () => onOpen(match.path),
190
+ title: match.path,
191
+ "aria-current": selected ? "true" : void 0,
192
+ className: `w-full rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${selected ? "bg-muted" : "hover:bg-muted"}`,
193
+ children: [
194
+ /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 items-center gap-2", children: [
195
+ /* @__PURE__ */ jsx2(FileText, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
196
+ /* @__PURE__ */ jsx2("span", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: match.path.slice(slash + 1) }),
197
+ slash > 0 && /* @__PURE__ */ jsx2("span", { className: "ml-auto min-w-0 shrink truncate text-sm text-muted-foreground", children: match.path.slice(0, slash) })
198
+ ] }),
199
+ /* @__PURE__ */ jsx2("span", { className: "mt-1 line-clamp-2 block text-sm text-muted-foreground", children: highlight(match.snippet, state.query) })
200
+ ]
201
+ }
202
+ ) }, match.path);
203
+ }) })
204
+ ] });
205
+ }
206
+
207
+ // src/vault/VaultHistoryPanel.tsx
208
+ import { useCallback, useEffect as useEffect2, useId as useId2, useState } from "react";
209
+ import { History, X } from "lucide-react";
210
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
211
+ function message(error, fallback) {
212
+ return error instanceof Error && error.message ? error.message : fallback;
213
+ }
214
+ function savedAtLabel(savedAt) {
215
+ const date = new Date(savedAt);
216
+ if (Number.isNaN(date.getTime())) return savedAt;
217
+ return new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }).format(date);
218
+ }
219
+ function VaultHistoryPanel({
220
+ path,
221
+ listRevisions,
222
+ readRevision,
223
+ canRestore,
224
+ renderPreview,
225
+ onRestore,
226
+ onClose
227
+ }) {
228
+ const listId = useId2();
229
+ const [revisions, setRevisions] = useState({ status: "loading" });
230
+ const [listNonce, setListNonce] = useState(0);
231
+ const [selectedId, setSelectedId] = useState(null);
232
+ const [contents, setContents] = useState({});
233
+ const [confirming, setConfirming] = useState(false);
234
+ const [restoring, setRestoring] = useState(false);
235
+ const [restoreError, setRestoreError] = useState(null);
236
+ useEffect2(() => {
237
+ let cancelled = false;
238
+ setRevisions({ status: "loading" });
239
+ listRevisions(path).then(
240
+ (value) => {
241
+ if (cancelled) return;
242
+ setRevisions({ status: "ready", value });
243
+ setSelectedId((current) => current ?? value[0]?.id ?? null);
244
+ },
245
+ (error) => {
246
+ if (!cancelled) setRevisions({ status: "error", message: message(error, "Could not list the saved versions.") });
247
+ }
248
+ );
249
+ return () => {
250
+ cancelled = true;
251
+ };
252
+ }, [path, listRevisions, listNonce]);
253
+ const loadContent = useCallback((id) => {
254
+ setContents((current) => ({ ...current, [id]: { status: "loading" } }));
255
+ readRevision(path, id).then(
256
+ (value) => setContents((current) => ({ ...current, [id]: { status: "ready", value } })),
257
+ (error) => setContents((current) => ({
258
+ ...current,
259
+ [id]: { status: "error", message: message(error, "Could not read this version.") }
260
+ }))
261
+ );
262
+ }, [path, readRevision]);
263
+ useEffect2(() => {
264
+ if (selectedId && !contents[selectedId]) loadContent(selectedId);
265
+ }, [selectedId, contents, loadContent]);
266
+ const list = revisions.status === "ready" ? revisions.value : [];
267
+ const selected = list.find((revision) => revision.id === selectedId) ?? null;
268
+ const content = selectedId ? contents[selectedId] : void 0;
269
+ const restorable = canRestore && selected !== null && !selected.current && content?.status === "ready";
270
+ const restore = async () => {
271
+ if (content?.status !== "ready") return;
272
+ setRestoring(true);
273
+ setRestoreError(null);
274
+ try {
275
+ await onRestore(content.value);
276
+ setConfirming(false);
277
+ } catch (error) {
278
+ setRestoreError(message(error, "Could not restore this version."));
279
+ setConfirming(false);
280
+ } finally {
281
+ setRestoring(false);
282
+ }
283
+ };
284
+ return /* @__PURE__ */ jsxs3("div", { "data-vault-history": true, className: "flex h-full min-h-0 flex-col @[60rem]/vault:flex-row", children: [
285
+ /* @__PURE__ */ jsxs3(
286
+ "nav",
287
+ {
288
+ "aria-labelledby": listId,
289
+ className: "flex max-h-56 shrink-0 flex-col border-b border-border @[60rem]/vault:max-h-none @[60rem]/vault:w-64 @[60rem]/vault:border-b-0 @[60rem]/vault:border-r",
290
+ children: [
291
+ /* @__PURE__ */ jsxs3("h3", { id: listId, className: "flex items-center gap-2 px-4 pb-2 pt-3 text-sm font-semibold text-foreground", children: [
292
+ /* @__PURE__ */ jsx3(History, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }),
293
+ "Saved versions"
294
+ ] }),
295
+ /* @__PURE__ */ jsxs3("div", { className: "min-h-0 flex-1 overflow-y-auto px-2 pb-2", children: [
296
+ revisions.status === "loading" && /* @__PURE__ */ jsx3("p", { role: "status", className: "px-2 py-1 text-sm text-muted-foreground", children: "Loading versions\u2026" }),
297
+ revisions.status === "error" && /* @__PURE__ */ jsxs3("div", { role: "alert", className: "space-y-2 px-2 py-1 text-sm text-[var(--surface-danger-text)]", children: [
298
+ /* @__PURE__ */ jsx3("p", { children: revisions.message }),
299
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => setListNonce((n) => n + 1), className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
300
+ ] }),
301
+ revisions.status === "ready" && list.length === 0 && /* @__PURE__ */ jsx3("p", { className: "px-2 py-1 text-sm text-muted-foreground", children: "No earlier versions are saved for this file." }),
302
+ /* @__PURE__ */ jsx3("ul", { className: "space-y-0.5", children: list.map((revision) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsxs3(
303
+ "button",
304
+ {
305
+ type: "button",
306
+ onClick: () => setSelectedId(revision.id),
307
+ "aria-pressed": revision.id === selectedId,
308
+ className: `w-full rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${revision.id === selectedId ? "bg-muted" : "hover:bg-muted"}`,
309
+ children: [
310
+ /* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [
311
+ savedAtLabel(revision.savedAt),
312
+ revision.current && /* @__PURE__ */ jsx3("span", { className: "rounded-full border border-border px-2 text-sm font-normal text-muted-foreground", children: "Current" })
313
+ ] }),
314
+ revision.author && /* @__PURE__ */ jsx3("span", { className: "mt-0.5 block text-sm text-muted-foreground", children: revision.author })
315
+ ]
316
+ }
317
+ ) }, revision.id)) })
318
+ ] })
319
+ ]
320
+ }
321
+ ),
322
+ /* @__PURE__ */ jsxs3("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [
323
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
324
+ /* @__PURE__ */ jsx3("p", { className: "min-w-0 text-sm text-muted-foreground", children: selected ? selected.current ? "This is the version the file holds now." : `Saved ${savedAtLabel(selected.savedAt)}${selected.author ? ` by ${selected.author}` : ""}. Read only.` : "Choose a version to see it." }),
325
+ /* @__PURE__ */ jsxs3("div", { className: "flex shrink-0 items-center gap-2", children: [
326
+ restorable && /* @__PURE__ */ jsx3(
327
+ "button",
328
+ {
329
+ type: "button",
330
+ onClick: () => {
331
+ setRestoreError(null);
332
+ setConfirming(true);
333
+ },
334
+ className: "inline-flex h-8 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",
335
+ children: "Restore this version"
336
+ }
337
+ ),
338
+ /* @__PURE__ */ jsxs3(
339
+ "button",
340
+ {
341
+ type: "button",
342
+ onClick: onClose,
343
+ className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-sm text-foreground transition-colors hover:bg-muted",
344
+ children: [
345
+ /* @__PURE__ */ jsx3(X, { className: "size-4", "aria-hidden": "true" }),
346
+ "Close history"
347
+ ]
348
+ }
349
+ )
350
+ ] })
351
+ ] }),
352
+ restoreError && /* @__PURE__ */ jsx3("p", { role: "alert", className: "border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-sm text-[var(--surface-danger-text)]", children: restoreError }),
353
+ /* @__PURE__ */ jsx3("div", { className: "min-h-0 flex-1 overflow-hidden", children: content?.status === "ready" && selected ? renderPreview(content.value, selected) : content?.status === "error" ? /* @__PURE__ */ jsxs3("div", { role: "alert", className: "space-y-2 p-6 text-sm text-[var(--surface-danger-text)]", children: [
354
+ /* @__PURE__ */ jsx3("p", { children: content.message }),
355
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => selectedId && loadContent(selectedId), className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
356
+ ] }) : selectedId ? /* @__PURE__ */ jsx3("p", { role: "status", className: "p-6 text-sm text-muted-foreground", children: "Loading this version\u2026" }) : null })
357
+ ] }),
358
+ /* @__PURE__ */ jsx3(
359
+ ConfirmDialog,
360
+ {
361
+ open: confirming,
362
+ title: "Restore this version?",
363
+ description: `${path} goes back to the version saved ${selected ? savedAtLabel(selected.savedAt) : ""}. The version it holds now stays in this list.`,
364
+ confirmLabel: restoring ? "Restoring\u2026" : "Restore version",
365
+ confirmDisabled: restoring,
366
+ onConfirm: () => void restore(),
367
+ onCancel: () => setConfirming(false)
368
+ }
369
+ )
370
+ ] });
371
+ }
372
+
148
373
  // src/vault/VaultPane.tsx
149
374
  import { filterFileNodes, VaultTree } from "@tangle-network/sandbox-ui/vault-tree";
150
375
  import { ShellHeader } from "@tangle-network/sandbox-ui/workspace";
151
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
376
+ import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
152
377
  var DOCK_SIDE_MIN_PX = 960;
378
+ var CONTENT_SEARCH_MIN = 2;
379
+ var CONTENT_SEARCH_DEBOUNCE_MS = 250;
153
380
  var TREE_ICON_BUTTON = "inline-flex size-8 shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [@media(pointer:coarse)]:size-10";
154
381
  var IDENTITY_CODEC = {
155
382
  parse: (raw) => raw,
@@ -203,13 +430,13 @@ var EditorErrorBoundary = class extends Component {
203
430
  render() {
204
431
  if (this.state.error) {
205
432
  const msg = this.state.error instanceof Error ? this.state.error.message : typeof this.state.error === "string" ? this.state.error : `${this.props.label} did not load. Reload the page to try again.`;
206
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
207
- /* @__PURE__ */ jsxs2("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
433
+ return /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
434
+ /* @__PURE__ */ jsxs4("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
208
435
  this.props.label,
209
436
  " failed to load"
210
437
  ] }),
211
- /* @__PURE__ */ jsx2("p", { className: "mb-4 max-w-xs text-xs text-muted-foreground", children: String(msg) }),
212
- /* @__PURE__ */ jsx2(
438
+ /* @__PURE__ */ jsx4("p", { className: "mb-4 max-w-xs text-xs text-muted-foreground", children: String(msg) }),
439
+ /* @__PURE__ */ jsx4(
213
440
  "button",
214
441
  {
215
442
  type: "button",
@@ -227,29 +454,29 @@ var EditorErrorBoundary = class extends Component {
227
454
  }
228
455
  };
229
456
  function SkeletonRegion({ label, className, children }) {
230
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
231
- /* @__PURE__ */ jsx2("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: label }),
232
- /* @__PURE__ */ jsx2("div", { className, "aria-hidden": "true", children })
457
+ return /* @__PURE__ */ jsxs4(Fragment, { children: [
458
+ /* @__PURE__ */ jsx4("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: label }),
459
+ /* @__PURE__ */ jsx4("div", { className, "aria-hidden": "true", children })
233
460
  ] });
234
461
  }
235
462
  function TreeSkeleton() {
236
- return /* @__PURE__ */ jsx2(SkeletonRegion, { label: "Loading files\u2026", className: "space-y-2 p-4", children: [32, 48, 40, 52].map((w, i) => /* @__PURE__ */ jsx2("div", { className: "h-4 animate-pulse rounded bg-muted", style: { width: `${w * 4}px` } }, i)) });
463
+ return /* @__PURE__ */ jsx4(SkeletonRegion, { label: "Loading files\u2026", className: "space-y-2 p-4", children: [32, 48, 40, 52].map((w, i) => /* @__PURE__ */ jsx4("div", { className: "h-4 animate-pulse rounded bg-muted", style: { width: `${w * 4}px` } }, i)) });
237
464
  }
238
465
  function EditorSkeleton() {
239
- return /* @__PURE__ */ jsxs2(SkeletonRegion, { label: "Loading file\u2026", className: "space-y-3 p-8", children: [
240
- /* @__PURE__ */ jsx2("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
241
- /* @__PURE__ */ jsx2("div", { className: "h-4 w-full animate-pulse rounded bg-muted" }),
242
- /* @__PURE__ */ jsx2("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
243
- /* @__PURE__ */ jsx2("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted" })
466
+ return /* @__PURE__ */ jsxs4(SkeletonRegion, { label: "Loading file\u2026", className: "space-y-3 p-8", children: [
467
+ /* @__PURE__ */ jsx4("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
468
+ /* @__PURE__ */ jsx4("div", { className: "h-4 w-full animate-pulse rounded bg-muted" }),
469
+ /* @__PURE__ */ jsx4("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
470
+ /* @__PURE__ */ jsx4("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted" })
244
471
  ] });
245
472
  }
246
- function ReadErrorState({ message, onRetry }) {
247
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [
248
- /* @__PURE__ */ jsxs2("div", { children: [
249
- /* @__PURE__ */ jsx2("h3", { className: "text-sm font-medium text-foreground", children: "Couldn't open this file" }),
250
- /* @__PURE__ */ jsx2("p", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: message })
473
+ function ReadErrorState({ message: message2, onRetry }) {
474
+ return /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [
475
+ /* @__PURE__ */ jsxs4("div", { children: [
476
+ /* @__PURE__ */ jsx4("h3", { className: "text-sm font-medium text-foreground", children: "Couldn't open this file" }),
477
+ /* @__PURE__ */ jsx4("p", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: message2 })
251
478
  ] }),
252
- /* @__PURE__ */ jsx2(
479
+ /* @__PURE__ */ jsx4(
253
480
  "button",
254
481
  {
255
482
  type: "button",
@@ -260,16 +487,16 @@ function ReadErrorState({ message, onRetry }) {
260
487
  )
261
488
  ] });
262
489
  }
263
- function TreeErrorState({ label, message, onRetry }) {
264
- return /* @__PURE__ */ jsxs2("div", { role: "alert", className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
265
- /* @__PURE__ */ jsxs2("div", { children: [
266
- /* @__PURE__ */ jsxs2("h3", { className: "text-sm font-medium text-foreground", children: [
490
+ function TreeErrorState({ label, message: message2, onRetry }) {
491
+ return /* @__PURE__ */ jsxs4("div", { role: "alert", className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
492
+ /* @__PURE__ */ jsxs4("div", { children: [
493
+ /* @__PURE__ */ jsxs4("h3", { className: "text-sm font-medium text-foreground", children: [
267
494
  "Couldn't load ",
268
495
  label
269
496
  ] }),
270
- /* @__PURE__ */ jsx2("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: message })
497
+ /* @__PURE__ */ jsx4("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: message2 })
271
498
  ] }),
272
- /* @__PURE__ */ jsx2(
499
+ /* @__PURE__ */ jsx4(
273
500
  "button",
274
501
  {
275
502
  type: "button",
@@ -281,19 +508,19 @@ function TreeErrorState({ label, message, onRetry }) {
281
508
  ] });
282
509
  }
283
510
  function TreeEmptyState({ canCreate, onCreate }) {
284
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
285
- /* @__PURE__ */ jsxs2("div", { children: [
286
- /* @__PURE__ */ jsx2("h3", { className: "text-sm font-medium text-foreground", children: "No files yet" }),
287
- /* @__PURE__ */ jsx2("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: canCreate ? "Create a file to start." : "Files appear here once they are added." })
511
+ return /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
512
+ /* @__PURE__ */ jsxs4("div", { children: [
513
+ /* @__PURE__ */ jsx4("h3", { className: "text-sm font-medium text-foreground", children: "No files yet" }),
514
+ /* @__PURE__ */ jsx4("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: canCreate ? "Create a file to start." : "Files appear here once they are added." })
288
515
  ] }),
289
- canCreate && /* @__PURE__ */ jsxs2(
516
+ canCreate && /* @__PURE__ */ jsxs4(
290
517
  "button",
291
518
  {
292
519
  type: "button",
293
520
  onClick: onCreate,
294
521
  className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",
295
522
  children: [
296
- /* @__PURE__ */ jsx2(Plus, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
523
+ /* @__PURE__ */ jsx4(Plus, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
297
524
  "New file"
298
525
  ]
299
526
  }
@@ -301,13 +528,13 @@ function TreeEmptyState({ canCreate, onCreate }) {
301
528
  ] });
302
529
  }
303
530
  function TreeNoMatchState({ query, onClear }) {
304
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-3 p-6 text-center", children: [
305
- /* @__PURE__ */ jsxs2("p", { className: "max-w-xs break-words text-xs text-muted-foreground", children: [
531
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3 p-6 text-center", children: [
532
+ /* @__PURE__ */ jsxs4("p", { className: "max-w-xs break-words text-xs text-muted-foreground", children: [
306
533
  "No files match \u201C",
307
534
  query,
308
535
  "\u201D."
309
536
  ] }),
310
- /* @__PURE__ */ jsx2(
537
+ /* @__PURE__ */ jsx4(
311
538
  "button",
312
539
  {
313
540
  type: "button",
@@ -319,21 +546,21 @@ function TreeNoMatchState({ query, onClear }) {
319
546
  ] });
320
547
  }
321
548
  function OperationErrorAlert({
322
- message,
549
+ message: message2,
323
550
  retryLabel,
324
551
  onRetry,
325
552
  onDismiss
326
553
  }) {
327
- return /* @__PURE__ */ jsxs2(
554
+ return /* @__PURE__ */ jsxs4(
328
555
  "div",
329
556
  {
330
557
  role: "alert",
331
558
  className: "flex shrink-0 items-center justify-between gap-3 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-[var(--surface-danger-text)]",
332
559
  children: [
333
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1", children: message }),
334
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-3", children: [
335
- /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
336
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
560
+ /* @__PURE__ */ jsx4("span", { className: "min-w-0 flex-1", children: message2 }),
561
+ /* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-3", children: [
562
+ /* @__PURE__ */ jsx4("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
563
+ /* @__PURE__ */ jsx4("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
337
564
  ] })
338
565
  ]
339
566
  }
@@ -341,20 +568,20 @@ function OperationErrorAlert({
341
568
  }
342
569
  var RECENT_SHOWN = 5;
343
570
  function DocumentEmptyState({ label, recent, onOpen }) {
344
- const recentHeadingId = useId();
345
- return /* @__PURE__ */ jsx2("div", { "data-vault-document-empty": true, className: "flex h-full items-center justify-center overflow-y-auto p-8", children: /* @__PURE__ */ jsxs2("div", { className: "w-full max-w-sm text-center", children: [
346
- /* @__PURE__ */ jsx2("span", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx2(FileText, { className: "size-5", "aria-hidden": "true" }) }),
347
- /* @__PURE__ */ jsx2("h3", { className: "mt-4 text-base font-semibold text-foreground", children: "Select a file" }),
348
- /* @__PURE__ */ jsxs2("p", { className: "mt-1 text-sm text-muted-foreground", children: [
571
+ const recentHeadingId = useId3();
572
+ return /* @__PURE__ */ jsx4("div", { "data-vault-document-empty": true, className: "flex h-full items-center justify-center overflow-y-auto p-8", children: /* @__PURE__ */ jsxs4("div", { className: "w-full max-w-sm text-center", children: [
573
+ /* @__PURE__ */ jsx4("span", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx4(FileText2, { className: "size-5", "aria-hidden": "true" }) }),
574
+ /* @__PURE__ */ jsx4("h3", { className: "mt-4 text-base font-semibold text-foreground", children: "Select a file" }),
575
+ /* @__PURE__ */ jsxs4("p", { className: "mt-1 text-sm text-muted-foreground", children: [
349
576
  "Choose a file in ",
350
577
  label,
351
578
  " to open it here."
352
579
  ] }),
353
- recent.length > 0 && /* @__PURE__ */ jsxs2("section", { "aria-labelledby": recentHeadingId, className: "mt-8 text-left", children: [
354
- /* @__PURE__ */ jsx2("h4", { id: recentHeadingId, className: "text-xs font-medium text-muted-foreground", children: "Recently opened" }),
355
- /* @__PURE__ */ jsx2("ul", { className: "mt-2 overflow-hidden rounded-xl border border-border bg-card shadow-raised", children: recent.map((path) => {
580
+ recent.length > 0 && /* @__PURE__ */ jsxs4("section", { "aria-labelledby": recentHeadingId, className: "mt-8 text-left", children: [
581
+ /* @__PURE__ */ jsx4("h4", { id: recentHeadingId, className: "text-xs font-medium text-muted-foreground", children: "Recently opened" }),
582
+ /* @__PURE__ */ jsx4("ul", { className: "mt-2 overflow-hidden rounded-xl border border-border bg-card shadow-raised", children: recent.map((path) => {
356
583
  const slash = path.lastIndexOf("/");
357
- return /* @__PURE__ */ jsx2("li", { className: "border-b border-border last:border-b-0", children: /* @__PURE__ */ jsxs2(
584
+ return /* @__PURE__ */ jsx4("li", { className: "border-b border-border last:border-b-0", children: /* @__PURE__ */ jsxs4(
358
585
  "button",
359
586
  {
360
587
  type: "button",
@@ -362,9 +589,9 @@ function DocumentEmptyState({ label, recent, onOpen }) {
362
589
  title: path,
363
590
  className: "flex min-h-10 w-full items-center gap-2.5 px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
364
591
  children: [
365
- /* @__PURE__ */ jsx2(FileText, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
366
- /* @__PURE__ */ jsx2("span", { className: "min-w-0 truncate font-medium", children: path.slice(slash + 1) }),
367
- slash > 0 && /* @__PURE__ */ jsx2("span", { className: "ml-auto min-w-0 shrink truncate text-xs text-muted-foreground", children: path.slice(0, slash) })
592
+ /* @__PURE__ */ jsx4(FileText2, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
593
+ /* @__PURE__ */ jsx4("span", { className: "min-w-0 truncate font-medium", children: path.slice(slash + 1) }),
594
+ slash > 0 && /* @__PURE__ */ jsx4("span", { className: "ml-auto min-w-0 shrink truncate text-xs text-muted-foreground", children: path.slice(0, slash) })
368
595
  ]
369
596
  }
370
597
  ) }, path);
@@ -404,23 +631,23 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
404
631
  const isMarkdownCapable = codec !== void 0;
405
632
  const persistentDock = dockToggle === false;
406
633
  const dockToggleCfg = dockToggle ? dockToggle : { label: "Discuss", disabledWhenDirty: true };
407
- const [tree, setTree] = useState([]);
408
- const [treeLoading, setTreeLoading] = useState(true);
409
- const [treeLoaded, setTreeLoaded] = useState(false);
410
- const [treeError, setTreeError] = useState(null);
411
- const [internalPath, setInternalPath] = useState(null);
634
+ const [tree, setTree] = useState2([]);
635
+ const [treeLoading, setTreeLoading] = useState2(true);
636
+ const [treeLoaded, setTreeLoaded] = useState2(false);
637
+ const [treeError, setTreeError] = useState2(null);
638
+ const [internalPath, setInternalPath] = useState2(null);
412
639
  const selectedPath = controlled ? controlledPath ?? null : internalPath;
413
- const [filesOpen, setFilesOpen] = useState(false);
640
+ const [filesOpen, setFilesOpen] = useState2(false);
414
641
  const showFiles = filesOpen || !selectedPath;
415
642
  const searchRef = useRef2(null);
416
643
  const documentRef = useRef2(null);
417
- const treeHeadingId = useId();
418
- const [recentFiles, setRecentFiles] = useState(() => ({ key: treeStateKey, paths: readRecentFiles(treeStateKey) }));
644
+ const treeHeadingId = useId3();
645
+ const [recentFiles, setRecentFiles] = useState2(() => ({ key: treeStateKey, paths: readRecentFiles(treeStateKey) }));
419
646
  if (recentFiles.key !== treeStateKey) setRecentFiles({ key: treeStateKey, paths: readRecentFiles(treeStateKey) });
420
- useEffect2(() => {
647
+ useEffect3(() => {
421
648
  setFilesOpen(false);
422
649
  }, [selectedPath]);
423
- const showDocument = useCallback(() => {
650
+ const showDocument = useCallback2(() => {
424
651
  const focused = document.activeElement;
425
652
  setFilesOpen(false);
426
653
  requestAnimationFrame(() => {
@@ -429,27 +656,27 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
429
656
  }
430
657
  });
431
658
  }, []);
432
- const [selectedFile, setSelectedFile] = useState(null);
433
- const [displayReadyPath, setDisplayReadyPath] = useState(null);
434
- const [fileLoading, setFileLoading] = useState(false);
435
- const [readError, setReadError] = useState(null);
436
- const [reloadNonce, setReloadNonce] = useState(0);
437
- const [saving, setSaving] = useState(false);
438
- const [saveError, setSaveError] = useState(null);
439
- const [editorMode, setEditorMode] = useState("rich");
440
- const [richDraft, setRichDraft] = useState("");
441
- const [sourceDraft, setSourceDraft] = useState("");
442
- const [isDirty, setIsDirty] = useState(false);
443
- const [createOpen, setCreateOpen] = useState(false);
444
- const [newPath, setNewPath] = useState("");
445
- const [creating, setCreating] = useState(false);
446
- const [createError, setCreateError] = useState(null);
447
- const [deleteOpen, setDeleteOpen] = useState(false);
448
- const [deleting, setDeleting] = useState(false);
449
- const [deleteError, setDeleteError] = useState(null);
450
- const [dockOpen, setDockOpen] = useState(false);
659
+ const [selectedFile, setSelectedFile] = useState2(null);
660
+ const [displayReadyPath, setDisplayReadyPath] = useState2(null);
661
+ const [fileLoading, setFileLoading] = useState2(false);
662
+ const [readError, setReadError] = useState2(null);
663
+ const [reloadNonce, setReloadNonce] = useState2(0);
664
+ const [saving, setSaving] = useState2(false);
665
+ const [saveError, setSaveError] = useState2(null);
666
+ const [editorMode, setEditorMode] = useState2("rich");
667
+ const [richDraft, setRichDraft] = useState2("");
668
+ const [sourceDraft, setSourceDraft] = useState2("");
669
+ const [isDirty, setIsDirty] = useState2(false);
670
+ const [createOpen, setCreateOpen] = useState2(false);
671
+ const [newPath, setNewPath] = useState2("");
672
+ const [creating, setCreating] = useState2(false);
673
+ const [createError, setCreateError] = useState2(null);
674
+ const [deleteOpen, setDeleteOpen] = useState2(false);
675
+ const [deleting, setDeleting] = useState2(false);
676
+ const [deleteError, setDeleteError] = useState2(null);
677
+ const [dockOpen, setDockOpen] = useState2(false);
451
678
  const rootRef = useRef2(null);
452
- const [dockInline, setDockInline] = useState(false);
679
+ const [dockInline, setDockInline] = useState2(false);
453
680
  useLayoutEffect(() => {
454
681
  const root = rootRef.current;
455
682
  if (!root || !renderDock || typeof ResizeObserver === "undefined") return;
@@ -461,9 +688,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
461
688
  observer.observe(root);
462
689
  return () => observer.disconnect();
463
690
  }, [renderDock]);
464
- const [pendingNav, setPendingNav] = useState(null);
465
- const [query, setQuery] = useState("");
466
- const [folderPath, setFolderPath] = useState(null);
691
+ const [pendingNav, setPendingNav] = useState2(null);
692
+ const [query, setQuery] = useState2("");
693
+ const [folderPath, setFolderPath] = useState2(null);
694
+ const [contentSearch, setContentSearch] = useState2({ status: "idle" });
695
+ const [contentSearchNonce, setContentSearchNonce] = useState2(0);
696
+ const [historyOpen, setHistoryOpen] = useState2(false);
467
697
  const dirtyRef = useRef2(isDirty);
468
698
  dirtyRef.current = isDirty;
469
699
  const treeRequestRef = useRef2(0);
@@ -473,7 +703,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
473
703
  onOperationErrorRef.current = onOperationError;
474
704
  const pendingOpenRef = useRef2(null);
475
705
  const previousPortRef = useRef2(port);
476
- const finishPendingOpen = useCallback((opened, clearNavigation = true) => {
706
+ const finishPendingOpen = useCallback2((opened, clearNavigation = true) => {
477
707
  const pending = pendingOpenRef.current;
478
708
  if (!pending) return;
479
709
  pendingOpenRef.current = null;
@@ -482,12 +712,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
482
712
  }
483
713
  pending.resolve(opened);
484
714
  }, []);
485
- useEffect2(() => () => finishPendingOpen(false, false), [finishPendingOpen]);
486
- useEffect2(() => {
715
+ useEffect3(() => () => finishPendingOpen(false, false), [finishPendingOpen]);
716
+ useEffect3(() => {
487
717
  if (previousPortRef.current !== port) finishPendingOpen(false);
488
718
  previousPortRef.current = port;
489
719
  }, [port, finishPendingOpen]);
490
- useEffect2(() => {
720
+ useEffect3(() => {
491
721
  const pending = pendingOpenRef.current;
492
722
  if (!pending) return;
493
723
  if (selectedPath === pending.path) pending.selected = true;
@@ -515,10 +745,40 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
515
745
  const visibleRoot = useMemo(() => {
516
746
  const q = query.trim().toLowerCase();
517
747
  if (!q) return treeRoot;
518
- const base = activeFolderNode ?? treeRoot;
519
- return { ...base, children: filterFileNodes(base.children ?? [], q) };
520
- }, [treeRoot, activeFolderNode, query]);
521
- const commitPath = useCallback(
748
+ return { ...treeRoot, children: filterFileNodes(treeRoot.children ?? [], q) };
749
+ }, [treeRoot, query]);
750
+ const searchQuery = query.trim();
751
+ const canSearchContent = typeof port.searchContent === "function";
752
+ useEffect3(() => {
753
+ if (!canSearchContent || searchQuery.length < CONTENT_SEARCH_MIN) {
754
+ setContentSearch({ status: "idle" });
755
+ return;
756
+ }
757
+ const controller = new AbortController();
758
+ setContentSearch((current) => ({
759
+ status: "loading",
760
+ query: searchQuery,
761
+ matches: current.status !== "idle" && current.status !== "error" && current.query === searchQuery ? current.matches : []
762
+ }));
763
+ const timer = setTimeout(() => {
764
+ port.searchContent(searchQuery, { signal: controller.signal }).then(
765
+ (matches) => {
766
+ if (!controller.signal.aborted) setContentSearch({ status: "done", query: searchQuery, matches });
767
+ },
768
+ (error) => {
769
+ if (!controller.signal.aborted) {
770
+ setContentSearch({ status: "error", query: searchQuery, message: operationMessage(error, "The search did not answer.") });
771
+ }
772
+ }
773
+ );
774
+ }, CONTENT_SEARCH_DEBOUNCE_MS);
775
+ return () => {
776
+ clearTimeout(timer);
777
+ controller.abort();
778
+ };
779
+ }, [port, canSearchContent, searchQuery, contentSearchNonce]);
780
+ const contentResults = !canSearchContent || searchQuery.length < CONTENT_SEARCH_MIN ? { status: "idle" } : contentSearch.status !== "idle" && contentSearch.query === searchQuery ? contentSearch : { status: "loading", query: searchQuery, matches: [] };
781
+ const commitPath = useCallback2(
522
782
  (next) => {
523
783
  if (controlled) {
524
784
  const decision = onSelectedPathChange?.(next);
@@ -530,7 +790,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
530
790
  },
531
791
  [controlled, onSelectedPathChange]
532
792
  );
533
- const reportFailure = useCallback((operation, phase, error, fallback, path) => {
793
+ const reportFailure = useCallback2((operation, phase, error, fallback, path) => {
534
794
  const failure = {
535
795
  operation,
536
796
  phase,
@@ -545,7 +805,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
545
805
  }
546
806
  return failure;
547
807
  }, []);
548
- const refresh = useCallback(async (context = LIST_CONTEXT) => {
808
+ const refresh = useCallback2(async (context = LIST_CONTEXT) => {
549
809
  const request = ++treeRequestRef.current;
550
810
  setTreeLoading(true);
551
811
  setTreeError(null);
@@ -570,25 +830,25 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
570
830
  if (request === treeRequestRef.current) setTreeLoading(false);
571
831
  }
572
832
  }, [port, reportFailure, label]);
573
- useEffect2(() => {
833
+ useEffect3(() => {
574
834
  setTree([]);
575
835
  setTreeLoaded(false);
576
836
  setTreeError(null);
577
837
  setSelectedFile(null);
578
838
  }, [port]);
579
- useEffect2(() => {
839
+ useEffect3(() => {
580
840
  void refresh();
581
841
  return () => {
582
842
  treeRequestRef.current += 1;
583
843
  };
584
844
  }, [refresh, refreshKey]);
585
- const retryTree = useCallback(async () => {
845
+ const retryTree = useCallback2(async () => {
586
846
  if (!treeError) return;
587
847
  const { context } = treeError;
588
848
  const recovered = await refresh(context);
589
849
  if (recovered && context.selectAfterRecovery) commitPath(context.selectAfterRecovery);
590
850
  }, [treeError, refresh, commitPath]);
591
- useEffect2(() => {
851
+ useEffect3(() => {
592
852
  if (!selectedPath) {
593
853
  setSelectedFile(null);
594
854
  setFileLoading(false);
@@ -638,7 +898,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
638
898
  cancelled = true;
639
899
  };
640
900
  }, [port, selectedPath, resolvedSelectedPath, treeLoading, treeLoaded, treeError, isDirty, saving, reloadNonce, commitPath, reportFailure, finishPendingOpen]);
641
- useEffect2(() => {
901
+ useEffect3(() => {
642
902
  if (!selectedFile) {
643
903
  loadedPathRef.current = null;
644
904
  setDisplayReadyPath(null);
@@ -661,13 +921,13 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
661
921
  setSaveError(null);
662
922
  setDockOpen(false);
663
923
  }, [selectedFile?.path, selectedFile?.content, activeCodec]);
664
- useEffect2(() => {
924
+ useEffect3(() => {
665
925
  const pending = pendingOpenRef.current;
666
926
  if (pending?.loaded && pending.path === selectedPath && selectedFile?.path === pending.path && displayReadyPath === pending.path && sourceDraft === selectedFile.content && !fileLoading) {
667
927
  finishPendingOpen(true);
668
928
  }
669
929
  }, [selectedPath, selectedFile, displayReadyPath, sourceDraft, fileLoading, finishPendingOpen]);
670
- const guardedOpen = useCallback((rawPath, resolve) => {
930
+ const guardedOpen = useCallback2((rawPath, resolve) => {
671
931
  const target = resolveTreePath(rawPath, treePaths);
672
932
  if (!rawPath.trim() || target?.type === "directory") {
673
933
  resolve?.(false);
@@ -706,10 +966,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
706
966
  useImperativeHandle(ref, () => ({
707
967
  openFile: (path) => new Promise((resolve) => guardedOpen(path, resolve))
708
968
  }), [guardedOpen]);
709
- const toggleFolder = useCallback((path) => {
969
+ const toggleFolder = useCallback2((path) => {
710
970
  setFolderPath((current) => current === path ? null : path);
711
971
  }, []);
712
- const handleFolderToggle = useCallback((path, expanded) => {
972
+ const handleFolderToggle = useCallback2((path, expanded) => {
713
973
  setFolderPath((current) => {
714
974
  if (expanded) return path;
715
975
  return current && (current === path || current.startsWith(`${path}/`)) ? null : current;
@@ -726,8 +986,8 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
726
986
  }
727
987
  toggleFolder(target.path);
728
988
  };
729
- const handleTreeSelect = useCallback((path) => selectFileRef.current(path), []);
730
- const confirmDiscard = useCallback(() => {
989
+ const handleTreeSelect = useCallback2((path) => selectFileRef.current(path), []);
990
+ const confirmDiscard = useCallback2(() => {
731
991
  const nav = pendingNav;
732
992
  setPendingNav(null);
733
993
  if (!nav) return;
@@ -739,7 +999,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
739
999
  setIsDirty(false);
740
1000
  showDocument();
741
1001
  }, [pendingNav, commitPath, showDocument, finishPendingOpen]);
742
- const showRichMode = useCallback(() => {
1002
+ const showRichMode = useCallback2(() => {
743
1003
  setEditorMode((mode) => {
744
1004
  if (mode === "rich") return mode;
745
1005
  setRichDraft(activeCodec.parse(sourceDraft));
@@ -747,7 +1007,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
747
1007
  return "rich";
748
1008
  });
749
1009
  }, [activeCodec, sourceDraft]);
750
- const showSourceMode = useCallback(() => {
1010
+ const showSourceMode = useCallback2(() => {
751
1011
  setEditorMode((mode) => {
752
1012
  if (mode === "source") return mode;
753
1013
  const content = isDirty ? activeCodec.serialize(richDraft) : savedContentRef.current;
@@ -756,17 +1016,17 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
756
1016
  return "source";
757
1017
  });
758
1018
  }, [activeCodec, isDirty, richDraft]);
759
- const onSourceChange = useCallback((next) => {
1019
+ const onSourceChange = useCallback2((next) => {
760
1020
  dirtyRef.current = next !== savedContentRef.current;
761
1021
  setSourceDraft(next);
762
1022
  setIsDirty(dirtyRef.current);
763
1023
  }, []);
764
- const onRichChange = useCallback((next) => {
1024
+ const onRichChange = useCallback2((next) => {
765
1025
  dirtyRef.current = activeCodec.serialize(next) !== savedContentRef.current;
766
1026
  setRichDraft(next);
767
1027
  setIsDirty(dirtyRef.current);
768
1028
  }, [activeCodec]);
769
- const saveCurrent = useCallback(async () => {
1029
+ const saveCurrent = useCallback2(async () => {
770
1030
  if (!selectedFile) return;
771
1031
  const content = editorMode === "source" ? sourceDraft : activeCodec.serialize(richDraft);
772
1032
  setSaving(true);
@@ -784,7 +1044,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
784
1044
  setSaving(false);
785
1045
  }
786
1046
  }, [selectedFile, editorMode, sourceDraft, richDraft, activeCodec, port, reportFailure]);
787
- const handleCreate = useCallback(async () => {
1047
+ const handleCreate = useCallback2(async () => {
788
1048
  const trimmed = newPath.trim();
789
1049
  if (!trimmed || !trimmed.split("/").pop()?.trim()) return;
790
1050
  setCreating(true);
@@ -806,7 +1066,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
806
1066
  setCreating(false);
807
1067
  }
808
1068
  }, [newPath, port, refresh, commitPath, reportFailure]);
809
- const handleDelete = useCallback(async () => {
1069
+ const handleDelete = useCallback2(async () => {
810
1070
  if (!selectedFile) return;
811
1071
  const path = selectedFile.path;
812
1072
  setDeleting(true);
@@ -824,8 +1084,21 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
824
1084
  setDeleting(false);
825
1085
  }
826
1086
  }, [selectedFile, port, refresh, commitPath, reportFailure]);
1087
+ const historyPath = selectedFile?.path ?? null;
1088
+ useEffect3(() => {
1089
+ setHistoryOpen(false);
1090
+ }, [historyPath]);
1091
+ const canShowHistory = typeof port.listRevisions === "function" && typeof port.readRevision === "function";
1092
+ const listRevisions = useCallback2((path) => port.listRevisions(path), [port]);
1093
+ const readRevision = useCallback2((path, id) => port.readRevision(path, id), [port]);
1094
+ const restoreRevision = useCallback2(async (content) => {
1095
+ if (!selectedFile) return;
1096
+ await port.writeFile(selectedFile.path, content);
1097
+ setHistoryOpen(false);
1098
+ setReloadNonce((n) => n + 1);
1099
+ }, [port, selectedFile]);
827
1100
  const shownPath = selectedFile?.path ?? null;
828
- useEffect2(() => {
1101
+ useEffect3(() => {
829
1102
  if (!shownPath || !treeStateKey) return;
830
1103
  setRecentFiles({ key: treeStateKey, paths: recordRecentFile(treeStateKey, shownPath) });
831
1104
  }, [shownPath, treeStateKey]);
@@ -840,14 +1113,15 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
840
1113
  };
841
1114
  const vaultEmpty = treeLoaded && treePaths.files.size === 0 && treePaths.directories.size === 0;
842
1115
  const trimmedQuery = query.trim();
1116
+ const nameMatches = (visibleRoot.children?.length ?? 0) > 0;
843
1117
  let treeContent;
844
1118
  if (!treeLoaded && (treeLoading || !treeError)) {
845
- treeContent = /* @__PURE__ */ jsx2(TreeSkeleton, {});
1119
+ treeContent = /* @__PURE__ */ jsx4(TreeSkeleton, {});
846
1120
  } else if (!treeLoaded && treeError) {
847
- treeContent = /* @__PURE__ */ jsx2(TreeErrorState, { label, message: treeFailureMessage(treeError.failure, label), onRetry: () => void retryTree() });
1121
+ treeContent = /* @__PURE__ */ jsx4(TreeErrorState, { label, message: treeFailureMessage(treeError.failure, label), onRetry: () => void retryTree() });
848
1122
  } else {
849
- treeContent = /* @__PURE__ */ jsxs2(Fragment, { children: [
850
- treeError && /* @__PURE__ */ jsx2(
1123
+ treeContent = /* @__PURE__ */ jsxs4(Fragment, { children: [
1124
+ treeError && /* @__PURE__ */ jsx4(
851
1125
  OperationErrorAlert,
852
1126
  {
853
1127
  message: treeFailureMessage(treeError.failure, label),
@@ -856,11 +1130,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
856
1130
  onDismiss: () => setTreeError(null)
857
1131
  }
858
1132
  ),
859
- vaultEmpty && !trimmedQuery ? treeEmptyState !== void 0 ? treeEmptyState : /* @__PURE__ */ jsx2(TreeEmptyState, { canCreate, onCreate: openCreate }) : trimmedQuery && (visibleRoot.children?.length ?? 0) === 0 ? /* @__PURE__ */ jsx2(TreeNoMatchState, { query: trimmedQuery, onClear: () => setQuery("") }) : renderTree ? renderTree({
1133
+ vaultEmpty && !trimmedQuery ? treeEmptyState !== void 0 ? treeEmptyState : /* @__PURE__ */ jsx4(TreeEmptyState, { canCreate, onCreate: openCreate }) : trimmedQuery && !nameMatches && (contentResults.status === "idle" || contentResults.status === "done" && contentResults.matches.length === 0) ? /* @__PURE__ */ jsx4(TreeNoMatchState, { query: trimmedQuery, onClear: () => setQuery("") }) : trimmedQuery && !nameMatches ? null : renderTree ? renderTree({
860
1134
  root: visibleRoot,
861
1135
  selectedPath: resolvedSelectedPath ?? void 0,
862
1136
  onSelect: handleTreeSelect
863
- }) : /* @__PURE__ */ jsx2(
1137
+ }) : /* @__PURE__ */ jsx4(
864
1138
  VaultTree,
865
1139
  {
866
1140
  root: visibleRoot,
@@ -872,16 +1146,25 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
872
1146
  expandAll: !!trimmedQuery,
873
1147
  label
874
1148
  }
1149
+ ),
1150
+ trimmedQuery && contentResults.status !== "idle" && /* @__PURE__ */ jsx4(
1151
+ VaultContentResults,
1152
+ {
1153
+ state: contentResults,
1154
+ selectedPath: resolvedSelectedPath,
1155
+ onOpen: (path) => guardedOpen(path),
1156
+ onRetry: () => setContentSearchNonce((n) => n + 1)
1157
+ }
875
1158
  )
876
1159
  ] });
877
1160
  }
878
- return /* @__PURE__ */ jsx2(EditorErrorBoundary, { label, onReset: () => {
1161
+ return /* @__PURE__ */ jsx4(EditorErrorBoundary, { label, onReset: () => {
879
1162
  commitPath(null);
880
1163
  setSelectedFile(null);
881
- }, children: /* @__PURE__ */ jsxs2("div", { ref: rootRef, className: `flex min-h-0 min-w-0 flex-1 overflow-hidden ${className ?? ""}`, children: [
882
- /* @__PURE__ */ jsxs2("div", { className: "@container/vault flex min-w-0 flex-1 flex-col", children: [
883
- selectedPath && /* @__PURE__ */ jsxs2("nav", { "aria-label": `${label} navigation`, className: "flex shrink-0 items-center gap-1 border-b border-border p-2 @[45rem]/vault:hidden", children: [
884
- /* @__PURE__ */ jsx2(
1164
+ }, children: /* @__PURE__ */ jsxs4("div", { ref: rootRef, className: `flex min-h-0 min-w-0 flex-1 overflow-hidden ${className ?? ""}`, children: [
1165
+ /* @__PURE__ */ jsxs4("div", { className: "@container/vault flex min-w-0 flex-1 flex-col", children: [
1166
+ selectedPath && /* @__PURE__ */ jsxs4("nav", { "aria-label": `${label} navigation`, className: "flex shrink-0 items-center gap-1 border-b border-border p-2 @[60rem]/vault:hidden", children: [
1167
+ /* @__PURE__ */ jsx4(
885
1168
  "button",
886
1169
  {
887
1170
  type: "button",
@@ -899,7 +1182,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
899
1182
  children: "Files"
900
1183
  }
901
1184
  ),
902
- selectedPath && /* @__PURE__ */ jsx2(
1185
+ selectedPath && /* @__PURE__ */ jsx4(
903
1186
  "button",
904
1187
  {
905
1188
  type: "button",
@@ -911,19 +1194,19 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
911
1194
  }
912
1195
  )
913
1196
  ] }),
914
- /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 min-w-0 flex-1", children: [
915
- /* @__PURE__ */ jsx2("div", { "data-vault-tree": true, className: `${showFiles ? "flex" : "hidden"} min-w-0 flex-1 flex-col p-2 @[45rem]/vault:flex @[45rem]/vault:p-3 @[45rem]/vault:w-[23rem] @[45rem]/vault:min-w-[23rem] @[45rem]/vault:flex-none`, children: /* @__PURE__ */ jsxs2(
1197
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-h-0 min-w-0 flex-1", children: [
1198
+ /* @__PURE__ */ jsx4("div", { "data-vault-tree": true, className: `${showFiles ? "flex" : "hidden"} min-w-0 flex-1 flex-col p-2 @[60rem]/vault:flex @[60rem]/vault:p-3 @[60rem]/vault:w-[23rem] @[60rem]/vault:min-w-[23rem] @[60rem]/vault:flex-none`, children: /* @__PURE__ */ jsxs4(
916
1199
  "section",
917
1200
  {
918
1201
  "aria-labelledby": treeHeadingId,
919
1202
  "data-vault-tree-surface": true,
920
1203
  className: "flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-raised",
921
1204
  children: [
922
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2 px-3 pb-2 pt-3", children: [
923
- /* @__PURE__ */ jsx2("h2", { id: treeHeadingId, className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: label }),
924
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-1", children: [
1205
+ /* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-2 px-3 pb-2 pt-3", children: [
1206
+ /* @__PURE__ */ jsx4("h2", { id: treeHeadingId, className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: label }),
1207
+ /* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-1", children: [
925
1208
  headerActions,
926
- /* @__PURE__ */ jsx2(
1209
+ /* @__PURE__ */ jsx4(
927
1210
  "button",
928
1211
  {
929
1212
  type: "button",
@@ -931,10 +1214,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
931
1214
  title: "Refresh",
932
1215
  onClick: () => void refresh(),
933
1216
  className: `${TREE_ICON_BUTTON} text-muted-foreground hover:bg-muted hover:text-foreground`,
934
- children: /* @__PURE__ */ jsx2(RefreshCw, { className: "size-4", "aria-hidden": "true" })
1217
+ children: /* @__PURE__ */ jsx4(RefreshCw, { className: "size-4", "aria-hidden": "true" })
935
1218
  }
936
1219
  ),
937
- canCreate && /* @__PURE__ */ jsx2(
1220
+ canCreate && /* @__PURE__ */ jsx4(
938
1221
  "button",
939
1222
  {
940
1223
  type: "button",
@@ -942,12 +1225,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
942
1225
  "aria-label": activeFolder ? `New file in ${activeFolder}` : "New file",
943
1226
  onClick: openCreate,
944
1227
  className: `${TREE_ICON_BUTTON} bg-primary text-primary-foreground hover:bg-primary/90`,
945
- children: /* @__PURE__ */ jsx2(Plus, { className: "size-4", "aria-hidden": "true" })
1228
+ children: /* @__PURE__ */ jsx4(Plus, { className: "size-4", "aria-hidden": "true" })
946
1229
  }
947
1230
  )
948
1231
  ] })
949
1232
  ] }),
950
- /* @__PURE__ */ jsx2("div", { className: "shrink-0 px-3 pb-2", children: /* @__PURE__ */ jsx2(
1233
+ /* @__PURE__ */ jsx4("div", { className: "shrink-0 px-3 pb-2", children: /* @__PURE__ */ jsx4(
951
1234
  "input",
952
1235
  {
953
1236
  ref: searchRef,
@@ -955,15 +1238,16 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
955
1238
  disabled: vaultEmpty,
956
1239
  value: query,
957
1240
  onChange: (e) => setQuery(e.target.value),
958
- placeholder: activeFolder ? `Search ${activeFolder}\u2026` : `Search ${noun}\u2026`,
1241
+ placeholder: canSearchContent ? `Search ${noun} names and text\u2026` : `Search ${noun}\u2026`,
959
1242
  "aria-label": `Search ${noun}`,
960
1243
  className: "h-8 w-full rounded-md border border-border bg-input px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [@media(pointer:coarse)]:h-10 [@media(pointer:coarse)]:text-base"
961
1244
  }
962
1245
  ) }),
963
- activeFolder && /* @__PURE__ */ jsxs2("div", { className: "mx-3 mb-2 flex shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs", children: [
964
- /* @__PURE__ */ jsx2(Folder, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
965
- /* @__PURE__ */ jsx2("span", { "data-vault-folder": true, className: "min-w-0 flex-1 truncate font-medium text-foreground", title: activeFolder, children: activeFolder }),
966
- /* @__PURE__ */ jsx2(
1246
+ activeFolder && canCreate && /* @__PURE__ */ jsxs4("div", { className: "mx-3 mb-2 flex shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-sm", children: [
1247
+ /* @__PURE__ */ jsx4(Folder, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
1248
+ /* @__PURE__ */ jsx4("span", { className: "shrink-0 text-muted-foreground", children: "New files go in" }),
1249
+ /* @__PURE__ */ jsx4("span", { "data-vault-folder": true, className: "min-w-0 flex-1 truncate font-medium text-foreground", title: activeFolder, children: activeFolder }),
1250
+ /* @__PURE__ */ jsx4(
967
1251
  "button",
968
1252
  {
969
1253
  type: "button",
@@ -974,47 +1258,62 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
974
1258
  }
975
1259
  )
976
1260
  ] }),
977
- /* @__PURE__ */ jsx2("div", { className: "min-h-0 flex-1 overflow-y-auto border-t border-border px-1.5 py-1.5", children: treeContent })
1261
+ /* @__PURE__ */ jsx4("div", { className: "min-h-0 flex-1 overflow-y-auto border-t border-border px-1.5 py-1.5", children: treeContent })
978
1262
  ]
979
1263
  }
980
1264
  ) }),
981
- /* @__PURE__ */ jsxs2(
1265
+ /* @__PURE__ */ jsxs4(
982
1266
  "div",
983
1267
  {
984
1268
  ref: documentRef,
985
1269
  role: "region",
986
1270
  "aria-label": `${label} document`,
987
1271
  tabIndex: -1,
988
- className: `${showFiles ? "hidden" : "flex"} min-w-0 flex-1 flex-col overflow-hidden @[45rem]/vault:flex`,
1272
+ className: `${showFiles ? "hidden" : "flex"} min-w-0 flex-1 flex-col overflow-hidden @[60rem]/vault:flex`,
989
1273
  children: [
990
- selectedFile && /* @__PURE__ */ jsxs2(ShellHeader, { className: `justify-between gap-2 px-4 ${pathBarClassName ?? "bg-card"}`, children: [
991
- /* @__PURE__ */ jsx2("span", { "data-vault-path": true, className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", children: selectedFile.path }),
992
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-1", children: [
993
- canWrite && isMarkdownCapable && /* @__PURE__ */ jsxs2("div", { className: "mr-1 flex items-center gap-1", children: [
994
- /* @__PURE__ */ jsx2(
1274
+ selectedFile && /* @__PURE__ */ jsxs4(ShellHeader, { className: `justify-between gap-2 px-4 ${pathBarClassName ?? "bg-card"}`, children: [
1275
+ /* @__PURE__ */ jsx4("span", { "data-vault-path": true, className: "min-w-0 flex-1 truncate text-sm font-medium text-foreground", children: selectedFile.path }),
1276
+ /* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-1", children: [
1277
+ canWrite && isMarkdownCapable && /* @__PURE__ */ jsxs4("div", { className: "mr-1 flex items-center gap-1", children: [
1278
+ /* @__PURE__ */ jsx4(
995
1279
  "button",
996
1280
  {
997
1281
  type: "button",
998
1282
  "aria-label": "Edit as rich text",
999
1283
  "aria-pressed": editorMode === "rich",
1000
1284
  onClick: showRichMode,
1001
- className: `inline-flex h-7 items-center rounded px-2 text-xs transition-colors ${editorMode === "rich" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1285
+ className: `inline-flex h-8 items-center rounded px-2.5 text-sm transition-colors ${editorMode === "rich" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1002
1286
  children: "Rich"
1003
1287
  }
1004
1288
  ),
1005
- /* @__PURE__ */ jsx2(
1289
+ /* @__PURE__ */ jsx4(
1006
1290
  "button",
1007
1291
  {
1008
1292
  type: "button",
1009
1293
  "aria-label": "Edit as source",
1010
1294
  "aria-pressed": editorMode === "source",
1011
1295
  onClick: showSourceMode,
1012
- className: `inline-flex h-7 items-center rounded px-2 text-xs transition-colors ${editorMode === "source" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1296
+ className: `inline-flex h-8 items-center rounded px-2.5 text-sm transition-colors ${editorMode === "source" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1013
1297
  children: "Source"
1014
1298
  }
1015
1299
  )
1016
1300
  ] }),
1017
- renderDock && (!persistentDock || dockInline) && /* @__PURE__ */ jsx2(
1301
+ canShowHistory && /* @__PURE__ */ jsxs4(
1302
+ "button",
1303
+ {
1304
+ type: "button",
1305
+ "aria-pressed": historyOpen,
1306
+ disabled: isDirty && !historyOpen,
1307
+ title: isDirty && !historyOpen ? "Save or discard your edits first" : "Saved versions of this file",
1308
+ onClick: () => setHistoryOpen((open) => !open),
1309
+ className: `inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-sm transition-colors disabled:pointer-events-none disabled:opacity-40 ${historyOpen ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1310
+ children: [
1311
+ /* @__PURE__ */ jsx4(History2, { className: "size-4", "aria-hidden": "true" }),
1312
+ "History"
1313
+ ]
1314
+ }
1315
+ ),
1316
+ renderDock && (!persistentDock || dockInline) && /* @__PURE__ */ jsx4(
1018
1317
  "button",
1019
1318
  {
1020
1319
  type: "button",
@@ -1023,12 +1322,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1023
1322
  disabled: dockBlockedByDraft,
1024
1323
  title: dockBlockedByDraft ? "Save your changes first" : persistentDock ? dockLabel : dockToggleCfg.title ?? dockToggleCfg.label,
1025
1324
  onClick: () => setDockOpen((v) => !v),
1026
- className: `inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs transition-colors disabled:pointer-events-none disabled:opacity-40 ${dockOpen ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1325
+ className: `inline-flex h-8 items-center gap-1 rounded px-2.5 text-sm transition-colors disabled:pointer-events-none disabled:opacity-40 ${dockOpen ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
1027
1326
  children: dockButtonLabel
1028
1327
  }
1029
1328
  ),
1030
1329
  fileActions?.(selectedFile),
1031
- onDownloadFile && /* @__PURE__ */ jsx2(
1330
+ onDownloadFile && /* @__PURE__ */ jsx4(
1032
1331
  "button",
1033
1332
  {
1034
1333
  type: "button",
@@ -1036,10 +1335,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1036
1335
  title: "Download file",
1037
1336
  onClick: () => onDownloadFile(selectedFile),
1038
1337
  className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
1039
- children: /* @__PURE__ */ jsx2(Download, { className: "h-4 w-4" })
1338
+ children: /* @__PURE__ */ jsx4(Download, { className: "h-4 w-4" })
1040
1339
  }
1041
1340
  ),
1042
- canDelete && /* @__PURE__ */ jsx2(
1341
+ canDelete && /* @__PURE__ */ jsx4(
1043
1342
  "button",
1044
1343
  {
1045
1344
  type: "button",
@@ -1050,12 +1349,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1050
1349
  setDeleteOpen(true);
1051
1350
  },
1052
1351
  className: "inline-flex h-7 w-7 items-center justify-center rounded text-[var(--surface-danger-text)] transition-colors hover:bg-destructive/10",
1053
- children: /* @__PURE__ */ jsx2(Trash2, { className: "h-4 w-4" })
1352
+ children: /* @__PURE__ */ jsx4(Trash2, { className: "h-4 w-4" })
1054
1353
  }
1055
1354
  )
1056
1355
  ] })
1057
1356
  ] }),
1058
- selectedFile && saveError && /* @__PURE__ */ jsx2(
1357
+ selectedFile && saveError && /* @__PURE__ */ jsx4(
1059
1358
  OperationErrorAlert,
1060
1359
  {
1061
1360
  message: saveError.message,
@@ -1064,7 +1363,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1064
1363
  onDismiss: () => setSaveError(null)
1065
1364
  }
1066
1365
  ),
1067
- readError && selectedFile?.path === resolvedSelectedPath && /* @__PURE__ */ jsx2(
1366
+ readError && selectedFile?.path === resolvedSelectedPath && /* @__PURE__ */ jsx4(
1068
1367
  OperationErrorAlert,
1069
1368
  {
1070
1369
  message: readError,
@@ -1073,7 +1372,31 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1073
1372
  onDismiss: () => setReadError(null)
1074
1373
  }
1075
1374
  ),
1076
- /* @__PURE__ */ jsx2("div", { className: "flex-1 overflow-hidden", children: fileLoading && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx2(EditorSkeleton, {}) : readError && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx2(ReadErrorState, { message: readError, onRetry: () => setReloadNonce((n) => n + 1) }) : selectedFile && renderDock && dockInline && dockOpen ? /* @__PURE__ */ jsx2("div", { "data-vault-dock": "inline", className: "flex h-full min-h-0 flex-col overflow-y-auto", children: renderDock({ file: selectedFile, open: true, onClose: () => setDockOpen(false), placement: "inline" }) }) : selectedFile && canWrite && isMarkdownCapable && editorMode === "source" ? /* @__PURE__ */ jsx2(
1375
+ /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-hidden", children: fileLoading && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx4(EditorSkeleton, {}) : readError && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx4(ReadErrorState, { message: readError, onRetry: () => setReloadNonce((n) => n + 1) }) : selectedFile && historyOpen && canShowHistory ? /* @__PURE__ */ jsx4(
1376
+ VaultHistoryPanel,
1377
+ {
1378
+ path: selectedFile.path,
1379
+ listRevisions,
1380
+ readRevision,
1381
+ canRestore: canWrite,
1382
+ renderPreview: (content, revision) => renderArtifact({
1383
+ file: { ...selectedFile, content },
1384
+ loading: false,
1385
+ mode: "rich",
1386
+ canWrite: false,
1387
+ richDraft: activeCodec.parse(content),
1388
+ dirty: false,
1389
+ onRichChange: () => {
1390
+ },
1391
+ onSave: () => {
1392
+ },
1393
+ saving: false,
1394
+ revision
1395
+ }),
1396
+ onRestore: restoreRevision,
1397
+ onClose: () => setHistoryOpen(false)
1398
+ }
1399
+ ) : selectedFile && renderDock && dockInline && dockOpen ? /* @__PURE__ */ jsx4("div", { "data-vault-dock": "inline", className: "flex h-full min-h-0 flex-col overflow-y-auto", children: renderDock({ file: selectedFile, open: true, onClose: () => setDockOpen(false), placement: "inline" }) }) : selectedFile && canWrite && isMarkdownCapable && editorMode === "source" ? /* @__PURE__ */ jsx4(
1077
1400
  SourceEditor,
1078
1401
  {
1079
1402
  path: selectedFile.path,
@@ -1091,8 +1414,9 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1091
1414
  richDraft,
1092
1415
  dirty: isDirty,
1093
1416
  onRichChange,
1094
- onSave: () => void saveCurrent()
1095
- }) : emptyState !== void 0 ? emptyState : /* @__PURE__ */ jsx2(DocumentEmptyState, { label, recent: recentToOffer, onOpen: (path) => guardedOpen(path) }) })
1417
+ onSave: () => void saveCurrent(),
1418
+ saving
1419
+ }) : emptyState !== void 0 ? emptyState : /* @__PURE__ */ jsx4(DocumentEmptyState, { label, recent: recentToOffer, onOpen: (path) => guardedOpen(path) }) })
1096
1420
  ]
1097
1421
  }
1098
1422
  )
@@ -1105,7 +1429,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1105
1429
  } : () => setDockOpen(false),
1106
1430
  placement: "side"
1107
1431
  }),
1108
- /* @__PURE__ */ jsx2(
1432
+ /* @__PURE__ */ jsx4(
1109
1433
  ConfirmDialog,
1110
1434
  {
1111
1435
  open: createOpen,
@@ -1119,8 +1443,8 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1119
1443
  setNewPath("");
1120
1444
  setCreateError(null);
1121
1445
  },
1122
- children: /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
1123
- /* @__PURE__ */ jsx2(
1446
+ children: /* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
1447
+ /* @__PURE__ */ jsx4(
1124
1448
  "input",
1125
1449
  {
1126
1450
  value: newPath,
@@ -1131,11 +1455,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1131
1455
  className: "h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground"
1132
1456
  }
1133
1457
  ),
1134
- createError && /* @__PURE__ */ jsx2("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: createError.message })
1458
+ createError && /* @__PURE__ */ jsx4("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: createError.message })
1135
1459
  ] })
1136
1460
  }
1137
1461
  ),
1138
- /* @__PURE__ */ jsx2(
1462
+ /* @__PURE__ */ jsx4(
1139
1463
  ConfirmDialog,
1140
1464
  {
1141
1465
  open: deleteOpen,
@@ -1149,10 +1473,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
1149
1473
  setDeleteOpen(false);
1150
1474
  setDeleteError(null);
1151
1475
  },
1152
- children: deleteError && /* @__PURE__ */ jsx2("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: deleteError.message })
1476
+ children: deleteError && /* @__PURE__ */ jsx4("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: deleteError.message })
1153
1477
  }
1154
1478
  ),
1155
- /* @__PURE__ */ jsx2(
1479
+ /* @__PURE__ */ jsx4(
1156
1480
  ConfirmDialog,
1157
1481
  {
1158
1482
  open: pendingNav !== null,
@@ -1177,28 +1501,43 @@ function SourceEditor({
1177
1501
  onChange,
1178
1502
  onSave
1179
1503
  }) {
1180
- return /* @__PURE__ */ jsxs2("div", { className: "flex h-full min-h-0 flex-col bg-background", children: [
1181
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
1182
- /* @__PURE__ */ jsx2("p", { className: "truncate font-mono text-xs text-muted-foreground", children: path }),
1183
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2", children: [
1184
- /* @__PURE__ */ jsx2("span", { className: "rounded-full border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground", children: dirty ? "Unsaved changes" : "Saved" }),
1185
- /* @__PURE__ */ jsx2(
1504
+ return /* @__PURE__ */ jsxs4("div", { className: "flex h-full min-h-0 flex-col bg-background", children: [
1505
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
1506
+ /* @__PURE__ */ jsx4("p", { className: "truncate font-mono text-sm text-muted-foreground", children: path }),
1507
+ /* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-2", children: [
1508
+ /* @__PURE__ */ jsx4(
1509
+ "span",
1510
+ {
1511
+ role: "status",
1512
+ "aria-live": "polite",
1513
+ className: `rounded-full border px-2.5 py-1 text-sm ${dirty ? "border-[var(--surface-warning-border)] bg-[var(--surface-warning-bg)] text-[var(--surface-warning-text)]" : "border-border bg-background text-muted-foreground"}`,
1514
+ children: saving ? "Saving\u2026" : dirty ? "Unsaved changes" : "Saved"
1515
+ }
1516
+ ),
1517
+ (dirty || saving) && /* @__PURE__ */ jsx4(
1186
1518
  "button",
1187
1519
  {
1188
1520
  type: "button",
1189
1521
  onClick: onSave,
1190
- disabled: saving || !dirty,
1191
- className: "inline-flex h-7 items-center rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
1192
- children: saving ? "Saving\u2026" : "Save"
1522
+ disabled: saving,
1523
+ title: "Save (Ctrl+S)",
1524
+ className: "inline-flex h-8 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
1525
+ children: "Save"
1193
1526
  }
1194
1527
  )
1195
1528
  ] })
1196
1529
  ] }),
1197
- /* @__PURE__ */ jsx2(
1530
+ /* @__PURE__ */ jsx4(
1198
1531
  "textarea",
1199
1532
  {
1200
1533
  value: content,
1201
1534
  onChange: (event) => onChange(event.target.value),
1535
+ onKeyDown: (event) => {
1536
+ if ((event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "s") {
1537
+ event.preventDefault();
1538
+ if (dirty && !saving) onSave();
1539
+ }
1540
+ },
1202
1541
  spellCheck: false,
1203
1542
  "aria-label": "Source editor",
1204
1543
  className: "min-h-0 flex-1 resize-none border-0 bg-background p-4 font-mono text-sm leading-6 text-foreground focus-visible:[outline-offset:-2px]"
@@ -1211,4 +1550,4 @@ export {
1211
1550
  ConfirmDialog,
1212
1551
  VaultPane
1213
1552
  };
1214
- //# sourceMappingURL=chunk-RQSNTJTW.js.map
1553
+ //# sourceMappingURL=chunk-MO7PDQRZ.js.map