fix: resolve race conditions in assistant/cockpit session loading

- Always load session data on mount even when urlSessionId matches
  activeChatId, fixing empty state after view toggle between /assistant
  and /cockpit (tasks/messages not showing until sidebar click)
- Add loadingRef for synchronous guards preventing duplicate sends,
  duplicate session creation, and prefill races
- Fix stale evidence_items closure in CockpitPage handlers
- Move setLoading(true) before first await in handlePrefill and
  handleResumeNew

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-04-03 02:49:29 +00:00
parent 3ea669a1e5
commit 4ba32a08ac
3 changed files with 43 additions and 21 deletions

View File

@@ -20,7 +20,7 @@ export default function FlowPilotPage() {
}, []) // eslint-disable-line react-hooks/exhaustive-deps
const handleTaskSubmit = async (responses: Array<{ type: string; state: string; value: string; text?: string; label?: string }>) => {
if (!session.activeChatId || session.loading) return
if (!session.activeChatId || session.loading || session.loadingRef.current) return
const parts: string[] = []
for (const r of responses) {