Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/roam/src/components/settings/utils/zodSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const IndexSchema = z.object({
type RoamNode = {
text: string;
children?: RoamNode[];
uid?: string;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing uid here fixes ENG-1842:

  • RoamNodeSchema is only used for DiscourseNodeSchema.template
  • The optional uid let migration store legacy template trees with their block uids in block props
  • ENG-1454: Base getter() task #828's Template panel seeds an ephemeral buffer from that stored template → create-block replays the old uids → Block already exists (the originals still live under legacy Template) → buffer never created → panel dead. Shipped in v0.19.0, hence "suddenly broken"
  • Nothing reads template uids from the store: panel save (serializeBlockTree) and createBlocksFromTemplate (stripTemplateUids) both strip them already
  • Zod drops unknown keys on parse, so removal fixes both directions:
    • read: already-poisoned graphs get clean templates immediately, no data migration
    • write: future migrations store uid-free
  • Alternative was stripping in EphemeralBlocksPanel, but that patches one consumer and leaves the next one to hit the same landmine
  • Legacy mode (flag off) reads the live block tree and never touches this schema; fresh graphs were never poisoned

heading?: 0 | 1 | 2 | 3;
open?: boolean;
};
Expand All @@ -66,7 +65,6 @@ export const RoamNodeSchema: z.ZodType<RoamNode> = z.lazy(() =>
z.object({
text: z.string(),
children: RoamNodeSchema.array().optional(),
uid: z.string().optional(),
heading: z
.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)])
.optional(),
Expand Down