fix(edit): balance id unions when a record is deleted

Deleting a record in edit mode removed the structure row and its text but left the id union member in src/types/index.ts, so Record<SkillGroupId, SkillGroupText> rejected the shortened text document (TS2741) and pnpm build failed. draft.ts: readUnionBlock reads a union as its declaration span (CRLF/LF safe, never round-trips), diffIdsWithUnions reports missing and stale members against committedStructures(), applyUnionChanges rewrites only that member list in one PUT; newIdsInCommitted/patchUnionSource removed. types/index.ts drops logistics-technology. Verified: smoke-draft 12/12 (new checks 9-12), validate:content, lint (no new warnings), build.
This commit is contained in:
dong.nguyen committed 2026-10-24 10:08:58 +07:00
1 parent a0a1451272
commit 150ef90c73
8 files changed
+235 -41

No files matched your search

+2 -1
View File
@@ -281,7 +281,8 @@ export default function EditModeShell({ children }: { children: ReactNode }) {
const conflicted = results.filter((r) => r.status === 'conflict').map((r) => r.id);
setConflicts((prev) => [...new Set([...prev.filter((id) => !written.has(id)), ...conflicted])]);
// The third leg of §3.1: append ids whose documents landed to their unions.
// The third leg of §3.1: bring the unions to the ids whose documents
// landed — appended when a record was added, dropped when one was deleted.
const types = typesRef.current;
if (types) {
const union = await saveIdUnions(store, types, branch);