Skip to content
TypeScript

fix(server): preserve Claude question option previews (#21932)

Julius Marminge1327e7bdfb45
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
index e4704ae412f..19311662d75 100644
--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
@@ -302,13 +302,17 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
});
it("projects AskUserQuestion input with question text as the answer key", () => {
+ const preview = "\n **Proposed change**\n\n```ts\n\tconst enabled = true;\n```\n ";
assert.deepEqual(
ClaudeAdapterV2.claudeUserInputQuestions({
questions: [
{
header: "Approach",
question: "Which approach?",
- options: [{ label: "Simple", description: "Use fewer moving parts" }],
+ options: [
+ { label: "Simple", description: "Use fewer moving parts", preview },
+ { label: "Safe", description: "Keep the current setup" },
+ ],
multiSelect: true,
},
],
@@ -318,7 +322,10 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
id: "Which approach?",
header: "Approach",
question: "Which approach?",
- options: [{ label: "Simple", description: "Use fewer moving parts" }],
+ options: [
+ { label: "Simple", description: "Use fewer moving parts", preview },
+ { label: "Safe", description: "Keep the current setup" },
+ ],
multiSelect: true,
},
],
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
index 6f0ab121c68..d6aada46a90 100644
--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
@@ -3404,7 +3404,15 @@ export function claudeUserInputQuestions(
if (label.length === 0) return [];
const description =
typeof optionRecord.description === "string" ? optionRecord.description.trim() : "";
- return [{ label, description: description || label }];
+ return [
+ {
+ label,
+ description: description || label,
+ ...(typeof optionRecord.preview === "string"
+ ? { preview: optionRecord.preview }
+ : {}),
+ },
+ ];
})
: [];
return [
diff --git a/packages/contracts/src/orchestrationV2.ts b/packages/contracts/src/orchestrationV2.ts
index d5364ea2fa8..6a957dc2ba8 100644
--- a/packages/contracts/src/orchestrationV2.ts
+++ b/packages/contracts/src/orchestrationV2.ts
@@ -1132,6 +1132,7 @@ export const OrchestrationV2UserInputQuestion = Schema.Struct({
label: TrimmedNonEmptyString,
description: TrimmedNonEmptyString,
value: Schema.optional(Schema.String),
+ preview: Schema.optional(Schema.String),
}),
),
multiSelect: Schema.optional(Schema.Boolean),