Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/web/src/components/DesktopTitlebarSpacer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vite-plus/test";

import { DesktopTitlebarSpacer } from "./DesktopTitlebarSpacer";

describe("DesktopTitlebarSpacer", () => {
it("renders a full workspace drag region in Electron", () => {
const markup = renderToStaticMarkup(<DesktopTitlebarSpacer enabled />);

expect(markup).toContain('aria-hidden="true"');
expect(markup).toContain("workspace-topbar");
expect(markup).toContain("drag-region");
});

it("does not reserve titlebar space in the browser", () => {
expect(renderToStaticMarkup(<DesktopTitlebarSpacer enabled={false} />)).toBe("");
});
});
12 changes: 12 additions & 0 deletions apps/web/src/components/DesktopTitlebarSpacer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { isElectron } from "../env";

interface DesktopTitlebarSpacerProps {
readonly enabled?: boolean;
}

/** Keeps an otherwise empty Electron workspace draggable when the sidebar is closed. */
export function DesktopTitlebarSpacer({ enabled = isElectron }: DesktopTitlebarSpacerProps) {
if (!enabled) return null;

return <div aria-hidden="true" className="workspace-topbar drag-region" />;
}
2 changes: 2 additions & 0 deletions apps/web/src/routes/_chat.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LinkIcon, PlusIcon, RotateCcwIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";

import { openCommandPalette } from "../commandPaletteBus";
import { DesktopTitlebarSpacer } from "../components/DesktopTitlebarSpacer";
import { sortScopedProjectsForSidebar } from "../components/Sidebar.logic";
import { Button } from "../components/ui/button";
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../components/ui/empty";
Expand Down Expand Up @@ -110,6 +111,7 @@ function NoProjectsHero() {
return (
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground">
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-background">
<DesktopTitlebarSpacer />
<Empty className="flex-1">
<div className="w-full max-w-lg px-8 py-12">
<EmptyHeader className="max-w-none">
Expand Down
Loading