Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix(gui): compact workspace chrome and restore side-drag split

Rach Pradhanc9c9f5626eaa
diff --git a/apps/native/components/primitives/SidebarNav.tsx b/apps/native/components/primitives/SidebarNav.tsx
index 149c5a76..d08efd4b 100644
--- a/apps/native/components/primitives/SidebarNav.tsx
+++ b/apps/native/components/primitives/SidebarNav.tsx
@@ -34,6 +34,7 @@ const WORKSPACE = { key: "graff", name: "Codegraff", monogram: "G" };
const NAV_ITEMS: { key: string; label: string; icon: ReactNode; count?: string }[] = [
{ key: "home", label: "Home", icon: <IconHome size={18} /> },
{ key: "projects", label: "Projects", icon: <IconFolder size={18} /> },
+ { key: "agents", label: "Agents", icon: <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" aria-hidden><circle cx="9" cy="8" r="3"/><circle cx="16" cy="9" r="2.4"/><path d="M4 19c.5-2.6 2.6-4.5 5-4.5s4.5 1.9 5 4.5M13.5 19c.4-1.7 1.8-3 3.5-3s3.1 1.3 3.5 3"/></svg> },
{ key: "conversations", label: "Conversations", icon: <IconChat size={18} /> },
{ key: "workspace", label: "Files", icon: <IconFolder size={18} /> },
{ key: "changes", label: "Changes", icon: <IconEditBig size={18} /> },
@@ -348,7 +349,7 @@ export default function SidebarNav({
key={item.key}
icon={item.icon}
label={item.label}
- count={item.key === "conversations" && recentsTotal != null ? String(recentsTotal) : item.count}
+ count={item.key === "conversations" && recentsTotal ? String(recentsTotal) : item.count}
active={currentNav === item.key}
onClick={() => selectNav(item.key)}
/>
@@ -479,9 +480,9 @@ export default function SidebarNav({
</Fragment>
);
})}
- {visibleRecents.length === 0 && (
+ {visibleRecents.length === 0 && (query || !openSessions) && (
<div className="sidebar-copy mx-2 px-2 py-2 text-[12.5px] text-ink-3">
- {query ? "No chats found" : openSessions ? "No saved conversations yet." : "No chats yet — start one and it appears here."}
+ {query ? "No chats found" : "No chats yet — start one and it appears here."}
</div>
)}
{!query && onSeeAll && (recentsTotal ?? recents.length) > recents.length && (
diff --git a/apps/native/components/site/AppSettings.tsx b/apps/native/components/site/AppSettings.tsx
index 3bebc640..76d0639c 100644
--- a/apps/native/components/site/AppSettings.tsx
+++ b/apps/native/components/site/AppSettings.tsx
@@ -1,15 +1,10 @@
"use client";
-import ActionMenu from "../primitives/ActionMenu";
-import { IconSettingsGear1 } from "@/lib/icons";
import { ThemeToggle } from "./ThemeToggle";
-import DesktopSettings from "./DesktopSettings";
import McpServers from "./McpServers";
export default function AppSettings({ sidebar = false }: { sidebar?: boolean }) {
- return <ActionMenu label="Settings" text={<IconSettingsGear1 size={16} />}
- className={sidebar ? "mx-2 flex shrink-0 justify-end border-t border-line pt-2 [&>button]:size-8 [&>button]:p-0" : "shrink-0"}>
- <ThemeToggle labeled />
- <DesktopSettings labeled />
- <McpServers labeled />
- </ActionMenu>;
+ return <span className={sidebar ? "mx-2 flex shrink-0 items-center justify-end gap-1 border-t border-line pt-2" : "flex shrink-0 items-center"}>
+ <ThemeToggle gear />
+ <McpServers />
+ </span>;
}
diff --git a/apps/native/components/site/DesktopSettings.tsx b/apps/native/components/site/DesktopSettings.tsx
index 4fb7e958..1b39329c 100644
--- a/apps/native/components/site/DesktopSettings.tsx
+++ b/apps/native/components/site/DesktopSettings.tsx
@@ -4,7 +4,7 @@ import { createPortal } from "react-dom";
import { restoreActionFocus } from "../primitives/ActionMenu";
import { desktop, type LinkDestination } from "@/lib/desktop";
-export default function DesktopSettings({ labeled = false }: { labeled?: boolean }) {
+export default function DesktopSettings({ labeled = false, embedded = false }: { labeled?: boolean; embedded?: boolean }) {
const [available, setAvailable] = useState(false);
const [open, setOpen] = useState(false);
const [destination, setDestination] = useState<LinkDestination | null>(null);
@@ -13,6 +13,13 @@ export default function DesktopSettings({ labeled = false }: { labeled?: boolean
const trigger = useRef<HTMLButtonElement>(null);
const panel = useRef<HTMLDivElement>(null);
useEffect(() => setAvailable(!!desktop()?.linkSettings), []);
+ useEffect(() => {
+ if (!embedded) return;
+ let alive = true;
+ void desktop()?.linkSettings?.("load").then(value => { if (alive) setDestination(value); })
+ .catch(() => { if (alive) setError("Could not load link settings."); });
+ return () => { alive = false; };
+ }, [embedded]);
useEffect(() => {
if (!open) return;
let alive = true;
@@ -40,16 +47,7 @@ export default function DesktopSettings({ labeled = false }: { labeled?: boolean
finally { setSaving(false); }
};
if (!available) return null;
- return <>
- <button ref={trigger} aria-label={labeled ? "Link settings" : "Settings"} title="Settings" aria-haspopup="dialog" aria-expanded={open}
- onClick={() => setOpen(value => !value)} className="flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3 hover:bg-hover hover:text-ink">
- {labeled ? "Link settings" : <svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><path d="m9 3-1 3-3 1 1 3-2 2 2 2-1 3 3 1 1 3h6l1-3 3-1-1-3 2-2-2-2 1-3-3-1-1-3Z"/><circle cx="12" cy="12" r="3"/></svg>}
- </button>
- {open && createPortal(<div className="fixed inset-0 z-[200] flex items-center justify-center bg-black/20 p-4" onPointerDown={event => {
- if (event.target === event.currentTarget) { setOpen(false); restoreActionFocus(trigger.current); }
- }}>
- <div ref={panel} role="dialog" aria-label="Settings" aria-modal="true" className="w-[380px] max-w-full rounded-xl border border-line bg-surface p-4 shadow-overlay">
- <div className="mb-4 flex items-center justify-between"><strong className="text-sm font-medium">Settings</strong><button aria-label="Close settings" onClick={() => { setOpen(false); restoreActionFocus(trigger.current); }} className="rounded px-1.5 text-ink-3 hover:bg-hover">×</button></div>
+ const fields = <>
<fieldset disabled={destination === null || saving}>
<legend className="mb-1 text-xs font-medium">Open web links in</legend>
<p className="mb-3 text-xs text-ink-3">Choose where links from conversations open. Graff keeps pages beside your chat.</p>
@@ -59,6 +57,19 @@ export default function DesktopSettings({ labeled = false }: { labeled?: boolean
</fieldset>
{saving && <p role="status" className="mt-3 text-xs text-ink-3">Saving…</p>}
{error && <p role="alert" className="mt-3 text-xs text-red">{error}</p>}
+ </>;
+ if (embedded) return <div className="mt-3 border-t border-line pt-3">{fields}</div>;
+ return <>
+ <button ref={trigger} aria-label={labeled ? "Link settings" : "Settings"} title="Settings" aria-haspopup="dialog" aria-expanded={open}
+ onClick={() => setOpen(value => !value)} className={labeled ? "flex w-full items-center rounded-md px-3 py-2 text-left text-xs hover:bg-hover" : "flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3 hover:bg-hover hover:text-ink"}>
+ {labeled ? "Link settings" : <svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><path d="m9 3-1 3-3 1 1 3-2 2 2 2-1 3 3 1 1 3h6l1-3 3-1-1-3 2-2-2-2 1-3-3-1-1-3Z"/><circle cx="12" cy="12" r="3"/></svg>}
+ </button>
+ {open && createPortal(<div className="fixed inset-0 z-[200] flex items-center justify-center bg-black/20 p-4" onPointerDown={event => {
+ if (event.target === event.currentTarget) { setOpen(false); restoreActionFocus(trigger.current); }
+ }}>
+ <div ref={panel} role="dialog" aria-label="Settings" aria-modal="true" className="w-[380px] max-w-full rounded-xl border border-line bg-surface p-4 shadow-overlay">
+ <div className="mb-4 flex items-center justify-between"><strong className="text-sm font-medium">Settings</strong><button aria-label="Close settings" onClick={() => { setOpen(false); restoreActionFocus(trigger.current); }} className="rounded px-1.5 text-ink-3 hover:bg-hover">×</button></div>
+ {fields}
</div>
</div>, document.body)}
</>;
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsx
index 8a990c20..92f67e07 100644
--- a/apps/native/components/site/GraffHarness.tsx
+++ b/apps/native/components/site/GraffHarness.tsx
@@ -189,6 +189,14 @@ export default function GraffHarness() {
setFilesOpen(true);
setFileRequest({ path: "", n: (fileReqRef.current += 1), changes: true });
}, []);
+ const toggleChanges = useCallback(() => {
+ if (filesOpen && fileRequest?.changes) {
+ setFilesOpen(false);
+ setFileRequest(null);
+ return;
+ }
+ openChanges();
+ }, [filesOpen, fileRequest, openChanges]);
const changeModel = (key: string, forChat?: number) => {
// New tabs inherit the pick; the tab respawns its agent with it
@@ -269,12 +277,20 @@ export default function GraffHarness() {
const tabDrag = useTabDrag((id, drop) => {
if (drop.kind === "tab") { setChats(current => reorderChatGroups(current, groups.groups, id, drop.id, drop.after)); return; }
if (!chatsRef.current.some(chat => chat.id === id)) return;
- const source = groups.groups.find(group => group.ids.includes(id))?.ids ?? [id];
+ let sourceId = id;
+ const sourceGroup = groups.groups.find(group => group.ids.includes(id));
+ const targetGroup = groups.groups.find(group => group.ids.includes(drop.id));
+ if (id === drop.id || (sourceGroup && targetGroup && sourceGroup === targetGroup)) {
+ if (splitLimitReached(columnIds.length)) { setSplitNotice(SPLIT_LIMIT_MESSAGE); return; }
+ sourceId = (chatIdRef.current += 1);
+ openChat(sourceId);
+ }
+ const source = groups.groups.find(group => group.ids.includes(sourceId))?.ids ?? [sourceId];
const next = mergeChatGroups(columnIds, source, drop.id, drop.edge === "right" || drop.edge === "bottom");
- if (!next) { if (!source.some(id => columnIds.includes(id)) && columnIds.length + source.length > MAX_COLUMNS) setSplitNotice(SPLIT_LIMIT_MESSAGE); return; }
+ if (!next) { if (!source.some(pane => columnIds.includes(pane)) && columnIds.length + source.length > MAX_COLUMNS) setSplitNotice(SPLIT_LIMIT_MESSAGE); return; }
setSplitNotice(null); setZoomedPane(null);
- groups.split(id,drop.id,drop.edge); setActiveId(id);
- const folder = chatsRef.current.find(chat => chat.id === id)?.cwd;
+ groups.split(sourceId, drop.id, drop.edge); setActiveId(sourceId);
+ const folder = chatsRef.current.find(chat => chat.id === sourceId)?.cwd;
if (folder && folder !== activePathRef.current) activateWorkspace(folder);
});
@@ -404,7 +420,7 @@ export default function GraffHarness() {
});
const columnBody = (thread: Chat) => <ChatColumn key={thread.id} thread={thread}
- compact={columnIds.length > 1 || navigation.focusedMode} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}
+ compact={columnIds.length > 1 || navigation.focusedMode || filesOpen || browserOpen || agentsOpen} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}
onOpenPath={openPath} onReview={openChanges}
onRefresh={loaded => {
const messages: Msg[] = loaded.messages.map(m => ({ id: ++msgIdRef.current, ...m }));
@@ -461,7 +477,6 @@ export default function GraffHarness() {
<div {...navigation.panelProps}><SidebarNav
onCloseNavigation={navigation.close} onCollapsedChange={navigation.onCollapsedChange}
openSessions={navigation.sidebarVisible && <div className="mb-4">
- <button type="button" aria-label="Show agents" aria-pressed={agentsOpen} onClick={() => { setProjectsOpen(false); setAgentsOpen(!agentsOpen); setFilesOpen(false); setBrowserOpen(false); setConversationsOpen(false); }} className="mx-3 mb-2 rounded-md px-2 py-1 text-[13px] text-ink-2 hover:bg-hover">Agents{workingAgents ? ` (${workingAgents})` : ""}</button>
<p className="mb-1 px-4 text-[11px] font-medium text-ink-3">Open chats</p>
<SessionTabs vertical chats={groups.tabs} activeId={groups.activeTab} agentsOpen={agentsOpen}
busyIds={new Set(groups.groups.filter(group => group.ids.some(id => busyIds.has(id))).map(group => group.ids[0]))} unreadIds={unread}
@@ -476,9 +491,14 @@ export default function GraffHarness() {
onPick={pickRecent}
onNewChat={newChat}
onSeeAll={openConversations}
- activeNav={projectsOpen ? "projects" : filesOpen ? (fileRequest?.changes ? "changes" : "workspace") : browserOpen ? "browser" : conversationsOpen ? "conversations" : "home"}
+ activeNav={agentsOpen ? "agents" : projectsOpen ? "projects" : filesOpen ? (fileRequest?.changes ? "changes" : "workspace") : browserOpen ? "browser" : conversationsOpen ? "conversations" : "home"}
onNavigate={(key) => {
if (key === "home") requestPromptFocus(activeId);
+ if (key === "agents") {
+ setProjectsOpen(false); setFilesOpen(false); setBrowserOpen(false); setConversationsOpen(false);
+ setAgentsOpen(open => !open);
+ return;
+ }
setAgentsOpen(false);
setProjectsOpen(key === "projects");
if (key === "changes") { openChanges(); return; }
@@ -502,7 +522,7 @@ export default function GraffHarness() {
<HarnessChrome sidebarVisible={navigation.sidebarVisible} navigationToggle={navigation.trigger} unreadIds={unread} onTabPointerDown={tabDrag.begin} onTabClickCapture={tabDrag.suppressClick} chats={groups.tabs} activeId={groups.activeTab} busyIds={new Set(groups.groups.filter(group => group.ids.some(id => busyIds.has(id))).map(group => group.ids[0]))} focusChat={id => focusChat(groups.focusOf(id))} closeChat={closeTab} newChat={newChat}
conversationsOpen={conversationsOpen} openConversations={openConversations} split={panes.length > 0} toggleSplit={toggleSplit}
filesOpen={filesOpen} onFiles={() => { setAgentsOpen(false); setFileRequest(null); setProjectsOpen(false); setBrowserOpen(false); setConversationsOpen(false); setFilesOpen(fileRequest?.changes ? true : !filesOpen); }}
- chatCwd={chatCwd} workspaceName={workspaceName} onFolder={() => setDialog({ mode: "new" })} openChanges={openChanges}
+ chatCwd={chatCwd} workspaceName={workspaceName} onFolder={() => setDialog({ mode: "new" })} openChanges={toggleChanges} changesOpen={!!(filesOpen && fileRequest?.changes)}
browserOpen={browserOpen} onBrowser={() => { setAgentsOpen(false); setProjectsOpen(false); setConversationsOpen(false); setFilesOpen(false); setBrowserOpen(open => !open); }} pinCount={pinCount}
terminalVisible={terminalVisible} toggleTerminal={toggleTerminal} agentsOpen={agentsOpen}
workingAgents={workingAgents}
diff --git a/apps/native/components/site/HarnessChrome.tsx b/apps/native/components/site/HarnessChrome.tsx
index 79df3948..40289241 100644
--- a/apps/native/components/site/HarnessChrome.tsx
+++ b/apps/native/components/site/HarnessChrome.tsx
@@ -5,6 +5,7 @@ import AppSettings from "./AppSettings";
import type { PointerEvent, MouseEvent, ReactNode } from "react";
import type { Chat } from "./harness-types";
import reviewStyles from "./ChangesPane.module.css";
+
type Props = {
navigationToggle?: ReactNode; sidebarVisible?: boolean;
unreadIds?: ReadonlySet<number>;
@@ -13,21 +14,26 @@ type Props = {
focusChat(id: number): void; closeChat(id: number): void; newChat(): void;
conversationsOpen: boolean; openConversations(): void; split: boolean; toggleSplit(): void;
filesOpen: boolean; onFiles(): void; chatCwd?: string; workspaceName: string; onFolder(): void;
- openChanges(): void; browserOpen: boolean; onBrowser(): void; pinCount: number;
+ openChanges(): void; changesOpen?: boolean; browserOpen: boolean; onBrowser(): void; pinCount: number;
terminalVisible: boolean; toggleTerminal(): void; agentsOpen: boolean; onAgents(): void; workingAgents?: number;
tasksOpen?: boolean; taskCount?: number; onTasks?: () => void; splitNotice?: string | null;
};
+
+function paneBtn(pressed: boolean) {
+ return `h-7 shrink-0 rounded-[7px] px-2.5 text-[12.5px] font-medium ${pressed ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover"}`;
+}
+
export default function HarnessChrome({navigationToggle, sidebarVisible = false, unreadIds, chats, activeId, busyIds, focusChat, closeChat, newChat,
conversationsOpen, openConversations, split, toggleSplit, filesOpen, onFiles, chatCwd,
- workspaceName, onFolder, openChanges, browserOpen, onBrowser, pinCount, terminalVisible,
+ workspaceName, onFolder, openChanges, changesOpen = false, browserOpen, onBrowser, pinCount, terminalVisible,
toggleTerminal, agentsOpen, onAgents, workingAgents = 0, tasksOpen = false, taskCount = 0, onTasks, splitNotice, onTabPointerDown, onTabClickCapture}: Props) {
return (
- <div data-workspace-toolbar className={`${reviewStyles.chatbar} flex shrink-0 flex-col overflow-hidden rounded-[14px] border border-line bg-page`}>
+ <div data-workspace-toolbar className={`${reviewStyles.chatbar} flex shrink-0 flex-col ${sidebarVisible ? "overflow-visible bg-transparent" : "overflow-hidden rounded-[14px] border border-line bg-page"}`}>
{/* One workspace-level tab strip above every split; never owned by a pane. */}
<div data-session-tab-strip hidden={sidebarVisible} className={sidebarVisible ? "hidden" : "flex h-10 min-w-0 shrink-0 items-center gap-1 px-2"}>
<div className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
<button type="button" aria-label="Show agents" aria-pressed={agentsOpen} onClick={onAgents}
- className={`h-7 shrink-0 rounded-[7px] px-3 text-[12.5px] font-medium ${agentsOpen ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover"}`}>Agents{workingAgents > 0 ? ` (${workingAgents})` : ""}</button>
+ className={paneBtn(agentsOpen)}>Agents{workingAgents > 0 ? ` (${workingAgents})` : ""}</button>
<span aria-hidden="true" className="mx-1 h-4 w-px shrink-0 bg-line" />
{!sidebarVisible && <SessionTabs chats={chats} activeId={activeId} busyIds={busyIds} unreadIds={unreadIds}
agentsOpen={agentsOpen} focusChat={focusChat} closeChat={closeChat}
@@ -45,29 +51,27 @@ export default function HarnessChrome({navigationToggle, sidebarVisible = false,
</button>
</div>
</div>
- <div className={`${reviewStyles.actions} flex min-h-10 shrink-0 items-center gap-2 ${sidebarVisible ? "" : "border-t border-line"} px-3 py-1`}>
+ <div className={`${reviewStyles.actions} flex min-h-10 shrink-0 items-center gap-1 ${sidebarVisible ? "justify-end px-1" : "border-t border-line px-2"} py-1`}>
{navigationToggle}
- <button type="button" aria-pressed={filesOpen} onClick={onFiles} title={`${chatCwd ?? "Workspace"}\nShow this chat's files`}
- className="max-w-48 truncate lg:hidden rounded-md px-2 py-1 text-xs font-medium text-ink-2 hover:bg-hover">{workspaceName}</button>
- <button type="button" onClick={openChanges} aria-label="Review workspace changes" className="rounded-md px-2 py-1 text-xs text-ink-2 hover:bg-hover">Changes</button>
- {(taskCount > 0 || tasksOpen) && onTasks && <button type="button" aria-label="Show tasks" aria-pressed={tasksOpen} onClick={onTasks} className="rounded-md px-2 py-1 text-xs text-ink-2 hover:bg-hover">Tasks{taskCount ? ` (${taskCount})` : ""}</button>}
- <ActionMenu label="Workspace tools" text="Tools" wide className="ml-auto shrink-0">
- <p className="px-3 py-2 text-[11px] font-medium text-ink-3">Tools for this workspace</p>
- <button type="button" aria-label="Files" aria-pressed={filesOpen} onClick={onFiles}><span>Files<span className="mt-1 block text-ink-3">Explore the current project folder</span></span></button>
- <button type="button" aria-label="Browser" aria-pressed={browserOpen} onClick={onBrowser}><span>Browser{pinCount > 0 ? ` (${pinCount} pins)` : ""}<span className="mt-1 block text-ink-3">Keep a web page beside your conversation</span></span></button>
- <button type="button" aria-label="Toggle terminal" aria-pressed={terminalVisible} onClick={toggleTerminal}><span>Terminal<span className="mt-1 block text-ink-3">Run commands in this workspace · ⌘J</span></span></button>
- <button type="button" onClick={onFolder}><span>Open a folder…<span className="mt-1 block text-ink-3">Choose another workspace</span></span></button>
- </ActionMenu>
+ <button type="button" aria-pressed={filesOpen && !changesOpen} onClick={onFiles} title={`${chatCwd ?? "Workspace"}\nShow this chat's files`}
+ className={`max-w-48 truncate lg:hidden ${paneBtn(filesOpen && !changesOpen)}`}>{workspaceName}</button>
+ <div className={`flex items-center gap-1 ${sidebarVisible ? "rounded-[14px] border border-line bg-page px-2 py-0.5" : ""}`}>
+ <button type="button" aria-label="Files" aria-pressed={filesOpen && !changesOpen} onClick={onFiles} className={`hidden lg:inline-flex ${paneBtn(filesOpen && !changesOpen)}`}>Files</button>
+ <button type="button" aria-label="Review workspace changes" aria-pressed={changesOpen} onClick={openChanges} className={paneBtn(changesOpen)}>Changes</button>
+ <button type="button" aria-label="Browser" aria-pressed={browserOpen} onClick={onBrowser} className={paneBtn(browserOpen)}>Browser{pinCount > 0 ? ` (${pinCount})` : ""}</button>
+ <button type="button" aria-label="Toggle terminal" aria-pressed={terminalVisible} onClick={toggleTerminal} className={paneBtn(terminalVisible)}>Terminal</button>
+ {(taskCount > 0 || tasksOpen) && onTasks && <button type="button" aria-label="Show tasks" aria-pressed={tasksOpen} onClick={onTasks} className={paneBtn(tasksOpen)}>Tasks{taskCount ? ` (${taskCount})` : ""}</button>}
<ActionMenu label="Chat actions" text="More" className="shrink-0">
<button type="button" onClick={newChat}>New chat <span className="ml-auto text-ink-3">⌘T</span></button>
<button type="button" aria-pressed={split} onClick={toggleSplit}>{split ? "Close splits" : "Split view"} <span className="ml-auto text-ink-3">⌘\</span></button>
<button type="button" aria-pressed={conversationsOpen} onClick={openConversations}>All conversations</button>
+ <button type="button" onClick={onFolder}>Open a folder…</button>
</ActionMenu>
{!sidebarVisible && <AppSettings />}
<div data-desktop-update-slot className="shrink-0" />
+ </div>
</div>
{splitNotice && <p role="status" data-split-limit className="border-t border-line px-3 py-1.5 text-[12px] text-ink-2">{splitNotice}</p>}
</div>
);
-
}
diff --git a/apps/native/components/site/SessionTabs.tsx b/apps/native/components/site/SessionTabs.tsx
index 8b0b76d1..ed7a1c23 100644
--- a/apps/native/components/site/SessionTabs.tsx
+++ b/apps/native/components/site/SessionTabs.tsx
@@ -47,10 +47,10 @@ export default function SessionTabs({ chats, activeId, busyIds, unreadIds, agent
onClick={() => {
focusChat(c.id);
}}
- title={c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "New chat")}
+ title={c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "Chat")}
className="min-w-0 flex-1 text-left"
>
- <span className="block truncate">{c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "New chat")}</span>
+ <span className="block truncate">{c.title ?? (chats.length > 1 ? `Chat ${c.id}` : "Chat")}</span>
</button>
<button
type="button"
diff --git a/apps/native/components/site/ThemeToggle.tsx b/apps/native/components/site/ThemeToggle.tsx
index 45763d98..44840cbf 100644
--- a/apps/native/components/site/ThemeToggle.tsx
+++ b/apps/native/components/site/ThemeToggle.tsx
@@ -4,6 +4,9 @@ import { createPortal } from "react-dom";
import { restoreActionFocus } from "../primitives/ActionMenu";
import CustomThemes from "./CustomThemes";
import { appearanceEvent, appearanceKey, applyAppearance, readAppearance, type Appearance } from "@/lib/appearance";
+import { placeAnchoredPanel } from "@/lib/anchored-panel";
+import DesktopSettings from "./DesktopSettings";
+import { IconSettingsGear1 } from "@/lib/icons";
const themes = [
{ id: "codegraff", name: "CodeGraff", detail: "Official · Japanese palette", bg: "#f6eedf", surface: "#fffaf0", ink: "#1b1714", accent: "#2654d9" },
@@ -12,9 +15,9 @@ const themes = [
{ id: "website", name: "Website", detail: "CodeGraff emerald", bg: "#fafaf8", surface: "#ffffff", ink: "#18231e", accent: "#059669" },
] as const;
-export function ThemeToggle({ labeled = false }: { labeled?: boolean }) {
+export function ThemeToggle({ labeled = false, gear = false }: { labeled?: boolean; gear?: boolean }) {
const [theme, setTheme] = useState<Appearance>("dark");
- const [position, setPosition] = useState<{ top: number; right: number } | null>(null);
+ const [position, setPosition] = useState<{ top: number; left: number } | null>(null);
const trigger = useRef<HTMLButtonElement>(null);
const panel = useRef<HTMLDivElement>(null);
useEffect(() => {
@@ -47,19 +50,22 @@ export function ThemeToggle({ labeled = false }: { labeled?: boolean }) {
requestAnimationFrame(() => requestAnimationFrame(() => document.documentElement.classList.remove("theme-switching")));
};
return <>
- <button ref={trigger} aria-label="Appearance" title="Appearance" aria-haspopup="dialog" aria-expanded={!!position} onClick={() => {
+ <button ref={trigger} aria-label="Appearance" title={gear ? "Settings" : "Appearance"} aria-haspopup="dialog" aria-expanded={!!position} onClick={() => {
const rect = trigger.current!.getBoundingClientRect();
- setPosition(position ? null : { top: Math.max(48, Math.min(rect.bottom + 8, window.innerHeight - 420)), right: Math.max(8, window.innerWidth - rect.right) });
- }} className="flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3 hover:bg-hover hover:text-ink">
- {labeled ? "Appearance" : <svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><circle cx="12" cy="12" r="8" /><path d="M12 4a8 8 0 0 1 0 16Z" fill="currentColor" stroke="none" /></svg>}
+ setPosition(position ? null : placeAnchoredPanel(rect, { width: window.innerWidth, height: window.innerHeight }));
+ }} className={labeled ? "flex w-full items-center rounded-md px-3 py-2 text-left text-xs hover:bg-hover" : "flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3 hover:bg-hover hover:text-ink"}>
+ {labeled ? "Appearance" : gear ? <IconSettingsGear1 size={16} /> : <svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><circle cx="12" cy="12" r="8" /><path d="M12 4a8 8 0 0 1 0 16Z" fill="currentColor" stroke="none" /></svg>}
</button>
- {position && createPortal(<div ref={panel} role="dialog" aria-label="Appearance" aria-modal="true" className="fixed z-[200] w-[310px] max-w-[calc(100vw-16px)] overflow-y-auto rounded-xl border border-line bg-surface p-3 shadow-overlay" style={{ ...position, maxHeight: `calc(100dvh - ${position.top + 12}px)` }}>
- <div className="mb-3 flex items-center justify-between"><strong className="text-xs font-medium">Appearance</strong><button aria-label="Close appearance" onClick={() => { setPosition(null); restoreActionFocus(trigger.current); }} className="rounded px-1.5 text-ink-3 hover:bg-hover">×</button></div>
+ {position && createPortal(<div ref={panel} role="dialog" aria-label="Appearance" aria-modal="true" className="fixed z-[200] flex w-[310px] max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-xl border border-line bg-surface p-3 shadow-overlay" style={{ ...position, maxHeight: `calc(100dvh - ${position.top + 12}px)` }}>
+ <div className="mb-3 flex shrink-0 items-center justify-between"><strong className="text-xs font-medium">Appearance</strong><button aria-label="Close appearance" onClick={() => { setPosition(null); restoreActionFocus(trigger.current); }} className="rounded px-1.5 text-ink-3 hover:bg-hover">×</button></div>
+ <div className="min-h-0 overflow-y-auto">
<div className="grid grid-cols-2 gap-2">{themes.map(option => <button key={option.id} aria-pressed={theme === option.id} onClick={() => choose(option.id)} className={`rounded-lg border p-1.5 text-left focus-visible:outline-2 focus-visible:outline-accent ${theme === option.id ? "border-accent bg-accent-tint" : "border-line hover:bg-hover"}`}>
<span aria-hidden="true" className="mb-2 flex h-14 gap-1 overflow-hidden rounded p-1.5" style={{ background: option.bg }}><span className="w-3 rounded-sm" style={{ background: option.id === "codegraff" ? "#d45a43" : option.accent, opacity: .35 }} /><span className="flex flex-1 flex-col gap-1 rounded p-1" style={{ background: option.surface }}><span className="h-1 w-5 rounded" style={{ background: option.ink, opacity: .45 }} /><span className="h-1 w-8 rounded" style={{ background: option.ink, opacity: .15 }} /><span className="mt-auto h-1.5 w-4 rounded" style={{ background: option.accent }} /></span></span>
<span className="block text-[11px] font-medium text-ink">{option.name}</span><span className="block text-[9px] leading-4 text-ink-3">{option.detail}</span>
</button>)}</div>
<CustomThemes selected={theme} />
+ <DesktopSettings embedded />
+ </div>
</div>, document.body)}
</>;
}
diff --git a/apps/native/components/site/useChatGroups.ts b/apps/native/components/site/useChatGroups.ts
index 64efda12..73da414d 100644
--- a/apps/native/components/site/useChatGroups.ts
+++ b/apps/native/components/site/useChatGroups.ts
@@ -24,7 +24,7 @@ export function useChatGroups(chats: Chat[], activeId: number) {
});
const tabs = useMemo(() => groups.map(group => ({
id: group.ids[0], paneIds: group.ids, direction: group.direction, tree: group.tree,
- title: group.ids.map(id => chats.find(chat => chat.id === id)?.title ?? (chats.length > 1 ? `Chat ${id}` : 'New chat')).join(' / '),
+ title: group.ids.map(id => chats.find(chat => chat.id === id)?.title ?? (chats.length > 1 ? `Chat ${id}` : 'Chat')).join(' / '),
})), [groups,titleKey]);
const updateTree = (apply: (tree: SplitTree) => SplitTree) => setLayouts(old => {
const group=old.find(group=>group.ids.includes(activeId));
diff --git a/apps/native/components/site/useDesktopShortcuts.ts b/apps/native/components/site/useDesktopShortcuts.ts
index a47fedba..d429cfa2 100644
--- a/apps/native/components/site/useDesktopShortcuts.ts
+++ b/apps/native/components/site/useDesktopShortcuts.ts
@@ -10,6 +10,12 @@ type Actions = {
export function useDesktopShortcuts(actions: Actions) {
const ref=useRef(actions);ref.current=actions;
useEffect(()=>{
+ const focusPrompt=(id:number)=>{
+ const prompt=document.querySelector<HTMLTextAreaElement>(`[data-chat="${id}"] textarea[aria-label="Prompt"]`);
+ if(!prompt||!prompt.getClientRects().length)return false;
+ prompt.focus({preventScroll:true});
+ return true;
+ };
const dispatch=(action:string)=>{
// Native menu accelerators reach this path without a DOM keydown.
if(document.querySelector('[role="dialog"]'))return false;
@@ -25,6 +31,7 @@ export function useDesktopShortcuts(actions: Actions) {
case 'split-zoom':a.zoomPane();return true;
case 'terminal':a.toggleTerminal();return true;
case 'workspace':a.openWorkspace();return true;
+ case 'focus-prompt':return focusPrompt(a.activeId);
}
return false;
};
@@ -50,6 +57,7 @@ export function useDesktopShortcuts(actions: Actions) {
else if(e.altKey&&k.startsWith('arrow')){cycle(a.columns,k==='arrowleft'||k==='arrowup'?-1:1);handled=true;}
else if(!e.altKey){
if(k==='j'&&!e.shiftKey)handled=dispatch('terminal');
+ else if(k==='l'&&!e.shiftKey)handled=dispatch('focus-prompt');
else if(k==='n'&&!e.shiftKey)handled=dispatch('new');
else if(k==='t')handled=dispatch(e.shiftKey?'reopen':'new');
else if(k==='w'&&!e.shiftKey)handled=dispatch('close');
diff --git a/apps/native/components/site/useTabDrag.tsx b/apps/native/components/site/useTabDrag.tsx
index 966aa7a4..7f9ee772 100644
--- a/apps/native/components/site/useTabDrag.tsx
+++ b/apps/native/components/site/useTabDrag.tsx
@@ -51,7 +51,7 @@ export function useTabDrag(onDrop: (id: number, drop: TabDrop) => void) {
return { drop: { kind: "tab", id: Number(tab.dataset.tabId), after }, left: after ? r.right - 2 : r.left, top: r.top, width: 3, height: r.height, label: "Move tab" };
}
const pane = element?.closest<HTMLElement>('[data-chat]');
- if (!pane || Number(pane.dataset.chat) === id) return null;
+ if (!pane) return null;
const r = pane.getBoundingClientRect();
const sides = [
{ edge: "left" as const, distance: (x - r.left) / r.width, horizontal: true },
diff --git a/apps/native/electron/browser-focus-frontend.cjs b/apps/native/electron/browser-focus-frontend.cjs
index 3729cba5..3314adbb 100644
--- a/apps/native/electron/browser-focus-frontend.cjs
+++ b/apps/native/electron/browser-focus-frontend.cjs
@@ -29,14 +29,14 @@ async function runBrowserFocus({ win, output, click, until, report }) {
await until(() => browser.visible && browser.tabs.get(browser.visible)?.view?.webContents.getURL() === url, 'explicit address navigation');
};
const a = await focused();
- await click('[aria-label="Workspace tools"]'); await click('[aria-label="Browser"]');
+ await click('[aria-label="Browser"]');
await navigateUser(`${origin}/first`);
const chatA = browser.visible;
await js(`Array.from(document.querySelectorAll('button[aria-label="New chat"]')).find(e=>e.checkVisibility()).setAttribute('data-browser-new-chat','true')`);
await click('[data-browser-new-chat="true"]');
await until(async () => (await focused()) !== a && browser.visible !== chatA, 'second chat');
if (!await js(`!!document.querySelector('[aria-label="Address"]')?.checkVisibility()`)) {
- await click('[aria-label="Workspace tools"]'); await click('[aria-label="Browser"]');
+ await click('[aria-label="Browser"]');
}
await navigateUser(`${origin}/selected`);
const b = await focused(), chatB = browser.visible;
diff --git a/apps/native/electron/link-destination-visual.cjs b/apps/native/electron/link-destination-visual.cjs
index f73c0c6f..e30fce6a 100644
--- a/apps/native/electron/link-destination-visual.cjs
+++ b/apps/native/electron/link-destination-visual.cjs
@@ -74,7 +74,7 @@ async function runLinkDestinationVisuals({ origin, output }) {
throw Error(`Link destination timeout: ${label || test}`);
};
const click = selector => js(`document.querySelector(${JSON.stringify(selector)}).click()`);
- const dialog = '[role="dialog"][aria-label="Settings"][aria-modal="true"]';
+ const dialog = '[role="dialog"][aria-label="Appearance"][aria-modal="true"]';
const labels = { system: 'System default browser', graff: 'Graff built-in Browser' };
const option = choice => `Array.from(document.querySelectorAll('${dialog} button')).find(b=>b.textContent.trim()===${JSON.stringify(labels[choice])})`;
const selected = async choice => {
@@ -82,14 +82,12 @@ async function runLinkDestinationVisuals({ origin, output }) {
assert.equal(await js(`${option(choice === 'system' ? 'graff' : 'system')}?.getAttribute('aria-pressed')`), 'false');
};
const openSettings = async () => {
- await wait(`!!document.querySelector('[aria-label="Settings"]')`, 'Settings hydrated');
- await click('button[aria-label="Settings"]');
- await wait(`!!document.querySelector('[role="dialog"] button[aria-label="Link settings"]')`);
- await click('[role="dialog"] button[aria-label="Link settings"]');
+ await wait(`!!document.querySelector('[aria-label="Appearance"]')`, 'Settings hydrated');
+ await click('button[aria-label="Appearance"]');
await wait(`!!document.querySelector('${dialog}')`);
await wait(() => browser.overlay === true, 'settings hide the native browser view');
};
- const closeSettings = async () => { await click('[aria-label="Close settings"]'); await wait(`!document.querySelector('${dialog}')`); await wait(() => browser.overlay === false, 'closing settings releases the overlay'); };
+ const closeSettings = async () => { await click('[aria-label="Close appearance"]'); await wait(`!document.querySelector('${dialog}')`); await wait(() => browser.overlay === false, 'closing settings releases the overlay'); };
const choose = async choice => {
const before = settings.filter(s => s.action === 'save').length;
await wait(`${option(choice)} && !${option(choice)}.matches(':disabled')`, 'preference loaded and ready to change');
diff --git a/apps/native/electron/main.cjs b/apps/native/electron/main.cjs
index 000cb3e7..c7ef86ec 100644
--- a/apps/native/electron/main.cjs
+++ b/apps/native/electron/main.cjs
@@ -176,7 +176,7 @@ app.whenReady().then(async () => {
{ label: 'File', submenu: [
['New chat', 'CmdOrCtrl+N', 'new'], ['New tab', 'CmdOrCtrl+T', 'new'],
['Close chat', 'CmdOrCtrl+W', 'close'], ['Reopen closed chat', 'CmdOrCtrl+Shift+T', 'reopen'],
- ['Toggle terminal', 'CmdOrCtrl+J', 'terminal'], ['Open workspace…', 'CmdOrCtrl+O', 'workspace'], ['Split right', 'CmdOrCtrl+D', 'split-right'],
+ ['Toggle terminal', 'CmdOrCtrl+J', 'terminal'], ['Focus prompt', 'CmdOrCtrl+L', 'focus-prompt'], ['Open workspace…', 'CmdOrCtrl+O', 'workspace'], ['Split right', 'CmdOrCtrl+D', 'split-right'],
['Split down', 'CmdOrCtrl+Shift+D', 'split-down'], ['Zoom split', 'CmdOrCtrl+Shift+Enter', 'split-zoom'],
].map(([label, accelerator, action]) => ({ label, accelerator, click: () => win.webContents.send('desktop-action', action) })) },
{ label: 'Tools', submenu: [{ label: 'Configure MCP clients…', enabled: app.isPackaged, click: async () => {
diff --git a/apps/native/electron/projects-visual.cjs b/apps/native/electron/projects-visual.cjs
index 53da82a5..f936b0f9 100644
--- a/apps/native/electron/projects-visual.cjs
+++ b/apps/native/electron/projects-visual.cjs
@@ -60,7 +60,6 @@ async function runProjectVisuals({ win, origin, output }) {
await js(`document.querySelector('button[aria-label="Review workspace changes"]').click()`);
await wait(`!!document.querySelector('[aria-label="Workspace changes"]')`);
await wait(`document.body.textContent.includes('palette.css')`);
- await js(`document.querySelector('button[aria-label="Workspace tools"]').click()`);
await wait(`!!document.querySelector('button[aria-label="Files"]')`);
await js(`document.querySelector('button[aria-label="Files"]').click()`);
await wait(`!!document.querySelector('[aria-label="Workspace files"]')`);
diff --git a/apps/native/electron/session-navigation-visual.cjs b/apps/native/electron/session-navigation-visual.cjs
index ca6fc6a0..387eaf16 100644
--- a/apps/native/electron/session-navigation-visual.cjs
+++ b/apps/native/electron/session-navigation-visual.cjs
@@ -23,6 +23,14 @@ async function runSessionNavigation({ win, output }) {
};
await wait(`!!document.querySelector('[data-session-navigation="sidebar"]')`);
assert.equal(await js(`document.querySelector('[data-session-tab-strip]').getBoundingClientRect().height`),0);
+ await click('[aria-label="Workspace navigation"] button[aria-label="Appearance"]');
+ await wait(`!!document.querySelector('[role="dialog"][aria-label="Appearance"]')`);
+ const appearance = await js(`(()=>{const d=document.querySelector('[role="dialog"][aria-label="Appearance"]');const r=d.getBoundingClientRect();const h=[...d.querySelectorAll('strong')].find(el=>el.textContent==='Appearance');const hr=h.getBoundingClientRect();return {left:r.left,right:r.right,top:r.top,headingTop:hr.top,headingVisible:hr.bottom>0&&hr.top<innerHeight,vw:innerWidth};})()`);
+ assert.ok(appearance.left >= 0, 'appearance stays on-screen from the sidebar gear');
+ assert.ok(appearance.right <= appearance.vw, 'appearance does not overflow the right edge');
+ assert.ok(appearance.headingVisible && appearance.headingTop >= appearance.top, 'Appearance heading stays visible');
+ await click('[aria-label="Close appearance"]');
+ await wait(`!document.querySelector('[role="dialog"][aria-label="Appearance"]')`);
await click('[aria-label="Workspace navigation"] button[aria-label="New chat"]');
const drafted = await active();
for (const keyCode of 'Keep this draft') await desktop.testInput(wc,{type:'char',keyCode});
@@ -45,10 +53,7 @@ async function runSessionNavigation({ win, output }) {
assert.equal(await active(),drafted);
assert.equal(await js(`document.querySelector('[data-chat="${drafted}"] textarea').value`),'Keep this draft');
assert.equal(await js(`!!document.querySelector('[data-chat-empty] h1')`),false,'focused mode keeps the empty composer compact');
- await click('[data-workspace-toolbar] button[aria-label="Settings"]');
- await wait(`!!document.querySelector(':popover-open')`);
- assert.ok(await js(`document.querySelector(':popover-open').textContent.includes('Appearance')`),'theme control remains available');
- await click(':popover-open button[aria-label="Appearance"]');
+ await click('[data-workspace-toolbar] button[aria-label="Appearance"]');
await wait(`!!document.querySelector('[role="dialog"][aria-label="Appearance"]')`);
await click('[aria-label="Close appearance"]');
await desktop.testInput(wc,{type:'keyDown',keyCode:'Escape'});
diff --git a/apps/native/lib/anchored-panel.test.ts b/apps/native/lib/anchored-panel.test.ts
new file mode 100644
index 00000000..f9cf3b9c
--- /dev/null
+++ b/apps/native/lib/anchored-panel.test.ts
@@ -0,0 +1,23 @@
+import { test, expect } from "bun:test";
+import { placeAnchoredPanel } from "./anchored-panel";
+
+const panel = { width: 310, height: 420 };
+
+test("sidebar gear opens the panel to the right instead of clipping left", () => {
+ const placed = placeAnchoredPanel({ left: 12, right: 44, top: 720, bottom: 752 }, { width: 1440, height: 800 }, panel);
+ expect(placed.left).toBeGreaterThanOrEqual(8);
+ expect(placed.left + panel.width).toBeLessThanOrEqual(1440 - 8);
+ expect(placed.left).toBe(52);
+});
+
+test("toolbar gear keeps the panel right-aligned when that still fits", () => {
+ const placed = placeAnchoredPanel({ left: 1360, right: 1392, top: 48, bottom: 80 }, { width: 1440, height: 800 }, panel);
+ expect(placed.left).toBe(1392 - 310);
+ expect(placed.left + panel.width).toBeLessThanOrEqual(1440 - 8);
+});
+
+test("a narrow window clamps the panel inside the viewport", () => {
+ const placed = placeAnchoredPanel({ left: 4, right: 36, top: 40, bottom: 72 }, { width: 320, height: 500 }, panel);
+ expect(placed.left).toBeGreaterThanOrEqual(8);
+ expect(placed.left + Math.min(panel.width, 320 - 16)).toBeLessThanOrEqual(320 - 8);
+});
diff --git a/apps/native/lib/anchored-panel.ts b/apps/native/lib/anchored-panel.ts
new file mode 100644
index 00000000..3ab356f7
--- /dev/null
+++ b/apps/native/lib/anchored-panel.ts
@@ -0,0 +1,17 @@
+/** Place a fixed panel next to a trigger without clipping the viewport. */
+export type Box = { left: number; right: number; top: number; bottom: number };
+export type Viewport = { width: number; height: number };
+
+export function placeAnchoredPanel(
+ trigger: Box,
+ viewport: Viewport,
+ panel: { width: number; height: number } = { width: 310, height: 420 },
+): { top: number; left: number } {
+ const margin = 8;
+ const width = Math.min(panel.width, Math.max(0, viewport.width - margin * 2));
+ let left = trigger.right - width;
+ if (left < margin) left = trigger.right + margin;
+ left = Math.max(margin, Math.min(left, viewport.width - width - margin));
+ const top = Math.max(48, Math.min(trigger.bottom + margin, viewport.height - panel.height));
+ return { top, left };
+}