test(tmux): align placeholder command expectations
This commit is contained in:
@@ -298,7 +298,7 @@ describe("TmuxPollingManager overlap", () => {
|
|||||||
expect(tracked.attachActivated).toBe(true)
|
expect(tracked.attachActivated).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("does not close non-activated panes before focus activation", async () => {
|
test("does not close non-activated panes before they report any session status", async () => {
|
||||||
//#given
|
//#given
|
||||||
const sessions = new Map<string, TrackedSession>()
|
const sessions = new Map<string, TrackedSession>()
|
||||||
sessions.set("ses-1", {
|
sessions.set("ses-1", {
|
||||||
@@ -318,7 +318,7 @@ describe("TmuxPollingManager overlap", () => {
|
|||||||
const closedSessionIds: string[] = []
|
const closedSessionIds: string[] = []
|
||||||
const client = {
|
const client = {
|
||||||
session: {
|
session: {
|
||||||
status: async () => ({ data: { "ses-1": { type: "idle" } } }),
|
status: async () => ({ data: {} }),
|
||||||
messages: async () => ({ data: [] }),
|
messages: async () => ({ data: [] }),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -384,11 +384,12 @@ describe("TmuxPollingManager overlap", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const manager = new TmuxPollingManager(
|
const manager = new TmuxPollingManager(
|
||||||
client as unknown as import("../../tools/delegate-task/types").OpencodeClient,
|
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
|
||||||
sessions,
|
sessions,
|
||||||
async (sessionId) => {
|
async (sessionId) => {
|
||||||
closedSessionIds.push(sessionId)
|
closedSessionIds.push(sessionId)
|
||||||
},
|
},
|
||||||
|
undefined,
|
||||||
getWindowState,
|
getWindowState,
|
||||||
async () => {
|
async () => {
|
||||||
activationCount += 1
|
activationCount += 1
|
||||||
@@ -397,7 +398,7 @@ describe("TmuxPollingManager overlap", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
//#when
|
//#when
|
||||||
const pollSessions = (manager as unknown as { pollSessions: () => Promise<void> }).pollSessions
|
const pollSessions = unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager).pollSessions
|
||||||
await pollSessions.call(manager)
|
await pollSessions.call(manager)
|
||||||
await pollSessions.call(manager)
|
await pollSessions.call(manager)
|
||||||
await pollSessions.call(manager)
|
await pollSessions.call(manager)
|
||||||
@@ -437,7 +438,7 @@ describe("TmuxPollingManager overlap", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const manager = new TmuxPollingManager(
|
const manager = new TmuxPollingManager(
|
||||||
client as unknown as import("../../tools/delegate-task/types").OpencodeClient,
|
unsafeTestValue<import("../../tools/delegate-task/types").OpencodeClient>(client),
|
||||||
sessions,
|
sessions,
|
||||||
async (sessionId) => {
|
async (sessionId) => {
|
||||||
closedSessionIds.push(sessionId)
|
closedSessionIds.push(sessionId)
|
||||||
@@ -450,7 +451,7 @@ describe("TmuxPollingManager overlap", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
//#when
|
//#when
|
||||||
const pollSessions = (manager as unknown as { pollSessions: () => Promise<void> }).pollSessions
|
const pollSessions = unsafeTestValue<{ pollSessions: () => Promise<void> }>(manager).pollSessions
|
||||||
await pollSessions.call(manager)
|
await pollSessions.call(manager)
|
||||||
await pollSessions.call(manager)
|
await pollSessions.call(manager)
|
||||||
await pollSessions.call(manager)
|
await pollSessions.call(manager)
|
||||||
|
|||||||
@@ -115,21 +115,23 @@ describe("spawnTmuxPane runner integration", () => {
|
|||||||
expect(result).toEqual({ success: true, paneId: "%42" })
|
expect(result).toEqual({ success: true, paneId: "%42" })
|
||||||
expect(firstCall[1].slice(0, 8)).toEqual(["split-window", "-h", "-d", "-P", "-F", "#{pane_id}", "-t", "%0"])
|
expect(firstCall[1].slice(0, 8)).toEqual(["split-window", "-h", "-d", "-P", "-F", "#{pane_id}", "-t", "%0"])
|
||||||
expect(secondCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
expect(secondCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
||||||
expect(getSplitWindowCommand()).toContain(` --dir '${directory}'`)
|
expect(getSplitWindowCommand()).toContain("Focus this pane to attach.")
|
||||||
|
expect(getSplitWindowCommand()).toContain("tail -f /dev/null")
|
||||||
|
expect(getSplitWindowCommand()).not.toContain("opencode attach")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given directory with spaces #when spawnTmuxPane called #then wraps --dir value in single quotes", async () => {
|
it("#given description with spaces #when spawnTmuxPane called #then includes it in the placeholder", async () => {
|
||||||
// given
|
// given
|
||||||
const spawnTmuxPane = await loadSpawnTmuxPane()
|
const spawnTmuxPane = await loadSpawnTmuxPane()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", "-h", createDeps())
|
await spawnTmuxPane("session-1", "worker with spaces", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", "-h", createDeps())
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getSplitWindowCommand()).toContain("--dir '/path with spaces/here'")
|
expect(getSplitWindowCommand()).toContain("OMO subagent pane ready: worker with spaces")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given empty directory #when spawnTmuxPane called #then falls back to process cwd", async () => {
|
it("#given empty directory #when spawnTmuxPane called #then keeps the placeholder detached from attach", async () => {
|
||||||
// given
|
// given
|
||||||
const spawnTmuxPane = await loadSpawnTmuxPane()
|
const spawnTmuxPane = await loadSpawnTmuxPane()
|
||||||
|
|
||||||
@@ -137,17 +139,18 @@ describe("spawnTmuxPane runner integration", () => {
|
|||||||
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", "%0", "-h", createDeps())
|
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", "%0", "-h", createDeps())
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getSplitWindowCommand()).toContain(`--dir '${process.cwd()}'`)
|
expect(getSplitWindowCommand()).not.toContain("--dir")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given directory with single quotes #when spawnTmuxPane called #then escapes the value with POSIX-safe single quoting", async () => {
|
it("#given description with shell metacharacters #when spawnTmuxPane called #then escapes the placeholder", async () => {
|
||||||
// given
|
// given
|
||||||
const spawnTmuxPane = await loadSpawnTmuxPane()
|
const spawnTmuxPane = await loadSpawnTmuxPane()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
await spawnTmuxPane("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", "-h", createDeps())
|
await spawnTmuxPane("session-1", 'worker "$(whoami)"', enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", "-h", createDeps())
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(getSplitWindowCommand()).toContain("--dir '/path/with'\\''quote'")
|
expect(getSplitWindowCommand()).toContain('\\"')
|
||||||
|
expect(getSplitWindowCommand()).toContain("\\$")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -102,21 +102,23 @@ describe("spawnTmuxSession runner integration", () => {
|
|||||||
expect(newSessionCall[1].slice(0, 4)).toEqual(["new-session", "-d", "-s", newSessionCall[1][3]])
|
expect(newSessionCall[1].slice(0, 4)).toEqual(["new-session", "-d", "-s", newSessionCall[1][3]])
|
||||||
expect(String(newSessionCall[1][3]).startsWith("omo-agents-")).toBe(true)
|
expect(String(newSessionCall[1][3]).startsWith("omo-agents-")).toBe(true)
|
||||||
expect(selectPaneCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
expect(selectPaneCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
||||||
expect(harness.getSpawnCommand()).toContain(` --dir '${directory}'`)
|
expect(harness.getSpawnCommand()).toContain("Focus this pane to attach.")
|
||||||
|
expect(harness.getSpawnCommand()).toContain("tail -f /dev/null")
|
||||||
|
expect(harness.getSpawnCommand()).not.toContain("opencode attach")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given directory with spaces #when spawnTmuxSession called #then wraps --dir value in single quotes", async () => {
|
it("#given description with spaces #when spawnTmuxSession called #then includes it in the placeholder", async () => {
|
||||||
// given
|
// given
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", harness.deps)
|
await spawnTmuxSession("session-1", "worker with spaces", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", "%0", harness.deps)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(harness.getSpawnCommand()).toContain("--dir '/path with spaces/here'")
|
expect(harness.getSpawnCommand()).toContain("OMO subagent pane ready: worker with spaces")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given empty directory #when spawnTmuxSession called #then falls back to process cwd", async () => {
|
it("#given empty directory #when spawnTmuxSession called #then keeps the placeholder detached from attach", async () => {
|
||||||
// given
|
// given
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
|
|
||||||
@@ -124,17 +126,18 @@ describe("spawnTmuxSession runner integration", () => {
|
|||||||
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", "%0", harness.deps)
|
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", "%0", harness.deps)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(harness.getSpawnCommand()).toContain(`--dir '${process.cwd()}'`)
|
expect(harness.getSpawnCommand()).not.toContain("--dir")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given directory with single quotes #when spawnTmuxSession called #then escapes the value with POSIX-safe single quoting", async () => {
|
it("#given description with shell metacharacters #when spawnTmuxSession called #then escapes the placeholder", async () => {
|
||||||
// given
|
// given
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
await spawnTmuxSession("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", harness.deps)
|
await spawnTmuxSession("session-1", 'worker "$(whoami)"', enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", "%0", harness.deps)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(harness.getSpawnCommand()).toContain("--dir '/path/with'\\''quote'")
|
expect(harness.getSpawnCommand()).toContain('\\"')
|
||||||
|
expect(harness.getSpawnCommand()).toContain("\\$")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -90,21 +90,23 @@ describe("spawnTmuxWindow runner integration", () => {
|
|||||||
expect(result).toEqual({ success: true, paneId: "%42" })
|
expect(result).toEqual({ success: true, paneId: "%42" })
|
||||||
expect(firstCall[1].slice(0, 7)).toEqual(["new-window", "-d", "-n", "omo-agents", "-P", "-F", "#{pane_id}"])
|
expect(firstCall[1].slice(0, 7)).toEqual(["new-window", "-d", "-n", "omo-agents", "-P", "-F", "#{pane_id}"])
|
||||||
expect(secondCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
expect(secondCall[1]).toEqual(["select-pane", "-t", "%42", "-T", "omo-subagent-worker"])
|
||||||
expect(harness.getNewWindowCommand()).toContain(` --dir '${directory}'`)
|
expect(harness.getNewWindowCommand()).toContain("Focus this pane to attach.")
|
||||||
|
expect(harness.getNewWindowCommand()).toContain("tail -f /dev/null")
|
||||||
|
expect(harness.getNewWindowCommand()).not.toContain("opencode attach")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given directory with spaces #when spawnTmuxWindow called #then wraps --dir value in single quotes", async () => {
|
it("#given description with spaces #when spawnTmuxWindow called #then includes it in the placeholder", async () => {
|
||||||
// given
|
// given
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", harness.deps)
|
await spawnTmuxWindow("session-1", "worker with spaces", enabledTmuxConfig, "http://127.0.0.1:1234", "/path with spaces/here", harness.deps)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(harness.getNewWindowCommand()).toContain("--dir '/path with spaces/here'")
|
expect(harness.getNewWindowCommand()).toContain("OMO subagent pane ready: worker with spaces")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given empty directory #when spawnTmuxWindow called #then falls back to process cwd", async () => {
|
it("#given empty directory #when spawnTmuxWindow called #then keeps the placeholder detached from attach", async () => {
|
||||||
// given
|
// given
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
|
|
||||||
@@ -112,17 +114,18 @@ describe("spawnTmuxWindow runner integration", () => {
|
|||||||
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", harness.deps)
|
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "", harness.deps)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(harness.getNewWindowCommand()).toContain(`--dir '${process.cwd()}'`)
|
expect(harness.getNewWindowCommand()).not.toContain("--dir")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given directory with single quotes #when spawnTmuxWindow called #then escapes the value with POSIX-safe single quoting", async () => {
|
it("#given description with shell metacharacters #when spawnTmuxWindow called #then escapes the placeholder", async () => {
|
||||||
// given
|
// given
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
|
|
||||||
// when
|
// when
|
||||||
await spawnTmuxWindow("session-1", "worker", enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", harness.deps)
|
await spawnTmuxWindow("session-1", 'worker "$(whoami)"', enabledTmuxConfig, "http://127.0.0.1:1234", "/path/with'quote", harness.deps)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(harness.getNewWindowCommand()).toContain("--dir '/path/with'\\''quote'")
|
expect(harness.getNewWindowCommand()).toContain('\\"')
|
||||||
|
expect(harness.getNewWindowCommand()).toContain("\\$")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user