diff --git a/apps/web/src/features/copilot.tsx b/apps/web/src/features/copilot.tsx index 96d9e8e..b58366e 100644 --- a/apps/web/src/features/copilot.tsx +++ b/apps/web/src/features/copilot.tsx @@ -47,7 +47,11 @@ function WishDraft({ sessionId: string; onCreated: () => void; }) { - const baseGoal = message.goal ?? message.content; + // The card is the confirmation, not a second copy of the answer. When the Copilot did not write a + // separate goal, the answer above already says what will change, so the card must not repeat it. + const statedGoal = message.goal?.trim() ?? ''; + const baseGoal = statedGoal || message.content; + const repeatsAnswer = statedGoal === message.content.trim(); const baseCriteria = message.acceptanceCriteria ?? []; const [selected, setSelected] = useState>({}); const [busy, setBusy] = useState(false); @@ -109,10 +113,12 @@ function WishDraft({

{message.contextSummary || '没有额外说明。'}

) : null} -
- 要做的改动 -

{goal}

-
+ {statedGoal && !repeatsAnswer ? ( +
+ 要做的改动 +

{goal}

+
+ ) : null}
做完怎么确认 @@ -338,7 +344,12 @@ export function CopilotSidebar({ open, onClose }: { open: boolean; onClose: () = context: { pathname }, onDone: () => { setPendingUser(''); - void sessionResource.mutate().catch(() => undefined); + // The stored message replaces the streamed one. Read it back first, then clear the stream, + // so the answer is never on screen twice and never blinks away in between. + void sessionResource + .mutate() + .catch(() => undefined) + .then(() => stream.reset()); }, }); } catch (failure) { @@ -348,7 +359,14 @@ export function CopilotSidebar({ open, onClose }: { open: boolean; onClose: () = } }; const messages = sessionResource.data?.projectId === projectId ? sessionResource.data.messages : []; - const showStream = streaming || Boolean(stream.state.content) || Boolean(stream.state.error); + // One answer, one place. While it streams the local copy is the only one; once the stored message + // is in the transcript that becomes the answer, so the streamed text steps aside. + const streamedText = stream.state.content.trim(); + const answerAlreadyStored = + Boolean(streamedText) && + messages.some(message => message.role === 'assistant' && message.content.trim() === streamedText); + const showStream = + streaming || Boolean(stream.state.error) || (Boolean(stream.state.content) && !answerAlreadyStored); return (