修复策划V2澄清历史完整展示
统一解析回合结果与持久化历史中的问题结构 恢复历史消息中的问题正文、选项标签和选项说明
This commit is contained in:
@@ -182,9 +182,11 @@ function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
: null;
|
||||
}
|
||||
|
||||
function resultQuestion(result: PlanningTurnResultV2 | null) {
|
||||
const payload = asRecord(result?.payload);
|
||||
const question = asRecord(payload?.question);
|
||||
function questionFromPayload(payloadValue: unknown) {
|
||||
const payload = asRecord(payloadValue);
|
||||
// Turn results wrap the question in `payload.question`; persisted
|
||||
// conversation messages store the question object directly in `payload`.
|
||||
const question = asRecord(payload?.question) ?? payload;
|
||||
if (!question) {
|
||||
return null;
|
||||
}
|
||||
@@ -218,6 +220,10 @@ function resultQuestion(result: PlanningTurnResultV2 | null) {
|
||||
} satisfies PlanningQuestionV2;
|
||||
}
|
||||
|
||||
function resultQuestion(result: PlanningTurnResultV2 | null) {
|
||||
return questionFromPayload(result?.payload);
|
||||
}
|
||||
|
||||
export function planningResultText(result: PlanningTurnResultV2 | null) {
|
||||
const text = result?.payload?.text;
|
||||
return typeof text === 'string' ? text : '';
|
||||
@@ -274,11 +280,7 @@ function messageDisplayText(message: PlanningMessageV2) {
|
||||
return payload.text;
|
||||
}
|
||||
if (message.kind === 'question') {
|
||||
const question = resultQuestion({
|
||||
schemaVersion: 'planning-turn-result.v2',
|
||||
kind: 'question',
|
||||
payload: payload ?? {},
|
||||
});
|
||||
const question = questionFromPayload(payload);
|
||||
return question ? questionDisplayText(question) : '';
|
||||
}
|
||||
if (message.kind === 'artifact') {
|
||||
|
||||
Reference in New Issue
Block a user