Skip to content

IPC contract

Every interaction between the React renderer (and the CLI) and the Rust backend goes through Tauri's invoke / emit primitives. This page is the canonical list of what's available; the Rust API reference has the full type-signature view of the same surface.

Commands

Renderer code calls these with invoke<ReturnType>("command_name", { args }). CLI calls go through the local TCP IPC server (see Local IPC below). All commands live under scheduler::commands::* (or the small set of standalone modules listed last).

Settings

CommandArgsReturnsNotes
get_settingsSettingsActive profile's settings.
update_settingsnew: Settings()Hook fields are stripped before merge; use set_hooks for those.

Hooks

CommandArgsReturnsNotes
set_hookshooks_enabled: bool, hooks: Hook[]()Fires a native confirm dialog. Errors when one is already open or the user declines.

Profiles

CommandArgsReturnsNotes
list_profilesstring[]In tray-menu order.
get_active_profilestring
set_active_profilename: string()Resets per-profile timers (last_sleep preserved). Emits profile:changed.
create_profilename: string()Copies the currently-active profile's settings.
duplicate_profilesource: string, name: string()Copies source without flipping the active profile.
rename_profilefrom: string, to: string()Active pointer follows the rename.
delete_profilename: string()Refuses the only profile or the active profile.
reorder_profilesnames: string[]()Must be a permutation; rejects mismatches.
reset_profile_to_defaultsname: string()If name is active, in-memory settings reset too.

Breaks

CommandArgsReturnsNotes
pauseduration_secs?: number()Indefinite when omitted. Fires pause_start hooks + pause:changed.
resume()Fires pause_end hooks + pause:changed.
get_pause_infoPauseInforemaining_secs ticks live for timed pauses.
end_breakreason?: "completed" | "dismissed" | "postponed"()Default "completed". Updates session counters, fires break_end hooks.
trigger_test_breakkind: BreakKind, duration_secs: number()Bypasses suppressions. Used by the "Test now" buttons.
postpone_breakkind: BreakKind()Errors when strict_mode / postpone_enabled = false or the per-break cap is hit.
skip_next_breakkind: BreakKind()Errors when strict_mode is on.
get_postpone_statekind: BreakKindPostponeState{ count, max, remaining }.
get_last_break_infoLastBreakInfoDrives the tray's "Resume last skipped" item.
resume_last_break()Re-fires the last skipped/postponed break with current settings.

Stats

CommandArgsReturnsNotes
get_break_statsBreakStatsIn-session counter; resets on app restart.
reset_break_stats()Emits stats:changed. Doesn't touch events.jsonl.
get_stats_digestrange?: "week" | "month"DigestDefault "week". Aggregates events.jsonl.
export_stats_csvstringCSV body for the "Export CSV" download.
clear_event_log()Deletes events.jsonl. Emits stats:cleared.
get_idle_secsnumberSeconds since last input.
get_screen_timeScreenTimeStateAuto-rolls over at local midnight.
get_current_breakBreakEvent | nullLets the overlay rehydrate after a reload.

Misc

CommandArgsReturnsModule
check_for_updateUpdateInfoupdater.rs — GitHub Releases check, 10s timeout.
build_diagnostics_reportstringdiagnostics.rs — redacted markdown report for issue templates.
get_platformstringplatform.rsstd::env::consts::OS.

Events

The backend emits these via app.emit. The renderer subscribes with listen<Payload>("event:name", handler) from @tauri-apps/api/event.

EventPayloadFired by
break:startBreakEventoverlay::fire_break
break:end()end_break, postpone_break
pause:changedbooleanpause, resume, tray pause buttons, run-loop on auto-resume
stats:changedBreakStatsend_break, skip_next_from_cli, reset_break_stats
last_break:changedLastBreakInfoend_break, postpone_break, skip_next_from_cli, resume_last_break
profile:changedstringevery profile-mutating command
screen_time:remindernumber (budget minutes)run-loop when the daily budget is crossed
stats:cleared()clear_event_log

Local IPC

ipc.rs runs a TCP server on 127.0.0.1 that accepts JSON envelopes from the CLI when a normal user wants to drive a running Entracte from a terminal. Each request is:

json
{
  "token": "<contents of ipc-token>",
  "request": { "cmd": "...", "...": "..." }
}

The token is a 32-byte hex string written to <data_dir>/ipc-token (mode 0o600) at app start. The CLI reads it before sending. Server-side comparison uses subtle::ConstantTimeEq so a wrong token doesn't leak through timing.

Available requests mirror a subset of the Tauri commands but with a tightened surface:

RequestEquivalent
statuscombines get_pause_info + get_active_profile
profile_listlist_profiles
profile_use { name }set_active_profile
settings_get { key }one field of get_settings
settings_set { key, value }one field of update_settingshooks / hooks_enabled are denylisted
pause { duration_secs? }pause
resumeresume
trigger { kind }trigger_test_break with the configured duration
skip { kind }skip_next_break

The CLI itself is documented in the user-facing CLI guide.

Released under the Apache 2.0 License.