refactor(athena): rename session_handoff to switch_agent to avoid confusion with /handoff command
Rename across all layers to eliminate naming ambiguity: - Tool: session_handoff → switch_agent - Hook: agent-handoff → agent-switch - Feature: agent-handoff/ → agent-switch/ - Types: SessionHandoffArgs → SwitchAgentArgs, PendingHandoff → PendingSwitch - Functions: setPendingHandoff → setPendingSwitch, consumePendingHandoff → consumePendingSwitch /handoff = inter-session context summary (existing command) switch_agent = intra-session active agent change (our new tool)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, test, expect, beforeEach } from "bun:test"
|
||||
import { setPendingSwitch, consumePendingSwitch, _resetForTesting } from "./state"
|
||||
|
||||
describe("agent-switch state", () => {
|
||||
beforeEach(() => {
|
||||
_resetForTesting()
|
||||
})
|
||||
|
||||
//#given a pending switch is set
|
||||
//#when consumePendingSwitch is called
|
||||
//#then it returns the switch and removes it
|
||||
test("should store and consume a pending switch", () => {
|
||||
setPendingSwitch("session-1", "atlas", "Fix these findings")
|
||||
|
||||
const entry = consumePendingSwitch("session-1")
|
||||
|
||||
expect(entry).toEqual({ agent: "atlas", context: "Fix these findings" })
|
||||
expect(consumePendingSwitch("session-1")).toBeUndefined()
|
||||
})
|
||||
|
||||
//#given no pending switch exists
|
||||
//#when consumePendingSwitch is called
|
||||
//#then it returns undefined
|
||||
test("should return undefined when no switch is pending", () => {
|
||||
expect(consumePendingSwitch("session-1")).toBeUndefined()
|
||||
})
|
||||
|
||||
//#given a pending switch is set
|
||||
//#when a new switch is set for the same session
|
||||
//#then the latest switch wins
|
||||
test("should overwrite previous switch for same session", () => {
|
||||
setPendingSwitch("session-1", "atlas", "Fix A")
|
||||
setPendingSwitch("session-1", "prometheus", "Plan B")
|
||||
|
||||
const entry = consumePendingSwitch("session-1")
|
||||
|
||||
expect(entry).toEqual({ agent: "prometheus", context: "Plan B" })
|
||||
})
|
||||
|
||||
//#given switches for different sessions
|
||||
//#when consumed separately
|
||||
//#then each session gets its own switch
|
||||
test("should isolate switches by session", () => {
|
||||
setPendingSwitch("session-1", "atlas", "Fix A")
|
||||
setPendingSwitch("session-2", "prometheus", "Plan B")
|
||||
|
||||
expect(consumePendingSwitch("session-1")).toEqual({ agent: "atlas", context: "Fix A" })
|
||||
expect(consumePendingSwitch("session-2")).toEqual({ agent: "prometheus", context: "Plan B" })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user