Skip to content

Commit ef4cfa7

Browse files
committed
fix(composer): allow steering for attached compact prompts
1 parent 749577c commit ef4cfa7

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎packages/client-runtime/src/state/composerDispatch.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,16 @@ it("blocks steering only for a pending compact command or a running explicit com
8181
).toBe(false);
8282
}
8383
});
84+
85+
it("allows steering when an attached compact prompt compacts automatically", () => {
86+
const message = { id: "user", text: "/compact", attachments: [{}] };
87+
const canSteer = !isExplicitCompactionActive({
88+
compactCommandIsActive: false,
89+
compactionRunning: true,
90+
run: { userMessageId: "user" },
91+
messages: [message],
92+
});
93+
expect(resolveComposerDispatchMode({ running: true, alternateModifier: false, canSteer })).toBe(
94+
"steer",
95+
);
96+
});

‎packages/client-runtime/src/state/composerDispatch.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@ export function isExplicitCompactionActive(input: {
2020
readonly compactCommandIsActive: boolean;
2121
readonly compactionRunning: boolean;
2222
readonly run: { readonly userMessageId: string } | undefined;
23-
readonly messages: ReadonlyArray<{ readonly id: string; readonly text: string }> | undefined;
23+
readonly messages:
24+
| ReadonlyArray<{
25+
readonly id: string;
26+
readonly text: string;
27+
readonly attachments?: ReadonlyArray<unknown>;
28+
}>
29+
| undefined;
2430
}): boolean {
2531
if (input.compactCommandIsActive) return true;
2632
if (!input.compactionRunning || input.run === undefined) return false;
2733
const message = input.messages?.find((message) => message.id === input.run?.userMessageId);
28-
return /^\/compact(?:\s|$)/i.test(message?.text.trim() ?? "");
34+
return (
35+
(message?.attachments?.length ?? 0) === 0 &&
36+
/^\/compact(?:\s|$)/i.test(message?.text.trim() ?? "")
37+
);
2938
}
3039

3140
export function alternateComposerDispatchAction(

0 commit comments

Comments
 (0)