Skip to content

Feat/breakpoints#1000

Open
MSherbinii wants to merge 21 commits intodevelopfrom
feat/breakpoints
Open

Feat/breakpoints#1000
MSherbinii wants to merge 21 commits intodevelopfrom
feat/breakpoints

Conversation

@MSherbinii
Copy link
Copy Markdown
Collaborator

Goal

When debugging complex state machines or preparing live demos, developers need a way to pause execution at specific states. Currently, they must use "run to selected state" which can be unreliable due to zoom/UI issues, or manually pause execution or use step through debugging for the entire execution. This is particularly problematic during demos where pre-run sequences take significant time. This feature adds traditional IDE style breakpoints that automatically pause execution when reaching marked states providing a reliable alternative.

Changes

  • Add BreakpointManager class for breakpoint tracking and management
  • Integrate BreakpointManager into ExecutionEngine to check breakpoints during execution
  • Add breakpoint check in State.start() that pauses execution when breakpoint is hit
  • Add breakpoints panel in main window with list view and management controls
  • Add breakpoint checkbox to state overview panel for quick toggling
  • Add visual indicator (red dot) on state transitions for breakpointed states
  • Support enable/disable individual breakpoints without removing them
  • Support enable/disable all breakpoints at once
  • Support removing individual or all breakpoints

How It Works

When a user sets a breakpoint on a state:

  1. User can toggle breakpoint via checkbox in state overview panel OR via the breakpoints panel
  2. Breakpoint is registered in BreakpointManager with state ID, display name, and file system path
  3. During execution, before each state runs, the system checks if a breakpoint is set
  4. If breakpoint is enabled, execution automatically pauses and logs "Breakpoint hit: [state name]"
  5. Visual indicator (red dot) appears on transitions leading to breakpointed states
  6. User can manage all breakpoints from dedicated breakpoints panel with controls:
    • Enable/Disable individual breakpoints (checkbox)
    • Remove selected breakpoint
    • Remove all breakpoints
    • Disable/Enable all breakpoints at once
    • Refresh list to sync with current state

UI Components

Breakpoints Panel

  • Located in main window as a new tab/panel
  • Tree view with columns: Enabled (checkbox), State Name, File System Path
  • Toolbar buttons: Refresh, Remove, Remove All, Disable/Enable All
  • Real-time updates when breakpoints are added/removed from state overview

State Overview Panel

  • New "Breakpoint" checkbox added below state properties
  • Checkbox state syncs with BreakpointManager
  • Builds hierarchical display name

Visual Indicators

  • Red dot appears on transitions leading to breakpointed states
  • Drawn at arrow endpoint on the graphical state machine view
  • Visible indicator helps identify which states have active breakpoints

- Add BreakpointManager class to manage breakpoints centrally
- Store breakpoints by file_system_path basename (stable identifier)
- Implement add, remove, toggle, and query methods
- Support enable/disable and clear all functionality
- Session-only storage (cleared when RAFCON closes)
- Add BreakpointManager instance in ExecutionEngine.__init__
- Import BreakpointManager from breakpoint_manager module
…e types

- Add breakpoint check in State.start() run_wrapper before self.run()
- Check applies to all state types (ExecutionState, HierarchyState, LibraryState)
- Pause execution when breakpoint is hit
- Uses file_system_path from base State class
- Create BreakpointsView with GTK TreeView to display breakpoints
- Show columns: State name, Path, Enabled checkbox
- Buttons: Remove Selected, Remove All, Refresh, Toggle All
- View displays data without business logic
- Create BreakpointsController to manage breakpoints panel
- Populate TreeView from BreakpointManager.get_all_breakpoints()
- Handle user actions: toggle enabled, remove selected, remove all
- Update BreakpointManager when user makes changes
- Follows MVC pattern: controller bridges view and model
- Add Breakpoints tab to right sidebar in main window
- Wire up BreakpointsController in MainWindowController
- Add breakpoints view container to main_window.glade
- Add breakpoints view to main window view class
- Add breakpoint checkbox to state properties in overview panel
- Available for all state types
- Checkbox reflects current breakpoint state
- Toggle adds/removes breakpoint via BreakpointManager
- Draw red dot on transitions leading to states with breakpoints
- Uses Cairo graphics library for rendering
- Provides visual feedback in graphical state machine view
- Move import from inside function to module level
- Follows Python best practice of top-level imports
@flolay
Copy link
Copy Markdown
Collaborator

flolay commented Feb 5, 2026

I tested it for a simple state machine and there it works as expected great job.

For which kind of states did you test it?

Does it work for:

  • library states?
  • concurrency states?

also as a discussion point:
Do we want it to be configurable? (i.e. do we want to have a config entry to enable or disable it?)

  • for me personally, I think it can be default, since it does not add any overhead, I think we can just have it there

And another missing functionality:
How it is now
To enable a checkpoint, I need to click on a state and in the right view need to check the box for breakpoint.

Suggestion:
Additionally, I think being able to right-click on a state and have a "set / unset breakpoint" button there would be great.

What do you guys think?

@MSherbinii
Copy link
Copy Markdown
Collaborator Author

Yes, it should work for library and concurrency states, I tested them during development.

For configs, we could introduce a debugging mode if needed.

Also, right-click support should be straightforward to add.

@JohannesErnst
Copy link
Copy Markdown
Collaborator

I also agree for the right click thing, I think it is a nice idea! Generally I like the feature and the visuals are nice and intuitive, good job! I tested only very briefly here is what I found:

  • Another right click option for the breakpoints menu would also be nice in addition to what @flolay suggested. The functionality should just be to deactivate or remove the selected breakpoint (in addition to the buttons at the bottom of the window)
  • When the execution engine is paused at a breakpoint and I press stop (abort), the state machine with the breakpoint is still executed when it should actually stop the execution
  • Maybe updating the graphical editor faster would be nice: Right now when a breakpoint is added, the red marker only appears after some seconds or when hovering over the graphical editor. Probably we can send a signal to update it immediately if something changes?
  • I didn't look at the code yet but apparently some other functionalities broke. To reproduce: Try adding a new state machine to an existing one and drag the entry logic connection to it. The logic connection doesn't appear and when trying to run the state machine I get a TypeError: expected str, bytes or os.PathLike object, not NoneType. Maybe this problem should be tackled first

@MSherbinii
Copy link
Copy Markdown
Collaborator Author

  1. For the right click, agreed and will start developing it.
  2. I will reproduce this case and debug to understand whats happening, also a good point as I keep those for the unit tests.
  3. I agree, improvements must be done for speed and effeciency, the inital goal here was to have a functional feature then iterate upon it to be more optimized and sophisticated, there is probably an ability to signal an instant refresh to update the GUI with the red marker so it looks more seamless, will investigate.
  4. Is this issue linked to the new feature specifically? or is that another issue we should tackle?

@JohannesErnst
Copy link
Copy Markdown
Collaborator

About 4.: I think this is connected to the breakpoint feature as it doesn't happen on another branch version

@JohannesErnst
Copy link
Copy Markdown
Collaborator

I discovered another minor bug:
When adding a breakpoint (e.g via right-click menu), it appears in the Breakpoints widget as expected. Also, the checkbox in the State Editor is activated. However, when removing a breakpoint via the "Remove" button in the Breakpoints widget (bottom left), the Graphical Editor is not removing the red dot immediately and also the checkbox in the State Editor stays activated.

flolay
flolay previously approved these changes Apr 2, 2026
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