fix(webui): refine workspace picker navigation and macOS behavior

This commit is contained in:
Xubin Ren authored and chengyongru committed 2026-10-08 20:33:15 +08:00
1 parent 4ca146aef3
commit cc5f2a84d3
19 files changed
+716 -187

No files matched your search

+3
View File
@@ -498,6 +498,9 @@ export interface WorkspacesPayload {
controls: {
can_change_project: boolean;
can_use_full_access: boolean;
can_browse_directories?: boolean;
can_resolve_project?: boolean;
can_manage_favorites?: boolean;
};
}
+18
View File
@@ -62,4 +62,22 @@ export function workspaceDirectoryPrefix(path: string): string {
return path.replace(/[\\/]+$/, "") + separator;
}
/** Build navigation from the gateway path, never the browser's operating system. */
export function workspaceBreadcrumbs(path: string): { name: string; path: string }[] {
const windows = /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("\\\\");
const separator = windows ? "\\" : "/";
const normalized = windows ? path.replace(/\//g, "\\") : path;
const root = windows
? normalized.match(/^(?:[A-Za-z]:\\|\\\\[^\\]+\\[^\\]+\\?)/)?.[0]
: normalized.startsWith("/") ? "/" : normalized.startsWith("~") ? "~" : undefined;
if (!root) return [{ name: path, path }];
const crumbs = [{ name: root, path: root }];
let current = root.replace(/[\\/]$/, "");
for (const name of normalized.slice(root.length).split(separator).filter(Boolean)) {
current += separator + name;
crumbs.push({ name, path: current });
}
return crumbs;
}
export type BrowseWorkspaceDirectories = (path: string, query: string, showHidden: boolean, allowPartial?: boolean) => Promise<WorkspaceDirectoriesPayload>;