Skip to content

Conversation

@nstrayer
Copy link
Contributor

@nstrayer nstrayer commented Dec 3, 2025

Addresses #8607.

This PR adds "Fix" and "Explain" buttons to error outputs in notebooks, bringing notebook error handling to parity with the console experience. When an error occurs in a notebook cell, users now see quick action buttons directly in the output that allow them to:

  • Fix: Send the error and context to Positron Assistant to get a proposed fix
  • Explain: Get a detailed explanation of what caused the error

The implementation integrates with Positron Assistant and strips ANSI codes from errors before sending them to avoid token waste and improve chat clarity.

Demo

quick-fix-error-demo.mov

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

QA Notes

@:positron-notebooks @:assistant

  1. Open a notebook
  2. Execute code that produces an error, for example:
# Python example
x = 1 / 0
  1. Verify that "Fix" and "Explain" buttons appear below the error traceback
  2. Click "Fix" and verify:
    • Positron Assistant opens
    • Error context is sent to the assistant
    • Assistant provides a fix suggestion
  3. Click "Explain" and verify:
    • Assistant provides an explanation of the error
  4. Test with errors containing ANSI codes to verify they're stripped properly

…and update button event types. Changed fix and explain button handlers to simplify event management and removed unnecessary refs. Updated comments for clarity.
…waste tokens and create a jumbled mess in the chat.
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:positron-notebooks @:assistant

readme  valid tags

Copilot finished reviewing on behalf of nstrayer December 3, 2025 21:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds error handling quick-fix functionality to Positron notebooks by introducing "Fix" and "Explain" buttons that appear below error outputs. These buttons integrate with Positron Assistant to help users understand and resolve errors directly from notebook cells.

  • Implements split button UI with dropdown options for both "Fix" and "Explain" actions
  • Primary action creates a new chat session in agent mode, dropdown option continues in existing chat
  • Strips ANSI escape codes from error output before sending to assistant

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
NotebookCellQuickFix.tsx New React component implementing split buttons with primary actions (new chat) and dropdown menus (existing chat) for fix/explain operations
NotebookCellQuickFix.css Styles for split button UI matching action bar design patterns with hover states
CellTextOutput.tsx Integration point that conditionally renders quick-fix buttons when output type is 'error'

tabIndex={0}
title={explainDropdownTooltip}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space key handler should prevent default behavior to avoid scrolling the page. Add e.preventDefault(); inside the condition to prevent unwanted page scroll when activating the dropdown with the space key.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +35
* Primary click starts a fresh chat session in agent mode (with tool access to modify notebooks),
* dropdown opens in the existing chat panel to retain conversation context.
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states that the primary click "starts a fresh chat session in agent mode (with tool access to modify notebooks)", but it should also mention that the dropdown option retains conversation context in the existing chat. Consider rephrasing to: "Primary click starts a fresh chat session in agent mode (with tool access to modify notebooks). Dropdown provides option to continue in existing chat to retain conversation context."

Suggested change
* Primary click starts a fresh chat session in agent mode (with tool access to modify notebooks),
* dropdown opens in the existing chat panel to retain conversation context.
* Primary click starts a fresh chat session in agent mode (with tool access to modify notebooks).
* Dropdown provides option to continue in existing chat to retain conversation context.

Copilot uses AI. Check for mistakes.

const actions: IAction[] = [
{
id: 'continue-in-existing-chat',
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both fix and explain dropdown menus use the same action ID 'continue-in-existing-chat'. While this works functionally, it would be better to use unique IDs like 'fix-in-existing-chat' and 'explain-in-existing-chat' for better debuggability and consistency.

Suggested change
id: 'continue-in-existing-chat',
id: 'fix-in-existing-chat',

Copilot uses AI. Check for mistakes.

const actions: IAction[] = [
{
id: 'continue-in-existing-chat',
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both fix and explain dropdown menus use the same action ID 'continue-in-existing-chat'. While this works functionally, it would be better to use unique IDs like 'fix-in-existing-chat' and 'explain-in-existing-chat' for better debuggability and consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +66
.notebook-cell-quick-fix .assistant-action-dropdown {
display: flex;
align-items: center;
justify-content: center;
padding: 0 4px;
border-left: 1px solid var(--vscode-positronActionBar-selectBorder);
cursor: pointer;
user-select: none;
align-self: stretch;
border-radius: 0 3px 3px 0;
}
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing focus-visible style for keyboard navigation. Add a rule like .notebook-cell-quick-fix .assistant-action-dropdown:focus-visible { outline: 1px solid var(--vscode-focusBorder); outline-offset: -1px; } to provide visual feedback for keyboard users.

Copilot uses AI. Check for mistakes.
tabIndex={0}
title={fixDropdownTooltip}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space key handler should prevent default behavior to avoid scrolling the page. Add e.preventDefault(); inside the condition to prevent unwanted page scroll when activating the dropdown with the space key.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@dhruvisompura dhruvisompura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked pretty well for me!

Comment on lines +112 to +116
{
type === 'error'
? <NotebookCellQuickFix errorContent={content} />
: null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing I did notice is that you can't use the keyboard to navigate to the fix/explain buttons in the output since the output div element isn't focusable!

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.

3 participants