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
@@ -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 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),
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user