From f78a0994c8500d4b91d897029c04d63a181120e2 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Thu, 8 Oct 2026 10:16:28 +0800 Subject: [PATCH] fix(webui): preserve picker compatibility and column keyboard navigation --- docs/webui.md | 18 ++++++++++++++--- .../tests/test_websocket_http_routes.py | 3 +++ .../components/thread/WorkspaceControls.tsx | 11 +++++----- webui/src/tests/app-layout.test.tsx | 5 ++++- webui/src/tests/thread-composer.test.tsx | 20 +++++++++++-------- webui/src/tests/workspace-picker.test.tsx | 18 +++++++++++++++++ 6 files changed, 57 insertions(+), 18 deletions(-) diff --git a/docs/webui.md b/docs/webui.md index 8eb744418..2b5d2006c 100644 --- a/docs/webui.md +++ b/docs/webui.md @@ -293,9 +293,21 @@ or a result you must retain. Use the workspace picker to browse folders on the connected nanobot host, enter an absolute path, or return to recent and starred projects; favorites persist -across gateway restarts. Tab completes paths and Shift+wheel scrolls directory -columns. -Project paths refer to the gateway machine, not the browser's filesystem. +across gateway restarts. The title identifies the host. Project paths refer to +that machine, not the browser's filesystem. + +Use the breadcrumbs, Back, Forward, and Parent folder controls to navigate. +**Filter this folder** only filters the current directory. **Edit path** (or +**Cmd/Ctrl+Shift+G**) accepts a host path; Tab completes it and Enter opens it. +Browsing does not change the workspace until you choose **Select folder**. +**Cancel** leaves the current workspace unchanged. Desktop uses directory +columns with Shift+wheel horizontal scrolling; narrow screens show one folder +at a time, with favorites and recent projects under **Saved locations**. + +On a compatible host without the optional directory-browser capabilities, +manual path entry remains available. Browse and favorite requests are not sent +to that host. The gateway still validates the selected workspace and owns its +access policy. Selecting a project does not replace the configured agent workspace. The two paths have different responsibilities: diff --git a/nanobot/channels/websocket/tests/test_websocket_http_routes.py b/nanobot/channels/websocket/tests/test_websocket_http_routes.py index bfb2e872f..7bf6da5b3 100644 --- a/nanobot/channels/websocket/tests/test_websocket_http_routes.py +++ b/nanobot/channels/websocket/tests/test_websocket_http_routes.py @@ -3682,6 +3682,9 @@ def test_workspace_payload_separates_remote_project_selection_from_full_access( controls = json.loads(response.body.decode())["controls"] assert controls["can_change_project"] is True assert controls["can_use_full_access"] is can_use_full_access + assert controls["can_browse_directories"] is True + assert controls["can_resolve_project"] is True + assert controls["can_manage_favorites"] is True def test_local_browser_request_requires_loopback_host_and_forwarded_origin() -> None: diff --git a/webui/src/components/thread/WorkspaceControls.tsx b/webui/src/components/thread/WorkspaceControls.tsx index 9cc0922c7..0aedba3f4 100644 --- a/webui/src/components/thread/WorkspaceControls.tsx +++ b/webui/src/components/thread/WorkspaceControls.tsx @@ -32,7 +32,7 @@ function WorkspaceFavoriteButton({ path, pinned, busy, onToggle }: { } type PickerOption = ProjectDirectory & { kind: "directory" | "manual" }; -type PickerColumn = { path: string; options: PickerOption[]; selectedPath: string | null; hidden: boolean }; +type PickerColumn = { path: string; parent: string | null; options: PickerOption[]; selectedPath: string | null; hidden: boolean }; function WorkspacePickerTooltip({ label, children }: { label: string; children: ReactElement }) { return ( @@ -434,7 +434,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, if (!canBrowse) { void chooseProject(project.path, project.name); return; } navigate(project.path); } - const columns: PickerColumn[] = [...previousColumns, { path: directory?.path ?? requestedPath, options, selectedPath: null, hidden: showHidden }]; + const columns: PickerColumn[] = [...previousColumns, { path: directory?.path ?? requestedPath, parent: directory?.parent ?? null, options, selectedPath: null, hidden: showHidden }]; const activeOptions = columns[activeColumn]?.options ?? options; const activeOption = Math.min(activeIndex, Math.max(activeOptions.length - 1, 0)); const selectionPath = canBrowse ? (!loading && directory && !directory.partial ? directory.path : null) : (pathDraft.trim() ? absoluteDraft ? pathDraft.trim() : null : scope?.project_path ?? defaultScope?.project_path); @@ -464,10 +464,9 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, async function completePath(keepEditing = true) { if (!absoluteDraft) { setPathError(t("workspace.dialog.absolutePathRequired")); return; } const request = workspacePathCompletionQuery(pathDraft) ?? { path: basePath, query: "" }; - // Complete an exact address before descending into its implicitly active child. - const completingAddress = absoluteDraft && !!request.query && !highlightActive; const option = activeOptions[activeOption]; - if (highlightActive && option && option.kind !== "manual" && !completingAddress) { navigate(option.path, undefined, keepEditing); return; } + // Only an explicit keyboard selection may enter a child before resolving the address. + if (highlightActive && option && option.kind !== "manual") { navigate(option.path, undefined, keepEditing); return; } if (!directoryCache || !canBrowse) return; const id = ++completionRequest.current; const session = pickerSession.current; @@ -604,7 +603,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, setActiveIndex(event.key === "Home" ? 0 : event.key === "End" ? count - 1 : highlightActive ? (activeIndex + (event.key === "ArrowDown" ? 1 : -1) + count) % count : event.key === "ArrowDown" ? 0 : count - 1); } else if (count && (event.key === "Enter" || event.key === "ArrowRight")) { event.preventDefault(); activate(column.options[Math.min(activeIndex, count - 1)], columnIndex); - } else if (event.key === "ArrowLeft" && parentPath) { event.preventDefault(); navigate(parentPath); } + } else if (event.key === "ArrowLeft" && column.parent) { event.preventDefault(); navigate(column.parent); } }} renderOption={(option, index) =>