Skip to content

Pane balance

A second extension entry, src/balance.ts, keeps Herdr tabs even. When a pi starts in a tab (once per process, so /reload does not count) and after a pi quits and Herdr closes its pane, the panes of that tab get equal widths along each split, and stacked panes equal heights. It runs in every pi inside Herdr, joined or not, and leaves a zoomed tab alone. A pane that outlives its pi (a shell you keep) changes nothing.

Details

The work runs in src/balance.mjs as a detached node process: balance.mjs now <pane> at start, balance.mjs after-close <pane> <tab> at quit, because the quitting pi exits before Herdr closes its pane. It is started with windowsHide, so on Windows a detached console child gets no console window of its own. Each resize is planned from a freshly read layout, and a per-tab lock under the system temp directory (pi-straw-boss-pane-balance/) makes concurrent sessions take turns instead of applying the same change twice.

A local tower run’s pi (started with --sb-run, or marked by the run mode when the server hands it a standing pane, src/runmark.ts) never starts after-close: its pane stays, so the helper would only wait out its 30 s. On Windows that wait mattered: Herdr starts pi.cmd with Start-Process -Wait, which waits for the whole process tree, so the pane showed no prompt until the helper ended and the next herdr agent start there ran into its own timeout. An ally run’s pane is closed by the server as soon as pi is gone, so its pi keeps after-close and the tower tab is rebalanced as for any pane (the run mode marks the process ally once the claim says so).