super-productivity/packages/plugin-dev/document-mode
Johannes Millan cc3d9eaaec fix(document-mode): rebuild top-level chips in ctx.taskIds order
Diagnostic showed: in TODAY the chip *set* matched ctx.taskIds, but the
*order* didn't — saved-doc order won, while the regular TODAY view uses
ctx.taskIds (TODAY_TAG.taskIds). Plus the stored doc had duplicate
subtask rows under several parents (a residue of an earlier bug).

Rewrite reconcileTopLevelTaskRefs:

  - Pass 1 walks the stored content. For each parent taskRef it
    collects the parent + its trailing subTaskRef run as a "group",
    deduping subtasks within the group by taskId. The first stored
    group for a given parent wins; later duplicate groups for the
    same parent are dropped. Non-chip blocks (paragraphs, dividers,
    extra headings) are stashed; the first heading is preserved as
    the doc title at the top. Orphan subTaskRefs are dropped.

  - Pass 2 rebuilds the doc content. The title heading stays first.
    Chip groups follow ctx.taskIds order strictly — stored group if
    we have one, fresh from taskRefWithSubtasksJSON if the parent
    is new to this context. Custom non-chip blocks land at the end
    in their original relative order so they aren't lost.

Trade-off (documented in ADR #5 Open Limitations): paragraphs the
user had interleaved between chips lose their original anchor and
end up at the tail. The previous behaviour preserved their position
but at the cost of stale ordering and visible duplicates, which is
worse.

Also removed the temporary diagnostic console.logs.
2026-05-21 22:51:32 +02:00
..
scripts feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00
src fix(document-mode): rebuild top-level chips in ctx.taskIds order 2026-05-21 22:51:32 +02:00
.gitignore feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00
package-lock.json feat(document-mode): Notion-style UX (gutter, bubble menu, block menu) 2026-05-21 17:34:13 +02:00
package.json feat(document-mode): Notion-style UX (gutter, bubble menu, block menu) 2026-05-21 17:34:13 +02:00
tsconfig.json feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00