Skip to content

fix(open-knowledge): inline-image source-fallback targets wrong PM range (#2505)#778

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jul 23, 2026
Merged

fix(open-knowledge): inline-image source-fallback targets wrong PM range (#2505)#778
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Copybara-translated 1 Inkeep OSS change. Rebase-merge this PR so the prepared commit lands directly on public main.

…nge (#2505)

* wip: claim QA-005 inline-image source-fallback range fix

* test(open-knowledge): RED tests pinning inline-image source-fallback range contract

* fix(open-knowledge): resolve inline-image source-fallback to the image node range

Two chained defects in the clipboard serializer made the inline-image
source-fallback swap the paragraph's leading text run instead of the
image atom on cross-app copy:

1. findDescriptorRoot's data-clipboard-inline-leaf opt-out skipped the
   annotated NodeViewWrapper but kept climbing, and tiptap's outer
   .react-renderer span around the same node view matched as a
   descriptor. The opt-out now neutralizes the node view's whole
   wrapper stack: a .react-renderer that is the direct parent of an
   opted-out wrapper is skipped too. Genuine enclosing descriptors
   interpose their own NodeViewWrapper, so they still match.

2. The descriptor branch fed an element-only parent.children index to
   posAtDOM, whose offset argument counts childNodes. Any descriptor
   with a non-element preceding sibling was misaddressed. The offset
   is now computed over parent.childNodes.

Test reconciliation: fixture (f) now models the real production
topology (outer .react-renderer.node-image present); test (g) models a
genuinely nested descriptor with its own NodeViewWrapper and pins that
it still matches. The wrapDescriptor test double is memoized so wrapper
identity is stable like real DOM.

Also adds the clipboard-relative-url-source-fallback e2e file to the
fixed test:e2e CI subset so this deterministic failure class is
CI-visible from now on.

* review: changeset, comment cleanup, mark-adjacent e2e pin

Local review follow-ups for the inline-image source-fallback fix:

- Add a patch changeset for the user-visible clipboard behavior change.
- Strip process-history narration from test comments per the comment
  discipline convention; keep the topology and contract substance.
- Model the genuine mid-paragraph descriptor fixture on mathInline, the
  inline descriptor that actually sits between text nodes, instead of a
  block JsxComponent that never has text siblings.
- Extend the ImageInlineZoomView doc comment to mirror the whole-stack
  neutralization semantics now documented in findDescriptorRoot.
- Add a QA-005b e2e pinning the mark-adjacent case behaviorally:
  verified failing against the pre-fix serializer (fallback span carried
  the duplicated bold text run) and passing with the fix, marks intact.

* review: fix stale fake-DOM comment to cite the fixed identity-sensitive operations

* test: make the walker mock delegate to the real implementation

Bun's mock.module registry is process-global and never truly un-mocks
(oven-sh/bun#12823), and a restore factory built from a namespace spread
can observe the already-mocked namespace, so the previous afterAll
restore leaked the capture stub to later test files on some runner file
orders. CI caught clipboard-line-structure.test.ts receiving an empty
fragment from the stub while the same suite passed locally under a
different readdir order.

The registered mock now delegates to the real
walkLiveDomToInlineStyledFragment (reference captured before the mock,
immune to in-place namespace mutation) except inside an explicit
capture window scoped to captureEnv, so it is behavior-transparent to
every other file in the process and needs no restore at all.

GitOrigin-RevId: 7cf367e847cec90179c48146ced6e5fd9d7a8169
@inkeep-oss-sync
inkeep-oss-sync Bot merged commit b4cc5a0 into main Jul 23, 2026
@inkeep-oss-sync
inkeep-oss-sync Bot deleted the copybara/sync branch July 23, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant