Skip to content

Conversation

@nstrayer
Copy link
Contributor

Summary

Adds a new "Ask Assistant" action to the notebook action bar that provides quick access to context-aware assistant prompts. The feature includes both predefined prompts for common notebook tasks and optional AI-powered suggestions that adapt to the current notebook state.

assistant-notebook-actions.mov

Demo of :

  • Using a predefined action
  • Requesting AI generated contextual actions
  • Running an AI generated action

Key capabilities:

  • Predefined prompts: Static list of common notebook operations (describe notebook, explain selected cells, fix errors, optimize code, etc.)
  • AI-powered suggestions: Optional context-aware prompts generated by analyzing notebook execution state, errors, outputs, and cell content
  • Custom prompts: Support for user-defined prompts with a 15,000 character limit to prevent abuse
  • Multiple chat modes: Prompts can target Ask, Edit, or Agent modes based on the task type

Technical improvements:

  • Extended NotebookAction2 to support async action execution
  • Centralized notebook context serialization for consistency across chat pane, suggestions, and inline chat
  • Proper cancellation token handling to avoid completing requests when quick pick is dismissed
  • Loading states and error handling for AI suggestion generation

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

QA Notes

@:notebooks @:assistant

Prerequisites:

  1. Open a Jupyter notebook in Positron
  2. Ensure Positron Assistant is enabled

Testing steps:

  1. Test predefined prompts:

    • Click the sparkle icon (‚ú®) in the notebook action bar
    • Verify quick pick appears with predefined options:
      • Describe the notebook
      • Explain selected cells (requires selection)
      • Fix errors (if errors exist)
      • Optimize code
      • Add documentation
      • Custom prompt (opens input box)
    • Select "Describe the notebook" and verify assistant responds in chat pane
  2. Test AI suggestions:

    • Click the sparkle icon
    • Click "Get AI Suggestions..." at the bottom of the quick pick
    • Verify loading state appears while suggestions generate
    • Verify AI-generated suggestions appear based on notebook state
    • Select an AI suggestion and verify it executes correctly
  3. Test custom prompts:

    • Click the sparkle icon
    • Select "Custom prompt..."
    • Enter a custom prompt (test length limit by pasting >15,000 characters)
    • Verify prompt is sent to assistant
  4. Test edge cases:

    • Test with no cells selected (some prompts should be disabled)
    • Test with cells that have errors (should see error-related suggestions)
    • Test cancellation by closing quick pick while AI suggestions are generating
    • Test with different chat modes (Ask, Edit, Agent)
  5. Test different notebook states:

    • Empty notebook
    • Notebook with only markdown cells
    • Notebook with executed code cells
    • Notebook with failed cells
    • Notebook with multiple selected cells

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

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

readme  valid tags

Copilot finished reviewing on behalf of nstrayer November 13, 2025 21:47
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 a new "Ask Assistant" action to the notebook action bar that provides quick access to context-aware assistant prompts, enabling users to quickly interact with the AI assistant for common notebook tasks or AI-generated suggestions tailored to the current notebook state.

Key Changes

  • Introduced AskAssistantAction with a quick pick interface for predefined prompts (describe notebook, add comments, suggest next steps) and custom user prompts with a 15,000-character limit
  • Implemented AI-powered suggestion generation that analyzes notebook execution state, errors, outputs, and cell content to propose contextual actions
  • Centralized notebook context serialization logic in serializeNotebookContext to ensure consistency across chat pane, suggestions, and inline chat features

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/positronNotebook/browser/positronNotebook.contribution.ts Extracted NotebookAction2 base class and imported AskAssistantAction registration
src/vs/workbench/contrib/positronNotebook/browser/NotebookAction2.ts New base class for notebook-level actions with async support for Promise-based operations
src/vs/workbench/contrib/positronNotebook/browser/AskAssistantAction.ts New action implementing the assistant quick pick UI with predefined prompts, custom prompt validation, and AI suggestion generation
src/vs/platform/quickinput/browser/media/quickInput.css CSS fix to prevent spinner wobbling in quick pick items by setting transform-origin
extensions/positron-assistant/src/tools/notebookUtils.ts Added centralized serializeNotebookContext function with integrated filtering logic and helper functions for notebook context operations
extensions/positron-assistant/src/promptRender.ts Updated to use new SerializedNotebookContext interface instead of raw notebook context
extensions/positron-assistant/src/participants.ts Moved getAttachedNotebookContext to notebookUtils.ts to centralize notebook context handling
extensions/positron-assistant/src/notebookSuggestions.ts New module implementing AI-powered notebook suggestion generation with JSON validation and model selection logic
extensions/positron-assistant/src/notebookContextFilter.ts Added unused getCellsToInclude helper function (logic now in serializeNotebookContext)
extensions/positron-assistant/src/md/prompts/notebook/suggestions.md New system prompt template for AI suggestion generation with guidelines and examples
extensions/positron-assistant/src/extension.ts Registered new generateNotebookSuggestions command for AI-powered suggestion generation
extensions/positron-assistant/src/api.ts Updated to use new hasAttachedNotebookContext helper for tool availability checks
Comments suppressed due to low confidence (2)

src/vs/workbench/contrib/positronNotebook/browser/AskAssistantAction.ts:348

  • Extra trailing blank line that should be removed for consistency with coding standards.
    src/vs/workbench/contrib/positronNotebook/browser/NotebookAction2.ts:33
  • Extra trailing blank line that should be removed for consistency with coding standards.

@nstrayer nstrayer merged commit e0665d3 into main Nov 14, 2025
12 checks passed
@nstrayer nstrayer deleted the positron-nb-assistant-actions branch November 14, 2025 18:51
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants