Unverified 提交 ceb61118 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

fix: add missing createdAt to mid-turn compaction test messages (#2624)

## Summary - Two mid-turn compaction tests in `local_agent_handler.test.ts` were failing because mock messages lacked `createdAt` fields - `buildChatMessageHistory` and `getMidTurnCompactionSummaryIds` call `createdAt.getTime()` to detect mid-turn compaction summaries, causing a silent TypeError inside the async generator - Added `createdAt` timestamps to all mock messages and compaction summary messages in both tests ## Test plan - [x] `npm test` passes (786/786 tests) - [x] Both previously-failing mid-turn compaction tests now pass - [x] Lint, formatting, and type checks all pass #skip-bugbot 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2624" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix failing mid-turn compaction tests by adding createdAt timestamps to mocked chat and summary messages. This prevents a silent TypeError in the async generator and restores test reliability. - **Bug Fixes** - Added createdAt to all test messages (including compaction summaries) so buildChatMessageHistory and getMidTurnCompactionSummaryIds can safely call createdAt.getTime(). - Documented the createdAt requirement for compaction tests in AGENTS.md. <sup>Written for commit c8f0acb09058c5e3313f1423c585857ea61416f4. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
上级 2ebe6208
...@@ -452,12 +452,21 @@ describe("handleLocalAgentStream", () => { ...@@ -452,12 +452,21 @@ describe("handleLocalAgentStream", () => {
// Arrange // Arrange
const { event, getMessagesByChannel } = createFakeEvent(); const { event, getMessagesByChannel } = createFakeEvent();
mockSettings = buildTestSettings({ enableDyadPro: true }); mockSettings = buildTestSettings({ enableDyadPro: true });
const t0 = new Date("2025-01-01T00:00:00Z");
const t1 = new Date("2025-01-01T00:01:00Z");
const t2 = new Date("2025-01-01T00:02:00Z");
const t3 = new Date("2025-01-01T00:03:00Z");
mockChatData = buildTestChat({ mockChatData = buildTestChat({
messages: [ messages: [
{ id: 1, role: "user", content: "old context user" }, { id: 1, role: "user", content: "old context user", createdAt: t0 },
{ id: 2, role: "assistant", content: "old context assistant" }, {
{ id: 3, role: "user", content: "current task" }, id: 2,
{ id: 10, role: "assistant", content: "" }, // placeholder role: "assistant",
content: "old context assistant",
createdAt: t1,
},
{ id: 3, role: "user", content: "current task", createdAt: t2 },
{ id: 10, role: "assistant", content: "", createdAt: t3 }, // placeholder
], ],
}); });
...@@ -480,6 +489,7 @@ describe("handleLocalAgentStream", () => { ...@@ -480,6 +489,7 @@ describe("handleLocalAgentStream", () => {
content: content:
'<dyad-compaction title="Conversation compacted" state="finished">mid-turn summary</dyad-compaction>', '<dyad-compaction title="Conversation compacted" state="finished">mid-turn summary</dyad-compaction>',
isCompactionSummary: true, isCompactionSummary: true,
createdAt: new Date("2025-01-01T00:03:30Z"),
}, },
], ],
} as any; } as any;
...@@ -607,12 +617,21 @@ describe("handleLocalAgentStream", () => { ...@@ -607,12 +617,21 @@ describe("handleLocalAgentStream", () => {
// Arrange // Arrange
const { event } = createFakeEvent(); const { event } = createFakeEvent();
mockSettings = buildTestSettings({ enableDyadPro: true }); mockSettings = buildTestSettings({ enableDyadPro: true });
const t0 = new Date("2025-01-01T00:00:00Z");
const t1 = new Date("2025-01-01T00:01:00Z");
const t2 = new Date("2025-01-01T00:02:00Z");
const t3 = new Date("2025-01-01T00:03:00Z");
mockChatData = buildTestChat({ mockChatData = buildTestChat({
messages: [ messages: [
{ id: 1, role: "user", content: "old context user" }, { id: 1, role: "user", content: "old context user", createdAt: t0 },
{ id: 2, role: "assistant", content: "old context assistant" }, {
{ id: 3, role: "user", content: "current task" }, id: 2,
{ id: 10, role: "assistant", content: "" }, // placeholder role: "assistant",
content: "old context assistant",
createdAt: t1,
},
{ id: 3, role: "user", content: "current task", createdAt: t2 },
{ id: 10, role: "assistant", content: "", createdAt: t3 }, // placeholder
], ],
}); });
...@@ -635,6 +654,7 @@ describe("handleLocalAgentStream", () => { ...@@ -635,6 +654,7 @@ describe("handleLocalAgentStream", () => {
content: content:
'<dyad-compaction title="Conversation compacted" state="finished">mid-turn summary</dyad-compaction>', '<dyad-compaction title="Conversation compacted" state="finished">mid-turn summary</dyad-compaction>',
isCompactionSummary: true, isCompactionSummary: true,
createdAt: new Date("2025-01-01T00:03:30Z"),
}, },
], ],
} as any; } as any;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论