8000 Margin marks by kiran-brahma · Pull Request #89 · kiran-brahma/writing-tool · GitHub
[go: up one dir, main page]

Skip to content

Margin marks - 8000 #89

Merged
kiran-brahma merged 1 commit into
v1.3from
v1.3-65
Sep 26, 2026
Merged

kiran-brahma merged 1 commit into
v1.3from
v1.3-65

Conversation

@kiran-brahma
Copy link
Copy Markdown
Owner

Part of #57. Closes #65.

What changed

  • marginMarks(tree, highlights) in src/editor/callout.ts, next to calloutFindings. It is a pure function from the Document and the resolved Highlights to { blockIndex, findingIds }[], with one entry per top-level block where an open, attached Finding begins. It reads only ids and intervals, never a Finding's text. It renders the Document once and uses a binary search, so hundreds of Highlights cost one walk.
  • The Highlight plugin (src/editor/highlight.ts) draws each entry as a widget between top-level blocks, never inside a textblock. The widget is a zero-height holder with a button (tabIndex=-1, aria-label "N Finding(s)") positioned into the column's right padding. It shows ÷N in var(--color-mark). The plugin maps marks through edits along with the Highlights. The restyle path (mid-pause) drops Finding ids that are no longer drawn, so a mark whose last Finding left the queue goes away.
  • Click path: the widget stops its own events and prevents default on mousedown, so the caret and focus stay where they were. It reports {findingIds, blockStart} through an extension option. DocumentEditor turns that into the same onHighlightClick report a Highlight click makes. The Callout is anchored at the start of the marked block's prose. The shell opens the Callout with calloutFindings, and the Current Finding does not move (ADR 0011).
  • CSS .obelus-margin-mark in src/index.css:
    • The holder has no height and no margin, so the page lays out exactly as before. I measured this: block tops are identical with and without marks.
    • The button sits on the first line of the block beside it. Headings get a class set by the plugin rather than a :has() selector.
    • Both holder and button use contain, so a keystroke doesn't lay out or repaint them.
    • No colour tokens changed, and there are no .obelus-highlight* edits.
  • CONTEXT.md: adds Margin mark, with the note on why it's kept despite mark under the Anchor entry's Avoid. Callout now names the Margin mark as a second way to open it.

No App.tsx change, no Dexie migration, findings schema unchanged, no DOM test layer, no prompt change.

Acceptance criteria

  • marginMarks is tested — verified. Six tests in src/editor/callout.test.ts cover:
    • one entry at the block where an open Finding begins
    • a multi-Paragraph Finding counted once, beside the first block
    • shared blocks counted correctly, each block separate and in Document order
    • a Finding resolved twice named once
    • Orphaned, addressed and declined Findings absent (fed through reResolveFindings)
    • empty input
  • A click opens the Callout with that Paragraph's open Findings; the Current Finding and the Rail do not move — verified in headless Chromium at 1440px. A Current Finding was selected with the queue keys and the caret placed in another Paragraph. Clicking the ÷6 mark opened the Callout labelled "6 Findings" with 6 entries. The Current Finding row, its Highlight, the Rail's scroll position, the caret position and the focused element were all unchanged.
  • Marks stay beside the right Paragraph while typing above them — verified in Chromium. I typed two new Paragraphs above the marks. During the pause, every mark still sat level with its block's top (0px off); one mark moved down 115px with its Paragraph. After resolution the new Paragraph got its own mark, and all marks were still 0px off.
  • A mark disappears when its last Finding leaves the queue — verified in Chromium. Clicking a ÷1 mark and choosing Addressed in the Callout removed that mark once the verdict was saved (under 1.5s); the other marks were unchanged.
  • Tab never lands on a Margin mark; a screen reader announces its count — verified in Chromium. 80 Tab presses from the page never focused a mark (tabIndex=-1). The accessibility snapshot shows button "1 Finding", button "4 Findings", button "6 Findings". I did not test with an actual screen reader.
  • The caret moves normally at the start of a marked Paragraph in Safari — not verifiable here: only Chromium is available. By construction the widget sits between top-level blocks, never inside a textblock, with contenteditable=false, ignoreSelection and stopEvent, which is the placement the spec chose to avoid Safari's caret problem.
  • Typing with about 490 Highlights feels no slower than before (checked by hand) — not verifiable here: there is no WebKit and no one to judge by hand. As a proxy I timed keystrokes in Chromium with 483 Highlights and 29 marks at 4× CPU throttle: 176 keys × 3 runs each, alternating between this branch and origin/v 8000 1.3. Median keystroke is about 38.1ms here vs 36.9ms before (about 3%), and the means overlap within run-to-run noise. Before I added contain, the marks cost about 7%.

Visual checklist (performed in headless Chromium)

  • Light and dark, at 1440 and 1024px. The mark sits right of the prose and left of the Rail: at 1440 it spans x=830–847 with prose ending at 824 and the Rail starting at 1056; at 1024 it spans 599–616, prose ends at 593, Rail at 640. Colour is mark (rgb(3,105,161) light, rgb(56,189,248) dark).
  • 900px, the narrow-layout proxy: the mark stays inside the column's right padding (475–492, main edge at 516), so it doesn't depend on the Rail. After Narrow layout: the Rail overlays the prose #69, the overlaid Rail will cover it only while the overlay is open.
  • Beside h2/h3 headings mid-document, the mark is centred on the heading's first line.
  • 375px not checked: phone width is out of scope in the spec, and the mark sits in the column padding at every width.

🤖 Generated with Claude Code


Generated by Claude Code

marginMarks(tree, highlights), beside the Callout's pure functions, gives
one entry per top-level block where an open, attached Finding begins. The
Highlight plugin draws each as a zero-height widget between top-level
blocks, with a button hung into the column's right padding: the obelus and
its count in blue pencil, out of the Tab order and labelled with its count.
A click reports its Finding ids through the Highlight-click path, so the
Callout opens and the Current Finding and the Rail stay put (ADR 0011).
Adds Margin mark to CONTEXT.md.

Part of #57.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FjB3Gu8vhg5enkAneTdqga
@chatgpt-codex-connector
chatgpt-codex-connector Bot commented Sep 26, 2026 •
Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-26T11:10:05.837696Z 1e16f60 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kiran-brahma
kiran-brahma merged commit 55b0ad8 into v1.3 Sep 26, 2026
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.

2 participants

0