feat(KB-622): unify steeringComments and comments into single field
- Add database migration to merge steeringComments into comments field - Update SQLite schema and queries to use unified comments column - Refactor TaskStore to handle single comments field instead of dual fields - Update dashboard components (SteeringTab, TaskCard) for unified comments - Update engine executor and PR comment handler for new field structure - Remove deprecated steeringComments from types and interfaces
This commit is contained in:
@@ -1631,7 +1631,7 @@ describe("buildExecutionPrompt", () => {
|
||||
expect(result).toContain("## Comments");
|
||||
expect(result).toContain("**user**");
|
||||
expect(result).toContain("> Please handle the edge case");
|
||||
expect(result).toContain("The following comments were added by the user");
|
||||
expect(result).toContain("The following comments were added during execution");
|
||||
});
|
||||
|
||||
it("formats multiple comments correctly", () => {
|
||||
@@ -1675,14 +1675,14 @@ describe("buildExecutionPrompt", () => {
|
||||
});
|
||||
|
||||
it("includes only the 10 most recent comments", () => {
|
||||
const steeringComments = Array.from({ length: 15 }, (_, i) => ({
|
||||
const comments = Array.from({ length: 15 }, (_, i) => ({
|
||||
id: `${i}`,
|
||||
text: `Comment ${i}`,
|
||||
createdAt: new Date().toISOString(),
|
||||
author: "user" as const,
|
||||
}));
|
||||
|
||||
const task = createMockTaskDetail({ steeringComments });
|
||||
const task = createMockTaskDetail({ comments });
|
||||
const result = buildExecutionPrompt(task);
|
||||
|
||||
// Should include comments 5-14 (the 10 most recent), not 0-4
|
||||
@@ -1725,7 +1725,7 @@ describe("buildExecutionPrompt", () => {
|
||||
expect(result).toContain("## Comments");
|
||||
|
||||
// Verify explanatory header text
|
||||
expect(result).toContain("The following comments were added by the user during execution");
|
||||
expect(result).toContain("The following comments were added during execution");
|
||||
expect(result).toContain("Consider adjusting your approach or replanning remaining steps based on this feedback");
|
||||
|
||||
// Verify all three comments appear with correct author badges
|
||||
|
||||
@@ -237,21 +237,21 @@ export class TaskExecutor {
|
||||
// Mark as seen BEFORE attempting injection to prevent retry loops on failure
|
||||
seenSteeringIds.add(comment.id);
|
||||
|
||||
// Format and inject the steering comment
|
||||
const steeringMessage = formatSteeringCommentForInjection(comment);
|
||||
// Format and inject the comment
|
||||
const commentMessage = formatCommentForInjection(comment);
|
||||
try {
|
||||
executorLog.log(`Injecting steering comment into ${task.id}: ${summary}`);
|
||||
await session.steer(steeringMessage);
|
||||
executorLog.log(`Successfully injected steering comment into ${task.id}`);
|
||||
executorLog.log(`Injecting comment into ${task.id}: ${summary}`);
|
||||
await session.steer(commentMessage);
|
||||
executorLog.log(`Successfully injected comment into ${task.id}`);
|
||||
|
||||
// Log to the task that steering was received
|
||||
// Log to the task that comment was received
|
||||
await this.store.logEntry(
|
||||
task.id,
|
||||
`Steering comment received mid-execution: ${summary}`,
|
||||
`Comment received mid-execution: ${summary}`,
|
||||
`by ${comment.author}`
|
||||
);
|
||||
} catch (err) {
|
||||
executorLog.error(`Failed to inject steering comment for ${task.id}:`, err);
|
||||
executorLog.error(`Failed to inject comment for ${task.id}:`, err);
|
||||
// Comment is already marked as seen - we won't retry to avoid spamming
|
||||
// the agent with failed injections. The error is logged for debugging.
|
||||
}
|
||||
@@ -551,10 +551,10 @@ export class TaskExecutor {
|
||||
sessionRef.current = session;
|
||||
|
||||
// Register session so the pause listener can terminate it
|
||||
// Initialize with empty set of seen steering comments
|
||||
// Initialize with empty set of seen comments
|
||||
const seenSteeringIds = new Set<string>();
|
||||
if (detail.steeringComments) {
|
||||
for (const comment of detail.steeringComments) {
|
||||
if (detail.comments) {
|
||||
for (const comment of detail.comments) {
|
||||
seenSteeringIds.add(comment.id);
|
||||
}
|
||||
}
|
||||
@@ -1874,10 +1874,10 @@ When all steps are complete: call \`task_done()\``;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a steering comment for injection into a running agent session.
|
||||
* Format a comment for injection into a running agent session.
|
||||
* Used for real-time steering during task execution.
|
||||
*/
|
||||
function formatSteeringCommentForInjection(comment: import("@fusion/core").SteeringComment): string {
|
||||
function formatCommentForInjection(comment: import("@fusion/core").TaskComment): string {
|
||||
const timestamp = formatTimestamp(comment.createdAt);
|
||||
return `📣 **New steering feedback** — ${timestamp} (${comment.author}):\n\n${comment.text}\n\nPlease adjust your approach based on this feedback.`;
|
||||
return `📣 **New feedback** — ${timestamp} (${comment.author}):\n\n${comment.text}\n\nPlease adjust your approach based on this feedback.`;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { PrCommentHandler } from "./pr-comment-handler.js";
|
||||
import type { TaskStore, Task } from "@fusion/core";
|
||||
|
||||
const mockStore = {
|
||||
addSteeringComment: vi.fn<(id: string, text: string, author?: "user" | "agent") => Promise<Task>>(),
|
||||
addComment: vi.fn<(id: string, text: string, author?: "user" | "agent") => Promise<Task>>(),
|
||||
createTask: vi.fn<(input: Parameters<TaskStore["createTask"]>[0]) => Promise<Task>>().mockResolvedValue({ id: "FN-123" } as Task),
|
||||
} as unknown as TaskStore;
|
||||
|
||||
@@ -49,7 +49,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(mockStore.addSteeringComment).not.toHaveBeenCalled();
|
||||
expect(mockStore.addComment).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(mockStore.addSteeringComment).toHaveBeenCalled();
|
||||
expect(mockStore.addComment).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(mockStore.addSteeringComment).toHaveBeenCalled();
|
||||
expect(mockStore.addComment).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("creates steering comment for inline code suggestions", async () => {
|
||||
@@ -109,7 +109,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(mockStore.addSteeringComment).toHaveBeenCalled();
|
||||
expect(mockStore.addComment).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -126,7 +126,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
const call = (mockStore.addSteeringComment as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
const call = (mockStore.addComment as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
const text = call[1] as string;
|
||||
|
||||
expect(text).toContain("PR Review Feedback");
|
||||
@@ -151,7 +151,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
const call = (mockStore.addSteeringComment as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
const call = (mockStore.addComment as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
const text = call[1] as string;
|
||||
|
||||
expect(text.length).toBeLessThan(longBody.length);
|
||||
@@ -170,7 +170,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(mockStore.addSteeringComment).toHaveBeenCalledWith(
|
||||
expect(mockStore.addComment).toHaveBeenCalledWith(
|
||||
"FN-001",
|
||||
expect.any(String),
|
||||
"agent"
|
||||
@@ -189,7 +189,7 @@ describe("PrCommentHandler", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
const text = (mockStore.addSteeringComment as ReturnType<typeof vi.fn>).mock.calls[0][1] as string;
|
||||
const text = (mockStore.addComment as ReturnType<typeof vi.fn>).mock.calls[0][1] as string;
|
||||
expect(text).toContain("This PR is already merged");
|
||||
expect(text).toContain("follow-up work");
|
||||
});
|
||||
|
||||
@@ -85,10 +85,10 @@ export class PrCommentHandler {
|
||||
const text = this.buildSteeringText(prInfo, comment, hasCodeSuggestions);
|
||||
|
||||
try {
|
||||
await this.store.addSteeringComment(taskId, text, "agent");
|
||||
prMonitorLog.log(`Added steering comment for PR review #${comment.id}`);
|
||||
await this.store.addComment(taskId, text, "agent");
|
||||
prMonitorLog.log(`Added comment for PR review #${comment.id}`);
|
||||
} catch (err) {
|
||||
prMonitorLog.error(`Failed to add steering comment for ${taskId}:`, err);
|
||||
prMonitorLog.error(`Failed to add comment for ${taskId}:`, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user