Skip to content

Fix dashboard JS crash: q() throws on missing #restoreAllPreviewsBtn#3

Merged
falkoro merged 1 commit into
mainfrom
fix/events-q-throws-on-missing-restore-btn
May 28, 2026
Merged

Fix dashboard JS crash: q() throws on missing #restoreAllPreviewsBtn#3
falkoro merged 1 commit into
mainfrom
fix/events-q-throws-on-missing-restore-btn

Conversation

@falkoro
Copy link
Copy Markdown
Owner

@falkoro falkoro commented May 28, 2026

Bug

events.ts checked whether the injected "Restore all" button already exists with q('#restoreAllPreviewsBtn'). But q() is the assert-style helper that throws Missing element when nothing matches. On first load the button never exists yet, so the throw aborted events.js mid-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_LOGIN let the dashboard load): empty sidebar, header stuck on "syncing", Machine widget stuck on "—", console error Missing element: #restoreAllPreviewsBtn at q(...). Introduced in PR #1.

Fix

Use document.querySelector (returns null) instead of q() for the existence checks — both .shell-tools and #restoreAllPreviewsBtn.

Verified live (browser)

code.falkinator.org reloaded: 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

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>
Copilot AI review requested due to automatic review settings May 28, 2026 19:55
@falkoro falkoro merged commit a986744 into main May 28, 2026
@falkoro falkoro deleted the fix/events-q-throws-on-missing-restore-btn branch May 28, 2026 19:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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