Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(home): show folder names at phone width and the workspace empty state (#18037)

Engel Nyst9835ae81c535
diff --git a/__tests__/components/features/home/generic-dropdown-menu.test.tsx b/__tests__/components/features/home/generic-dropdown-menu.test.tsx
index 48df3c488b..878cf07019 100644
--- a/__tests__/components/features/home/generic-dropdown-menu.test.tsx
+++ b/__tests__/components/features/home/generic-dropdown-menu.test.tsx
@@ -68,3 +68,35 @@ describe("GenericDropdownMenu list structure", () => {
expect(divider).toHaveAttribute("aria-hidden", "true");
});
});
+
+describe("GenericDropdownMenu empty state", () => {
+ const stickyTopItem = <li data-testid="sticky-top">Most recent</li>;
+ const stickyFooterItem = (
+ <button type="button" data-testid="sticky-footer">
+ Add
+ </button>
+ );
+ const renderEmptyState = () => <li data-testid="empty-state">Empty</li>;
+
+ it("renders the empty state, and keeps the sticky footer, when no item matches", () => {
+ renderMenu({
+ filteredItems: [],
+ renderEmptyState,
+ stickyTopItem,
+ stickyFooterItem,
+ });
+
+ expect(screen.getByTestId("empty-state")).toBeInTheDocument();
+ expect(screen.queryByTestId("sticky-top")).not.toBeInTheDocument();
+ expect(screen.getByTestId("sticky-footer")).toBeInTheDocument();
+ });
+
+ it("renders the sticky items and options, without the empty state, when items match", () => {
+ renderMenu({ renderEmptyState, stickyTopItem, stickyFooterItem });
+
+ expect(screen.getByTestId("sticky-top")).toBeInTheDocument();
+ expect(screen.getAllByRole("option")).toHaveLength(ITEMS.length);
+ expect(screen.queryByTestId("empty-state")).not.toBeInTheDocument();
+ expect(screen.getByTestId("sticky-footer")).toBeInTheDocument();
+ });
+});
diff --git a/__tests__/components/features/home/workspace-dropdown.test.tsx b/__tests__/components/features/home/workspace-dropdown.test.tsx
index 9e2b0fb0c2..65e1073003 100644
--- a/__tests__/components/features/home/workspace-dropdown.test.tsx
+++ b/__tests__/components/features/home/workspace-dropdown.test.tsx
@@ -262,3 +262,28 @@ describe("WorkspaceDropdown grouping (#129)", () => {
expect(option).not.toHaveAttribute("aria-label");
});
});
+
+describe("WorkspaceDropdown empty state", () => {
+ it.each([
+ { scenario: "there are no workspaces", workspaces: [], search: "" },
+ {
+ scenario: "the search matches no workspace",
+ workspaces: GROUPED_WORKSPACES,
+ search: "zzz",
+ },
+ ])(
+ "shows the empty state above the Add Workspace footer when $scenario",
+ async ({ workspaces, search }) => {
+ const user = userEvent.setup();
+ renderDropdown({ workspaces });
+ const menu = await openMenu(user);
+
+ if (search) await user.keyboard(search);
+
+ expect(
+ within(menu).getByTestId("workspace-dropdown-empty"),
+ ).toHaveTextContent("HOME$NO_WORKSPACES");
+ expect(screen.getByTestId("add-workspaces-button")).toBeVisible();
+ },
+ );
+});
diff --git a/__tests__/components/features/home/workspace-selection-form.test.tsx b/__tests__/components/features/home/workspace-selection-form.test.tsx
index 1f68be6baf..7cb461d71c 100644
--- a/__tests__/components/features/home/workspace-selection-form.test.tsx
+++ b/__tests__/components/features/home/workspace-selection-form.test.tsx
@@ -427,6 +427,40 @@ describe("WorkspaceSelectionForm (server-backed workspaces)", () => {
});
});
+ it("keeps folder names readable in the Add Workspace browser below the md breakpoint", async () => {
+ // Arrange
+ mockSearchSubdirectories.mockImplementation(async (path: string) =>
+ path === "/Users/me"
+ ? {
+ items: [{ name: "dev", path: "/Users/me/dev" }],
+ next_page_id: null,
+ }
+ : { items: [], next_page_id: null },
+ );
+ renderForm();
+ const user = userEvent.setup();
+
+ // Act
+ await user.click(await screen.findByTestId("workspace-dropdown"));
+ await user.click(await screen.findByTestId("add-workspaces-button"));
+ const entry = await screen.findByTestId("folder-browser-entry-dev");
+
+ // Assert: at phone width the sidebar narrows and the Kind column shrinks,
+ // so a fixed 180px sidebar plus 120px Kind track can no longer squeeze the
+ // name track to 0px; desktop (md and up) keeps the original layout.
+ expect(screen.getByTestId("folder-browser-sidebar")).toHaveClass(
+ "w-28",
+ "md:w-45",
+ );
+ const header = screen.getByTestId("folder-browser-column-headers");
+ for (const row of [header, entry]) {
+ expect(row).toHaveClass(
+ "grid-cols-[minmax(0,1fr)_4rem]",
+ "md:grid-cols-[1fr_120px]",
+ );
+ }
+ });
+
it("handles Windows paths when browsing and adding a workspace", async () => {
const homePath = String.raw`C:\Users\me`;
const devPath = String.raw`C:\Users\me\dev`;
diff --git a/src/components/features/home/shared/generic-dropdown-menu.tsx b/src/components/features/home/shared/generic-dropdown-menu.tsx
index 6e136f0470..7bfc803544 100644
--- a/src/components/features/home/shared/generic-dropdown-menu.tsx
+++ b/src/components/features/home/shared/generic-dropdown-menu.tsx
@@ -63,8 +63,10 @@ export function GenericDropdownMenu<T>({
numberOfRecentItems = 0,
itemKey,
}: GenericDropdownMenuProps<T>) {
- const hasItems = filteredItems.length > 0;
- const showEmptyState = !hasItems && !stickyTopItem && !stickyFooterItem;
+ // The sticky footer renders outside the list, so it must not suppress the
+ // empty state: with no matching items the list shows the consumer's empty
+ // state (instead of a lone sticky header) and the footer stays below it.
+ const showEmptyState = filteredItems.length === 0;
// Always render the menu container (even when closed) so getMenuProps is always called
// This prevents the downshift warning about forgetting to call getMenuProps
diff --git a/src/components/features/home/workspace-dropdown/folder-browser-modal.tsx b/src/components/features/home/workspace-dropdown/folder-browser-modal.tsx
index be20ec9ec5..fe9f834353 100644
--- a/src/components/features/home/workspace-dropdown/folder-browser-modal.tsx
+++ b/src/components/features/home/workspace-dropdown/folder-browser-modal.tsx
@@ -23,6 +23,12 @@ import ChevronLeft from "#/icons/chevron-left-small.svg?react";
const PROJECTS_PATH = "/projects";
+// Shared by the column header and every entry row so the columns line up.
+// Below md the Kind track is narrow and the name track may shrink to its
+// share (the name truncates), so folder names stay visible at phone width.
+const FOLDER_BROWSER_COLUMNS_CLASS_NAME =
+ "grid grid-cols-[minmax(0,1fr)_4rem] gap-x-2 md:grid-cols-[1fr_120px] md:gap-x-0";
+
interface FolderBrowserModalProps {
isOpen: boolean;
onClose: () => void;
@@ -51,7 +57,7 @@ function SidebarSection({
if (entries.length === 0) return null;
return (
<div className="px-2 pb-3">
- <div className="px-2 pb-1 text-[11px] uppercase tracking-wide text-muted font-semibold">
+ <div className="px-2 pb-1 text-[11px] uppercase tracking-wide text-muted font-semibold truncate">
{label}
</div>
<ul>
@@ -251,7 +257,7 @@ export function FolderBrowserModal({
{/* Sidebar */}
<aside
data-testid="folder-browser-sidebar"
- className="w-45 shrink-0 border-r border-border-input bg-surface py-3 overflow-y-auto"
+ className="w-28 md:w-45 shrink-0 border-r border-border-input bg-surface py-3 overflow-y-auto"
>
<SidebarSection
label={t(I18nKey.HOME$FAVORITES)}
@@ -290,7 +296,13 @@ export function FolderBrowserModal({
</div>
{/* Column headers */}
- <div className="grid grid-cols-[1fr_120px] px-4 py-1 border-b border-border-input text-xs text-text-secondary font-semibold">
+ <div
+ data-testid="folder-browser-column-headers"
+ className={cn(
+ FOLDER_BROWSER_COLUMNS_CLASS_NAME,
+ "px-4 py-1 border-b border-border-input text-xs text-text-secondary font-semibold",
+ )}
+ >
<span>{t(I18nKey.HOME$NAME)}</span>
<span>{t(I18nKey.HOME$KIND)}</span>
</div>
@@ -333,7 +345,10 @@ export function FolderBrowserModal({
<button
type="button"
onClick={() => setCurrentPath(entry.path)}
- className="grid grid-cols-[1fr_120px] items-center w-full text-left px-4 py-1.5 text-sm text-contrast hover:bg-interactive-hover cursor-pointer"
+ className={cn(
+ FOLDER_BROWSER_COLUMNS_CLASS_NAME,
+ "items-center w-full text-left px-4 py-1.5 text-sm text-contrast hover:bg-interactive-hover cursor-pointer",
+ )}
data-testid={`folder-browser-entry-${entry.name}`}
>
<span className="flex items-center gap-2 min-w-0">