4f127ed104
When queryWindowState returned null during session deletion, the session mapping was deleted but the real tmux pane stayed alive, creating zombie panes. - Add closePending/closeRetryCount fields to TrackedSession - Mark sessions closePending instead of deleting on close failure - Add retryPendingCloses() called from onSessionCreated and cleanup - Force-remove mappings after 3 failed retry attempts - Extract TrackedSessionState helper for field initialization Tests: 3 pass, 9 expects
28 lines
579 B
TypeScript
28 lines
579 B
TypeScript
import type { TrackedSession } from "./types"
|
|
|
|
export function createTrackedSession(params: {
|
|
sessionId: string
|
|
paneId: string
|
|
description: string
|
|
now?: Date
|
|
}): TrackedSession {
|
|
const now = params.now ?? new Date()
|
|
|
|
return {
|
|
sessionId: params.sessionId,
|
|
paneId: params.paneId,
|
|
description: params.description,
|
|
createdAt: now,
|
|
lastSeenAt: now,
|
|
closePending: false,
|
|
closeRetryCount: 0,
|
|
}
|
|
}
|
|
|
|
export function markTrackedSessionClosePending(tracked: TrackedSession): TrackedSession {
|
|
return {
|
|
...tracked,
|
|
closePending: true,
|
|
}
|
|
}
|