Skip to content

Commit 43dbee0

Browse files
rm test noise
1 parent 5182362 commit 43dbee0

2 files changed

Lines changed: 36 additions & 214 deletions

File tree

tests/compress-message.test.ts

Lines changed: 36 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { join } from "node:path"
44
import { tmpdir } from "node:os"
55
import { mkdirSync } from "node:fs"
66
import { createCompressMessageTool } from "../lib/compress/message"
7-
import { createEventHandler } from "../lib/hooks"
87
import { createSessionState, type WithParts } from "../lib/state"
98
import type { PluginConfig } from "../lib/config"
109
import { Logger } from "../lib/logger"
@@ -232,120 +231,48 @@ test("compress message mode stores call id for later duration attachment", async
232231
const rawMessages = buildMessages(sessionID)
233232
const state = createSessionState()
234233
const logger = new Logger(false)
235-
const handler = createEventHandler(state, logger)
236-
const originalNow = Date.now
237-
Date.now = () => 100
238-
239-
try {
240-
await handler({
241-
event: {
242-
type: "message.part.updated",
243-
properties: {
244-
part: {
245-
type: "tool",
246-
tool: "compress",
247-
callID: "call-1",
248-
messageID: "msg-compress-message",
249-
sessionID,
250-
state: {
251-
status: "pending",
252-
input: {},
253-
raw: "",
254-
},
255-
},
256-
},
257-
},
258-
})
259-
260-
await handler({
261-
event: {
262-
type: "message.part.updated",
263-
properties: {
264-
part: {
265-
type: "tool",
266-
tool: "compress",
267-
callID: "call-1",
268-
messageID: "msg-compress-message",
269-
sessionID,
270-
state: {
271-
status: "running",
272-
input: {},
273-
time: { start: 325 },
274-
},
275-
},
276-
},
277-
},
278-
})
279234

280-
const tool = createCompressMessageTool({
281-
client: {
282-
session: {
283-
messages: async () => ({ data: rawMessages }),
284-
get: async () => ({ data: { parentID: null } }),
285-
},
235+
const tool = createCompressMessageTool({
236+
client: {
237+
session: {
238+
messages: async () => ({ data: rawMessages }),
239+
get: async () => ({ data: { parentID: null } }),
286240
},
287-
state,
288-
logger,
289-
config: buildConfig(),
290-
prompts: {
291-
reload() {},
292-
getRuntimePrompts() {
293-
return { compressMessage: "", compressRange: "" }
294-
},
241+
},
242+
state,
243+
logger,
244+
config: buildConfig(),
245+
prompts: {
246+
reload() {},
247+
getRuntimePrompts() {
248+
return { compressMessage: "", compressRange: "" }
295249
},
296-
} as any)
250+
},
251+
} as any)
297252

298-
await tool.execute(
299-
{
300-
topic: "Batch stale notes",
301-
content: [
302-
{
303-
messageId: "m0002",
304-
topic: "Code path note",
305-
summary: "Captured the assistant's code-path findings.",
306-
},
307-
],
308-
},
309-
{
310-
ask: async () => {},
311-
metadata: () => {},
312-
sessionID,
313-
messageID: "msg-compress-message",
314-
callID: "call-1",
315-
},
316-
)
317-
318-
const block = Array.from(state.prune.messages.blocksById.values())[0]
319-
assert.equal(block?.compressCallId, "call-1")
320-
assert.equal(block?.durationMs, 0)
321-
322-
await handler({
323-
event: {
324-
type: "message.part.updated",
325-
properties: {
326-
part: {
327-
type: "tool",
328-
tool: "compress",
329-
callID: "call-1",
330-
messageID: "msg-compress-message",
331-
sessionID,
332-
state: {
333-
status: "completed",
334-
input: {},
335-
output: "done",
336-
title: "",
337-
metadata: {},
338-
time: { start: 325, end: 400 },
339-
},
340-
},
253+
await tool.execute(
254+
{
255+
topic: "Batch stale notes",
256+
content: [
257+
{
258+
messageId: "m0002",
259+
topic: "Code path note",
260+
summary: "Captured the assistant's code-path findings.",
341261
},
342-
},
343-
})
262+
],
263+
},
264+
{
265+
ask: async () => {},
266+
metadata: () => {},
267+
sessionID,
268+
messageID: "msg-compress-message",
269+
callID: "call-1",
270+
},
271+
)
344272

345-
assert.equal(block?.durationMs, 225)
346-
} finally {
347-
Date.now = originalNow
348-
}
273+
const block = Array.from(state.prune.messages.blocksById.values())[0]
274+
assert.equal(block?.compressCallId, "call-1")
275+
assert.equal(block?.durationMs, 0)
349276
})
350277

351278
test("compress message mode does not partially apply when preparation fails", async () => {

tests/hooks-permission.test.ts

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -154,63 +154,6 @@ test("text complete strips hallucinated metadata tags", async () => {
154154
assert.equal(output.text, "alpha omega")
155155
})
156156

157-
test("event hook records compression start timing", async () => {
158-
const state = createSessionState()
159-
state.sessionId = "session-1"
160-
const handler = createEventHandler(state, new Logger(false))
161-
const originalNow = Date.now
162-
Date.now = () => 100
163-
164-
try {
165-
await handler({
166-
event: {
167-
type: "message.part.updated",
168-
properties: {
169-
part: {
170-
type: "tool",
171-
tool: "compress",
172-
callID: "call-1",
173-
messageID: "message-1",
174-
sessionID: "session-1",
175-
state: {
176-
status: "pending",
177-
input: {},
178-
raw: "",
179-
},
180-
},
181-
},
182-
},
183-
})
184-
185-
await handler({
186-
event: {
187-
type: "message.part.updated",
188-
properties: {
189-
part: {
190-
type: "tool",
191-
tool: "compress",
192-
callID: "call-1",
193-
messageID: "message-1",
194-
sessionID: "session-1",
195-
state: {
196-
status: "running",
197-
input: { topic: "x" },
198-
time: { start: 325 },
199-
},
200-
},
201-
},
202-
},
203-
})
204-
} finally {
205-
Date.now = originalNow
206-
}
207-
208-
assert.deepEqual(state.compressionStarts.get("call-1"), {
209-
messageId: "message-1",
210-
startedAt: 100,
211-
})
212-
})
213-
214157
test("event hook attaches durations to matching blocks by call id", async () => {
215158
const state = createSessionState()
216159
state.sessionId = "session-1"
@@ -461,51 +404,3 @@ test("event hook falls back to completed runtime when running duration missing",
461404

462405
assert.equal(state.prune.messages.blocksById.get(1)?.durationMs, 440)
463406
})
464-
465-
test("event hook ignores non-compress tool parts", async () => {
466-
const state = createSessionState()
467-
state.sessionId = "session-1"
468-
const handler = createEventHandler(state, new Logger(false))
469-
470-
await handler({
471-
event: {
472-
type: "message.part.updated",
473-
properties: {
474-
part: {
475-
type: "tool",
476-
tool: "bash",
477-
callID: "call-2",
478-
messageID: "message-2",
479-
sessionID: "session-1",
480-
state: {
481-
status: "pending",
482-
input: {},
483-
raw: "",
484-
},
485-
},
486-
},
487-
},
488-
})
489-
490-
await handler({
491-
event: {
492-
type: "message.part.updated",
493-
properties: {
494-
part: {
495-
type: "tool",
496-
tool: "bash",
497-
callID: "call-2",
498-
messageID: "message-2",
499-
sessionID: "session-1",
500-
state: {
501-
status: "running",
502-
input: {},
503-
time: { start: 220 },
504-
},
505-
},
506-
},
507-
},
508-
})
509-
510-
assert.equal(state.compressionStarts.size, 0)
511-
})

0 commit comments

Comments
 (0)