graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(native): resizable browser pane and a clickable Chats header
justrach0713e796315b
diff --git a/apps/native/README.md b/apps/native/README.mdindex e17eccf2..36403973 100644--- a/apps/native/README.md+++ b/apps/native/README.md@@ -121,6 +121,9 @@ and the next request starts a fresh browser. Kuri is started withthan that flag refuses localhost.- **Browse** forwards clicks, scrolling and typing to the page.+- Drag the pane's left edge to resize it (double-click the edge for the+ default width, arrow keys when it has focus); the width is remembered+ and the page's viewport follows, so pins stay on their elements.- The address bar takes `localhost:3000`-style addresses; Cmd/Ctrl+Lfocuses it from the page. The width control next to it shows the pageat the pane's own width (1:1) or a wider layout (768, 1024, 1280 px)diff --git a/apps/native/components/primitives/SidebarNav.tsx b/apps/native/components/primitives/SidebarNav.tsxindex e25d88e3..1c291bae 100644--- a/apps/native/components/primitives/SidebarNav.tsx+++ b/apps/native/components/primitives/SidebarNav.tsx@@ -265,6 +265,8 @@ export default function SidebarNav({const [workspaceOpen, setWorkspaceOpen] = useState(false);const [workspacePosition, setWorkspacePosition] = useState({ top: 0, left: 0 });const [searchOpen, setSearchOpen] = useState(false);+ /** The Chats header collapses its list; searching always opens it again. */+ const [chatsOpen, setChatsOpen] = useState(true);const [query, setQuery] = useState("");const workspaceButtonRef = useRef<HTMLButtonElement>(null);const searchRef = useRef<HTMLInputElement>(null);@@ -396,20 +398,31 @@ export default function SidebarNav({<div className="mt-3 min-h-0 flex-1 overflow-y-auto"><div className="sidebar-copy relative mx-2 mb-1 h-8">- <div+ <button+ type="button"aria-hidden={searchOpen}- className={`absolute inset-0 flex items-center gap-1.5 px-2 text-[12.5px] font-medium text-ink-3 transition-[opacity,transform] ${searchOpen ? "pointer-events-none -translate-x-1 opacity-0" : "translate-x-0 opacity-100"}`}+ aria-expanded={chatsOpen}+ aria-controls="sidebar-chat-list"+ title={chatsOpen ? "Hide the chat list" : "Show the chat list"}+ onClick={() => setChatsOpen((open) => !open)}+ className={`absolute inset-y-0 left-0 flex items-center gap-1.5 rounded-[8px] px-2 text-[12.5px] font-medium text-ink-3 transition-[opacity,transform,background-color,color] hover:bg-hover-2 hover:text-ink ${searchOpen ? "pointer-events-none -translate-x-1 opacity-0" : "translate-x-0 opacity-100"}`}style={{ transitionDuration: `${CHAT_SEARCH_MOTION.duration}ms`, transitionTimingFunction: CHAT_SEARCH_MOTION.easing }}>- <IconChevronDownSmall size={16} />+ <span className={`flex transition-transform duration-150 ${chatsOpen ? "" : "-rotate-90"}`}>+ <IconChevronDownSmall size={16} />+ </span><span>Chats</span>- </div>+ {visibleRecents.length > 0 && <span className="tabular-nums text-ink-3">{visibleRecents.length}</span>}+ </button><buttontype="button"aria-label="Search chats"aria-expanded={searchOpen}- onClick={() => setSearchOpen(true)}+ onClick={() => {+ setSearchOpen(true);+ setChatsOpen(true);+ }}className={`absolute right-0 top-0 z-10 flex size-8 items-center justify-center rounded-[8px] text-ink-3 transition-[opacity,background-color,color,transform] hover:bg-hover-2 hover:text-ink active:scale-[0.96] ${searchOpen ? "pointer-events-none opacity-0" : "opacity-100"}`}style={{ transitionDuration: `${CHAT_SEARCH_MOTION.duration}ms` }}>@@ -455,6 +468,7 @@ export default function SidebarNav({</div></div>+ <div id="sidebar-chat-list" hidden={!chatsOpen}><GlideGroup>{visibleRecents.map((item, index) => {const active = activeId !== undefined ? item.id === activeId : item.label === selectedTitle;@@ -486,10 +500,13 @@ export default function SidebarNav({</Fragment>);})}- {query && visibleRecents.length === 0 && (- <div className="sidebar-copy mx-2 px-2 py-2 text-[12.5px] text-ink-3">No chats found</div>+ {visibleRecents.length === 0 && (+ <div className="sidebar-copy mx-2 px-2 py-2 text-[12.5px] text-ink-3">+ {query ? "No chats found" : "No chats yet — start one and it appears here."}+ </div>)}</GlideGroup>+ </div></div><div className="sidebar-copy mx-2 mt-3 w-[208px] border-t border-line pt-3">diff --git a/apps/native/components/site/BrowserPane.tsx b/apps/native/components/site/BrowserPane.tsxindex 576dee62..f34951e6 100644--- a/apps/native/components/site/BrowserPane.tsx+++ b/apps/native/components/site/BrowserPane.tsx@@ -55,6 +55,28 @@ type Preset = "fit" | 768 | 1024 | 1280;const PRESETS: readonly Preset[] = ["fit", 768, 1024, 1280];const PRESET_KEY = "graff.native.browser.width";const LAST_URL_KEY = "graff.native.browser.lastUrl";+const PANE_WIDTH_KEY = "graff.native.browser.paneWidth";++/** How wide the pane itself is. Wide enough to read, never so wide that the+ * chat beside it becomes a column of single words. */+const PANE_DEFAULT = 560;+const PANE_MIN = 380;+const PANE_CHAT_MIN = 520;++function clampPaneWidth(px: number): number {+ const room = typeof window === "undefined" ? 1440 : window.innerWidth;+ return Math.round(Math.min(Math.max(px, PANE_MIN), Math.max(PANE_MIN, room - PANE_CHAT_MIN)));+}++function loadPaneWidth(): number {+ try {+ const n = Number(localStorage.getItem(PANE_WIDTH_KEY));+ if (Number.isFinite(n) && n > 0) return n;+ } catch {+ // no storage+ }+ return PANE_DEFAULT;+}function loadPreset(): Preset {try {@@ -168,6 +190,10 @@ export default function BrowserPane({const [hoverEl, setHoverEl] = useState<MapElement | null>(null);const [editing, setEditing] = useState<number | null>(null);const [preset, setPreset] = useState<Preset>(() => loadPreset());+ // Server and first client render must agree, so the stored width is read+ // after mount rather than in the initial state.+ const [paneWidth, setPaneWidth] = useState(PANE_DEFAULT);+ const [dragging, setDragging] = useState(false);const presetRef = useRef<Preset>(preset);presetRef.current = preset;const frameRef = useRef<HTMLDivElement>(null);@@ -374,6 +400,54 @@ export default function BrowserPane({if (editing !== null) window.setTimeout(() => noteRef.current?.focus(), 0);}, [editing]);+ // The pane's own width: restored on mount, kept within the window as it+ // is resized, saved once a drag ends.+ useEffect(() => {+ setPaneWidth(clampPaneWidth(loadPaneWidth()));+ const onResize = () => setPaneWidth((w) => clampPaneWidth(w));+ window.addEventListener("resize", onResize);+ return () => window.removeEventListener("resize", onResize);+ }, []);++ const dragFrom = useRef<{ x: number; width: number } | null>(null);++ const onHandleDown = (e: ReactPointerEvent<HTMLDivElement>) => {+ e.preventDefault();+ e.currentTarget.setPointerCapture(e.pointerId);+ dragFrom.current = { x: e.clientX, width: paneWidth };+ setDragging(true);+ };++ const onHandleMove = (e: ReactPointerEvent<HTMLDivElement>) => {+ const from = dragFrom.current;+ if (!from) return;+ // The pane sits on the right, so dragging left widens it.+ setPaneWidth(clampPaneWidth(from.width - (e.clientX - from.x)));+ };++ const endHandleDrag = (e: ReactPointerEvent<HTMLDivElement>) => {+ if (!dragFrom.current) return;+ dragFrom.current = null;+ setDragging(false);+ if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);+ try {+ localStorage.setItem(PANE_WIDTH_KEY, String(paneWidth));+ } catch {+ // no storage+ }+ };++ /** Keyboard resizing, and double-click to go back to the default. */+ const nudgeWidth = (px: number) => {+ const next = clampPaneWidth(px);+ setPaneWidth(next);+ try {+ localStorage.setItem(PANE_WIDTH_KEY, String(next));+ } catch {+ // no storage+ }+ };+/** Frame pixels → the page's CSS pixels. */const toPage = (e: { clientX: number; clientY: number }) => {const img = imgRef.current;@@ -517,9 +591,32 @@ export default function BrowserPane({return (<aside- className="hidden w-[560px] shrink-0 flex-col overflow-hidden rounded-[14px] border border-line bg-page lg:flex"- style={{ animation: "fade-in 300ms ease both" }}+ className="relative hidden shrink-0 flex-col overflow-hidden rounded-[14px] border border-line bg-page lg:flex"+ style={{ width: paneWidth, animation: "fade-in 300ms ease both" }}>+ <div+ role="separator"+ aria-orientation="vertical"+ aria-label="Resize the browser pane"+ aria-valuenow={paneWidth}+ aria-valuemin={PANE_MIN}+ tabIndex={0}+ onPointerDown={onHandleDown}+ onPointerMove={onHandleMove}+ onPointerUp={endHandleDrag}+ onPointerCancel={endHandleDrag}+ onDoubleClick={() => nudgeWidth(PANE_DEFAULT)}+ onKeyDown={(e) => {+ if (e.key === "ArrowLeft") nudgeWidth(paneWidth + (e.shiftKey ? 80 : 20));+ else if (e.key === "ArrowRight") nudgeWidth(paneWidth - (e.shiftKey ? 80 : 20));+ else return;+ e.preventDefault();+ }}+ title="Drag to resize · double-click to reset"+ className={`absolute inset-y-0 left-0 z-20 w-2 cursor-col-resize touch-none transition-colors ${+ dragging ? "bg-accent/60" : "hover:bg-accent/30 focus-visible:bg-accent/40"+ }`}+ /><div className="flex h-11 shrink-0 items-center gap-2 border-b border-line px-3"><span className="flex size-5 items-center justify-center text-ink-2"><IconGlobe size={16} />