Repository navigation
friglet-tray: real Stop scanning / daemon controls, no flashing errors, daemon log file (SNB-658) - #37
Merged
Conversation
…s, log files (SNB-658) Scanning controls - ScanSupervisor kept reporting "not running" the moment Stop was asked, while the scan task could not end until its next await: blindbit-lib's P2P block download is blocking I/O inside the scan future (up to 90 s per attempt). The UI then offered Start, and the Stop request held the apply lock, so a Start queued behind it resumed scanning right after. The task entry now stays until the task really ended (ScanState Stopping -> Paused), Stop answers within 3 s (with a note while still stopping), Start while stopping is refused, the select! checks the cancellation first, and the pause survives an in-process restart. - GetStatus no longer waits on the oracle (a background poller keeps the tip): an unresponsive oracle made every status answer take ~2 s, longer than the tray's poll timeout, so the tray called the daemon unreachable and eventually killed it as wedged. Daemon controls - Stop daemon / Start daemon in the window and the tray menu, for a tray-spawned daemon and an attached external one alike; the Status tab says who started it and what Quit does. An explicit stop, and a daemon exiting with status 0, are never undone by the auto-restart supervisor. Errors vs waiting - view.rs derives what is shown: a stall or oracle outage is "waiting" for 2 minutes, an unanswering daemon "reconnecting" for 10 s, then an error. Errors stay under "Needs attention" with their start time until resolved and remain in a Recent errors list; each one is logged. - The setup flow no longer flashes "Daemon unreachable": attach/spawn publishes the daemon's status at once instead of waiting for the next poll. Logs - The daemon writes friglet.log and the tray friglet-tray.log in $XDG_STATE_HOME/friglet (macOS ~/Library/Logs/friglet, Windows %LOCALAPPDATA%\friglet\logs), 10 MiB cap with two rotations; FRIGLET_LOG_FILE overrides or turns off the daemon's. Logging starts before the config is read, so config errors land in the file too. The tray forwards daemon output at its own level (info/warn/error), shows both paths and has an Open log folder button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 2, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SNB-658: the bugs from the first mainnet run of friglet-tray (Sparrow SP wallet, Omarchy/Hyprland).
Root causes
ScanSupervisor::stop()dropped its task record before the task had ended.GetStatusreportedscanning: falsestraight away, so the UI enabled Start. The scan future only stops at its next.await, and blindbit-lib's P2P block download (P2pConnection::connect/fetch_block) is blocking socket I/O inside that future: 30 s read timeout, 90 s deadline per attempt, up to 4 attempts. So during a download the scan kept running. The Stop handler also heldapply_lockwhile it waited, which meant a Start pressed in the meantime queued behind it and resumed scanning as soon as the old task ended. I reproduced this on the base commit with a unit test that uses a blocking scan step:is_running=false stop_returned=false, and the scan still processed a block after Stop.save_local_configreturns as soon as the spawned daemon answers, and the window then leaves setup mode and re-renders. The tray's cached status still said "unreachable" until the poller's next tick, so for up to about 1 s the Settings tab showed the red "Daemon unreachable — settings cannot be loaded or changed." and a red header pill. Both vanished once scanning started. I captured this in 2 of 5 setup runs with the fix reverted, and in 0 of 7 with it.GetInfoadvancing).debuglevel, which the defaultinfofilter hides. Neither the daemon nor the tray wrote a log file, and a fatal daemon error went only toeprintln!.A related problem came up while testing:
GetStatusfetched the oracle tip inline with a 2 s timeout. With an unresponsive oracle, every status answer took about 2.04 s (measured), longer than the tray's 0.9 s poll timeout. The tray therefore showed the daemon as unreachable, and after 120 s killed it as "wedged".Changes
friglet)ScanStateis running, stopping, paused or failed. The task record stays until the task has really ended.Stopanswers within 3 s, adding a "stopping: …" note if the task is still finishing a blocking step.Startis refused while a stop is still in progress.select!checks cancellation first (biased).oracle_error/oracle_down_since_unix), soGetStatusnever waits on the network.start_height - 1instead of 0.pidandlog_file.friglet_ipc::logfileprovides a size-cappedRotatingLog(10 MiB, keeps.1/.2, 0600 in a 0700 directory).$XDG_STATE_HOME/friglet/friglet.log(macOS~/Library/Logs/friglet, Windows%LOCALAPPDATA%\friglet\logs).FRIGLET_LOG_FILEoverrides the path or turns the file off.friglet-tray.lognext to it and forwards daemon lines at their own level./data/friglet.log.view.rs(pure, unit-tested) computes the scan and daemon states and theErrorBook. A stall or oracle outage shows as "waiting" for 2 min and an unanswering daemon as "reconnecting" for 10 s; after that each becomes an error.Verification
All runs used debug builds.
cargo test --workspacepassed: blindbit-lib 55 (1 ignored), friglet 69, friglet-ipc 26 + 1, friglet-tray 50 + 9. A later stop-race test brought friglet-tray to 51 + 9, and that crate was re-run.cargo clippy -p friglet -p friglet-ipc -p friglet-tray --all-targetsreports nothing in these crates, andcargo fmt --checkpasses for them.End-to-end runs under Xvfb, each with a fresh HOME, a throwaway signet descriptor, the hosted signet oracle and node
signet.oracle.setor.dev. The UI was driven with xdotool clicks and the tray menu over dbusmenu, through a minimal StatusNotifierWatcher (the same path waybar uses). Screenshots were taken for each case.no-such-node.invalid…", and it stayed visible. Recent errors listed it as "(×6, last …)". The error is infriglet.logand infriglet-tray.log. Stop daemon ended the restart loop (7 attempts before the stop, 7 after 40 s).~/.local/state/friglet/friglet.logexists (mode 600) with daemon lines in every run.FRIGLET_LOG_FILE=<path>writes there, including a missing-config error, and=offwrites no file. Open log folder calledxdg-open <log dir>.Not covered: real Hyprland/waybar (the SNI host here is a stub watcher); macOS/Windows log paths (only compiled for Linux here); the Docker image (not rebuilt); and a live stop during a real blocking P2P download (unit-tested with a blocking scan step only).