fix(pilot): wipe full task-lane state on chat switch + extract palette event
All checks were successful
Mirror to GitHub / mirror (push) Successful in 10s
All checks were successful
Mirror to GitHub / mirror (push) Successful in 10s
Two fixes from the Phase 5 shakedown:
1. Stale lane data leaking across chats. handleNewChat, sendPrefill, and
handleResumeNew were each missed when Phase 3/5 added activeFix,
previewKind, previewData, and scriptPanelOpen — only selectChat reset
the full set. Result: starting a new chat while a Suggested Fix card
was active showed the previous session's fix card (and any open
preview/script panel) until the next backend refresh swept it.
Consolidated all four entry points behind a single
resetSessionDerivedState() helper so adding new lane state in future
phases only requires touching one place.
2. CommandPalette TDZ on cold load. SCRIPTS_INLINE_QUICK_ACTION (line 66)
referenced PILOT_INLINE_SCRIPT_PATH declared at line 94 — module-level
evaluation hit the use before the declaration. Browser blanked with
"Cannot access 'PILOT_INLINE_SCRIPT_PATH' before initialization".
Moved the path const above its first use; also extracted
PILOT_INLINE_SCRIPT_EVENT into a tiny @/lib/pilotEvents module so
AssistantChatPage doesn't import the palette component just to read a
string — that mixed-export pattern broke Fast Refresh ("consistent
components exports") and added an unnecessary import edge.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
14
frontend/src/lib/pilotEvents.ts
Normal file
14
frontend/src/lib/pilotEvents.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Cross-component event names for the FlowPilot session UI.
|
||||
*
|
||||
* Lives in /lib (not /components) so importing the event name does NOT
|
||||
* pull in any React component module. AssistantChatPage and CommandPalette
|
||||
* both reference it without forming an import cycle, and Vite's
|
||||
* react-fast-refresh "consistent components exports" check stays happy.
|
||||
*/
|
||||
|
||||
// Phase 5: dispatched by the global Cmd+K palette when the engineer picks
|
||||
// "Open inline Script Generator" while on a /pilot/:id route. The chat
|
||||
// page subscribes via `window.addEventListener` and toggles its inline
|
||||
// Script Generator panel if there's an active suggested fix.
|
||||
export const PILOT_INLINE_SCRIPT_EVENT = 'flowpilot:open-inline-script'
|
||||
Reference in New Issue
Block a user