fix: harden daemon engine stability#4
Closed
zensh wants to merge 3 commits into
Closed
Conversation
Refine desktop launcher update handling so downloaded updates are recorded in the menu instead of prompting from automatic polling. Clear the pending downloaded-update state after a successful restart handoff and update the menu label to describe the explicit action. Co-Authored-By: Anda Bot <noreply@anda.bot>
…est progress When a background shell task or subagent completes, the final output prompt now checks against the latest intermediate progress content. If identical, it sends a short completion notice instead of repeating the full payload, reducing context window noise. Extract helper functions for both subagent and shell background output formatting, and maintain a per-session progress output cache that is cleaned up on task start and completion. Includes 4 unit tests covering dedup and non-dedup paths for both subagent and shell background completion. Co-Authored-By: Anda Bot <noreply@anda.bot>
Write daemon config updates atomically via temp file + fsync + rename and serialize concurrent updates with a mutex, so a crash mid-save can no longer leave a truncated config that blocks the next daemon start. Make skill directory scan failures non-fatal at startup, log and return the underlying error from /daemon/status, and drop the redundant verify_update_request wrapper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
Author
|
Superseded: rebasing locally onto main instead. |
There was a problem hiding this comment.
Pull request overview
This PR focuses on improving daemon stability and launcher update UX in the anda_bot crate, including safer daemon config writes and clearer launcher update behavior.
Changes:
- Harden daemon config writes by serializing concurrent updates and writing via temp-file + fsync + rename.
- Make daemon startup more resilient by logging (not failing) on skill-directory scan/load errors.
- Adjust launcher update flow to only install/restart from explicit user action, with improved menu state handling and updated localized strings.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
scripts/publish-homebrew.sh |
Updates Homebrew formula test to assert the macOS launcher binary exists. |
CHANGELOG.md |
Adds 0.9.7 release notes describing daemon stability and launcher update UX changes. |
Cargo.lock |
Bumps anda_bot package version to 0.9.7. |
anda_bot/Cargo.toml |
Bumps crate version to 0.9.7. |
anda_bot/src/engine/agent.rs |
Avoids duplicating final background outputs when they match the latest progress output; adds tests. |
anda_bot/src/engine.rs |
Adds serialized + atomic config writes, makes skill loading non-fatal, improves /daemon/status error reporting. |
anda_bot/src/bin/anda_launcher/windows.rs |
Removes auto-prompting on downloaded updates; aligns restart-success UI state handling. |
anda_bot/src/bin/anda_launcher/macos.rs |
Same update-flow adjustments as Windows launcher. |
anda_bot/src/bin/anda_launcher/core.rs |
Adds finish_update_restart_success to clear “downloaded update” menu state after successful install/restart. |
anda_bot/locales/app.yml |
Updates EN/ZH menu text to “Install and restart …”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+586
to
+590
| let mut file = tokio::fs::File::create(&tmp_path).await?; | ||
| file.write_all(content).await?; | ||
| file.sync_all().await?; | ||
| drop(file); | ||
| tokio::fs::rename(&tmp_path, path).await |
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.
What changed
Stability review of
anda_bot/src/engine.rs, fixing four issues plus one simplification:PUT /daemon/configpreviously overwroteconfig.tomlin place withtokio::fs::write, which truncates before writing. A crash or power loss mid-write would corrupt the config and prevent the daemon (and theandaCLI, which parses the config on load) from starting. Writes now go through a same-directory temp file withsync_allfollowed by an atomic rename, with temp-file cleanup on failure.PUT /daemon/configrequests could interleave the backup check, backup copy, and file write. Updates are now serialized with atokio::sync::Mutexin the route state. Reads need no lock since rename is atomic.skills_tool.load().await?aborted daemon startup on any skill-directory scan error. The scanned dirs include the shared, user-writable~/.agents/skills, so a permission problem there could brick startup entirely. Failures are now logged and the daemon starts without skills./daemon/statusfailures (which depend on the brain service viabrain_status()) returned a fixed "Failed to get status" with no logging. The handler now logs a warning and includes the error detail in the 500 response.verify_update_request, an empty pass-through wrapper aroundverify_authenticated_request.Reviewed and intentionally unchanged
/daemon/statusstays unauthenticated: it is the launcher's readiness probe (250ms polling), returns only three counters, and the gateway binds to127.0.0.1:8042by default.expclaim;cwt_fromonly validates expiry when the claim is present, so long-running daemons cannot hit token expiry.Testing
cargo test -p anda_bot --bin anda engine— 113 passed, including a new test covering the atomic write helper (replace + create paths, no leftover temp files).cargo clippyandcargo fmt --checkclean.🤖 Generated with Claude Code