Adversarial pass (MINOR): the new Segmented/IconBtn regressed a11y vs the
project's existing Segmented. Add role=radiogroup/radio + aria-checked to the
segmented control, type="button" to all buttons (segmented, icon, execute,
row toggle), aria-label to icon buttons, aria-expanded to the row toggle.
Move the debug console out of the Settings 调试 subtab into a dedicated
top-level /debug page (sidebar nav + route + AppPath), and redesign it in an
Apple-HIG flavour: translucent sticky header with title block + connection
pill, soft layered cards (rounded-2xl, hairline borders, blurred backdrop),
an iOS-style segmented control with a sliding active pill (params form/JSON,
stream all/event/action filter), refined timeline rows + empty state, calm
type hierarchy with tabular-nums. Logic (tester + live SSE) carried over
verbatim. Remove the old settings/debug-panel + the Settings 'debug' subtab.
Adversarial Wave A3 flagged the hand-rolled SSE drop/marker logic as the
untested weak point. Extract createFramePusher (drop under desiredSize<=0,
coalesced {kind:'dropped'} marker before the next delivered frame, null = no
backpressure) and unit-test it; the stream handler now uses it. Non-blocking
hardening — no behavior change.
New Settings → 调试 tab (DebugPanel): an action tester (account picker +
schema-driven form from /api/debug/actions, with a raw-JSON escape hatch for
legacy actions, real-side-effect warning) and a live merged SSE view of OneBot
events + action calls (pause / clear / kind filter, expandable JSON, drop
marker). Typed debug API client domain (actions/invoke/stream over EventSource
with ?token=). View layer — verified by tsc + vite build.
GET /api/debug/actions (collectActionDocs for the tester form), POST
/api/debug/invoke {uin,action,params} (routes to that account's ApiHandler —
real side effects, /api/* auth, uin validated), GET /api/debug/stream (merged
SSE of OneBot events + action calls across accounts, tagged by uin+kind). Taps
attach only while a client is connected (on-demand); a slow client is dropped
with a periodic {kind:'dropped'} marker rather than buffering unbounded.
/api/debug/stream added to the ?token= allowlist for EventSource.
Add NetworkManager.subscribeDebug (notified for every emitEvent, before the
adapter check, so the debug stream sees events even with no adapter) and
ApiHandler.setObserver (fires after every handled action with
{action,params,response,ms}, success or failure). Both Set-based, return an
unsubscribe, and swallow subscriber throws so they never break dispatch.
OneBotInstance exposes subscribeDebugEvents / observeActions / invokeAction.
Foundation for the Wave A3 debug stream + action tester.
Adversarial Wave A2 pass, 3 MAJORs:
- #3/#3b: the allowlist missed per-account config/onebot_<uin>.json (the file
that actually carries each account's network config + OneBot access token).
Add it via an /^onebot_\d+\.json$/ pattern; classify ALL onebot config
(global + per-uin) as credential since it holds the access token — a
no-credentials backup no longer leaks tokens. Export scans config/ for them.
- #6: GET export could carry the private key/hash; add Cache-Control: no-store
+ Pragma so the response is never cached.
- #4: refactor applyBackup → pure planRestore + a two-phase atomic restore in
server.ts (snapshot → stage all .tmp → rename all), so a staging failure
leaves the live config untouched; clean up stray tmp on failure.
A '配置备份 / 恢复' card in the 服务 tab: export downloads the JSON bundle
(with an 包含登录凭据 toggle + red warning), restore picks a .json file and
calls importBackup with a 一并恢复登录凭据 toggle (default off). Shows
restored/skipped counts + restart-to-apply. Typed systemSettings.exportBackup/
importBackup client methods. View layer — verified by tsc + vite build.
GET /api/system/backup/export?credentials=1 streams the JSON bundle (download
header); POST /api/system/backup/import validates then applies, snapshotting
current config to config/.restore-backup-<ts>/ first (recoverable), writing
atomically (tmp+rename), key.pem at 0600. Both behind /api/* auth; import body
capped at 32MB. Restore is restart-to-apply.
Add reusable Select (styled native select + chevron) and Textarea components
matching Input's design language, and replace every native <select>/<textarea>
across the app (system-panel, node-edit-dialog, notification-channel-dialog,
settings customCss, widget note) with them.
TLS cert UX: once a cert is installed, the sensitive PEM is no longer rendered
on revisit — show an '已安装(未改变)' summary with 更改/删除 buttons; 更改
reveals the inputs again (with a 取消). Private key is never sent back to the
client. Verified by tsc + vite build.
Wrap the post-write chmodSync in try/catch like auth.ts: the key is already
written with mode 0600, so a rare chmod failure shouldn't misreport a
successful write as a 500.
Adversarial Wave A1 pass (MAJOR): the TLS private key was written with the
default umask mode (typically 0644 — world-readable). Write config/key.pem
with mode 0600 + an explicit chmodSync (writeFileSync's mode is ignored for an
existing file), mirroring auth.ts's webui.json handling. cert.pem stays public.
New Settings → 服务 tab (SystemPanel) over the /api/system/settings + TLS cert
API: edit port / bind host / trust-proxy, paste cert+key PEM to enable HTTPS,
delete cert. Flags env-overridden fields ('被环境变量覆盖') and shows a
restart-to-apply banner (no self-restart). Typed systemSettings API client
domain. View layer — verified by tsc + vite build (webui has no component-test
infra).
GET/POST /api/system/settings (port/host/tlsEnabled/trustProxy) persisted via
updateRuntimeConfig — listener-level, restart-to-apply; response carries
restartRequiredToApply + the env-overridden field names so the panel can flag
edits that won't take effect. Enabling TLS is blocked unless a usable cert is
present. POST/DELETE /api/system/tls/cert validates a pasted PEM pair
(validateTlsPair) before writing config/cert.pem + key.pem. Adds read-only
readRuntimeConfig() and a tested pure coerceSettingsPatch validator. All routes
sit behind the existing /api/* auth middleware.
Persist a partial RuntimeConfig update, merging onto the on-disk config (not
the env-merged view) so an env override is never baked into runtime.json.
Tested: patch merge + the env-not-persisted invariant (chdir to a temp cwd).
Move the trust-proxy/client-ip resolver from a module-level direct read of
SNOWLUMA_WEBUI_TRUST_PROXY into initWebUI, fed by runtime.json's trustProxy
(loadRuntimeConfig already merges the env override on top). Default '' parses
identically to the old undefined (trust socket peer only), so behavior is
unchanged when unset.
initWebUI now takes { host, tlsEnabled }. When TLS is enabled, load+validate
config/cert.pem + key.pem (tls.ts: validateTlsPair / resolveTlsContext, both
unit-tested) and serve via @hono/node-server's https createServer; a missing
or invalid cert falls back to HTTP with a loud warning (never bricks the WebUI).
Bind host is now configurable (default 0.0.0.0). Wired from runtime.json
(webuiHost / webuiTls.enabled) in core/index.ts.
Add webuiHost / webuiTls.enabled / trustProxy to RuntimeConfig as the shared
system-settings model for WebUI Wave A1 (HTTPS + self-config panel). Refactor
load into pure, tested normalizeRuntimeConfig + resolveRuntimeEnvOverrides
(env wins, in-memory only; SNOWLUMA_WEBUI_HOST added alongside the existing
PORT/TRUST_PROXY overrides). loadRuntimeConfig backfills older runtime.json
with the new defaults. Adds vitest to @snowluma/common (was typecheck-only).
Adversarial Wave 3 pass: the prior 'round-trip locks pb tags' test was a
fake lock — symmetric encode/decode via the same proto would not catch a tag
swap. Replace with a fixed hex byte-oracle (hand-decoded in the comment) that
goes red on any tag change, plus an empty-ocr-body deserialize test. Note in
the action that a passed-in URL is used verbatim (not rkey re-signed).
Server-side image OCR ported from Lagrange.Core ([Service]
"OidbSvcTrpcTcp.0xe07_0") cross-checked with NapCat's Oidb.0xE07 proto
(NapCat's transformer cmd 0xEB7 is a typo; the proto name + Lagrange + the
wire name all say 0xE07_0). New ImageOcr service + proto types, misc.ocrImage
api, and the ocr_image/.ocr_image action. The cmd takes an image URL, so the
action accepts an http(s) url or a cached image file_id (resolved via
getImageInfo); base64/local input is unsupported (NapCat's path is a
Windows-only kernel OCR, not portable). Wire round-trip + response-parse
tests lock the pb tags.
Adversarial Wave 2 pass (no blockers): get_rkey_server now returns
ACTION_FAILED instead of an 'expired_time=now, no keys' shell when no
download rkey is available, so a caching caller can't misread 'unavailable'
as 'valid-but-expired'. Added an empty-list test. Annotated rename_group_file's
{ok:true} body as a deliberate NapCat-parity deviation from sibling file ops.
Reshape the download-rkey list (type 10=private, 20=group, same 0x9067
source) into NapCat's GetRkeyServer shape {private_rkey, group_rkey,
expired_time, name}, expired_time = now + min present ttl. get_rkey /
nc_get_rkey already existed (raw list) and are left unchanged.
Add the file-rename slot to the group-file OIDB envelope (req/resp field 5),
a RenameGroupFile service mirroring MoveGroupFile, a groupFile.rename() api
method, and the rename_group_file action (params group_id/file_id/
current_parent_directory/new_name, NapCat-aligned), replacing the stub.
Wire fields (busId=102, parentFolder=current dir, newFileName) verified
against NapCat's Oidb.0x6D6 transformer; subCommand 4 cross-checked against
the move op (sub 5 on both sides). Serialize + envelope round-trip test locks
the pb tags.
Second adversarial pass: the previous 'unsupported' wording over-corrected
— it mislabeled a genuinely-uncached image file_id as 'unsupported',
mirroring the original defect. A double cache miss is runtime-indistinguishable
between a group-file id and an evicted image/voice, so the message now states
the cache miss neutrally and offers get_group_file_url as guidance only. The
prior 'group-file id' test took the same code path as the cache-miss test
(a fake test); consolidated into one honest assertion.
Adversarial review of Wave 1: get_file's 'file not found in cache' was
misleading for group-file file_ids (unsupported here, not uncached).
Distinguish the two in the error message, surface the limitation in the
summary, and lock the contract with a negative test. Also annotate
get_group_shut_list's ~60s cache-delay tradeoff and mark _mark_all_as_read
as an explicit no-op pending an RE'd one-shot read cmd.
Resolve file_id against the image cache, then the record cache (both
already mint a fresh url + carry file_size/file_name), replacing the
not-yet-implemented stub. Document-type files have no id-resolvable
cache yet, so they are intentionally left uncovered rather than faked.
Derive the muted-member list from the TTL-cached group member list
(shutUpTime = absolute expiry epoch seconds), replacing the placeholder
that always returned []. NapCat-shaped output {user_id,nickname,shut_up_time}.
Settings → 通知 now mirrors the node-config UX: info-only channel cards
(name / id / url / template + an inline enable toggle), create + edit via a
dialog, and all changes debounced-auto-save (no save button). The save path
is generation-guarded so a superseded in-flight save can't clobber a newer
edit; the test action flushes the pending save first so it never hits an
unsaved channel. The channel id is locked while editing to keep per-account
channelIds references from orphaning.
Per-account opt-in: a globally-disabled channel's toggle is now locked +
forced off (it can never fire). The id is kept in channelIds — the backend
already filters disabled channels — so re-enabling globally restores the
prior selection.
New: notification-channel-dialog.tsx. webui typecheck + build green.
Adversarial review: 0 blockers / 0 should-fix (2 nits applied).
- API client: notifications surface (getConfig/saveConfig/recent/test) + types.
- Settings → 通知 tab: global channel CRUD (id/name/url/body-template/enabled) +
global debounce window, per-channel test-send, dirty-tracked save; invalid
channels (bad slug / non-http URL) are dropped server-side and surfaced.
- Per-account 通用设置: opt-in toggles bound to notifications.channelIds, riding
the ConfigPage's existing debounced autosave; stale opt-ins preserved.
- Overview: opt-in 最近投递 widget (polls /api/notifications/recent, read-only).
Hidden-by-default set is now DERIVED from the catalogue (defaultVisible) and
shared by desktop + mobile reconcile — replaces the hardcoded STATIC_WIDGET_IDS
so a new opt-in widget can't reappear unbidden on existing mobile dashboards.
Typecheck + build green. Adversarial review: 1 should-fix (mobile hidden-set) +
2 nits found, fixed/triaged, and re-verified clean.
Global singleton observing every account's online/offline edge:
- Pure per-UIN debounce state machine (debounce.ts): an offline surviving
debounceSeconds fires "offline"; recovery fires the paired "online"; a
self-heal within the window fires nothing; a cold online fires nothing.
- NotificationManager (manager.ts): renders each opted-in + enabled channel's
body template and POSTs it (single attempt + timeout, JSON), recording the
outcome in a bounded in-memory history (lost on restart). Side effects
(config/channelIds/post/clock) are injected for testability.
- BridgeManager: single-callback setters → additive listeners so OneBotManager
and NotificationManager observe independently; close edge now carries the
bridge (read nickname before dispose); fire-all with per-listener try/catch.
- Wired into the composition root, bound after OneBotManager.
Tests: debounce machine (pure, all misfire sequences) + manager (selectChannels,
dispatch, history cap, fake-timer self-heal/pairing). 23 green, typecheck clean.
Adversarial review: 0 blockers / 0 should-fix (2 NITs applied).
Global channel store at config/notifications.json, mirroring ui-config's
total-normalize + atomic-write + cached-load conventions: NotificationsConfig
(version, debounceSeconds clamp [0,3600] default 30, channels[]), a total
normalizeNotificationsConfig (drops malformed/non-http channels, dedupes by
id, strips unknown fields), and the pure renderTemplate ({key} substitution;
missing keys left as-is; no re-expansion of substituted values).
Per-UIN opt-in: OneBotConfig.notifications.channelIds (validated slugs,
last-write-wins merge across global+per-uin, deduped) in the onebot package.
Tests: 19 (core notifications-config) + 12 (onebot config), all green.
Adversarial review: 0 blockers / 0 should-fix.
The read-only push-body probe in Bridge has served its purpose; the KickNT
push body and its reason fields are captured for the upcoming notification
reason-enrichment. Bridge back to baseline.
Conclude the spike on the inbound
`trpc.qq_new_tech.status_svc.StatusService.KickNT` push and remove its
throwaway instrumentation:
- Bridge: drop the outbound send probe.
- HookSession: drop the loggedIn-gate bypass; restore `if (!this.loggedIn) return;`.
- HookManager: drop the disconnect-timing log.
Keep one read-only `[KICK-BODY]` probe in Bridge that logs the KickNT push
body (hex + utf8) so the reason fields (tipsTitle / tipsDesc) can be reversed
for the upcoming notification reason-enrichment. Remove once captured.
Reworks the desktop overview edit UX from per-card show/hide toggles to an
Apple-widgets model:
- The grid shows only the widgets that are on it; hidden ones live in a new
right-side 部件库 ("store") panel that slides in during edit mode.
- Add: drag a gallery tile onto the canvas (HTML5 DnD) — dropped at the cursor
cell, driven entirely through React state.
- Remove ("hide"): drag a card back onto the gallery (gridstack `removable`).
Move/resize/remove all funnel through one onChange writer that derives removal
from a block's absence in the grid snapshot — no separate handler, no state
race.
- Card affordance: the big top "notch" bar is gone. Edit mode now shows two
small square corner icons — a subtle semi-transparent drag hint (top-left, the
whole card stays draggable) and the settings gear (top-right, configurable
widgets only). The eye toggle is removed.
Mobile is unchanged (single-column reorder panel) — the gallery drag UX is
desktop-only by design.
- 导出当前视图: a toolbar button dumps the current (filtered) log view to a
client-side `.log` text file — no server endpoint, respects the active level
filter + search.
- 视图预设: 开发 / 运维 / 精简 presets bundle the existing display prefs
(visibleLevels / maxLines / autoScroll / wrap); a new `UiLogsPrefs.preset`
field stores the active id. Any hand edit to those prefs drops to 自定义.
The client owns the preset→prefs bundles; the server just stores + validates
the id (oneOf, defaults custom). No non-chronological reordering, per plan.
A session-sticky kiosk mode for showing the dashboard on a wall display:
- Entry: `?kiosk=1` URL param (stripped after read) or a top-bar button
(toggleable via topbarItems 'kiosk').
- Hides the sidebar + top bar (MainLayout) and any in-content edit entry marked
data-kiosk-hide (the overview 编辑布局 toolbar) via an html[data-kiosk] CSS rule.
- Exit: Esc key or a dim corner button.
Purely cosmetic — never touches auth and issues no token. A new KioskProvider
(sessionStorage-backed, mounted under LayoutProvider) owns the state.
Completes the B2 dashboard/components batch.
Three opt-in static widgets join the GRID_WIDGETS catalogue (hidden by default
— enabled from the layout editor), with content stored in block.config:
- 便签 (note): pre-wrap plain text, capped at 4000 chars (under the server's
4096-byte config cap). No Markdown.
- 链接卡 (link): label + http(s)-only url (javascript:/data: rejected) + an
icon from a curated lucide set; renders as a clickable card.
- 账号快捷卡 (account): a specified uin's avatar/nickname/online dot, with a
datalist of connected accounts in the config form.
GridWidgetSpec gains `defaultVisible`, honored by defaultOverviewGrid/Mobile and
migrateOverviewBlocks; reconcileLayoutItems gains a `hiddenByDefault` set so the
mobile catalogue appends these hidden too. parse* validators keep config total
over corrupt input.
Adds the gear config form to two more overview widgets (stat tiles stay
form-less, per plan):
- 主机资源 (host): toggle which resource panels show (CPU / 内存 / 运行进程);
the grid column count tracks the visible panel count, and an all-off config
falls back to all-on (no empty card).
- OneBot 连接 (connections): filter by account nickname/uin, an "仅显示异常端点"
toggle (drops healthy adapters and emptied accounts), and sort by 默认 /
名称 / 异常优先 (worst status first).
Both register in CONFIGURABLE_WIDGETS with parse* validators, render via the
existing dialog, and surface on mobile through the same per-widget config map.
The top-bar's optional right-side elements (connection-status badge, theme
toggle) are now toggleable via `topbarItems`. Essential controls — the
menu/collapse button, page title, and logout — always render and aren't listed.
- A TOPBAR_CATALOGUE (id+label) drives both the render gating and the settings
toggles; TopBar reconciles `topbarItems` against it so a new element defaults
to shown.
- A 顶栏 group in settings → 外观 exposes one switch per catalogue element.
Phones now render the overview from the dedicated `overviewMobile` ordering
instead of deriving a 1-column view from the desktop grid — the two layouts are
fully disjoint, so reordering on a phone never touches grid coords and vice
versa.
- View mode reuses DashboardGrid (drag disabled, cols=1), stacking each widget
at its catalogue height via a pure prefix-sum, so cards keep their cell
sizing. Per-widget config is shared with the desktop blocks.
- Edit mode surfaces a motion `Reorder` drag-sort panel (grip + show/hide eye +
config gear for configurable widgets) — no 2D drag on mobile, per plan.
- The 编辑布局 toggle now appears on mobile too, with a mobile-specific hint.
Order/visibility reconciles against the live widget catalogue, so a widget
added later just appears on phones as well.
Schema foundation for the B2 dashboard batch, mirroring the navItems shape:
- `overviewMobile: UiLayoutItem[]` — a separate single-column (id+visible)
ordering for phones, kept fully disjoint from the desktop 2D `overviewBlocks`
grid so mobile ordering never pollutes grid coords.
- `topbarItems: UiLayoutItem[]` — show/hide list for toggleable top-bar
elements (status badge, theme toggle, kiosk button); essential elements stay
pinned in the consumer.
Server `normalizeLayout` round-trips both (idOr + dedup, total over corrupt
input); defaults seed first run. `LayoutContext` exposes them with
setOverviewMobile/setTopbarItems setters and reconcile-on-consume semantics, so
adding a widget/element later just appears. Old configs lacking the fields fall
back to defaults on load.
Consumers (mobile render, topbar render + config, drag-sort panel) land in
follow-up B2 commits.
Keyboard-a11y polish to match the codebase's standard
`focus-visible:ring-[3px] focus-visible:ring-ring/40` treatment:
- ToggleSwitch (role=switch, used across every settings/config surface) had
no focus-visible ring — keyboard users got no focus indicator.
- Sheet's close button used a bare `focus:outline-none`; now mirrors the
Dialog close button's ring.
Slider, Button, Input, Select, Tabs, Checkbox, Switch already carry the ring.
- Custom-CSS editor stays a plain <textarea> (native Cmd/Ctrl+Z undo) but
gains insert-at-cursor template buttons (string-constant snippets) and a
best-effort on-blur validation that warns on unbalanced braces or CSS that
parses to zero rules. Never blocks saving; ?safe-mode=1 remains the escape.
- Accent picker: choosing a custom colour whose contrast against the canvas
falls below WCAG 3:1 surfaces a one-time (per-session) advisory offering to
revert. Pure-advisory — applies immediately, no persistent banner, no nag.
Adds two appearance customizations from the WebUI plan's B1 batch:
- Custom fonts: new `fontSansCustom`/`fontMonoCustom` free-form family
fields (mirroring accent's preset/custom dual-field). A "自定义" segment
reveals a text input; on Chromium it gets a native <datalist> of installed
fonts via `queryLocalFonts()`, feature-detected with a silent fallback to
a plain text box on Firefox/Safari/mobile. No font-file uploads.
- Theme-variable panel: new `cssVars` map lets the operator override
individual theme tokens (background/foreground/primary/…) with colour
pickers, layered last over palette+accent. Both keys (token whitelist) and
values (hex/named/functional colour) are validated, so — unlike customCss —
this stays safe to serve to the unauthenticated login page.
Server `normalizeAppearance` gains `fontFamilyOr` (rejects control
chars/injection) and `normalizeCssVars` (whitelist keys + colour-only values,
total over corrupt input). Client `ThemeContext` re-validates defensively
(the localStorage cache is locally tamperable) before injecting into CSS.
Tests for the new normalizers land with the B4 batch.
Upgrades the blank-body heuristic to NT's exact discriminator. RE of
wrapper.linux.node (msg_header_codec_helper.cc::DecodeRoutingHead, sub_3B42650)
shows the official client classifies a C2C push by (svr_msg_type, c2c_cmd):
msgType ∈ {141,166,167} with c2c_cmd ∈ {1,73,75,129,131,133,135,192} is routed
through OnRecvSysMsg (long_cnn_msg_mgr.cc) as a system/control signal and never
shown as a chat bubble — the group-invite "[空消息]" phantom is one of these.
- proto-defs: ContentHead field 3 was mislabelled `divSeq`; it is `c2c_cmd`.
Renamed (only other use was forward.ts, which zeroes it on a fake send).
- MsgPushHead now carries c2cCmd; new isC2cControlPush() in blank-filter.ts.
- parseMsgPush + both history fetches drop control pushes by (msgType, c2cCmd)
regardless of body, so a control signal carrying stray content is caught too
(not just the empty case). isBlankMessage stays as the fallback for
content-less pushes we don't yet classify by cmd. Live path debug-logs a
control push that carried elements, in case the table ever eats real content.
NOTE: the c2c_cmd set is taken from NT; we have not captured #24's actual cmd
(our diagnostic never logged field 3), so the blank fallback remains load-bearing
until a live capture confirms which cmd the invite phantom uses.
The #102 fix dropped content-less control pushes only in parseMsgPush (live).
History fetches (fetchC2cMessageRange / fetchGroupMessageRange) decoded straight
into the result, so the same phantom resurfaced as "[空消息]" on backfill. RE of
wrapper.linux.node confirms QQ NT filters blanks on BOTH paths — live/roam C2C
via c2c_roam_msg_mgr.cc::FilterBlankMsgAndRetryFetch and group roam via
group_roam_msg_worker.cc::FilterBlankSeqsMsg.
Extracts the blank test into blank-filter.ts (bodyHasDecodableContent +
isBlankMessage) and applies it in all three message-producing paths. A message
that decoded to 0 elements but whose body carried content is a missing decoder,
not a blank — isBlankMessage returns false there so it's kept (live path still
warns).