Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

feat(sidebar): fold Tools in the icon column

sakuralost26a42f505383
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 2476992cb3..0a5550045b 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1481,7 +1481,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
{rail ? <SimpleRailFooter
owner={cloudOwner}
archived={archivedEntry}
- /> : phone ? <SidebarPhoneBar query={query} onQuery={setQuery} /> : <SidebarFooter density={density} simple={simpleDesk} owner={cloudOwner} archived={archivedEntry} toolsCollapsed={sectionCollapsed(TOOLS_SECTION_ID)} onToggleTools={layoutInteractive ? () => toggleSection(TOOLS_SECTION_ID) : undefined} />}
+ /> : phone ? <SidebarPhoneBar query={query} onQuery={setQuery} /> : <SidebarFooter density={density} simple={simpleDesk} owner={cloudOwner} archived={archivedEntry} toolsCollapsed={sectionCollapsed(TOOLS_SECTION_ID)} onToggleTools={() => toggleSection(TOOLS_SECTION_ID)} />}
</GlassBar>
</GlassScrollFrame>
diff --git a/src/components/SidebarFooter.tsx b/src/components/SidebarFooter.tsx
index 63fdf4acb9..05fd64dd04 100644
--- a/src/components/SidebarFooter.tsx
+++ b/src/components/SidebarFooter.tsx
@@ -1,6 +1,8 @@
+import { ChevronDown, ChevronRight } from "lucide-react";
import { useRef } from "react";
import { cn } from "@/lib/cn";
+import { t } from "@/lib/i18n";
import type { SidebarDensity } from "@/lib/sidebar-preferences";
import { useStore } from "@/state/store";
@@ -9,7 +11,7 @@ import { CloudRoomCard } from "./CloudRoomCard";
import { CloudUsageCard } from "./CloudUsageMeter";
import { endCloudHowTo, useWorkspacePlace, type WorkspacePlace } from "./DesktopWorkspaceSwitcher";
import { SidebarConnectApps } from "./SidebarConnectApps";
-import { SidebarBottomButtons, SidebarFooterNav } from "./SidebarFooterNav";
+import { SidebarBottomButtons, SidebarFooterNav, useAutomationsNeedYou } from "./SidebarFooterNav";
import { phoneSettingsAction, SidebarPhoneButton } from "./SidebarPhoneButton";
import { StorageNotice } from "./StorageNotice";
import { SidebarProfileMenu, useSimpleAccount, type ArchivedBots } from "./SidebarProfileMenu";
@@ -50,6 +52,27 @@ function SimpleSidebarFooter({ owner, archived }: { owner: string | null; archiv
);
}
+function ToolsFoldButton({ collapsed, alert, onToggle }: { collapsed: boolean; alert: boolean; onToggle?: () => void }) {
+ if (!onToggle) return null;
+ const label = t(collapsed ? "sidebar.section.expand" : "sidebar.section.collapse", { name: t("sidebar.tools") });
+ const Chevron = collapsed ? ChevronRight : ChevronDown;
+ return (
+ <button
+ type="button"
+ data-sidebar-tools-fold=""
+ data-tour={collapsed ? "tools" : undefined}
+ aria-expanded={!collapsed}
+ aria-label={label}
+ title={label}
+ onClick={onToggle}
+ className="relative mx-auto flex size-[46px] shrink-0 items-center justify-center rounded-xl text-ink-secondary hover:bg-raised hover:text-ink"
+ >
+ <Chevron size={18} aria-hidden="true" />
+ {alert && <span data-testid="section-alert" aria-hidden="true" className="absolute right-2 top-2 size-2 rounded-full bg-danger" />}
+ </button>
+ );
+}
+
export function SidebarFooter({ density, simple = false, owner = null, archived, toolsCollapsed, onToggleTools }: {
density: SidebarDensity;
simple?: boolean;
@@ -59,15 +82,19 @@ export function SidebarFooter({ density, simple = false, owner = null, archived,
onToggleTools?: () => void;
}) {
const { dispatch } = useStore();
+ const automationsNeedYou = useAutomationsNeedYou();
if (simple) return <SimpleSidebarFooter owner={owner} archived={archived} />;
+ const icons = density === "icons";
+ const toolsOpen = !icons || !toolsCollapsed;
return (
- <div className={cn("pb-3 pt-2", density === "icons" ? "flex flex-col items-center gap-1 px-2" : "px-3")}>
- <SidebarFooterNav density={density} collapsed={toolsCollapsed} onToggleCollapsed={onToggleTools} />
- {density === "icons" ? (
+ <div className={cn("pb-3 pt-2", icons ? "flex flex-col items-center gap-1 px-2" : "px-3")}>
+ {icons && <ToolsFoldButton collapsed={toolsCollapsed} alert={toolsCollapsed && automationsNeedYou} onToggle={onToggleTools} />}
+ {toolsOpen && <SidebarFooterNav density={density} collapsed={toolsCollapsed} onToggleCollapsed={onToggleTools} />}
+ {icons ? (
<>
- <SidebarPhoneButton density={density} onOpen={() => dispatch(phoneSettingsAction())} />
+ {toolsOpen && <SidebarPhoneButton density={density} onOpen={() => dispatch(phoneSettingsAction())} />}
<div className="flex flex-col items-center justify-center gap-1">
- <UpdateIndicator />
+ {toolsOpen && <UpdateIndicator />}
<SidebarProfileMenu iconOnly />
</div>
</>
diff --git a/src/components/SidebarFooterNav.test.ts b/src/components/SidebarFooterNav.test.ts
index 92f00b71f2..cade191b7e 100644
--- a/src/components/SidebarFooterNav.test.ts
+++ b/src/components/SidebarFooterNav.test.ts
@@ -214,6 +214,15 @@ describe("Tools header", () => {
expect(render("comfortable", { collapsed: true }).html).not.toContain('data-testid="section-alert"');
});
+ it("hides the icon rows when the shared Tools section is collapsed", () => {
+ fixture.advanced = true;
+ const { html } = render("icons", { collapsed: true });
+ for (const id of ["automations", "team-map", "published-apps", "apps"]) {
+ expect(html).not.toContain(`data-sidebar-nav="${id}"`);
+ }
+ expect(html).not.toContain(">Tools<");
+ });
+
it("draws no Tools header in the avatars-only density or in Simple mode", () => {
fixture.advanced = true;
expect(render("icons").html).not.toContain(">Tools<");
diff --git a/src/components/SidebarFooterNav.tsx b/src/components/SidebarFooterNav.tsx
index 7c3046b470..dfb5bc6597 100644
--- a/src/components/SidebarFooterNav.tsx
+++ b/src/components/SidebarFooterNav.tsx
@@ -208,6 +208,7 @@ export function SidebarFooterNav({
);
if (iconsOnly) {
+ if (collapsed) return null;
return <nav data-tour="tools" aria-label={t("sidebar.tools")} className="flex flex-col items-center gap-1">{rows}</nav>;
}
return (
diff --git a/src/components/SidebarSections.tsx b/src/components/SidebarSections.tsx
index 89f602870f..2492a7c2f4 100644
--- a/src/components/SidebarSections.tsx
+++ b/src/components/SidebarSections.tsx
@@ -11,6 +11,7 @@ import {
sameSectionOrder,
sidebarLayoutInteractive,
sidebarSectionCollapsed,
+ TOOLS_SECTION_ID,
simpleOrderedSections,
userSectionId,
withDepartmentOrder,
@@ -78,9 +79,13 @@ export function useSidebarSections({ simple, rail, density, query, label, sideba
announcement,
announce: setAnnouncement,
focusHeader,
- collapsed: (id: string) => sidebarSectionCollapsed(id, collapsedIds, density, query),
+ // The Tools footer keeps its collapsed flag in the avatar column. Other sections stay open there, because that
+ // column has no section headers to fold.
+ collapsed: (id: string) => id === TOOLS_SECTION_ID
+ ? collapsedIds.includes(id)
+ : sidebarSectionCollapsed(id, collapsedIds, density, query),
toggle: (id: string) => {
- if (!interactive) return;
+ if (!interactive && id !== TOOLS_SECTION_ID) return;
const next = toggleCollapsedSection(collapsedIds, id);
setCollapsedIds(next);
saveCollapsedSections(next);