Skip to content

Add simulation menu with speed control#486

Merged
bedaHovorka merged 3 commits intocopilot/goal-7-simulation-speed-controlfrom
copilot/add-simulation-menu-bar
May 5, 2026
Merged

Add simulation menu with speed control#486
bedaHovorka merged 3 commits intocopilot/goal-7-simulation-speed-controlfrom
copilot/add-simulation-menu-bar

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

Adds a "Simulation" menu to the MenuBar (positioned between File and Help) and wires it into the existing simulation infrastructure.

Changes Made

MenuBar (MenuBar.kt)

  • "Start..." action: shows a file chooser dialog, loads the selected XML as a SimulationContext via SimulationContextFactory, then calls Frame.setContext() + Frame.startSimulation()
  • "Stop" action: terminates the running simulation cleanly via Frame.stopSimulation()
  • Separator between Start/Stop and the Speed submenu
  • "Speed" submenu with 5 presets (0.1x, 0.5x, 1x, 2x, 10x) and keyboard accelerators (keys 1–5) that call SimulationController.setSpeed()
  • Updated "Usage" help dialog to document simulation keyboard shortcuts

SimulationController (SimulationController.kt)

  • Added setSpeed(multiplier: Double) method with input validation; stores the desired speed and applies it immediately to the current runner (if any) and to each new runner on start()

MenuBarTest (MenuBarTest.kt)

  • Updated menu count assertion from 2 to 3
  • Updated Help menu index from 1 to 2
  • Added 7 new Simulation menu tests: Start/Stop actions, separator, Speed submenu presence, 5 preset items, correct labels, and keyboard accelerators

Testing

  • ✅ Compilation clean
  • detekt and ktlintCheck pass
  • ✅ All MenuBarTest integration tests compile and run (skipped in headless CI as expected)

@bedaHovorka
Copy link
Copy Markdown
Owner

@copilot : please try again

@bedaHovorka
Copy link
Copy Markdown
Owner

@copilot : please try again

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 5, 2026

@copilot : please try again

Done in commit 5e85d2c. The implementation adds:

  • SimulationController.setSpeed() — stores desired speed and applies it to the current runner immediately; also applied to new runners on start()
  • "Simulation" menu (between File and Help) with:
    • Start... — JFileChooser → loads XML as SimulationContextFrame.setContext() + Frame.startSimulation()
    • Stop — calls Frame.stopSimulation()
    • Separator
    • Speed submenu: 0.1x/0.5x/1x/2x/10x with keyboard accelerators (keys 1–5)
  • Updated "Usage" help text documenting the simulation shortcuts
  • MenuBarTest updated: menu count 3, Help at index 2, 7 new Simulation menu tests (Start, Stop, separator, Speed submenu, 5 items, labels, accelerators)

Copilot AI changed the title [WIP] Add simulation menu with speed control Add simulation menu with speed control May 5, 2026
@bedaHovorka bedaHovorka marked this pull request as ready for review May 5, 2026 19:50

This comment was marked as resolved.

@bedaHovorka
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 5, 2026

@copilot apply changes based on the comments in this thread

Done in commit 895fd42. Applied all four issues from the review:

  1. Resource leakStartSimulationAction now loads via editingContextFactory.createContext(file).use { editCtx -> simulationContextFactory.createContext(editCtx) } so the intermediate EditingContext scope is closed immediately after transformation.
  2. Report typessimContext.addReportTypes(*ReportType.values()) is called before frame.setContext(), so AnimationController and EventTimelinePanel receive property-change events and the animation is not visually frozen.
  3. ModificationTrackermarkClean() and setCurrentFile(null) are called before switching to simulation mode, preventing the window-close handler from attempting to save through the editor path.
  4. setSpeed() tests — Added 5 new tests to SimulationControllerTest: below-min throws, above-max throws, boundary values accepted, applies immediately to active runner, and pre-selected speed is carried into the next start().

Copilot AI requested a review from bedaHovorka May 5, 2026 20:19
@bedaHovorka bedaHovorka force-pushed the copilot/add-simulation-menu-bar branch from 895fd42 to 514be4c Compare May 5, 2026 20:40
Copilot AI and others added 3 commits May 5, 2026 22:44
…r modificationTracker, add setSpeed tests

Agent-Logs-Url: https://github.com/bedaHovorka/interlockSim/sessions/d9498f97-4781-4986-98c1-96cb2a57850d

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
@bedaHovorka bedaHovorka force-pushed the copilot/add-simulation-menu-bar branch from 514be4c to b1acb3e Compare May 5, 2026 20:48
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@bedaHovorka bedaHovorka merged commit b23bcb1 into copilot/goal-7-simulation-speed-control May 5, 2026
9 checks passed
@bedaHovorka bedaHovorka deleted the copilot/add-simulation-menu-bar branch May 5, 2026 22:18
Copilot AI added a commit that referenced this pull request May 6, 2026
* Add Simulation menu with Start/Stop/Speed control to MenuBar

Agent-Logs-Url: https://github.com/bedaHovorka/interlockSim/sessions/69dde112-6219-41c1-8517-555ceb9dcb6e

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

* Apply reviewer feedback: fix resource leak, enable report types, clear modificationTracker, add setSpeed tests

Agent-Logs-Url: https://github.com/bedaHovorka/interlockSim/sessions/d9498f97-4781-4986-98c1-96cb2a57850d

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
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.

Phase 2.3: MenuBar Simulation Menu

3 participants