Skip to content

feat(layout): add on-overflow focused column centering - #146

Open
qeude wants to merge 3 commits into
mainfrom
feat/102-on-overflow-centering
Open

qeude wants to merge 3 commits into
mainfrom
feat/102-on-overflow-centering

Conversation

@qeude

@qeude qeude commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Adds center_focused_column = "on-overflow". When focus moves to another column, Defi centers the new column only if it cannot share the screen with the column that was focused before. Otherwise it scrolls just enough to reveal it, like "never". The default stays "never", and "never"/"always" behave as before.

Closes #102

Behavior

  • Fit. The span runs from the left edge of the leftmost column to the right edge of the rightmost, including any columns between them. It fits when it is at most the usable monitor width. Column slots include their gaps, and an exact fit counts as fitting.
  • Prior column. This is the selected window that Defi last resolved the workspace's scroll target for. With no prior column (first window, prior window closed), Defi only reveals.
  • Stability. The decision is made once, when the selected window changes, and is stored with that window (Workspace.scrollFocus). Later recomputation keeps it: desktop syncs, stale completions, column moves and learned minimum widths. Focusing the selected window again changes nothing.
  • Oversized columns. A column wider than the screen is left-aligned in every mode.
  • Settings. Settings > Layout > Focused column gains "Center on overflow". The mode is documented in CONFIGURATION.md under "Focused column centering".

Verification

  • python3 script/verify.py local passed on the final head.
  • New pure tests:
    • a config decoding test;
    • a never/always/on-overflow decision table over prior and new columns, plus an oversized-column test;
    • a runtime transition sequence covering exact fit, adjacent and nonadjacent focus, refocus, a stale scroll offset and a column move;
    • daemon native-focus cases.
  • Desktop: verify.py desktop on the staged bundle. The first full run had 5 failing tests (hotkeys, Carbon reservations, pointer, keyboard activation) and the second had 1 (native stacking precondition). The sets did not overlap. Each failing test passed when rerun alone on the same build, and the session store restored each time.
  • Installed journey: verify-defi centering_check.sh (new). On this build, it passed all 6 width/mode rows driven by the CLI. It passed again driven by real hyper hotkeys at about 0.8 s spacing, with captured=12 and drift=0[]. One daemon remained and the initial workspace was restored.
  • Not run: Computer Use, because it is unavailable in this session. Multi-monitor isolation was not exercised because only one display was attached.

Manual test (about 5 minutes)

<mod> is your default_key_modifier (hyper in your config).

  1. Open Settings > Layout > Focused column and choose Center on overflow. Alternatively, add center_focused_column = "on-overflow" under [layout] in ~/.config/defi/config.toml.
  2. On an empty workspace, open 4 windows. TextEdit with Cmd-N works. Columns are 0.5 wide by default.
  3. Press <mod>-[ to focus the first column, then <mod>-Right. Expected: the second column shows at the right half and nothing scrolls, because two half-width columns fit exactly.
  4. Press <mod>-Right again. Expected: the third column is revealed at the right edge, not centered.
  5. Press <mod>-[, then <mod>-Right twice quickly. Expected: each step reveals and nothing is centered.
  6. On each column, press <mod>-= (cycle-width next) to make it 0.66 wide. Then press <mod>-[ and <mod>-Right. Expected: the second column is centered because the two columns overflow.
  7. Wait a few seconds, then click the centered window. Expected: it stays centered and the view does not move.
  8. Switch the setting back to Reveal as needed. Repeat step 6. Expected: the second column lands at the right edge instead.

View guided diff Turn on auto-fix

Note

Add on-overflow focused-column centering mode

  • Adds a third focused-column centering option: center a column only when the span from the previously selected column exceeds the usable viewport; otherwise reveal it as needed. The overflow decision persists per workspace until the selected window changes.
  • Plumbs the new value through config (CenterFocusedColumnConfig), runtime (CenterFocusedColumn.init(config:)), core scrolling (focusedColumnScrollTarget), a new ScrollFocus model field on Workspace, and the macOS settings UI plus settings search.
  • Adds an end-to-end verification script (centering_check.sh) that drives TextEdit across all centering modes, records traces, and restores workspace and config state on exit.
  • Behavioral Change: workspaces now persist a ScrollFocus record via synchronizeScrollOffsets in ScrollReconciliation.swift; the recorded on-overflow decision survives mode switches, manual offset changes, and width changes until the selection changes. Default remains never.

Macroscope summarized 916288c.

qeude added 2 commits October 19, 2026 23:23
Center a newly focused column only when it cannot share the screen with
the previously focused column. Fitting is measured over the usable
viewport with gaps, and an exact fit counts as fitting. Each workspace
records the selected window its scroll target was resolved for, plus the
centering decision, so recomputation, column moves and learned widths
keep the decision until the selection changes.

Expose Center on overflow in Layout Settings and document the mode.

Closes #102
centering_check.sh opens scratch TextEdit columns on the trailing
workspace and proves never, always and on-overflow at an exact fit and
an overflow, driven by the CLI or by real hotkeys.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 16 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .agents/skills/verify-defi/centering_check.sh
Comment thread Tests/DefiRuntimeTests/NativeFocusTests.swift
Comment thread Tests/DefiCoreTests/WorkspaceScrollingTests.swift
Comment thread Sources/DefiCore/WorkspaceScrolling.swift Outdated
Comment thread .agents/skills/verify-defi/centering_check.sh Outdated
Comment thread .agents/skills/verify-defi/centering_check.sh Outdated
Comment thread .agents/skills/verify-defi/centering_check.sh
Comment thread CONFIGURATION.md Outdated
Comment thread CONFIGURATION.md Outdated
@macroscopeapp

macroscopeapp Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Approvability

Verdict: Approved at 916288c

Macroscope's review found this PR approvable — Adds a small, opt-in focused-column centering mode while preserving existing defaults and behavior, with configuration, UI, persistence compatibility, and runtime tests covering the new path. The remaining concerns are incremental boundary-test improvements rather than evidence of a material production risk.

You can add or adjust custom eligibility rules. Learn more.

Record the on-overflow decision in every centering mode so switching
modes without refocusing keeps it. Pin the centering journey's column
widths and presets, create the [layout] table or config file when absent,
and send hotkeys with the configured modifier. Clarify the docs.

This branch has not been deployed

No deployments
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.

[P1/P2] Add on-overflow column centering

1 participant