Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 4574a98

Browse files
committed
refactor: remove ai clutter
1 parent a96ad27 commit 4574a98

6 files changed

Lines changed: 1045 additions & 1507 deletions

File tree

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,8 @@
33
*/
44

55
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"
6-
import type { PluginContext, Todo, LoopEvent } from "../types.js"
7-
import { createTaskContinuation } from "../task-continuation.js"
8-
9-
interface PromptCall {
10-
body: {
11-
agent?: string
12-
model?: string
13-
parts: Array<{
14-
ignored?: boolean
15-
text: string
16-
}>
17-
}
18-
}
6+
import type { PluginContext, Todo, LoopEvent, PromptCall } from "../types.js"
7+
import { createTaskContinuation } from "../index.ts"
198

209
// Create a mock context
2110
function createMockContext(): PluginContext {
@@ -145,32 +134,6 @@ describe("TaskContinuation", () => {
145134
expect(taskContinuation).toBeDefined()
146135
})
147136

148-
it("should send completion message when all todos are complete", async () => {
149-
const ctx = createMockContext()
150-
const mockTodoFn = ctx.client.session.todo as unknown as {
151-
mockResolvedValue: (val: Todo[]) => void
152-
}
153-
mockTodoFn.mockResolvedValue(createMockTodos(3, 0))
154-
155-
const taskContinuation = createTaskContinuation(ctx)
156-
await taskContinuation.handler({ event: createIdleEvent("session-123") })
157-
158-
// Should send a completion status message (ignored: true)
159-
expect(ctx.client.session.prompt).toHaveBeenCalled()
160-
interface PromptCall {
161-
body: {
162-
parts: Array<{
163-
ignored?: boolean
164-
text: string
165-
}>
166-
}
167-
}
168-
const promptCall = (ctx.client.session.prompt as any).mock.calls[0][0] as PromptCall
169-
const call: PromptCall = promptCall
170-
expect(call.body.parts[0].ignored).toBe(true)
171-
expect(call.body.parts[0].text).toContain("completed")
172-
})
173-
174137
it("should inject continuation when incomplete todos remain", async () => {
175138
const ctx = createMockContext()
176139
const mockTodoFn = ctx.client.session.todo as unknown as {
@@ -346,38 +309,6 @@ describe("TaskContinuation", () => {
346309
expect(promptCall.body.model).toBe("configured-model")
347310
})
348311

349-
it("should use tracked agent/model for completion message", async () => {
350-
const ctx = createMockContext()
351-
const mockTodoFn = ctx.client.session.todo as unknown as {
352-
mockResolvedValue: (val: Todo[]) => void
353-
}
354-
// All tasks completed
355-
mockTodoFn.mockResolvedValue(createMockTodos(3, 0))
356-
357-
const taskContinuation = createTaskContinuation(ctx, {
358-
agent: "configured-agent",
359-
model: "configured-model",
360-
})
361-
362-
// Simulate a user message with a specific agent/model
363-
const userMessageEvent = createUserMessageEventWithAgentModel(
364-
"session-123",
365-
"user-agent",
366-
"user-model"
367-
)
368-
await taskContinuation.handler({ event: userMessageEvent })
369-
370-
// Trigger a session idle event (all tasks are completed)
371-
await taskContinuation.handler({ event: createIdleEvent("session-123") })
372-
373-
// Verify that the completion message used the user message agent/model
374-
expect(ctx.client.session.prompt).toHaveBeenCalled()
375-
const promptCall = (ctx.client.session.prompt as any).mock.calls[0][0] as PromptCall
376-
expect(promptCall.body.agent).toBe("user-agent")
377-
expect(promptCall.body.model).toBe("user-model")
378-
expect(promptCall.body.parts[0].ignored).toBe(true)
379-
})
380-
381312
// ===========================================================================
382313
// Regression Tests: Message Filtering for Countdown Cancellation
383314
// These tests prevent the bug where message updates incorrectly cancelled countdowns

0 commit comments

Comments
 (0)