Skip to content

fix: show CLI upgrade instructions in the WebUI - #11621

Merged
Soulter merged 2 commits into
AstrBotDevs:masterfrom
xianshujun:fix/11620-cli-update-guidance
Dec 3, 2026
Merged

Soulter merged 2 commits into
AstrBotDevs:masterfrom
xianshujun:fix/11620-cli-update-guidance

Conversation

@xianshujun

@xianshujun xianshujun commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Modifications

When AstrBot is started via the CLI, return a stable update error and show package-manager-specific instructions in the progress panel: uv tool upgrade astrbot for uv tool installs or python -m pip install --upgrade astrbot in the original pip environment. The core downloader is unchanged.

Test results

The route regression uses the v1 update endpoint and polls progress. It failed on the base branch; 65 targeted backend tests, 5 frontend tests, the four-locale key check, and Ruff lint and format checks passed.

Fixes #11620

Summary by Sourcery

Guide CLI-launched users to upgrade AstrBot with their package manager instead of attempting a WebUI update.

New Features:

  • Show CLI-specific package-manager upgrade commands and a localized guide link in the WebUI update progress panel when updates cannot be performed there.

Enhancements:

  • Return a stable cli_update_required error through update progress when AstrBot is launched via the CLI, without starting the core updater.

Tests:

  • Add a regression test that submits and polls the v1 update endpoint to verify CLI guidance and confirm the core updater is not called.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="astrbot/dashboard/services/update_service.py" line_range="183" />
<code_context>
             reboot: Whether to restart AstrBot after applying files.
             proxy: Optional GitHub proxy URL.
         """
+        if os.environ.get("ASTRBOT_CLI") == "1":
+            self.update_progress[progress_id].update(
+                status="error",
</code_context>
<issue_to_address>
**CLI installs show generic update errors**

When `ASTRBOT_CLI` is truthy but not exactly `"1"`, or `ASTRBOT_LAUNCHER` is set, the CLI check skips the guidance branch, then the updater rejects the installation and the exception handler reports a generic update failure instead of package-manager instructions.

Use the updater’s CLI-managed installation conditions for the guidance check, including truthy `ASTRBOT_CLI` values and a set `ASTRBOT_LAUNCHER`.
</issue_to_address>

### Comment 2
<location path="astrbot/dashboard/services/update_service.py" line_range="185" />
<code_context>
         """
