Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(claude-code): make the answered askUserQuestion render compact (#17196)

Arvin Xub44a60c9b616
diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.json
index efa79370f4f..0ff887b7581 100644
--- a/locales/en-US/plugin.json
+++ b/locales/en-US/plugin.json
@@ -128,9 +128,7 @@
"builtins.lobe-claude-code.agent.instruction": "Instruction",
"builtins.lobe-claude-code.agent.result": "Result",
"builtins.lobe-claude-code.askUserQuestion.noAnswer": "No answer received — model continued without their input.",
- "builtins.lobe-claude-code.askUserQuestion.question": "Question",
- "builtins.lobe-claude-code.askUserQuestion.reply": "Reply",
- "builtins.lobe-claude-code.askUserQuestion.selected": "Selected",
+ "builtins.lobe-claude-code.askUserQuestion.notAnswered": "Not answered",
"builtins.lobe-claude-code.sendMessage.queued": "Queued for delivery",
"builtins.lobe-claude-code.sendMessage.title": "Send message",
"builtins.lobe-claude-code.task.create.completed": "Task created: ",
diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.json
index c19700f1b27..9e988256caf 100644
--- a/locales/zh-CN/plugin.json
+++ b/locales/zh-CN/plugin.json
@@ -128,9 +128,7 @@
"builtins.lobe-claude-code.agent.instruction": "指令",
"builtins.lobe-claude-code.agent.result": "结果",
"builtins.lobe-claude-code.askUserQuestion.noAnswer": "未收到回答——模型在没有用户输入的情况下继续。",
- "builtins.lobe-claude-code.askUserQuestion.question": "问题",
- "builtins.lobe-claude-code.askUserQuestion.reply": "回复",
- "builtins.lobe-claude-code.askUserQuestion.selected": "已选择",
+ "builtins.lobe-claude-code.askUserQuestion.notAnswered": "未作答",
"builtins.lobe-claude-code.sendMessage.queued": "已加入投递队列",
"builtins.lobe-claude-code.sendMessage.title": "发送消息",
"builtins.lobe-claude-code.task.create.completed": "已创建任务:",
diff --git a/packages/builtin-tool-claude-code/src/client/Inspector/AskUserQuestion.tsx b/packages/builtin-tool-claude-code/src/client/Inspector/AskUserQuestion.tsx
index 02e4febe5c0..ef9a9f3387c 100644
--- a/packages/builtin-tool-claude-code/src/client/Inspector/AskUserQuestion.tsx
+++ b/packages/builtin-tool-claude-code/src/client/Inspector/AskUserQuestion.tsx
@@ -10,12 +10,19 @@ import { useTranslation } from 'react-i18next';
import type { AskUserQuestionArgs } from '../../types';
import { ClaudeCodeApiName } from '../../types';
+/**
+ * A tool card in the message list is ~470px wide, leaving ~210px for the chips.
+ * Two headers fit at their natural width; a third forces all of them to shrink and
+ * every chip ellipsizes to two characters, which says less than showing fewer. So
+ * cap at two and fold the rest into `+N` — fewer, fully legible beats more, truncated.
+ */
+const MAX_CHIPS = 2;
+
const styles = createStaticStyles(({ css, cssVar }) => ({
chip: css`
overflow: hidden;
min-width: 0;
- margin-inline-start: 6px;
padding-block: 2px;
padding-inline: 10px;
border-radius: 999px;
@@ -27,6 +34,24 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
background: ${cssVar.colorFillTertiary};
`,
+ chips: css`
+ overflow: hidden;
+ display: flex;
+ gap: 4px;
+ align-items: center;
+
+ min-width: 0;
+ margin-inline-start: 6px;
+ `,
+ /** Never shrinks — the chips absorb the compression and ellipsize instead. */
+ label: css`
+ flex-shrink: 0;
+ `,
+ more: css`
+ flex-shrink: 0;
+ font-size: 12px;
+ color: ${cssVar.colorTextTertiary};
+ `,
}));
export const AskUserQuestionInspector = memo<BuiltinInspectorProps<AskUserQuestionArgs>>(
@@ -35,14 +60,16 @@ export const AskUserQuestionInspector = memo<BuiltinInspectorProps<AskUserQuesti
const label = t(ClaudeCodeApiName.AskUserQuestion as any);
const argsQuestions = normalizeAskUserQuestions(args);
const questions = argsQuestions.length ? argsQuestions : normalizeAskUserQuestions(partialArgs);
- const summary =
- questions.length === 0
- ? undefined
- : questions.length === 1
- ? questions[0]?.header || questions[0]?.question
- : `${questions[0]?.header || questions[0]?.question} +${questions.length - 1}`;
-
- if (isArgumentsStreaming && !summary) {
+
+ // One chip per question, so a collapsed card still says *what* was asked. The
+ // old `header +N` named only the first and turned the rest into a count.
+ const headers = questions
+ .map((q) => q.header || q.question)
+ .filter((header): header is string => !!header);
+ const shown = headers.slice(0, MAX_CHIPS);
+ const rest = headers.length - shown.length;
+
+ if (isArgumentsStreaming && shown.length === 0) {
return <div className={cx(inspectorTextStyles.root, shinyTextStyles.shinyText)}>{label}</div>;
}
@@ -53,8 +80,17 @@ export const AskUserQuestionInspector = memo<BuiltinInspectorProps<AskUserQuesti
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
)}
>
- <span>{label}</span>
- {summary && <span className={styles.chip}>{summary}</span>}
+ <span className={styles.label}>{label}</span>
+ {shown.length > 0 && (
+ <div className={styles.chips}>
+ {shown.map((header, idx) => (
+ <span className={styles.chip} key={`${header}-${idx}`}>
+ {header}
+ </span>
+ ))}
+ {rest > 0 && <span className={styles.more}>{`+${rest}`}</span>}
+ </div>
+ )}
</div>
);
},
diff --git a/packages/builtin-tool-claude-code/src/client/Render/AskUserQuestion/index.tsx b/packages/builtin-tool-claude-code/src/client/Render/AskUserQuestion/index.tsx
index 10c936a0529..540c1da7d7c 100644
--- a/packages/builtin-tool-claude-code/src/client/Render/AskUserQuestion/index.tsx
+++ b/packages/builtin-tool-claude-code/src/client/Render/AskUserQuestion/index.tsx
@@ -18,12 +18,13 @@ interface AskUserQuestionState {
const styles = createStaticStyles(({ css, cssVar }) => ({
answer: css`
- line-height: 1.6;
+ font-size: 14px;
+ line-height: 1.5;
color: ${cssVar.colorText};
`,
check: css`
flex-shrink: 0;
- margin-block-start: 3px;
+ margin-block-start: 4px;
color: ${cssVar.colorPrimary};
`,
container: css`
@@ -31,81 +32,135 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
description: css`
font-size: 13px;
- line-height: 1.6;
+ line-height: 1.5;
color: ${cssVar.colorTextTertiary};
`,
divider: css`
align-self: stretch;
height: 1px;
+ margin-block: 4px;
background: ${cssVar.colorFillSecondary};
`,
- label: css`
- font-size: 12px;
+ /** The question's own short `header`, riding along the title line — costs no row. */
+ header: css`
+ flex-shrink: 0;
+
+ padding-block: 1px;
+ padding-inline: 6px;
+ border-radius: 4px;
+
+ font-size: 11px;
+ font-weight: 400;
color: ${cssVar.colorTextTertiary};
+ white-space: nowrap;
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ /** Ordinal rail. Its presence is what groups the blocks — hence no hairline. */
+ ordinal: css`
+ flex-shrink: 0;
+
+ width: 22px;
+ padding-block-start: 2px;
+
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: 11px;
+ font-variant-numeric: tabular-nums;
+ line-height: 1.5;
+ color: ${cssVar.colorTextQuaternary};
`,
question: css`
- font-size: 15px;
+ font-size: 14px;
font-weight: 500;
line-height: 1.5;
color: ${cssVar.colorText};
`,
+ titleRow: css`
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ align-items: baseline;
+ `,
+ unanswered: css`
+ padding-inline-start: 22px;
+ font-size: 14px;
+ line-height: 1.5;
+ color: ${cssVar.colorTextQuaternary};
+ `,
}));
+interface AnswerLineProps {
+ description?: string;
+ icon: typeof Check;
+ text: string;
+}
+
+const AnswerLine = memo<AnswerLineProps>(({ icon, text, description }) => (
+ <Flexbox horizontal align="flex-start" gap={8}>
+ <Icon className={styles.check} icon={icon} size={14} />
+ <Flexbox gap={1}>
+ <span className={styles.answer}>{text}</span>
+ {description && <span className={styles.description}>{description}</span>}
+ </Flexbox>
+ </Flexbox>
+));
+
+AnswerLine.displayName = 'CCAskUserAnswerLine';
+
interface QABlockProps {
answer?: string | string[];
+ /** 1-based ordinal, only passed when the form carries more than one question. */
+ index?: number;
question: AskUserQuestionItem;
}
/**
- * One question/answer pair for the completed Render, laid out as a single
- * flat surface (no nested cards): a "Question" label + the question text,
- * a hairline divider, then a "Selected" label + the picked option(s). Each
- * pick is one check-prefixed line with its description underneath; multi-select
- * fans out into multiple lines. When `answer` is absent — older messages
- * persisted before structured storage — we show a `—` placeholder so the
- * layout stays uniform.
+ * One question/answer pair, laid out flat (no nested cards, no field labels): the
+ * question line, then the pick(s) beneath it as check-prefixed rows with their
+ * description underneath. Multi-select fans out into several rows.
+ *
+ * With more than one question, `index` turns on an ordinal rail (`Q1`, `Q2`) and
+ * the question's own `header` rides along the title line as a trailing chip. The
+ * rail is what separates the blocks — it doubles as the grouping signal, so no
+ * hairline is drawn between them. A lone question gets neither: `Q1` would imply a
+ * `Q2` that doesn't exist, and the Inspector already names it.
+ *
+ * When `answer` is absent — older messages persisted before structured storage —
+ * we show a muted placeholder so the row still reads as an answer slot.
*/
-const QABlock = memo<QABlockProps>(({ question, answer }) => {
+const QABlock = memo<QABlockProps>(({ question, answer, index }) => {
const { t } = useTranslation('plugin');
const labels: string[] = Array.isArray(answer) ? answer : answer ? [answer] : [];
const optionByLabel = new Map(question.options.map((o) => [o.label, o]));
return (
- <Flexbox gap={12}>
+ <Flexbox align="flex-start" horizontal={!!index}>
+ {!!index && <span className={styles.ordinal}>{`Q${index}`}</span>}
<Flexbox gap={6}>
- <span className={styles.label}>
- {t('builtins.lobe-claude-code.askUserQuestion.question')}
- </span>
- <div className={styles.question}>{question.question}</div>
- </Flexbox>
-
- <div className={styles.divider} />
-
- <Flexbox gap={8}>
- <span className={styles.label}>
- {t('builtins.lobe-claude-code.askUserQuestion.selected')}
- </span>
+ <div className={index ? styles.titleRow : undefined}>
+ <span className={styles.question}>{question.question}</span>
+ {!!index && question.header && <span className={styles.header}>{question.header}</span>}
+ </div>
{labels.length > 0 ? (
- <Flexbox gap={10}>
+ <Flexbox gap={6}>
{labels.map((label) => {
const opt = optionByLabel.get(label);
return (
- <Flexbox gap={2} key={label}>
- <Flexbox horizontal align="flex-start" gap={8}>
- <Icon className={styles.check} icon={Check} size={14} />
- <Text className={styles.answer}>{label}</Text>
- </Flexbox>
- {opt?.description && opt.description !== label && (
- <span className={styles.description} style={{ paddingInlineStart: 22 }}>
- {opt.description}
- </span>
- )}
- </Flexbox>
+ <AnswerLine
+ icon={Check}
+ key={label}
+ text={label}
+ description={
+ opt?.description && opt.description !== label ? opt.description : undefined
+ }
+ />
);
})}
</Flexbox>
) : (
- <Text type="secondary">—</Text>
+ <span className={styles.unanswered}>
+ {t('builtins.lobe-claude-code.askUserQuestion.notAnswered')}
+ </span>
)}
</Flexbox>
</Flexbox>
@@ -140,32 +195,28 @@ const AskUserQuestion = memo<
const freeform = answers?.['__freeform__'];
const freeformText = typeof freeform === 'string' ? freeform.trim() : '';
const isError = !!pluginError;
+ const multiple = questions.length > 1;
// Escape-mode reply: the user opted out of the multi-choice form and
// wrote freeform text instead. The form picks are intentionally absent,
- // so render the questions for context (label + body) plus the typed reply
- // as a check-style line — Q&A pairs would render as empty rows.
+ // so render the questions for context plus the typed reply as its own line —
+ // Q&A pairs would render as empty rows.
if (freeformText) {
return (
- <Flexbox className={styles.container} gap={16}>
+ <Flexbox className={styles.container} gap={12}>
{questions.map((q, idx) => (
- <Flexbox gap={6} key={`${q.question}-${idx}`}>
- <span className={styles.label}>
- {t('builtins.lobe-claude-code.askUserQuestion.question')}
- </span>
- <div className={styles.question}>{q.question}</div>
+ <Flexbox align="flex-start" horizontal={multiple} key={`${q.question}-${idx}`}>
+ {multiple && <span className={styles.ordinal}>{`Q${idx + 1}`}</span>}
+ <div className={multiple ? styles.titleRow : undefined}>
+ <span className={styles.question}>{q.question}</span>
+ {multiple && q.header && <span className={styles.header}>{q.header}</span>}
+ </div>
</Flexbox>
))}
- <div className={styles.divider} />
- <Flexbox gap={8}>
- <span className={styles.label}>
- {t('builtins.lobe-claude-code.askUserQuestion.reply')}
- </span>
- <Flexbox horizontal align="flex-start" gap={8}>
- <Icon className={styles.check} icon={PenLine} size={14} />
- <Text className={styles.answer}>{freeformText}</Text>
- </Flexbox>
- </Flexbox>
+ {/* The reply answers the whole form, not the last question — with several
+ questions on screen that scope needs a rule to be legible. */}
+ {multiple && <div className={styles.divider} />}
+ <AnswerLine icon={PenLine} text={freeformText} />
{isError && (
<Text type="warning">{t('builtins.lobe-claude-code.askUserQuestion.noAnswer')}</Text>
)}
@@ -174,9 +225,14 @@ const AskUserQuestion = memo<
}
return (
- <Flexbox className={styles.container} gap={20}>
+ <Flexbox className={styles.container} gap={12}>
{questions.map((q, idx) => (
- <QABlock answer={answers?.[q.question]} key={`${q.question}-${idx}`} question={q} />
+ <QABlock
+ answer={answers?.[q.question]}
+ index={multiple ? idx + 1 : undefined}
+ key={`${q.question}-${idx}`}
+ question={q}
+ />
))}
{isError && (
<Text type="warning">{t('builtins.lobe-claude-code.askUserQuestion.noAnswer')}</Text>
diff --git a/packages/locales/src/default/plugin.ts b/packages/locales/src/default/plugin.ts
index 42e39e91343..eebd76c9a1d 100644
--- a/packages/locales/src/default/plugin.ts
+++ b/packages/locales/src/default/plugin.ts
@@ -63,9 +63,7 @@ export default {
'builtins.lobe-claude-code.agent.result': 'Result',
'builtins.lobe-claude-code.askUserQuestion.noAnswer':
'No answer received — model continued without their input.',
- 'builtins.lobe-claude-code.askUserQuestion.question': 'Question',
- 'builtins.lobe-claude-code.askUserQuestion.reply': 'Reply',
- 'builtins.lobe-claude-code.askUserQuestion.selected': 'Selected',
+ 'builtins.lobe-claude-code.askUserQuestion.notAnswered': 'Not answered',
'builtins.lobe-claude-code.sendMessage.queued': 'Queued for delivery',
'builtins.lobe-claude-code.sendMessage.title': 'Send message',
'builtins.lobe-claude-code.task.create.completed': 'Task created: ',
diff --git a/src/features/DevPanel/RenderGallery/fixtures/claude-code.ts b/src/features/DevPanel/RenderGallery/fixtures/claude-code.ts
index a6de46314b7..c3243e257c7 100644
--- a/src/features/DevPanel/RenderGallery/fixtures/claude-code.ts
+++ b/src/features/DevPanel/RenderGallery/fixtures/claude-code.ts
@@ -168,6 +168,12 @@ export default defineFixtures({
],
},
label: 'Multi question',
+ pluginState: {
+ askUserAnswers: {
+ 'How deep should this audit round go?': 'L1 + L2 (screenshots)',
+ 'Which surfaces should the audit cover?': ['Chat surface', 'Onboarding'],
+ },
+ },
},
{
args: {
@@ -189,6 +195,92 @@ export default defineFixtures({
],
},
label: 'Single question',
+ pluginState: {
+ askUserAnswers: { 'How should I handle the legacy module?': 'Minimal fix' },
+ },
+ },
+ {
+ args: {
+ questions: [
+ {
+ header: 'Approach',
+ options: [
+ {
+ description: 'Ship the minimal fix now and file a follow-up for the refactor.',
+ label: 'Minimal fix',
+ },
+ {
+ description: 'Refactor the module properly before fixing. Slower but cleaner.',
+ label: 'Refactor first',
+ },
+ ],
+ question: 'How should I handle the legacy module?',
+ },
+ ],
+ },
+ label: 'Freeform reply',
+ pluginState: {
+ askUserAnswers: {
+ __freeform__:
+ "Neither — delete the module, nothing calls it any more. I'll confirm with a grep first.",
+ },
+ },
+ },
+ {
+ args: {
+ questions: [
+ {
+ header: 'Approach',
+ options: [
+ {
+ description: 'Ship the minimal fix now and file a follow-up for the refactor.',
+ label: 'Minimal fix',
+ },
+ ],
+ question: 'How should I handle the legacy module?',
+ },
+ ],
+ },
+ // No `askUserAnswers` — an older message persisted before structured
+ // storage, or a skipped/cancelled flow. Exercises the placeholder row.
+ label: 'No structured answer',
+ },
+ {
+ // Four questions: the Inspector caps its header chips at 3 and folds the
+ // rest into `+N` so the row can't crowd out the tool's own actions.
+ args: {
+ questions: [
+ {
+ header: 'Audit level',
+ options: [{ description: 'Read the code only.', label: 'L1 only' }],
+ question: 'How deep should this audit round go?',
+ },
+ {
+ header: 'Scope',
+ options: [{ description: 'The chat conversation pane.', label: 'Chat surface' }],
+ question: 'Which surfaces should the audit cover?',
+ },
+ {
+ header: 'Report target',
+ options: [{ description: 'Publish to the verify channel.', label: '/verify' }],
+ question: 'Where should the report go?',
+ },
+ {
+ header: 'On failure',
+ options: [{ description: 'Leave the environment up for inspection.', label: 'Stop' }],
+ question: 'If a check fails, roll back automatically?',
+ },
+ ],
+ },
+ label: 'Inspector overflow (4 questions)',
+ pluginState: {
+ askUserAnswers: {
+ 'How deep should this audit round go?': 'L1 only',
+ 'If a check fails, roll back automatically?': 'Stop',
+ 'Where should the report go?': '/verify',
+ 'Which surfaces should the audit cover?': 'Chat surface',
+ },
+ },
},
]),
Agent: single({