exlab_wizard.tray.main#

exlab-wizard-tray console_scripts entry point. Backend Spec §4.3.2.

Wires the long-lived process:

  1. Configure logging.

  2. Build / load the FastAPI app.

  3. Construct AutostartManager, ServerRunner, WindowLauncher, QuitCoordinator, StatusTicker, and NotificationBus.

  4. Build the pystray Icon and run its event loop.

The orchestration is intentionally light – each component owns its own lifecycle; main() is the assembly point. Tests cover the wiring by constructing TrayApp directly with stub components; the real main() resolves production wiring (FastAPI app + state dir) and delegates.

Functions

main([argv])

exlab-wizard-tray entry point.

Classes

TrayApp(server_runner, window_launcher, ...)

Bundle of long-lived tray components.

class exlab_wizard.tray.main.TrayApp(server_runner, window_launcher, quit_coordinator, status_ticker, notification_bus, autostart, icon=None)[source]#

Bases: object

Bundle of long-lived tray components.

The launcher constructs one and calls run(); tests build one with stub components and exercise shutdown() / open() individually.

Parameters:
autostart: AutostartManager#
icon: Any = None#
notification_bus: NotificationBus#
open_window()[source]#

Spawn or focus the window subprocess.

Return type:

None

quit_coordinator: QuitCoordinator#
request_quit()[source]#

Trigger the graceful-shutdown protocol on the icon thread.

Return type:

None

run(*, run_loop=None)[source]#

Start the server, build the icon, run the pystray loop.

run_loop is injected by tests so they don’t actually call Icon.run (which would block on a real backend). Returns the exit code.

Parameters:

run_loop (Callable[[], None] | None)

Return type:

int

server_runner: ServerRunner#
shutdown()[source]#

Tear down sub-components synchronously.

Return type:

None

start_server()[source]#

Start the in-process FastAPI server. Returns the bound port.

Return type:

int

status_ticker: StatusTicker#
window_launcher: WindowLauncher#
exlab_wizard.tray.main.main(argv=None)[source]#

exlab-wizard-tray entry point.

The main thread runs pystray; the FastAPI server runs on a worker thread inside ServerRunner. The function returns the exit code (0 on clean tray-driven Quit).

Parameters:

argv (list[str] | None)

Return type:

int