feat(webui): show commit and prefill bug report diagnostics (#6080)

* feat(webui): show gateway commit in About settings

* feat(webui): prefill revision in bug reports

* fix(webui): use parentheses for commit details

* feat(webui): prefill gateway diagnostics in bug reports

* docs: remove About settings explanation

* fix(webui): prefill dedicated issue diagnostic fields

* fix(docker): include revision helper in dependency build layer
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-06 18:53:50 +08:00
1 parent 42f06ab1dc
commit b0d28af321
12 files changed
+274 -56

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
from __future__ import annotations
import subprocess
from pathlib import Path
from nanobot.build_info import read_commit
def git(root: Path, *args: str) -> str:
return subprocess.check_output(["git", "-C", str(root), *args], text=True).strip()
def test_checkout_and_worktree_report_their_own_head(tmp_path: Path) -> None:
git(tmp_path, "init")
git(tmp_path, "-c", "user.name=Test", "-c", "user.email=test@example.com",
"commit", "--allow-empty", "-m", "initial")
expected = git(tmp_path, "rev-parse", "HEAD")
assert read_commit(tmp_path) == expected
worktree = tmp_path / "checkout"
git(tmp_path, "worktree", "add", "-b", "topic", str(worktree))
git(worktree, "-c", "user.name=Test", "-c", "user.email=test@example.com",
"commit", "--allow-empty", "-m", "topic")
assert read_commit(worktree) == git(worktree, "rev-parse", "HEAD")
assert read_commit(worktree) != expected
def test_packaged_revision_ignores_an_enclosing_repository(tmp_path: Path) -> None:
git(tmp_path, "init")
git(tmp_path, "-c", "user.name=Test", "-c", "user.email=test@example.com",
"commit", "--allow-empty", "-m", "unrelated project")
install_root = tmp_path / "site-packages"
package = install_root / "nanobot"
package.mkdir(parents=True)
assert read_commit(install_root) is None
stamp = package / "_build_commit.txt"
stamp.write_text("a" * 40 + "\n", encoding="utf-8")
assert read_commit(install_root) == "a" * 40
stamp.write_text("unknown", encoding="utf-8")
assert read_commit(install_root) is None
+26 -3
View File
@@ -1,6 +1,10 @@
from __future__ import annotations
import platform
from pathlib import Path
import pytest
import yaml
from nanobot.channels.contracts import channel_default_config, channel_instance_specs
from nanobot.channels.manager import ChannelManager
@@ -15,7 +19,8 @@ from nanobot.webui.settings_system import (
)
def test_system_domain_owns_runtime_dto_and_agent_updates(tmp_path) -> None:
def test_system_domain_owns_runtime_dto_and_agent_updates(tmp_path, monkeypatch) -> None:
monkeypatch.setattr("nanobot.webui.settings_system.COMMIT", "a" * 40)
config = Config()
changed, restart_required = update_agent_system_settings(
@@ -37,9 +42,15 @@ def test_system_domain_owns_runtime_dto_and_agent_updates(tmp_path) -> None:
assert config.agents.defaults.timezone_mode == "manual"
assert config.agents.defaults.tool_hint_max_length == 120
assert payload["runtime"]["config_path"] == str(tmp_path / "config.json")
assert payload["version"] == {"current": "0.3.0"}
assert payload["version"] == {"current": "0.3.0", "commit": "a" * 40}
assert payload["environment"] == {
"python_version": platform.python_version(),
"os": platform.system(),
"os_version": platform.release(),
"architecture": platform.machine(),
}
assert payload["docs"]["version"] == "0.3.0"
assert set(payload) == {"runtime", "runtime_config", "usage", "advanced", "version", "docs"}
assert set(payload) == {"runtime", "runtime_config", "usage", "advanced", "version", "environment", "docs"}
def test_system_domain_validates_channel_field_values() -> None:
@@ -115,3 +126,15 @@ def test_saving_other_qq_settings_does_not_pin_the_global_notice_policy():
config, "qq", {"appId": "a", "secret": "s"}, load_channel_plugin=load_channel_plugin,
)
assert config.channels.qq.get("showCompactionNotices") is None
def test_feedback_template_accepts_environment_prefills() -> None:
root = Path(__file__).resolve().parents[2]
template = yaml.safe_load((root / ".github/ISSUE_TEMPLATE/bug_report.yml").read_text())
fields = {field["id"]: field for field in template["body"] if "id" in field}
for field_id in ("version", "python_version", "os", "channel", "llm_provider"):
assert fields[field_id]["type"] == "input"
assert fields[field_id]["validations"]["required"] is True
for field_id in ("model", "browser", "connection"):
assert fields[field_id]["type"] == "input"
assert fields["additional"]["type"] == "textarea"