Skip to content

The open-source app everyone uses to manage agents at work

Reset sessions for comment-triggered wakeups

Dotta944263f44beb
diff --git a/server/src/__tests__/heartbeat-workspace-session.test.ts b/server/src/__tests__/heartbeat-workspace-session.test.ts
index f36698c470..67536fe99f 100644
--- a/server/src/__tests__/heartbeat-workspace-session.test.ts
+++ b/server/src/__tests__/heartbeat-workspace-session.test.ts
@@ -93,8 +93,26 @@ describe("shouldResetTaskSessionForWake", () => {
expect(shouldResetTaskSessionForWake({ wakeReason: "issue_assigned" })).toBe(true);
});
+ it("resets session context on mention wake comment", () => {
+ expect(
+ shouldResetTaskSessionForWake({
+ wakeReason: "issue_comment_mentioned",
+ wakeCommentId: "comment-1",
+ }),
+ ).toBe(true);
+ });
+
+ it("resets session context when commentId is present", () => {
+ expect(
+ shouldResetTaskSessionForWake({
+ wakeReason: "issue_commented",
+ commentId: "comment-2",
+ }),
+ ).toBe(true);
+ });
+
it("does not reset for comment wakes", () => {
- expect(shouldResetTaskSessionForWake({ wakeReason: "issue_comment_mentioned" })).toBe(false);
+ expect(shouldResetTaskSessionForWake({ wakeReason: "issue_commented" })).toBe(false);
});
it("does not reset when wake reason is missing", () => {
diff --git a/server/src/services/heartbeat.ts b/server/src/services/heartbeat.ts
index 88155bbcac..3ea9421ffc 100644
--- a/server/src/services/heartbeat.ts
+++ b/server/src/services/heartbeat.ts
@@ -199,7 +199,11 @@ export function shouldResetTaskSessionForWake(
contextSnapshot: Record<string, unknown> | null | undefined,
) {
const wakeReason = readNonEmptyString(contextSnapshot?.wakeReason);
- return wakeReason === "issue_assigned";
+ if (wakeReason === "issue_assigned") return true;
+ const wakeCommentId =
+ readNonEmptyString(contextSnapshot?.wakeCommentId) ??
+ readNonEmptyString(contextSnapshot?.commentId);
+ return wakeCommentId != null;
}
function deriveCommentId(