Skip to content

feat(terminal): fit 80 columns in a narrow split pane - #824

Merged
devswha merged 4 commits into
mainfrom
feat/auto-fit-narrow-pane
Oct 11, 2026
Merged

devswha merged 4 commits into
mainfrom
feat/auto-fit-narrow-pane

Conversation

@devswha

@devswha devswha commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Change

Splitting a window can leave a pane a few columns short of 80, and a program that needs 80 columns then refuses to draw: btop in a 72-column pane shows only its "terminal size too small" notice. Until now the way out was to drag the divider, zoom the pane or lower the font size in Settings.

A split pane that would have fewer than 80 columns at the user's font size now draws in the largest smaller whole-pixel size that gives it 80, never below 10px. It returns to the user's size as soon as it is wide enough.

  • Only panes drawn side by side: a pane alone in its tab, a zoomed pane and a phone's one-pane-at-a-time view (fix(mobile): show a split tab one pane at a time on a phone #819) keep the user's size.
  • A pane that 10px cannot bring to 80 columns keeps the user's size, so a phone or a very narrow split is not shrunk for nothing.
  • A pane this browser only watches or mirrors keeps the user's size: it does not drive that grid, so a smaller font would gain no columns.
  • The saved font size never changes. baseFontRef holds the user's size (Settings, or a pinch in progress) apart from the size drawn.
  • Settings → Terminal → Fit 80 columns in a split pane turns it off (on by default), with Korean, Japanese, Chinese and Turkish labels.
  • The setting, a zoom and the last sibling closing refit the pane themselves, since none of them has to resize its host.

Each pane already fits its own xterm and sends its own grid for its pty, and herdr's layout rectangles are not pty dimensions (DESIGN.md), so a pane sending 80 columns for a rectangle 72 cells wide does not move the layout or the divider math. The pty is shared as before: herdr's own TUI shows such a pane at the grid this client set.

Known limit: with the setting on, a pinch in a narrow split pane saves the size its badge shows, but the pane stays at the size that fits 80 columns until it has the room. DESIGN.md says so.

Validation

  • bun run typecheck: passed.
  • bun scripts/narrow-pane-demo-regression.ts (new, added to ci-browser.sh): passed on the unmodified client over the demo transport. It reads the drawn font and the columns each pane sends for its pty through: a pane alone, a wide split, a split under 80 columns (11px for 80 columns at a 1450px window), the setting off and on again, a split no font can bring to 80, a zoom and unzoom, and the split widened; it also asserts the smaller size is never the saved one.
  • bun scripts/settings-pages-demo-regression.ts: passed (the Terminal page with its new row fits 390px and 320px phones in en, ko, ja and zh).
  • bun run test:unit: 2676 passed, 4 failed. The four also fail on main at 6e77292 on this macOS / Bun 1.4.0 host and are unrelated:
    • scripts/check.test.ts (3): the temporary unix socket path is 120 characters, over the 100-character limit.
    • server/voice.test.ts:229 (1): expected multipart filename audio.webm, received clip.webm.
  • New unit tests: src/lib/narrowPaneFont.test.ts (the size chosen, the 10px floor, the unreachable case) and a settings.test.ts case for the new setting.
  • Read-only review of the approach and of every fit and font path in PaneTerminal.tsx; its two findings (a shrunk font surviving a fixed or observed grid; no way to opt out) are fixed here.

Not run locally: the integration suite and the rest of the browser lane (left to CI), and btop itself in a live herdr session. The fixed-grid and observe paths were checked by reading the code, not in a browser.

Release

Client-side change; no HTTP/WS contract or remote runtime bundle change. The new setting defaults to on, so installed users get the smaller font in narrow split panes with the app release containing this PR.

A split pane under 80 columns draws its terminal in the largest smaller
whole-pixel font that gives it 80, never below 10px, so a program that
refuses a narrower screen (btop) still draws. A pane alone in its tab or
zoomed, one that 10px cannot bring to 80 columns, and one this browser
only watches or mirrors keep the user's size, and the saved size never
changes. Settings -> Terminal -> Fit 80 columns in a split pane turns it
off.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 763ee775-ed0d-4069-83d5-1030fad5ee52

📥 Commits

Reviewing files that changed from the base of the PR and between 6e6eaaf and a8039e0.


📒 Files selected for processing (18)
  • CHANGELOG.md
  • DESIGN.md
  • docs/development.md
  • scripts/ci-browser.sh
  • scripts/ci-browser.test.ts
  • scripts/narrow-pane-demo-regression.ts
  • src/App.tsx
  • src/components/PaneCanvas.tsx
  • src/components/PaneTerminal.tsx
  • src/components/SettingsDialog.tsx
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.tr.ts
  • src/lib/i18n.zh.ts
  • src/lib/narrowPaneFont.test.ts
  • src/lib/narrowPaneFont.ts
  • src/lib/settings.test.ts
  • src/lib/settings.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devswha added a commit that referenced this pull request Oct 11, 2026
## Change

