Skip to content

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

Simple: a round blue update button after Connect apps (#6893)

Milind Sonia53a9a48d80f
diff --git a/src/App.tsx b/src/App.tsx
index 4dbd05d555..e84653a833 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -349,8 +349,10 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
}, [dispatch]);
const framed = windowFramed(capabilities);
+ // The sidebar is on screen, so its update button is too. In Simple that button is the one; the top bar leaves its own out.
+ const sidebarShown = !calendarFocus && (sidebarInline || drawerOpen);
const strips = <>
- <UpdateBanner sidebarIndicator={framed || (!calendarFocus && (sidebarInline || drawerOpen))} />
+ <UpdateBanner sidebarIndicator={framed || sidebarShown} />
<CloudAsleepStrip />
<LiveConnectionStrip connected={state.connected} hydrated={state.hydrated === true} />
<CloudSendStrip cloudHome={state.config?.cloudHome === true} />
@@ -360,7 +362,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
</>;
return (
<div data-look="app" className={cn("flex h-full flex-col", framed && "bg-frame")} onClickCapture={drawerOpen ? noteDrawerAction : undefined} onKeyDownCapture={drawerOpen ? noteDrawerAction : undefined}>
- <WindowFrameBar notifications={notificationTray} />
+ <WindowFrameBar notifications={notificationTray} sidebarUpdate={!advanced && sidebarShown} />
<BotLimitPopup />
<ConversationShareDialogs />
{!framed && strips}
diff --git a/src/components/SidebarConnectApps.test.ts b/src/components/SidebarConnectApps.test.ts
index a689b82153..aad7df86b6 100644
--- a/src/components/SidebarConnectApps.test.ts
+++ b/src/components/SidebarConnectApps.test.ts
@@ -34,6 +34,18 @@ describe("the Connect apps faces", () => {
expect(faces[2]).toContain("motion-safe:group-hover/apps:translate-x-[3px] motion-safe:group-hover/apps:rotate-[8deg]");
});
+ it("never cuts its label short: in a tight row, as beside the update button, whole logos drop instead", () => {
+ const html = renderToStaticMarkup(createElement(SidebarConnectApps));
+ const label = /<span data-apps-label="" class="([^"]*)">Connect apps<\/span>/.exec(html)?.[1]?.split(" ");
+ expect(label).toEqual(expect.arrayContaining(["shrink-0", "whitespace-nowrap"]));
+ expect(label).not.toContain("truncate");
+ expect(label).not.toContain("min-w-0");
+ const faces = /data-app-faces="" class="([^"]*)"/.exec(html)![1]!.split(" ");
+ expect(faces, "the logos give way: they wrap onto a line one logo high hides").toEqual(expect.arrayContaining(["min-w-0", "flex-wrap", "h-[22px]", "overflow-hidden"]));
+ expect(faces).not.toContain("shrink-0");
+ expect(html, "an empty first item, so even the first logo can wrap away whole").toMatch(/data-app-faces="" class="[^"]*"><span data-app-faces-start="" class="-me-1 h-\[18px\] w-0"><\/span><span data-app-face=/);
+ });
+
it("is a round 36px puzzle button on the collapsed rail, named for screen readers", () => {
const html = renderToStaticMarkup(createElement(SidebarConnectApps, { circle: true }));
expect(html).toMatch(/data-tour="nav-apps"[^>]*aria-label="Connect apps" title="Connect apps" class="[^"]*\bsize-9\b[^"]*\brounded-full\b/);
diff --git a/src/components/SidebarConnectApps.tsx b/src/components/SidebarConnectApps.tsx
index 7bc9e90705..f3e777bd60 100644
--- a/src/components/SidebarConnectApps.tsx
+++ b/src/components/SidebarConnectApps.tsx
@@ -82,9 +82,13 @@ export function SidebarConnectApps({ circle = false }: { circle?: boolean }) {
className={circle ? SIMPLE_TOP_BUTTON : cn("group/apps flex h-9 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full pl-4 pr-3 text-[14px] font-medium leading-5 text-ink", ELEVATED_CONTROL, ELEVATED_HOVER)}
>
{circle ? <Puzzle size={16} aria-hidden="true" /> : <>
- <span className="min-w-0 truncate">{label}</span>
- {/* The logos rest grey and apart, with no tile, so the sidebar's loudest colour is never an ad; hover brings the tiles and colour back. */}
- <span aria-hidden="true" data-app-faces="" className="flex shrink-0 items-center gap-1 opacity-60 grayscale motion-safe:transition-[filter,opacity] group-hover/apps:opacity-100 group-hover/apps:grayscale-0 group-hover/apps:invert-0 group-hover/apps:mix-blend-normal group-focus-visible/apps:opacity-100 group-focus-visible/apps:grayscale-0 group-focus-visible/apps:invert-0 group-focus-visible/apps:mix-blend-normal">
+ <span data-apps-label="" className="shrink-0 whitespace-nowrap">{label}</span>
+ {/* The logos rest grey and apart, with no tile, so the sidebar's loudest colour is never an ad; hover brings the tiles and colour back.
+ In a tight row the label stays whole and whole logos drop instead: they wrap onto a second line that the one-line
+ height hides; the empty first item, a logo high and no wider than nothing, lets even the first logo wrap rather than show cut. The
+ padding, taken back by the negative margin, leaves room for the hover fan. */}
+ <span aria-hidden="true" data-app-faces="" className="-mx-1 -my-0.5 flex h-[22px] min-w-0 flex-wrap content-start items-center gap-1 overflow-hidden px-1 py-0.5 opacity-60 grayscale motion-safe:transition-[filter,opacity] group-hover/apps:opacity-100 group-hover/apps:grayscale-0 group-hover/apps:invert-0 group-hover/apps:mix-blend-normal group-focus-visible/apps:opacity-100 group-focus-visible/apps:grayscale-0 group-focus-visible/apps:invert-0 group-focus-visible/apps:mix-blend-normal">
+ <span data-app-faces-start="" className="-me-1 h-[18px] w-0" />
{faces.map((face, index) => <AppFaceIcon key={face.slug} face={face}
className={cn(faces.length > 1 && FAN[index === 0 ? 0 : index === faces.length - 1 ? 2 : 1], "motion-safe:transition-transform motion-safe:duration-150")} />)}
</span>
diff --git a/src/components/SidebarFooter.tsx b/src/components/SidebarFooter.tsx
index 3dde7a39eb..4f6290377f 100644
--- a/src/components/SidebarFooter.tsx
+++ b/src/components/SidebarFooter.tsx
@@ -42,7 +42,7 @@ function SimpleSidebarFooter({ owner, archived }: { owner: string | null; archiv
<div className="flex items-center gap-2 not-first:mt-2">
<SidebarProfileMenu simple={account} />
<SidebarConnectApps />
- <UpdateIndicator className="size-9" />
+ <UpdateIndicator />
</div>
</div>
);
diff --git a/src/components/UpdateIndicator.test.ts b/src/components/UpdateIndicator.test.ts
index 44a3a7a75e..2c05fe4122 100644
--- a/src/components/UpdateIndicator.test.ts
+++ b/src/components/UpdateIndicator.test.ts
@@ -3,6 +3,8 @@ import { act, createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { botButtonTone } from "@/lib/bot-button";
+import { setAdvancedMode } from "@/lib/interface-mode";
import type { UpdaterState } from "@/lib/updater";
import { UpdateIndicator, updateIndicatorLabel, updateIndicatorShown } from "./UpdateIndicator";
import { updateHasButton } from "./SidebarProfileMenu";
@@ -35,6 +37,7 @@ beforeEach(async () => {
getState: async () => ({ status: "idle" }),
},
};
+ setAdvancedMode(true);
host = document.createElement("div");
document.body.appendChild(host);
root = createRoot(host);
@@ -67,6 +70,25 @@ describe("the update button", () => {
expect(updateHasButton("handed-off")).toBe(false);
});
+ it("in Simple is a round blue button the height of the Connect apps pill, its white arrow pulsing while it downloads", async () => {
+ expect(botButtonTone("blue").ink, "white on a blue bot's own send-button fill").toBe("#ffffff");
+ await act(async () => setAdvancedMode(false));
+ expect(button(), "nothing while there is no update").toBeNull();
+ await emit({ status: "downloading", version: "0.2.0", percent: 10 });
+ const classes = () => button()!.className.split(" ");
+ expect(classes()).toEqual(expect.arrayContaining(["bot-button", "size-9", "rounded-full", "animate-pulse", "motion-reduce:animate-none"]));
+ expect(classes()).not.toContain("bg-white");
+ expect(button()!.style.getPropertyValue("--bot-button")).toBe(botButtonTone("blue").fill);
+ expect(button()!.style.getPropertyValue("--bot-button-ink")).toBe("#ffffff");
+ await emit({ status: "downloaded", version: "0.2.0" });
+ expect(classes(), "still once it is ready").not.toContain("animate-pulse");
+ await act(async () => button()!.click());
+ expect(card(), "it opens the update card").not.toBeNull();
+ await emit({ status: "idle" });
+ expect(button(), "gone once the app has updated").toBeNull();
+ expect(card()).toBeNull();
+ });
+
it("appears when an update arrives and goes when there is none", async () => {
expect(button()).toBeNull();
await emit({ status: "downloading", version: "0.2.0", percent: 10 });
diff --git a/src/components/UpdateIndicator.tsx b/src/components/UpdateIndicator.tsx
index 50bcf20235..f091e028db 100644
--- a/src/components/UpdateIndicator.tsx
+++ b/src/components/UpdateIndicator.tsx
@@ -6,8 +6,10 @@ import { updaterMessage, useUpdaterState, type UpdaterState } from "@/lib/update
import { releaseHighlights } from "@/lib/release-highlights";
import { RELEASES_URL, desktopAppVersion, openExternalLink } from "@/lib/app-links";
import { productName } from "../lib/brand";
+import { BOT_BUTTON, botButtonStyle } from "@/lib/bot-button";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
+import { useAdvancedMode } from "@/lib/interface-mode";
import { useDesktopCapabilities, windowFramed } from "./DesktopCapabilities";
export function updateIndicatorShown(state: UpdaterState | null): boolean {
@@ -26,18 +28,21 @@ export function updateIndicatorLabel(state: UpdaterState): string {
: t("update.button.downloading", { percent: Math.round(state.percent) });
}
-/** `bar`: in the window frame's top bar, a download arrow in that bar's button look (the class given). In a framed
- * window that arrow is the only one, so the sidebar's round buttons draw nothing. */
+/** `bar`: in the window frame's top bar, a download arrow in that bar's button look (the class given). In Advanced, a
+ * framed window shows only that arrow, so the sidebar's round buttons draw nothing. In Simple the sidebar's button is
+ * the one, a round blue button the height of the Connect apps pill, and the top bar leaves its arrow out while the
+ * sidebar is on screen (WindowFrameBar's `sidebarUpdate`). */
export function UpdateIndicator({ className, bar }: { className?: string; bar?: string }) {
const state = useUpdaterState();
const framed = windowFramed(useDesktopCapabilities().capabilities);
+ const advanced = useAdvancedMode();
const [open, setOpen] = useState(false);
const buttonRef = useRef<HTMLButtonElement>(null);
const settled = !state || state.status === "idle" || state.status === "checking" || state.status === "handed-off";
useEffect(() => {
if (settled) setOpen(false);
}, [settled]);
- if (framed && bar === undefined) return null;
+ if (framed && advanced && bar === undefined) return null;
if (!state || !updateIndicatorShown(state)) {
return open && !settled ? <UpdateCard state={state} onClose={() => setOpen(false)} returnFocusRef={buttonRef} /> : null;
}
@@ -60,6 +65,24 @@ export function UpdateIndicator({ className, bar }: { className?: string; bar?:
{open && <UpdateCard state={state} onClose={() => setOpen(false)} returnFocusRef={buttonRef} />}
</>
);
+ if (!advanced) return (
+ <>
+ <button
+ ref={buttonRef}
+ type="button"
+ data-update-indicator={state.status}
+ aria-label={label}
+ aria-haspopup="dialog"
+ title={label}
+ onClick={() => setOpen(true)}
+ style={botButtonStyle("blue")}
+ className={cn(BOT_BUTTON, "flex size-9 shrink-0 items-center justify-center rounded-full shadow-sm transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus", !ready && "animate-pulse motion-reduce:animate-none")}
+ >
+ <ArrowDown size={18} strokeWidth={2.25} aria-hidden />
+ </button>
+ {open && <UpdateCard state={state} onClose={() => setOpen(false)} returnFocusRef={buttonRef} />}
+ </>
+ );
return (
<div
className={cn("flex size-[46px] shrink-0 items-center justify-center", className)}
diff --git a/src/components/WindowFrameBar.test.ts b/src/components/WindowFrameBar.test.ts
index 38e3ebfcb7..f455019c24 100644
--- a/src/components/WindowFrameBar.test.ts
+++ b/src/components/WindowFrameBar.test.ts
@@ -28,6 +28,7 @@ vi.mock("./DesktopCapabilities", async (importOriginal) => ({
}));
import { setLocale } from "@/lib/i18n";
+import { setAdvancedMode } from "@/lib/interface-mode";
import { tilesClearCorner } from "./SidebarTiles";
import { NotificationRail } from "./NotificationsPanel";
import { UpdateIndicator } from "./UpdateIndicator";
@@ -38,6 +39,7 @@ let host: HTMLDivElement, root: Root | null = null;
let place: Place | null;
beforeEach(() => {
setLocale("en");
+ setAdvancedMode(true);
host = document.createElement("div");
document.body.append(host);
fixture.windowChrome = "mac-inset";
@@ -195,6 +197,44 @@ describe("the window frame's top bar", () => {
await act(async () => root!.render(createElement(UpdateIndicator)));
expect(host.querySelector("[data-update-indicator='downloaded']"), "unframed, the sidebar keeps its own").not.toBeNull();
});
+
+ const simpleWindow = (sidebarUpdate: boolean) =>
+ createElement("div", null, createElement(WindowFrameBar, { sidebarUpdate }), createElement("aside", null, createElement(UpdateIndicator)));
+ const sidebarButton = () => host.querySelector<HTMLButtonElement>("aside [data-update-indicator]");
+
+ it("in Simple leaves the update to the sidebar's blue button, the only one, while the sidebar is on screen", async () => {
+ setAdvancedMode(false);
+ fixture.update = { status: "downloaded", version: "0.1.176" };
+ await mount(simpleWindow(true));
+ expect(bar()!.querySelector("[data-update-indicator]"), "no arrow on the bar").toBeNull();
+ expect(sidebarButton()!.className.split(" ")).toEqual(expect.arrayContaining(["bot-button", "size-9", "rounded-full"]));
+ expect(host.querySelectorAll("[data-update-indicator]")).toHaveLength(1);
+ });
+
+ it("in Simple keeps the bar's arrow while the sidebar is hidden, so an update always has a button", async () => {
+ setAdvancedMode(false);
+ fixture.update = { status: "downloaded", version: "0.1.176" };
+ await mount(createElement(WindowFrameBar, { sidebarUpdate: false }));
+ expect(bar()!.querySelector("[data-update-indicator='downloaded']")).not.toBeNull();
+ });
+
+ it("in Advanced keeps the bar's arrow and the sidebar's round buttons step aside", async () => {
+ fixture.update = { status: "downloading", percent: 10 };
+ await mount(simpleWindow(false));
+ expect(bar()!.querySelector("[data-update-indicator='downloading']")).not.toBeNull();
+ expect(sidebarButton()).toBeNull();
+ });
+
+ it("shows no update button anywhere while there is none, or once the app has updated", async () => {
+ for (const [advanced, update] of [[false, null], [false, { status: "idle" }], [false, { status: "checking" }], [true, { status: "idle" }], [false, { status: "handed-off" }]] as const) {
+ setAdvancedMode(advanced);
+ fixture.update = update;
+ await mount(simpleWindow(!advanced));
+ expect(host.querySelector("[data-update-indicator]"), `${advanced ? "Advanced" : "Simple"}, ${update?.status ?? "no updater"}`).toBeNull();
+ await act(async () => root!.unmount());
+ root = null;
+ }
+ });
});
describe("the bell on the window's edge, for windows without the top bar", () => {
diff --git a/src/components/WindowFrameBar.tsx b/src/components/WindowFrameBar.tsx
index 2e70db1536..6106438a6f 100644
--- a/src/components/WindowFrameBar.tsx
+++ b/src/components/WindowFrameBar.tsx
@@ -18,10 +18,11 @@ export const FRAME_BAR_BUTTON = "flex size-[22px] shrink-0 items-center justify-
/** The window frame's top bar (windowFramed), as thin as the traffic lights allow: they sit in it on macOS (main puts
* them there: electron/window-chrome.mjs), the caption buttons on Windows (WindowCaptionButtons, drawn over its right
* end). The rail's button follows the traffic lights; the place on screen is named in its middle; an update while one
- * waits, the Notifications bell (when `notifications`: the tray is on here) and the app's settings, close the right end.
+ * waits (unless `sidebarUpdate`: Simple's sidebar is on screen and shows it), the Notifications bell (when
+ * `notifications`: the tray is on here) and the app's settings, close the right end.
* The whole bar drags the window. It reaches under the window's rail (the page starts --rail-beside in), so its middle
* is the window's middle. */
-export function WindowFrameBar({ notifications = false }: { notifications?: boolean }) {
+export function WindowFrameBar({ notifications = false, sidebarUpdate = false }: { notifications?: boolean; sidebarUpdate?: boolean }) {
const { capabilities } = useDesktopCapabilities();
const { dispatch } = useStore();
const frameable = windowFrameable(capabilities), framed = windowFramed(capabilities);
@@ -42,7 +43,7 @@ export function WindowFrameBar({ notifications = false }: { notifications?: bool
</div>
<WindowPlaceTitle />
<div data-frame-bar-end className={cn("flex items-center justify-end gap-0.5", mac ? "pr-2" : "pr-[140px]")}>
- <UpdateIndicator bar={FRAME_BAR_BUTTON} />
+ {!sidebarUpdate && <UpdateIndicator bar={FRAME_BAR_BUTTON} />}
{notifications && <NotificationBell bar={FRAME_BAR_BUTTON} />}
<button
type="button"