Files
oh-my-opencode/src/features/tmux-subagent/action-executor-core.ts
T
YeonGyu-Kim b29d3ce382 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>
2026-02-17 03:40:46 +09:00

84 lines
1.9 KiB
TypeScript

import type { TmuxConfig } from "../../config/schema"
import type { applyLayout, closeTmuxPane, enforceMainPaneWidth, replaceTmuxPane, spawnTmuxPane } from "../../shared/tmux"
import type { PaneAction, WindowState } from "./types"
export interface ActionResult {
success: boolean
paneId?: string
error?: string
}
export interface ExecuteContext {
config: TmuxConfig
serverUrl: string
windowState: WindowState
}
export interface ActionExecutorDeps {
spawnTmuxPane: typeof spawnTmuxPane
closeTmuxPane: typeof closeTmuxPane
replaceTmuxPane: typeof replaceTmuxPane
applyLayout: typeof applyLayout
enforceMainPaneWidth: typeof enforceMainPaneWidth
}
async function enforceMainPane(
windowState: WindowState,
config: TmuxConfig,
deps: ActionExecutorDeps,
): Promise<void> {
if (!windowState.mainPane) return
await deps.enforceMainPaneWidth(
windowState.mainPane.paneId,
windowState.windowWidth,
config.main_pane_size,
)
}
export async function executeActionWithDeps(
action: PaneAction,
ctx: ExecuteContext,
deps: ActionExecutorDeps,
): Promise<ActionResult> {
if (action.type === "close") {
const success = await deps.closeTmuxPane(action.paneId)
if (success) {
await enforceMainPane(ctx.windowState, ctx.config, deps)
}
return { success }
}
if (action.type === "replace") {
const result = await deps.replaceTmuxPane(
action.paneId,
action.newSessionId,
action.description,
ctx.config,
ctx.serverUrl,
)
return {
success: result.success,
paneId: result.paneId,
}
}
const result = await deps.spawnTmuxPane(
action.sessionId,
action.description,
ctx.config,
ctx.serverUrl,
action.targetPaneId,
action.splitDirection,
)
if (result.success) {
await deps.applyLayout(ctx.config.layout, ctx.config.main_pane_size)
await enforceMainPane(ctx.windowState, ctx.config, deps)
}
return {
success: result.success,
paneId: result.paneId,
}
}