Skip to content

🙌 OpenHands: AI-Driven Development

feat(sidebar): collapsible left-hand nav with icons + hover tooltips (#279)

Robert Brennand9beb1525073
diff --git a/__tests__/components/features/sidebar/sidebar.test.tsx b/__tests__/components/features/sidebar/sidebar.test.tsx
index c09226ca93..0daee63b9e 100644
--- a/__tests__/components/features/sidebar/sidebar.test.tsx
+++ b/__tests__/components/features/sidebar/sidebar.test.tsx
@@ -1,6 +1,6 @@
-import { render, screen } from "@testing-library/react";
+import { render, screen, fireEvent } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { describe, expect, it, vi } from "vitest";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { Sidebar } from "#/components/features/sidebar/sidebar";
import {
NavigationProvider,
@@ -97,6 +97,14 @@ function renderSidebar(currentPath: string) {
}
describe("Sidebar", () => {
+ beforeEach(() => {
+ window.localStorage.clear();
+ });
+
+ afterEach(() => {
+ window.localStorage.clear();
+ });
+
it.each([["/conversations"], ["/automations"], ["/automations/abc-123"], ["/settings"]])(
"keeps the sidebar's default top padding on %s so spacing stays consistent with the conversations page",
(currentPath) => {
@@ -117,4 +125,44 @@ describe("Sidebar", () => {
const settingsToggle = screen.getByTestId("sidebar-settings-toggle");
expect(settingsToggle.className).toMatch(/(^|\s)text-\[#8C8C8C\](\s|$)/);
});
+
+ it("toggles between expanded and collapsed states and persists the choice", () => {
+ const { unmount } = renderSidebar("/conversations");
+
+ const sidebar = screen.getByRole("navigation").parentElement;
+ expect(sidebar?.dataset.collapsed).toBe("false");
+ // Settings inline toggle is rendered in expanded mode only.
+ expect(screen.getByTestId("sidebar-settings-toggle")).toBeInTheDocument();
+
+ const toggle = screen.getByTestId("sidebar-collapse-toggle");
+ fireEvent.click(toggle);
+
+ expect(sidebar?.dataset.collapsed).toBe("true");
+ // Inline settings submenu toggle disappears in the collapsed rail; the
+ // single Settings link remains as the icon entry point.
+ expect(
+ screen.queryByTestId("sidebar-settings-toggle"),
+ ).not.toBeInTheDocument();
+ expect(screen.getByTestId("sidebar-settings-link")).toBeInTheDocument();
+
+ // The choice survives a remount via localStorage.
+ unmount();
+ renderSidebar("/conversations");
+ const remountedSidebar = screen.getByRole("navigation").parentElement;
+ expect(remountedSidebar?.dataset.collapsed).toBe("true");
+ });
+
+ it("renders icons for every top-level nav item so they remain meaningful in the collapsed rail", () => {
+ renderSidebar("/conversations");
+
+ for (const testId of [
+ "sidebar-conversations-link",
+ "sidebar-automations-link",
+ "sidebar-skills-link",
+ "sidebar-settings-toggle",
+ ]) {
+ const link = screen.getByTestId(testId);
+ expect(link.querySelector("svg")).not.toBeNull();
+ }
+ });
});
diff --git a/src/components/features/conversation-panel/compact-conversation-row.tsx b/src/components/features/conversation-panel/compact-conversation-row.tsx
new file mode 100644
index 0000000000..8a50341bcf
--- /dev/null
+++ b/src/components/features/conversation-panel/compact-conversation-row.tsx
@@ -0,0 +1,90 @@
+import React from "react";
+import { Tooltip } from "@heroui/react";
+import { NavigationLink } from "#/components/shared/navigation-link";
+import { ExecutionStatus } from "#/types/agent-server/core/base/common";
+import { RepositorySelection } from "#/api/open-hands.types";
+import { cn } from "#/utils/utils";
+import { ConversationStatusDot } from "../home/recent-conversations/conversation-status-dot";
+import { ConversationCardFooter } from "./conversation-card/conversation-card-footer";
+
+interface CompactConversationRowProps {
+ conversationId: string;
+ title: string;
+ selectedRepository: RepositorySelection | null;
+ executionStatus?: ExecutionStatus | null;
+ lastUpdatedAt: string;
+ createdAt?: string;
+ workspaceWorkingDir?: string | null;
+ isActive?: boolean;
+ onClose?: () => void;
+}
+
+/**
+ * Minimal one-row presentation of a conversation used by the collapsed
+ * sidebar. The row itself is just the agent status dot; hovering it shows a
+ * floating preview with the conversation's title, repo and timestamp.
+ */
+export function CompactConversationRow({
+ conversationId,
+ title,
+ selectedRepository,
+ executionStatus,
+ lastUpdatedAt,
+ createdAt,
+ workspaceWorkingDir,
+ isActive = false,
+ onClose,
+}: CompactConversationRowProps) {
+ const disableAnimation = import.meta.env.MODE === "test";
+
+ const preview = (
+ <div className="w-[260px] p-3">
+ <div className="flex items-center gap-2 mb-1">
+ <ConversationStatusDot
+ executionStatus={executionStatus}
+ showTooltip={false}
+ />
+ <span className="text-sm font-medium text-white truncate" title={title}>
+ {title || "(untitled)"}
+ </span>
+ </div>
+ <ConversationCardFooter
+ selectedRepository={selectedRepository}
+ lastUpdatedAt={lastUpdatedAt}
+ createdAt={createdAt}
+ executionStatus={executionStatus}
+ workspaceWorkingDir={workspaceWorkingDir}
+ />
+ </div>
+ );
+
+ return (
+ <Tooltip
+ content={preview}
+ placement="right"
+ closeDelay={100}
+ className="bg-[#1f2228] text-white border border-[#2a2f38] shadow-xl p-0"
+ disableAnimation={disableAnimation}
+ >
+ <NavigationLink
+ to={`/conversations/${conversationId}`}
+ onClick={onClose}
+ data-testid="compact-conversation-row"
+ data-conversation-id={conversationId}
+ aria-label={title || conversationId}
+ className={({ isActive: navActive }) =>
+ cn(
+ "flex items-center justify-center w-10 h-9 mx-auto rounded-md",
+ "transition-colors cursor-pointer",
+ navActive || isActive ? "bg-[#1f1f1f99]" : "hover:bg-[#1f1f1f99]",
+ )
+ }
+ >
+ <ConversationStatusDot
+ executionStatus={executionStatus}
+ showTooltip={false}
+ />
+ </NavigationLink>
+ </Tooltip>
+ );
+}
diff --git a/src/components/features/conversation-panel/conversation-panel.tsx b/src/components/features/conversation-panel/conversation-panel.tsx
index 0fc7e54629..8d848a9b5e 100644
--- a/src/components/features/conversation-panel/conversation-panel.tsx
+++ b/src/components/features/conversation-panel/conversation-panel.tsx
@@ -21,9 +21,16 @@ import {
import { ConversationCard } from "./conversation-card/conversation-card";
import { StartTaskCard } from "./start-task-card/start-task-card";
import { ConversationCardSkeleton } from "./conversation-card/conversation-card-skeleton";
+import { CompactConversationRow } from "./compact-conversation-row";
interface ConversationPanelProps {
onClose?: () => void;
+ /**
+ * Render a minimal icon-only variant of each conversation row (used by the
+ * collapsed sidebar). Each row is a single status dot with a hover preview
+ * containing the full card content.
+ */
+ compact?: boolean;
}
const noop = () => {};
@@ -52,7 +59,10 @@ const partitionByCutoff = <T extends { updated_at: string }>(
return { recent, older };
};
-export function ConversationPanel({ onClose }: ConversationPanelProps) {
+export function ConversationPanel({
+ onClose,
+ compact = false,
+}: ConversationPanelProps) {
const { t } = useTranslation("openhands");
const { conversationId: currentConversationId, navigate } = useNavigation();
// Click-outside is only relevant in the legacy drawer mode where an
@@ -112,7 +122,9 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
// pagination, which previously caused the panel to feel like it had stray
// scrollable space at the bottom.
const olderHidden = olderConversations.length > 0 && !showOlderConversations;
- const showLoadMore = !!hasNextPage && !olderHidden;
+ // Compact mode also hides "Load more" — paginating into archived
+ // conversations contradicts the "active only" intent of the icon rail.
+ const showLoadMore = !!hasNextPage && !olderHidden && !compact;
const handleDeleteProject = React.useCallback(
(conversationId: string, title: string) => {
@@ -193,41 +205,64 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
};
const renderConversationCard = React.useCallback(
- (conversation: (typeof conversations)[number]) => (
- <NavigationLink
- key={conversation.id}
- to={`/conversations/${conversation.id}`}
- onClick={onClose}
- className="block"
- >
- <ConversationCard
- onDelete={() =>
- handleDeleteProject(conversation.id, conversation.title ?? "")
- }
- onStop={() => handleStopConversation(conversation.id)}
- onChangeTitle={(title) =>
- handleConversationTitleChange(conversation.id, title)
- }
- title={conversation.title ?? ""}
- selectedRepository={{
- selected_repository: conversation.selected_repository,
- selected_branch: conversation.selected_branch,
- git_provider: conversation.git_provider as Provider,
- }}
- lastUpdatedAt={conversation.updated_at}
- createdAt={conversation.created_at}
- executionStatus={conversation.execution_status}
- conversationId={conversation.id}
- contextMenuOpen={openContextMenuId === conversation.id}
- onContextMenuToggle={(isOpen) =>
- setOpenContextMenuId(isOpen ? conversation.id : null)
- }
- isActive={conversation.id === currentConversationId}
- workspaceWorkingDir={conversation.workspace?.working_dir}
- />
- </NavigationLink>
- ),
+ (conversation: (typeof conversations)[number]) => {
+ if (compact) {
+ return (
+ <CompactConversationRow
+ key={conversation.id}
+ conversationId={conversation.id}
+ title={conversation.title ?? ""}
+ selectedRepository={{
+ selected_repository: conversation.selected_repository,
+ selected_branch: conversation.selected_branch,
+ git_provider: conversation.git_provider as Provider,
+ }}
+ executionStatus={conversation.execution_status}
+ lastUpdatedAt={conversation.updated_at}
+ createdAt={conversation.created_at}
+ workspaceWorkingDir={conversation.workspace?.working_dir}
+ isActive={conversation.id === currentConversationId}
+ onClose={onClose}
+ />
+ );
+ }
+ return (
+ <NavigationLink
+ key={conversation.id}
+ to={`/conversations/${conversation.id}`}
+ onClick={onClose}
+ className="block"
+ >
+ <ConversationCard
+ onDelete={() =>
+ handleDeleteProject(conversation.id, conversation.title ?? "")
+ }
+ onStop={() => handleStopConversation(conversation.id)}
+ onChangeTitle={(title) =>
+ handleConversationTitleChange(conversation.id, title)
+ }
+ title={conversation.title ?? ""}
+ selectedRepository={{
+ selected_repository: conversation.selected_repository,
+ selected_branch: conversation.selected_branch,
+ git_provider: conversation.git_provider as Provider,
+ }}
+ lastUpdatedAt={conversation.updated_at}
+ createdAt={conversation.created_at}
+ executionStatus={conversation.execution_status}
+ conversationId={conversation.id}
+ contextMenuOpen={openContextMenuId === conversation.id}
+ onContextMenuToggle={(isOpen) =>
+ setOpenContextMenuId(isOpen ? conversation.id : null)
+ }
+ isActive={conversation.id === currentConversationId}
+ workspaceWorkingDir={conversation.workspace?.working_dir}
+ />
+ </NavigationLink>
+ );
+ },
[
+ compact,
currentConversationId,
handleConversationTitleChange,
handleDeleteProject,
@@ -274,23 +309,26 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
</div>
)}
- {/* Render in-progress start tasks first */}
- {startTasks?.map((task) => (
- <NavigationLink
- key={task.id}
- to={`/conversations/task-${task.id}`}
- onClick={onClose}
- className="block"
- >
- <StartTaskCard task={task} />
- </NavigationLink>
- ))}
+ {/* Render in-progress start tasks first (skipped in compact mode —
+ their rich card layout doesn't fit in the icon rail). */}
+ {!compact &&
+ startTasks?.map((task) => (
+ <NavigationLink
+ key={task.id}
+ to={`/conversations/task-${task.id}`}
+ onClick={onClose}
+ className="block"
+ >
+ <StartTaskCard task={task} />
+ </NavigationLink>
+ ))}
{/* Recent conversations (last_updated within the past hour) */}
{recentConversations.map(renderConversationCard)}
- {/* Older conversations are hidden by default behind a count + toggle */}
- {olderConversations.length > 0 && (
+ {/* Older conversations: full summary in expanded mode, just a flat
+ list of dots in compact mode (the summary text can't fit). */}
+ {!compact && olderConversations.length > 0 && (
<div
data-testid="older-conversations-summary"
className="px-3 py-2 text-xs text-neutral-400 flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-[#1f2228]"
@@ -320,7 +358,11 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
</div>
)}
- {showOlderConversations &&
+ {/* Older conversations only render when explicitly expanded via
+ "Show all". Compact mode mirrors expanded's default — recent
+ only — so the icon rail isn't packed with archive cruft. */}
+ {!compact &&
+ showOlderConversations &&
olderConversations.map(renderConversationCard)}
{/* Explicit "Load more" trigger. Only shown when more pages exist
diff --git a/src/components/features/conversation-panel/new-conversation-button-cloud.tsx b/src/components/features/conversation-panel/new-conversation-button-cloud.tsx
index 0074a59be1..a0b3593143 100644
--- a/src/components/features/conversation-panel/new-conversation-button-cloud.tsx
+++ b/src/components/features/conversation-panel/new-conversation-button-cloud.tsx
@@ -16,6 +16,16 @@ import { GitRepository } from "#/types/git";
import { Provider } from "#/types/settings";
import RepoIcon from "#/icons/repo.svg?react";
import { GitProviderIcon } from "#/components/shared/git-provider-icon";
+import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";
+
+interface CloudNewConversationButtonProps {
+ /**
+ * Render the trigger as a "+" icon-only button (used by the collapsed
+ * sidebar). The popover content is unchanged; only the trigger pill
+ * collapses.
+ */
+ compact?: boolean;
+}
interface RepoListItemProps {
repo: GitRepository;
@@ -56,7 +66,9 @@ function RepoListItem({
* picker is exposed — the user can switch branches from inside the
* conversation once it's running.
*/
-export function CloudNewConversationButton() {
+export function CloudNewConversationButton({
+ compact = false,
+}: CloudNewConversationButtonProps = {}) {
const { t } = useTranslation("openhands");
const { navigate } = useNavigation();
@@ -186,30 +198,50 @@ export function CloudNewConversationButton() {
const showLoadMore =
!debouncedQuery && hasNextPage && repositories.length > 0;
+ const newConversationLabel = t(I18nKey.SIDEBAR$NEW_CONVERSATION);
+
+ const triggerButton = (
+ <button
+ type="button"
+ data-testid="new-conversation-button"
+ onClick={() => setOpen((o) => !o)}
+ aria-expanded={open}
+ aria-label={compact ? newConversationLabel : undefined}
+ className={cn(
+ "flex items-center rounded-md cursor-pointer transition-colors",
+ "text-sm font-medium text-white bg-[#1f1f1f99] hover:bg-[#2a2a2a]",
+ "border border-[#525252]",
+ compact
+ ? "justify-center w-10 h-10 p-0 mx-auto"
+ : "gap-1.5 w-full px-3 py-2",
+ )}
+ >
+ <Plus width={16} height={16} className="shrink-0" />
+ {!compact && newConversationLabel}
+ </button>
+ );
+
return (
- <div className="relative" ref={popoverRef}>
- <button
- type="button"
- data-testid="new-conversation-button"
- onClick={() => setOpen((o) => !o)}
- aria-expanded={open}
- className={cn(
- "flex items-center gap-1.5 w-full px-3 py-2 rounded-md",
- "text-sm font-medium text-white bg-[#1f1f1f99] hover:bg-[#2a2a2a]",
- "border border-[#525252] cursor-pointer transition-colors",
- )}
- >
- <Plus width={16} height={16} className="shrink-0" />
- {t(I18nKey.SIDEBAR$NEW_CONVERSATION)}
- </button>
+ <div
+ className={cn("relative", compact && "flex justify-center")}
+ ref={popoverRef}
+ >
+ {compact ? (
+ <StyledTooltip content={newConversationLabel} placement="right">
+ {triggerButton}
+ </StyledTooltip>
+ ) : (
+ triggerButton
+ )}
{open && (
<div
data-testid="new-conversation-popover"
className={cn(
- "absolute z-30 left-0 right-0 top-full mt-2 p-1",
+ "absolute z-30 top-full mt-2 p-1",
"bg-[#26282D] border border-[#727987] rounded-lg shadow-xl",
"flex flex-col gap-1",
+ compact ? "left-0 w-[260px]" : "left-0 right-0",
)}
>
{providers.length > 1 && (
diff --git a/src/components/features/conversation-panel/new-conversation-button-local.tsx b/src/components/features/conversation-panel/new-conversation-button-local.tsx
index 80066b2e10..1ade7cc414 100644
--- a/src/components/features/conversation-panel/new-conversation-button-local.tsx
+++ b/src/components/features/conversation-panel/new-conversation-button-local.tsx
@@ -10,10 +10,20 @@ import { useResolvedWorkspaces } from "#/hooks/query/use-resolved-workspaces";
import { I18nKey } from "#/i18n/declaration";
import { cn } from "#/utils/utils";
import RepoIcon from "#/icons/repo.svg?react";
+import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";
import { FolderBrowserModal } from "#/components/features/home/workspace-dropdown/folder-browser-modal";
import { ManageWorkspacesModal } from "#/components/features/home/workspace-dropdown/manage-workspaces-modal";
+interface LocalNewConversationButtonProps {
+ /**
+ * Render the trigger as a "+" icon-only button (used by the collapsed
+ * sidebar). The popover content is unchanged; only the trigger pill
+ * collapses.
+ */
+ compact?: boolean;
+}
+
/**
* Local-backend variant of the sidebar "+ New Conversation" trigger.
*
@@ -22,7 +32,9 @@ import { ManageWorkspacesModal } from "#/components/features/home/workspace-drop
* immediately starts a conversation when clicked. The sticky footer still
* exposes "+ Add Workspace" / "Manage Workspaces" entries.
*/
-export function LocalNewConversationButton() {
+export function LocalNewConversationButton({
+ compact = false,
+}: LocalNewConversationButtonProps = {}) {
const { t } = useTranslation("openhands");
const { navigate } = useNavigation();
@@ -102,30 +114,50 @@ export function LocalNewConversationButton() {
[],
);
+ const newConversationLabel = t(I18nKey.SIDEBAR$NEW_CONVERSATION);
+
+ const triggerButton = (
+ <button
+ type="button"
+ data-testid="new-conversation-button"
+ onClick={() => setOpen((o) => !o)}
+ aria-expanded={open}
+ aria-label={compact ? newConversationLabel : undefined}
+ className={cn(
+ "flex items-center rounded-md cursor-pointer transition-colors",
+ "text-sm font-medium text-white bg-[#1f1f1f99] hover:bg-[#2a2a2a]",
+ "border border-[#525252]",
+ compact
+ ? "justify-center w-10 h-10 p-0 mx-auto"
+ : "gap-1.5 w-full px-3 py-2",
+ )}
+ >
+ <Plus width={16} height={16} className="shrink-0" />
+ {!compact && newConversationLabel}
+ </button>
+ );
+
return (
- <div className="relative" ref={popoverRef}>
- <button
- type="button"
- data-testid="new-conversation-button"
- onClick={() => setOpen((o) => !o)}
- aria-expanded={open}
- className={cn(
- "flex items-center gap-1.5 w-full px-3 py-2 rounded-md",
- "text-sm font-medium text-white bg-[#1f1f1f99] hover:bg-[#2a2a2a]",
- "border border-[#525252] cursor-pointer transition-colors",
- )}
- >
- <Plus width={16} height={16} className="shrink-0" />
- {t(I18nKey.SIDEBAR$NEW_CONVERSATION)}
- </button>
+ <div
+ className={cn("relative", compact && "flex justify-center")}
+ ref={popoverRef}
+ >
+ {compact ? (
+ <StyledTooltip content={newConversationLabel} placement="right">
+ {triggerButton}
+ </StyledTooltip>
+ ) : (
+ triggerButton
+ )}
{open && (
<div
data-testid="new-conversation-popover"
className={cn(
- "absolute z-30 left-0 right-0 top-full mt-2 p-1",
+ "absolute z-30 top-full mt-2 p-1",
"bg-[#26282D] border border-[#727987] rounded-lg shadow-xl",
"flex flex-col",
+ compact ? "left-0 w-[260px]" : "left-0 right-0",
)}
>
<ul className="flex flex-col max-h-[40vh] sm:max-h-[280px] overflow-y-auto">
diff --git a/src/components/features/conversation-panel/new-conversation-button.tsx b/src/components/features/conversation-panel/new-conversation-button.tsx
index d7d013c3eb..ef016b88a1 100644
--- a/src/components/features/conversation-panel/new-conversation-button.tsx
+++ b/src/components/features/conversation-panel/new-conversation-button.tsx
@@ -3,6 +3,15 @@ import { useActiveBackend } from "#/contexts/active-backend-context";
import { CloudNewConversationButton } from "./new-conversation-button-cloud";
import { LocalNewConversationButton } from "./new-conversation-button-local";
+interface NewConversationButtonProps {
+ /**
+ * Render the trigger as a "+" icon-only button (used by the collapsed
+ * sidebar). The popover content is unchanged; only the trigger pill
+ * collapses.
+ */
+ compact?: boolean;
+}
+
/**
* Sidebar "+ New Conversation" trigger.
*
@@ -10,9 +19,11 @@ import { LocalNewConversationButton } from "./new-conversation-button-local";
* on workspace folders so we surface the workspace picker, while cloud
* backends operate on git repositories so we surface a repository picker.
*/
-export function NewConversationButton() {
+export function NewConversationButton({
+ compact = false,
+}: NewConversationButtonProps = {}) {
const isCloud = useActiveBackend().backend.kind === "cloud";
- if (isCloud) return <CloudNewConversationButton />;
- return <LocalNewConversationButton />;
+ if (isCloud) return <CloudNewConversationButton compact={compact} />;
+ return <LocalNewConversationButton compact={compact} />;
}
diff --git a/src/components/features/home/recent-conversations/conversation-status-dot.tsx b/src/components/features/home/recent-conversations/conversation-status-dot.tsx
index da1253450e..902d702575 100644
--- a/src/components/features/home/recent-conversations/conversation-status-dot.tsx
+++ b/src/components/features/home/recent-conversations/conversation-status-dot.tsx
@@ -4,6 +4,13 @@ import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";
interface ConversationStatusDotProps {
executionStatus: ExecutionStatus | null | undefined;
+ /**
+ * Wrap the dot in a tooltip showing the human-readable status label.
+ * Disable this when the dot is already nested inside a larger tooltip
+ * (e.g. the collapsed-sidebar conversation preview) so the smaller
+ * tooltip doesn't intercept the hover.
+ */
+ showTooltip?: boolean;
}
type Visual = "check" | "working" | "paused" | "error" | "unknown";
@@ -101,6 +108,7 @@ function renderIndicator(visual: Visual) {
export function ConversationStatusDot({
executionStatus,
+ showTooltip = true,
}: ConversationStatusDotProps) {
const { t } = useTranslation("openhands");
@@ -108,6 +116,14 @@ export function ConversationStatusDot({
const label = t(labelKeyFor(visual));
const indicator = renderIndicator(visual);
+ const dot = (
+ <div className="w-2.5 h-2.5 flex items-center justify-center shrink-0">
+ {indicator}
+ </div>
+ );
+
+ if (!showTooltip) return dot;
+
return (
<StyledTooltip
content={label}
@@ -115,9 +131,7 @@ export function ConversationStatusDot({
showArrow
tooltipClassName="bg-[#1a1a1a] text-white text-xs shadow-lg"
>
- <div className="w-2.5 h-2.5 flex items-center justify-center shrink-0">
- {indicator}
- </div>
+ {dot}
</StyledTooltip>
);
}
diff --git a/src/components/features/sidebar/sidebar-collapse-context.ts b/src/components/features/sidebar/sidebar-collapse-context.ts
new file mode 100644
index 0000000000..56da40cff6
--- /dev/null
+++ b/src/components/features/sidebar/sidebar-collapse-context.ts
@@ -0,0 +1,11 @@
+import React from "react";
+
+/**
+ * Lightweight context exposing the sidebar's collapsed state to descendant
+ * components (e.g. the conversation list and the "+ New" button) so they can
+ * render a compact icon-only variant when the parent sidebar is collapsed.
+ */
+export const SidebarCollapseContext = React.createContext<boolean>(false);
+
+export const useSidebarCollapsed = (): boolean =>
+ React.useContext(SidebarCollapseContext);
diff --git a/src/components/features/sidebar/sidebar-conversation-list.tsx b/src/components/features/sidebar/sidebar-conversation-list.tsx
index 560d3dab69..0fd84b2b96 100644
--- a/src/components/features/sidebar/sidebar-conversation-list.tsx
+++ b/src/components/features/sidebar/sidebar-conversation-list.tsx
@@ -1,19 +1,31 @@
import { ConversationPanel } from "#/components/features/conversation-panel/conversation-panel";
import { NewConversationButton } from "#/components/features/conversation-panel/new-conversation-button";
+import { useSidebarCollapsed } from "./sidebar-collapse-context";
+import { cn } from "#/utils/utils";
/**
* Conversation list section rendered inside the sidebar nav. The list itself
* scrolls independently from the rest of the nav, while the "+ New" trigger
* stays pinned above it.
+ *
+ * In the collapsed sidebar variant the list reduces each row to a status
+ * indicator + hover-preview, and the new-conversation button collapses to a
+ * "+" icon.
*/
export function SidebarConversationList() {
+ const collapsed = useSidebarCollapsed();
return (
- <div className="hidden md:flex md:flex-col md:flex-1 md:min-h-0 gap-2 -mx-3">
- <div className="px-3">
- <NewConversationButton />
+ <div
+ className={cn(
+ "hidden md:flex md:flex-col md:flex-1 md:min-h-0 gap-2",
+ collapsed ? "items-center -mx-1" : "-mx-3",
+ )}
+ >
+ <div className={cn("w-full", collapsed ? "px-1" : "px-3")}>
+ <NewConversationButton compact={collapsed} />
</div>
- <div className="flex-1 min-h-0 overflow-hidden">
- <ConversationPanel />
+ <div className="flex-1 min-h-0 overflow-hidden w-full">
+ <ConversationPanel compact={collapsed} />
</div>
</div>
);
diff --git a/src/components/features/sidebar/sidebar-nav-link.tsx b/src/components/features/sidebar/sidebar-nav-link.tsx
index ae2e59b11f..658b5ff3dc 100644
--- a/src/components/features/sidebar/sidebar-nav-link.tsx
+++ b/src/components/features/sidebar/sidebar-nav-link.tsx
@@ -1,5 +1,6 @@
import React from "react";
import { NavigationLink } from "#/components/shared/navigation-link";
+import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";
import { cn } from "#/utils/utils";
interface SidebarNavLinkProps {
@@ -10,6 +11,23 @@ interface SidebarNavLinkProps {
testId?: string;
disabled?: boolean;
icon?: React.ReactElement;
+ /**
+ * When true, render only the icon (label is shown via a hover tooltip
+ * floating to the side). Used by the collapsed sidebar.
+ */
+ collapsed?: boolean;
+ /**
+ * Optional rich-content node shown in the hover tooltip instead of the
+ * plain label. Useful for rendering an "expanded version" of the item
+ * while the sidebar is collapsed.
+ */
+ hoverContent?: React.ReactNode;
+}
+
+function getLayoutClasses(collapsed: boolean, indent: boolean): string {
+ if (collapsed) return "justify-center w-10 h-10 p-0 mx-auto";
+ if (indent) return "pl-7 pr-3 py-1.5 w-full";
+ return "px-3 py-2 w-full";
}
export function SidebarNavLink({
@@ -20,13 +38,16 @@ export function SidebarNavLink({
testId,
disabled = false,
icon,
+ collapsed = false,
+ hoverContent,
}: SidebarNavLinkProps) {
- return (
+ const link = (
<NavigationLink
to={to}
end={end}
data-testid={testId}
tabIndex={disabled ? -1 : 0}
+ aria-label={collapsed ? label : undefined}
onClick={(e) => {
if (disabled) {
e.preventDefault();
@@ -34,9 +55,9 @@ export function SidebarNavLink({
}}
className={({ isActive }) =>
cn(
- "flex items-center gap-2 w-full rounded-md transition-colors",
+ "flex items-center gap-2 rounded-md transition-colors",
"text-sm leading-5 truncate",
- indent ? "pl-7 pr-3 py-1.5" : "px-3 py-2",
+ getLayoutClasses(collapsed, indent),
isActive
? "bg-[#1f1f1f99] text-white font-medium"
: "text-[#8C8C8C] hover:text-white hover:bg-[#1f1f1f99]",
@@ -44,8 +65,26 @@ export function SidebarNavLink({
)
}
>
- {icon ? <span className="shrink-0">{icon}</span> : null}
- <span className="truncate">{label}</span>
+ {icon ? (
+ <span className="shrink-0 flex items-center justify-center">
+ {icon}
+ </span>
+ ) : null}
+ {!collapsed && <span className="truncate">{label}</span>}
</NavigationLink>
);
+
+ if (!collapsed) return link;
+
+ return (
+ <StyledTooltip
+ content={hoverContent ?? label}
+ placement="right"
+ tooltipClassName={
+ hoverContent ? "p-0 bg-[#1f2228] text-white" : undefined
+ }
+ >
+ {link}
+ </StyledTooltip>
+ );
}
diff --git a/src/components/features/sidebar/sidebar.tsx b/src/components/features/sidebar/sidebar.tsx
index daef214956..20a1591a11 100644
--- a/src/components/features/sidebar/sidebar.tsx
+++ b/src/components/features/sidebar/sidebar.tsx
@@ -1,5 +1,6 @@
import React from "react";
import { useTranslation } from "react-i18next";
+import { ChevronLeft, ChevronRight } from "lucide-react";
import { OpenHandsLogoButton } from "#/components/shared/buttons/openhands-logo-button";
import { SidebarNavLink } from "./sidebar-nav-link";
import { getErrorStatus, useSettings } from "#/hooks/query/use-settings";
@@ -12,6 +13,12 @@ import { useSettingsNavItems } from "#/hooks/use-settings-nav-items";
import { BackendSelector } from "#/components/features/backends/backend-selector";
import { OSS_NAV_ITEMS } from "#/constants/settings-nav";
import { SidebarConversationList } from "./sidebar-conversation-list";
+import { SidebarCollapseContext } from "./sidebar-collapse-context";
+import { useSidebarCollapsedState } from "#/hooks/use-sidebar-collapsed";
+import MessageIcon from "#/icons/message.svg?react";
+import AutomationsIcon from "#/icons/automations.svg?react";
+import SparkleIcon from "#/icons/sparkle.svg?react";
+import CogIcon from "#/icons/cog.svg?react";
// The LLM settings modal is only mounted when the settings query 404s and
// LLM settings aren't hidden — keep it out of the sidebar's eager graph.
@@ -25,6 +32,8 @@ const SETTINGS_NAV_ICON_BY_PATH = new Map(
OSS_NAV_ITEMS.map((item) => [item.to, item.icon] as const),
);
+const ICON_SIZE = 18;
+
export function Sidebar() {
const { t } = useTranslation("openhands");
const { currentPath } = useNavigation();
@@ -37,6 +46,7 @@ export function Sidebar() {
} = useSettings();
const settingsNavItems = useSettingsNavItems();
+ const [collapsed, setCollapsed] = useSidebarCollapsedState();
const [settingsModalIsOpen, setSettingsModalIsOpen] = React.useState(false);
const settingsErrorStatus = getErrorStatus(settingsError);
@@ -80,45 +90,149 @@ export function Sidebar() {
const linkDisabled = settings?.email_verified === false;
+ // Floating panel rendered in the hover tooltip when the (collapsed)
+ // Settings button is hovered: lists the same submenu the expanded variant
+ // shows inline.
+ const settingsHoverPanel = (
+ <div
+ data-testid="sidebar-settings-flyout"
+ className="w-[220px] p-1 bg-[#1f2228] text-white rounded-md"
+ >
+ <div className="px-2 py-1 text-xs font-semibold text-[#A3A3A3] uppercase tracking-wider">
+ {t(I18nKey.SIDEBAR$SETTINGS)}
+ </div>
+ <ul className="flex flex-col gap-0.5">
+ {settingsNavItems.map((rendered) => {
+ if (rendered.type !== "item") return null;
+ const navIcon = SETTINGS_NAV_ICON_BY_PATH.get(rendered.item.to);
+ return (
+ <li key={rendered.item.to}>
+ <SidebarNavLink
+ to={rendered.item.to}
+ label={t(rendered.item.text as I18nKey)}
+ end
+ testId={`sidebar-settings-flyout-${rendered.item.to}`}
+ disabled={linkDisabled}
+ icon={
+ navIcon
+ ? React.cloneElement(
+ navIcon as React.ReactElement<{
+ width?: number;
+ height?: number;
+ }>,
+ { width: 16, height: 16 },
+ )
+ : undefined
+ }
+ />
+ </li>
+ );
+ })}
+ </ul>
+ </div>
+ );
+
+ const collapseToggleLabel = t(
+ collapsed ? I18nKey.SIDEBAR$EXPAND : I18nKey.SIDEBAR$COLLAPSE,
+ );
+
return (
- <>
+ <SidebarCollapseContext.Provider value={collapsed}>
<aside
aria-label={t(I18nKey.SIDEBAR$NAVIGATION_LABEL)}
+ data-collapsed={collapsed ? "true" : "false"}
className={cn(
- "bg-base flex flex-col gap-3",
- // Mobile: top bar; Desktop: vertical column
- "h-[54px] md:h-full md:w-[300px] md:min-w-[300px]",
- "px-3 py-2 md:px-3 md:pt-4",
+ "bg-base flex flex-col gap-3 transition-[width] duration-200",
+ // Mobile: top bar; Desktop: vertical column. Width responds to
+ // the collapsed state on md+ screens.
+ "h-[54px] md:h-full",
+ collapsed
+ ? "md:w-[64px] md:min-w-[64px]"
+ : "md:w-[300px] md:min-w-[300px]",
+ collapsed ? "md:px-2 md:pt-4" : "px-3 py-2 md:px-3 md:pt-4",
"flex-row md:flex-col",
currentPath === "/" && "md:pt-6.5 md:pb-3",
)}
>
- <div className="flex items-center md:px-2 md:py-1">
+ <div
+ className={cn(
+ "flex items-center gap-2 md:py-1",
+ // Collapsed: stack the chevron beneath the logo so the 64px rail
+ // doesn't need to grow to fit two controls in a row. Expanded:
+ // chevron is right-aligned via ml-auto further down.
+ collapsed ? "md:flex-col md:gap-2 md:px-0" : "md:pl-2 md:pr-0",
+ )}
+ >
<OpenHandsLogoButton />
+ {/* Desktop-only collapse toggle. Hidden on mobile (the sidebar
+ there is the top bar and doesn't collapse). No tooltip — the
+ chevron direction already conveys what the button does. */}
+ <button
+ type="button"
+ data-testid="sidebar-collapse-toggle"
+ aria-pressed={collapsed}
+ aria-label={collapseToggleLabel}
+ onClick={() => setCollapsed((prev) => !prev)}
+ className={cn(
+ "hidden md:inline-flex items-center justify-center shrink-0",
+ "w-7 h-7 rounded-md text-[#8C8C8C] hover:text-white hover:bg-[#1f1f1f99]",
+ "transition-colors cursor-pointer",
+ collapsed
+ ? "mx-auto"
+ : // ml-auto right-aligns inside the header row; -mr-2 pulls
+ // past the header's own pr-0 + most of the aside's pr-3 so
+ // the caret sits flush against the right edge of the rail.
+ "ml-auto md:-mr-2",
+ )}
+ >
+ {collapsed ? (
+ <ChevronRight width={18} height={18} />
+ ) : (
+ <ChevronLeft width={18} height={18} />
+ )}
+ </button>
</div>
- <div className="hidden md:flex md:flex-col md:items-stretch">
- <BackendSelector />
- </div>
+ {/* Hide the backend selector when collapsed — it is a wide dropdown
+ that doesn't compress meaningfully into a 56px rail. Users who
+ want to switch backends can expand the sidebar first. */}
+ {!collapsed && (
+ <div className="hidden md:flex md:flex-col md:items-stretch">
+ <BackendSelector />
+ </div>
+ )}
- <nav className="flex flex-row md:flex-col gap-1 md:gap-0.5 items-center md:items-stretch w-full md:shrink-0">
+ <nav
+ className={cn(
+ "flex flex-row md:flex-col gap-1 md:gap-0.5 w-full md:shrink-0",
+ collapsed
+ ? "items-center md:items-center"
+ : "items-center md:items-stretch",
+ )}
+ >
<SidebarNavLink
to="/conversations"
label={t(I18nKey.SIDEBAR$CONVERSATIONS)}
testId="sidebar-conversations-link"
disabled={linkDisabled}
- />
- <SidebarNavLink
- to="/automations"
- label={t(I18nKey.SIDEBAR$AUTOMATIONS)}
- testId="sidebar-automations-link"
- disabled={linkDisabled}
+ collapsed={collapsed}
+ icon={<MessageIcon width={ICON_SIZE} height={ICON_SIZE} />}
/>
<SidebarNavLink
to="/skills"
label={t(I18nKey.SIDEBAR$SKILLS)}
testId="sidebar-skills-link"
disabled={linkDisabled}
+ collapsed={collapsed}
+ icon={<SparkleIcon width={ICON_SIZE} height={ICON_SIZE} />}
+ />
+ <SidebarNavLink
+ to="/automations"
+ label={t(I18nKey.SIDEBAR$AUTOMATIONS)}
+ testId="sidebar-automations-link"
+ disabled={linkDisabled}
+ collapsed={collapsed}
+ icon={<AutomationsIcon width={ICON_SIZE} height={ICON_SIZE} />}
/>
{/*
Integrations tab is currently hidden because it isn't working yet.
@@ -132,68 +246,87 @@ export function Sidebar() {
disabled={linkDisabled}
/> */}
<div className="hidden md:flex flex-col gap-0.5">
- <button
- type="button"
- data-testid="sidebar-settings-toggle"
- aria-expanded={settingsExpanded}
- onClick={() => setSettingsExpanded((prev) => !prev)}
- className={cn(
- "flex items-center justify-between w-full text-sm leading-5 px-3 py-2 rounded-md transition-colors cursor-pointer",
- isSettingsActive
- ? "bg-[#1f1f1f99] text-white font-medium"
- : "text-[#8C8C8C] hover:text-white hover:bg-[#1f1f1f99]",
- )}
- >
- <span>{t(I18nKey.SIDEBAR$SETTINGS)}</span>
- <svg
- width="14"
- height="14"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- aria-hidden="true"
- className={cn(
- "transition-transform duration-150",
- settingsExpanded ? "rotate-180" : "rotate-0",
+ {collapsed ? (
+ // Collapsed: render Settings as a single icon link to /settings
+ // with a hover-flyout that lists the full submenu.
+ <SidebarNavLink
+ to="/settings"
+ label={t(I18nKey.SIDEBAR$SETTINGS)}
+ testId="sidebar-settings-link"
+ disabled={linkDisabled}
+ collapsed
+ icon={<CogIcon width={ICON_SIZE} height={ICON_SIZE} />}
+ hoverContent={settingsHoverPanel}
+ />
+ ) : (
+ <>
+ <button
+ type="button"
+ data-testid="sidebar-settings-toggle"
+ aria-expanded={settingsExpanded}
+ onClick={() => setSettingsExpanded((prev) => !prev)}
+ className={cn(
+ "flex items-center justify-between w-full text-sm leading-5 px-3 py-2 rounded-md transition-colors cursor-pointer",
+ isSettingsActive
+ ? "bg-[#1f1f1f99] text-white font-medium"
+ : "text-[#8C8C8C] hover:text-white hover:bg-[#1f1f1f99]",
+ )}
+ >
+ <span className="flex items-center gap-2">
+ <CogIcon width={ICON_SIZE} height={ICON_SIZE} />
+ {t(I18nKey.SIDEBAR$SETTINGS)}
+ </span>
+ <svg
+ width="14"
+ height="14"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ aria-hidden="true"
+ className={cn(
+ "transition-transform duration-150",
+ settingsExpanded ? "rotate-180" : "rotate-0",
+ )}
+ >
+ <polyline points="6 9 12 15 18 9" />
+ </svg>
+ </button>
+ {settingsExpanded && (
+ <div className="flex flex-col gap-0.5 pt-0.5">
+ {settingsNavItems.map((rendered) => {
+ if (rendered.type !== "item") return null;
+ const navIcon = SETTINGS_NAV_ICON_BY_PATH.get(
+ rendered.item.to,
+ );
+ return (
+ <SidebarNavLink
+ key={rendered.item.to}
+ to={rendered.item.to}
+ label={t(rendered.item.text as I18nKey)}
+ end
+ indent
+ testId={`sidebar-settings-${rendered.item.to}`}
+ disabled={linkDisabled}
+ icon={
+ navIcon
+ ? React.cloneElement(
+ navIcon as React.ReactElement<{
+ width?: number;
+ height?: number;
+ }>,
+ { width: 16, height: 16 },
+ )
+ : undefined
+ }
+ />
+ );
+ })}
+ </div>
)}
- >
- <polyline points="6 9 12 15 18 9" />
- </svg>
- </button>
- {settingsExpanded && (
- <div className="flex flex-col gap-0.5 pt-0.5">
- {settingsNavItems.map((rendered) => {
- if (rendered.type !== "item") return null;
- const navIcon = SETTINGS_NAV_ICON_BY_PATH.get(
- rendered.item.to,
- );
- return (
- <SidebarNavLink
- key={rendered.item.to}
- to={rendered.item.to}
- label={t(rendered.item.text as I18nKey)}
- end
- indent
- testId={`sidebar-settings-${rendered.item.to}`}
- disabled={linkDisabled}
- icon={
- navIcon
- ? React.cloneElement(
- navIcon as React.ReactElement<{
- width?: number;
- height?: number;
- }>,
- { width: 16, height: 16 },
- )
- : undefined
- }
- />
- );
- })}
- </div>
+ </>
)}
</div>
{/* Mobile: settings as a flat link, no submenu */}
@@ -218,6 +351,6 @@ export function Sidebar() {
/>
</React.Suspense>
)}
- </>
+ </SidebarCollapseContext.Provider>
);
}
diff --git a/src/hooks/use-sidebar-collapsed.ts b/src/hooks/use-sidebar-collapsed.ts
new file mode 100644
index 0000000000..558e461034
--- /dev/null
+++ b/src/hooks/use-sidebar-collapsed.ts
@@ -0,0 +1,35 @@
+import React from "react";
+
+const STORAGE_KEY = "openhands-sidebar-collapsed";
+
+const readPersisted = (): boolean => {
+ if (typeof window === "undefined") return false;
+ try {
+ return window.localStorage.getItem(STORAGE_KEY) === "true";
+ } catch {
+ return false;
+ }
+};
+
+/**
+ * Persisted boolean for whether the desktop sidebar is collapsed to the
+ * icon-only rail. The value is stored in localStorage so the user's choice
+ * survives reloads.
+ */
+export function useSidebarCollapsedState(): readonly [
+ boolean,
+ (next: boolean | ((prev: boolean) => boolean)) => void,
+] {
+ const [collapsed, setCollapsed] = React.useState<boolean>(readPersisted);
+
+ React.useEffect(() => {
+ if (typeof window === "undefined") return;
+ try {
+ window.localStorage.setItem(STORAGE_KEY, collapsed ? "true" : "false");
+ } catch {
+ // ignore quota / privacy-mode failures; the in-memory state is still fine
+ }
+ }, [collapsed]);
+
+ return [collapsed, setCollapsed] as const;
+}
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 1fe23a8d6c..b3daaf3db7 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -10692,6 +10692,12 @@
"uk": "Навігація бічної панелі",
"ca": "Navegació de la barra lateral"
},
+ "SIDEBAR$COLLAPSE": {
+ "en": "Collapse sidebar"
+ },
+ "SIDEBAR$EXPAND": {
+ "en": "Expand sidebar"
+ },
"FEEDBACK$PUBLIC_LABEL": {
"en": "Public",
"zh-CN": "公开",
diff --git a/src/icons/message.svg b/src/icons/message.svg
index 3bf0a6e3e2..33e0bb01f3 100644
--- a/src/icons/message.svg
+++ b/src/icons/message.svg
@@ -1,5 +1,5 @@
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M19.8335 8.16634H8.16683C7.85741 8.16634 7.56066 8.28926 7.34187 8.50805C7.12308 8.72684 7.00016 9.02359 7.00016 9.33301C7.00016 9.64243 7.12308 9.93917 7.34187 10.158C7.56066 10.3768 7.85741 10.4997 8.16683 10.4997H19.8335C20.1429 10.4997 20.4397 10.3768 20.6585 10.158C20.8772 9.93917 21.0002 9.64243 21.0002 9.33301C21.0002 9.02359 20.8772 8.72684 20.6585 8.50805C20.4397 8.28926 20.1429 8.16634 19.8335 8.16634ZM19.8335 12.833H8.16683C7.85741 12.833 7.56066 12.9559 7.34187 13.1747C7.12308 13.3935 7.00016 13.6903 7.00016 13.9997C7.00016 14.3091 7.12308 14.6058 7.34187 14.8246C7.56066 15.0434 7.85741 15.1663 8.16683 15.1663H19.8335C20.1429 15.1663 20.4397 15.0434 20.6585 14.8246C20.8772 14.6058 21.0002 14.3091 21.0002 13.9997C21.0002 13.6903 20.8772 13.3935 20.6585 13.1747C20.4397 12.9559 20.1429 12.833 19.8335 12.833ZM22.1668 2.33301H5.8335C4.90524 2.33301 4.015 2.70176 3.35862 3.35813C2.70225 4.01451 2.3335 4.90475 2.3335 5.83301V17.4997C2.3335 18.4279 2.70225 19.3182 3.35862 19.9745C4.015 20.6309 4.90524 20.9997 5.8335 20.9997H19.3552L23.6718 25.328C23.7808 25.4361 23.9101 25.5217 24.0523 25.5797C24.1944 25.6378 24.3466 25.6672 24.5002 25.6663C24.6532 25.6703 24.805 25.6383 24.9435 25.573C25.1565 25.4855 25.3389 25.3369 25.4677 25.1458C25.5964 24.9548 25.6657 24.73 25.6668 24.4997V5.83301C25.6668 4.90475 25.2981 4.01451 24.6417 3.35813C23.9853 2.70176 23.0951 2.33301 22.1668 2.33301ZM23.3335 21.688L20.6618 19.0047C20.5528 18.8965 20.4235 18.811 20.2814 18.7529C20.1392 18.6949 19.987 18.6655 19.8335 18.6663H5.8335C5.52408 18.6663 5.22733 18.5434 5.00854 18.3246C4.78975 18.1058 4.66683 17.8091 4.66683 17.4997V5.83301C4.66683 5.52359 4.78975 5.22684 5.00854 5.00805C5.22733 4.78926 5.52408 4.66634 5.8335 4.66634H22.1668C22.4762 4.66634 22.773 4.78926 22.9918 5.00805C23.2106 5.22684 23.3335 5.52359 23.3335 5.83301V21.688Z"
- fill="white" />
+ fill="currentColor" />
</svg>