plugin: honor tmux disablement for interactive tmux features
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
import type { OhMyOpenCodeConfig, TmuxConfig } from "./config"
|
import type { OhMyOpenCodeConfig, TmuxConfig } from "./config"
|
||||||
import { TmuxConfigSchema } from "./config/schema/tmux"
|
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 {
|
export function createRuntimeTmuxConfig(pluginConfig: { tmux?: OhMyOpenCodeConfig["tmux"] }): TmuxConfig {
|
||||||
return TmuxConfigSchema.parse(pluginConfig.tmux ?? {})
|
return TmuxConfigSchema.parse(pluginConfig.tmux ?? {})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,4 +53,30 @@ describe("createSessionHooks", () => {
|
|||||||
// then
|
// then
|
||||||
expect(result.modelFallback).not.toBeNull()
|
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()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import {
|
|||||||
} from "../../shared"
|
} from "../../shared"
|
||||||
import { safeCreateHook } from "../../shared/safe-create-hook"
|
import { safeCreateHook } from "../../shared/safe-create-hook"
|
||||||
import { sessionExists } from "../../tools"
|
import { sessionExists } from "../../tools"
|
||||||
|
import { isTmuxIntegrationEnabled } from "../../create-runtime-tmux-config"
|
||||||
|
|
||||||
export type SessionHooks = {
|
export type SessionHooks = {
|
||||||
contextWindowMonitor: ReturnType<typeof createContextWindowMonitorHook> | null
|
contextWindowMonitor: ReturnType<typeof createContextWindowMonitorHook> | null
|
||||||
@@ -196,7 +197,9 @@ export function createSessionHooks(args: {
|
|||||||
? safeHook("non-interactive-env", () => createNonInteractiveEnvHook(ctx))
|
? safeHook("non-interactive-env", () => createNonInteractiveEnvHook(ctx))
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const interactiveBashSession = isHookEnabled("interactive-bash-session")
|
const interactiveBashSession =
|
||||||
|
isHookEnabled("interactive-bash-session") &&
|
||||||
|
isTmuxIntegrationEnabled(pluginConfig)
|
||||||
? safeHook("interactive-bash-session", () => createInteractiveBashSessionHook(ctx))
|
? safeHook("interactive-bash-session", () => createInteractiveBashSessionHook(ctx))
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
|||||||
@@ -81,3 +81,35 @@ describe("#given task_system configuration", () => {
|
|||||||
expect(result.filteredTools).toHaveProperty("task_update")
|
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")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
AvailableCategory,
|
AvailableCategory,
|
||||||
} from "../agents/dynamic-agent-prompt-builder"
|
} from "../agents/dynamic-agent-prompt-builder"
|
||||||
import type { OhMyOpenCodeConfig } from "../config"
|
import type { OhMyOpenCodeConfig } from "../config"
|
||||||
|
import { isTmuxIntegrationEnabled } from "../create-runtime-tmux-config"
|
||||||
import type { PluginContext, ToolsRecord } from "./types"
|
import type { PluginContext, ToolsRecord } from "./types"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -105,6 +106,7 @@ export function createToolRegistry(args: {
|
|||||||
availableCategories: AvailableCategory[]
|
availableCategories: AvailableCategory[]
|
||||||
}): ToolRegistryResult {
|
}): ToolRegistryResult {
|
||||||
const { ctx, pluginConfig, managers, skillContext, availableCategories } = args
|
const { ctx, pluginConfig, managers, skillContext, availableCategories } = args
|
||||||
|
const tmuxIntegrationEnabled = isTmuxIntegrationEnabled(pluginConfig)
|
||||||
|
|
||||||
const backgroundTools = createBackgroundTools(managers.backgroundManager, ctx.client)
|
const backgroundTools = createBackgroundTools(managers.backgroundManager, ctx.client)
|
||||||
const callOmoAgent = createCallOmoAgent(
|
const callOmoAgent = createCallOmoAgent(
|
||||||
@@ -202,7 +204,7 @@ export function createToolRegistry(args: {
|
|||||||
task: delegateTask,
|
task: delegateTask,
|
||||||
skill_mcp: skillMcpTool,
|
skill_mcp: skillMcpTool,
|
||||||
skill: skillTool,
|
skill: skillTool,
|
||||||
interactive_bash,
|
...(tmuxIntegrationEnabled ? { interactive_bash } : {}),
|
||||||
...taskToolsRecord,
|
...taskToolsRecord,
|
||||||
...hashlineToolsRecord,
|
...hashlineToolsRecord,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user