Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): compact saved locations and remove directory shortcuts
chengyongrufb605ddc7b45
diff --git a/docs/webui.md b/docs/webui.mdindex 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 directorycolumns with Shift+wheel horizontal scrolling; narrow screens show one folderat 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.tsxindex 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<string, string> = {- 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,</button></DialogTrigger></WorkspacePickerTooltip>- <DialogContent showCloseButton={false} layoutAnchor={layoutAnchor} centerInLayoutAnchor className="flex h-[min(37rem,calc(100%-2rem))] max-w-5xl flex-col gap-0 overflow-hidden p-0 text-[13px] leading-5 [--picker-sidebar-width:15rem] [--picker-toolbar-inset:0.75rem] [--picker-field-radius:calc(var(--radius-modal)_-_var(--picker-toolbar-inset))] sm:[--picker-toolbar-inset:1rem] dark:bg-background"+ <DialogContent showCloseButton={false} layoutAnchor={layoutAnchor} centerInLayoutAnchor className="flex h-[min(37rem,calc(100%-2rem))] max-w-5xl flex-col gap-0 overflow-hidden p-0 text-[13px] leading-5 [--picker-sidebar-width:11rem] [--picker-toolbar-inset:0.75rem] [--picker-field-radius:calc(var(--radius-modal)_-_var(--picker-toolbar-inset))] sm:[--picker-toolbar-inset:1rem] dark:bg-background"onOpenAutoFocus={event => { 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,<div className="flex min-w-0 flex-1 items-center rounded-[var(--picker-field-radius)] bg-background/80">{editingPath || !canBrowse ? <Input ref={inputRef} role="combobox" aria-expanded={open} aria-controls={`${optionsId}-${activeColumn}`} aria-activedescendant={highlightActive && activeOptions.length ? `${optionsId}-${activeColumn}-${activeOption}` : undefined} aria-autocomplete="list" aria-busy={loading} value={pathDraft} disabled={disabled || pickingFolder} onChange={event => 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))}><span className="min-w-0 flex-1 truncate">{projectNameFromPath(project.path)}</span>- {sameWorkspacePath(project.path, scope?.project_path ?? defaultScope.project_path) && <Check className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />}</button>{favoriteButton(project.path)}</div>)}@@ -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) => <div role="presentation" className={cn("workspace-picker-row", SIDEBAR_SELECTION_ITEM_CLASS)} data-keyboard-active={highlightActive && columnIndex === activeColumn && index === activeOption ? "" : undefined}><button id={`${optionsId}-${columnIndex}-${index}`} type="button" role="option" tabIndex={-1} aria-label={option.path} aria-selected={sameWorkspacePath(column.selectedPath, option.path)} aria-posinset={index + 1} aria-setsize={column.options.length} disabled={pickingFolder}diff --git a/webui/src/tests/workspace-picker.test.tsx b/webui/src/tests/workspace-picker.test.tsxindex 987807035..e57ce94c3 100644--- a/webui/src/tests/workspace-picker.test.tsx+++ b/webui/src/tests/workspace-picker.test.tsx@@ -529,8 +529,8 @@ describe("Workspace project picker", () => {await screen.findByRole("option", { name: "/srv/alpine" });expect(screen.getByRole("button", { name: "Confirm" })).toBeDisabled();expect(screen.queryByRole("alert")).not.toBeInTheDocument();- await user.keyboard("{ArrowDown}{ArrowDown}{Tab}");- expect(input).toHaveValue("/srv/alpine/");+ await user.keyboard("{Tab}");+ expect(input).toHaveValue("/srv/alpha/");expect(screen.getAllByRole("combobox")).toHaveLength(1);expect(screen.getAllByRole("listbox")).toHaveLength(1);await waitFor(() => expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled());@@ -558,9 +558,6 @@ describe("Workspace project picker", () => {await user.tab();expect(input).not.toHaveFocus();expect(input).toHaveValue("/srv/alpha/");- await user.click(input);- await user.keyboard("{ArrowUp}{Tab}");- expect(input).toHaveValue("/srv/alpha/docs/");});it("ignores a Tab completion after the user changes the path", async () => {@@ -655,25 +652,7 @@ describe("Workspace project picker", () => {expect(screen.queryByRole("option", { name: "/srv/other/child" })).not.toBeInTheDocument();expect(onChange).not.toHaveBeenCalled();});- it.each(["{ArrowLeft}", "h"])("moves to the focused column's parent with %s", async (key) => {- const user = userEvent.setup();- const browse = vi.fn((raw: string) => {- const path = raw.replace(/\/$/, "");- return Promise.resolve({ ...directory, path, parent: path.slice(0, path.lastIndexOf("/")) || "/",- entries: [{ name: "child", path: `${path}/child` }] });- });- render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={browse} onChange={vi.fn()} />);- await user.click(screen.getByRole("button", { name: "Switch working directory" }));- await user.click(await screen.findByRole("option", { name: "/srv/workspace/child" }));- await user.click(await screen.findByRole("option", { name: "/srv/workspace/child/child" }));- const ancestor = screen.getByRole("listbox", { name: "/srv/workspace", exact: true });- act(() => ancestor.focus());- await user.keyboard(key);- await screen.findByRole("listbox", { name: "/srv", exact: true });- expect(screen.getAllByRole("listbox")).toHaveLength(1);- });-- it("uses jkl to browse the active column without consuming text input", async () => {+ it("leaves directory selection unchanged for hjkl and arrow keys", async () => {const user = userEvent.setup();const onChange = vi.fn();const browse = vi.fn((raw: string, query: string) => {@@ -685,26 +664,27 @@ describe("Workspace project picker", () => {const trigger = screen.getByRole("button", { name: "Switch working directory" });await user.click(trigger);const alpha = await screen.findByRole("option", { name: "/srv/workspace/alpha" });- const beta = screen.getByRole("option", { name: "/srv/workspace/beta" });const column = screen.getByRole("listbox");act(() => column.focus());- await user.keyboard("jjk");- expect(column).toHaveAttribute("aria-activedescendant", alpha.id);+ const requests = browse.mock.calls.length;+ await user.keyboard("hjkl{ArrowDown}{ArrowUp}{ArrowLeft}{ArrowRight}{Alt>}{ArrowLeft}{ArrowRight}{ArrowUp}{/Alt}");+ expect(column).not.toHaveAttribute("aria-activedescendant");+ expect(column).toHaveFocus();expect(alpha).not.toHaveFocus();- expect(beta).not.toHaveFocus();- await user.keyboard("l");- await screen.findByRole("listbox", { name: "/srv/workspace/alpha", exact: true });+ expect(browse).toHaveBeenCalledTimes(requests);expect(trigger).not.toHaveFocus();expect(onChange).not.toHaveBeenCalled();const filter = screen.getByRole("textbox", { name: "Filter this folder" });await user.type(filter, "hjkl");expect(filter).toHaveValue("hjkl");- expect(screen.getByRole("listbox", { name: "/srv/workspace/alpha", exact: true })).toBeInTheDocument();+ expect(screen.getByRole("listbox", { name: "/srv/workspace", exact: true })).toBeInTheDocument();await user.click(screen.getByRole("button", { name: /^Edit path:/ }));const editor = screen.getByRole("combobox");await user.clear(editor);await user.type(editor, "/srv/hjkl");+ await user.keyboard("{ArrowDown}{ArrowUp}");expect(editor).toHaveValue("/srv/hjkl");+ expect(editor).not.toHaveAttribute("aria-activedescendant");});it("keeps ancestor columns and replaces descendants when another folder is opened", async () => {