fix(web): stop background work through session teardown #11159
Closedsatyalyadav(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/11159/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/web/src/components/ChatView.tsx line 5743OutdatedResolvedby satyalyadav(GitHub profile, opens in a new tab)@@ -5730,5 +5731,13 @@57305731 // returning only means the request was accepted.57315732 if (activeBackgroundLiveness === null) {57325733 setIsStoppingBackgroundWork(false);5734+ return;5735+ }5736+ if (!isStoppingBackgroundWork) {5737+ return;57335738 }5734- }, [activeBackgroundLiveness]);5739+ // A missed task completion event or delayed provider interrupt must not5740+ // freeze the Stop affordance permanently on "Stopping...". Re-enable Stop5741+ // after the timeout window so the user is never wedged.5742+ return scheduleStopBackgroundWorkTimeout(() => {5743+ setIsStoppingBackgroundWork(false);
- apps/web/src/components/ChatView.tsx lines 5734 to 5745OutdatedResolvedby satyalyadav(GitHub profile, opens in a new tab)@@ -5730,5 +5731,15 @@57305731 // returning only means the request was accepted.57315732 if (activeBackgroundLiveness === null) {57325733 setIsStoppingBackgroundWork(false);5734+ return;5735+ }5736+ if (!isStoppingBackgroundWork) {5737+ return;57335738 }5734- }, [activeBackgroundLiveness]);5739+ // A missed task completion event or delayed provider interrupt must not5740+ // freeze the Stop affordance permanently on "Stopping...". Re-enable Stop5741+ // after the timeout window so the user is never wedged.5742+ return scheduleStopBackgroundWorkTimeout(() => {5743+ setIsStoppingBackgroundWork(false);5744+ });5745+ }, [activeBackgroundLiveness, isStoppingBackgroundWork]);
satyalyadav(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/components/ChatView.tsx lines 5734 to 5739Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -5722,13 +5724,14 @@5722- // banner is the only visible stop affordance. Stop routes through the5723- // stop-everything interrupt: it kills every live background task before5724- // interrupting, and works by session, so no active turn is needed.5724+ // banner is the only visible stop affordance. Stop ends the provider session,5725+ // which tears down its background work and emits the liveness update.57255726 const activeBackgroundLiveness =57265727 !isWorking && activeThread ? (activeThreadShell?.backgroundLiveness ?? null) : null;5727- const [isStoppingBackgroundWork, setIsStoppingBackgroundWork] = useState(false);5728+ const [stoppingBackgroundWorkThreadId, setStoppingBackgroundWorkThreadId] =5729+ useState<ThreadId | null>(null);5730+ const isStoppingBackgroundWork = activeThread?.id === stoppingBackgroundWorkThreadId;57285731 useEffect(() => {5729- // "Stopping..." holds until the liveness clears; the interrupt command5730- // returning only means the request was accepted.5732+ // The provider session stop is the hard boundary. Keep "Stopping..."5733+ // visible until the existing liveness signal reports that it has cleared.57315734 if (activeBackgroundLiveness === null) {5732- setIsStoppingBackgroundWork(false);5735+ setStoppingBackgroundWorkThreadId(null);57335736 }57345737 }, [activeBackgroundLiveness]);
juliusmarminge closed this
Sign in to join this conversation.
Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.