+        if os.environ.get("ASTRBOT_CLI") == "1":
+            self.update_progress[progress_id].update(
+                status="error",
+                error_code="cli_update_required",
+                message=(
</code_context>
<issue_to_address>
**Older polls overwrite terminal guidance**

When an older running poll returns after a newer poll has returned the terminal CLI error, `applyUpdateProgress` replaces the terminal error with the older running response after polling has stopped, so the panel remains stuck on a nonterminal message instead of showing upgrade instructions.

Prevent an older running response from replacing a terminal update state.
</issue_to_address>

### Comment 3
<location path="tests/test_dashboard.py" line_range="3262" />
<code_context>
+    assert progress["status"] == "error"
+    assert progress.get("error_code") == "cli_update_required"
+    assert "uv tool upgrade astrbot" in progress["message"]
+    assert "pip install" in progress["message"]
+    assert progress["overall_percent"] == 0
+    update.assert_not_awaited()
</code_context>
<issue_to_address>
**Generic pip guidance passes route test**

When the polled response contains a generic `pip install` instruction but omits the required command details, `test_cli_update_guidance_in_polled_progress` only checks for the substring `pip install`, so a response missing `python -m`, `--upgrade astrbot`, or the original-environment instruction still passes as valid guidance.

Assert the full pip upgrade command and the original-Python-environment guidance in the polled message.
</issue_to_address>

### Comment 4
<location path="dashboard/tests/updateProgressMessage.test.mjs" line_range="1-16" />
<code_context>
+import { expect, test } from "vitest";
+import en from "../src/i18n/locales/en-US/core/header.json";
+import ja from "../src/i18n/locales/ja-JP/core/header.json";
+import ru from "../src/i18n/locales/ru-RU/core/header.json";
+import zh from "../src/i18n/locales/zh-CN/core/header.json";
+import { getUpdateProgressMessage } from "../src/utils/updateProgressMessage.ts";
+
+const failure = { status: "error", stage: "preparing", message: "Server fallback" };
+
</code_context>
<issue_to_address>
**Repository guidance is disregarded**

When the newly added dashboard test file is included, the PR adds a new frontend test file despite the repository-wide instruction not to generate test files, so this change violates that rule.

Remove the newly added test file.
</issue_to_address>

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: astrbot/dashboard/services/update_service.py:183, astrbot/dashboard/services/update_service.py:185, tests/test_dashboard.py:3262


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

reboot: Whether to restart AstrBot after applying files.
proxy: Optional GitHub proxy URL.
"""
if os.environ.get("ASTRBOT_CLI") == "1":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · CLI installs show generic update errors

When ASTRBOT_CLI is truthy but not exactly "1", or ASTRBOT_LAUNCHER is set, the CLI check skips the guidance branch, then the updater rejects the installation and the exception handler reports a generic update failure instead of package-manager instructions.

Use the updater’s CLI-managed installation conditions for the guidance check, including truthy ASTRBOT_CLI values and a set ASTRBOT_LAUNCHER.

Prompt for AI agents
In `astrbot/dashboard/services/update_service.py` at line 183:

**CLI installs show generic update errors**

When `ASTRBOT_CLI` is truthy but not exactly `"1"`, or `ASTRBOT_LAUNCHER` is set, the CLI check skips the guidance branch, then the updater rejects the installation and the exception handler reports a generic update failure instead of package-manager instructions.

Use the updater’s CLI-managed installation conditions for the guidance check, including truthy `ASTRBOT_CLI` values and a set `ASTRBOT_LAUNCHER`.

"""
if os.environ.get("ASTRBOT_CLI") == "1":
self.update_progress[progress_id].update(
status="error",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Older polls overwrite terminal guidance

When an older running poll returns after a newer poll has returned the terminal CLI error, applyUpdateProgress replaces the terminal error with the older running response after polling has stopped, so the panel remains stuck on a nonterminal message instead of showing upgrade instructions.

Prevent an older running response from replacing a terminal update state.

Prompt for AI agents
In `astrbot/dashboard/services/update_service.py` at line 185:

**Older polls overwrite terminal guidance**

When an older running poll returns after a newer poll has returned the terminal CLI error, `applyUpdateProgress` replaces the terminal error with the older running response after polling has stopped, so the panel remains stuck on a nonterminal message instead of showing upgrade instructions.

Prevent an older running response from replacing a terminal update state.

Comment thread tests/test_dashboard.py Resolved
@mantoujun12
mantoujun12 requested a review from Soulter December 3, 2026 05:52
@Soulter
Soulter changed the base branch from dev to master December 3, 2026 13:01
@Soulter
Soulter changed the base branch from master to dev December 3, 2026 13:01
@Soulter
Soulter force-pushed the fix/11620-cli-update-guidance branch from 64a79ca to 1772156 Compare December 3, 2026 13:07
@Soulter
Soulter changed the base branch from dev to master December 3, 2026 13:07
@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit c696aee

#11620 使用uv安装的AstrBot无法通过WebUI更新。当前实现具有显著误导性 · 1 of 1 met

# Requirement Status Notes
1 Show CLI-launched users upgrade instructions instead of the generic update failure. ✅ Met The update service detects ASTRBOT_CLI=1 before calling the updater, records a stable cli_update_required error, and the progress panel displays localized instructions for uv tool and pip installs, including the original Python environment.

@Soulter
Soulter merged commit 570ae49 into AstrBotDevs:master Dec 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

使用uv安装的AstrBot无法通过WebUI更新。当前实现具有显著误导性

2 participants