fix(tmux): address review feedback for split/defer reliability
This commit is contained in:
parent
541f0d354d
commit
d2dc25e567
@ -30,6 +30,9 @@ function resolveMinPaneWidth(options?: CapacityOptions): number {
|
|||||||
if (typeof options === "number") {
|
if (typeof options === "number") {
|
||||||
return Math.max(1, options)
|
return Math.max(1, options)
|
||||||
}
|
}
|
||||||
|
if (options && typeof options.agentPaneWidth === "number") {
|
||||||
|
return Math.max(1, options.agentPaneWidth)
|
||||||
|
}
|
||||||
return MIN_PANE_WIDTH
|
return MIN_PANE_WIDTH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,7 @@ export class TmuxSessionManager {
|
|||||||
private deferredSessions = new Map<string, DeferredSession>()
|
private deferredSessions = new Map<string, DeferredSession>()
|
||||||
private deferredQueue: string[] = []
|
private deferredQueue: string[] = []
|
||||||
private deferredAttachInterval?: ReturnType<typeof setInterval>
|
private deferredAttachInterval?: ReturnType<typeof setInterval>
|
||||||
|
private deferredAttachTickScheduled = false
|
||||||
private deps: TmuxUtilDeps
|
private deps: TmuxUtilDeps
|
||||||
private pollingManager: TmuxPollingManager
|
private pollingManager: TmuxPollingManager
|
||||||
constructor(ctx: PluginInput, tmuxConfig: TmuxConfig, deps: TmuxUtilDeps = defaultTmuxDeps) {
|
constructor(ctx: PluginInput, tmuxConfig: TmuxConfig, deps: TmuxUtilDeps = defaultTmuxDeps) {
|
||||||
@ -130,8 +131,14 @@ export class TmuxSessionManager {
|
|||||||
private startDeferredAttachLoop(): void {
|
private startDeferredAttachLoop(): void {
|
||||||
if (this.deferredAttachInterval) return
|
if (this.deferredAttachInterval) return
|
||||||
this.deferredAttachInterval = setInterval(() => {
|
this.deferredAttachInterval = setInterval(() => {
|
||||||
|
if (this.deferredAttachTickScheduled) return
|
||||||
|
this.deferredAttachTickScheduled = true
|
||||||
void this.enqueueSpawn(async () => {
|
void this.enqueueSpawn(async () => {
|
||||||
await this.tryAttachDeferredSession()
|
try {
|
||||||
|
await this.tryAttachDeferredSession()
|
||||||
|
} finally {
|
||||||
|
this.deferredAttachTickScheduled = false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}, POLL_INTERVAL_BACKGROUND_MS)
|
}, POLL_INTERVAL_BACKGROUND_MS)
|
||||||
log("[tmux-session-manager] deferred attach polling started", {
|
log("[tmux-session-manager] deferred attach polling started", {
|
||||||
@ -143,6 +150,7 @@ export class TmuxSessionManager {
|
|||||||
if (!this.deferredAttachInterval) return
|
if (!this.deferredAttachInterval) return
|
||||||
clearInterval(this.deferredAttachInterval)
|
clearInterval(this.deferredAttachInterval)
|
||||||
this.deferredAttachInterval = undefined
|
this.deferredAttachInterval = undefined
|
||||||
|
this.deferredAttachTickScheduled = false
|
||||||
log("[tmux-session-manager] deferred attach polling stopped")
|
log("[tmux-session-manager] deferred attach polling stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export async function queryWindowState(sourcePaneId: string): Promise<WindowStat
|
|||||||
"-t",
|
"-t",
|
||||||
sourcePaneId,
|
sourcePaneId,
|
||||||
"-F",
|
"-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" }
|
{ stdout: "pipe", stderr: "pipe" }
|
||||||
)
|
)
|
||||||
@ -35,7 +35,11 @@ export async function queryWindowState(sourcePaneId: string): Promise<WindowStat
|
|||||||
const panes: TmuxPaneInfo[] = []
|
const panes: TmuxPaneInfo[] = []
|
||||||
|
|
||||||
for (const line of lines) {
|
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 width = parseInt(widthStr, 10)
|
||||||
const height = parseInt(heightStr, 10)
|
const height = parseInt(heightStr, 10)
|
||||||
const left = parseInt(leftStr, 10)
|
const left = parseInt(leftStr, 10)
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export interface SpawnDecision {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CapacityConfig {
|
export interface CapacityConfig {
|
||||||
layout?: string
|
layout?: string
|
||||||
mainPaneSize?: number
|
mainPaneSize?: number
|
||||||
mainPaneMinWidth: number
|
mainPaneMinWidth: number
|
||||||
agentPaneWidth: number
|
agentPaneWidth: number
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user