@arbidocs/react 0.4.58 → 0.4.60

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.
@@ -57,14 +57,22 @@ interface UseRedlineResult {
57
57
  declare function useRedline({ baseText, compareText, isLoading, withRegions, engine, }: UseRedlineOptions): UseRedlineResult;
58
58
 
59
59
  /**
60
- * Version lineage of an artifact. Every save creates a NEW document whose `parent_ext_id` is the
61
- * version it was saved from, so a lineage is a tree (a save from an old version is a deliberate
62
- * branch). Computed from a document list the host already has; no extra request.
60
+ * Versions of a document. Every save creates a NEW immutable document in the same lineage
61
+ * (`lineage_id`), numbered 1..n (`version_number`); the lineage says which one is current
62
+ * (`is_current`). Workspace lists hold current versions only, so a document's full history comes
63
+ * from `GET /v1/document/{id}/versions` (`arbi.documents.versions`).
63
64
  */
64
- /** The fields of a workspace document the lineage needs (structurally a subset of the API type). */
65
+ /** The fields of a workspace document the version list needs (a subset of the API type). */
65
66
  interface VersionedDoc {
66
67
  external_id?: string | null;
67
- parent_ext_id?: string | null;
68
+ lineage_id?: string | null;
69
+ version_number?: number | null;
70
+ is_current?: boolean | null;
71
+ /** Provenance: an `edit`/`sync` entry names the version this one was saved from. */
72
+ derived_from?: readonly {
73
+ doc_ext_id: string;
74
+ role: string;
75
+ }[] | null;
68
76
  file_name?: string | null;
69
77
  created_at?: string | null;
70
78
  }
@@ -75,19 +83,23 @@ interface ArtifactVersion {
75
83
  name: string;
76
84
  /** ISO timestamp. */
77
85
  createdAt: string;
78
- /** The version this one was saved from. */
79
- parentId?: string | null;
86
+ /** 1-based version number within the document. */
87
+ number: number;
88
+ /** The version this one was saved from (an older one than the previous version when restored). */
89
+ savedFromId?: string | null;
80
90
  }
91
+ /** The version a document was saved from, from its `edit`/`sync` provenance. */
92
+ declare function savedFromId(doc: VersionedDoc): string | null;
81
93
  /**
82
- * The whole lineage of `docId` (root first, then oldest to newest), or `[]` when the document is
83
- * not in `docs`. Cycle-safe.
94
+ * The versions of `docId`'s document that are in `docs` (same `lineage_id`), oldest first, or `[]`
95
+ * when the document is not in `docs`.
84
96
  */
85
97
  declare function buildVersionChain<T extends VersionedDoc>(docs: readonly T[], docId: string | null | undefined): T[];
86
- /** The lineage of `docId` as plain version rows. */
98
+ /** Version documents (oldest first) as plain version rows. */
87
99
  declare function toArtifactVersions(chain: readonly VersionedDoc[]): ArtifactVersion[];
88
100
  /**
89
- * "v2": the 1-based position of `docId` in its lineage. `null` when there is nothing to tell apart
90
- * (the lineage is just this document, or it is unknown), so unversioned documents stay unlabelled.
101
+ * "v2": the version number of `docId`. `null` when there is nothing to tell apart (the document
102
+ * has a single version, or it is unknown), so unversioned documents stay unlabelled.
91
103
  */
92
104
  declare function versionLabel(versions: readonly ArtifactVersion[], docId: string | null | undefined): string | null;
93
105
  /**
@@ -128,7 +140,7 @@ interface ArtifactEditSessionOptions {
128
140
  startEditing?: boolean;
129
141
  initialContent?: string;
130
142
  /** The version this one was saved from. Offering "compare with previous" needs it. */
131
- parentId?: string | null;
143
+ savedFromId?: string | null;
132
144
  /** Controlled comparison target. Omit for an uncontrolled one the session owns. */
133
145
  compareId?: string | null;
134
146
  onCompareChange?: (id: string | null) => void;
@@ -236,22 +248,25 @@ declare function useArtifactText(docId: string | null | undefined, options?: {
236
248
  retry?: ArtifactTextRetry;
237
249
  }): ArtifactText;
238
250
 
239
- /** The version lineage of an artifact in a workspace, oldest first. */
251
+ /**
252
+ * The versions of an artifact, oldest first. A current document at version 1 has no history, so it
253
+ * is answered from the workspace list; anything else asks for the document's version list.
254
+ */
240
255
  declare function useArtifactVersions(workspaceId: string | undefined, docId: string | null | undefined): ArtifactVersion[];
241
256
  interface SaveArtifactVersionInput {
242
257
  /** File name of the new version (`.md` is added when missing). */
243
258
  title: string;
244
259
  content: string;
245
- /** The version this one is saved from; omit for a first version. */
246
- parentId?: string | null;
260
+ /** Save as the next version of this document (any version's id); omit for a new document. */
261
+ versionOf?: string | null;
247
262
  /** The processing config (auto-title, parsing) to run the upload with. */
248
263
  configId?: string | null;
249
264
  /** `artifact` (default) for AI-style drafts; `source` for a document the user typed. */
250
265
  wpType?: 'artifact' | 'source';
251
266
  }
252
267
  /**
253
- * Save markdown as a NEW immutable version (a child document of `parentId`) and refresh the
254
- * workspace document list so the version list picks it up. The id of the new version is often not
268
+ * Save markdown as a NEW immutable version (the next version of `versionOf`'s document) and refresh
269
+ * the workspace document list and version lists so they pick it up. The id of the new version is often not
255
270
  * known yet (the document is parsed asynchronously); it then arrives through the list.
256
271
  */
257
272
  declare function useSaveArtifactVersion(): _tanstack_react_query.UseMutationResult<ArtifactSaveResult, Error, SaveArtifactVersionInput & {
@@ -411,4 +426,4 @@ interface StreamedArtifact {
411
426
  */
412
427
  declare function useStreamedArtifact({ artifacts, workspaceId, settled, clean, onCleaned, configId, parseRetry, }: UseStreamedArtifactOptions): StreamedArtifact;
413
428
 
414
- export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc, buildVersionChain, flattenChunks, isDocumentId, mainThreadRedlineEngine, renderArtifactMarkdown, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel };
429
+ export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc, buildVersionChain, flattenChunks, isDocumentId, mainThreadRedlineEngine, renderArtifactMarkdown, savedFromId, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel };
@@ -57,14 +57,22 @@ interface UseRedlineResult {
57
57
  declare function useRedline({ baseText, compareText, isLoading, withRegions, engine, }: UseRedlineOptions): UseRedlineResult;
58
58
 
59
59
  /**
60
- * Version lineage of an artifact. Every save creates a NEW document whose `parent_ext_id` is the
61
- * version it was saved from, so a lineage is a tree (a save from an old version is a deliberate
62
- * branch). Computed from a document list the host already has; no extra request.
60
+ * Versions of a document. Every save creates a NEW immutable document in the same lineage
61
+ * (`lineage_id`), numbered 1..n (`version_number`); the lineage says which one is current
62
+ * (`is_current`). Workspace lists hold current versions only, so a document's full history comes
63
+ * from `GET /v1/document/{id}/versions` (`arbi.documents.versions`).
63
64
  */
64
- /** The fields of a workspace document the lineage needs (structurally a subset of the API type). */
65
+ /** The fields of a workspace document the version list needs (a subset of the API type). */
65
66
  interface VersionedDoc {
66
67
  external_id?: string | null;
67
- parent_ext_id?: string | null;
68
+ lineage_id?: string | null;
69
+ version_number?: number | null;
70
+ is_current?: boolean | null;
71
+ /** Provenance: an `edit`/`sync` entry names the version this one was saved from. */
72
+ derived_from?: readonly {
73
+ doc_ext_id: string;
74
+ role: string;
75
+ }[] | null;
68
76
  file_name?: string | null;
69
77
  created_at?: string | null;
70
78
  }
@@ -75,19 +83,23 @@ interface ArtifactVersion {
75
83
  name: string;
76
84
  /** ISO timestamp. */
77
85
  createdAt: string;
78
- /** The version this one was saved from. */
79
- parentId?: string | null;
86
+ /** 1-based version number within the document. */
87
+ number: number;
88
+ /** The version this one was saved from (an older one than the previous version when restored). */
89
+ savedFromId?: string | null;
80
90
  }
91
+ /** The version a document was saved from, from its `edit`/`sync` provenance. */
92
+ declare function savedFromId(doc: VersionedDoc): string | null;
81
93
  /**
82
- * The whole lineage of `docId` (root first, then oldest to newest), or `[]` when the document is
83
- * not in `docs`. Cycle-safe.
94
+ * The versions of `docId`'s document that are in `docs` (same `lineage_id`), oldest first, or `[]`
95
+ * when the document is not in `docs`.
84
96
  */
85
97
  declare function buildVersionChain<T extends VersionedDoc>(docs: readonly T[], docId: string | null | undefined): T[];
86
- /** The lineage of `docId` as plain version rows. */
98
+ /** Version documents (oldest first) as plain version rows. */
87
99
  declare function toArtifactVersions(chain: readonly VersionedDoc[]): ArtifactVersion[];
88
100
  /**
89
- * "v2": the 1-based position of `docId` in its lineage. `null` when there is nothing to tell apart
90
- * (the lineage is just this document, or it is unknown), so unversioned documents stay unlabelled.
101
+ * "v2": the version number of `docId`. `null` when there is nothing to tell apart (the document
102
+ * has a single version, or it is unknown), so unversioned documents stay unlabelled.
91
103
  */
92
104
  declare function versionLabel(versions: readonly ArtifactVersion[], docId: string | null | undefined): string | null;
93
105
  /**
@@ -128,7 +140,7 @@ interface ArtifactEditSessionOptions {
128
140
  startEditing?: boolean;
129
141
  initialContent?: string;
130
142
  /** The version this one was saved from. Offering "compare with previous" needs it. */
131
- parentId?: string | null;
143
+ savedFromId?: string | null;
132
144
  /** Controlled comparison target. Omit for an uncontrolled one the session owns. */
133
145
  compareId?: string | null;
134
146
  onCompareChange?: (id: string | null) => void;
@@ -236,22 +248,25 @@ declare function useArtifactText(docId: string | null | undefined, options?: {
236
248
  retry?: ArtifactTextRetry;
237
249
  }): ArtifactText;
238
250
 
239
- /** The version lineage of an artifact in a workspace, oldest first. */
251
+ /**
252
+ * The versions of an artifact, oldest first. A current document at version 1 has no history, so it
253
+ * is answered from the workspace list; anything else asks for the document's version list.
254
+ */
240
255
  declare function useArtifactVersions(workspaceId: string | undefined, docId: string | null | undefined): ArtifactVersion[];
241
256
  interface SaveArtifactVersionInput {
242
257
  /** File name of the new version (`.md` is added when missing). */
243
258
  title: string;
244
259
  content: string;
245
- /** The version this one is saved from; omit for a first version. */
246
- parentId?: string | null;
260
+ /** Save as the next version of this document (any version's id); omit for a new document. */
261
+ versionOf?: string | null;
247
262
  /** The processing config (auto-title, parsing) to run the upload with. */
248
263
  configId?: string | null;
249
264
  /** `artifact` (default) for AI-style drafts; `source` for a document the user typed. */
250
265
  wpType?: 'artifact' | 'source';
251
266
  }
252
267
  /**
253
- * Save markdown as a NEW immutable version (a child document of `parentId`) and refresh the
254
- * workspace document list so the version list picks it up. The id of the new version is often not
268
+ * Save markdown as a NEW immutable version (the next version of `versionOf`'s document) and refresh
269
+ * the workspace document list and version lists so they pick it up. The id of the new version is often not
255
270
  * known yet (the document is parsed asynchronously); it then arrives through the list.
256
271
  */
257
272
  declare function useSaveArtifactVersion(): _tanstack_react_query.UseMutationResult<ArtifactSaveResult, Error, SaveArtifactVersionInput & {
@@ -411,4 +426,4 @@ interface StreamedArtifact {
411
426
  */
412
427
  declare function useStreamedArtifact({ artifacts, workspaceId, settled, clean, onCleaned, configId, parseRetry, }: UseStreamedArtifactOptions): StreamedArtifact;
413
428
 
414
- export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc, buildVersionChain, flattenChunks, isDocumentId, mainThreadRedlineEngine, renderArtifactMarkdown, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel };
429
+ export { type ArtifactEditSession, type ArtifactEditSessionOptions, type ArtifactRedlineComponents, type ArtifactSaveResult, type ArtifactSession, type ArtifactSessionOptions, type ArtifactSessionView, type ArtifactText, type ArtifactTextRetry, type ArtifactTextStatus, type ArtifactVersion, DEFAULT_ARTIFACT_TEXT_RETRY, DraftCleanReport, type RedlineEngine, RedlineRegion, type RedlineState, RedlineWithRegions, type SaveArtifactVersionInput, type StreamedArtifact, type StreamedArtifactPhase, type UseRedlineOptions, type UseRedlineResult, type UseStreamedArtifactOptions, type VersionedDoc, buildVersionChain, flattenChunks, isDocumentId, mainThreadRedlineEngine, renderArtifactMarkdown, savedFromId, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel };
@@ -1,10 +1,10 @@
1
- import { repairParsedStructure, repairParsedTitle, unescapeMarkdown, arbiQueryKeys, useDocuments, cleanDraftWithReport } from '../chunk-GT6KN3DV.js';
2
- export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from '../chunk-GT6KN3DV.js';
1
+ import { repairParsedStructure, repairParsedTitle, unescapeMarkdown, arbiQueryKeys, useDocuments, useDocumentVersionList, cleanDraftWithReport } from '../chunk-DSG3E7QX.js';
2
+ export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from '../chunk-DSG3E7QX.js';
3
3
  import { revertRedlineRegion, buildHybridRedlineWithRegions, buildHybridRedlineMarkdown, normalizeMarkdown } from '../chunk-43AKLNBC.js';
4
4
  export { buildHybridRedlineMarkdown, buildHybridRedlineWithRegions, normalizeMarkdown, revertRedlineRegion } from '../chunk-43AKLNBC.js';
5
- import { useArbi } from '../chunk-J4MX2W4H.js';
6
5
  import { MarkdownRenderer } from '../chunk-JPGV7NMY.js';
7
6
  import '../chunk-SN5YV6FF.js';
7
+ import { useArbi } from '../chunk-J4MX2W4H.js';
8
8
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
9
9
  import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
10
10
  import { jsx } from 'react/jsx-runtime';
@@ -81,54 +81,33 @@ function useRedline({
81
81
  }
82
82
 
83
83
  // src/artifacts/versions.ts
84
+ function savedFromId(doc) {
85
+ return doc.derived_from?.find((d) => d.role === "edit" || d.role === "sync")?.doc_ext_id ?? null;
86
+ }
84
87
  function buildVersionChain(docs, docId) {
85
88
  if (!docId) return [];
86
- const byId = /* @__PURE__ */ new Map();
87
- for (const d of docs) if (d.external_id) byId.set(d.external_id, d);
88
- const current = byId.get(docId);
89
- if (!current) return [];
90
- let root = current;
91
- const up = /* @__PURE__ */ new Set();
92
- while (root.parent_ext_id && byId.has(root.parent_ext_id) && root.external_id && !up.has(root.external_id)) {
93
- up.add(root.external_id);
94
- root = byId.get(root.parent_ext_id);
95
- }
96
- const byParent = /* @__PURE__ */ new Map();
97
- for (const d of docs) {
98
- if (d.parent_ext_id) {
99
- const siblings = byParent.get(d.parent_ext_id) ?? [];
100
- siblings.push(d);
101
- byParent.set(d.parent_ext_id, siblings);
102
- }
103
- }
104
- const out = [];
105
- const visited = /* @__PURE__ */ new Set();
106
- const walk = (d) => {
107
- if (!d.external_id || visited.has(d.external_id)) return;
108
- visited.add(d.external_id);
109
- out.push(d);
110
- for (const child of byParent.get(d.external_id) ?? []) walk(child);
111
- };
112
- walk(root);
113
- out.sort((a, b) => (a.created_at ?? "").localeCompare(b.created_at ?? ""));
114
- return out;
89
+ const doc = docs.find((d) => d.external_id === docId);
90
+ if (!doc) return [];
91
+ if (!doc.lineage_id) return [doc];
92
+ return docs.filter((d) => d.lineage_id === doc.lineage_id).sort((a, b) => (a.version_number ?? 1) - (b.version_number ?? 1));
115
93
  }
116
94
  function toArtifactVersions(chain) {
117
95
  return chain.flatMap(
118
- (d) => d.external_id ? [
96
+ (d, i) => d.external_id ? [
119
97
  {
120
98
  id: d.external_id,
121
99
  name: d.file_name ?? "",
122
100
  createdAt: d.created_at ?? "",
123
- parentId: d.parent_ext_id
101
+ number: d.version_number ?? i + 1,
102
+ savedFromId: savedFromId(d)
124
103
  }
125
104
  ] : []
126
105
  );
127
106
  }
128
107
  function versionLabel(versions, docId) {
129
108
  if (!docId || versions.length <= 1) return null;
130
- const index = versions.findIndex((v) => v.id === docId);
131
- return index === -1 ? null : `v${index + 1}`;
109
+ const version = versions.find((v) => v.id === docId);
110
+ return version ? `v${version.number}` : null;
132
111
  }
133
112
  function flattenChunks(chunks, options) {
134
113
  const text = (chunks ?? []).map((c) => (c.content ?? "").trim()).join("\n\n");
@@ -147,7 +126,7 @@ function useArtifactEditSession(options) {
147
126
  baseline: loadedBaseline,
148
127
  startEditing = false,
149
128
  initialContent,
150
- parentId,
129
+ savedFromId: savedFromId2,
151
130
  compareId: controlledCompareId,
152
131
  onCompareChange,
153
132
  compareText,
@@ -209,10 +188,10 @@ function useArtifactEditSession(options) {
209
188
  }, [stopCompare]);
210
189
  const compare = useCallback(
211
190
  (id) => {
212
- const target = id ?? parentId;
191
+ const target = id ?? savedFromId2;
213
192
  if (target) setCompareId(target);
214
193
  },
215
- [parentId, setCompareId]
194
+ [savedFromId2, setCompareId]
216
195
  );
217
196
  const hasBaseline = baseline !== "";
218
197
  useEffect(() => {
@@ -283,7 +262,7 @@ function useArtifactEditSession(options) {
283
262
  content,
284
263
  hasChanges,
285
264
  isSaving,
286
- canCompare: !!parentId && !compareId,
265
+ canCompare: !!savedFromId2 && !compareId,
287
266
  compareId,
288
267
  showTrackChanges,
289
268
  redline,
@@ -303,7 +282,7 @@ function useArtifactEditSession(options) {
303
282
  content,
304
283
  hasChanges,
305
284
  isSaving,
306
- parentId,
285
+ savedFromId2,
307
286
  compareId,
308
287
  showTrackChanges,
309
288
  redline,
@@ -385,29 +364,33 @@ function useArtifactText(docId, options) {
385
364
  // src/artifacts/useArtifactSession.ts
386
365
  function useArtifactVersions(workspaceId, docId) {
387
366
  const { data: documents } = useDocuments(workspaceId);
367
+ const listed = useMemo(() => buildVersionChain(documents ?? [], docId), [documents, docId]);
368
+ const single = listed.length === 1 && (listed[0].version_number ?? 1) <= 1;
369
+ const { data: history } = useDocumentVersionList(docId, { enabled: !!docId && !single });
388
370
  return useMemo(
389
- () => toArtifactVersions(buildVersionChain(documents ?? [], docId)),
390
- [documents, docId]
371
+ () => toArtifactVersions(single || !history ? listed : history),
372
+ [single, history, listed]
391
373
  );
392
374
  }
393
375
  function useSaveArtifactVersion() {
394
376
  const arbi = useArbi();
395
377
  const queryClient = useQueryClient();
396
378
  return useMutation({
397
- mutationFn: async ({ title, content, parentId, configId, wpType, workspaceId }) => {
379
+ mutationFn: async ({ title, content, versionOf, configId, wpType, workspaceId }) => {
398
380
  const fileName = /\.md$/i.test(title) ? title : `${title}.md`;
399
381
  const result = await arbi.documents.uploadFile(
400
382
  new Blob([content], { type: "text/markdown" }),
401
383
  fileName,
402
384
  {
403
385
  wpType: wpType ?? "artifact",
404
- parentExtId: parentId ?? void 0,
386
+ versionOf: versionOf ?? void 0,
405
387
  configExtId: configId ?? void 0
406
388
  }
407
389
  );
408
390
  if (workspaceId) {
409
391
  await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documents(workspaceId) });
410
392
  }
393
+ await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.allDocumentVersions() });
411
394
  return { docId: result.doc_ext_ids?.[0] };
412
395
  }
413
396
  });
@@ -449,11 +432,12 @@ function useArtifactSession(options) {
449
432
  const result = await saveVersion.mutateAsync({
450
433
  title: title ?? current?.name ?? "Untitled",
451
434
  content,
452
- parentId: isLocal ? null : docId,
435
+ versionOf: isLocal ? null : docId,
453
436
  configId,
454
437
  workspaceId
455
438
  });
456
- return { ...result, version: isLocal ? 1 : versions.length + 1 };
439
+ const latest = versions.reduce((n, v) => Math.max(n, v.number), 0);
440
+ return { ...result, version: isLocal ? 1 : latest + 1 };
457
441
  },
458
442
  [saveVersion, title, current?.name, isLocal, docId, configId, workspaceId, versions.length]
459
443
  );
@@ -471,7 +455,7 @@ function useArtifactSession(options) {
471
455
  // A local draft has only its own text; a just-saved one shows what was saved until the parsed
472
456
  // text of the new document arrives.
473
457
  baseline: text ?? (isLocal ? draftContent : adopted?.text),
474
- parentId: current?.parentId,
458
+ savedFromId: current?.savedFromId,
475
459
  compareId: activeCompareId,
476
460
  onCompareChange: changeCompare,
477
461
  compareText,
@@ -593,6 +577,6 @@ function useStreamedArtifact({
593
577
  return { phase, artifact, docId, error, cleaned, retry };
594
578
  }
595
579
 
596
- export { DEFAULT_ARTIFACT_TEXT_RETRY, buildVersionChain, flattenChunks, isDocumentId, mainThreadRedlineEngine, renderArtifactMarkdown, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel };
580
+ export { DEFAULT_ARTIFACT_TEXT_RETRY, buildVersionChain, flattenChunks, isDocumentId, mainThreadRedlineEngine, renderArtifactMarkdown, savedFromId, toArtifactVersions, useArtifactEditSession, useArtifactSession, useArtifactText, useArtifactVersions, useRedline, useSaveArtifactVersion, useStreamedArtifact, versionLabel };
597
581
  //# sourceMappingURL=index.js.map
598
582
  //# sourceMappingURL=index.js.map