Skip to content

Separate highlights from cards and fix per-keystroke author colors - #78

Merged
kylemcd merged 7 commits into
mainfrom
feat/highlights-toggle-and-author-color-fix
Oct 5, 2026
Merged

kylemcd merged 7 commits into
mainfrom
feat/highlights-toggle-and-author-color-fix

Conversation

@kylemcd

@kylemcd kylemcd commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

Picks the three usable changes out of #77 and reimplements them against main. Thanks to @atendev for finding the first two.

Stop assigning author colors on every keystroke

colorForAuthor runs on every transaction, and it created and persisted an assignment as a side effect. The Author setting's onChange fires per keystroke and triggers a refresh, so typing Alice saved generated colors for A, Al, Ali and Alic as well — which is why the Highlight colors list filled up with junk.

  • resolveAuthorColor is replaced by a pure readAuthorColor. The render path can no longer mutate or persist anything.
  • Creation stays at the explicit points that already existed: the vault scan, Rescan, Assign color, and load.
  • A typed Author name gets its color from a 600ms debounce, so only the name you settle on is assigned.

Add a Show highlights setting

Highlights rode the showComments toggle, so hiding the cards also wiped the underlines out of the text. They are independent now — hide the cards and keep the highlights, or the reverse. Applies to editing, reading, and mobile views.

Note that with cards hidden, clicking a highlight doesn't do anything yet; the sidebar is how you read those threads. #77's "highlights open sidebar" setting is not included here.

Add "Add comment" to the right-click menu

Appears in the editor context menu when text is selected, reusing the command's entry point. The README no longer sends people to Commander just for this.

Deliberately not included from #77

The author-selector / "Available authors" feature, the action-bar move (it breaks in the sidebar, where cards are position: static), the more-menu toggle guard, the .dc-act restyle, the author-colored draft border, and the .gitignore change.

#77 also dropped the vault.on("modify") → scheduleReadingRefresh() call and the authorColorsEnabled gate on colorForAuthor. Both are left intact here.

Testing

npm run check passes — format, lint, typecheck, 208 tests.

Three new tests, each verified to fail against main before the fix:

  • reading an author's color never creates an assignment
  • typing an author name defers the color assignment instead of running per keystroke
  • highlights survive hiding the comment column and follow showHighlights

Three changes picked out of #77, reimplemented against main.

Stop assigning author colors on every keystroke. colorForAuthor ran on
every transaction and created + persisted an assignment as a side effect,
so typing "Alice" into the Author setting saved generated colors for "A",
"Al", "Ali" and "Alic" too. resolveAuthorColor is replaced by a pure
readAuthorColor; creation stays at the explicit points that already
existed (vault scan, Rescan, "Assign color", load) plus a debounced
assignment when a typed Author name settles.

Add a Show highlights setting. Highlights used to ride the showComments
toggle, so hiding the cards also wiped the underlines out of the text.
The two are independent now, and either can be hidden alone.

Add "Add comment" to the editor right-click menu when text is selected.
It reuses the command's entry point, so the README no longer needs to
send people to Commander for it.

The vault modify/create/delete/rename listeners and the authorColorsEnabled
gate on colorForAuthor are both left intact, unlike in #77.
Table highlights in Live Preview paint through the CSS Custom Highlight
API, not `.doc-comment-span`, so the `dc-highlights` class never reaches
them and they were still gated on showComments. That inverted both halves
of the new setting inside tables: Show highlights off left them painted,
and hiding the cards wiped them. Gate them on showHighlights and cover it
with a test that fails against the old gate.

Carry a saved showComments:false over to showHighlights on first load.
Before this branch, hiding the comments hid the highlights too, so
defaulting the new setting to true would have switched every highlight
back on for those vaults without explanation.

Cancel scheduleAuthorColorSave in onunload alongside the new debouncer.
The 600ms author-color timer feeds a 100ms save, so unloading in that
window let a write land after a reloaded instance had already loaded.

Keep the draft marker visible while highlights are off. It is a
`.doc-comment-span`, so the blanking rule erased the anchor the open
composer is writing against — a state the old code could not reach.

Also: add a Toggle highlights command to match the other visibility
toggles, make ensureCurrentAuthorColor private, fix comments in
styles.css, editor/margin.ts and editor-view.test.ts that still claimed
highlights follow showComments, note the Commander duplicate in the
README, and add the CHANGELOG entry.
Inheriting a saved showComments:false persisted showHighlights:false for
anyone who merely had comments toggled off at update time, and it stuck:
turning comments back on later left the highlights gone with no visible
cause. Highlights reappearing is immediately visible and one toggle to
undo, so take that over a silent sticky one. The test now records the
decision rather than the inheritance.
Probe the table-highlight gate with a vi.fn instead of a let flag, type
the author name with forEach, and say why the async keystroke test needs
a for...of loop.
Mobile has no comment cards, so Toggle comments only ever showed there
through the highlights. Once highlights followed Show highlights alone,
the ribbon icon and the command said "Comments hidden" on mobile and
changed nothing.

On mobile, show the highlights only while both settings are on, in Live
Preview, Reading view and table cells. Desktop keeps the two settings
independent.
@kylemcd
kylemcd merged commit 4dfbafd into main Oct 5, 2026
1 of 2 checks passed
@kylemcd
kylemcd deleted the feat/highlights-toggle-and-author-color-fix branch October 5, 2026 19:51
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