Work in progress: this documentation is still being written and reviewed. Check details against the source code.

Chat interface

Present messages, tool calls, execution outcomes, and Plan/Run controls.

mtc_gui.chat_panel Β· Source

Operator GUI Β· Guide Β· Symbol index

How it is used

MTCMainWindow connects ChatPanel to AgentBridge. The panel emits message_submitted and mode_change_requested; bridge signals feed its message and status methods. The panel itself neither opens an agent connection nor submits robot goals.

Update this widget on the GUI thread. Messages are rendered as plain text, tool details expand on demand, and set_thinking() controls both the animation and input availability. Mode radios remain disabled until the bridge acknowledges a change through the main window.

Start here

Callable

Purpose

ChatPanel.__init__

Create the conversation view, input controls, status, and Plan/Run selector.

ChatPanel.append_assistant

Append an assistant bubble stamped with current local HH:MM time.

ChatPanel.append_tool_call

Append an expandable tool-call bubble.

ChatPanel.set_thinking

Show or hide the thinking indicator and disable or enable chat input.

ChatPanel.append_execution_outcome

Render the result of an agent-initiated execution as an assistant or error bubble.

ChatPanel

Own conversation widgets, input, and mode controls. It communicates through signals so the main window can coordinate agent and execution state.

Inherits from: QWidget.

ChatPanel.__init__()

Create the conversation view, input controls, status, and Plan/Run selector.

Lifecycle Β· Source

__init__(self, parent=None)

Parameter

Meaning

parent

Optional parent widget.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Defaults to Plan and Connecting, connects radio/send/clear handlers, and installs an input-key event filter. Starts no agent connection.

Referenced in source (1)

ChatPanel.append_assistant()

Append an assistant bubble stamped with current local HH:MM time.

Callback Β· Source

append_assistant(self, text: str) -> None

Parameter

Meaning

text

Plain-text assistant response to show.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Creates a MessageBubble and schedules bottom scrolling.

ChatPanel.append_tool_call()

Append an expandable tool-call bubble.

Callback Β· Source

append_tool_call(self, name: str, args_json: str, result: str) -> None

Parameter

Meaning

name

Tool name.

args_json

Already serialized argument display text.

result

Tool-result display text.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Creates ToolCallBubble and schedules bottom scrolling; performs no tool invocation.

ChatPanel.set_thinking()

Show or hide the thinking indicator and disable or enable chat input.

Callback Β· Source

set_thinking(self, is_thinking: bool) -> None

Parameter

Meaning

is_thinking

True starts animation and disables send/input; False stops animation and reenables them.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Updates animation and enabled states; finishing restores input focus. Mode radios and Clear remain independently controlled.

ChatPanel.append_execution_outcome()

Render the result of an agent-initiated execution as an assistant or error bubble.

Callback Β· Source

append_execution_outcome(
    self,
    success: bool,
    error: str,
    completed: int,
    total: int,
) -> None

Parameter

Meaning

success

True selects the succeeded assistant message; False selects an error bubble.

error

Optional failure detail appended only on unsuccessful outcomes.

completed

Completed step count shown in the summary.

total

Total step count shown in the summary.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Formats completed/total outcome text, creates the appropriate bubble, and schedules scrolling.

ChatPanel.set_status()

Replace the connection/status label text.

Method Β· Source

set_status(self, text: str) -> None

Parameter

Meaning

text

Complete display string; no suffix or formatting is added.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Sets _status_label text.

ChatPanel.append_user()

Append a user bubble stamped with current local HH:MM time.

Method Β· Source

append_user(self, text: str) -> None

Parameter

Meaning

text

Plain-text user message to show.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Creates a MessageBubble and schedules scrolling to the bottom; does not send the message.

ChatPanel.set_mode_label()

Reenable both mode radios and synchronize their checked state after bridge acknowledgment.

Method Β· Source

set_mode_label(self, mode: str) -> None

Parameter

Meaning

mode

β€œplan” or β€œrun” selects the matching radio; other strings only reenable the controls.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Temporarily blocks the radio being set to prevent another selected-state request. Despite the method docstring, it does not alter status-label text.

Internal callbacks and helpers

ChatPanel.eventFilter()

Submit on Return/Enter unless Shift is held; allow Shift+Enter to insert a newline.

Callback Β· Source

eventFilter(self, obj, event)

Parameter

Meaning

obj

Watched QObject; custom handling applies only to input_field.

event

Qt keyboard/event object; key and modifier fields are inspected only for KeyPress.

Returns: True when an Enter key was handled, False for Shift+Enter, otherwise the base event-filter result.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: May clear input and emit message_submitted through _on_send.

ChatPanel.append_error()

Append a styled error bubble to the conversation.

Callback Β· Source

append_error(self, text: str) -> None

Parameter

Meaning

text

Plain-text error message.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Creates ErrorBubble and schedules bottom scrolling.

ChatPanel.clear_chat()

