refactor(interactive-bash): reuse tmux parser

Route interactive bash tracking through the existing tmux parser so session name narrowing is shared and type-safe.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-15 16:31:13 +09:00
parent 15e7330ff0
commit 4785767a0c
3 changed files with 24 additions and 136 deletions
@@ -2,21 +2,25 @@ import type { InteractiveBashSessionState } from "./types";
import { loadInteractiveBashSessionState } from "./storage";
import { OMO_SESSION_PREFIX } from "./constants";
import { spawnWithWindowsHide } from "../../shared/spawn-with-windows-hide";
import { log } from "../../shared/logger";
export function getOrCreateState(sessionID: string, sessionStates: Map<string, InteractiveBashSessionState>): InteractiveBashSessionState {
if (!sessionStates.has(sessionID)) {
const persisted = loadInteractiveBashSessionState(sessionID);
const state: InteractiveBashSessionState = persisted ?? {
sessionID,
tmuxSessions: new Set<string>(),
updatedAt: Date.now(),
};
sessionStates.set(sessionID, state);
const existing = sessionStates.get(sessionID);
if (existing) {
return existing;
}
return sessionStates.get(sessionID)!;
const persisted = loadInteractiveBashSessionState(sessionID);
const state: InteractiveBashSessionState = persisted ?? {
sessionID,
tmuxSessions: new Set<string>(),
updatedAt: Date.now(),
};
sessionStates.set(sessionID, state);
return state;
}
export function isOmoSession(sessionName: string | null): boolean {
export function isOmoSession(sessionName: string | null): sessionName is string {
return sessionName !== null && sessionName.startsWith(OMO_SESSION_PREFIX);
}
@@ -30,6 +34,11 @@ export async function killAllTrackedSessions(
stderr: "ignore",
});
await proc.exited;
} catch {}
} catch (error) {
log("[interactive-bash-session] failed to kill tracked tmux session", {
error: error instanceof Error ? error.message : String(error),
sessionName,
});
}
}
}