From fb605ddc7b45176a89a5179a35f6a8a82c4c6373 Mon Sep 17 00:00:00 2001 From: chengyongru Date: Thu, 8 Oct 2026 18:40:00 +0800 Subject: [PATCH] fix(webui): compact saved locations and remove directory shortcuts --- docs/webui.md | 4 -- .../components/thread/WorkspaceControls.tsx | 28 +++---------- webui/src/tests/workspace-picker.test.tsx | 42 +++++-------------- 3 files changed, 17 insertions(+), 57 deletions(-) diff --git a/docs/webui.md b/docs/webui.md index 904047501..81a2177da 100644 --- a/docs/webui.md +++ b/docs/webui.md @@ -307,10 +307,6 @@ Browsing does not change the workspace until you choose **Confirm**. **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**. -Within a directory column, **Up/Down** or **k/j** move the active row, -**Right** or **l** enters it, and **Left** or **h** opens the parent folder. -**Enter** also enters the active directory. These shortcuts apply while a -directory column has focus; letters typed into the path or filter stay as text. Directory columns settle on complete rows after scrolling. On a compatible host without the optional directory-browser capabilities, diff --git a/webui/src/components/thread/WorkspaceControls.tsx b/webui/src/components/thread/WorkspaceControls.tsx index ea27063f9..6c9f3d2d6 100644 --- a/webui/src/components/thread/WorkspaceControls.tsx +++ b/webui/src/components/thread/WorkspaceControls.tsx @@ -62,9 +62,6 @@ function PickerToolButton({ label, disabled, onClick, children }: { const DIRECTORY_ROW_HEIGHT = 44; const DIRECTORY_OVERSCAN = 4; -const DIRECTORY_NAVIGATION_KEYS: Record = { - h: "ArrowLeft", j: "ArrowDown", k: "ArrowUp", l: "ArrowRight", -}; function WorkspaceDirectoryColumn({ options, activeIndex, selectedPath, initialScrollTop, visitRevision, renderOption, children, style, className, ...props }: { options: PickerOption[]; @@ -502,7 +499,6 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, else if (selectedIndex + 1 < projects.length && sameWorkspacePath(projects[selectedIndex + 1].path, hoveredLocation)) savedSelectionJoin = "bottom"; } const breadcrumbs = workspaceBreadcrumbs(currentPath); - const parentPath = directory?.parent; const hostName = catalog?.host?.name ?? directory?.host; useLayoutEffect(() => { @@ -529,9 +525,6 @@ 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: "" }; - const option = activeOptions[activeOption]; - // 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; @@ -579,16 +572,13 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, - { event.preventDefault(); if (canBrowse) focusDirectory(); else inputRef.current?.focus(); }} onPointerDownCapture={() => setKeyboardInteraction(false)} onKeyDownCapture={event => { if (!["Alt", "Control", "Meta", "Shift"].includes(event.key)) setKeyboardInteraction(true); if (!canBrowse || pickingFolder || event.nativeEvent.isComposing) return; if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.key.toLowerCase() === "g") { event.preventDefault(); editPath(); } - else if (event.altKey && event.key === "ArrowLeft") { event.preventDefault(); moveHistory(-1); } - else if (event.altKey && event.key === "ArrowRight") { event.preventDefault(); moveHistory(1); } - else if (event.altKey && event.key === "ArrowUp" && parentPath) { event.preventDefault(); navigate(parentPath); } }} onEscapeKeyDown={event => { if (editingPath) { event.preventDefault(); cancelPathEditing(); } }} onCloseAutoFocus={event => { if (!openedWithKeyboard.current) event.preventDefault(); }}> @@ -604,11 +594,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
{editingPath || !canBrowse ? changeDraft(event.target.value)} onBlur={event => { if (canBrowse && !keyboardInteraction && event.relatedTarget !== confirmRef.current) cancelPathEditing(false); }} placeholder={t("workspace.dialog.manual")} aria-label={t("workspace.dialog.manual")} aria-invalid={displayedError ? true : undefined} aria-describedby={displayedError ? errorId : undefined} className="h-9 min-w-0 flex-1 rounded-[var(--picker-field-radius)] border-transparent shadow-none focus-visible:ring-0 text-[16px] leading-5 sm:text-[13px]" onKeyDown={event => { if (event.nativeEvent.isComposing) return; - if ((event.key === "ArrowDown" || event.key === "ArrowUp") && !event.altKey && activeOptions.length) { - event.preventDefault(); - const next = highlightActive ? (activeOption + (event.key === "ArrowDown" ? 1 : -1) + activeOptions.length) % activeOptions.length : event.key === "ArrowDown" ? 0 : activeOptions.length - 1; - setHighlightActive(true); setActiveIndex(next); - } else if (event.key === "Tab" && !event.shiftKey && canBrowse && absoluteDraft && (highlightActive || !/[\\/]$/.test(pathDraft))) { + if (event.key === "Tab" && !event.shiftKey && canBrowse && absoluteDraft && !/[\\/]$/.test(pathDraft)) { event.preventDefault(); void completePath(); } else if (event.key === "Enter") { event.preventDefault(); @@ -650,7 +636,6 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, sameWorkspacePath(currentPath, project.path) && "font-medium text-foreground group-hover/workspace-saved-row:bg-transparent dark:group-hover/workspace-saved-row:bg-transparent", sameWorkspacePath(hoveredLocation, project.path) && (savedSelectionJoin === "top" ? "rounded-b-none" : savedSelectionJoin === "bottom" ? "rounded-t-none" : undefined))}> {projectNameFromPath(project.path)} - {sameWorkspacePath(project.path, scope?.project_path ?? defaultScope.project_path) && } {favoriteButton(project.path)}
)} @@ -666,14 +651,13 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, onFocus={event => { if (event.target === event.currentTarget) { setActiveColumn(columnIndex); setActiveIndex(0); } }} onKeyDown={event => { if (event.target !== event.currentTarget || event.altKey || event.metaKey || event.ctrlKey || pickingFolder) return; - const key = DIRECTORY_NAVIGATION_KEYS[event.key] ?? event.key; const count = column.options.length; - if (count && ["ArrowDown", "ArrowUp", "Home", "End"].includes(key)) { + if (count && (event.key === "Home" || event.key === "End")) { event.preventDefault(); setHighlightActive(true); setActiveColumn(columnIndex); - setActiveIndex(key === "Home" ? 0 : key === "End" ? count - 1 : highlightActive ? (activeIndex + (key === "ArrowDown" ? 1 : -1) + count) % count : key === "ArrowDown" ? 0 : count - 1); - } else if (count && (key === "Enter" || key === "ArrowRight")) { + setActiveIndex(event.key === "Home" ? 0 : count - 1); + } else if (count && event.key === "Enter") { event.preventDefault(); activate(column.options[Math.min(activeIndex, count - 1)], columnIndex); - } else if (key === "ArrowLeft" && column.parent) { event.preventDefault(); navigate(column.parent); } + } }} renderOption={(option, index) =>