Skip to content

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

Python

Fix chat divider rebalancing

yxlyxe914744d2dc3
diff --git a/apps/native/components/site/SplitDivider.tsx b/apps/native/components/site/SplitDivider.tsx
index b37a647e..bd241f59 100644
--- a/apps/native/components/site/SplitDivider.tsx
+++ b/apps/native/components/site/SplitDivider.tsx
@@ -1,6 +1,6 @@
import {useEffect,useMemo,useRef,useState} from 'react';
import {createFrameBatch} from '@/lib/frame-batch';
-import {dividerStyle,paneStyle,resizeSplit,splitGeometry,splitIds,type SplitBox,type SplitTree} from '@/lib/split-tree';
+import {balanceSplit,dividerStyle,paneStyle,resizeSplit,splitGeometry,splitIds,type SplitBox,type SplitTree} from '@/lib/split-tree';
function paint(root:HTMLElement,tree:SplitTree) {
const {panes,dividers}=splitGeometry(tree);
@@ -44,7 +44,7 @@ export default function SplitDivider({node,box,tree,onChange,index}:{
onPointerMove={event=>move(vertical?event.clientX:event.clientY)}
onPointerUp={event=>{move(vertical?event.clientX:event.clientY);finish();if(event.currentTarget.hasPointerCapture(event.pointerId))event.currentTarget.releasePointerCapture(event.pointerId);}}
onPointerCancel={()=>finish(true)} onLostPointerCapture={()=>finish()}
- onDoubleClick={()=>onChange(resizeSplit(tree,node.key,.5))}
+ onDoubleClick={()=>onChange(balanceSplit(tree))}
onKeyDown={event=>{
const delta=event.key===(vertical?'ArrowLeft':'ArrowUp')?-.05:event.key===(vertical?'ArrowRight':'ArrowDown')?.05:0;
if(delta){event.preventDefault();event.stopPropagation();onChange(resizeSplit(tree,node.key,node.ratio+delta));}
diff --git a/apps/native/electron/split-focus-visual.cjs b/apps/native/electron/split-focus-visual.cjs
index a35a990e..f769bd53 100644
--- a/apps/native/electron/split-focus-visual.cjs
+++ b/apps/native/electron/split-focus-visual.cjs
@@ -19,6 +19,20 @@ async function runSplitFocus({win,origin,output}) {
await key('d',{metaKey:true});
await wait(`document.querySelectorAll('[data-chat]').length===3`);
const original=await ids();
+ const divider='[data-chat-divider][aria-orientation="vertical"]';
+ const dividerPoint=await js(`(()=>{const r=document.querySelector(${JSON.stringify(divider)}).getBoundingClientRect();return {x:Math.round(r.x+r.width/2),y:Math.round(r.y+r.height/2)}})()`);
+ const widths=()=>js(`Array.from(document.querySelectorAll('[data-chat]')).map(e=>e.getBoundingClientRect().width)`);
+ await testDesktop.testInput(wc,{type:'mouseDown',button:'left',clickCount:1,...dividerPoint});
+ await testDesktop.testInput(wc,{type:'mouseMove',button:'left',x:dividerPoint.x+80,y:dividerPoint.y});
+ await testDesktop.testInput(wc,{type:'mouseUp',button:'left',clickCount:1,x:dividerPoint.x+80,y:dividerPoint.y});
+ await wait(`(()=>{const w=Array.from(document.querySelectorAll('[data-chat]')).map(e=>e.getBoundingClientRect().width);return Math.max(...w)-Math.min(...w)>30})()`);
+ const balancePoint=await js(`(()=>{const r=document.querySelector(${JSON.stringify(divider)}).getBoundingClientRect();return {x:Math.round(r.x+r.width/2),y:Math.round(r.y+r.height/2)}})()`);
+ for(const clickCount of [1,2]) {
+ await testDesktop.testInput(wc,{type:'mouseDown',button:'left',clickCount,...balancePoint});
+ await testDesktop.testInput(wc,{type:'mouseUp',button:'left',clickCount,...balancePoint});
+ }
+ await wait(`(()=>{const w=Array.from(document.querySelectorAll('[data-chat]')).map(e=>e.getBoundingClientRect().width);return Math.max(...w)-Math.min(...w)<10})()`);
+ assert.ok(Math.max(...await widths())-Math.min(...await widths())<10,'Double-click must rebalance all three chat panes after a drag');
await js(`document.querySelectorAll('[data-chat] textarea').forEach((e,i)=>{Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,'value').set.call(e,'Draft '+i);e.dispatchEvent(new Event('input',{bubbles:true}));})`);
await pointer(`[data-chat="${original[1]}"] textarea`);
fs.writeFileSync(path.join(output,'split-before-close.png'),(await wc.capturePage()).toPNG());
diff --git a/docs/adr/0081-desktop-split-focus-and-layout.md b/docs/adr/0081-desktop-split-focus-and-layout.md
index ba5843e5..4442a113 100644
--- a/docs/adr/0081-desktop-split-focus-and-layout.md
+++ b/docs/adr/0081-desktop-split-focus-and-layout.md
@@ -33,7 +33,8 @@ Tabs and workspace controls live in a shared toolbar above all panes. A combined
tab shows its member names and a miniature layout icon. Each split
has a compact, consistent header identifying its chat and folder. Adjacent panes
can be resized by dragging their separator or using its arrow keys; double-click
-balances the pair. The active pane has an accent border.
+balances the visible chat layout, including groups with more than two panes. The
+active pane has an accent border.
Projects and Conversations hide the chat layout while keeping it mounted, so
visiting either surface preserves visible composers and transcript positions.