mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 11:04:35 +00:00
Use exhaustive switch on message.role throughout coding-agent
- addMessageToChat: exhaustive switch for all AgentMessage roles - renderSessionContext: delegates to addMessageToChat, special handling for assistant tool calls and tool results - export-html formatMessage: exhaustive switch for all AgentMessage roles - Removed isHookMessage, isBashExecutionMessage type guards in favor of role checks - Fixed imports and removed unused getLatestCompactionEntry
This commit is contained in:
parent
ecef601d19
commit
b921298af7
11 changed files with 442 additions and 376 deletions
|
|
@ -16,7 +16,6 @@ import {
|
|||
import {
|
||||
buildSessionContext,
|
||||
type CompactionEntry,
|
||||
createSummaryMessage,
|
||||
type ModelChangeEntry,
|
||||
migrateSessionEntries,
|
||||
parseSessionEntries,
|
||||
|
|
@ -272,21 +271,6 @@ describe("findCutPoint", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("createSummaryMessage", () => {
|
||||
it("should create user message with prefix and correct timestamp", () => {
|
||||
const ts = "2025-01-01T12:00:00.000Z";
|
||||
const msg = createSummaryMessage("This is the summary", ts);
|
||||
expect(msg.role).toBe("user");
|
||||
expect(msg.timestamp).toBe(new Date(ts).getTime());
|
||||
if (msg.role === "user") {
|
||||
expect(msg.content).toContain(
|
||||
"The conversation history before this point was compacted into the following summary:",
|
||||
);
|
||||
expect(msg.content).toContain("This is the summary");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildSessionContext", () => {
|
||||
it("should load all messages when no compaction", () => {
|
||||
const entries: SessionEntry[] = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue