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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
da3f24b8b1
commit
17da22704e
@ -22,9 +22,17 @@ export interface ActionExecutorDeps {
|
|||||||
enforceMainPaneWidth: typeof enforceMainPaneWidth
|
enforceMainPaneWidth: typeof enforceMainPaneWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
async function enforceMainPane(windowState: WindowState, deps: ActionExecutorDeps): Promise<void> {
|
async function enforceMainPane(
|
||||||
|
windowState: WindowState,
|
||||||
|
config: TmuxConfig,
|
||||||
|
deps: ActionExecutorDeps,
|
||||||
|
): Promise<void> {
|
||||||
if (!windowState.mainPane) return
|
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(
|
export async function executeActionWithDeps(
|
||||||
@ -35,7 +43,7 @@ export async function executeActionWithDeps(
|
|||||||
if (action.type === "close") {
|
if (action.type === "close") {
|
||||||
const success = await deps.closeTmuxPane(action.paneId)
|
const success = await deps.closeTmuxPane(action.paneId)
|
||||||
if (success) {
|
if (success) {
|
||||||
await enforceMainPane(ctx.windowState, deps)
|
await enforceMainPane(ctx.windowState, ctx.config, deps)
|
||||||
}
|
}
|
||||||
return { success }
|
return { success }
|
||||||
}
|
}
|
||||||
@ -65,7 +73,7 @@ export async function executeActionWithDeps(
|
|||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
await deps.applyLayout(ctx.config.layout, ctx.config.main_pane_size)
|
await deps.applyLayout(ctx.config.layout, ctx.config.main_pane_size)
|
||||||
await enforceMainPane(ctx.windowState, deps)
|
await enforceMainPane(ctx.windowState, ctx.config, deps)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -86,6 +86,7 @@ describe("executeAction", () => {
|
|||||||
expect(mockApplyLayout).toHaveBeenCalledTimes(1)
|
expect(mockApplyLayout).toHaveBeenCalledTimes(1)
|
||||||
expect(mockApplyLayout).toHaveBeenCalledWith("main-horizontal", 55)
|
expect(mockApplyLayout).toHaveBeenCalledWith("main-horizontal", 55)
|
||||||
expect(mockEnforceMainPaneWidth).toHaveBeenCalledTimes(1)
|
expect(mockEnforceMainPaneWidth).toHaveBeenCalledTimes(1)
|
||||||
|
expect(mockEnforceMainPaneWidth).toHaveBeenCalledWith("%0", 220, 55)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("does not apply layout when spawn fails", async () => {
|
test("does not apply layout when spawn fails", async () => {
|
||||||
|
|||||||
@ -29,13 +29,15 @@ export async function applyLayout(
|
|||||||
export async function enforceMainPaneWidth(
|
export async function enforceMainPaneWidth(
|
||||||
mainPaneId: string,
|
mainPaneId: string,
|
||||||
windowWidth: number,
|
windowWidth: number,
|
||||||
|
mainPaneSize: number,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { log } = await import("../../logger")
|
const { log } = await import("../../logger")
|
||||||
const tmux = await getTmuxPath()
|
const tmux = await getTmuxPath()
|
||||||
if (!tmux) return
|
if (!tmux) return
|
||||||
|
|
||||||
const dividerWidth = 1
|
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)], {
|
const proc = spawn([tmux, "resize-pane", "-t", mainPaneId, "-x", String(mainWidth)], {
|
||||||
stdout: "ignore",
|
stdout: "ignore",
|
||||||
@ -47,5 +49,6 @@ export async function enforceMainPaneWidth(
|
|||||||
mainPaneId,
|
mainPaneId,
|
||||||
mainWidth,
|
mainWidth,
|
||||||
windowWidth,
|
windowWidth,
|
||||||
|
mainPaneSize: boundedMainPaneSize,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user