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:
1 parent
42f06ab1dc
commit
b0d28af321
12 files changed
+274
-56
No files matched your search
@@ -53,73 +53,62 @@ body:
|
|||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: dropdown
|
- type: input
|
||||||
id: python_version
|
id: python_version
|
||||||
attributes:
|
attributes:
|
||||||
label: Python Version
|
label: Python Version
|
||||||
description: What Python version are you using?
|
description: Python version running the nanobot gateway.
|
||||||
options:
|
placeholder: e.g., 3.12.10
|
||||||
- "3.11"
|
|
||||||
- "3.12"
|
|
||||||
- "3.13"
|
|
||||||
- Other (specify below)
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: dropdown
|
- type: input
|
||||||
id: os
|
id: os
|
||||||
attributes:
|
attributes:
|
||||||
label: Operating System
|
label: Operating System
|
||||||
options:
|
description: Operating system running the nanobot gateway (including container OS).
|
||||||
- Windows
|
placeholder: e.g., Windows, macOS, Linux, Docker
|
||||||
- macOS
|
|
||||||
- Linux
|
|
||||||
- Docker
|
|
||||||
- Other (specify below)
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: dropdown
|
- type: input
|
||||||
id: channel
|
id: channel
|
||||||
attributes:
|
attributes:
|
||||||
label: Channel / Platform
|
label: Channel / Platform
|
||||||
description: Which messaging platform are you using?
|
description: Which messaging platform are you using?
|
||||||
options:
|
placeholder: e.g., WebSocket, Telegram, Feishu (Lark), API Server
|
||||||
- Weixin (Personal WeChat)
|
|
||||||
- WeCom (Enterprise WeChat)
|
|
||||||
- Feishu (Lark)
|
|
||||||
- DingTalk
|
|
||||||
- Telegram
|
|
||||||
- Discord
|
|
||||||
- Slack
|
|
||||||
- QQ
|
|
||||||
- WhatsApp
|
|
||||||
- Email
|
|
||||||
- MS Teams
|
|
||||||
- Matrix
|
|
||||||
- WebSocket
|
|
||||||
- API Server
|
|
||||||
- Other (specify below)
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: dropdown
|
- type: input
|
||||||
id: llm_provider
|
id: llm_provider
|
||||||
attributes:
|
attributes:
|
||||||
label: LLM Provider
|
label: LLM Provider
|
||||||
description: Which LLM provider are you using?
|
description: Configured default provider. Edit if the affected conversation uses another provider.
|
||||||
options:
|
placeholder: e.g., openai, openai_codex, anthropic, deepseek
|
||||||
- OpenAI
|
|
||||||
- Anthropic (Claude)
|
|
||||||
- DeepSeek
|
|
||||||
- Google (Gemini)
|
|
||||||
- Ollama (Local)
|
|
||||||
- OpenRouter
|
|
||||||
- Azure OpenAI
|
|
||||||
- Other (specify below)
|
|
||||||
validations:
|
validations:
|
||||||
required: true
|
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
|
- type: textarea
|
||||||
id: config
|
id: config
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
@@ -104,3 +104,6 @@ exp/
|
|||||||
bridge/node_modules/
|
bridge/node_modules/
|
||||||
webui/.verify-*
|
webui/.verify-*
|
||||||
.playwright-cli/
|
.playwright-cli/
|
||||||
|
|
||||||
|
# Generated source revision for wheels and sdists
|
||||||
|
nanobot/_build_commit.txt
|
||||||
+2
-1
@@ -23,9 +23,10 @@ ENV PATH="/app/.venv/bin:$PATH"
|
|||||||
RUN uv venv --seed "$VIRTUAL_ENV"
|
RUN uv venv --seed "$VIRTUAL_ENV"
|
||||||
|
|
||||||
# Install Python dependencies first (cached layer). Hatch reads the custom build
|
# 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=
|
ARG NANOBOT_EXTRAS=
|
||||||
COPY pyproject.toml README.md LICENSE THIRD_PARTY_NOTICES.md hatch_build.py ./
|
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 && \
|
RUN mkdir -p nanobot && touch nanobot/__init__.py && \
|
||||||
if [ -n "$NANOBOT_EXTRAS" ]; then \
|
if [ -n "$NANOBOT_EXTRAS" ]; then \
|
||||||
NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install \
|
NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install \
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ class WebUIBuildHook(BuildHookInterface):
|
|||||||
)
|
)
|
||||||
return
|
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":
|
if os.environ.get("NANOBOT_SKIP_WEBUI_BUILD") == "1":
|
||||||
self.app.display_info("[webui-build] skipped via NANOBOT_SKIP_WEBUI_BUILD=1")
|
self.app.display_info("[webui-build] skipped via NANOBOT_SKIP_WEBUI_BUILD=1")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from collections.abc import Callable, Iterable, Mapping
|
from collections.abc import Callable, Iterable, Mapping
|
||||||
@@ -15,6 +16,7 @@ from zoneinfo import ZoneInfo
|
|||||||
|
|
||||||
from pydantic.alias_generators import to_snake
|
from pydantic.alias_generators import to_snake
|
||||||
|
|
||||||
|
from nanobot.build_info import COMMIT
|
||||||
from nanobot.channels._setup import channel_setup_spec
|
from nanobot.channels._setup import channel_setup_spec
|
||||||
from nanobot.channels.connect import ChannelConnectError
|
from nanobot.channels.connect import ChannelConnectError
|
||||||
from nanobot.channels.contracts import (
|
from nanobot.channels.contracts import (
|
||||||
@@ -66,12 +68,20 @@ class SystemSettingsOperations:
|
|||||||
channel_runtime_status: Callable[[], dict[str, Any]] | None = None
|
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):
|
class SystemSettingsPayload(TypedDict):
|
||||||
runtime_config: dict[str, Any]
|
runtime_config: dict[str, Any]
|
||||||
runtime: dict[str, Any]
|
runtime: dict[str, Any]
|
||||||
usage: dict[str, Any]
|
usage: dict[str, Any]
|
||||||
advanced: dict[str, Any]
|
advanced: dict[str, Any]
|
||||||
version: dict[str, Any]
|
version: dict[str, Any]
|
||||||
|
environment: GatewayEnvironmentPayload
|
||||||
docs: dict[str, Any]
|
docs: dict[str, Any]
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +148,13 @@ def system_settings_payload(
|
|||||||
"exec_path_prepend_set": bool(exec_config.path_prepend),
|
"exec_path_prepend_set": bool(exec_config.path_prepend),
|
||||||
"exec_path_append_set": bool(exec_config.path_append),
|
"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),
|
"docs": docs_payload(version),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import platform
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import yaml
|
||||||
|
|
||||||
from nanobot.channels.contracts import channel_default_config, channel_instance_specs
|
from nanobot.channels.contracts import channel_default_config, channel_instance_specs
|
||||||
from nanobot.channels.manager import ChannelManager
|
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()
|
config = Config()
|
||||||
|
|
||||||
changed, restart_required = update_agent_system_settings(
|
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.timezone_mode == "manual"
|
||||||
assert config.agents.defaults.tool_hint_max_length == 120
|
assert config.agents.defaults.tool_hint_max_length == 120
|
||||||
assert payload["runtime"]["config_path"] == str(tmp_path / "config.json")
|
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 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:
|
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,
|
config, "qq", {"appId": "a", "secret": "s"}, load_channel_plugin=load_channel_plugin,
|
||||||
)
|
)
|
||||||
assert config.channels.qq.get("showCompactionNotices") is None
|
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"
|
||||||
@@ -326,7 +326,7 @@ export function SettingsPage({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "about":
|
case "about":
|
||||||
return <AboutSettings currentVersion={settings.version?.current} />;
|
return <AboutSettings settings={settings} />;
|
||||||
case "appearance":
|
case "appearance":
|
||||||
return (
|
return (
|
||||||
<AppearanceSettings
|
<AppearanceSettings
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
ImageGenerationIcon,
|
ImageGenerationIcon,
|
||||||
VoiceIcon,
|
VoiceIcon,
|
||||||
} from "@/components/icons/product-icons";
|
} from "@/components/icons/product-icons";
|
||||||
import { useState, type Dispatch, type SetStateAction } from "react";
|
import { useContext, useState, type Dispatch, type SetStateAction } from "react";
|
||||||
import {
|
import {
|
||||||
ArrowUpCircle,
|
ArrowUpCircle,
|
||||||
BookOpen,
|
BookOpen,
|
||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { HostNavigationContext } from "@/components/remote/HostSwitcher";
|
||||||
import { StarLink } from "@/components/StarPrompt";
|
import { StarLink } from "@/components/StarPrompt";
|
||||||
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
|
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
|
||||||
import { DEFAULT_TRANSCRIPTION_SETTINGS } from "@/components/settings/capabilities/TranscriptionSettings";
|
import { DEFAULT_TRANSCRIPTION_SETTINGS } from "@/components/settings/capabilities/TranscriptionSettings";
|
||||||
@@ -68,9 +69,9 @@ export function OverviewSettings({
|
|||||||
? settings.agent.model
|
? settings.agent.model
|
||||||
: tx("settings.values.notConfigured", "Not configured");
|
: tx("settings.values.notConfigured", "Not configured");
|
||||||
const activeModelCaption = activeProviderConfigured
|
const activeModelCaption = activeProviderConfigured
|
||||||
? [activeProvider, activePreset].filter(Boolean).join(" · ")
|
? [activeProvider, activePreset].filter(Boolean).join(" ")
|
||||||
: activeProviderLabel || settings.agent.model
|
: 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");
|
: tx("settings.byok.noConfiguredProviders", "No configured providers");
|
||||||
const webStatus = settings.web.enable
|
const webStatus = settings.web.enable
|
||||||
? tx("settings.values.enabled", "Enabled")
|
? 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 { 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 = [
|
const links = [
|
||||||
{ key: "sourceCode", icon: Github, href: "https://github.com/HKUDS/nanobot" },
|
{ key: "sourceCode", icon: Github, href: "https://github.com/HKUDS/nanobot" },
|
||||||
{ key: "documentation", icon: BookOpen, href: "https://nanobot.wiki/" },
|
{ 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 (
|
return (
|
||||||
<div className="flex flex-1 flex-col gap-5">
|
<div className="flex flex-1 flex-col gap-5">
|
||||||
<div className="flex flex-col items-center gap-4 py-6 text-center">
|
<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} />
|
<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>
|
<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>
|
</div>
|
||||||
<SettingsGroup>
|
<SettingsGroup>
|
||||||
{links.map(({ key, icon: Icon, href }) => (
|
{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 { t } = useTranslation();
|
||||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||||
const { token } = useClient();
|
const { token } = useClient();
|
||||||
@@ -209,6 +235,17 @@ function VersionCheckRow({ currentVersion }: { currentVersion?: string }) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="mt-0.5 text-[12px] leading-5 text-muted-foreground">
|
<div className="mt-0.5 text-[12px] leading-5 text-muted-foreground">
|
||||||
{currentVersion ? `v${currentVersion}` : "nanobot"}
|
{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>
|
</div>
|
||||||
<div className="flex shrink-0 flex-col items-center gap-2">
|
<div className="flex shrink-0 flex-col items-center gap-2">
|
||||||
|
|||||||
@@ -907,6 +907,13 @@ export interface SettingsPayload {
|
|||||||
restart_required_sections?: Array<"runtime" | "browser" | "image">;
|
restart_required_sections?: Array<"runtime" | "browser" | "image">;
|
||||||
version?: {
|
version?: {
|
||||||
current: string;
|
current: string;
|
||||||
|
commit?: string | null;
|
||||||
|
};
|
||||||
|
environment?: {
|
||||||
|
python_version: string;
|
||||||
|
os: string;
|
||||||
|
os_version: string;
|
||||||
|
architecture: string;
|
||||||
};
|
};
|
||||||
docs?: {
|
docs?: {
|
||||||
version: string;
|
version: string;
|
||||||
|
|||||||
@@ -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 { 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 type { SettingsPayload } from "@/lib/types";
|
||||||
import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
|
import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
|
||||||
|
|
||||||
@@ -10,6 +14,66 @@ describe("Settings overview and appearance", () => {
|
|||||||
installSettingsViewTestHooks();
|
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 () => {
|
it("persists the file edit display local preference", async () => {
|
||||||
renderSettingsView({
|
renderSettingsView({
|
||||||
initialSection: "appearance",
|
initialSection: "appearance",
|
||||||
|
|||||||
Reference in new issue
Block a user