fix: mark packaged backend as desktop-managed#146
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function configure_desktop_managed_environment to set the ASTRBOT_DESKTOP_CLIENT and ASTRBOT_DESKTOP_MANAGED environment variables when running in packaged mode. It also includes corresponding unit tests to verify that these environment variables are correctly set. There are no review comments, and the changes look clean and well-tested, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/backend/launch.rs" line_range="135-137" />
<code_context>
command.env("PYTHONNOUSERSITE", "1");
}
+fn configure_desktop_managed_environment(command: &mut Command) {
+ command.env("ASTRBOT_DESKTOP_CLIENT", "1");
+ command.env("ASTRBOT_DESKTOP_MANAGED", "1");
+}
+
</code_context>
<issue_to_address>
**suggestion:** Consider centralizing the ASTRBOT_* environment variable names as shared constants.
These env var keys are now duplicated here and in call sites/tests. Defining shared module-level constants for `ASTRBOT_DESKTOP_CLIENT`, `ASTRBOT_DESKTOP_MANAGED`, and any related `ASTRBOT_*` vars would reduce typo risk and make future changes easier to manage in one place.
Suggested implementation:
```rust
command.env("PYTHONNOUSERSITE", "1");
}
// Shared environment variable keys for Astrbot desktop flows.
const ENV_ASTRBOT_DESKTOP_CLIENT: &str = "ASTRBOT_DESKTOP_CLIENT";
const ENV_ASTRBOT_DESKTOP_MANAGED: &str = "ASTRBOT_DESKTOP_MANAGED";
fn configure_desktop_managed_environment(command: &mut Command) {
command.env(ENV_ASTRBOT_DESKTOP_CLIENT, "1");
command.env(ENV_ASTRBOT_DESKTOP_MANAGED, "1");
}
```
1. Replace any other hard-coded `"ASTRBOT_DESKTOP_CLIENT"` and `"ASTRBOT_DESKTOP_MANAGED"` usages in this module (and possibly others) with `ENV_ASTRBOT_DESKTOP_CLIENT` and `ENV_ASTRBOT_DESKTOP_MANAGED` respectively.
2. If there are additional `ASTRBOT_*` environment variables used elsewhere in `launch.rs`, consider defining corresponding `const ENV_ASTRBOT_...` identifiers alongside these new constants to fully centralize the keys.
3. If tests or helper utilities refer directly to these env var names as string literals, update them to either import and reuse these constants (if appropriate/accessible) or to define their own shared constants in the relevant test modules.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
Background
AstrBot Desktop manages the packaged backend process from the Tauri shell. The same backend can also serve WebUI pages to an external browser. In that browser path, there is no Tauri desktop bridge, so the original WebUI fallback can call core restart/update APIs directly.
The paired Core-side guard needs a reliable signal that the backend is managed by the desktop shell.
Summary
ASTRBOT_DESKTOP_MANAGED=1to packaged backend process environment.ASTRBOT_DESKTOP_CLIENT=1marker.configure_desktop_managed_environment().Behavior
For packaged desktop-managed backends, the child process now receives:
This lets AstrBot Core reject browser/API-triggered self-restart and self-update flows while preserving the existing desktop runtime marker.
Related Core PR
The paired Core PR consumes
ASTRBOT_DESKTOP_MANAGED=1to block unmanaged restart/update paths:Review / CI Follow-up
cargo fmt --checkCI failure.Tests
rtk cargo fmt --all rtk cargo test backend::launch::testsCI status at last check: all reported checks passed, no failing checks.
Summary by Sourcery
Mark packaged backend processes as desktop-managed via dedicated environment configuration.
Bug Fixes:
Enhancements:
Tests: