Skip to content

Stop/Emergency Stop also fire the 'completed' callback: status overwritten and duplicate session-log entries #41

Closed

Description

@TMHSDigital

Summary

Every stop path, including user Stop and Emergency Stop, also triggers the "completed naturally" path. As a result the status bar overwrites "Emergency Stop" with "Stopped", and the session log records two stop events per run.

Why it matters

  • After pressing ESC the user briefly sees "Emergency Stop" (red), which is replaced almost at once by "Stopped" (grey). The state indicator is the main safety feedback in the UI.
  • sessions.log gets event=stop reason=user_stop (or emergency) and event=stop reason=completed for the same run, so the log can't be used for auditing.
  • notify_click_complete() calls stop_clicking() a second time, joining from the Tk thread again.
  • Related: after Emergency Stop (which deliberately does not join), pressing F6 while the old thread is still finishing makes start_clicking() return False (click_engine.py:124-127), and the UI gives no feedback at all.

Evidence

  • autoclicker/core/click_engine.py:342-345 — finally: always calls on_click_complete() unless a safety stop fired; it doesn't check whether the stop was user-initiated.
  • autoclicker/gui/main_window.py:342-345 — _on_clicking_complete unconditionally calls controller.notify_click_complete() (logs reason=completed) and paints "Stopped".
  • autoclicker/app/controller.py:207-213.

Reproduced: on_click_complete fired after user stop: 1.

Suggested approach

  • Have the engine record a stop reason (completed/user/emergency/safety/error) and pass it to a single on_finished(reason) callback. Only max_clicks/auto_stop count as completed.
  • Alternatively, tag each run with a generation id and ignore callbacks from a superseded run.
  • When Start is refused because the previous thread is still alive, show a status message such as "Still stopping…".
  • Update the stop-path table in docs/ARCHITECTURE.md.

Done when

  • One stop event per run in sessions.log, with the correct reason (tests for each path).
  • The Emergency Stop status persists until the next action.
  • A refused Start produces visible feedback.

Activity

  1. added
    bug
    priority: medium
    safety
    on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: mediumsafety

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions