From 17da22704e3467a15656cce54e7cc58694a67f77 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 17 Feb 2026 03:40:46 +0900 Subject: [PATCH] fix: size main pane using configured layout percentage Main pane resize now uses main_pane_size instead of a hardcoded 50 percent fallback so post-split layout remains stable and predictable. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- .../tmux-subagent/action-executor-core.ts | 16 ++++++++++++---- .../tmux-subagent/action-executor.test.ts | 1 + src/shared/tmux/tmux-utils/layout.ts | 5 ++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/features/tmux-subagent/action-executor-core.ts b/src/features/tmux-subagent/action-executor-core.ts index a1ae9c13..466cbe95 100644 --- a/src/features/tmux-subagent/action-executor-core.ts +++ b/src/features/tmux-subagent/action-executor-core.ts @@ -22,9 +22,17 @@ export interface ActionExecutorDeps { enforceMainPaneWidth: typeof enforceMainPaneWidth } -async function enforceMainPane(windowState: WindowState, deps: ActionExecutorDeps): Promise { +async function enforceMainPane( + windowState: WindowState, + config: TmuxConfig, + deps: ActionExecutorDeps, +): Promise { if (!windowState.mainPane) return - await deps.enforceMainPaneWidth(windowState.mainPane.paneId, windowState.windowWidth) + await deps.enforceMainPaneWidth( + windowState.mainPane.paneId, + windowState.windowWidth, + config.main_pane_size, + ) } export async function executeActionWithDeps( @@ -35,7 +43,7 @@ export async function executeActionWithDeps( if (action.type === "close") { const success = await deps.closeTmuxPane(action.paneId) if (success) { - await enforceMainPane(ctx.windowState, deps) + await enforceMainPane(ctx.windowState, ctx.config, deps) } return { success } } @@ -65,7 +73,7 @@ export async function executeActionWithDeps( if (result.success) { await deps.applyLayout(ctx.config.layout, ctx.config.main_pane_size) - await enforceMainPane(ctx.windowState, deps) + await enforceMainPane(ctx.windowState, ctx.config, deps) } return { diff --git a/src/features/tmux-subagent/action-executor.test.ts b/src/features/tmux-subagent/action-executor.test.ts index 90a85ca5..f5ab3d74 100644 --- a/src/features/tmux-subagent/action-executor.test.ts +++ b/src/features/tmux-subagent/action-executor.test.ts @@ -86,6 +86,7 @@ describe("executeAction", () => { expect(mockApplyLayout).toHaveBeenCalledTimes(1) expect(mockApplyLayout).toHaveBeenCalledWith("main-horizontal", 55) expect(mockEnforceMainPaneWidth).toHaveBeenCalledTimes(1) + expect(mockEnforceMainPaneWidth).toHaveBeenCalledWith("%0", 220, 55) }) test("does not apply layout when spawn fails", async () => { diff --git a/src/shared/tmux/tmux-utils/layout.ts b/src/shared/tmux/tmux-utils/layout.ts index 7aeeae02..355b598e 100644 --- a/src/shared/tmux/tmux-utils/layout.ts +++ b/src/shared/tmux/tmux-utils/layout.ts @@ -29,13 +29,15 @@ export async function applyLayout( export async function enforceMainPaneWidth( mainPaneId: string, windowWidth: number, + mainPaneSize: number, ): Promise { const { log } = await import("../../logger") const tmux = await getTmuxPath() if (!tmux) return const dividerWidth = 1 - const mainWidth = Math.floor((windowWidth - dividerWidth) / 2) + const boundedMainPaneSize = Math.max(20, Math.min(80, mainPaneSize)) + const mainWidth = Math.floor(((windowWidth - dividerWidth) * boundedMainPaneSize) / 100) const proc = spawn([tmux, "resize-pane", "-t", mainPaneId, "-x", String(mainWidth)], { stdout: "ignore", @@ -47,5 +49,6 @@ export async function enforceMainPaneWidth( mainPaneId, mainWidth, windowWidth, + mainPaneSize: boundedMainPaneSize, }) }