
Key takeaways
- TIMO360 stores offline activity in an O(1) append-only key-value queue capped at 20,000 events, retaining recent work and removing batches only after server confirmation.
- OutageTracker distinguishes NETWORK_DOWN (agent running, API unreachable) from SYSTEM_DOWN (machine asleep, off or crashed) after a 90-second threshold.
- Billing lapses or paused tracking return soft 402/403 refusals so the agent stays enrolled, keeps queueing locally and resumes automatically when resolved.
- Long-lived device bearer tokens are stored in Windows Credential Manager, macOS Keychain or Linux Secret Service — never plaintext webview storage.
Remote employees work on spotty home Wi-Fi, on trains and across laptop sleep cycles. If a desktop tracking agent drops events on a failed HTTP request, stalls the UI rewriting giant queue files or loses track of whether a laptop slept versus lost internet, timelines quickly turn into guesswork.
Here is how TIMO360 engineers offline resilience, outage attribution, credential storage and automatic updates inside our Tauri desktop agent and shared @etp/tracking-core package.
An O(1) Append-Only Queue Instead of One Giant JSON Array
A common mistake in local-first agents is storing queued events inside a single serialized JSON array. Every new event forces the process to read, parse, append and rewrite the entire queue. At 20,000 queued events, rewriting one array took roughly four minutes of O(n²) work — unacceptable for a background agent running on an employee's machine.
EventQueue avoids that bottleneck with an append-only log design:
- One key per event: Each payload is written under its own indexed key while a tiny head/tail metadata pointer advances in O(1) constant time.
- Bounded at 20,000 events: If a prolonged outage fills the buffer, the oldest entries drop from the head so the employee's most recent work is always preserved.
- Ack-before-delete syncing:
SyncManagerpeeks batches of up to 500 events and deletes them from the head only afterPOST /agent/eventsconfirms storage. Aflushingreentrancy guard ensures an immediateidle_startflush never races the regular 20-second sync tick.
Telling Network Drops Apart From Sleep or Crashes
When a gap appears in a workday timeline, managers need to know whether the employee simply stopped touching the keyboard, lost internet connectivity or closed their laptop. OutageTracker separates the two real outages cleanly:
NETWORK_DOWN: Every 20 seconds, the agent updates a locallastAliveAtproof-of-life timestamp even while offline. When the sync layer flips offline and stays unreachable past 90 seconds (OUTAGE_GAP_THRESHOLD_MS), restoring connectivity emits aNETWORK_DOWNevent carryingmetadata.since. Short single-request blips under 90 seconds are ignored.SYSTEM_DOWN: When a laptop sleeps, powers off or crashes, nothing is running to notice recovery. On the next launch,detectSystemDownGap()compares the current clock against the oldest oflastAliveAtand any leftover network-down marker; if 90+ seconds passed, it emits a reconstructedSYSTEM_DOWNspan before resuming.
Soft refusals keep devices enrolled
If an employee's license lapses (HTTP 402
LICENSE_INACTIVE) or an admin pauses tracking (HTTP 403TRACKING_DISABLED),SyncManagerkeeps the device enrolled, holds events safely in the local queue and shows a clear notice in the agent. Reporting resumes automatically once resolved — unlike a revoked device (HTTP 401), which signs out cleanly.
OS Keychain Credentials and Signed Auto-Updates
Because an enrolled desktop agent holds a long-lived device bearer token, keeping that secret in plaintext webview localStorage would expose it to anything reading the app's data folder. Instead, KeychainStore delegates token reads and writes through Rust's keyring crate to the operating system's native credential vault — Windows Credential Manager, macOS Keychain or Linux Secret Service — while keeping only non-sensitive queued events in local storage.
Finally, fleets drift when updates rely on manual clicks. At startup, the agent checks for updates silently and verifies every package against a public signing key pinned directly in tauri.conf.json (and uses platform-aware relaunch logic on Windows so an installer replacement never enters a restart loop).
Want to see how the backend pairs these events into clean timelines? Read Why Window Titles Break Idle Tracking or visit our Security and Privacy overview.