The pull request template and `CONTRIBUTING.md` asked every UI change to
attach a screenshot or recording. The maintainer does not review from
those images, and a PR opened from the command line cannot attach one,
so recent PRs (#823, #824) carried a note saying the images were
captured but not attached. Remove the requirement from both places.

Unchanged: the rules about where a capture comes from when someone does
make one (`AGENTS.md` and `CONTRIBUTING.md`: a demo or test session,
never a live one).

## Validation

Documentation only. `git diff` touches one sentence in
`.github/pull_request_template.md` and one in `CONTRIBUTING.md`; a
search of `.github`, `CONTRIBUTING.md`, the `AGENTS.md` files and
`docs/development.md` found no other place that asks for an attachment.

## Release

No app or runtime change.
@devswha
devswha merged commit 517786e into main Oct 11, 2026
15 of 17 checks passed
@devswha
devswha deleted the feat/auto-fit-narrow-pane branch October 11, 2026 18:14
devswha added a commit to sobir-git/herdr-web-ui that referenced this pull request Oct 11, 2026
main added a browser script (devswha#824) and raised the lane's expected count to
34, the same number this branch already used for its own script, so the two
edits merged without a conflict and left the count one short. It is 35 now.
devswha added a commit that referenced this pull request Oct 11, 2026
## Change

`scripts/ui-regression.ts` could fail with every check passing. On #824
the first CI attempt ended with

```
451 |     await route.fulfill({ response, json: body });
error: fulfill: Route is already handled!
```

after the check that owns that route had printed PASS; a rerun of the
same commit passed.

The handlers in question await `route.fetch()` before they answer, and
the app polls `/api/machines` on its own, so a call can be in flight
whenever a check ends. `page.unroute` does not wait for it. When the
route taken away is the page's last one, Playwright drops the page's
interceptor and continues the request on the server side; the handler's
own `fulfill` then finds the route handled. The rejection travels
through Playwright's event listener, outside every assertion, and Bun
exits 1.

`scripts/drained-route.ts` adds `routeDrained(page, url, handler)`: it
registers the route and returns an unroute that first waits for the
calls in flight (15 s deadline), then removes that handler. It is used
at:

- `ui-regression.ts`: the held stale poll, the BG status check, and the
plan check on the desktop page and on the phone (its context is closed
right after).
- `tab-menu-regression.ts`: the pending-selection check, which unrouted
first and waited for its handlers afterwards.

Not used, on purpose: `unrouteAll({ behavior: "wait" })` has the same
race between two calls in flight (playwright-core 1.63) and removes
unrelated routes; `"ignoreErrors"` and a `.catch(() => {})` would hide a
handler's real failure. A handler that throws still fails the unroute
here.

Left alone: `tab-menu-regression.ts:292` and
`terminal-copy-regression.ts:176` only race in a failure's cleanup, and
five scripts close a context with a fetched route registered (a
different error, if any). #806 moves the `ui-regression.ts` sites into
`ui-regression-palette.ts`; it needs this carried over when it is
rebased.

## Validation

- Reproduction (throwaway script, local Chrome): two requests in flight,
then `page.unroute` → `fulfill: Route is already handled!` twice as
unhandled rejections; the same with `routeDrained` → both fulfilled, no
rejection; a handler that throws → the unroute rejects with that error.
- `TMPDIR=/tmp CHROME_PATH=<lockfile Chromium> bun run check run --build
bun scripts/ui-regression.ts`: exit 0, 115 PASS lines, on an isolated
herdr (this includes `checkTabMenu`).
- `bun run typecheck`: passed.
- The diagnosis and the fix were reviewed read-only against
playwright-core's source (`Route.removeHandler` continuing the request,
`_startHandling`'s assertion).

The original failure is rare (one of the last 26 failed CI runs), so a
passing run does not prove its absence; the reproduction is what shows
the race gone.

## Release

Test scripts only; no app, contract or runtime change.
alexanderkreidich added a commit to alexanderkreidich/t-rex-ovis-fork that referenced this pull request Oct 23, 2026
Opening a split changed how the terminal looked: the text in both halves
got smaller, and grew back once the pane was alone again. On a 1450px
window the demo client drew a split pane at 10px instead of 13px.

The cause was upstream's "fit 80 columns in a narrow split pane" (devswha#824):
any pane drawn beside another that had fewer than 80 columns at the
user's size was drawn at the largest smaller size that gave it 80, down
to 10px. Upstream later removed the setting that turned it off (devswha#1099),
so every split under 80 columns shrank and nothing could stop it.

Every pane now draws at the user's terminal font size, alone or split.
A program that needs 80 columns (btop) gets them from a zoom, a wider
split or a smaller size in Settings.

Removed: lib/narrowPaneFont.ts and its unit test, the `split` prop of
PaneTerminal and the split flag PaneCanvas passed to renderPane, the
refit that ran when that flag changed, the font resets on observe and on
a fixed grid (they only undid the shrunk font), and the browser lane's
narrow-pane-demo-regression.ts. DESIGN.md states the new rule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant