Skip to content

Commit 8f94032

Browse files
committed
fix: prefer target entry for inline abort cutoff
1 parent f1b6934 commit 8f94032

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,43 @@ describe("handleInlineActions", () => {
419419
expect(handleCommandsMock).not.toHaveBeenCalled();
420420
});
421421

422+
it("prefers the target session entry for inline /stop cutoff checks", async () => {
423+
const typing = createTypingController();
424+
const wrapperSessionEntry: SessionEntry = {
425+
sessionId: "wrapper-session",
426+
updatedAt: Date.now(),
427+
abortCutoffMessageSid: "40",
428+
abortedLastRun: true,
429+
};
430+
const targetSessionEntry: SessionEntry = {
431+
sessionId: "target-session",
432+
updatedAt: Date.now(),
433+
abortCutoffMessageSid: "42",
434+
abortedLastRun: true,
435+
};
436+
const ctx = buildTestCtx({
437+
Body: "old queued message",
438+
CommandBody: "old queued message",
439+
MessageSid: "41",
440+
});
441+
442+
await expectInlineActionSkipped({
443+
ctx,
444+
typing,
445+
cleanedBody: "old queued message",
446+
command: {
447+
rawBodyNormalized: "old queued message",
448+
commandBodyNormalized: "old queued message",
449+
},
450+
overrides: {
451+
sessionEntry: wrapperSessionEntry,
452+
sessionStore: {
453+
"s:main": targetSessionEntry,
454+
},
455+
},
456+
});
457+
});
458+
422459
it("rewrites Claude bundle markdown commands into a native agent prompt", async () => {
423460
const typing = createTypingController();
424461
handleCommandsMock.mockResolvedValue({ shouldContinue: false, reply: { text: "done" } });

src/auto-reply/reply/get-reply-inline-actions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ export async function handleInlineActions(params: {
297297
};
298298

299299
const isStopLikeInbound = isAbortRequestText(command.rawBodyNormalized);
300-
if (!isStopLikeInbound && sessionEntry) {
301-
const cutoff = readAbortCutoffFromSessionEntry(sessionEntry);
300+
const targetSessionEntry = sessionStore?.[sessionKey] ?? sessionEntry;
301+
if (!isStopLikeInbound && targetSessionEntry) {
302+
const cutoff = readAbortCutoffFromSessionEntry(targetSessionEntry);
302303
const incoming = resolveAbortCutoffFromContext(ctx);
303304
const shouldSkip = cutoff
304305
? shouldSkipMessageByAbortCutoff({
@@ -316,7 +317,7 @@ export async function handleInlineActions(params: {
316317
await (
317318
await import("./abort-cutoff.runtime.js")
318319
).clearAbortCutoffInSessionRuntime({
319-
sessionEntry,
320+
sessionEntry: targetSessionEntry,
320321
sessionStore,
321322
sessionKey,
322323
storePath,
@@ -347,7 +348,6 @@ export async function handleInlineActions(params: {
347348
let didSendInlineStatus = false;
348349
if (handleInlineStatus) {
349350
const { buildStatusReply } = await import("./commands.runtime.js");
350-
const targetSessionEntry = sessionStore?.[sessionKey] ?? sessionEntry;
351351
const inlineStatusReply = await buildStatusReply({
352352
cfg,
353353
command,

0 commit comments

Comments
 (0)