fix(status): source column reflects real traffic + theme-aware tray menu

- api/status sources now carry recent_ok/recent_err (last 300s real gateway
  requests via Stats.SourceRecent) so a source actually serving traffic is
  never shown as down just because probe /models got rate-limited
- WebUI source status column repaints every 5s (no more frozen-at-first-
  render) with a manual refresh button; shows success rate + probe + cooldown
- tray menu status rows were enabled:false (GTK fixed light-grey, invisible
  on light themes) — now enabled with no-op click and nativeTheme listener
  rebuilds the menu on dark/light switches
- ignore local ops scripts (scripts/, machine-specific)
This commit is contained in:
2026-08-17 17:37:04 +08:00
parent 23bd9e5552
commit 8c5279b416
6 changed files with 141 additions and 32 deletions

View File

@ -10,6 +10,7 @@ const {
Tray,
shell,
nativeImage,
nativeTheme,
} = require("electron");
const path = require("path");
const fs = require("fs");
@ -357,17 +358,27 @@ function createTray() {
);
}
tray = new Tray(img);
// Rebuild the context menu when the OS theme flips (dark/light) so menu
// text colors follow the desktop theme; nativeTheme is the Electron API
// that tracks GTK/appindicator dark mode on Linux.
const themeRebuild = () => {
try {
if (global.__rebuildTray) global.__rebuildTray();
} catch (e) {}
};
try {
nativeTheme.on("updated", themeRebuild);
} catch (e) {}
// Status rows used to be enabled:false, which GTK renders in a fixed light
// grey that never flips with the system dark/light theme — invisible on
// light desktops. They are now enabled (normal theme-aware fg) with a
// no-op click so they stay display-only but inherit the menu text color.
const statusRow = (text) => ({ label: text, enabled: true, click: () => {} });
const rebuild = () => {
const running = coreStarted();
const menu = Menu.buildFromTemplate([
{
label: "ModelRouter Desktop",
enabled: false,
},
{
label: running ? "● 内核运行中" : "○ 内核已停止",
enabled: false,
},
statusRow("ModelRouter Desktop"),
statusRow(running ? "● 内核运行中" : "○ 内核已停止"),
{ type: "separator" },
{
label: "显示主窗口",