Skip to content

id(web): ImageNodeView.update() reassigns img.src on every update for relative sources — images reload/flicker on unrelated edits #1392

Closed

Description

@dezren39

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.src getter: http://localhost:3000/api/files/cat.png
  • img.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 no img.src assignment
    (compare against getAttribute("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 touch img.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

  1. developing-today commented on Oct 27, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/lowNice to have; do when convenient
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 27, 2026
  3. dezren39 commented on Oct 27, 2026

    @dezren39
    MemberAuthor

    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 absolutized http://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.

  4. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  5. added
    queue/claimedQueue worker lifecycle state
    and removed on Oct 31, 2026
  6. 13 remaining items

  7. added
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Oct 31, 2026
  8. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

    • Agent: repo-worker-code (openchamber scheduled lane)
    • Session / ID: queue task 1364
    • PR: fix(id-web): compare authored src in ImageNodeView.update() (#1392) #3197, current head 20496ae4454f823f6e61ec953cf1f7083535c551.
    • Evidence: Codex reports no findings on this head; the only visible check is CodeRabbit neutral/skipped, not a passing CI result. The previous worker reported 14 targeted tests and typecheck passing; these were not rerun this session.
    • Resume: Verify passing CI and mergeability on the current head, then assess merge. Parked for 20 minutes.
  9. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 31, 2026
  10. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up (resume) — merging PR 3197

    • Agent: repo-worker-code (lane E)
    • Session / ID: repo-queue-worker-shift-e 2026-10-31 · task 1364 (resume)
    • Found via: Fresh verification of PR 3197 @20496ae44: Codex review of the current head completed with zero findings (codex-review-state:v1, checked this run); diff is exactly the two scoped files (+72/−2). No CI workflow runs on this path (only CodeRabbit neutral registers), so the packet tests were run on the laptop at the PR head: bunx vitest run src/image-node-view.test.ts 14/14 PASS, bunx tsc --noEmit exit 0. Full web suite: 492 passed, 1 failed — search-panel.test.ts aria-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.
    • Task: Merging PR 3197 under the standing merge criteria (Codex clean, targeted tests verified, diff matches intent); completing task 1364 as fixed_merged.
  11. added a commit that references this issue on Oct 31, 2026
  12. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — PR 3197 merged (task 1364)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions