wxMaxima
Loading...
Searching...
No Matches
Public Member Functions
AiChatSidebar Class Reference

A sidebar to chat with an external AI about the current worksheet (follow-up to the MCP server, GH request: "a de facto standard AI sidebar that ... gives it access to a worksheet"). More...

#include <AiChatSidebar.h>

Inheritance diagram for AiChatSidebar:
[legend]
Collaboration diagram for AiChatSidebar:
[legend]

Public Member Functions

 AiChatSidebar (wxWindow *parent, Configuration *configuration, Worksheet *worksheet, Variablespane *variablesPane, StatusBar *statusBar=nullptr, AiConnectionMonitor *monitor=nullptr, wxWindowID id=wxID_ANY)
 
void ReloadProviderFromConfig ()
 Re-reads Configuration for the selected provider/API key/model and rebuilds this sidebar's provider accordingly. Call after the Options dialog closes, in case the AI settings changed. Safe to call even while a request is in flight – see AiProvider::SendChat()'s own shared_ptr-based lifetime handling for why that's safe.
 
void ClearConversation ()
 Clears the conversation history (but not the provider/API key setup).
 
void InterruptRequest ()
 Cancels the reply we are currently waiting for, if any. Does nothing when no request is in flight, so this is safe to call unconditionally.
 
void FocusInput ()
 Gives keyboard focus to the input box – called when the AI status icon is single-clicked to bring this sidebar to the user's attention.
 

Detailed Description

A sidebar to chat with an external AI about the current worksheet (follow-up to the MCP server, GH request: "a de facto standard AI sidebar that ... gives it access to a worksheet").

Safety scope, same as the MCP server's (see McpTools.h): every message sent to the AI is accompanied by a read-only worksheet snapshot (built via McpTools, the same tool logic the MCP server itself uses), refreshed before each turn – but this first pass does NOT give the AI any tool- calling ability to actively request a specific cell/section/variable mid-conversation, and it cannot insert, edit, or evaluate anything in the worksheet. It is a read-only-context chat, not an agent. A real tool-calling loop (the AI deciding for itself to call read_cell/ read_section/watch_variable) is a natural follow-up once this ships, since McpTools already implements every tool such a loop would need – it just isn't wired up to a provider's function-calling API yet.

Needs an internet connection and an API key the user pastes into Options for one of a handful of providers (AiProvider.h) – unlike the MCP server, which is entirely local. Requires wxUSE_WEBREQUEST (wxWidgets >= 3.1.5 with a working backend); says so plainly and refuses to send anything if that's not available in this build, rather than silently failing.

Constructor & Destructor Documentation

◆ AiChatSidebar()

AiChatSidebar::AiChatSidebar ( wxWindow *  parent,
Configuration *  configuration,
Worksheet *  worksheet,
Variablespane *  variablesPane,
StatusBar *  statusBar = nullptr,
AiConnectionMonitor *  monitor = nullptr,
wxWindowID  id = wxID_ANY 
)
Parameters
statusBarThe status bar to keep the AI status icon (4th field) in sync with, or nullptr to skip that entirely – see UpdateAiStatusIcon().
monitorThe AI connection monitor sidebar to mirror raw request/response traffic into, or nullptr to skip that.

The documentation for this class was generated from the following files: