feat(remarks): show unconfirmed remark ink as a translucent overlay where it was written #30
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daniel/obsidian-remarkable-round-trip!30
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/remark-ink-overlay"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #29
Goal
Issue #29 asks to show unconfirmed handwritten remarks in Obsidian roughly where the ink sits on the reMarkable page, as a half-transparent overlay. Today a remark only shows up as a callout (
> [!note] Remark+![[…png]]+^ink-<id>) placed after the whole block it was written against (seesrc/__tests__/remarkplacement.test.ts). The note gives no sense of where on the page the ink actually was.What already exists (no new data needed)
renderHandwriting(src/main.ts:~2178-2186) writes anInkStrokesrecord viathis.state.writeInk(<image file name>, ink). Read it back withthis.state.readInk(file.name)(src/sync/syncstate.ts:211; stored atreMarkable/.sync/ink/<image>.json).InkStrokes(src/ink/inkimage.ts:54-83) has:sourceWidth/sourceHeight: the ink's natural size in px at 96 dpi (pt ÷ 0.75), i.e. ink width in pt =sourceWidth * 0.75.at?: RemarkPlace { text, x, below }.textis the printed row the ink sits against.xis the ink's left edge in pt from the page's left.belowis the ink's top in pt under that row's baseline (negative means above it). It is computed ingroupNotes,src/incoming/marks.ts:574(PDF y-up, sobelow = row.y - ink.maxY).atis absent for added pages and for remarks read before positions were kept, so those get no overlay.atto draw ink back in place:overlayPlacementsinsrc/ink/inkrender.ts:181-210. Mirror its interpretation ofx/below.pdfLayout(src/id/mapping.ts:52:margin,pageWidth,fontSize,lineHeight) for the note'snotePath. Fall back to theconvert/pdf.tsdefaults (margin: 40,PAGE_WIDTH) when there is no entry.planRender,src/incoming/strokerender.ts,padding ?? 40). Account for that padding when sizing/offsetting the<img>so the strokes, not the padded box, land atx/below. Alternatively useobject-fit/a negative margin equal to the padding scaled.findRemark/remarkAt(src/incoming/remarkid.ts).confirmedis true when the title ends in ✓. A rendered callout is matched to its remark inRemarkControls.idOf(src/remarkui.ts).anchorAbove/wordsOfinsrc/incoming/remarkinsert.ts:122-140match a printed row to a source line by its first ≤4 words, with markdown and punctuation stripped. Export and reuse this (or factor it out) instead of writing a new matcher. Search above the callout's start line, asinsertRemarkTextdoes.What to build
src/incoming/remarkoverlay.ts, unit-tested, no DOM).InkStrokes(needsat), page{ pageWidth, margin }, the rendered text column width in px, and the line-height ratio.{ leftPx, topPx (relative to the anchor row's baseline), widthPx, heightPx }.pageWidth - 2*marginpt) maps onto the Obsidian column width, sos = columnPx / (pageWidth - 2*margin),left = (x - margin) * s, andwidth = sourceWidth*0.75*s. Margin-written ink gives negativeleftorleft + width > columnPx. Clamp it so it stays inside the view (it may overhang into the editor's side padding, but must not be clipped away entirely).top = below * s. Using the same scale is fine; "approximately" is the explicit requirement.nullwhenatis missing.RemarkControls(src/remarkui.ts) or add a sibling post-processor registered next to it (src/main.ts:~312).InkStrokes.at, find the rendered element holding the anchor row's text (DOM text search for the row's first words viaRange/getClientRects).<img class="remarkable-ink-remark-overlay">(the same vault image viaapp.vault.getResourcePath) positioned from that row's line box.position: relative) on whichever section contains the anchor text.ViewPluginregistered withthis.registerEditorExtension(...).@codemirror/viewand@codemirror/stateare already esbuild externals and present inpackage-lock.json; the repo does not import them yet.view.coordsAtPos/lineBlockAtfor it, and draw the overlays in alayer()(or absolutely positioned widgets) onview.scrollDOM.InkStrokesasynchronously and cache by image name; invalidate when the note's remark set changes.styles.css, following the existing.remarkable-ink-*naming.opacity: 0.5,pointer-events: noneso the text underneath stays selectable/editable. Optionallymix-blend-mode: multiplyso the white PNG background does not hide text; in dark theme usefilter: invert(1)withmix-blend-mode: screenor similar.npm run lint:css(stylelint obsidianmd config).inkRemarkOverlay: boolean, default true, insrc/settingsmodel.ts+src/settingschema.ts. Put it in the same "Handwriting" group asinkRemarks(settingschema.ts:~346). Suggested name: "Show unconfirmed remarks on the text", with a description explaining it is translucent and goes away once confirmed. When off, register nothing / render nothing.Constraints and decisions
projectOntoSourceplacement, or^ink-ids. The overlay is purely a rendering layer and must never write to the note.InkStrokes.strokeson a canvas was considered and ruled out as unnecessary for "approximately".at(old remarks, added pages), or whose anchor row can't be found in the current note text: no overlay, silently.src/__tests__/fixtures/layout-inset0.json(golden layout; imported marks are anchored to it).^ink-lines.Scope boundary
Not included: changing where the callout goes, editing ink, a click-through from the overlay to the callout (nice follow-up), and overlays for added whole pages.
Validation contract
The repo has no
flake.nix, so run Node directly:npm ci && npx vitest run src/__tests__/remarkoverlay.test.ts→ PASS. This is a new test file for the pure placement module and must cover these cases:x = margin,below = 2→left ≈ 0,top ≈ 2*s;atmissing →null;x).npm test→ all existing tests still pass.npm run build→ exit 0, andnpm run lint→ exit 0 (ESLint obsidianmd and stylelint,--max-warnings 0).🤖 Generated with Claude Code
🤖 Agent is working on this — turn 17
Last activity: assistant message — updated 17:58:40 UTC
Last message:
claude referenced this pull request2026-10-20 19:08:31 +02:00
claude referenced this pull request2026-10-20 19:08:32 +02:00
What changed
src/incoming/remarkoverlay.ts(pure, unit-tested). It maps the tablet's text column onto the note's column. The strokes, not the padded PNG, land atx/below. Margin ink is clamped into view, and remarks withoutatgetnull. The row matcher (wordSpans/runsOf/anchorAbove) is now exported fromremarkinsert.tsand shared, with no behaviour change.src/remarkoverlayui.ts. Reading view: a post-processor attaches the overlay<img>to the section holding the anchor row, measured with a DOMRange. It is redrawn on resize and on note changes, so a ✓ elsewhere in the note removes it. Live preview and source mode: a CM6ViewPlugin+layer(). Only unconfirmed remarks with an image get an overlay. The note itself is never written.pointer-events: none, multiply blend (inverted + screen in dark theme). The settinginkRemarkOverlay(default on, "Show unconfirmed remarks on the text", under Handwriting) adds or removes the editor extension live. README bullet and CHANGELOG-INK entry added.@codemirror/stateand@codemirror/viewwere added as devDependencies at the versions already in the lock. Without that,import/no-extraneous-dependencieswarns.css-mixblendmodewas added to stylelint's ignore list, with the reason in the config: Safari only lacks the non-separable blend modes, and this uses multiply/screen.Verify
npx vitest run src/__tests__/remarkoverlay.test.tscovers the four required cases. It failed to import before the module existed and passes now.remarkoverlayui.test.ts(happy-dom, layout stubbed) checks: an overlay appears for an unconfirmed margin remark, and it disappears on ✓ and when the setting is turned off.npm test714/714,npm run buildandnpm run lintall exit 0. There is no branch CI on this repo.Follow-ups
✅ Agent run completed
2m41s · 12 turns · $0.37
Since my last update: merged
maininto the branch (6224350) to clear the conflict. The only conflict was the Unreleased list inCHANGELOG-INK.md, where I kept both entries. After the merge,npm testpasses (733/733), andnpm run buildandnpm run lintboth exit 0.Acceptance-intent assessment
Issue #29 asks for unconfirmed ink to be shown as a half-transparent overlay, roughly where it sat on the reMarkable page. The diff does this as a rendering-only layer. It places each unconfirmed remark's existing PNG over the note using the recorded
InkStrokes.atrow/x/below, mapped onto the note's text column. It works in both reading view and the editor. Confirming the remark or inserting it as text removes the overlay, and a setting (on by default) turns the feature off. Every item in the MR's hand-off spec is covered by the diff.Criteria
pendingRemarksskips remarks with ✓ and remarks without an image. The overlay is the vault PNG viagetResourcePath, with no re-render of strokes.overlayBoxusess = columnPx/(pageWidth-2·margin),left=(x-margin)·s,top=below·s(optionally scaled by line pitch). The anchor row is found above the callout with the sharedanchorAbove/wordSpans/runsOfmatcher, which is exported fromremarkinsert.tswith matching behaviour unchanged.styles.csssetsopacity: 0.5andpointer-events: none, usesmultiply, and in dark theme usesinvert(1)withscreen.src/incoming/remarkoverlay.tsis tested inremarkoverlay.test.ts: column edge atbelow=2, right-margin ink clamped into view (left margin too), missingatreturnsnull, and the 40-unit padding offset so the strokes land atx. Commitee86738adds the module and its test together. 20/20 pass locally.OverlaySection) attaches the<img class="remarkable-ink-remark-overlay">to the section holding the anchor row. The row is measured withRange.getClientRects, and the overlay is redrawn on resize and on vaultmodify, so a ✓ removes it. The happy-dom test covers it appearing, going away on ✓, and going away when the setting is off.ViewPluginpluslayer()is registered viaregisterEditorExtension. It usescoordsAtPoson the anchor line and recomputes on doc, viewport and geometry changes. InkStrokes are read asynchronously and cached by image path and mtime.inkRemarkOverlay(default true, in Handwriting next toinkRemarks, suggested name and description): PASS. When off,sync()empties the editor extension and the post-processor returns early. BothsaveSettingsandonExternalSettingsChangecall it.^ink-unchanged, no overlay withoutator anchor, early bail without^ink-, golden fixture untouched): PASS. No write path was added, andsrc/__tests__/fixtures/is not in the diff.npm cipasses,npm testpasses 714/714, andnpm run buildandnpm run lint(eslint plus stylelint--max-warnings 0) both exit 0.Verdict
Approved
Since my last update: the intent review approved, so I tried to self-merge. Forgejo refused all three attempts (squash twice, then a plain merge) with
HTTP 405 merge not completed.On the operator side nothing should block it:
mainand has no conflicts;6224350.The refusal therefore seems to come from Forgejo itself, most likely a protection rule on
main(required approvals or status checks) or a disabled merge style. Approving the MR in Forgejo or merging it by hand should finish it; no code changes are pending.@claude resolve mr conflicts
Since my last update: I merged the latest
main(7a021f8, the one-click Ollama setup) into the branch and pushed it as2c10986. OnlyCHANGELOG-INK.mdconflicted; I kept both Unreleased entries.src/main.tsandREADME.mdmerged on their own. After the merge, build and lint both exit 0, and all 762 tests pass. I tried to self-merge once more and Forgejo refused again with the same HTTP 405 ("merge not completed"), so it still needs approving in Forgejo or merging by hand. No code changes are pending.