Skip to content

feat(app): arrange the main window from a Layout page in Options - #309

Merged
TooonyChen merged 3 commits into
mainfrom
feature/layout-page
Dec 3, 2026
Merged

TooonyChen merged 3 commits into
mainfrom
feature/layout-page

Conversation

@TooonyChen

@TooonyChen TooonyChen commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a Layout page to the Options window (under General) that arranges the main window, as approved in #307. The server monitor, the session list and the bottom panel take fixed places around the terminal, which does not move: the top or bottom of the left column, the top or bottom of the right column, and under the terminal. The monitor and the session list take any column place; the panel takes the place under the terminal or a right-column place. A block alone in a column fills it; an empty column goes away.

The page has a thumbnail of the main window to drag the blocks in, a "Position" select per block that lists only the places it may take, the four presets (the matching one shown pressed), Restore defaults and a hint line. While a block is dragged, both columns and the place under the terminal show (an empty column too), the allowed places are outlined, the place it left says "Original place", the place under the pointer fills, a line above says what the drop does ("Drop: Left column, top · swaps with the server monitor"), the terminal and the places it may not take are dimmed, and Escape cancels. The existing context-menu entries stay and change the same settings. Each of those menus, and the session list's blank-area menu (as in the mockup), now ends with "Layout…", which opens the page.

Design

  • Model (internal/app/layout.go, pure functions): arrangement is one place per block. place moves a block. A block in the way takes the mover's old place, or if it may not go there, its first free allowed place: for the panel that is under the terminal, for the monitor or session list the left column first, then the right. A disallowed place changes nothing. There are 24 reachable arrangements: 12 with the panel under the terminal and 6 + 6 with it in the right column. Presets are compared on what the window shows (a block alone in a column counts the same at top or bottom).
  • Settings: new per-device keys monitorSlot, sessionListSlot, bottomPanelSlot (leftTop, leftBottom, rightTop, rightBottom, underTerminal), in localSettings. A file without all three is read from monitorSide/bottomPanelSide: monitor right goes to the right column's top, panel right to the right column's bottom, which is the layout it had before. Two blocks in one place, a disallowed place or a missing key loads as the default. The old keys are still written next to the new ones (right when the monitor or panel is in the right column), so an older version shows the nearest layout it can (with the session list always on the left). An older version that saves the file drops the new keys, and this version then migrates again from the old ones.
  • Context menus: the monitor's "Move to right side" puts it at the right column's top and "Move to left side" at the left column's top. The panel's "Move panel to right side" puts it at the right column's bottom and "Move panel to bottom" under the terminal. If the target place is taken, the same swap and fallback rule applies. From the default layout these give exactly the "Monitor on the right" and "Panel on the right" presets.
  • Sizes belong to columns and dividers: sidebarWidth (left column), monitorPercent (top share of the left column), rightPanelWidth, rightMonitorPercent (top share of the right column), terminalPercent. A swap keeps every divider where it was, and double-click still resets each one. The keys keep their names; the docs describe their new meaning.
  • Right column width: one width whichever blocks are in it (default 460, kept from the right edge). It is at least 410 while the panel is in it and widens to that when the panel moves in. With only the monitor or the session list it is at least 180, like the left column.
  • Minimum sizes: the left and right columns are at least 180 wide (410 with the panel); the terminal is at least 300 wide (420 with the panel under it); in a column the monitor is at least 60 high, the session list 90, the panel 120; the terminal is at least 140 high. The terminal's minimum beside a panel column went from 320 to 300 so that the widest arrangement (a column on each side, panel on the right) fits the 900 DIP minimum window: 180 + 410 + 300 + 2 dividers = 892. The tallest column needs 210 of 560. Divider drags are clamped to these limits. When the window is narrower than the saved widths, the columns are drawn narrower for that frame, the right one first, down to their minimums (fitWidths, fitPercent); the saved values do not change.
  • Main view (internal/app/layoutview.go): it builds a left column, the terminal with the place under it, and a right column from the model, instead of special cases. In the default layout the element tree is the same as before, and the README main-window scenes are pixel-identical. A hidden panel next to another block in the right column collapses to its tab row in its own place (top or bottom); hidden alone there, it removes the column and leaves the strip, as before. Maximize, the panel's own window, hide, the session list's pages and header buttons, Close all, the monitor's menu and full screen all follow the block.
  • Thumbnail: its proportions follow the main window as last drawn (at most 480 × 240 so the page fits the Options window at its default size), using the same fitted column widths and divider shares. Block contents are schematic. Each place is a keyed cell, so the dragged block stays the drag source when the empty places appear; drop targets are overlays on the cells (an Absolute sibling, so the copy that follows the pointer is the clean block).
  • Keyboard: the selects and the preset toggles are in Tab order on the page. In the main window, dividers move with the arrow keys once focused (tested in every arrangement). Focus order follows the element tree: left column top, left column bottom, then the right column (the flipped split that sizes it from the right edge builds it first, as on main for the monitor or panel on the right), then the terminal and the panel under it.

Differences from the mockup

  • The thumbnail is 375 × 240 at the default window size rather than about 480 × 300, so that the page with all its rows fits the Options window at its default 760 × 600 without scrolling. Because of that, block names in the narrow left column are truncated ("服务…").
  • The preset buttons are a little smaller than the selects. In English the fourth preset wraps to a second line.
  • The dragged copy is tilted and shadowed by MyGo's drag copy, with less tilt than drawn.
  • The session list's blank-area menu also gets "Layout…" (the mockup lists it; the issue text names only the monitor and panel menus).

