Skip to content

Commit 3e86b10

Browse files
refactor(web): retry guard needs no ref
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 7245435 commit 3e86b10

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,9 @@ function releaseChatTimelineAnchor<T extends { readonly messageId: MessageId | n
15031503
return current.messageId === null ? current : { ...current, messageId: null };
15041504
}
15051505

1506+
/** Runs with a workspace preparation retry in flight, across ChatView instances. */
1507+
const retryingWorkspacePreparationRunIds = new Set<RunId>();
1508+
15061509
export default function ChatView(props: ChatViewProps) {
15071510
const {
15081511
environmentId,
@@ -3883,16 +3886,15 @@ export default function ChatView(props: ChatViewProps) {
38833886
() => new Set(retryableRunIdsKey === "" ? [] : (retryableRunIdsKey.split("\n") as RunId[])),
38843887
[retryableRunIdsKey],
38853888
);
3886-
// One retry per failed run: a second click lands after the run is preparing again.
3887-
const retryingRunIds = useRef(new Set<RunId>());
38883889
const onRetryWorkspacePreparation = useCallback(
38893890
(runId: RunId) => {
3890-
if (!activeThreadRef || retryingRunIds.current.has(runId)) return;
3891-
retryingRunIds.current.add(runId);
3891+
// One retry per failed run: a second click lands after the run is preparing again.
3892+
if (!activeThreadRef || retryingWorkspacePreparationRunIds.has(runId)) return;
3893+
retryingWorkspacePreparationRunIds.add(runId);
38923894
void retryWorkspacePreparation({
38933895
environmentId: activeThreadRef.environmentId,
38943896
input: { threadId: activeThreadRef.threadId, runId },
3895-
}).finally(() => retryingRunIds.current.delete(runId));
3897+
}).finally(() => retryingWorkspacePreparationRunIds.delete(runId));
38963898
},
38973899
[activeThreadRef, retryWorkspacePreparation],
38983900
);

0 commit comments

Comments
 (0)