Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(observability): add Sentry error reporting

cyhf850f70f7102
diff --git a/config/v2_config.py b/config/v2_config.py
index b923a94e2..5d9571438 100644
--- a/config/v2_config.py
+++ b/config/v2_config.py
@@ -101,6 +101,22 @@ class RuntimeConfig:
log_level: str = "INFO"
+@dataclass
+class SentryConfig:
+ dsn: Optional[str] = None
+ environment: Optional[str] = None
+ traces_sample_rate: float = 0.0
+ profiles_sample_rate: float = 0.0
+ send_default_pii: bool = False
+
+ def validate(self) -> None:
+ for field_name in ("traces_sample_rate", "profiles_sample_rate"):
+ value = getattr(self, field_name)
+ if not isinstance(value, (int, float)) or not 0.0 <= float(value) <= 1.0:
+ raise ValueError(f"Config 'sentry.{field_name}' must be a number between 0 and 1")
+ setattr(self, field_name, float(value))
+
+
@dataclass
class OpenCodeConfig:
enabled: bool = True
@@ -191,6 +207,7 @@ class V2Config:
lark: Optional[LarkConfig] = None
wechat: Optional[WeChatConfig] = None
gateway: Optional[GatewayConfig] = None
+ sentry: Optional[SentryConfig] = None
ui: UiConfig = field(default_factory=UiConfig)
update: UpdateConfig = field(default_factory=UpdateConfig)
ack_mode: str = "typing"
@@ -294,6 +311,14 @@ class V2Config:
raise ValueError("Config 'gateway' must be an object")
gateway = GatewayConfig(**_filter_dataclass_fields(GatewayConfig, gateway_payload)) if gateway_payload else None
+ sentry_payload = payload.get("sentry")
+ if sentry_payload is not None and not isinstance(sentry_payload, dict):
+ raise ValueError("Config 'sentry' must be an object")
+ sentry = None
+ if sentry_payload is not None:
+ sentry = SentryConfig(**_filter_dataclass_fields(SentryConfig, sentry_payload))
+ sentry.validate()
+
runtime_payload = payload.get("runtime")
if not isinstance(runtime_payload, dict):
raise ValueError("Config 'runtime' must be an object")
@@ -373,6 +398,7 @@ class V2Config:
runtime=runtime,
agents=agents,
gateway=gateway,
+ sentry=sentry,
ui=ui,
update=update,
ack_mode=ack_mode,
@@ -410,6 +436,7 @@ class V2Config:
"codex": self.agents.codex.__dict__,
},
"gateway": self.gateway.__dict__ if self.gateway else None,
+ "sentry": self.sentry.__dict__ if self.sentry else None,
"ui": self.ui.__dict__,
"update": self.update.__dict__,
"ack_mode": self.ack_mode,
diff --git a/docs/CLI.md b/docs/CLI.md
index 74929159d..9f6ea3dd2 100644
--- a/docs/CLI.md
+++ b/docs/CLI.md
@@ -244,6 +244,10 @@ The web UI (`http://127.0.0.1:5123`) provides the same controls:
| Variable | Description |
|----------|-------------|
| `OPENCODE_PORT` | Override OpenCode server port (default: 4096) |
+| `VIBE_SENTRY_DSN` / `SENTRY_DSN` | Enable Sentry error reporting for the main service and Web UI |
+| `VIBE_SENTRY_ENVIRONMENT` / `SENTRY_ENVIRONMENT` | Override the Sentry environment tag |
+| `VIBE_SENTRY_TRACES_SAMPLE_RATE` | Override Sentry traces sample rate (0.0-1.0) |
+| `VIBE_SENTRY_PROFILES_SAMPLE_RATE` | Override Sentry profiles sample rate (0.0-1.0) |
## See Also
diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.md
index af10d5161..753f9079f 100644
--- a/docs/CLI_ZH.md
+++ b/docs/CLI_ZH.md
@@ -244,6 +244,10 @@ Web UI (`http://127.0.0.1:5123`) 提供相同的控制功能:
| 变量 | 说明 |
|------|------|
| `OPENCODE_PORT` | 覆盖 OpenCode 服务器端口(默认:4096) |
+| `VIBE_SENTRY_DSN` / `SENTRY_DSN` | 为主服务和 Web UI 启用 Sentry 错误上报 |
+| `VIBE_SENTRY_ENVIRONMENT` / `SENTRY_ENVIRONMENT` | 覆盖 Sentry 的 environment 标签 |
+| `VIBE_SENTRY_TRACES_SAMPLE_RATE` | 覆盖 Sentry traces 采样率(0.0-1.0) |
+| `VIBE_SENTRY_PROFILES_SAMPLE_RATE` | 覆盖 Sentry profiles 采样率(0.0-1.0) |
## 另请参阅
diff --git a/main.py b/main.py
index 53ad0a25d..05b0c79ba 100644
--- a/main.py
+++ b/main.py
@@ -7,6 +7,7 @@ import asyncio
from config.paths import ensure_data_dirs, get_logs_dir
from config.v2_config import V2Config
from core.controller import Controller
+from vibe.sentry_integration import init_sentry
def setup_logging(level: str = "INFO"):
@@ -61,6 +62,7 @@ def main():
logger = logging.getLogger(__name__)
apply_claude_sdk_patches()
+ init_sentry(config, component="service")
logger.info("Starting vibe-remote service...")
logger.info(f"Working directory: {config.runtime.default_cwd}")
diff --git a/pyproject.toml b/pyproject.toml
index 196e81f8e..5d95879d4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -37,6 +37,7 @@ dependencies = [
"PyYAML>=6.0",
"flask>=3.0.0",
"lark-oapi>=1.4.0",
+ "sentry-sdk>=2.0.0",
"python-socks[asyncio]>=2.0.0",
"aiohttp-socks>=0.8.0",
]
diff --git a/tests/test_api_save_config_merge.py b/tests/test_api_save_config_merge.py
index 116984d15..0f6d688a2 100644
--- a/tests/test_api_save_config_merge.py
+++ b/tests/test_api_save_config_merge.py
@@ -62,6 +62,13 @@ def _full_config_payload() -> dict:
},
},
"gateway": None,
+ "sentry": {
+ "dsn": "https://[email protected]/1",
+ "environment": "test",
+ "traces_sample_rate": 0.0,
+ "profiles_sample_rate": 0.0,
+ "send_default_pii": False,
+ },
"ui": {
"setup_host": "127.0.0.1",
"setup_port": 5123,
@@ -96,6 +103,8 @@ def test_save_config_merges_partial_payload(monkeypatch, tmp_path):
assert updated.discord is not None
assert updated.discord.bot_token == "discord-token-1234567890"
assert updated.runtime.default_cwd == "/tmp/workdir"
+ assert updated.sentry is not None
+ assert updated.sentry.dsn == "https://[email protected]/1"
def test_save_config_accepts_typing_ack_mode(monkeypatch, tmp_path):
@@ -154,6 +163,17 @@ def test_save_config_rejects_enabled_platform_without_credentials(monkeypatch, t
)
+def test_save_config_round_trips_sentry_config(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+
+ updated = api.save_config(_full_config_payload())
+ payload = api.config_to_payload(updated)
+
+ assert payload["sentry"]["dsn"] == "https://[email protected]/1"
+ assert payload["sentry"]["environment"] == "test"
+ assert payload["sentry"]["traces_sample_rate"] == 0.0
+
+
def test_init_sessions_is_noop_when_sessions_file_exists(monkeypatch, tmp_path):
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
diff --git a/tests/test_sentry_integration.py b/tests/test_sentry_integration.py
new file mode 100644
index 000000000..dd58b5a4e
--- /dev/null
+++ b/tests/test_sentry_integration.py
@@ -0,0 +1,70 @@
+from __future__ import annotations
+
+import os
+
+from config.v2_config import (
+ AgentsConfig,
+ RuntimeConfig,
+ SentryConfig,
+ SlackConfig,
+ V2Config,
+)
+from vibe.sentry_integration import resolve_sentry_options, scrub_data
+
+
+def _config_with_sentry() -> V2Config:
+ return V2Config(
+ mode="self_host",
+ version="v2",
+ slack=SlackConfig(bot_token=""),
+ runtime=RuntimeConfig(default_cwd="/tmp/workdir", log_level="INFO"),
+ agents=AgentsConfig(),
+ sentry=SentryConfig(
+ dsn="https://[email protected]/1",
+ environment="config-env",
+ traces_sample_rate=0.0,
+ profiles_sample_rate=0.0,
+ send_default_pii=False,
+ ),
+ )
+
+
+def test_resolve_sentry_options_prefers_environment(monkeypatch):
+ monkeypatch.setenv("VIBE_SENTRY_DSN", "https://[email protected]/2")
+ monkeypatch.setenv("VIBE_SENTRY_ENVIRONMENT", "regression")
+ monkeypatch.setenv("VIBE_SENTRY_TRACES_SAMPLE_RATE", "0.25")
+ config = _config_with_sentry()
+
+ options = resolve_sentry_options(config)
+
+ assert options is not None
+ assert options["dsn"] == "https://[email protected]/2"
+ assert options["environment"] == "regression"
+ assert options["traces_sample_rate"] == 0.25
+
+
+def test_resolve_sentry_options_returns_none_without_dsn(monkeypatch):
+ monkeypatch.delenv("VIBE_SENTRY_DSN", raising=False)
+ monkeypatch.delenv("SENTRY_DSN", raising=False)
+ config = _config_with_sentry()
+ config.sentry = SentryConfig()
+
+ assert resolve_sentry_options(config) is None
+
+
+def test_scrub_data_redacts_sensitive_values():
+ event = {
+ "request": {
+ "headers": {"Authorization": "Bearer abc", "Cookie": "session=secret"},
+ "data": {"bot_token": "xoxb-secret", "nested": [{"client_secret": "shh"}]},
+ },
+ "message": "token=abc123 and xapp-123456",
+ }
+
+ scrubbed = scrub_data(event)
+
+ assert scrubbed["request"]["headers"]["Authorization"] == "[Filtered]"
+ assert scrubbed["request"]["headers"]["Cookie"] == "[Filtered]"
+ assert scrubbed["request"]["data"]["bot_token"] == "[Filtered]"
+ assert scrubbed["request"]["data"]["nested"][0]["client_secret"] == "[Filtered]"
+ assert "[Filtered]" in scrubbed["message"]
diff --git a/ui/src/components/Dashboard.tsx b/ui/src/components/Dashboard.tsx
index e314c1252..1b6fbc6c6 100644
--- a/ui/src/components/Dashboard.tsx
+++ b/ui/src/components/Dashboard.tsx
@@ -94,11 +94,21 @@ export const Dashboard: React.FC = () => {
setDiagnosticsSaving(true);
setDiagnosticsMessage(null);
try {
+ const sentryDsn = (config.sentry?.dsn || '').trim();
+ const sentryEnvironment = (config.sentry?.environment || '').trim();
+ const sentryPayload = sentryDsn || sentryEnvironment || config.sentry?.traces_sample_rate || config.sentry?.profiles_sample_rate || config.sentry?.send_default_pii
+ ? {
+ ...(config.sentry || {}),
+ dsn: sentryDsn || null,
+ environment: sentryEnvironment || null,
+ }
+ : null;
const runtimePayload = {
log_level: config.runtime?.log_level || 'INFO',
};
const configPayload = {
runtime: runtimePayload,
+ sentry: sentryPayload,
};
await fetch('/config', {
method: 'POST',
@@ -521,6 +531,43 @@ export const Dashboard: React.FC = () => {
))}
</select>
</div>
+ <div className="flex justify-between items-center">
+ <span className="text-muted">{t('dashboard.sentryDsn')}</span>
+ <input
+ type="password"
+ value={config.sentry?.dsn || ''}
+ onChange={(e) => {
+ const dsn = e.target.value;
+ setDiagnosticsMessage(null);
+ setConfig((prev: any) => ({
+ ...prev,
+ sentry: { ...(prev.sentry || {}), dsn },
+ }));
+ }}
+ placeholder="https://..."
+ className="w-64 bg-neutral-100 border border-border rounded px-2 py-1 text-xs font-mono"
+ />
+ </div>
+ <div className="flex justify-between items-center">
+ <span className="text-muted">{t('dashboard.sentryEnvironment')}</span>
+ <input
+ type="text"
+ value={config.sentry?.environment || ''}
+ onChange={(e) => {
+ const environment = e.target.value;
+ setDiagnosticsMessage(null);
+ setConfig((prev: any) => ({
+ ...prev,
+ sentry: { ...(prev.sentry || {}), environment },
+ }));
+ }}
+ placeholder="production"
+ className="w-40 bg-neutral-100 border border-border rounded px-2 py-1 text-xs font-mono"
+ />
+ </div>
+ <div className="text-xs text-muted">
+ {t('dashboard.sentryHint')}
+ </div>
<div className="flex justify-between items-center">
<span className="text-muted">{t('dashboard.configFile')}</span>
<code className="font-mono text-xs bg-neutral-100 px-2 py-1 rounded text-text">~/.vibe_remote/config/config.json</code>
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 6829d2bd2..24f7f82aa 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -414,6 +414,9 @@
"port": "Port",
"diagnostics": "Diagnostics",
"logLevel": "Log Level",
+ "sentryDsn": "Sentry DSN",
+ "sentryEnvironment": "Sentry Environment",
+ "sentryHint": "Leave DSN empty to disable. Advanced sample-rate overrides remain available via env vars or config JSON.",
"configFile": "Config File",
"logs": "Logs",
"uiRestartMessage": "Saved. Restarting UI server...",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index bd0d38286..765b1ad63 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -414,6 +414,9 @@
"port": "端口",
"diagnostics": "诊断",
"logLevel": "日志级别",
+ "sentryDsn": "Sentry DSN",
+ "sentryEnvironment": "Sentry 环境",
+ "sentryHint": "DSN 留空即禁用。更高级的采样率覆盖仍可通过环境变量或 config JSON 设置。",
"configFile": "配置文件",
"logs": "日志",
"uiRestartMessage": "已保存,正在重启 UI 服务器...",
diff --git a/uv.lock b/uv.lock
index 1bbd538b7..1e88ae6ef 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1688,6 +1688,19 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/b7/b95708304cd49b7b6f82fdd039f1748b66ec2b21d6a45180910802f1abf1/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:ac37f9f516c51e5753f27dfdef11a88330f04de2d564be3991384b2f3535d02e", size = 562191, upload-time = "2025-11-30T20:24:36.853Z" },
]
+[[package]]
+name = "sentry-sdk"
+version = "2.56.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "certifi" },
+ { name = "urllib3" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/de/df/5008954f5466085966468612a7d1638487596ee6d2fd7fb51783a85351bf/sentry_sdk-2.56.0.tar.gz", hash = "sha256:fdab72030b69625665b2eeb9738bdde748ad254e8073085a0ce95382678e8168", size = 426820, upload-time = "2026-03-24T09:56:36.575Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/cd/1a/b3a3e9f6520493fed7997af4d2de7965d71549c62f994a8fd15f2ecd519e/sentry_sdk-2.56.0-py2.py3-none-any.whl", hash = "sha256:5afafb744ceb91d22f4cc650c6bd048ac6af5f7412dcc6c59305a2e36f4dbc02", size = 451568, upload-time = "2026-03-24T09:56:34.807Z" },
+]
+
[[package]]
name = "slack-sdk"
version = "3.39.0"
@@ -1781,6 +1794,7 @@ dependencies = [
{ name = "markdown-to-mrkdwn" },
{ name = "python-socks", extra = ["asyncio"] },
{ name = "pyyaml" },
+ { name = "sentry-sdk" },
{ name = "slack-sdk" },
{ name = "typing-extensions" },
]
@@ -1797,6 +1811,7 @@ requires-dist = [
{ name = "markdown-to-mrkdwn", specifier = ">=0.2.0" },
{ name = "python-socks", extras = ["asyncio"], specifier = ">=2.0.0" },
{ name = "pyyaml", specifier = ">=6.0" },
+ { name = "sentry-sdk", specifier = ">=2.0.0" },
{ name = "slack-sdk", specifier = ">=3.26.0" },
{ name = "typing-extensions", specifier = ">=4.12.2" },
]
diff --git a/vibe/api.py b/vibe/api.py
index 9b6cc7fc7..4417e9f1a 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -267,6 +267,7 @@ def config_to_payload(config: V2Config) -> dict:
"codex": config.agents.codex.__dict__,
},
"gateway": config.gateway.__dict__ if config.gateway else None,
+ "sentry": config.sentry.__dict__ if config.sentry else None,
"ui": config.ui.__dict__,
"update": config.update.__dict__,
"ack_mode": config.ack_mode,
diff --git a/vibe/sentry_integration.py b/vibe/sentry_integration.py
new file mode 100644
index 000000000..7871dba49
--- /dev/null
+++ b/vibe/sentry_integration.py
@@ -0,0 +1,183 @@
+from __future__ import annotations
+
+import logging
+import os
+import re
+from typing import Any, Optional
+
+from config.v2_config import V2Config
+
+logger = logging.getLogger(__name__)
+
+_SENSITIVE_KEY_PARTS = (
+ "access_key",
+ "api_key",
+ "app_token",
+ "authorization",
+ "bot_token",
+ "client_secret",
+ "cookie",
+ "dsn",
+ "password",
+ "secret",
+ "signing_secret",
+ "token",
+ "webhook",
+ "workspace_token",
+)
+_REDACTED = "[Filtered]"
+_STRING_REPLACEMENTS = (
+ (re.compile(r"(?i)(authorization[:=]\s*)(bearer\s+)?\S+"), r"\1" + _REDACTED),
+ (re.compile(r"(?i)(token=)[^&\s]+"), r"\1" + _REDACTED),
+ (re.compile(r"(?i)(cookie[:=]\s*)\S+"), r"\1" + _REDACTED),
+ (re.compile(r"\bxox[baprs]-[A-Za-z0-9-]+\b"), _REDACTED),
+ (re.compile(r"\bxapp-[A-Za-z0-9-]+\b"), _REDACTED),
+)
+
+
+def _redact_string(value: str) -> str:
+ redacted = value
+ for pattern, replacement in _STRING_REPLACEMENTS:
+ redacted = pattern.sub(replacement, redacted)
+ return redacted
+
+
+def _is_sensitive_key(key: str) -> bool:
+ lowered = key.lower()
+ return any(part in lowered for part in _SENSITIVE_KEY_PARTS)
+
+
+def scrub_data(value: Any) -> Any:
+ if isinstance(value, dict):
+ scrubbed: dict[Any, Any] = {}
+ for key, item in value.items():
+ if isinstance(key, str) and _is_sensitive_key(key):
+ scrubbed[key] = _REDACTED
+ else:
+ scrubbed[key] = scrub_data(item)
+ return scrubbed
+ if isinstance(value, list):
+ return [scrub_data(item) for item in value]
+ if isinstance(value, tuple):
+ return tuple(scrub_data(item) for item in value)
+ if isinstance(value, str):
+ return _redact_string(value)
+ return value
+
+
+def _safe_float(raw: Optional[str], fallback: float) -> float:
+ if raw is None or raw == "":
+ return fallback
+ try:
+ value = float(raw)
+ except (TypeError, ValueError):
+ logger.warning("Invalid Sentry sample rate %r, falling back to %s", raw, fallback)
+ return fallback
+ if 0.0 <= value <= 1.0:
+ return value
+ logger.warning("Out-of-range Sentry sample rate %r, falling back to %s", raw, fallback)
+ return fallback
+
+
+def resolve_sentry_options(config: V2Config) -> Optional[dict[str, Any]]:
+ sentry_config = getattr(config, "sentry", None)
+ env_dsn = os.environ.get("VIBE_SENTRY_DSN") or os.environ.get("SENTRY_DSN")
+ dsn = env_dsn or (sentry_config.dsn if sentry_config else None)
+ if not dsn:
+ return None
+
+ environment = (
+ os.environ.get("VIBE_SENTRY_ENVIRONMENT")
+ or os.environ.get("SENTRY_ENVIRONMENT")
+ or (sentry_config.environment if sentry_config else None)
+ or config.mode
+ )
+ traces_sample_rate = _safe_float(
+ os.environ.get("VIBE_SENTRY_TRACES_SAMPLE_RATE"),
+ sentry_config.traces_sample_rate if sentry_config else 0.0,
+ )
+ profiles_sample_rate = _safe_float(
+ os.environ.get("VIBE_SENTRY_PROFILES_SAMPLE_RATE"),
+ sentry_config.profiles_sample_rate if sentry_config else 0.0,
+ )
+ return {
+ "dsn": dsn,
+ "environment": environment,
+ "traces_sample_rate": traces_sample_rate,
+ "profiles_sample_rate": profiles_sample_rate,
+ "send_default_pii": bool(sentry_config.send_default_pii) if sentry_config else False,
+ }
+
+
+def before_send(event: dict[str, Any], hint: dict[str, Any]) -> dict[str, Any]:
+ del hint
+ return scrub_data(event)
+
+
+def before_breadcrumb(crumb: dict[str, Any], hint: dict[str, Any]) -> dict[str, Any]:
+ del hint
+ return scrub_data(crumb)
+
+
+def init_sentry(config: V2Config, component: str, enable_flask: bool = False) -> bool:
+ options = resolve_sentry_options(config)
+ if not options:
+ return False
+
+ try:
+ import sentry_sdk
+ from sentry_sdk.integrations.logging import LoggingIntegration
+ except Exception as exc:
+ logger.warning("Sentry initialization skipped: %s", exc)
+ return False
+
+ integrations: list[Any] = [
+ LoggingIntegration(
+ level=logging.WARNING,
+ event_level=logging.ERROR,
+ )
+ ]
+ if enable_flask:
+ try:
+ from sentry_sdk.integrations.flask import FlaskIntegration
+ except Exception as exc:
+ logger.warning("Flask Sentry integration unavailable: %s", exc)
+ else:
+ integrations.append(FlaskIntegration())
+
+ from vibe import __version__
+
+ sentry_sdk.init(
+ dsn=options["dsn"],
+ environment=options["environment"],
+ release=f"vibe-remote@{__version__}",
+ integrations=integrations,
+ before_send=before_send,
+ before_breadcrumb=before_breadcrumb,
+ attach_stacktrace=True,
+ ignore_errors=[KeyboardInterrupt, SystemExit],
+ max_breadcrumbs=50,
+ traces_sample_rate=options["traces_sample_rate"],
+ profiles_sample_rate=options["profiles_sample_rate"],
+ send_default_pii=options["send_default_pii"],
+ )
+ sentry_sdk.set_tag("component", component)
+ sentry_sdk.set_tag("mode", config.mode)
+ sentry_sdk.set_tag("primary_platform", config.platforms.primary)
+ sentry_sdk.set_context(
+ "vibe_remote",
+ {
+ "enabled_platforms": config.platforms.enabled,
+ "default_backend": config.agents.default_backend,
+ },
+ )
+ logger.info("Sentry initialized for %s (environment=%s)", component, options["environment"])
+ return True
+
+
+def capture_exception(exc: Exception) -> None:
+ try:
+ import sentry_sdk
+ except Exception:
+ return
+ sentry_sdk.capture_exception(exc)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 4cd021e18..88090b6f7 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -10,7 +10,9 @@ from typing import Any
from flask import Flask, request, jsonify, send_file, Response
from config import paths
+from config.v2_config import V2Config
from vibe.runtime import get_ui_dist_path, get_working_dir
+from vibe.sentry_integration import capture_exception, init_sentry
logger = logging.getLogger(__name__)
@@ -63,6 +65,7 @@ def handle_exception(e):
return jsonify({"error": e.description}), e.code
# Log and return 500 for unexpected server errors
+ capture_exception(e)
logger.exception("Unhandled exception in UI server")
return jsonify({"error": str(e)}), 500
@@ -847,6 +850,12 @@ def run_ui_server(host: str, port: int) -> None:
from werkzeug.serving import make_server
paths.ensure_data_dirs()
+ try:
+ config = V2Config.load()
+ except FileNotFoundError:
+ config = None
+ if config is not None:
+ init_sentry(config, component="ui", enable_flask=True)
print(f"UI Server running at http://{host}:{port}")
# Use make_server directly for better compatibility with subprocess/multiprocessing