Track datasetRefs against the live draft so manual edits and extract link immediately

This commit is contained in:
2026-06-07 23:54:01 +03:00
parent cdd5cf149f
commit 7d247e8d2c
8 changed files with 183 additions and 57 deletions
+4 -3
View File
@@ -283,8 +283,8 @@ export function reassignCollidingSnippetIds(
* Propagate dataset renames (from `dedupeIncomingDatasetNames`) into the imported
* snippets that reference them (architecture 07 §6): for each rename, rewrite both
* `spec` and `draftSpec` via `renameDatasetInSpec`, then recompute `datasetRefs`
* from the rewritten spec — the spec is the source of truth, `datasetRefs` mirrors
* it. Matching is case-insensitive (consistent with the naming helpers). Only
* from the rewritten draft — the draft is the source of truth, `datasetRefs`
* mirrors it. Matching is case-insensitive (consistent with the naming helpers). Only
* snippets that actually change are cloned.
*
* Applied to the imported set ONLY — existing snippets keep their references,
@@ -323,7 +323,8 @@ export function applyDatasetRenamesToSnippets(
draftSpec = renameDatasetInSpec(draftSpec, oldName, to);
}
return { ...snippet, spec, draftSpec, datasetRefs: recomputeDatasetRefs(spec) };
// datasetRefs mirrors the draft — the version the editor shows (arch 07 §3).
return { ...snippet, spec, draftSpec, datasetRefs: recomputeDatasetRefs(draftSpec) };
});
}
+3 -1
View File
@@ -40,7 +40,9 @@ export interface Snippet {
comment: string;
/** User-assigned labels. */
tags: string[];
/** Names of datasets referenced by this spec (maintained on publish). */
/** Names of datasets referenced by the draft spec; mirrors the version being
* edited, recomputed on every draft change (create/auto-save/extract/revert)
* and on publish (docs/architecture/07 §3). */
datasetRefs: string[];
/** Free-form, extensible metadata bag. */
meta: Record<string, unknown>;