From c15dcc198b2563637b156c1113f55099f1f32404 Mon Sep 17 00:00:00 2001 From: Kresna Date: Mon, 27 Jul 2026 00:01:38 +0700 Subject: [PATCH] feat(shell): hide desktop-only tools (Hotkey Test) from the web Add a desktopOnly ToolDef flag (set on hotkey-test). The tool's page still generates (desktop uses the same build), but it's hidden from the web tool grid (CSS: hidden by default, revealed under html.tauri set by an inline script) and filtered from command-palette search. Category counts exclude it on the web. --- src/components/ToolGrid.tsx | 3 ++- src/components/shell/CommandPalette.tsx | 6 +++++- src/layouts/Base.astro | 22 +++++++++++----------- src/registry/tools.ts | 3 ++- src/styles/global.css | 9 +++++++++ src/types/tool.ts | 2 ++ 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/components/ToolGrid.tsx b/src/components/ToolGrid.tsx index 1918675..75c9326 100644 --- a/src/components/ToolGrid.tsx +++ b/src/components/ToolGrid.tsx @@ -22,7 +22,7 @@ export function ToolGrid() { />

{category}

- ({categoryTools.length}) + ({categoryTools.filter(tool => !tool.desktopOnly).length})
@@ -32,6 +32,7 @@ export function ToolGrid() { (null); - const results = searchTools(search); + // Desktop-only tools (e.g. Hotkey Test) are excluded from web search results. + const results = searchTools(search).filter(tool => isDesktop || !tool.desktopOnly); useEffect(() => { const down = (e: KeyboardEvent) => { @@ -19,6 +22,7 @@ export function CommandPalette() { // Let any element open search by clicking (dispatch 'gwt:open-search'), // so it works without a keyboard. const openSearch = () => setOpen(true); + setIsDesktop(isTauri()); document.addEventListener('keydown', down); window.addEventListener('gwt:open-search', openSearch); return () => { diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 98dfd2a..60b241f 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -102,18 +102,18 @@ const jsonLdBlocks = [siteJsonLd, ...(Array.isArray(jsonLd) ? jsonLd : jsonLd ? diff --git a/src/registry/tools.ts b/src/registry/tools.ts index 906dd8e..6ba003b 100644 --- a/src/registry/tools.ts +++ b/src/registry/tools.ts @@ -99,7 +99,8 @@ export const tools: ToolDef[] = [ icon: Keyboard, summary: 'Test global hotkey registration (desktop only)', load: () => import('@/islands/dev/HotkeyTest'), - status: 'beta' + status: 'beta', + desktopOnly: true }, { id: 'csv-json', diff --git a/src/styles/global.css b/src/styles/global.css index ba4026e..ea2cc7c 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -179,3 +179,12 @@ body { background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; } + +/* Desktop-only tools (e.g. Hotkey Test) are hidden on the web and revealed only + in the Tauri desktop app, where an inline script sets `.tauri` on . */ +[data-desktop-only] { + display: none; +} +html.tauri [data-desktop-only] { + display: flex; +} diff --git a/src/types/tool.ts b/src/types/tool.ts index c507ffd..243ca0a 100644 --- a/src/types/tool.ts +++ b/src/types/tool.ts @@ -19,6 +19,8 @@ export interface ToolDef { summary: string; load: () => Promise<{ default: React.ComponentType }>; needsIsolation?: boolean; + /** Hidden from web listings (grid + search); only shown in the Tauri desktop app. */ + desktopOnly?: boolean; assets?: AssetRef[]; status: 'stable' | 'beta' | 'experimental'; }