fix(tmux): address review feedback for split/defer reliability

This commit is contained in:
liu-qingyuan
2026-02-19 00:18:39 +08:00
parent 541f0d354d
commit d2dc25e567
4 changed files with 19 additions and 4 deletions

View File

@@ -30,6 +30,9 @@ function resolveMinPaneWidth(options?: CapacityOptions): number {
if (typeof options === "number") {
return Math.max(1, options)
}
if (options && typeof options.agentPaneWidth === "number") {
return Math.max(1, options.agentPaneWidth)
}
return MIN_PANE_WIDTH
}

View File

@@ -58,6 +58,7 @@ export class TmuxSessionManager {
private deferredSessions = new Map<string, DeferredSession>()
private deferredQueue: string[] = []
private deferredAttachInterval?: ReturnType<typeof setInterval>
private deferredAttachTickScheduled = false
private deps: TmuxUtilDeps
private pollingManager: TmuxPollingManager
constructor(ctx: PluginInput, tmuxConfig: TmuxConfig, deps: TmuxUtilDeps = defaultTmuxDeps) {
@@ -130,8 +131,14 @@ export class TmuxSessionManager {
private startDeferredAttachLoop(): void {
if (this.deferredAttachInterval) return
this.deferredAttachInterval = setInterval(() => {
if (this.deferredAttachTickScheduled) return
this.deferredAttachTickScheduled = true
void this.enqueueSpawn(async () => {
await this.tryAttachDeferredSession()
try {
await this.tryAttachDeferredSession()
} finally {
this.deferredAttachTickScheduled = false
}
})
}, POLL_INTERVAL_BACKGROUND_MS)
log("[tmux-session-manager] deferred attach polling started", {
@@ -143,6 +150,7 @@ export class TmuxSessionManager {
if (!this.deferredAttachInterval) return
clearInterval(this.deferredAttachInterval)
this.deferredAttachInterval = undefined
this.deferredAttachTickScheduled = false
log("[tmux-session-manager] deferred attach polling stopped")
}

View File

@@ -14,7 +14,7 @@ export async function queryWindowState(sourcePaneId: string): Promise<WindowStat
"-t",
sourcePaneId,
"-F",
"#{pane_id}\t#{pane_width}\t#{pane_height}\t#{pane_left}\t#{pane_top}\t#{pane_title}\t#{pane_active}\t#{window_width}\t#{window_height}",
"#{pane_id}\t#{pane_width}\t#{pane_height}\t#{pane_left}\t#{pane_top}\t#{pane_active}\t#{window_width}\t#{window_height}\t#{pane_title}",
],
{ stdout: "pipe", stderr: "pipe" }
)
@@ -35,7 +35,11 @@ export async function queryWindowState(sourcePaneId: string): Promise<WindowStat
const panes: TmuxPaneInfo[] = []
for (const line of lines) {
const [paneId, widthStr, heightStr, leftStr, topStr, title, activeStr, windowWidthStr, windowHeightStr] = line.split("\t")
const fields = line.split("\t")
if (fields.length < 9) continue
const [paneId, widthStr, heightStr, leftStr, topStr, activeStr, windowWidthStr, windowHeightStr] = fields
const title = fields.slice(8).join("\t")
const width = parseInt(widthStr, 10)
const height = parseInt(heightStr, 10)
const left = parseInt(leftStr, 10)

View File

@@ -43,7 +43,7 @@ export interface SpawnDecision {
}
export interface CapacityConfig {
layout?: string
layout?: string
mainPaneSize?: number
mainPaneMinWidth: number
agentPaneWidth: number