Repository navigation
Description
Bug
In the id web editor's markdown ↔ ProseMirror codec (pkgs/id/src/web/markdown.rs), link reference definitions that are not used by a link in the document are silently deleted on save:
body text
[unused]: https://example.comloads and saves as just:
body textThe extreme case is total: a document consisting only of reference definitions (a shared "link library" page, or a draft whose links are added later)
[a]: https://a.com
[b]: https://b.comloads as an empty document and saves as an empty file.
Definitions that are used survive in substance — full ([one][r]), collapsed ([text][]) and shortcut ([ref]) references all round-trip, with the reference inlined as [text](url) and the definition consumed. So the loss is specifically: any definition whose label no link in the current document references.
Verified repro (this run, main 3b9d159)
Standalone verbatim-codec probe (evidence log: goal hidden_files/probe-2026-10-26-1415/out4.log):
unused-ref-def:"body text\n\n[unused]: https://example.com\n"→ PM is a single paragraphbody text(the definition appears nowhere) → save returns"body text\n".ref-def-only-doc:"[a]: https://a.com\n[b]: https://b.com\n"→ PM is the empty-document placeholder paragraph → save returns""(empty file).- Controls (same log):
shortcut-ref,collapsed-ref,multi-ref-same— used definitions round-trip correctly as inlined links.
Why it happens / why it matters
The ProseMirror schema the codec targets has no node for a reference definition, and comrak resolves definitions during parsing without surfacing unused ones as AST nodes — so the parse direction has nowhere to put them and they vanish before the editor ever sees the document. Keeping a block of reference definitions at the foot of a note for later use is a standard markdown authoring pattern; opening such a file in the id web editor and saving (even with no edit) destroys that block with no warning. Same silent-loss-on-save family as #996 (empty links), in a distinct mechanism.
Suggested direction (triage to decide)
The fix needs a deliberate design choice, e.g.: (a) preserve unused definitions verbatim — the parse direction would need a source pre-scan for reference definitions, diff them against the labels comrak actually consumed, and carry the leftovers (e.g. as a trailing raw block the editor displays but does not eat); (b) represent definitions in the PM doc (a dedicated node) — cleaner but touches the editor schema; or (c) if neither is acceptable, document the limitation where the codec's schema is described (module doc comment at the top of markdown.rs) so the loss is at least a known, stated behaviour instead of a silent one. Doing nothing silently is the only unacceptable outcome.
Acceptance criteria
- A document with an unused reference definition no longer loses it silently on a load/save round trip — either the definition survives (verbatim or in an equivalent reference form), or the limitation is explicitly documented in the codec module docs and this issue is closed citing that documentation.
- Used references (full, collapsed, shortcut, multiple links sharing one definition) keep round-tripping exactly as today.
- A definitions-only document does not save as an empty file under the chosen fix (or is covered by the documented limitation).
- Existing
web::markdowntests pass.
Activity
developing-today commentedon Oct 26, 2026
CODE-175
dezren39 commentedon Oct 26, 2026
🤖 Agent note · filed
hidden_files/probe-2026-10-26-1415/out4.log, casesunused-ref-def/ref-def-only-doc): link reference definitions no link uses never reach the ProseMirror doc and are deleted on save; a definitions-only document saves as an empty file. Used references (full/collapsed/shortcut controls in the same log) round-trip fine. Enqueued as a triage packet to repo-health-code-pilot — this one needs a design decision (preserve, represent, or explicitly document), not a quick patch.177 remaining items
dezren39 commentedon Nov 11, 2026
agent-note:v1
event: blocked
task: 14704; worker repo-worker-code; scheduled lane 02cafe76-eafd-4d0b-aaa6-2b7a737d68dc
state: PR #7170 and #5949 both remain open for this issue; earlier triage called #5949 canonical and #7170 duplicate, while task 14704 has subsequently advanced #7170. Issue already has user/escalated. PR #7170 is Drew-authored and this lane cannot modify it. No PR changed.
resume: establish the canonical ownership/disposition between both PRs, then reassess CI and review feedback.
dezren39 commentedon Nov 11, 2026
agent-note:v1
state: parked — CI wait
task: 14767
lane: code-o
issue: #1004
pr: #5949
Fresh Codex round on head f1f736b (3 P2s) dispositioned in 0f25337: front-matter boundaries now match comrak split_off_front_matter exactly; multiline blockquoted definition labels strip containers from every line before keying; find_balanced_label_close skips inline code spans. One regression test per finding (each failed before, passes after); full web::markdown suite 279 passed (cargo test --lib --features web). Disposition comment on PR #5949 (6786142186); all review threads resolved.
Parked as a broker CI wait on PR #5949 at head 0f25337 (checks queued in the Actions stall). Resume: checks green + fresh Codex round clean -> merge PR #5949, verify #1004/#8355 closed by the merge, complete task 14767.
dezren39 commentedon Nov 12, 2026
Task 14704 claimed to shepherd duplicate PR #7170. Fresh state: issue #1004 is CLOSED; canonical PR #5949 is MERGED (2026-11-11T06:56:59Z); PR #7170 remains OPEN at f342c4b, with no labels or assignees. #7170 is authored by the fleet account
dezren39; I will determine whether any unique content remains before disposition. The earlier conflicting ownership is now resolved by #5949 merging; no branch changes yet.dezren39 commentedon Nov 12, 2026
Task 14704 disposition: PR #7170 is CLOSED as superseded by merged canonical PR #5949 (merge commit 8d14e1f; implementation head f1f8ebd). Fresh content-level diff found no unique behavior to salvage; the comparison is on #5949 and the close reason is on #7170. Issue #1004 is CLOSED by #5949. No branch was deleted.