fix: prefer target entry for inline status

This commit is contained in:
Tak Hoffman
2026-04-10 21:08:02 -05:00
parent da1e60a6aa
commit 84fb20aa52
3 changed files with 56 additions and 4 deletions

View File

@@ -241,12 +241,13 @@ export async function applyInlineDirectiveOverrides(params: {
let statusReply: ReplyPayload | undefined;
if (directives.hasStatusDirective && allowTextCommands && command.isAuthorizedSender) {
const { buildStatusReply } = await loadCommandsStatus();
const targetSessionEntry = sessionStore[sessionKey] ?? sessionEntry;
statusReply = await buildStatusReply({
cfg,
command,
sessionEntry,
sessionEntry: targetSessionEntry,
sessionKey,
parentSessionKey: ctx.ParentSessionKey,
parentSessionKey: targetSessionEntry?.parentSessionKey ?? ctx.ParentSessionKey,
sessionScope,
storePath,
provider,

View File

@@ -259,6 +259,56 @@ describe("handleInlineActions", () => {
expect(handleCommandsMock).not.toHaveBeenCalled();
});
it("prefers the target session entry when routing inline status through the shared status builder", async () => {
const typing = createTypingController();
const ctx = buildTestCtx({
Body: "/status",
CommandBody: "/status",
ParentSessionKey: "ctx-parent",
});
const result = await handleInlineActions(
createHandleInlineActionsInput({
ctx,
typing,
cleanedBody: stripInlineStatus("/status").cleaned,
command: {
isAuthorizedSender: true,
rawBodyNormalized: "/status",
commandBodyNormalized: "/status",
},
overrides: {
allowTextCommands: true,
inlineStatusRequested: true,
sessionEntry: {
sessionId: "wrapper-session",
updatedAt: Date.now(),
parentSessionKey: "wrapper-parent",
} as SessionEntry,
sessionStore: {
"s:main": {
sessionId: "target-session",
updatedAt: Date.now(),
parentSessionKey: "target-parent",
} as SessionEntry,
},
},
}),
);
expect(result).toEqual({ kind: "reply", reply: undefined });
expect(buildStatusReplyMock).toHaveBeenCalledWith(
expect.objectContaining({
sessionEntry: expect.objectContaining({
sessionId: "target-session",
parentSessionKey: "target-parent",
}),
parentSessionKey: "target-parent",
}),
);
expect(handleCommandsMock).not.toHaveBeenCalled();
});
it("does not continue into the agent after a mention-wrapped inline status-only turn", async () => {
const typing = createTypingController();
const ctx = buildTestCtx({

View File

@@ -347,12 +347,13 @@ 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,
sessionEntry,
sessionEntry: targetSessionEntry,
sessionKey,
parentSessionKey: ctx.ParentSessionKey,
parentSessionKey: targetSessionEntry?.parentSessionKey ?? ctx.ParentSessionKey,
sessionScope,
storePath,
provider,