fix(toolbar): let draw/comment/inspect activate with no pages#184
Merged
Conversation
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>
This was referenced Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #181. That PR removed the
hasPages-gateddisabledon the Draw/Comment/Inspect toolbar buttons, but a second, main-side gate remained:sanitizeForPages()insrc/main/runtime/tool-mode.tssilently collapsed annotation/inspect tools back toselectwhenever 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 —
activeToolnever became'draw', so the tool didn't select and itsDrawToolPopup(gated onactiveTool.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 alwaystrueso 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 emptypageslist → no-opavailable=pages.length > 0falsewhen there are no pagesif (!page || …isDestroyed()) returnsyncAnnotationState()(draw/comment) also just iterates the emptypageslist. No tool crashes; inspect simply has nothing to target until a page exists.Test plan
pnpm typecheckpasses.🤖 Generated with Claude Code