fix(tmux): scope isolated session name per plugin instance (Oracle review)
Oracle flagged the previous commit: "omo-agents" was a shared constant, so when two plugin instances ran in the same tmux server they wrote into the same session. One instance's cleanup would then kill-session on the shared name and tear down the other instance's live attached panes. Replace the const ISOLATED_SESSION_NAME with getIsolatedSessionName(pid) which defaults to process.pid, so every opencode process owns its own "omo-agents-<pid>" session. spawnTmuxSession and cleanup both resolve the name through this helper. Discovery is straightforward from the host tmux via 'tmux list-sessions | grep omo-agents-'. Manager test covers two concurrent managers and asserts each kills a per-pid session name, proving they no longer collide on a global name.
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
spawnTmuxWindow,
|
||||
spawnTmuxSession,
|
||||
killTmuxSessionIfExists,
|
||||
ISOLATED_SESSION_NAME,
|
||||
getIsolatedSessionName,
|
||||
} from "../../shared/tmux"
|
||||
import { queryWindowState } from "./pane-state-querier"
|
||||
import { decideSpawnActions, decideCloseAction, type SessionMapping } from "./decision-engine"
|
||||
@@ -970,15 +970,16 @@ export class TmuxSessionManager {
|
||||
this.isolatedWindowPaneId = undefined
|
||||
|
||||
if (this.tmuxConfig.isolation === "session") {
|
||||
const isolatedSessionName = getIsolatedSessionName()
|
||||
try {
|
||||
const killed = await killTmuxSessionIfExists(ISOLATED_SESSION_NAME)
|
||||
const killed = await killTmuxSessionIfExists(isolatedSessionName)
|
||||
log("[tmux-session-manager] isolated session teardown", {
|
||||
session: ISOLATED_SESSION_NAME,
|
||||
session: isolatedSessionName,
|
||||
killed,
|
||||
})
|
||||
} catch (error) {
|
||||
log("[tmux-session-manager] isolated session teardown failed", {
|
||||
session: ISOLATED_SESSION_NAME,
|
||||
session: isolatedSessionName,
|
||||
error: String(error),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user