fix: TAB_IDS missing stats + archive — keyboard shortcuts + persistence broken

When the Statistik (4.6.14) and Archiv (4.6.15) tabs were added to
the sidebar nav, the TAB_IDS const never got extended past its
original five entries:

  const TAB_IDS = ["vods", "clips", "cutter", "merge", "settings"]

Two consequences:

1) Ctrl+1..5 keyboard shortcut was hard-capped at five tabs (the
   guard `tabIndex < TAB_IDS.length` filtered Ctrl+6 and Ctrl+7 out).
   Even though there were 7 visible tabs.

2) persistActiveTab(tab) called isKnownTab(tab) before localStorage
   write. For 'stats' or 'archive' that returned false, so the tab
   was silently NOT persisted. Open the app on the Archiv tab,
   close it, reopen — it'd boot on VODs because the persisted value
   was the previous non-stats/archive selection.

Extended TAB_IDS to all seven nav-items + bumped the keyboard
shortcut range from 1-5 to 1-7. Ctrl+5 now maps to Statistik,
Ctrl+6 to Archiv, Ctrl+7 to Einstellungen. Persistence works for
the full set.

Added a comment to TAB_IDS pointing out the failure modes when
this is out of sync with the HTML nav, so the next nav addition
doesn't repeat the bug.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xRangerDE 2026-05-11 05:15:30 +02:00
parent 62400e4aa0
commit dba6e872a9

View File

@ -249,8 +249,8 @@ async function init(): Promise<void> {
// Skip rest if user is typing in an input field
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) return;
// Ctrl+1..5 jumps directly to a tab (Cmd on macOS via metaKey)
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key >= '1' && e.key <= '5') {
// Ctrl+1..7 jumps directly to a tab (Cmd on macOS via metaKey)
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key >= '1' && e.key <= '7') {
const tabIndex = parseInt(e.key, 10) - 1;
if (tabIndex >= 0 && tabIndex < TAB_IDS.length) {
e.preventDefault();
@ -794,7 +794,12 @@ async function syncQueueAndDownloadState(): Promise<void> {
}
}
const TAB_IDS = ['vods', 'clips', 'cutter', 'merge', 'settings'] as const;
// Must include every nav-item from index.html — otherwise:
// - Ctrl+N keyboard shortcut won't reach tabs past index 4
// - persistActiveTab silently no-ops, so the tab won't restore on reboot
// 'stats' (4.6.14) and 'archive' (4.6.15) were added to the nav but the
// const was never updated, leaving them effectively second-class tabs.
const TAB_IDS = ['vods', 'clips', 'cutter', 'merge', 'stats', 'archive', 'settings'] as const;
const ACTIVE_TAB_STORAGE_KEY = 'twitch-vod-manager:active-tab';
function isKnownTab(value: string): value is typeof TAB_IDS[number] {