# System tray


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Runtime dependencies

## Dispatcher

------------------------------------------------------------------------

<a
href="https://github.com/sayanbanerjee32/snooper_pkg/blob/main/snooper_pkg/tray.py#L27"
target="_blank" style="float:right; font-size:smaller">source</a>

### UiDispatcher

``` python
def UiDispatcher(
    root
):
```

Dispatches callbacks from background threads to Tkinter’s main thread,
ensuring UI updates are executed safely through the root event loop.

## Report actions

------------------------------------------------------------------------

<a
href="https://github.com/sayanbanerjee32/snooper_pkg/blob/main/snooper_pkg/tray.py#L63"
target="_blank" style="float:right; font-size:smaller">source</a>

### open_current_session_report

``` python
def open_current_session_report(
    controller, # Controller used to generate current-session report data
    root, submit_ui
):
```

*Show the current-session report when report data is available.*

------------------------------------------------------------------------

<a
href="https://github.com/sayanbanerjee32/snooper_pkg/blob/main/snooper_pkg/tray.py#L48"
target="_blank" style="float:right; font-size:smaller">source</a>

### open_last_session_report

``` python
def open_last_session_report(
    controller, # Controller used to generate last-session report data
    root, submit_ui
):
```

*Show the last-session report when report data is available.*

## Tray menu and event loop

------------------------------------------------------------------------

<a
href="https://github.com/sayanbanerjee32/snooper_pkg/blob/main/snooper_pkg/tray.py#L79"
target="_blank" style="float:right; font-size:smaller">source</a>

### run_tray

``` python
def run_tray(
    controller, # Controller that owns monitoring and pause/resume state
    show_last_on_start:bool=False, # Whether to show the last session report on app start up
):
```

*Start the tray integration and block in the Tkinter event loop until
exit.*

- `root = tk.Tk()` runs at module-import time. This creates a GUI object
  as an import side effect and will also fail in headless environments.
  Confirm that import-time Tk initialization is intentional.

- The report helpers call
  [`show_report`](https://sayanbanerjee32.github.io/snooper_pkg/report_window.html#show_report)
  from new daemon threads. This appears inconsistent with the project
  rule that Tkinter UI operations should run on the Tk main thread,
  preferably through `root.after(...)`.

- After pausing, `pause_for` calls
  `open_current_session_report(controller)`. Because pausing ends the
  current session, confirm whether this should instead display the
  report for the just-ended session.

- Cancelling the custom pause dialog performs no pause. It does not use
  `DEFAULT_PAUSE_MINUTES`; confirm whether this is the intended current
  behaviour.

- `root` is exported as part of the module’s public API because its cell
  uses `#| export`. Confirm whether it should remain public or
  eventually become an internal implementation detail.

- The public functions accept an untyped `controller`. The comments
  document how it is used, but the implementation does not identify a
  concrete controller type, so no type annotation has been invented.

- The current notebook output shows that the failed `pystray` import
  prevented `tk` from being imported, which caused the later
  `root = tk.Tk()` cell to fail with `NameError`. This is a cascading
  notebook-execution failure rather than an independent missing import.
