plugin: honor tmux disablement for interactive tmux features

This commit is contained in:
YeonGyu-Kim
2026-04-04 14:14:19 +09:00
parent 2d72f51a92
commit 731c3f1109
5 changed files with 71 additions and 2 deletions
+6
View File
@@ -1,6 +1,12 @@
import type { OhMyOpenCodeConfig, TmuxConfig } from "./config"
import { TmuxConfigSchema } from "./config/schema/tmux"
export function isTmuxIntegrationEnabled(
pluginConfig: { tmux?: { enabled?: boolean } | undefined },
): boolean {
return pluginConfig.tmux?.enabled ?? false
}
export function createRuntimeTmuxConfig(pluginConfig: { tmux?: OhMyOpenCodeConfig["tmux"] }): TmuxConfig {
return TmuxConfigSchema.parse(pluginConfig.tmux ?? {})
}
@@ -53,4 +53,30 @@ describe("createSessionHooks", () => {
// then
expect(result.modelFallback).not.toBeNull()
})
it("skips interactive bash session hook when tmux integration is disabled", () => {
// given
const pluginConfig = {
tmux: {
enabled: false,
layout: "main-vertical",
main_pane_size: 60,
main_pane_min_width: 120,
agent_pane_min_width: 40,
isolation: "inline",
},
} as OhMyOpenCodeConfig
// when
const result = createSessionHooks({
ctx: mockContext,
pluginConfig,
modelCacheState: mockModelCacheState,
isHookEnabled: (hookName) => hookName === "interactive-bash-session",
safeHookEnabled: true,
})
// then
expect(result.interactiveBashSession).toBeNull()
})
})
+4 -1
View File
@@ -36,6 +36,7 @@ import {
} from "../../shared"
import { safeCreateHook } from "../../shared/safe-create-hook"
import { sessionExists } from "../../tools"
import { isTmuxIntegrationEnabled } from "../../create-runtime-tmux-config"
export type SessionHooks = {
contextWindowMonitor: ReturnType<typeof createContextWindowMonitorHook> | null
@@ -196,7 +197,9 @@ export function createSessionHooks(args: {
? safeHook("non-interactive-env", () => createNonInteractiveEnvHook(ctx))
: null
const interactiveBashSession = isHookEnabled("interactive-bash-session")
const interactiveBashSession =
isHookEnabled("interactive-bash-session") &&
isTmuxIntegrationEnabled(pluginConfig)
? safeHook("interactive-bash-session", () => createInteractiveBashSessionHook(ctx))
: null
+32
View File
@@ -81,3 +81,35 @@ describe("#given task_system configuration", () => {
expect(result.filteredTools).toHaveProperty("task_update")
})
})
describe("#given tmux integration is disabled", () => {
test("#when tool registry is created #then interactive_bash is not registered", () => {
const result = createToolRegistry({
ctx: { directory: "/tmp" } as Parameters<typeof createToolRegistry>[0]["ctx"],
pluginConfig: {
tmux: {
enabled: false,
layout: "main-vertical",
main_pane_size: 60,
main_pane_min_width: 120,
agent_pane_min_width: 40,
isolation: "inline",
},
},
managers: {
backgroundManager: {},
tmuxSessionManager: {},
skillMcpManager: {},
} as Parameters<typeof createToolRegistry>[0]["managers"],
skillContext: {
mergedSkills: [],
availableSkills: [],
browserProvider: "playwright",
disabledSkills: new Set(),
},
availableCategories: [],
})
expect(result.filteredTools).not.toHaveProperty("interactive_bash")
})
})
+3 -1
View File
@@ -5,6 +5,7 @@ import type {
AvailableCategory,
} from "../agents/dynamic-agent-prompt-builder"
import type { OhMyOpenCodeConfig } from "../config"
import { isTmuxIntegrationEnabled } from "../create-runtime-tmux-config"
import type { PluginContext, ToolsRecord } from "./types"
import {
@@ -105,6 +106,7 @@ export function createToolRegistry(args: {
availableCategories: AvailableCategory[]
}): ToolRegistryResult {
const { ctx, pluginConfig, managers, skillContext, availableCategories } = args
const tmuxIntegrationEnabled = isTmuxIntegrationEnabled(pluginConfig)
const backgroundTools = createBackgroundTools(managers.backgroundManager, ctx.client)
const callOmoAgent = createCallOmoAgent(
@@ -202,7 +204,7 @@ export function createToolRegistry(args: {
task: delegateTask,
skill_mcp: skillMcpTool,
skill: skillTool,
interactive_bash,
...(tmuxIntegrationEnabled ? { interactive_bash } : {}),
...taskToolsRecord,
...hashlineToolsRecord,
}