Skip to content

Commit 84fb20a

Browse files
committed
fix: prefer target entry for inline status
1 parent da1e60a commit 84fb20a

3 files changed

Lines changed: 56 additions & 4 deletions

File tree

src/auto-reply/reply/get-reply-directives-apply.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ export async function applyInlineDirectiveOverrides(params: {
241241
let statusReply: ReplyPayload | undefined;
242242
if (directives.hasStatusDirective && allowTextCommands && command.isAuthorizedSender) {
243243
const { buildStatusReply } = await loadCommandsStatus();
244+
const targetSessionEntry = sessionStore[sessionKey] ?? sessionEntry;
244245
statusReply = await buildStatusReply({
245246
cfg,
246247
command,
247-
sessionEntry,
248+
sessionEntry: targetSessionEntry,
248249
sessionKey,
249-
parentSessionKey: ctx.ParentSessionKey,
250+
parentSessionKey: targetSessionEntry?.parentSessionKey ?? ctx.ParentSessionKey,
250251
sessionScope,
251252
storePath,
252253
provider,

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,56 @@ describe("handleInlineActions", () => {
259259
expect(handleCommandsMock).not.toHaveBeenCalled();
260260
});
261261

262+
it("prefers the target session entry when routing inline status through the shared status builder", async () => {
263+
const typing = createTypingController();
264+
const ctx = buildTestCtx({
265+
Body: "/status",
266+
CommandBody: "/status",
267+
ParentSessionKey: "ctx-parent",
268+
});
269+
270+
const result = await handleInlineActions(
271+
createHandleInlineActionsInput({
272+
ctx,
273+
typing,
274+
cleanedBody: stripInlineStatus("/status").cleaned,
275+
command: {
276+
isAuthorizedSender: true,
277+
rawBodyNormalized: "/status",
278+
commandBodyNormalized: "/status",
279+
},
280+
overrides: {
281+
allowTextCommands: true,
282+
inlineStatusRequested: true,
283+
sessionEntry: {
284+
sessionId: "wrapper-session",
285+
updatedAt: Date.now(),
286+
parentSessionKey: "wrapper-parent",
287+
} as SessionEntry,
288+
sessionStore: {
289+
"s:main": {
290+
sessionId: "target-session",
291+
updatedAt: Date.now(),
292+
parentSessionKey: "target-parent",
293+
} as SessionEntry,
294+
},
295+
},
296+
}),
297+
);
298+
299+
expect(result).toEqual({ kind: "reply", reply: undefined });
300+
expect(buildStatusReplyMock).toHaveBeenCalledWith(
301+
expect.objectContaining({
302+
sessionEntry: expect.objectContaining({
303+
sessionId: "target-session",
304+
parentSessionKey: "target-parent",
305+
}),
306+
parentSessionKey: "target-parent",
307+
}),
308+
);
309+
expect(handleCommandsMock).not.toHaveBeenCalled();
310+
});
311+
262312
it("does not continue into the agent after a mention-wrapped inline status-only turn", async () => {
263313
const typing = createTypingController();
264314
const ctx = buildTestCtx({

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,13 @@ export async function handleInlineActions(params: {
347347
let didSendInlineStatus = false;
348348
if (handleInlineStatus) {
349349
const { buildStatusReply } = await import("./commands.runtime.js");
350+
const targetSessionEntry = sessionStore?.[sessionKey] ?? sessionEntry;
350351
const inlineStatusReply = await buildStatusReply({
351352
cfg,
352353
command,
353-
sessionEntry,
354+
sessionEntry: targetSessionEntry,
354355
sessionKey,
355-
parentSessionKey: ctx.ParentSessionKey,
356+
parentSessionKey: targetSessionEntry?.parentSessionKey ?? ctx.ParentSessionKey,
356357
sessionScope,
357358
storePath,
358359
provider,

0 commit comments

Comments
 (0)