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

@@ -326,7 +326,7 @@ export function SettingsPage({
/>
);
case "about":
return <AboutSettings currentVersion={settings.version?.current} />;
return <AboutSettings settings={settings} />;
case "appearance":
return (
<AppearanceSettings
@@ -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">
+7
View File
@@ -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;
+65 -1
View File
@@ -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",