Fix dashboard JS crash: q() throws on missing #restoreAllPreviewsBtn#3
Merged
Merged
Conversation
events.ts used q('#restoreAllPreviewsBtn') to test whether the injected
"Restore all" button already exists, but q() throws ("Missing element")
when the selector matches nothing. On first load the button never exists,
so the throw aborted events.js mid-file — taking out render(initialModel),
the metrics/last-activity polling, the Restore-all injection, and the
drag-to-reorder/resize handlers. The dashboard rendered an empty sidebar
("syncing" forever, Machine widget stuck on "—").
Use document.querySelector (returns null) for the existence checks instead.
Verified live: 0 console errors, sessions + Machine metrics populate,
window controls render on all cards.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Bug
events.tschecked whether the injected "Restore all" button already exists withq('#restoreAllPreviewsBtn'). Butq()is the assert-style helper that throwsMissing elementwhen nothing matches. On first load the button never exists yet, so the throw abortedevents.jsmid-file — killing everything after it:render(initialModel), the metrics + last-activity polling, the Restore-all injection itself, and the drag-to-reorder / drag-to-resize handlers.Symptom (seen live once
DASHBOARD_SKIP_LOGINlet the dashboard load): empty sidebar, header stuck on "syncing", Machine widget stuck on "—", console errorMissing element: #restoreAllPreviewsBtn at q(...). Introduced in PR #1.Fix
Use
document.querySelector(returnsnull) instead ofq()for the existence checks — both.shell-toolsand#restoreAllPreviewsBtn.Verified live (browser)
code.falkinator.orgreloaded: 0 console errors; sessions list renders with "Nm ago" labels; Machine widget populates (logan-laptop, CPU/RAM/temps/load); "Restore all" present; after unlock, all 7 shell cards show the− ⤢ □window controls.🤖 Generated with Claude Code