Skip to content

balance-sizes: preserve total weight instead of resetting to a constant - #57

Merged
vitorebatista merged 1 commit into
mainfrom
port/balance-sizes-preserve-weight
Aug 27, 2026
Merged

balance-sizes: preserve total weight instead of resetting to a constant#57
vitorebatista merged 1 commit into
mainfrom
port/balance-sizes-preserve-weight

Conversation

@vitorebatista

Copy link
Copy Markdown
Owner

balance-sizes assigned the constant weight 1 to every child, discarding the container's total. Weights are only converted to real sizes by the layout pass, which runs once after a binding's whole command list — so a resize running later in the same list worked against a total that no longer matched the monitor, and windows visibly jumped.

Now the container's existing total is redistributed equally, which is the same visual result for balance-sizes alone and correct for balance-sizes followed by resize.

Ports nikitabobko#2211 (author: @MsfPablo) — upstream issue nikitabobko#1837.

Fork adaptation: upstream's tests use a parseCommand("...") test helper that doesn't exist in this fork, so the three tests were rewritten in the fork's style — direct BalanceSizesCommand(args: BalanceSizesCmdArgs(rawArgs: [])) / ResizeCommand(args:) construction with try await ... .run(.defaultEnv.copy(\.workspaceName, name), .emptyStdin). Coverage is identical.

Tests: BalanceSizesCommandTest — existing test updated (three windows of weight 1/2/3 now balance to 2 each, not 1), plus a nested-container case and a balance-sizesresize regression case for nikitabobko#1837. All 3 pass.

./build-debug.sh -Xswiftc -warnings-as-errors ✅ · ./swift-test.sh

Docs: none needed (no user-visible flag/config change; balance-sizes behaves the same standalone).

`balance-sizes` set every child's weight to the constant 1, which throws away the
container's total. Weights are only turned into real sizes by the layout pass,
which runs once after a whole binding's command list — so a `resize` later in the
same list operated on a total that no longer matched the monitor, and the windows
jumped. Redistribute the container's existing total equally instead.

Ports nikitabobko#2211 (upstream issue nikitabobko#1837)

Tests rewritten against the fork's test API (`BalanceSizesCommand(args:)` +
`.defaultEnv.copy(\.workspaceName,)` instead of upstream's `parseCommand`, which
the fork doesn't have in tests).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBcwRe3CktWZGGcHJHP4ds
@vitorebatista
vitorebatista merged commit bf21cf5 into main Aug 27, 2026
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