Skip to content

Commit 21f3d5c

Browse files
committed
Drop aggressive canonical-already-present guards
The previous commit added two guards (snapshotPersisted check at trickle effect start, late-arrival guard inside startTrickle) that intended to prevent the trickle's optimistic from clobbering a canonical reportComment that arrived during the pre-trickle setTimeout window. Those guards broke the visible trickle in the common "server fast" case: when the canonical reportComment lands during the 4s pre-trickle delay, startTrickle was returning without firing [ConciergeTrickle] start. The ui-verify spec requires the start log to fire within 15s of click; this caused a regression. The clobber-on-natural-completion case the guards targeted is a real pre-existing bug, but it's separate from the revisit fix shipped in the prior commit. Reverting the guards. The displayAfter anchoring (resume on revisit) and TRICKLE_HARD_CAP_MS staleness gate stay.
1 parent 69459e1 commit 21f3d5c

1 file changed

Lines changed: 7 additions & 28 deletions

File tree

src/hooks/usePendingConciergeResponse.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,20 @@ function usePendingConciergeResponse(reportID: string | undefined) {
4848
// pendingResponse/tokens/fullHtml — without this snapshot, those non-content
4949
// updates would cancel the running interval and restart the reveal. The
5050
// useEffect keeps ref writes in the commit phase (React-Compiler-safe).
51-
const trickleInputsRef = useRef({pendingResponse, fullHtml, tokens, dispatchLocalDraftEvent, persistedAction});
51+
const trickleInputsRef = useRef({pendingResponse, fullHtml, tokens, dispatchLocalDraftEvent});
5252
useEffect(() => {
53-
trickleInputsRef.current = {pendingResponse, fullHtml, tokens, dispatchLocalDraftEvent, persistedAction};
53+
trickleInputsRef.current = {pendingResponse, fullHtml, tokens, dispatchLocalDraftEvent};
5454
});
5555

5656
// Reconciliation: when the canonical reportComment lands in REPORT_ACTIONS
5757
// mid-trickle, fire the running loop's accelerator so the remaining reveal
58-
// finishes in ~1.5s instead of snapping the synthetic bubble closed. If the
59-
// canonical lands while no trickle is running (e.g. arrived while the user
60-
// was on a different report), drop the pending optimistic so we don't
61-
// reapply it on top of the canonical on remount.
58+
// finishes in ~1.5s instead of snapping the synthetic bubble closed.
6259
useEffect(() => {
63-
if (!persistedAction) {
60+
if (!persistedAction || !accelerateRef.current) {
6461
return;
6562
}
66-
if (accelerateRef.current) {
67-
accelerateRef.current(Date.now());
68-
} else {
69-
discardPendingConciergeAction(reportID);
70-
}
71-
}, [persistedAction, reportID]);
63+
accelerateRef.current(Date.now());
64+
}, [persistedAction]);
7265

7366
useEffect(() => {
7467
if (!reportID || !reportActionID) {
@@ -78,17 +71,10 @@ function usePendingConciergeResponse(reportID: string | undefined) {
7871
// when it began; subsequent updates that share this same reportActionID don't
7972
// disturb the in-progress reveal. A genuinely new Concierge reply produces a
8073
// new reportActionID and re-enters this effect via the deps below.
81-
const {pendingResponse: snapshot, fullHtml: snapshotHtml, tokens: snapshotTokens, persistedAction: snapshotPersisted} = trickleInputsRef.current;
74+
const {pendingResponse: snapshot, fullHtml: snapshotHtml, tokens: snapshotTokens} = trickleInputsRef.current;
8275
if (!snapshot) {
8376
return;
8477
}
85-
// If the canonical reportComment is already in REPORT_ACTIONS at mount,
86-
// there's nothing to optimistically reveal — discard pending so we don't
87-
// re-apply the optimistic on top of the canonical.
88-
if (snapshotPersisted) {
89-
discardPendingConciergeAction(reportID);
90-
return;
91-
}
9278
const {reportAction, displayAfter} = snapshot;
9379
const remainingDelay = displayAfter - Date.now();
9480

@@ -188,13 +174,6 @@ function usePendingConciergeResponse(reportID: string | undefined) {
188174
if (cancelled) {
189175
return;
190176
}
191-
// Late-arrival guard: the canonical reportComment may have landed
192-
// during the pre-trickle setTimeout window. Skip the trickle so we
193-
// don't apply the optimistic on top of the canonical at completion.
194-
if (trickleInputsRef.current.persistedAction) {
195-
discardPendingConciergeAction(reportID);
196-
return;
197-
}
198177
// Anchor to displayAfter so revisit resumes at the wall-clock-correct
199178
// stage instead of restarting the reveal from char 0.
200179
trickleStart = displayAfter;

0 commit comments

Comments
 (0)