From a27b26abbd012eae16947ae2d4da7218498aeb13 Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Tue, 30 Jun 2026 08:46:59 +0200 Subject: [PATCH] fix(shortcuts): keep shortcut contract in config/ (Rust include_str! path) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shortcut contract (shortcutActions.ts + shortcutTypes.ts) is NOT a pure-frontend file: src-tauri/src/cli/parse.rs include_str!s '/../src/config/shortcutActions.ts' at compile time, so moving it to lib/shortcuts/ (slice 7ad19671) broke the Rust build (couldn't read the file -> dev build won't start). Revert the contract back to src/config/ — it has a build-time backend path contract and belongs where Rust anchors it, not in lib/. No Rust file touched (fix = restore the frontend path the backend expects). cargo check green (13s), tsc 0, lint 0/0, frontend suite 319/2353 green. Lesson: grep src-tauri for include_str!/include_bytes! '../src/...' before moving ANY frontend file — Rust can pin a TS file by path. --- src/config/shortcutActionRegistry.ts | 2 +- src/{lib/shortcuts => config}/shortcutActions.ts | 2 +- src/config/shortcutBindings.ts | 2 +- src/config/shortcutDispatch.ts | 2 +- src/{lib/shortcuts => config}/shortcutTypes.ts | 0 src/features/settings/components/InputTab.tsx | 2 +- src/features/settings/components/settingsSearch.ts | 2 +- src/hooks/tauriBridge/useCliBridge.ts | 2 +- src/hooks/tauriBridge/useInAppKeybindings.ts | 2 +- src/hooks/tauriBridge/useMediaAndWindowBridge.ts | 2 +- src/shortcuts/runtime.ts | 2 +- src/store/globalShortcutsStore.ts | 4 ++-- src/store/keybindingsStore.ts | 4 ++-- 13 files changed, 14 insertions(+), 14 deletions(-) rename src/{lib/shortcuts => config}/shortcutActions.ts (98%) rename src/{lib/shortcuts => config}/shortcutTypes.ts (100%) diff --git a/src/config/shortcutActionRegistry.ts b/src/config/shortcutActionRegistry.ts index 85832fe5..43d010ae 100644 --- a/src/config/shortcutActionRegistry.ts +++ b/src/config/shortcutActionRegistry.ts @@ -8,7 +8,7 @@ import { usePlayerStore } from '../store/playerStore'; import { usePreviewStore } from '../store/previewStore'; import { useLyricsStore } from '../store/lyricsStore'; import { showToast } from '../utils/ui/toast'; -import type { ActionContext, ShortcutSlot, ShortcutActionMeta } from '@/lib/shortcuts/shortcutTypes'; +import type { ActionContext, ShortcutSlot, ShortcutActionMeta } from '@/config/shortcutTypes'; let cliPremuteVolume: number | null = null; diff --git a/src/lib/shortcuts/shortcutActions.ts b/src/config/shortcutActions.ts similarity index 98% rename from src/lib/shortcuts/shortcutActions.ts rename to src/config/shortcutActions.ts index 9040ef38..b31b21fb 100644 --- a/src/lib/shortcuts/shortcutActions.ts +++ b/src/config/shortcutActions.ts @@ -48,7 +48,7 @@ export type { ActionContext, CliContext, ShortcutActionMeta, -} from '@/lib/shortcuts/shortcutTypes'; +} from '@/config/shortcutTypes'; export { SHORTCUT_ACTION_REGISTRY, diff --git a/src/config/shortcutBindings.ts b/src/config/shortcutBindings.ts index a939dee5..e1cc6619 100644 --- a/src/config/shortcutBindings.ts +++ b/src/config/shortcutBindings.ts @@ -1,4 +1,4 @@ -import type { ShortcutSlot } from '@/lib/shortcuts/shortcutTypes'; +import type { ShortcutSlot } from '@/config/shortcutTypes'; import { SHORTCUT_ACTION_REGISTRY, type ShortcutAction, diff --git a/src/config/shortcutDispatch.ts b/src/config/shortcutDispatch.ts index ae785832..1dbf9bd3 100644 --- a/src/config/shortcutDispatch.ts +++ b/src/config/shortcutDispatch.ts @@ -3,7 +3,7 @@ import i18n from '@/lib/i18n'; import { usePlayerStore } from '../store/playerStore'; import { showToast } from '../utils/ui/toast'; import { playByOpaqueId } from '../utils/playback/playByOpaqueId'; -import type { ActionContext, CliContext } from '@/lib/shortcuts/shortcutTypes'; +import type { ActionContext, CliContext } from '@/config/shortcutTypes'; import { SHORTCUT_ACTION_REGISTRY, type ShortcutAction, diff --git a/src/lib/shortcuts/shortcutTypes.ts b/src/config/shortcutTypes.ts similarity index 100% rename from src/lib/shortcuts/shortcutTypes.ts rename to src/config/shortcutTypes.ts diff --git a/src/features/settings/components/InputTab.tsx b/src/features/settings/components/InputTab.tsx index 63ca9554..95183664 100644 --- a/src/features/settings/components/InputTab.tsx +++ b/src/features/settings/components/InputTab.tsx @@ -1,7 +1,7 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Keyboard, RotateCcw, X } from 'lucide-react'; -import { IN_APP_SHORTCUT_ACTIONS, GLOBAL_SHORTCUT_ACTIONS } from '@/lib/shortcuts/shortcutActions'; +import { IN_APP_SHORTCUT_ACTIONS, GLOBAL_SHORTCUT_ACTIONS } from '@/config/shortcutActions'; import { useGlobalShortcutsStore, type GlobalAction, buildGlobalShortcut, formatGlobalShortcut } from '@/store/globalShortcutsStore'; import { useKeybindingsStore, type KeyAction, buildInAppBinding, formatBinding } from '@/store/keybindingsStore'; import SettingsSubSection from '@/features/settings/components/SettingsSubSection'; diff --git a/src/features/settings/components/settingsSearch.ts b/src/features/settings/components/settingsSearch.ts index 30d0c5bb..bd4c8884 100644 --- a/src/features/settings/components/settingsSearch.ts +++ b/src/features/settings/components/settingsSearch.ts @@ -1,5 +1,5 @@ import type { TFunction } from 'i18next'; -import { GLOBAL_SHORTCUT_ACTIONS, IN_APP_SHORTCUT_ACTIONS } from '@/lib/shortcuts/shortcutActions'; +import { GLOBAL_SHORTCUT_ACTIONS, IN_APP_SHORTCUT_ACTIONS } from '@/config/shortcutActions'; import { SETTINGS_INDEX, matchScore, type Tab } from '@/features/settings/components/settingsTabs'; export type SettingsSearchHit = { diff --git a/src/hooks/tauriBridge/useCliBridge.ts b/src/hooks/tauriBridge/useCliBridge.ts index 9ddc3ea3..a2ceac8d 100644 --- a/src/hooks/tauriBridge/useCliBridge.ts +++ b/src/hooks/tauriBridge/useCliBridge.ts @@ -13,7 +13,7 @@ import { switchActiveServer } from '../../utils/server/switchActiveServer'; import i18n from '@/lib/i18n'; import { usePlayerStore } from '../../store/playerStore'; import { useAuthStore } from '../../store/authStore'; -import { executeCliPlayerCommand } from '@/lib/shortcuts/shortcutActions'; +import { executeCliPlayerCommand } from '@/config/shortcutActions'; /** The full `cli:*` listener surface forwarded from the Rust single-instance * handler: audio-device, instant-mix, library / server resolution, search and diff --git a/src/hooks/tauriBridge/useInAppKeybindings.ts b/src/hooks/tauriBridge/useInAppKeybindings.ts index 4f39cdc7..7f6cb6a8 100644 --- a/src/hooks/tauriBridge/useInAppKeybindings.ts +++ b/src/hooks/tauriBridge/useInAppKeybindings.ts @@ -2,7 +2,7 @@ import { useEffect } from 'react'; import type { NavigateFunction } from 'react-router-dom'; import { useKeybindingsStore, buildInAppBinding } from '../../store/keybindingsStore'; import { useGlobalShortcutsStore } from '../../store/globalShortcutsStore'; -import { DEFAULT_IN_APP_BINDINGS, executeRuntimeAction } from '@/lib/shortcuts/shortcutActions'; +import { DEFAULT_IN_APP_BINDINGS, executeRuntimeAction } from '@/config/shortcutActions'; import { matchInAppShortcutAction } from '../../shortcuts/runtime'; /** Configurable in-app keybindings: matches keydown chords against the user's diff --git a/src/hooks/tauriBridge/useMediaAndWindowBridge.ts b/src/hooks/tauriBridge/useMediaAndWindowBridge.ts index a83c307d..a5a2bd51 100644 --- a/src/hooks/tauriBridge/useMediaAndWindowBridge.ts +++ b/src/hooks/tauriBridge/useMediaAndWindowBridge.ts @@ -16,7 +16,7 @@ import { executeRuntimeAction, isGlobalShortcutActionId, isShortcutAction, -} from '@/lib/shortcuts/shortcutActions'; +} from '@/config/shortcutActions'; /** Media keys, tray actions, global / cross-window shortcut events, relative & * absolute seek + volume, and the window-close / force-quit exit flow. */ diff --git a/src/shortcuts/runtime.ts b/src/shortcuts/runtime.ts index 710d6c99..fd18ba26 100644 --- a/src/shortcuts/runtime.ts +++ b/src/shortcuts/runtime.ts @@ -1,5 +1,5 @@ import { matchInAppBinding, type Bindings } from '../store/keybindingsStore'; -import type { KeyAction } from '@/lib/shortcuts/shortcutActions'; +import type { KeyAction } from '@/config/shortcutActions'; export function matchInAppShortcutAction( event: KeyboardEvent, diff --git a/src/store/globalShortcutsStore.ts b/src/store/globalShortcutsStore.ts index aebddedc..a687bfd1 100644 --- a/src/store/globalShortcutsStore.ts +++ b/src/store/globalShortcutsStore.ts @@ -2,7 +2,7 @@ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; import { invoke } from '@tauri-apps/api/core'; import { MODIFIER_KEY_CODES, formatBinding } from './keybindingsStore'; -import { DEFAULT_GLOBAL_SHORTCUTS, isGlobalShortcutActionId, type GlobalAction } from '@/lib/shortcuts/shortcutActions'; +import { DEFAULT_GLOBAL_SHORTCUTS, isGlobalShortcutActionId, type GlobalAction } from '@/config/shortcutActions'; /** Dev builds run alongside release — OS-level grabs stay on the release instance. */ const GLOBAL_SHORTCUTS_OS_ENABLED = !import.meta.env.DEV; @@ -101,4 +101,4 @@ export const useGlobalShortcutsStore = create()( ) ); -export type { GlobalAction } from '@/lib/shortcuts/shortcutActions'; +export type { GlobalAction } from '@/config/shortcutActions'; diff --git a/src/store/keybindingsStore.ts b/src/store/keybindingsStore.ts index ed48d68d..1af27cd4 100644 --- a/src/store/keybindingsStore.ts +++ b/src/store/keybindingsStore.ts @@ -1,6 +1,6 @@ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; -import { DEFAULT_IN_APP_BINDINGS, type KeyAction } from '@/lib/shortcuts/shortcutActions'; +import { DEFAULT_IN_APP_BINDINGS, type KeyAction } from '@/config/shortcutActions'; /** Physical keys only — ignore for binding capture */ export const MODIFIER_KEY_CODES = [ @@ -12,7 +12,7 @@ export const MODIFIER_KEY_CODES = [ export type Bindings = Record; export const DEFAULT_BINDINGS: Bindings = { ...DEFAULT_IN_APP_BINDINGS }; -export type { KeyAction } from '@/lib/shortcuts/shortcutActions'; +export type { KeyAction } from '@/config/shortcutActions'; function normalizeBindings( bindings: Partial> | undefined