Skip to content

feat(panel): persist the panel size and fix the divider drag without a terminal - #679

Merged
eugenioenko merged 1 commit into
mainfrom
feat/panel-size-state
Sep 27, 2026
Merged

eugenioenko merged 1 commit into
mainfrom
feat/panel-size-state

Conversation

@eugenioenko

@eugenioenko eugenioenko commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Why

The bottom panel height and the right-docked panel width reset on every launch, while the sidebar and commit history sizes are already restored from state.json.

Change

  • state.json gains panelHeight and panelWidth, stored separately since the two docks are not interchangeable. Saved once when a divider drag ends (the OnResizeEnd hook from fix(sidebar): restore closed state and a usable width on launch #678) and by View: Increase/Decrease Panel Size; restored at startup. The fullscreen terminal toggle does not save, so a full-height terminal is not remembered as your size.
  • New minimums, ui.MinPanelHeight = 5 (divider, tab bar, and three content rows, the same rule as changesHistoryMinHeight) and ui.MinPanelWidth = 30. You can still drag below them or close the panel, but those sizes are not saved or restored, and reopening resets them to a usable size (previously only a height of 1 or less was reset, and width never was). The three copies of that reopen logic are folded into ensureUsablePanelSize.
  • Open/closed state and the active tab are intentionally not persisted: restoring the panel open would start a shell on every launch.
  • The settings reference now lists the panel among the layout saved to state.json.

Tests

Unit tests in internal/app:

  • TestPanelSizeRestoresAndPersists: sizes round-trip through a rebuild, sizes under the minimums are not saved, and saved sizes under the minimums are not restored.
  • TestReopeningTinyPanelResetsSize: reopening after a tiny drag resets height to half the area and width to the default.

The save-on-release contract of ContentSplitWidget.OnResizeEnd is covered by TestCommitHistoryDragPersistsOnlyOnRelease from #678.

Exercised in the real binary with an isolated TTT_CONFIG_DIR:

  • Drag the bottom divider up 6 rows: {"panelHeight":21,...}; the next launch opens at 21.
  • Drag it down to a sliver: state.json keeps 21.
  • Dock right and drag narrower: {"panelWidth":36,...}; the next launch opens at 36.

Fix: panel drag canceled when no terminal exists

Dragging the divider started a terminal on the first mouse move when none existed. Spawning moves focus, and the focus change canceled the pointer capture (Root.SetFocus → CancelPointerCapture), so the drag stopped after one step; it also switched an open Output or Problems panel to the Terminal tab. Reproduces on main:

bin/ttt --size 100x30 --exec "wait-for Explore; panel output; drag 60 12 60 6; debug /tmp/d.json; quit" .

The drag now only resizes (resizePanel). finishPanelResize starts a terminal when the drag ends, and only if the drag opened a closed panel. Covered by two e2e tests in tests/e2e/panel_drag_test.go, both failing on the old code:

  • TestPanelDragWithoutTerminalKeepsDragAndTab: resizing an open Output panel keeps the drag alive, reaches the dragged height, starts no terminal, and stays on Output.
  • TestPanelDraggedOpenStartsTerminalOnRelease: dragging a closed panel open starts no terminal mid-drag and one on release.

The repro above now ends at height 21 on the Output tab.

make test passes. make lint reports only pre-existing staticcheck SA5011 issues in unrelated test files.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 28 minutes.

Check out review usage here.

View limit details

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

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: eugenioenko/ttt/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 206f9b18-ad46-4481-93ad-a2eb966998a6

📥 Commits

Reviewing files that changed from the base of the PR and between f669907 and 22651e2.

📒 Files selected for processing (10)
  • docs-web/src/content/docs/reference/settings.md
  • internal/app/app.go
  • internal/app/callbacks.go
  • internal/app/commands_view.go
  • internal/app/exec_script.go
  • internal/app/settings_apply_test.go
  • internal/app/widgets.go
  • internal/config/state.go
  • internal/ui/content_split.go
  • tests/e2e/panel_drag_test.go

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.

@eugenioenko eugenioenko changed the title feat(panel): persist the panel size across launches feat(panel): persist the panel size and fix the divider drag without a terminal Sep 27, 2026
…a terminal

The bottom panel height and right-docked panel width reset on every
launch. Save both to state.json when a divider drag ends or the panel
resize commands run, and restore them at startup. Sizes below
MinPanelHeight (5) and MinPanelWidth (30) are never saved or restored,
and reopening the panel after dragging it that small resets it to a
usable size, matching the sidebar's rule.

Dragging the divider also started a terminal on the first mouse move
when none existed. Spawning moves focus, and the focus change canceled
the pointer capture, so the drag stopped after one step and switched an
open Output or Problems panel to the Terminal tab. The drag now only
resizes; a terminal starts when the drag ends, and only when the drag
opened a closed panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eugenioenko
eugenioenko merged commit b901ec6 into main Sep 27, 2026
12 checks passed
@eugenioenko
eugenioenko deleted the feat/panel-size-state branch September 27, 2026 15:40
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