fix: agent preview session lifecycle continuity @W-22497762@#210
Conversation
App now owns a single source of truth for the session-transition lifecycle (isSessionStarting, isSessionTransitioning, isStopPending) and threads it down to both AgentSelector and AgentPreview. This fixes: - Tab flicker when switching between simulation and live test - Blank chat area with floating tabs during transitions - Loading state gaps between click and backend acknowledgement - Start/Stop buttons re-enabling momentarily during loading - Chat input remaining interactive after Stop click Also removes the noisy "Agent preview reset." VS Code toast and adds 22 new tests covering the lifecycle behavior. Mocks @salesforce/core in the coreExtensionService test so the fallback path no longer reaches into the host's ~/.sfdx config.
npiccolo
left a comment
There was a problem hiding this comment.
Manual testing ✅
Setup: Extension Development Host launched from ml/w-22497762-agent-preview-loading-continuity, agent script project afdx-pro-code-testdrive opened in the test window.
Tabs appear on agent select — Preview and Tracer tabs appear immediately on agent selection with no flicker.
Loading spinner is immediate — spinner appears on the next render after clicking Start, before any backend round-trip. Start button stays disabled continuously through sessionStarted.
Chat input during active session — input enabled and Send works normally.
Stop disables input immediately — chat input becomes non-typeable instantly on Stop click, before backend confirms sessionEnded. Start button stays disabled until ack.
No tab flicker on mode switch — switching Simulation → Live Test and Live Test → Simulation produces no tab flicker, no blank chat area, continuous loading spinner.
No "Agent preview reset." toast — triggering a compilation error and clicking Go Back produces no VS Code information toast.
Automated tests: npm run test:backend (386/386) and npm run test:frontend (456/456) all pass.
LGTM ✅
Summary
@W-22497762@
App now owns a single source of truth for the Agent Preview session-transition lifecycle (
isSessionStarting,isSessionTransitioning,isStopPending) and threads it down to bothAgentSelector(for button disabled state) andAgentPreview(for input disabled state). This eliminates several visible glitches when starting, stopping, and switching between Simulation and Live Test, and removes a redundant "Agent preview reset." VS Code toast.Before
sessionStartingmessage.sessionEndedandsessionStartingon a restart, between Stop click andsessionEnded).After
sessionEnded → sessionStartingduring a restart.sessionStarted(and from Stop click throughsessionEnded).sessionEnded.Testing
Automated
npm run test:frontend— 456 passing (was 434 before this branch). Newly added:test/webview/App.sessionLifecycle.test.tsx(11 tests) covers Start, Stop,clearMessagesgating during transitions, error/recovery paths (error,compilationError,refreshAgentsall clearisStopPending), and prop wiring toAgentSelector/AgentPreview.test/webview/AgentSelector.test.tsxfor the newisSessionTransitioningdisabled wiring on the SplitButton, published-agent button, Stop button, and agent dropdown, plus mode-switch behavior.test/webview/AgentPreview.sendMessage.test.tsxfor the newhandleSendMessageguards (parentIsSessionActive,isStopPending,isSessionTransitioning).test/webview/AgentPreview.placeholder.test.tsxverifying the placeholder Start button delegates toparentOnStartSessionwhen provided.npm run test:backend— 386 passing. Includes a fix totest/services/coreExtensionService.test.tsthat mocks@salesforce/core'sConfigAggregatorandOrgso the fallback path no longer reaches into the host's~/.sfdxconfig and a real Salesforce connection during tests.Manual