fix: recover from session start failures in the AFDX agent preview @W-22434854@#204
Conversation
When a session start fails, the webview's isSessionStarting flag and the agentforceDX:sessionStarting context were not reliably cleared, leaving the title-bar Refresh and Reset buttons unresponsive. - Always clear setSessionStarting(false) in the backend error handler, not just when an agent instance had been created. - In the webview, clear isSessionStarting on compilationError, clearMessages, and refreshAgents in addition to the existing error handler. W-22434854
Compilation errors were rendered as plain text inside the chat transcript. Route them through the same error screen as other session start failures, with an icon and a Go Back button. The bold title is now always "Something went wrong" with the specific cause shown as details below, so the entry point to recovery is consistent across all error types. Keep the agent selector mounted while the error screen is showing so it does not refetch the agents list and disable its controls when the user clicks Go Back. W-22434854
The error screen has a bold title and a muted subtitle. The previous copy used a long sentence as the title and the raw server error as the subtitle, which read poorly and exposed stack-like text to users. Move the human-readable explanation into the subtitle and use short, recognizable titles for known cases. The generic case still shows the raw server error in the subtitle, since there is no curated copy to display there. W-22434854
The compilation error subtitle contains EOL-separated lines from logCompilationError, but the <p> element collapsed them into a single space. Apply white-space: pre-wrap so multi-line compiler output reads correctly. W-22434854
npiccolo
left a comment
There was a problem hiding this comment.
Manual testing ✅
Setup: Extension Development Host launched from ml/W-22434854-buttons-stuck-on-session-failure, agent script project afdx-pro-code-testdrive opened in the test window.
Compilation error recovery
Selected TestVerboseAgent, introduced a syntax error, clicked Start Simulation. Error screen appeared with "Compilation failed" as the bold title and the compiler output as the subtitle. Title-bar Refresh and Reset icons were visible and responsive. Clicking Go Back returned to the agent selector with the agent still selected, dropdown not loading, Start button enabled and ready.
Happy path regression
Restored the agent file, selected TestVerboseAgent, clicked Start Simulation. Chat loaded cleanly with no error flash. Sent a message and received a correct response. Clicked Stop then Start Simulation again — restarted cleanly with no stuck state.
Automated tests: npm run test:backend (381/381) and npm run test:frontend (387/387) all pass.
LGTM ✅
What does this PR do?
Fixes recovery from session start failures in the AFDX agent preview.
isSessionStartingand theagentforceDX:sessionStartingcontext flag are cleared onerror,compilationError,clearMessages, andrefreshAgents.white-space: pre-wrap).What issues does this PR fix or reference?
@W-22434854@
Functionality Before
Functionality After
Testing Setup Notes
Automated
npm run test:backend(381 tests) andnpm run test:frontend(387 tests) pass. Updated assertions intest/views/agentCombined/handlers/webviewMessageHandlers.test.tsandtest/webview/AgentPreview.messages.test.tsx.Manual verification