Skip to main content

Module breaks

Module breaks 

Source

Structs§

PostponeOutcome
Returned by postpone_break_impl so test callers can see what the command would have emitted. The shim discards this in production.

Functions§

compute_postpone_state 🔒
Lock-then-snapshot helper: settings first (cloned and released), then timers (read and released). Never holds two scheduler mutex guards across an .await, so two concurrent callers can’t deadlock even if the rest of the codebase locks them in the opposite order.
effective_postpone_secs 🔒
end_break
Conclude the currently-active break. reason distinguishes "completed" (taken in full), "dismissed" (user closed it early), and "postponed" (countdown wasn’t honoured). Updates the session counters, fires break_end hooks, hides every overlay window, and emits break:end.
get_last_break_info
The most recently skipped or postponed break — drives the tray’s “Resume last skipped break” menu item.
get_pause_info
Current pause status for the renderer. While paused with a deadline, remaining_secs is the live countdown; while paused indefinitely it’s None.
get_postpone_state
Per-kind postpone budget snapshot for the overlay button label (e.g. “Postpone (2 of 3)”).
pause
Pause the scheduler. duration_secs = None pauses indefinitely; Some(n) pauses for n seconds. Fires pause_start hooks and emits the pause:changed event. Idempotent — a pause-while-paused updates the deadline but doesn’t re-fire hooks.
pause_impl
Pause-state mutation core: updates the in-memory state, persists, logs the event, and fires pause_start hooks on a true running→paused edge. AppHandle-free so unit tests can drive it.
postpone_break
Push the active break out by the configured postpone interval (with optional escalation by previous postpone count). Errors when strict_mode / postpone_enabled = false block postpone or when the per-break postpone cap is reached. Side-effects: bumps the per-kind postpone counter, fires break_postponed hooks, hides overlays.
postpone_break_impl
Postpone-state mutation core: validates the request, updates timers, bumps counters, logs, fires hooks. AppHandle-free; the calling #[tauri::command] wrapper handles overlay hides + IPC emits.
resume
Resume the scheduler from any pause state. Fires pause_end hooks and emits pause:changed. No-op if already running.
resume_impl
Resume-state mutation core: clears the pause, persists, logs, and fires pause_end hooks on a true paused→running edge.
resume_last_break
Renderer-facing resume. Thin wrapper over resume_last_break_impl.
resume_last_break_impl
Re-fire the most recently skipped/postponed break with the current profile’s full settings (duration, hints, enforceability). Shared by the renderer command and the tray menu handler. Errors with "no break to resume" when the slot is empty.
skip_next_break
Renderer-facing skip. Thin wrapper over skip_next_from_cli.
skip_next_break_impl
Skip-next mutation core. Resets the per-kind interval anchor to Instant::now(), clears warn/deferred flags, zeroes the postpone counter, bumps the session skip total, logs, and fires hooks. AppHandle-free; the wrapper handles IPC emits.
skip_next_from_cli
Reset the next-break timer for kind so the user “skips” the upcoming break. Shared by the renderer command and the CLI’s skip subcommand. Errors when strict_mode is on.
test_break_enforceable 🔒
Mirrors the enforceability rule used by the scheduler’s normal break-firing paths in run_loop.rs: micro/long obey their own *_enforceable flag OR strict_mode, while sleep is always enforceable.
trigger_break_from_cli
Fire a one-off break of the given kind right now. Shared by the renderer-facing trigger_test_break and the CLI’s trigger command. Bypasses suppression checks (the user asked explicitly).
trigger_test_break
Renderer hook to fire a break immediately — used by the “Test now” buttons on the Schedule tab.