Skip to content

Your lightweight open-source personal agent.

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

chengyongrub0d28af32193
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 67d95e1ca..fd63768a3 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -53,73 +53,62 @@ body:
validations:
required: true
- - type: dropdown
+ - type: input
id: python_version
attributes:
label: Python Version
- description: What Python version are you using?
- options:
- - "3.11"
- - "3.12"
- - "3.13"
- - Other (specify below)
+ description: Python version running the nanobot gateway.
+ placeholder: e.g., 3.12.10
validations:
required: true
- - type: dropdown
+ - type: input
id: os
attributes:
label: Operating System
- options:
- - Windows
- - macOS
- - Linux
- - Docker
- - Other (specify below)
+ description: Operating system running the nanobot gateway (including container OS).
+ placeholder: e.g., Windows, macOS, Linux, Docker
validations:
required: true
- - type: dropdown
+ - type: input
id: channel
attributes:
label: Channel / Platform
description: Which messaging platform are you using?
- options:
- - Weixin (Personal WeChat)
- - WeCom (Enterprise WeChat)
- - Feishu (Lark)
- - DingTalk
- - Telegram
- - Discord
- - Slack
- - QQ
- - WhatsApp
- - Email
- - MS Teams
- - Matrix
- - WebSocket
- - API Server
- - Other (specify below)
+ placeholder: e.g., WebSocket, Telegram, Feishu (Lark), API Server
validations:
required: true
- - type: dropdown
+ - type: input
id: llm_provider
attributes:
label: LLM Provider
- description: Which LLM provider are you using?
- options:
- - OpenAI
- - Anthropic (Claude)
- - DeepSeek
- - Google (Gemini)
- - Ollama (Local)
- - OpenRouter
- - Azure OpenAI
- - Other (specify below)
+ description: Configured default provider. Edit if the affected conversation uses another provider.
+ placeholder: e.g., openai, openai_codex, anthropic, deepseek
validations:
required: true
+ - type: input
+ id: model
+ attributes:
+ label: Model
+ description: Configured default model. Edit if the affected conversation uses another model.
+ placeholder: e.g., openai/gpt-4o
+
+ - type: input
+ id: browser
+ attributes:
+ label: Browser
+ description: Browser version or user agent, for WebUI issues.
+
+ - type: input
+ id: connection
+ attributes:
+ label: Connection
+ description: How the WebUI connects to the gateway.
+ placeholder: e.g., Local host, Remote host, Direct WebUI
+
- type: textarea
id: config
attributes:
diff --git a/.gitignore b/.gitignore
index ff1026a9c..e8aace56e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -104,3 +104,6 @@ exp/
bridge/node_modules/
webui/.verify-*
.playwright-cli/
+
+# Generated source revision for wheels and sdists
+nanobot/_build_commit.txt
diff --git a/Dockerfile b/Dockerfile
index 397957a89..87ba7212e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -23,9 +23,10 @@ ENV PATH="/app/.venv/bin:$PATH"
RUN uv venv --seed "$VIRTUAL_ENV"
# Install Python dependencies first (cached layer). Hatch reads the custom build
-# hook from hatch_build.py even for this metadata-only install.
+# hook and its revision helper even for this metadata-only install.
ARG NANOBOT_EXTRAS=
COPY pyproject.toml README.md LICENSE THIRD_PARTY_NOTICES.md hatch_build.py ./
+COPY nanobot/build_info.py nanobot/
RUN mkdir -p nanobot && touch nanobot/__init__.py && \
if [ -n "$NANOBOT_EXTRAS" ]; then \
NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install \
diff --git a/hatch_build.py b/hatch_build.py
index d4e93f186..3d7bc05aa 100644
--- a/hatch_build.py
+++ b/hatch_build.py
@@ -58,6 +58,14 @@ class WebUIBuildHook(BuildHookInterface):
)
return
+ from nanobot.build_info import read_commit
+
+ commit = read_commit(root)
+ if commit:
+ commit_file = root / "nanobot" / "_build_commit.txt"
+ commit_file.write_text(commit + "\n", encoding="utf-8")
+ build_data.setdefault("force_include", {})[str(commit_file)] = "nanobot/_build_commit.txt"
+
if os.environ.get("NANOBOT_SKIP_WEBUI_BUILD") == "1":
self.app.display_info("[webui-build] skipped via NANOBOT_SKIP_WEBUI_BUILD=1")
return
diff --git a/nanobot/build_info.py b/nanobot/build_info.py
new file mode 100644
index 000000000..f29c61868
--- /dev/null
+++ b/nanobot/build_info.py
@@ -0,0 +1,31 @@
+"""Source revision of the running installation and built distributions."""
+
+from __future__ import annotations
+
+import re
+import subprocess
+from pathlib import Path
+
+
+def read_commit(root: Path) -> str | None:
+ """Read this checkout's HEAD, or the revision recorded when packaging it."""
+ if (root / ".git").exists():
+ try:
+ commit = subprocess.run(
+ ["git", "-C", str(root), "rev-parse", "--verify", "HEAD"],
+ capture_output=True,
+ text=True,
+ check=True,
+ timeout=2,
+ ).stdout.strip()
+ except (OSError, subprocess.SubprocessError):
+ return None
+ else:
+ try:
+ commit = (root / "nanobot" / "_build_commit.txt").read_text(encoding="utf-8").strip()
+ except OSError:
+ return None
+ return commit if re.fullmatch(r"[0-9a-f]{40}|[0-9a-f]{64}", commit) else None
+
+
+COMMIT = read_commit(Path(__file__).resolve().parent.parent)
diff --git a/nanobot/webui/settings_system.py b/nanobot/webui/settings_system.py
index 5267c3636..592470475 100644
--- a/nanobot/webui/settings_system.py
+++ b/nanobot/webui/settings_system.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import asyncio
import inspect
import json
+import platform
import re
import time
from collections.abc import Callable, Iterable, Mapping
@@ -15,6 +16,7 @@ from zoneinfo import ZoneInfo
from pydantic.alias_generators import to_snake
+from nanobot.build_info import COMMIT
from nanobot.channels._setup import channel_setup_spec
from nanobot.channels.connect import ChannelConnectError
from nanobot.channels.contracts import (
@@ -66,12 +68,20 @@ class SystemSettingsOperations:
channel_runtime_status: Callable[[], dict[str, Any]] | None = None
+class GatewayEnvironmentPayload(TypedDict):
+ python_version: str
+ os: str
+ os_version: str
+ architecture: str
+
+
class SystemSettingsPayload(TypedDict):
runtime_config: dict[str, Any]
runtime: dict[str, Any]
usage: dict[str, Any]
advanced: dict[str, Any]
version: dict[str, Any]
+ environment: GatewayEnvironmentPayload
docs: dict[str, Any]
@@ -138,7 +148,13 @@ def system_settings_payload(
"exec_path_prepend_set": bool(exec_config.path_prepend),
"exec_path_append_set": bool(exec_config.path_append),
},
- "version": {"current": version},
+ "version": {"current": version, "commit": COMMIT},
+ "environment": {
+ "python_version": platform.python_version(),
+ "os": platform.system(),
+ "os_version": platform.release(),
+ "architecture": platform.machine(),
+ },
"docs": docs_payload(version),
}
diff --git a/tests/test_build_info.py b/tests/test_build_info.py
new file mode 100644
index 000000000..3300a12cf
--- /dev/null
+++ b/tests/test_build_info.py
@@ -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", "[email protected]",
+ "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", "[email protected]",
+ "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", "[email protected]",
+ "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
diff --git a/tests/webui/test_settings_system.py b/tests/webui/test_settings_system.py
index f7affe5a7..5cc0a4459 100644
--- a/tests/webui/test_settings_system.py
+++ b/tests/webui/test_settings_system.py
@@ -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"
diff --git a/webui/src/components/settings/SettingsPage.tsx b/webui/src/components/settings/SettingsPage.tsx
index 84093f7b8..a3b1331d0 100644
--- a/webui/src/components/settings/SettingsPage.tsx
+++ b/webui/src/components/settings/SettingsPage.tsx
@@ -326,7 +326,7 @@ export function SettingsPage({
/>
);
case "about":
- return <AboutSettings currentVersion={settings.version?.current} />;
+ return <AboutSettings settings={settings} />;
case "appearance":
return (
<AppearanceSettings
diff --git a/webui/src/components/settings/overview/OverviewSettings.tsx b/webui/src/components/settings/overview/OverviewSettings.tsx
index 06e55d7ef..162f80ae6 100644
--- a/webui/src/components/settings/overview/OverviewSettings.tsx
+++ b/webui/src/components/settings/overview/OverviewSettings.tsx
@@ -4,7 +4,7 @@ import {
ImageGenerationIcon,
VoiceIcon,
} from "@/components/icons/product-icons";
-import { useState, type Dispatch, type SetStateAction } from "react";
+import { useContext, useState, type Dispatch, type SetStateAction } from "react";
import {
ArrowUpCircle,
BookOpen,
@@ -18,6 +18,7 @@ import {
} from "lucide-react";
import { useTranslation } from "react-i18next";
+import { HostNavigationContext } from "@/components/remote/HostSwitcher";
import { StarLink } from "@/components/StarPrompt";
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
import { DEFAULT_TRANSCRIPTION_SETTINGS } from "@/components/settings/capabilities/TranscriptionSettings";
@@ -68,9 +69,9 @@ export function OverviewSettings({
? settings.agent.model
: tx("settings.values.notConfigured", "Not configured");
const activeModelCaption = activeProviderConfigured
- ? [activeProvider, activePreset].filter(Boolean).join(" · ")
+ ? [activeProvider, activePreset].filter(Boolean).join(" ")
: activeProviderLabel || settings.agent.model
- ? [activeProviderLabel, settings.agent.model].filter(Boolean).join(" · ")
+ ? [activeProviderLabel, settings.agent.model].filter(Boolean).join(" ")
: tx("settings.byok.noConfiguredProviders", "No configured providers");
const webStatus = settings.web.enable
? tx("settings.values.enabled", "Enabled")
@@ -137,19 +138,44 @@ export function OverviewSettings({
);
}
-export function AboutSettings({ currentVersion }: { currentVersion?: string }) {
+type VersionInfoProps = { currentVersion?: string; currentCommit?: string | null };
+
+export function AboutSettings({ settings }: { settings: SettingsPayload }) {
const { t } = useTranslation();
+ const hostPicker = useContext(HostNavigationContext);
+ const currentVersion = settings.version?.current;
+ const currentCommit = settings.version?.commit;
+ const environment = settings.environment;
+ const reportIssueUrl = new URL("https://github.com/HKUDS/nanobot/issues/new");
+ reportIssueUrl.searchParams.set("template", "bug_report.yml");
+ const reportedVersion = [currentVersion, currentCommit && `(commit ${currentCommit})`]
+ .filter(Boolean).join(" ");
+ if (reportedVersion) reportIssueUrl.searchParams.set("version", reportedVersion);
+ reportIssueUrl.searchParams.set("channel", "WebSocket");
+ if (environment) {
+ reportIssueUrl.searchParams.set("python_version", environment.python_version);
+ const osName = environment.os === "Darwin" ? "macOS" : environment.os;
+ const osVersion = [osName, environment.os_version].filter(Boolean).join(" ");
+ reportIssueUrl.searchParams.set("os", environment.architecture
+ ? `${osVersion} (${environment.architecture})` : osVersion);
+ }
+ if (settings.agent.model) reportIssueUrl.searchParams.set("model", settings.agent.model);
+ const provider = settings.agent.resolved_provider || settings.agent.provider;
+ if (provider) reportIssueUrl.searchParams.set("llm_provider", provider);
+ reportIssueUrl.searchParams.set("browser", navigator.userAgent);
+ reportIssueUrl.searchParams.set("connection", hostPicker?.kind === "embedded"
+ ? "Remote host" : hostPicker ? "Local host" : "Direct WebUI");
const links = [
{ key: "sourceCode", icon: Github, href: "https://github.com/HKUDS/nanobot" },
{ key: "documentation", icon: BookOpen, href: "https://nanobot.wiki/" },
- { key: "reportIssue", icon: MessageCircle, href: "https://github.com/HKUDS/nanobot/issues" },
+ { key: "reportIssue", icon: MessageCircle, href: reportIssueUrl.href },
];
return (
<div className="flex flex-1 flex-col gap-5">
<div className="flex flex-col items-center gap-4 py-6 text-center">
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16 select-none" draggable={false} />
<h1><img src="/brand/nanobot_wordmark.svg" alt="nanobot" className="h-auto w-40 select-none dark:brightness-150" draggable={false} /></h1>
- <VersionCheckRow currentVersion={currentVersion} />
+ <VersionCheckRow currentVersion={currentVersion} currentCommit={currentCommit} />
</div>
<SettingsGroup>
{links.map(({ key, icon: Icon, href }) => (
@@ -168,7 +194,7 @@ export function AboutSettings({ currentVersion }: { currentVersion?: string }) {
);
}
-function VersionCheckRow({ currentVersion }: { currentVersion?: string }) {
+function VersionCheckRow({ currentVersion, currentCommit }: VersionInfoProps) {
const { t } = useTranslation();
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
const { token } = useClient();
@@ -209,6 +235,17 @@ function VersionCheckRow({ currentVersion }: { currentVersion?: string }) {
</div>
<div className="mt-0.5 text-[12px] leading-5 text-muted-foreground">
{currentVersion ? `v${currentVersion}` : "nanobot"}
+ {currentCommit && (
+ <>
+ <span aria-hidden> (</span>
+ <a href={`https://github.com/HKUDS/nanobot/commit/${currentCommit}`}
+ target="_blank" rel="noopener noreferrer" title={currentCommit}
+ className="font-mono hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ {currentCommit.slice(0, 7)}
+ </a>
+ <span aria-hidden>)</span>
+ </>
+ )}
</div>
</div>
<div className="flex shrink-0 flex-col items-center gap-2">
diff --git a/webui/src/lib/types.ts b/webui/src/lib/types.ts
index 0b1490435..19c1e8a8e 100644
--- a/webui/src/lib/types.ts
+++ b/webui/src/lib/types.ts
@@ -907,6 +907,13 @@ export interface SettingsPayload {
restart_required_sections?: Array<"runtime" | "browser" | "image">;
version?: {
current: string;
+ commit?: string | null;
+ };
+ environment?: {
+ python_version: string;
+ os: string;
+ os_version: string;
+ architecture: string;
};
docs?: {
version: string;
diff --git a/webui/src/tests/settings-overview.test.tsx b/webui/src/tests/settings-overview.test.tsx
index 4a6446157..deea94a41 100644
--- a/webui/src/tests/settings-overview.test.tsx
+++ b/webui/src/tests/settings-overview.test.tsx
@@ -1,5 +1,9 @@
-import { act, fireEvent, screen, waitFor } from "@testing-library/react";
+import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { expect, it, vi } from "vitest";
+import { HostNavigationContext } from "@/components/remote/HostSwitcher";
+import { AboutSettings } from "@/components/settings/overview/OverviewSettings";
+import { NanobotClient } from "@/lib/nanobot-client";
+import { ClientProvider } from "@/providers/ClientProvider";
import type { SettingsPayload } from "@/lib/types";
import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
@@ -10,6 +14,66 @@ describe("Settings overview and appearance", () => {
installSettingsViewTestHooks();
+ it("links the host's short commit beside its version", () => {
+ const commit = "abcdef12".repeat(5);
+ renderSettingsView({
+ initialSection: "about",
+ initialSettings: { ...settingsPayload(), version: { current: "0.3.5", commit } },
+ });
+ expect(screen.getByText("v0.3.5")).toBeInTheDocument();
+ const link = screen.getByRole("link", { name: "abcdef1" });
+ expect(link).toHaveAttribute("href", `https://github.com/HKUDS/nanobot/commit/${commit}`);
+ expect(link).toHaveAttribute("title", commit);
+ const reportUrl = new URL(screen.getByRole("link", { name: "Report an issue" }).getAttribute("href")!);
+ expect(reportUrl.origin + reportUrl.pathname).toBe("https://github.com/HKUDS/nanobot/issues/new");
+ expect(reportUrl.searchParams.get("template")).toBe("bug_report.yml");
+ expect(reportUrl.searchParams.get("version")).toBe(`0.3.5 (commit ${commit})`);
+ });
+
+ it.each([undefined, null])("keeps About usable when the host reports no commit (%s)", (commit) => {
+ renderSettingsView({
+ initialSection: "about",
+ initialSettings: { ...settingsPayload(), version: { current: "0.3.5", commit } },
+ });
+ expect(screen.getByText("v0.3.5")).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Check for updates" })).toBeEnabled();
+ expect(document.querySelector('a[href*="/commit/"]')).toBeNull();
+ const reportUrl = new URL(screen.getByRole("link", { name: "Report an issue" }).getAttribute("href")!);
+ expect(reportUrl.searchParams.get("version")).toBe("0.3.5");
+ expect(reportUrl.searchParams.get("python_version")).toBeNull();
+ expect(reportUrl.searchParams.get("os")).toBeNull();
+ expect(reportUrl.searchParams.get("channel")).toBe("WebSocket");
+ expect(reportUrl.searchParams.get("llm_provider")).toBe("openai");
+ expect(reportUrl.searchParams.get("model")).toBe("openai/gpt-4o");
+ expect(reportUrl.searchParams.get("additional")).toBeNull();
+ });
+
+ it("prefills the remote gateway environment separately from the browser", () => {
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue("Browser on Windows");
+ const payload: SettingsPayload = {
+ ...settingsPayload(),
+ environment: { python_version: "3.14.2", os: "Darwin", os_version: "24.4.0", architecture: "arm64" },
+ };
+ render(
+ <ClientProvider client={new NanobotClient({ url: "ws://localhost:8765" })} token="tok">
+ <HostNavigationContext.Provider value={{ kind: "embedded", name: "Remote", hostname: "private-host", open: vi.fn() }}>
+ <AboutSettings settings={payload} />
+ </HostNavigationContext.Provider>
+ </ClientProvider>,
+ );
+ const url = new URL(screen.getByRole("link", { name: "Report an issue" }).getAttribute("href")!);
+ expect(url.searchParams.get("python_version")).toBe("3.14.2");
+ expect(url.searchParams.get("os")).toBe("macOS 24.4.0 (arm64)");
+ expect(url.searchParams.get("channel")).toBe("WebSocket");
+ expect(url.searchParams.get("browser")).toBe("Browser on Windows");
+ expect(url.searchParams.get("connection")).toBe("Remote host");
+ expect(url.searchParams.get("model")).toBe("openai/gpt-4o");
+ expect(url.searchParams.get("llm_provider")).toBe("openai");
+ expect(url.searchParams.get("additional")).toBeNull();
+ expect(url.href).not.toContain(encodeURIComponent(payload.runtime.config_path));
+ expect(url.href).not.toContain("private-host");
+ });
+
it("persists the file edit display local preference", async () => {
renderSettingsView({
initialSection: "appearance",