Repository navigation
Description
Summary
ImageNodeView.update() reassigns img.src on every update for any image
whose src attr is relative (which is the normal shape for id's own images,
e.g. /api/files/…) — even when nothing about the image changed. In a browser,
assigning img.src restarts the image load, so images flicker / refetch /
re-decode whenever ProseMirror re-runs the node view during editing or collab
updates.
Evidence (verified on main 95bfedb, this run)
pkgs/id/web/src/image-node-view.ts:240:
if (this.img.src !== node.attrs.src) this.img.src = node.attrs.src || "";The img.src getter returns the resolved absolute URL, while
node.attrs.src holds the authored (relative) value, so the comparison is
never equal for relative sources and the guard never guards.
Probe (targeted vitest, real ImageNodeView + EditorView/richSchema,
happy-dom; probe removed after the run, log in the creator's probe archive):
- node attrs src:
/api/files/cat.png img.srcgetter:http://localhost:3000/api/files/cat.pngimg.getAttribute("src"):/api/files/cat.png- Setter spy during
update()with an identical fresh node (same src,
alt): 1 src assignment — the reload is triggered on a no-op update.
The neighbouring syncs in the same method are fine: alt/title are compared
against node.attrs directly (:241-242), only the src check compares
against the absolutizing DOM getter. The constructor (:50) assigns once and
is not affected.
Why it matters
update() runs whenever ProseMirror reconciles the image node — local
typing near an image, remote collab steps, selection-driven re-renders.
Each pass silently restarts every relative-src image's load: visible flicker
in image-heavy docs, extra requests against the id server, and re-decode
jank, for zero benefit. It also makes the DOM churn under any future test
that asserts update() is a no-op for unchanged nodes.
Acceptance criteria
-
update()with unchanged attrs performs noimg.srcassignment
(compare againstgetAttribute("src")or a tracked last-applied src). - Changing the src attr still updates the image exactly once; clearing
it still clears the image. - Regression test in
image-node-view.test.ts(created by the id(web): image resize west handles (nw/sw) drag in the wrong direction — outward shrinks, inward grows #1389 fix
or here, whichever lands first): setter-spy or attribute-based
assertion that an unchanged update does not touchimg.src, and a
changed src does. - Web unit tests + typecheck pass.
Notes
Small, self-contained fix in image-node-view.ts. Sibling in the same file,
distinct defect: #1389 (west resize handles inverted).
Activity
developing-today commentedon Oct 27, 2026
CODE-484
dezren39 commentedon Oct 27, 2026
state: filed
agent: new-issue-creator-code-b
Found via: filed this run — targeted vitest probe (real ImageNodeView + EditorView/richSchema, happy-dom) on main 95bfedb: node attrs src
/api/files/cat.png, img.src getter returns the absolutizedhttp://localhost:3000/api/files/cat.png, so update()'s guard at image-node-view.ts:240 never matches for relative sources; a setter spy counted 1 src assignment during update() with identical attrs. Probe removed after the run; log: hidden_files/probe-2026-10-27-creator-b3/out2.log. Enqueued as a small_fix packet to repo-health-code-pilot. Sibling in the same file, distinct defect: #1389.dezren39 commentedon Oct 31, 2026
🤖 Agent note · picked up
image-node-view.ts:248—if (this.img.src !== node.attrs.src)compares the absolutized getter against the authored relative attr, so it reassigns on every update.getAttribute("src")(the authored value), keeping changed/cleared-src paths updating exactly once; regression tests inimage-node-view.test.ts.13 remaining items
dezren39 commentedon Oct 31, 2026
🤖 Agent note · parked
20496ae4454f823f6e61ec953cf1f7083535c551.dezren39 commentedon Oct 31, 2026
🤖 Agent note · picked up (resume) — merging PR 3197
bunx vitest run src/image-node-view.test.ts14/14 PASS,bunx tsc --noEmitexit 0. Full web suite: 492 passed, 1 failed —search-panel.test.tsaria-label expectation, proven pre-existing on main (implementation/test disagree on main itself; PR touches neither file) and filed as id(web): search-panel test expects aria-label 'Replace all' but implementation renders 'Replace all matches' — full web suite red on main #3243.Merge pull request #3197 from developing-today/queue/1364-1392-image-…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done — PR 3197 merged (task 1364)
8f24c7db5a2a3412bb19262eb12f2cf86c5d6a3b; this issue auto-closed by the merge. Verification: Codex clean on head20496ae44; laptopbunx vitest run src/image-node-view.test.ts14/14 PASS;bunx tsc --noEmitexit 0. Full web suite's only failure is the pre-existing search-panel aria-label mismatch, filed as id(web): search-panel test expects aria-label 'Replace all' but implementation renders 'Replace all matches' — full web suite red on main #3243.fixed_merged.