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): align picker rows and browser surfaces
chengyongru883924febce2
diff --git a/webui/src/components/SidebarSelectionHighlight.tsx b/webui/src/components/SidebarSelectionHighlight.tsxindex fb0b4dbea..6b89c34d2 100644--- a/webui/src/components/SidebarSelectionHighlight.tsx+++ b/webui/src/components/SidebarSelectionHighlight.tsx@@ -62,19 +62,14 @@ export function SidebarSelectionHighlight({const firstPosition = !positionedRef.current;if (firstPosition) highlight.style.transitionProperty = "none";- // Align the paint origin and destination to layout pixels. A fractional- // origin rasterized before translation can leave seams beside row backgrounds.- const snap = Math.round;- const originLeft = snap(containerRect.left);- const originTop = snap(containerRect.top);- const targetLeft = snap(targetRect.left);- const targetTop = snap(targetRect.top);- highlight.style.left = `${originLeft - containerRect.left}px`;- highlight.style.top = `${originTop - containerRect.top}px`;- highlight.style.width = `${snap(targetRect.right) - targetLeft}px`;- highlight.style.height = `${snap(targetRect.bottom) - targetTop}px`;- highlight.style.transform = `translate3d(${targetLeft - originLeft}px, ${- targetTop - originTop+ // Preserve fractional layout coordinates so the highlight shares the+ // target's edges, including where it meets an adjacent hover background.+ highlight.style.left = "0px";+ highlight.style.top = "0px";+ highlight.style.width = `${targetRect.width}px`;+ highlight.style.height = `${targetRect.height}px`;+ highlight.style.transform = `translate3d(${targetRect.left - containerRect.left}px, ${+ targetRect.top - containerRect.top}px, 0)`;highlight.style.opacity = "1";positionedRef.current = true;diff --git a/webui/src/components/thread/WorkspaceControls.tsx b/webui/src/components/thread/WorkspaceControls.tsxindex 561c5a2b4..7b9bde031 100644--- a/webui/src/components/thread/WorkspaceControls.tsx+++ b/webui/src/components/thread/WorkspaceControls.tsx@@ -154,16 +154,6 @@ function WorkspacePickerPath({ path }: { path: string }) {);}-function WorkspaceSavedProjectLabel({ path }: { path: string }) {- const parts = workspacePathCompletionQuery(path);- return (- <span className="min-w-0 flex-1">- <span className="block truncate text-[13px] font-medium leading-5">{projectNameFromPath(path)}</span>- {parts?.query && <span dir="rtl" className="block truncate text-left text-[11px] leading-4 text-muted-foreground"><bdi dir="ltr">{parts.path}</bdi></span>}- </span>- );-}-export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope, controls, error, onLoadProjects, onResolveProject, onFavoriteProject, onBrowseDirectories, layoutAnchor, onChange }: {layoutAnchor?: HTMLElement | null;isHero: boolean;@@ -645,11 +635,10 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,onPointerEnter={() => setHoveredLocation(project.path)} onPointerLeave={() => setHoveredLocation(null)}><button type="button" aria-label={project.path} aria-current={sameWorkspacePath(currentPath, project.path) ? "location" : undefined}disabled={pickingFolder} onMouseDown={event => event.preventDefault()} onClick={() => openShortcut(project)}- className={cn(floatingItemClassName, "flex h-14 min-h-14 w-full min-w-0 items-center gap-2 px-3 py-2 text-left group-hover/workspace-saved-row:bg-foreground/[0.055] dark:group-hover/workspace-saved-row:bg-white/[0.08] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring", canFavorite && "pr-12",- sameWorkspacePath(currentPath, project.path) && "text-foreground group-hover/workspace-saved-row:bg-transparent dark:group-hover/workspace-saved-row:bg-transparent",+ className={cn(floatingItemClassName, "flex h-11 min-h-11 w-full min-w-0 items-center gap-2 px-3 py-2 text-left group-hover/workspace-saved-row:bg-foreground/[0.055] dark:group-hover/workspace-saved-row:bg-white/[0.08] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring", canFavorite && "pr-12",+ 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))}>- <WorkspaceIcon className="h-4 w-4 shrink-0 text-muted-foreground" />- <WorkspaceSavedProjectLabel path={project.path} />+ <span className="min-w-0 flex-1 truncate text-[13px] leading-4">{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)}@@ -659,7 +648,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,))}</SidebarSelectionHighlight></nav>}- <div className={cn("flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-l-control bg-[#fcfcfc] dark:bg-muted", compact && showLocations && canBrowse && "hidden")}>+ <div className={cn("mr-[var(--picker-toolbar-inset)] flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[var(--picker-field-radius)] bg-[#fcfcfc] dark:bg-muted", compact && showLocations && canBrowse && "hidden")}><div ref={attachColumns} data-workspace-columns className="sidebar-scrollbar flex flex-1 min-h-0 min-w-0 overflow-x-auto overscroll-x-contain">{columns.map((column, columnIndex) => (!compact || columnIndex === currentColumnIndex) && <WorkspaceDirectoryColumn key={columnIndex} options={column.options} selectedPath={column.selectedPath} initialScrollTop={previewingPath ? 0 : currentVisit.scrollTops[columnIndex] ?? 0} visitRevision={history.revision} activeIndex={highlightActive && columnIndex === activeColumn ? activeOption : null}id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className={cn("sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 pt-1 pb-2 outline-none", keyboardInteraction && "focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring")}@@ -681,7 +670,6 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,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] disabled:opacity-50", canFavorite && "pr-12",sameWorkspacePath(column.selectedPath, option.path) && "font-medium text-foreground hover:bg-transparent dark:hover:bg-transparent focus:bg-transparent dark:focus:bg-transparent",highlightActive && columnIndex === activeColumn && index === activeOption && "ring-1 ring-inset ring-ring")}>- <WorkspaceIcon className="h-4 w-4 shrink-0 -translate-y-px text-muted-foreground" />{option.kind === "directory" ? <span className="min-w-0 flex-1 truncate text-[13px] leading-4">{option.name}</span> : <WorkspacePickerPath path={option.path} />}{sameWorkspacePath(option.path, scope?.project_path ?? defaultScope.project_path) && <Check className="h-4 w-4 shrink-0 text-muted-foreground" />}</button>diff --git a/webui/src/tests/sidebar-selection-highlight.test.tsx b/webui/src/tests/sidebar-selection-highlight.test.tsxindex fdcf19fb4..da3b60e9b 100644--- a/webui/src/tests/sidebar-selection-highlight.test.tsx+++ b/webui/src/tests/sidebar-selection-highlight.test.tsx@@ -22,7 +22,7 @@ function Harness({ activeId, targetByRef }: { activeId: string | null; targetByRdescribe("sidebar selection highlight geometry", () => {it.each([true, false])("updates the animated width as its target resizes (target by ref: %s)", (targetByRef) => {- let width = 272;+ let width = 272.25;let frameId = 0;const frames = new Map<number, FrameRequestCallback>();vi.spyOn(window, "requestAnimationFrame").mockImplementation((callback) => {@@ -47,14 +47,14 @@ describe("sidebar selection highlight geometry", () => {const container = this.dataset.testid === "highlight-container";const second = this.textContent === "Second";const inset = container ? 0 : second ? 24 : 8;- const x = 100 + inset;- const y = container ? 20 : second ? 100 : 60;+ const x = 100.5 + inset;+ const y = container ? 20.5 : second ? 100.5 : 60.5;const w = container ? width : width - inset - 8;return { x, y, left: x, top: y, right: x + w, bottom: y + 32, width: w, height: 32, toJSON() {} };});const { rerender } = render(<Harness activeId="first" targetByRef={targetByRef} />);const highlight = screen.getByTestId("test-selection-highlight");- expect(highlight).toHaveStyle({ width: "256px", height: "32px", transform: "translate3d(8px, 40px, 0)" });+ expect(highlight).toHaveStyle({ left: "0px", top: "0px", width: "256.25px", height: "32px", transform: "translate3d(8px, 40px, 0)" });paint();// After initial placement, every observer update changes the animation's@@ -65,7 +65,7 @@ describe("sidebar selection highlight geometry", () => {width = 420;act(() => resizes.at(-1)?.());expect(frames.size).toBe(1);- expect(highlight).toHaveStyle({ width: "256px" });+ expect(highlight).toHaveStyle({ width: "256.25px" });paint();expect(highlight).toHaveStyle({ width: "404px" });expect(highlight.style.transitionProperty).not.toBe("none");diff --git a/webui/src/tests/workspace-picker.test.tsx b/webui/src/tests/workspace-picker.test.tsxindex 58e598868..3a4e2255d 100644--- a/webui/src/tests/workspace-picker.test.tsx+++ b/webui/src/tests/workspace-picker.test.tsx@@ -234,7 +234,7 @@ describe("Workspace project picker", () => {it.each([["/srv/alpha/", "/srv/beta/"],["C:\\Projects\\alpha\\", "C:\\Projects\\beta\\"],- ])("distinguishes saved folders with the same name by their parent paths: %s", async (firstParent, secondParent) => {+ ])("keeps same-named saved folders independently selectable by their full paths: %s", async (firstParent, secondParent) => {const user = userEvent.setup();const firstPath = `${firstParent}src`;const secondPath = `${secondParent}src`;@@ -247,10 +247,8 @@ describe("Workspace project picker", () => {await user.click(screen.getByRole("button", { name: "Switch working directory" }));const first = await screen.findByRole("button", { name: firstPath });const second = screen.getByRole("button", { name: secondPath });- expect(within(first).getByText("src", { exact: true })).toBeInTheDocument();- expect(within(first).getByText(firstParent, { exact: true })).toBeInTheDocument();- expect(within(second).getByText("src", { exact: true })).toBeInTheDocument();- expect(within(second).getByText(secondParent, { exact: true })).toBeInTheDocument();+ expect(first).toHaveTextContent(/^src$/);+ expect(second).toHaveTextContent(/^src$/);act(() => first.focus());expect(first).toHaveFocus();await user.click(second);