fix: prefer target entry for inline abort cutoff

This commit is contained in:
Tak Hoffman
2026-04-10 21:20:53 -05:00
parent f1b6934700
commit 8f94032dc1
2 changed files with 41 additions and 4 deletions

View File

@@ -419,6 +419,43 @@ describe("handleInlineActions", () => {
expect(handleCommandsMock).not.toHaveBeenCalled();
});
it("prefers the target session entry for inline /stop cutoff checks", async () => {
const typing = createTypingController();
const wrapperSessionEntry: SessionEntry = {
sessionId: "wrapper-session",
updatedAt: Date.now(),
abortCutoffMessageSid: "40",
abortedLastRun: true,
};
const targetSessionEntry: SessionEntry = {
sessionId: "target-session",
updatedAt: Date.now(),
abortCutoffMessageSid: "42",
abortedLastRun: true,
};
const ctx = buildTestCtx({
Body: "old queued message",
CommandBody: "old queued message",
MessageSid: "41",
});
await expectInlineActionSkipped({
ctx,
typing,
cleanedBody: "old queued message",
command: {
rawBodyNormalized: "old queued message",
commandBodyNormalized: "old queued message",
},
overrides: {
sessionEntry: wrapperSessionEntry,
sessionStore: {
"s:main": targetSessionEntry,
},
},
});
});
it("rewrites Claude bundle markdown commands into a native agent prompt", async () => {
const typing = createTypingController();
handleCommandsMock.mockResolvedValue({ shouldContinue: false, reply: { text: "done" } });

View File

@@ -297,8 +297,9 @@ export async function handleInlineActions(params: {
};
const isStopLikeInbound = isAbortRequestText(command.rawBodyNormalized);
if (!isStopLikeInbound && sessionEntry) {
const cutoff = readAbortCutoffFromSessionEntry(sessionEntry);
const targetSessionEntry = sessionStore?.[sessionKey] ?? sessionEntry;
if (!isStopLikeInbound && targetSessionEntry) {
const cutoff = readAbortCutoffFromSessionEntry(targetSessionEntry);
const incoming = resolveAbortCutoffFromContext(ctx);
const shouldSkip = cutoff
? shouldSkipMessageByAbortCutoff({
@@ -316,7 +317,7 @@ export async function handleInlineActions(params: {
await (
await import("./abort-cutoff.runtime.js")
).clearAbortCutoffInSessionRuntime({
sessionEntry,
sessionEntry: targetSessionEntry,
sessionStore,
sessionKey,
storePath,
@@ -347,7 +348,6 @@ export async function handleInlineActions(params: {
let didSendInlineStatus = false;
if (handleInlineStatus) {
const { buildStatusReply } = await import("./commands.runtime.js");
const targetSessionEntry = sessionStore?.[sessionKey] ?? sessionEntry;
const inlineStatusReply = await buildStatusReply({
cfg,
command,