From 5dd2daee356758ab7489655ab0677aee6d065c0b Mon Sep 17 00:00:00 2001 From: wishforge Date: Mon, 9 Nov 2026 19:06:16 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Show=20the=20answer=20once,=20an?= =?UTF-8?q?d=20keep=20the=20wish=20card=20from=20repeating=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two copies of the same words could appear on screen, and both came from the panel rather than from the model. The card that asks the customer to confirm a drafted wish fell back to the answer text whenever the Copilot wrote no separate goal, then printed it under 「要做的改动」 — the answer above the card already said it. The card now shows that section only when the goal really is a different sentence. The streamed answer also stayed on screen after it ended, next to the stored message it had just become. It is now dropped as soon as the transcript holds the same text, and the stored session is read back before the stream is cleared. --- apps/web/src/features/copilot.tsx | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) 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}
做完怎么确认
    {criteria.length ? criteria.map(item =>
  • {item}
  • ) :
  • 改动完成即可。
  • }
@@ -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 (