Skip to content

Commit 607734a

Browse files
committed
fix(webapp): watch confirmation must not leak into a later-mounted chat
The appended-message hand-off wasn't scoped to a chat: a chat mounted after a watch was created started with a fresh dedupe ref, saw the pending seq, and adopted another chat's confirmation into its transcript. The hand-off now carries its chatId and only the matching chat receives it.
1 parent 5458cff commit 607734a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

apps/webapp/app/components/dashboard-agent/DashboardAgentPanel.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,11 @@ export function DashboardAgentPanel({
426426
const [watchPending, setWatchPending] = useState(false);
427427
const [watchError, setWatchError] = useState<string | null>(null);
428428
// The block the server appended, handed to the open chat so it appears now
429-
// rather than on the next open. `seq` makes each append distinct.
429+
// rather than on the next open. `seq` makes each append distinct. Carries the
430+
// chat it belongs to: a chat mounted later (fresh dedupe ref) must not adopt
431+
// another chat's confirmation.
430432
const [appendedMessage, setAppendedMessage] = useState<
431-
{ message: UIMessage; seq: number } | undefined
433+
{ chatId: string; message: UIMessage; seq: number } | undefined
432434
>(undefined);
433435

434436
const handledWatchSeq = useRef<number | undefined>(undefined);
@@ -482,6 +484,7 @@ export function DashboardAgentPanel({
482484

483485
if (active?.chatId === data.chatId) {
484486
setAppendedMessage((current) => ({
487+
chatId: data.chatId!,
485488
message: data.message!,
486489
seq: (current?.seq ?? 0) + 1,
487490
}));
@@ -656,7 +659,9 @@ export function DashboardAgentPanel({
656659
watches={chatWatches}
657660
pagePaths={pagePaths}
658661
watchCard={watchCard}
659-
appendedMessage={appendedMessage}
662+
appendedMessage={
663+
appendedMessage?.chatId === active.chatId ? appendedMessage : undefined
664+
}
660665
onWatchIntent={openWatchCard}
661666
onCancelWatch={cancelWatch}
662667
onTurnSettled={handleTurnSettled}

0 commit comments

Comments
 (0)