spacr.qt.widgets.ai_chat_panel

AIChatPanel — reusable chat widget hosting the spacr AI Console.

Meant to be embedded next to the pipeline Console (via a QDockWidget on the main window) so users never leave the app they’re running. Exposes open_error_flow(traceback, active_app) for AppScreen’s “Explain error” button.

Design notes

  • One instance is shared across the whole main window; the user’s chat context persists as they switch between Mask/Measure/etc.

  • Streaming is done in a QThread via spacr.qt.ai.worker.StreamWorker. The worker reference is stored on self — if we let Python drop it, Qt may never deliver the finished signal.

  • There is NO “already streaming” guard. If a stream is in flight, the Send button turns into Cancel so the user can always recover.

Module Contents

class spacr.qt.widgets.ai_chat_panel.AIChatPanel(parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QWidget

Full chat panel — embed inside a QDockWidget or any container.

refresh_provider_combo() None[source]

Rebuild the provider dropdown from the currently configured CLIs.

clear_chat() None[source]

Discard chat history and remove every bubble from the scroll area.

open_error_flow(traceback_text: str, active_app: str = '') None[source]

Send a traceback to the AI explainer and stream the reply.

Parameters:
  • traceback_text – raw traceback captured from the pipeline.

  • active_app – optional app label used in the framing prompt.