Remove all conversation widgets while retaining the layout’s trailing stretch.

Callback Β· Source

clear_chat(self) -> None

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Takes message items from the layout and schedules their widgets for deletion. It does not emit a clear-history signal or call AgentBridge.clear_history.

Referenced in source (1)

ChatPanel._on_mode_radio_toggled()

Request the newly selected mode and disable the radios until acknowledgment.

Callback Β· Source

_on_mode_radio_toggled(self, checked: bool) -> None

Parameter

Meaning

checked

Qt toggled payload; False returns immediately.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Determines mode from Plan’s checked state, disables both radios, and emits mode_change_requested(β€œplan” or β€œrun”).

Referenced in source (1)

ChatPanel._on_send()

Trim nonempty input, clear the editor, and emit the user message.

Callback Β· Source

_on_send(self) -> None

Returns: None.

Errors: Blank/whitespace-only text is ignored; Qt errors otherwise propagate.

Side effects: Clears input and emits message_submitted; bubble insertion is left to the connected main-window handler.

Referenced in source (2)

ChatPanel._add_message_widget()

Insert a conversation widget immediately before the trailing stretch.

Internal helper Β· Source

_add_message_widget(self, widget: QWidget) -> None

Parameter

Meaning

widget

Message/error/tool QWidget to append to the scrollable conversation.

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Adds widget to the layout and schedules _scroll_bottom after 10 ms to allow layout sizing.

Referenced in source (5)

ChatPanel._scroll_bottom()

Scroll the conversation to its current vertical maximum.

Callback Β· Source

_scroll_bottom(self) -> None

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Sets the vertical scrollbar value to maximum.

Referenced in source (1)

MessageBubble

Display one selectable plain-text user or assistant message with role styling and an optional timestamp.

Inherits from: QFrame.

MessageBubble.__init__()

Create a selectable plain-text message bubble with role styling and an optional timestamp.

Lifecycle Β· Source

__init__(self, text: str, role: str, timestamp: str='', parent=None)

Parameter

Meaning

text

Message text displayed as PlainText, not interpreted as HTML or Markdown.

role

β€œuser” uses right-aligned You styling; every other value uses Assistant styling.

timestamp

Optional already-formatted timestamp string; empty suppresses its label.

parent

Optional parent widget.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Builds labels/frame; user and assistant variants use opposite margins and alignments.

Referenced in source (3)

ToolCallBubble

Display a tool name with expandable plain-text arguments and result.

Inherits from: QFrame.

ToolCallBubble.__init__()

Create a collapsed tool-name button and hidden plain-text argument/result details.

Lifecycle Β· Source

__init__(self, name: str, args_json: str, result: str, parent=None)

Parameter

Meaning

name

Tool name shown as name().

args_json

Argument display text retained unchanged; the bridge may already have truncated it.

result

Result display text retained unchanged.

parent

Optional parent widget.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Stores arguments/result, builds widgets, and connects the header to expansion toggling.

Referenced in source (1)

Internal callbacks and helpers

ToolCallBubble._toggle()

Expand or collapse the saved tool-call arguments and result.

Callback Β· Source

_toggle(self)

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Flips _expanded; expansion writes β€œArgs: … Result: …”, shows detail, and reapplies header styling; collapse hides detail.

Referenced in source (1)

ErrorBubble

Display a selectable plain-text error message in the conversation.

Inherits from: QFrame.

ErrorBubble.__init__()

Build an amber error bubble with a selectable plain-text message and optional alert icon.

Lifecycle Β· Source

__init__(self, text: str, parent=None)

Parameter

Meaning

text

Error text displayed without HTML interpretation.

parent

Optional parent widget.

Errors: Optional qtawesome icon failures are suppressed; other Qt errors propagate.

Side effects: Creates Error heading, colored frame, and message label.

Referenced in source (2)

ThinkingIndicator

Animate the waiting indicator with a Qt timer. ChatPanel starts and stops it around agent turns.

Inherits from: QFrame.

ThinkingIndicator.__init__()

Create three dot labels and an inactive animation timer.

Lifecycle Β· Source

__init__(self, parent=None)

Parameter

Meaning

parent

Optional parent widget.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Initializes _tick=0 and connects the timer to _animate; does not start it.

Referenced in source (1)

ThinkingIndicator.start()

Restart the dot animation from tick zero at a 400 ms interval.

Method Β· Source

start(self)

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Resets tick, starts the QTimer, and shows the indicator; existing dot styles update on the next timeout.

ThinkingIndicator.stop()

Stop thinking animation and hide its frame.

Method Β· Source

stop(self)

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Stops the timer and hides the indicator.

Internal callbacks and helpers

ThinkingIndicator._animate()

Advance the waiting animation by one step.

Callback Β· Source

_animate(self)

Returns: None.

Errors: Qt/widget errors propagate; no local exception handler.

Side effects: Changes dot colors/font sizes and increments _tick.

Referenced in source (1)