Fix plan follow-up mode switching and submission text

- Extract follow-up submission resolution into `resolvePlanFollowUpSubmission`
- Send implementation prompt in default mode when follow-up text is empty
- Keep composer mode toggle synced when starting same-thread implementation turns
- Add tests for follow-up submission behavior
This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-03-05 23:00:41 -08:00
1 parent 6ee057e25b
commit 010ba70561
3 files changed
+60 -7

No files matched your search

+12 -7
View File
@@ -92,6 +92,7 @@ import {
buildPlanImplementationPrompt,
buildProposedPlanMarkdownFilename,
proposedPlanTitle,
resolvePlanFollowUpSubmission,
} from "../proposedPlan";
import { truncateTitle } from "../truncateTitle";
import {
@@ -2318,19 +2319,18 @@ export default function ChatView({ threadId }: ChatViewProps) {
}
const trimmed = prompt.trim();
if (showPlanFollowUpPrompt && activeProposedPlan) {
const followUpText =
trimmed.length > 0
? trimmed
: buildPlanImplementationPrompt(activeProposedPlan.planMarkdown);
const nextInteractionMode = trimmed.length > 0 ? "plan" : "default";
const followUp = resolvePlanFollowUpSubmission({
draftText: trimmed,
planMarkdown: activeProposedPlan.planMarkdown,
});
promptRef.current = "";
clearComposerDraftContent(activeThread.id);
setComposerHighlightedItemId(null);
setComposerCursor(0);
setComposerTrigger(null);
await onSubmitPlanFollowUp({
text: followUpText,
interactionMode: nextInteractionMode,
text: followUp.text,
interactionMode: followUp.interactionMode,
});
return;
}
@@ -2795,6 +2795,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
interactionMode: nextInteractionMode,
});
// Keep the mode toggle and plan-follow-up banner in sync immediately
// while the same-thread implementation turn is starting.
setComposerDraftInteractionMode(threadIdForSend, nextInteractionMode);
await api.orchestration.dispatchCommand({
type: "thread.turn.start",
commandId: newCommandId(),
@@ -2840,6 +2844,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
selectedModel,
selectedModelOptionsForDispatch,
selectedProvider,
setComposerDraftInteractionMode,
setThreadError,
settings.enableAssistantStreaming,
],
+27
View File
@@ -5,6 +5,7 @@ import {
buildPlanImplementationPrompt,
buildProposedPlanMarkdownFilename,
proposedPlanTitle,
resolvePlanFollowUpSubmission,
} from "./proposedPlan";
describe("proposedPlanTitle", () => {
@@ -25,6 +26,32 @@ describe("buildPlanImplementationPrompt", () => {
});
});
describe("resolvePlanFollowUpSubmission", () => {
it("switches to default mode when implementing the ready plan without extra text", () => {
expect(
resolvePlanFollowUpSubmission({
draftText: " ",
planMarkdown: "## Ship it\n\n- step 1\n",
}),
).toEqual({
text: "PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",
interactionMode: "default",
});
});
it("stays in plan mode when the user adds a follow-up prompt", () => {
expect(
resolvePlanFollowUpSubmission({
draftText: "Refine step 2 first",
planMarkdown: "## Ship it\n\n- step 1\n",
}),
).toEqual({
text: "Refine step 2 first",
interactionMode: "plan",
});
});
});
describe("buildPlanImplementationThreadTitle", () => {
it("uses the plan heading when building the implementation thread title", () => {
expect(buildPlanImplementationThreadTitle("# Integrate RPC\n\nBody")).toBe(
+21
View File
@@ -16,6 +16,27 @@ export function buildPlanImplementationPrompt(planMarkdown: string): string {
return `PLEASE IMPLEMENT THIS PLAN:\n${planMarkdown.trim()}`;
}
export function resolvePlanFollowUpSubmission(input: {
draftText: string;
planMarkdown: string;
}): {
text: string;
interactionMode: "default" | "plan";
} {
const trimmedDraftText = input.draftText.trim();
if (trimmedDraftText.length > 0) {
return {
text: trimmedDraftText,
interactionMode: "plan",
};
}
return {
text: buildPlanImplementationPrompt(input.planMarkdown),
interactionMode: "default",
};
}
export function buildPlanImplementationThreadTitle(planMarkdown: string): string {
const title = proposedPlanTitle(planMarkdown);
if (!title) {