Fix global search folder navigation

This commit is contained in:
mirivlad 2026-06-30 20:57:58 +08:00
parent 268e79d2f0
commit b28039cf0d
3 changed files with 78 additions and 4 deletions

View File

@ -31,6 +31,21 @@ test.describe('UX follow-up fixes', () => {
await expect(page.locator('[data-global-search-results]')).toContainText('project-only.txt', { timeout: 10000 });
});
test('global search folder results open the workspace Files context', async ({ page }) => {
const search = page.locator('[data-global-search-input]');
await search.fill('Project/Notes');
const folderResult = page.locator('[data-global-search-result-type="Folder"][data-global-search-result-path="Project/Notes"]');
await expect(folderResult).toBeVisible({ timeout: 10000 });
await folderResult.click();
await expect(page.locator('.workspace-title')).toHaveText('Project', { timeout: 10000 });
await expect(page.getByRole('tab', { name: 'Files' })).toHaveAttribute('aria-selected', 'true');
await expect(page.locator('.files-root')).toBeVisible();
await expect(page.locator('.files-breadcrumb')).toContainText('Notes');
await expect(page.locator('.files-item')).toContainText('Overview.md');
});
test('plugin settings modal gives complex panels enough space', async ({ page }) => {
await openPluginManager(page);
await page.locator('.plugin-card').filter({ hasText: 'verstak.platform-test' }).getByRole('button', { name: 'Settings' }).click();

View File

@ -180,6 +180,7 @@
rank: entry.type === 'folder' ? 30 : 40,
action: entry.type === 'folder' ? 'file-folder' : 'file',
path,
nodes,
});
}
@ -209,6 +210,28 @@
}));
return;
}
if (item.action === 'file-folder') {
const parts = String(item.path || '').split('/').filter(Boolean);
const workspaceName = parts[0] || '';
const localPath = parts.slice(1).join('/');
if (workspaceName) {
window.__filesHistoryByWorkspace = window.__filesHistoryByWorkspace || {};
window.__filesHistoryByWorkspace[workspaceName] = {
stack: [localPath],
index: 0,
currentPath: localPath,
};
const detail = { workspaceName };
if (Array.isArray(item.nodes) && item.nodes.length > 0) detail.nodes = item.nodes;
window.dispatchEvent(new CustomEvent('verstak:workspace-selected', {
detail
}));
window.dispatchEvent(new CustomEvent('verstak:workspace-open-tool', {
detail: { kind: 'files' }
}));
}
return;
}
if (item.action === 'file') {
const response = await App.OpenWorkbenchResource('verstak.search', {
kind: 'vault-file',
@ -241,7 +264,13 @@
<div class="global-search-results" data-global-search-results>
{#if results.length}
{#each results as item}
<button type="button" class="global-search-result" on:mousedown|preventDefault={() => openResult(item)}>
<button
type="button"
class="global-search-result"
data-global-search-result-type={item.type}
data-global-search-result-path={item.path || ''}
on:mousedown|preventDefault={() => openResult(item)}
>
<span class="global-search-result-title">{item.title}</span>
<span class="global-search-result-meta">{item.type} · {item.subtitle}</span>
</button>

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;