Skip to content

fix(toolbar): let draw/comment/inspect activate with no pages#184

Merged
lklyne merged 2 commits into
mainfrom
fix/annotate-tools-without-pages
Jun 1, 2026
Merged

fix(toolbar): let draw/comment/inspect activate with no pages#184
lklyne merged 2 commits into
mainfrom
fix/annotate-tools-without-pages

Conversation

@lklyne
Copy link
Copy Markdown
Owner

@lklyne lklyne commented Jun 1, 2026

Summary

Follow-up to #181. That PR removed the hasPages-gated disabled on the Draw/Comment/Inspect toolbar buttons, but a second, main-side gate remained: sanitizeForPages() in src/main/runtime/tool-mode.ts silently collapsed annotation/inspect tools back to select whenever the canvas had zero pages.

The result: with no frame on the canvas, the Draw (pen/marker) button looked clickable but the activation died in main — activeTool never became 'draw', so the tool didn't select and its DrawToolPopup (gated on activeTool.kind === 'draw') never appeared. Same for Comment and Inspect.

This removes the page collapse entirely, so draw, comment, and inspect activate on an empty canvas — matching the always-enabled buttons. Only the drawing feature flag can veto a tool now.

It also closes a parallel gate: the right panel's "Add comments" button used annotateAvailable: pages.length > 0, which stayed disabled on an empty canvas even though the toolbar comment tool now activates there. That flag is now always true so both surfaces agree.

Why it's safe with zero pages

The inspect path (the only one that touches page content) is already defensive:

  • syncInspectionState() iterates an empty pages list → no-op
  • panel data reports available = pages.length > 0
  • inspection-enabled is forced false when there are no pages
  • hover-target handlers guard if (!page || …isDestroyed()) return

syncAnnotationState() (draw/comment) also just iterates the empty pages list. No tool crashes; inspect simply has nothing to target until a page exists.

Test plan

  • Empty canvas (no pages): click Draw → tool activates and the brush/color popup appears in the top toolbar.
  • Empty canvas: click Comment → comment tool activates.
  • Empty canvas: open right panel → Comments → "Add comments" button is enabled and toggles comment mode.
  • Empty canvas: click Inspect → inspect tool activates (panel shows nothing to inspect, no error).
  • With pages present, all three tools behave exactly as before.
  • pnpm typecheck passes.

🤖 Generated with Claude Code

lklyne and others added 2 commits May 31, 2026 20:33
PR #181 removed the hasPages-gated `disabled` on the Draw/Comment/Inspect
toolbar buttons, but a second, main-side gate remained: sanitizeForPages()
in tool-mode silently collapsed annotation/inspect tools back to `select`
when the canvas had zero pages. So the buttons looked clickable but the
activation died in main — the draw tool never became active and its
DrawToolPopup (gated on activeTool.kind === 'draw') never appeared.

Remove the page collapse entirely so draw, comment, and inspect activate on
an empty canvas, matching the always-enabled buttons. Only the drawing
feature flag can veto a tool now. The inspect path is already defensive
about zero pages (syncInspectionState loops over an empty pages list;
panel data reports available/annotateAvailable = pages.length > 0;
inspection enable is forced false with no pages), so no tool crashes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The right panel's "Add comments" button gated on pages.length > 0, but
the toolbar comment tool now activates on an empty canvas. Make
annotateAvailable always true so both surfaces agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lklyne lklyne merged commit a42b79a into main Jun 1, 2026
1 of 2 checks passed
@lklyne lklyne deleted the fix/annotate-tools-without-pages branch June 1, 2026 05:36
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