fix(webui): reveal favorite stars on hover and trim user guide

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-08 20:33:15 +08:00
1 parent 8e8b14897e
commit ee7eda3084
14 files changed
+128 -177

No files matched your search

+39 -110
View File
@@ -66,17 +66,15 @@ WebUI beyond localhost or want a browser password:
The WebUI is served by the WebSocket channel on port `8765` by default. The The WebUI is served by the WebSocket channel on port `8765` by default. The
gateway health endpoint, `18790` by default, is not the browser UI. gateway health endpoint, `18790` by default, is not the browser UI.
## First 10 Minutes ## Setup
Use the WebUI as the primary setup surface: Configure a provider, credentials, and an active model preset in **Settings →
Models**. Channels and web, voice, and image providers have their own Settings
panels; CLI Apps and MCP integrations are managed in **Apps**. Controls that
require a gateway restart indicate it in the WebUI.
1. Open **Settings → Models** and configure a provider, credential, and active model preset. Normal setup does not require editing `config.json`. The reference docs cover
2. Send `Hello!` in a new topic to prove the selected model works. options outside the WebUI and deployments that manage configuration as code.
3. Start a separate topic before project work, then choose the intended workspace and access mode.
4. Add only one capability next: a chat channel in **Settings → Channels**, a web/voice/image provider in **Settings**, or an App/MCP integration in **Apps**.
5. Restart when the WebUI shows a restart requirement, then test that capability with the smallest possible request.
This path avoids hand-editing `config.json` for normal setup. Use the reference docs when you need an option the WebUI does not expose or when you manage config as code.
## What It Is For ## What It Is For
@@ -97,12 +95,10 @@ This path avoids hand-editing `config.json` for normal setup. Use the reference
### Optional GitHub invitation ### Optional GitHub invitation
Returning users may see an illustrated invitation to star nanobot on GitHub. The optional GitHub star invitation can be dismissed temporarily with **Maybe
It follows the WebUI language and theme; the button's star animation also later**, or permanently with **Don't ask again**. Opening GitHub from the
supports keyboard focus and respects reduced-motion preferences. **Maybe later**, invitation also stops reminders. The permanent preference is shared across
the close button, or Escape dismisses it for now. **Don't ask again** or opening browsers connected to the same gateway instance.
GitHub from the invitation stops future reminders for the gateway instance,
including in other browsers. Starring is optional and never required to use nanobot.
## Topic Workspace ## Topic Workspace
@@ -111,14 +107,9 @@ workspace selection, and linked automations. Use a new topic when you want a
separate context; use fork when you want to continue from an existing point separate context; use fork when you want to continue from an existing point
without changing the original thread. without changing the original thread.
On touch devices, sidebar action buttons stay visible with larger touch areas Sidebar action menus appear on hover or keyboard focus on desktop and remain
for topics, conversation groups, panes, and projects. Tap a title to select it visible on touch devices. They include rename, fork, group, move, and delete
or the adjacent action button for its menu. Desktop actions still appear on operations.
hover or keyboard focus. Press Escape in an action menu to return focus to its
button and continue with Tab, including from the **Move to** submenu. ArrowLeft
leaves the submenu and returns to **Move to** without closing the parent menu.
Choosing Rename instead moves focus into the
dialog; clicking outside a menu keeps focus at the clicked destination.
Drag a topic within its current sidebar group to keep frequently used work in Drag a topic within its current sidebar group to keep frequently used work in
your preferred order. Drag a topic from the sidebar into the composer when you your preferred order. Drag a topic from the sidebar into the composer when you
@@ -197,33 +188,11 @@ explains the restriction and keeps **Open in browser** and **Copy link** availab
Sites can still refuse embedding through their own security headers. nanobot Sites can still refuse embedding through their own security headers. nanobot
does not proxy pages or bypass those restrictions; use **Open in browser** instead. does not proxy pages or bypass those restrictions; use **Open in browser** instead.
On touch devices with Visual Viewport support, the app follows the visible area On touch devices, navigation, search, menus, and the composer fit the visible
when the on-screen keyboard opens or pans the page. Navigation and the composer area above the on-screen keyboard. Messages and results scroll independently.
stay in view while messages scroll independently. Session search also follows Landscape layouts use side-by-side controls when height is limited. Pinch zoom
the visible area: the search field stays above the keyboard and results scroll preserves the existing layout; compact text fields avoid Safari's automatic
inside the dialog. In short landscape viewports, its input and results sit side focus zoom. Preview tabs remain horizontally scrollable on narrow screens.
by side so a result remains reachable. Taller dialogs scroll from their top
instead of centering content outside the visible area. The `@` mention and `/` command
menus use the visible app area above or below the composer, including when the
keyboard pans the page. Scroll within a menu to reach more results. Mention rows
use the app's larger touch targets on phones while retaining desktop density.
In very short, wide viewports (such as landscape with the keyboard open), menus
sit beside the input instead of overflowing the scrollable composer. Scroll the
menu for more candidates and the input area for its controls. If the browser
bars and keyboard leave no usable page area, dismiss
the keyboard or return to portrait. Pinch zoom keeps the existing layout instead of resizing it to the
magnified area; normal fitting resumes when
you return to the default zoom. Non-touch desktop and native-host layout remain
unchanged.
On touch devices, compact text fields use a readable 16px minimum baseline to
avoid Safari automatically zooming the page on focus. Desktop field density
and manual page zoom remain unchanged.
On touch devices, preview tab controls and
the full-screen image viewer's close button use larger touch areas without
enlarging the icons. Preview tabs remain horizontally scrollable when space is
limited.
Open the context indicator beside the composer model badge to see how much of Open the context indicator beside the composer model badge to see how much of
the model's context window is in use. The **Recent rounds** chart shows input the model's context window is in use. The **Recent rounds** chart shows input
@@ -262,12 +231,8 @@ restart behavior.
## Temporary Chats ## Temporary Chats
Use a temporary chat for a conversation that should not be added to nanobot's **Temporary chat** in the new-topic header starts a conversation outside saved
topic history or long-term memory: topic history and long-term memory.
1. Select **New topic**.
2. Select the **Temporary chat** control in the page header.
3. Send the first message.
You can keep more than one temporary chat open and switch between them under You can keep more than one temporary chat open and switch between them under
**Temporary chats** in the sidebar while the current WebUI connection remains **Temporary chats** in the sidebar while the current WebUI connection remains
@@ -291,57 +256,24 @@ or a result you must retain.
## Workspace and Access ## Workspace and Access
The folder label shows the current working directory in the composer toolbar. The composer’s folder control selects the project directory on the connected
On narrow screens, it sits below the input on the left, opposite the access gateway, including remote and headless hosts. Paths refer to that machine,
control. rather than the browser’s filesystem. Windows drive and UNC paths are supported;
Hover it to see the full path, or click it to switch directories before starting a local host may also offer its native folder chooser. Hosts without directory
project-specific work. This gives the agent the right project context for file paths, shell commands, and topic browsing support accept an absolute path manually.
metadata. The picker opens one dialog with a saved-locations sidebar and a
directory browser. Favorites and recent projects remain in the sidebar while
you navigate. Right-click a folder to pin or unpin it without selecting it.
Right-click a column's empty area to pin its directory. Favorites keep their
pin order, are saved by the connected gateway, and remain available after a
restart. A deleted folder can still be unpinned.
Typing a name filters the current directory only; typing an absolute host path The picker combines column browsing, recent projects, and favorites. Names
lists its directories as you edit. An unfinished folder name filters its parent filter the current directory; absolute paths navigate directly, with partial
directory by prefix. Use the arrow keys to highlight a result, then Tab to folder names matched against their parent. Arrow keys highlight results, Tab
complete its path or Enter to enter the directory. Opening a folder preserves completes paths, and Shift+wheel scrolls deep directory trails horizontally.
its column and displays its subdirectories in a new column to the right. **Select** confirms the resolved directory.
Column widths stay stable as you navigate; deeper levels scroll horizontally.
Hold Shift while using the mouse wheel over directory columns to scroll
horizontally. Ordinary wheel scrolling remains vertical.
The picker caches up to 64 directory listings for 30 seconds, reuses in-flight
requests, and displays cached listings immediately. Only typed queries are
debounced; entering a folder starts its request immediately.
Selecting a different folder in an earlier column replaces the columns to its
right. Clicking a saved location starts a new directory trail. Expanded branches
have a persistent selection fill; pointer hover and keyboard focus remain
visually distinct. Directory columns show folder names; the input and hover
hints retain full paths. Favorites and recent projects show full paths to
distinguish folders with the same name. On narrow screens, saved locations move
into a compact area above the directory columns.
Use **Select** to confirm the directory being browsed. Only a fully A folder’s star toggles its favorite status without changing the project.
resolved directory can be selected or pinned. **Show hidden folders** includes Stars appear on hover or keyboard focus, and remain visible on touch devices.
hidden entries. Favorites retain their order across gateway restarts; deleted folders can still
Escape or clicking outside closes the dialog. Shift+Tab moves focus back. be removed from favorites. Directory listings may be cached for up to 30
seconds. Browsing exposes directory names, not file contents, and does not
The dialog is centered within the message thread and keeps a fixed height change access permissions.
within the available space, so changing results cannot move the input field.
Loading, errors, and completion candidates appear in the active column. Each column scrolls vertically, and deeper paths scroll
the columns horizontally. Up to three columns
fit on desktop; narrower windows show fewer columns.
The directory browser works on Windows,
Linux, and macOS hosts, including remote gateways and environments without a
desktop. It lists directory names without reading file contents or changing the
agent's access mode. Windows drive paths and UNC paths can be entered directly.
A locally hosted WebUI also offers the operating system's folder chooser when
available. You can enter an absolute host path in the search field; gateways
without directory browsing support retain this option. The browser's local
filesystem is never used for project selection.
Selecting a project does not replace the configured agent workspace. The two Selecting a project does not replace the configured agent workspace. The two
paths have different responsibilities: paths have different responsibilities:
@@ -371,8 +303,8 @@ selected project. These tool exceptions do not broaden the browser's file
preview boundary. preview boundary.
Remote WebUI connections may reduce access for the current workspace and may Remote WebUI connections may reduce access for the current workspace and may
select a different workspace by browsing directories or entering its server-side path. A remote project select a different workspace by browsing directories or entering its server-side
change must use Restricted mode; enabling Full Access remains limited to local path. A remote project change must use Restricted mode; enabling Full Access remains limited to local
and native clients. and native clients.
## Composer ## Composer
@@ -598,9 +530,6 @@ package and skill installs disabled unless that is intentional.
Optional feature installs use pip's configured package index, including Optional feature installs use pip's configured package index, including
`PIP_INDEX_URL`. skills.sh marketplace installs use `npx` instead. `PIP_INDEX_URL`. skills.sh marketplace installs use `npx` instead.
Leave remote package installs disabled when the WebUI is exposed beyond a
private, trusted network.
## Troubleshooting ## Troubleshooting
### Links and website previews ### Links and website previews
@@ -1,13 +1,11 @@
import { FullAccessIcon, WorkspaceIcon, RestrictedAccessIcon } from "@/components/icons/product-icons"; import { FullAccessIcon, WorkspaceIcon, RestrictedAccessIcon } from "@/components/icons/product-icons";
import * as Menu from "@radix-ui/react-menu";
import { useFloatingPortal } from "@/components/ui/floating-portal";
import type { ReactElement } from "react"; import type { ReactElement } from "react";
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Check, FolderOpen, Search } from "lucide-react"; import { Check, FolderOpen, Search, Star } from "lucide-react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { ToggleButton } from "@/components/settings/ToggleButton"; import { ToggleButton } from "@/components/settings/ToggleButton";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { floatingItemClassName, floatingItemFocusClassName, floatingSurfaceClassName, floatingSurfaceMotionClassName } from "@/components/ui/floating-surface"; import { floatingItemClassName, floatingItemFocusClassName } from "@/components/ui/floating-surface";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Dialog, DialogContent, DialogTrigger, DialogTitle, DialogDescription } from "@/components/ui/dialog"; import { Dialog, DialogContent, DialogTrigger, DialogTitle, DialogDescription } from "@/components/ui/dialog";
@@ -17,39 +15,19 @@ import { getRuntimeHost } from "@/lib/runtime";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { isAbsoluteWorkspacePath, projectNameFromPath, sameWorkspacePath, scopeWithAccessMode, workspacePathCompletionQuery, workspaceDirectoryPrefix, selectedProjectScope, type BrowseWorkspaceDirectories } from "@/lib/workspace"; import { isAbsoluteWorkspacePath, projectNameFromPath, sameWorkspacePath, scopeWithAccessMode, workspacePathCompletionQuery, workspaceDirectoryPrefix, selectedProjectScope, type BrowseWorkspaceDirectories } from "@/lib/workspace";
function WorkspaceFolderMenu({ path, pinned, busy, onToggle, onRequestFocus, children }: { function WorkspaceFavoriteButton({ path, pinned, busy, onToggle }: {
path: string; pinned: boolean; busy: boolean; path: string; pinned: boolean; busy: boolean; onToggle: () => void;
onToggle: () => void; onRequestFocus: () => void; children: ReactElement;
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const portal = useFloatingPortal(); const label = t(pinned ? "workspace.picker.unpin" : "workspace.picker.pin", { name: projectNameFromPath(path) });
const [open, setOpen] = useState(false);
const point = useRef({ x: 0, y: 0 });
const anchor = useRef({ getBoundingClientRect: () => new DOMRect(point.current.x, point.current.y, 0, 0) });
return ( return (
<Menu.Root open={open} onOpenChange={setOpen}> <WorkspacePickerTooltip label={label}>
<Menu.Anchor virtualRef={anchor} /> <button type="button" aria-label={label} aria-pressed={pinned} disabled={busy}
<div className="contents" onContextMenu={event => { onMouseDown={event => event.preventDefault()} onClick={onToggle}
event.preventDefault(); event.stopPropagation(); className="workspace-picker-favorite touch-target absolute right-1 top-1/2 inline-flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground outline-none hover:bg-foreground/[0.055] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none">
point.current = { x: event.clientX, y: event.clientY }; setOpen(true); <Star className={cn("h-3.5 w-3.5", pinned && "fill-current text-foreground")} />
}} onKeyDown={event => { </button>
if (event.key !== "ContextMenu" && !(event.key === "F10" && event.shiftKey)) return; </WorkspacePickerTooltip>
event.preventDefault(); event.stopPropagation();
const bounds = (event.target as HTMLElement).getBoundingClientRect();
point.current = { x: bounds.left, y: bounds.bottom }; setOpen(true);
}}>{children}</div>
<Menu.Portal container={portal ?? undefined}>
<Menu.Content align="start" sideOffset={4} collisionPadding={12}
className={cn(floatingSurfaceClassName, floatingSurfaceMotionClassName, "min-w-40 rounded-control p-1")}
onContextMenu={event => { event.preventDefault(); event.stopPropagation(); }}
onCloseAutoFocus={event => { event.preventDefault(); onRequestFocus(); }}>
<Menu.Item disabled={busy} onSelect={onToggle}
className={cn(floatingItemClassName, floatingItemFocusClassName, "cursor-default data-[disabled]:pointer-events-none data-[disabled]:opacity-50")}>
{t(pinned ? "workspace.picker.unpin" : "workspace.picker.pin", { name: projectNameFromPath(path) })}
</Menu.Item>
</Menu.Content>
</Menu.Portal>
</Menu.Root>
); );
} }
@@ -330,9 +308,9 @@ export function WorkspaceProjectPicker({ isHero, connected = false, disabled, sc
const favorites = catalog?.favorite_projects ?? []; const favorites = catalog?.favorite_projects ?? [];
const canFavorite = !!catalog?.controls.can_manage_favorites && !!onFavoriteProject; const canFavorite = !!catalog?.controls.can_manage_favorites && !!onFavoriteProject;
const isFavorite = (path: string) => favorites.some(item => sameWorkspacePath(item.path, path)); const isFavorite = (path: string) => favorites.some(item => sameWorkspacePath(item.path, path));
function folderMenu(path: string, children: ReactElement, enabled = true) { function favoriteButton(path: string) {
return canFavorite && enabled ? <WorkspaceFolderMenu path={path} pinned={isFavorite(path)} busy={favoriteBusy || pickingFolder} return canFavorite ? <WorkspaceFavoriteButton path={path} pinned={isFavorite(path)} busy={favoriteBusy || pickingFolder}
onToggle={() => void toggleFavorite(path)} onRequestFocus={() => inputRef.current?.focus()}>{children}</WorkspaceFolderMenu> : children; onToggle={() => { void toggleFavorite(path); inputRef.current?.focus(); }} /> : null;
} }
const toggleFavorite = async (path: string) => { const toggleFavorite = async (path: string) => {
@@ -437,34 +415,37 @@ export function WorkspaceProjectPicker({ isHero, connected = false, disabled, sc
{[{ label: t("workspace.picker.favorites"), projects: favorites, favorite: true }, { label: t("workspace.picker.recent"), projects: recentProjects, favorite: false }].map(section => ( {[{ label: t("workspace.picker.favorites"), projects: favorites, favorite: true }, { label: t("workspace.picker.recent"), projects: recentProjects, favorite: false }].map(section => (
<section key={section.label} className="min-w-0 shrink-0 w-48 sm:w-auto"> <section key={section.label} className="min-w-0 shrink-0 w-48 sm:w-auto">
<h3 className="px-3 py-2 text-[11px] font-medium text-muted-foreground">{section.label}</h3> <h3 className="px-3 py-2 text-[11px] font-medium text-muted-foreground">{section.label}</h3>
{section.projects.map(project => <div key={project.path}>{folderMenu(project.path, {section.projects.map(project => <div key={project.path} className="workspace-picker-row relative">
<button type="button" aria-label={project.path} aria-current={sameWorkspacePath(basePath, project.path) ? "location" : undefined} <button type="button" aria-label={project.path} aria-current={sameWorkspacePath(basePath, project.path) ? "location" : undefined}
disabled={pickingFolder} onMouseDown={event => event.preventDefault()} onClick={() => openShortcut(project)} disabled={pickingFolder} onMouseDown={event => event.preventDefault()} onClick={() => openShortcut(project)}
className={cn(floatingItemClassName, floatingItemFocusClassName, "flex min-h-11 w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-foreground/[0.055] dark:hover:bg-white/[0.08]", sameWorkspacePath(basePath, project.path) && "bg-primary/10 text-primary")}> className={cn(floatingItemClassName, floatingItemFocusClassName, "flex min-h-11 w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-foreground/[0.055] dark:hover:bg-white/[0.08]", canFavorite && "pr-12", sameWorkspacePath(basePath, project.path) && "bg-primary/10 text-primary")}>
<WorkspacePickerPath path={project.path} /> <WorkspacePickerPath path={project.path} />
{sameWorkspacePath(project.path, scope?.project_path ?? defaultScope.project_path) && <Check className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />} {sameWorkspacePath(project.path, scope?.project_path ?? defaultScope.project_path) && <Check className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />}
</button>)}</div>)} </button>
{favoriteButton(project.path)}
</div>)}
{section.favorite && !favorites.length && canFavorite && <p className="px-3 text-[11px] leading-relaxed text-muted-foreground">{t("workspace.picker.favoriteHint")}</p>} {section.favorite && !favorites.length && canFavorite && <p className="px-3 text-[11px] leading-relaxed text-muted-foreground">{t("workspace.picker.favoriteHint")}</p>}
</section> </section>
))} ))}
</nav> </nav>
<div ref={attachColumns} data-workspace-columns className="flex flex-1 min-h-0 min-w-0 overflow-x-auto overscroll-x-contain"> <div ref={attachColumns} data-workspace-columns className="flex flex-1 min-h-0 min-w-0 overflow-x-auto overscroll-x-contain">
{columns.map((column, columnIndex) => <div key={columnIndex} className="contents">{folderMenu(column.path, <div id={`${optionsId}-${columnIndex}`} role="listbox" aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === previousColumns.length && loading} style={{ width: `${100 / visibleColumns}%` }} className={cn("min-w-0 shrink-0 overflow-x-hidden overflow-y-auto border-r border-transparent px-1 py-1", !!columns[columnIndex + 1]?.options.length && "border-border/50")}> {columns.map((column, columnIndex) => <div key={columnIndex} id={`${optionsId}-${columnIndex}`} role="listbox" aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === previousColumns.length && loading} style={{ width: `${100 / visibleColumns}%` }} className={cn("min-w-0 shrink-0 overflow-x-hidden overflow-y-auto border-r border-transparent px-1 py-1", !!columns[columnIndex + 1]?.options.length && "border-border/50")}>
{column.options.map((option, index) => <div key={`${option.kind}-${option.path}`} role="presentation"> {column.options.map((option, index) => <div key={`${option.kind}-${option.path}`} role="presentation" className="workspace-picker-row relative" data-keyboard-active={highlightActive && columnIndex === activeColumn && index === activeOption ? "" : undefined}>
{folderMenu(option.path, <button id={`${optionsId}-${columnIndex}-${index}`} type="button" role="option" aria-label={option.path} aria-selected={sameWorkspacePath(column.selectedPath, option.path)} disabled={pickingFolder} <button id={`${optionsId}-${columnIndex}-${index}`} type="button" role="option" aria-label={option.path} aria-selected={sameWorkspacePath(column.selectedPath, option.path)} disabled={pickingFolder}
onPointerMove={() => { setHighlightActive(false); setActiveColumn(columnIndex); setActiveIndex(index); }} onPointerMove={() => { setHighlightActive(false); setActiveColumn(columnIndex); setActiveIndex(index); }}
onMouseDown={event => event.preventDefault()} onClick={() => activate(option, columnIndex)} onMouseDown={event => event.preventDefault()} onClick={() => activate(option, columnIndex)}
className={cn(floatingItemClassName, floatingItemFocusClassName, "flex min-h-11 w-full min-w-0 items-center gap-3 px-3 py-2 text-left hover:bg-foreground/[0.055] dark:hover:bg-white/[0.08] disabled:opacity-50", className={cn(floatingItemClassName, floatingItemFocusClassName, "flex min-h-11 w-full min-w-0 items-center gap-3 px-3 py-2 text-left hover:bg-foreground/[0.055] dark:hover:bg-white/[0.08] disabled:opacity-50", canFavorite && "pr-12",
sameWorkspacePath(column.selectedPath, option.path) && "bg-primary/10 text-primary font-medium hover:bg-primary/10", sameWorkspacePath(column.selectedPath, option.path) && "bg-primary/10 text-primary font-medium hover:bg-primary/10",
highlightActive && columnIndex === activeColumn && index === activeOption && "ring-1 ring-inset ring-ring")}> highlightActive && columnIndex === activeColumn && index === activeOption && "ring-1 ring-inset ring-ring")}>
{option.kind === "directory" ? <WorkspacePickerTooltip label={option.path}><span className="min-w-0 flex-1 truncate text-[13px]">{option.name}</span></WorkspacePickerTooltip> : <WorkspacePickerPath path={option.path} />} {option.kind === "directory" ? <WorkspacePickerTooltip label={option.path}><span className="min-w-0 flex-1 truncate text-[13px]">{option.name}</span></WorkspacePickerTooltip> : <WorkspacePickerPath path={option.path} />}
{sameWorkspacePath(option.path, scope?.project_path ?? defaultScope.project_path) && <Check className="h-4 w-4 shrink-0 text-muted-foreground" />} {sameWorkspacePath(option.path, scope?.project_path ?? defaultScope.project_path) && <Check className="h-4 w-4 shrink-0 text-muted-foreground" />}
</button>)} </button>
{favoriteButton(option.path)}
</div>)} </div>)}
{columnIndex === previousColumns.length && loading && <WorkspaceDirectorySkeleton />} {columnIndex === previousColumns.length && loading && <WorkspaceDirectorySkeleton />}
{columnIndex === previousColumns.length && directory?.truncated && <p className="px-3 py-2 text-[11px] text-muted-foreground">{t("workspace.picker.truncated")}</p>} {columnIndex === previousColumns.length && directory?.truncated && <p className="px-3 py-2 text-[11px] text-muted-foreground">{t("workspace.picker.truncated")}</p>}
{columnIndex === previousColumns.length && displayedError && <p id={errorId} role="alert" className="px-3 py-2 text-[11.5px] text-destructive">{displayedError}</p>} {columnIndex === previousColumns.length && displayedError && <p id={errorId} role="alert" className="px-3 py-2 text-[11.5px] text-destructive">{displayedError}</p>}
</div>, columnIndex !== previousColumns.length || !!selectionPath)}</div>)} </div>)}
</div> </div>
</div> </div>
<div className="flex shrink-0 items-center justify-between gap-2 px-2 pt-1"> <div className="flex shrink-0 items-center justify-between gap-2 px-2 pt-1">
+26
View File
@@ -900,6 +900,32 @@
} }
} }
.workspace-picker-favorite {
pointer-events: none;
opacity: 0;
transition: opacity 120ms ease-out;
}
.workspace-picker-row:hover .workspace-picker-favorite,
.workspace-picker-row:focus-within .workspace-picker-favorite,
.workspace-picker-row[data-keyboard-active] .workspace-picker-favorite {
pointer-events: auto;
opacity: 1;
}
@media (hover: none) {
.workspace-picker-favorite {
pointer-events: auto;
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.workspace-picker-favorite {
transition: none;
}
}
@media (pointer: coarse) { @media (pointer: coarse) {
/* Readable form text avoids Safari's focus zoom without disabling the user's /* Readable form text avoids Safari's focus zoom without disabling the user's
pinch zoom. Keep this after utilities so compact desktop overrides cannot pinch zoom. Keep this after utilities so compact desktop overrides cannot
+1 -1
View File
@@ -2500,7 +2500,7 @@
"emptyProjects": "No matching projects", "emptyProjects": "No matching projects",
"search": "Enter a path or filter this folder…", "search": "Enter a path or filter this folder…",
"shortcuts": "Saved locations", "shortcuts": "Saved locations",
"favoriteHint": "Right-click a folder to add it here.", "favoriteHint": "Use a folder’s star to add it here.",
"native": "Use system folder picker…", "native": "Use system folder picker…",
"up": "Parent directory", "up": "Parent directory",
"loading": "Loading folders…", "loading": "Loading folders…",
+1 -1
View File
@@ -2301,7 +2301,7 @@
"emptyProjects": "No hay proyectos coincidentes", "emptyProjects": "No hay proyectos coincidentes",
"search": "Introduce una ruta o filtra esta carpeta…", "search": "Introduce una ruta o filtra esta carpeta…",
"shortcuts": "Ubicaciones guardadas", "shortcuts": "Ubicaciones guardadas",
"favoriteHint": "Haz clic derecho en una carpeta para añadirla aquí.", "favoriteHint": "Pulsa la estrella de una carpeta para añadirla aquí.",
"native": "Usar el selector de carpetas del sistema…", "native": "Usar el selector de carpetas del sistema…",
"up": "Carpeta superior", "up": "Carpeta superior",
"loading": "Cargando carpetas…", "loading": "Cargando carpetas…",
+1 -1
View File
@@ -2300,7 +2300,7 @@
"emptyProjects": "Aucun projet correspondant", "emptyProjects": "Aucun projet correspondant",
"search": "Saisir un chemin ou filtrer ce dossier…", "search": "Saisir un chemin ou filtrer ce dossier…",
"shortcuts": "Emplacements enregistrés", "shortcuts": "Emplacements enregistrés",
"favoriteHint": "Faites un clic droit sur un dossier pour l’ajouter ici.", "favoriteHint": "Cliquez sur l’étoile d’un dossier pour l’ajouter ici.",
"native": "Utiliser le sélecteur de dossiers du système…", "native": "Utiliser le sélecteur de dossiers du système…",
"up": "Dossier parent", "up": "Dossier parent",
"loading": "Chargement des dossiers…", "loading": "Chargement des dossiers…",
+1 -1
View File
@@ -2300,7 +2300,7 @@
"emptyProjects": "Tidak ada proyek yang cocok", "emptyProjects": "Tidak ada proyek yang cocok",
"search": "Masukkan jalur atau filter folder ini…", "search": "Masukkan jalur atau filter folder ini…",
"shortcuts": "Lokasi tersimpan", "shortcuts": "Lokasi tersimpan",
"favoriteHint": "Klik kanan folder untuk menambahkannya di sini.", "favoriteHint": "Klik bintang di samping folder untuk menambahkannya di sini.",
"native": "Gunakan pemilih folder sistem…", "native": "Gunakan pemilih folder sistem…",
"up": "Direktori induk", "up": "Direktori induk",
"loading": "Memuat folder…", "loading": "Memuat folder…",
+1 -1
View File
@@ -2300,7 +2300,7 @@
"emptyProjects": "一致するプロジェクトはありません", "emptyProjects": "一致するプロジェクトはありません",
"search": "パスを入力、または現在のフォルダを絞り込む…", "search": "パスを入力、または現在のフォルダを絞り込む…",
"shortcuts": "保存した場所", "shortcuts": "保存した場所",
"favoriteHint": "フォルダを右クリックして、お気に入りに追加します。", "favoriteHint": "フォルダの星をクリックして追加します。",
"native": "システムのフォルダー選択を使用…", "native": "システムのフォルダー選択を使用…",
"up": "親ディレクトリ", "up": "親ディレクトリ",
"loading": "フォルダーを読み込み中…", "loading": "フォルダーを読み込み中…",
+1 -1
View File
@@ -2300,7 +2300,7 @@
"emptyProjects": "일치하는 프로젝트가 없습니다", "emptyProjects": "일치하는 프로젝트가 없습니다",
"search": "경로 입력 또는 현재 폴더 필터링…", "search": "경로 입력 또는 현재 폴더 필터링…",
"shortcuts": "저장된 위치", "shortcuts": "저장된 위치",
"favoriteHint": "폴더를 마우스 오른쪽 버튼으로 클릭하여 즐겨찾기에 추가하세요.", "favoriteHint": "폴더 옆의 별을 눌러 즐겨찾기에 추가하세요.",
"native": "시스템 폴더 선택기 사용…", "native": "시스템 폴더 선택기 사용…",
"up": "상위 디렉터리", "up": "상위 디렉터리",
"loading": "폴더 불러오는 중…", "loading": "폴더 불러오는 중…",
+1 -1
View File
@@ -2314,7 +2314,7 @@
"emptyProjects": "Nenhum projeto correspondente", "emptyProjects": "Nenhum projeto correspondente",
"search": "Digite um caminho ou filtre esta pasta…", "search": "Digite um caminho ou filtre esta pasta…",
"shortcuts": "Locais salvos", "shortcuts": "Locais salvos",
"favoriteHint": "Clique com o botão direito em uma pasta para adicioná-la aqui.", "favoriteHint": "Clique na estrela de uma pasta para adicioná-la aqui.",
"native": "Usar o seletor de pastas do sistema…", "native": "Usar o seletor de pastas do sistema…",
"up": "Pasta superior", "up": "Pasta superior",
"loading": "Carregando pastas…", "loading": "Carregando pastas…",
+1 -1
View File
@@ -2300,7 +2300,7 @@
"emptyProjects": "Không có dự án phù hợp", "emptyProjects": "Không có dự án phù hợp",
"search": "Nhập đường dẫn hoặc lọc thư mục này…", "search": "Nhập đường dẫn hoặc lọc thư mục này…",
"shortcuts": "Vị trí đã lưu", "shortcuts": "Vị trí đã lưu",
"favoriteHint": "Nhấp chuột phải vào thư mục để thêm vào đây.", "favoriteHint": "Nhấn ngôi sao bên cạnh thư mục để thêm vào đây.",
"native": "Dùng bộ chọn thư mục hệ thống…", "native": "Dùng bộ chọn thư mục hệ thống…",
"up": "Thư mục cha", "up": "Thư mục cha",
"loading": "Đang tải thư mục…", "loading": "Đang tải thư mục…",
+1 -1
View File
@@ -2500,7 +2500,7 @@
"emptyProjects": "没有匹配的项目", "emptyProjects": "没有匹配的项目",
"search": "输入路径或筛选当前目录…", "search": "输入路径或筛选当前目录…",
"shortcuts": "快捷位置", "shortcuts": "快捷位置",
"favoriteHint": "右键点击文件夹,将它加入收藏。", "favoriteHint": "点击文件夹旁的星标收藏。",
"native": "使用系统文件夹选择器…", "native": "使用系统文件夹选择器…",
"up": "返回上级目录", "up": "返回上级目录",
"loading": "正在加载文件夹…", "loading": "正在加载文件夹…",
+1 -1
View File
@@ -2300,7 +2300,7 @@
"emptyProjects": "沒有符合的專案", "emptyProjects": "沒有符合的專案",
"search": "輸入路徑或篩選目前目錄…", "search": "輸入路徑或篩選目前目錄…",
"shortcuts": "快捷位置", "shortcuts": "快捷位置",
"favoriteHint": "右鍵點擊資料夾,將它加入收藏。", "favoriteHint": "點擊資料夾旁的星號收藏。",
"native": "使用系統資料夾選擇器…", "native": "使用系統資料夾選擇器…",
"up": "返回上層目錄", "up": "返回上層目錄",
"loading": "正在載入資料夾…", "loading": "正在載入資料夾…",
+26 -11
View File
@@ -1,4 +1,4 @@
import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
@@ -167,25 +167,40 @@ describe("Workspace project picker", () => {
const onFavorite = vi.fn().mockResolvedValueOnce(favorites).mockRejectedValueOnce(new Error("disk full")).mockResolvedValueOnce([]); const onFavorite = vi.fn().mockResolvedValueOnce(favorites).mockRejectedValueOnce(new Error("disk full")).mockResolvedValueOnce([]);
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue({ ...catalog, controls: { ...catalog.controls, can_manage_favorites: true } })} onFavoriteProject={onFavorite} onChange={onChange} />); render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue({ ...catalog, controls: { ...catalog.controls, can_manage_favorites: true } })} onFavoriteProject={onFavorite} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" })); await user.click(screen.getByRole("button", { name: "Switch working directory" }));
async function openFavoriteMenu(name: string) { await user.click(await screen.findByRole("button", { name: "Pin beta" }));
fireEvent.contextMenu(await screen.findByRole("button", { name: "/srv/beta" }), { clientX: 100, clientY: 100 });
return screen.findByRole("menuitem", { name });
}
await user.click(await openFavoriteMenu("Pin beta"));
expect(onFavorite).toHaveBeenLastCalledWith("/srv/beta", true); expect(onFavorite).toHaveBeenLastCalledWith("/srv/beta", true);
await waitFor(() => expect(screen.queryByRole("menu")).not.toBeInTheDocument()); await screen.findByRole("button", { name: "Unpin beta" });
expect(screen.getByRole("navigation")).toHaveTextContent("Favorites/srv/betaRecent projects"); expect(screen.getByRole("navigation")).toHaveTextContent("Favorites/srv/betaRecent projects");
expect(screen.getByRole("combobox")).toHaveFocus(); expect(screen.getByRole("combobox")).toHaveFocus();
expect(onChange).not.toHaveBeenCalled(); expect(onChange).not.toHaveBeenCalled();
await user.click(await openFavoriteMenu("Unpin beta")); await user.click(screen.getByRole("button", { name: "Unpin beta" }));
expect(await screen.findByRole("alert")).toHaveTextContent("disk full"); expect(await screen.findByRole("alert")).toHaveTextContent("disk full");
await user.click(await openFavoriteMenu("Unpin beta")); await user.click(screen.getByRole("button", { name: "Unpin beta" }));
await waitFor(() => expect(screen.queryByRole("menu")).not.toBeInTheDocument()); expect(await screen.findByRole("button", { name: "Pin beta" })).toHaveAttribute("aria-pressed", "false");
expect(await openFavoriteMenu("Pin beta")).toBeInTheDocument();
expect(onFavorite).toHaveBeenLastCalledWith("/srv/beta", false); expect(onFavorite).toHaveBeenLastCalledWith("/srv/beta", false);
expect(onChange).not.toHaveBeenCalled(); expect(onChange).not.toHaveBeenCalled();
}); });
it("stars a directory with the keyboard without navigating or selecting it", async () => {
const user = userEvent.setup();
const onChange = vi.fn();
const onFavorite = vi.fn().mockResolvedValue([{ name: "alpha", path: "/srv/workspace/alpha" }]);
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls}
onLoadProjects={vi.fn().mockResolvedValue({ ...catalog, controls: { ...catalog.controls, can_manage_favorites: true } })}
onBrowseDirectories={vi.fn().mockResolvedValue(directory)} onFavoriteProject={onFavorite} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
const option = await screen.findByRole("option", { name: "/srv/workspace/alpha" });
const star = await within(option.parentElement!).findByRole("button", { name: "Pin alpha" });
act(() => star.focus());
await user.keyboard("{Enter}");
expect(onFavorite).toHaveBeenCalledWith("/srv/workspace/alpha", true);
await waitFor(() => expect(screen.getAllByRole("button", { name: "Unpin alpha" })).toHaveLength(2));
expect(option).toHaveAttribute("aria-selected", "false");
expect(screen.getByRole("combobox")).toHaveValue("/srv/workspace/");
expect(screen.getByRole("combobox")).toHaveFocus();
expect(onChange).not.toHaveBeenCalled();
});
it.each([ it.each([
["/srv/al", "/srv/alpha", "/srv/alpha/"], ["/srv/al", "/srv/alpha", "/srv/alpha/"],
["C:\\Projects\\al", "C:\\Projects\\alpha", "C:\\Projects\\alpha\\"], ["C:\\Projects\\al", "C:\\Projects\\alpha", "C:\\Projects\\alpha\\"],