Skip to content

fix: recover from session start failures in the AFDX agent preview @W-22434854@#204

Open
marcelinollano wants to merge 3 commits into
mainfrom
ml/W-22434854-buttons-stuck-on-session-failure
Open

fix: recover from session start failures in the AFDX agent preview @W-22434854@#204
marcelinollano wants to merge 3 commits into
mainfrom
ml/W-22434854-buttons-stuck-on-session-failure

Conversation

@marcelinollano
Copy link
Copy Markdown
Collaborator

@marcelinollano marcelinollano commented May 11, 2026

@W-22434854@

Summary

When a session start failed in the AFDX VS Code extension agent preview, the title-bar Refresh and Reset (clear-all) icons became unresponsive and compilation errors rendered as plain text inside the chat transcript. This PR routes every failure through the same error screen, keeps the agent selector mounted while recovering, and rewrites the error copy so the bold title is short and the muted subtitle holds the explanation.

Before

  • Compilation errors showed as a centered system message with no recovery affordance.
  • Other failure types used full-paragraph bold titles, with the raw server error string shown as the subtitle.
  • After clicking Go Back from the error screen, the dropdown briefly re-loaded and the top start button stayed disabled because the selector remounted from scratch.
  • The title-bar Refresh and Reset icons stayed hidden after early session-start failures because the agentforceDX:sessionStarting context flag never cleared.

After

  • All failure types render the same error screen (icon + title + details + Go Back button).
  • Titles are short and distinct: "Agent deactivated", "Agent not found", "Permission denied", "Compilation failed", "Something went wrong".
  • The subtitle holds the human-readable explanation for known cases (deactivated/not found/forbidden/compilation) or the raw server error for the generic case.
  • Refresh and Reset icons are reachable from the error screen and recover the view to a usable state.
  • Clicking Go Back keeps the agent selector populated and its controls enabled.
  • Session-starting state is cleared on error, compilationError, clearMessages, and refreshAgents so the buttons never get stuck.

Testing

Automated

  • npm run test:backend — 381 tests pass; updated assertions in test/views/agentCombined/handlers/webviewMessageHandlers.test.ts for the new short titles and subtitle copy.
  • npm run test:frontend — 387 tests pass; updated test/webview/AgentPreview.messages.test.tsx to assert the compilation error renders the unified error screen with title and subtitle.

Manual verification

  1. Open an agent script project in the Extension Development Host. Select an agent that has a syntax error and click Start Simulation. Expected: error screen with icon, "Compilation failed" as the bold title, the compiler output as the subtitle, and a Go Back button. The title-bar Refresh and Reset icons are visible.
  2. From step 1, click Go Back. Expected: returns to the agent selector with the same agent selected, dropdown not in a loading state, top start button enabled. Selecting a different agent and starting works.
  3. From step 1, click the title-bar Refresh icon instead. Expected: the agents list reloads and the view returns to the placeholder. Click again to verify it stays responsive.
  4. From step 1, click the title-bar Reset icon. Expected: clears the error and returns to the agent placeholder for the same agent.
  5. Authenticate to an org and select a deactivated agent, then Start Live Test. Expected: error screen with title "Agent deactivated" and the activation guidance as the subtitle.
  6. Repeat with a 403/permission scenario and a 404/deleted agent. Expected: titles "Permission denied" and "Agent not found" respectively, with the matching explanation as the subtitle.
  7. Successful session start regression: select a healthy agent and Start Simulation. Expected: no error screen flashes; chat loads as normal; stop and restart still work.

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
@marcelinollano marcelinollano changed the title fix: recover from session start failures in the AFDX agent preview fix: recover from session start failures in the AFDX agent preview @W-22434854@ May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant