Fix global search folder navigation

This commit is contained in:
2026-06-30 20:57:58 +08:00
parent 268e79d2f0
commit b28039cf0d
3 changed files with 78 additions and 4 deletions
+33 -3
View File
@@ -2,6 +2,7 @@
import PluginBundleHost from '../plugin-host/PluginBundleHost.svelte';
import TodaySurface from './TodaySurface.svelte';
import * as App from '../../../wailsjs/go/api/App';
import { onDestroy, onMount } from 'svelte';
export let selectedWorkspaceName = '';
export let nodes = [];
@@ -11,6 +12,7 @@
let plugins = [];
let workspaceTools = [];
let toolsLoaded = false;
let requestedToolKind = '';
const todayTool = { id: '__today', title: 'Today', pluginId: 'verstak.shell', component: 'TodaySurface', shell: true };
const toolOrder = new Map([
@@ -31,8 +33,23 @@
$: if (displayedTools.length > 0 && (!activeToolKey || (toolsLoaded && !displayedTools.some(tool => toolKey(tool) === activeToolKey)))) {
activeToolKey = toolKey(todayTool);
}
$: if (requestedToolKind && workspaceTools.length > 0) {
const match = findWorkspaceTool(requestedToolKind);
if (match) {
requestedToolKind = '';
selectTool(match);
}
}
$: if (selectedWorkspaceName) loadTools();
onMount(() => {
window.addEventListener('verstak:workspace-open-tool', handleWorkspaceOpenTool);
});
onDestroy(() => {
window.removeEventListener('verstak:workspace-open-tool', handleWorkspaceOpenTool);
});
function toolKey(tool) {
return `${tool?.pluginId || ''}:${tool?.id || ''}`;
}
@@ -64,16 +81,29 @@
}));
}
function openWorkspaceTool(event) {
const kind = String(event?.detail?.kind || '').toLowerCase();
const match = workspaceTools.find(tool => {
function findWorkspaceTool(kind) {
kind = String(kind || '').toLowerCase();
return workspaceTools.find(tool => {
const text = `${tool?.title || ''} ${tool?.id || ''} ${tool?.pluginId || ''}`.toLowerCase();
if (kind === 'browser-inbox') return text.includes('browser') || text.includes('inbox');
return text.includes(kind);
});
}
function requestWorkspaceTool(kind) {
requestedToolKind = String(kind || '').toLowerCase();
const match = findWorkspaceTool(requestedToolKind);
if (match) selectTool(match);
}
function openWorkspaceTool(event) {
requestWorkspaceTool(event?.detail?.kind);
}
function handleWorkspaceOpenTool(event) {
requestWorkspaceTool(event?.detail?.kind);
}
async function loadTools() {
try {
toolsLoaded = false;