Screenshots

The main-window README scenes are unchanged (go run ./tools/screenshots leaves them byte-identical). The four Options-window scenes (file icon themes, color scheme, background image, shortcuts) change only by the new "Layout" entry in the page tree. They are updated in a separate commit, which can be dropped if you prefer to keep them as they were.

Closes #307

Testing

  • go build ./..., go vet ./..., GOOS=windows go vet ., GOOS=darwin go vet ., go tool mygo vet, toolchain gofmt -l . (empty)
  • go test -race -count=1 -timeout 30m ./...: all packages pass
  • New tests:
    • layout_test.go: every one of the 125 place combinations checked against valid; all 24 arrangements; every move from every arrangement (swap, fallback, disallowed); every arrangement reaches every other; settings round trip, old keys, impossible combinations; an old file loaded by the app; fitWidths at the minimum window for all 24 arrangements.
    • layoutpage_test.go: the page in both languages; every arrangement reached by dragging in the thumbnail and by the selects, with the main window and the thumbnail checked against it; the selects list only allowed places; swap, push-out to under the terminal, disallowed drops, Escape cancel, the drop texts, the empty left column disappearing; drag visuals; presets, the pressed preset, Restore defaults (sizes too); context menus in step with the page, swaps when the target is taken, "Layout…" from all three menus; scenes for the four presets, the session list in the right column and everything on the right.
    • layoutarrange_test.go: in seven arrangements (default, session list on top, panel on the right, monitor on the right, session list on the right, session list over the panel on the right, everything on the right): hide/show, maximize/restore, own window, the connections page and back, full screen, Close all; every divider by mouse, double click and arrow key; a swap keeps the divider; at 900 × 560 every arrangement, panel shown or hidden, keeps all minimums and shows every block.
  • Existing tests updated for the new menu entries and the renamed fields/limits; TestReadmeScreenshots and TestLayoutInBothLanguages are unchanged.
  • Not tested: real windows on Windows, macOS or Linux; real mouse drags (only the headless tester's pointer events); screen readers.

Changes after review

  • The thumbnail shows short names ("Monitor", "Sessions", "Panel"; 监控, 会话, 面板) so they are never cut off; the full name is the tooltip and the accessible label. The English presets are "Default", "Sessions on top", "Panel right", "Monitor right" and fit one row. Where the sections above say otherwise, this is what the code does now.
  • The right column is always drawn, and kept, at least as wide as what it shows needs: a panel that comes back into a column narrowed while it was hidden, maximized, in its own window or elsewhere gets its 410 minimum again, by one rule (widenRightColumn) instead of a call at each site. TestPanelBackIntoNarrowColumn covers the arrow button, the menu item, the shortcut, restore after maximize, closing the panel's window, a preset, a drag and a settings file.
  • Known follow-up, not in this PR: the right column's default width is the shared 460 also when it holds only the monitor or the session list.

Generated by Claude Code

The server monitor, the session list and the bottom panel take fixed
places around the terminal: the top or bottom of the left or right
column, or under the terminal. A Layout page in Options shows a
thumbnail to drag them in, a select per block, presets and Restore
defaults. The places are kept per device in monitorSlot,
sessionListSlot and bottomPanelSlot, read from monitorSide and
bottomPanelSide in older files; the context menus' moves change the
same settings and end with Layout….

Closes #307

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM
The Options window's tree gained the Layout entry under General; the
main window scenes are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T03:57:13.145964Z 6f48d54 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f48d5476a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +126 to +127
if p.ok && !(p.b == blockPanel && m.panelHidden) {
m.rightMin = max(m.rightMin, blockMinWidth(p.b))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the panel's minimum width when expanding it

When the panel shares the right column with the monitor or session list, collapsing it now allows the column to be resized down to 180 DIPs, which is stored in a.rightWidth. Expanding the panel through setBottomPanelHidden(false) does not call widenForPanel, and fitWidths only reduces widths, so the expanded panel remains narrower than its required 410 DIPs. This can clip panel content, particularly the Processes details panes. Enforce the panel minimum when showing it again, or clamp the drawn width to the current minimum.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with a test and fixed in 6c5a0d4. TestPanelBackIntoNarrowColumn failed in five of its eight cases before the fix (panel shown again by the arrow button, the menu item or the shortcut; restored after maximize; its own window closed). The right column is now always drawn at least as wide as what it shows needs, and widenRightColumn raises and saves the kept width at the start of each frame, in place of the calls at individual sites.


Generated by Claude Code

The right column could be dragged to 180 DIPs while the panel was away
(hidden beside another block, maximized or in its own window) and stayed
that narrow when the panel came back. Now it is drawn at least as wide
as what it shows needs, and its kept width is raised to that in one
place, whatever brings the panel back.

The thumbnail shows short block names (the full name is the tooltip and
accessible name) in columns at least 84 DIPs wide, and the English
presets have shorter names, so both fit with fonts a fifth wider.

Refs #307

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM
@TooonyChen
TooonyChen merged commit 079265f into main Dec 3, 2026
1 check passed
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.

feat(app): arrange the main window from a Layout page in Options

2 participants