From 910cf23e61afe6c156ccfc71e4f32b3a72502c08 Mon Sep 17 00:00:00 2001 From: debont80 Date: Tue, 30 Jun 2026 13:48:41 -0400 Subject: [PATCH] Fix L17/L18/L56: regex validation, terminal visibility, SponsorBlock warning L17: TemplateManager urlPattern field now validates the regex on each keystroke; an error message appears below the input and Save is blocked until fixed. L18: Terminal nav item is hidden when customCommandEnabled is false -- no more dead-end gated view. Sidebar gains showTerminal prop; App.tsx reads the setting and passes it through. L56: SponsorBlock Categories Field shows a 'warning' validationMessage when the toggle is ON but no categories are selected, making the silent no-op visible. typecheck + 242 tests + eslint + prettier green. Co-Authored-By: Claude Opus 4.8 --- CODE-AUDIT.md | 6 ++-- src/renderer/src/App.tsx | 2 ++ .../src/components/DownloadOptionsForm.tsx | 10 ++++++- src/renderer/src/components/Sidebar.tsx | 7 +++-- .../src/components/TemplateManager.tsx | 29 +++++++++++++++---- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/CODE-AUDIT.md b/CODE-AUDIT.md index 2cc9f2a..26ab263 100644 --- a/CODE-AUDIT.md +++ b/CODE-AUDIT.md @@ -410,9 +410,9 @@ token system + shared primitives (UI/SIMP — high value, larger effort) · i18n already that union). - [ ] **L16 — `relTime`/`formatWhen` verbosity.** `relTime` returns unbounded "N d ago"; History's `formatWhen` always appends the year, even for the current year. -- [ ] **L17 — TemplateManager regex not validated.** An invalid `urlPattern` is accepted with no +- [x] **L17 — TemplateManager regex not validated.** An invalid `urlPattern` is accepted with no feedback and silently never matches (main's `matchesUrl` swallows the error). -- [ ] **L18 — Terminal nav item shown when custom commands are off** — leads to a gated dead-end +- [x] **L18 — Terminal nav item shown when custom commands are off** — leads to a gated dead-end view; consider hiding/disabling it. - [ ] **L19 — `App.tsx` focus hack** — `setTimeout(() => …focus(), 60)` after a tab switch. - [ ] **L20 — `youtubePlayerClient` is free text** with no allowlist/validation; a typo passes @@ -486,7 +486,7 @@ token system + shared primitives (UI/SIMP — high value, larger effort) · i18n - [x] **L54 — DownloadBar preview `` has no `onError` fallback** (inconsistent with `MediaThumb`'s retry). - [x] **L55 — QueueItem meta line can show size twice** — a probed-format `quality` label already contains the size, then `sizeLabel` is appended again. -- [ ] **L56 — SponsorBlock ON with zero categories silently no-ops** (`buildArgs` guards on +- [x] **L56 — SponsorBlock ON with zero categories silently no-ops** (`buildArgs` guards on `length > 0`) with no UI warning. - [x] **L57 — Scheduling a past datetime silently downloads now** (`buildItem` future-only guard), no feedback that the schedule was ignored. diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 26a32d3..37e19b2 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -38,6 +38,7 @@ function App(): React.JSX.Element { const theme = useSettings((s) => s.theme) const accentColor = useSettings((s) => s.accentColor) const updateSettings = useSettings((s) => s.update) + const showTerminal = useSettings((s) => s.customCommandEnabled) const isDark = useResolvedDark() const [tab, setTab] = useState('downloads') const [paletteOpen, setPaletteOpen] = useState(false) @@ -171,6 +172,7 @@ function App(): React.JSX.Element { version={version} collapsed={collapsed} onToggleCollapsed={toggleCollapsed} + showTerminal={showTerminal} />
diff --git a/src/renderer/src/components/DownloadOptionsForm.tsx b/src/renderer/src/components/DownloadOptionsForm.tsx index 8ed25d4..7ae293b 100644 --- a/src/renderer/src/components/DownloadOptionsForm.tsx +++ b/src/renderer/src/components/DownloadOptionsForm.tsx @@ -196,7 +196,15 @@ export function DownloadOptionsForm({ value, onChange }: Props): React.JSX.Eleme onChange={(v) => setOpt('sponsorBlockMode', v as SponsorBlockMode)} /> - +
{SPONSORBLOCK_CATEGORIES.map((cat) => ( void + /** Show the Terminal nav item (only when custom commands are enabled) */ + showTerminal: boolean } export function Sidebar({ @@ -162,7 +164,8 @@ export function Sidebar({ onSetTheme, version, collapsed, - onToggleCollapsed + onToggleCollapsed, + showTerminal }: SidebarProps): React.JSX.Element { const styles = useStyles() const focus = useFocusStyles() @@ -214,7 +217,7 @@ export function Sidebar({
- {NAV.map((n) => { + {NAV.filter((n) => n.value !== 'terminal' || showTerminal).map((n) => { const active = tab === n.value const btn = (