Commit Graph
1068 Commits
Author SHA1 Message Date
DrSmoothl c637329884 fix(webui): a11y for debug page controls (match project standard)
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.
2026-06-18 15:48:21 +08:00
DrSmoothl f153781208 feat(webui): promote debug to a standalone page, Apple-style redesign
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.
2026-06-18 15:44:05 +08:00
DrSmoothl 3655f10a43 test(webui): extract + test debug SSE backpressure framing
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.
2026-06-18 15:31:50 +08:00
DrSmoothl fae2f75525 feat(webui): debug panel — action tester + live stream (Wave A3)
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.
2026-06-18 15:25:34 +08:00
DrSmoothl 39864f6e48 feat(webui): debug API — action schemas, invoke, live SSE (Wave A3)
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.
2026-06-18 15:20:06 +08:00
DrSmoothl cde5a22ec8 feat(onebot): debug subscribe seams for NetworkManager + ApiHandler
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.
2026-06-18 15:17:28 +08:00
DrSmoothl d2e8222886 fix(webui): A2 backup — per-uin onebot config, no-store, atomic restore
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.
2026-06-18 15:08:51 +08:00
DrSmoothl 0c20d58a8c feat(webui): backup/restore UI in system settings (Wave A2)
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.
2026-06-18 15:01:17 +08:00
DrSmoothl c0e3bd0cff feat(webui): backup export/import API (Wave A2)
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.
2026-06-18 14:57:46 +08:00
DrSmoothl b71aedaa60 feat(webui): config backup/restore core (Wave A2)
Pure, tested backup module: buildBackup (allowlist → JSON bundle, credential
files gated), validateBackup (version/app/known-filename/no-traversal/entry
shape — rejects wholesale), applyBackup (snapshot-then-write, skips
credentials unless opted in). Credentials = webui.json + key.pem; cert.pem is
public and always travels. fs glue lands next in server.ts.
2026-06-18 14:56:12 +08:00
DrSmoothl a38b33c8aa feat(webui): Select/Textarea UI components + hide installed TLS cert
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.
2026-06-18 14:53:43 +08:00
DrSmoothl 675261691f fix(webui): make key.pem chmod best-effort (match auth.ts)
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.
2026-06-18 14:45:09 +08:00
DrSmoothl a4b226f1d0 fix(webui): write key.pem with 0600 (was world-readable)
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.
2026-06-18 14:43:27 +08:00
DrSmoothl 82d5f782a3 feat(webui): system settings panel (port/host/TLS/trust-proxy)
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).
2026-06-18 14:39:35 +08:00
DrSmoothl 7faef1b7c0 feat(webui): system settings + TLS cert API (Wave A1)
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.
2026-06-18 14:32:24 +08:00
DrSmoothl 9a455b30c6 feat(common): updateRuntimeConfig(patch) for the WebUI settings panel
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).
2026-06-18 14:28:31 +08:00
DrSmoothl ad21e19dc8 feat(webui): source trustProxy from runtime config (env still overrides)
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.
2026-06-18 14:26:32 +08:00
DrSmoothl 64c10e2856 feat(webui): HTTPS serving + configurable bind host
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.
2026-06-18 14:24:51 +08:00
DrSmoothl 77b16faebb feat(common): extend RuntimeConfig for WebUI listener settings
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).
2026-06-18 14:19:45 +08:00
DrSmoothl 90d3f7c0d6 test(protocol): real byte-oracle for ocr_image request wire
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).
2026-06-18 00:40:26 +08:00
DrSmoothl e07090376a feat(onebot): implement ocr_image via OIDB 0xE07_0
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.
2026-06-18 00:36:07 +08:00
DrSmoothl f936515a59 fix(onebot): get_rkey_server fails on empty rkey set; document rename return
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.
2026-06-18 00:26:34 +08:00
DrSmoothl 7625c18768 feat(onebot): add get_rkey_server (NapCat server-shape rkey)
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.
2026-06-18 00:21:35 +08:00
DrSmoothl 07988629f1 feat(onebot): implement rename_group_file (OIDB 0x6D6_4)
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.
2026-06-18 00:19:00 +08:00
DrSmoothl 0ba5eba31c fix(onebot): neutral get_file cache-miss message, drop fake test
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.
2026-06-18 00:08:44 +08:00
DrSmoothl dbb5160be7 fix(onebot): clarify get_file limitation + honest _mark_all_as_read summary
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.
2026-06-18 00:05:20 +08:00
DrSmoothl 84e5254c3a feat(onebot): implement get_file via media cache resolution
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.
2026-06-17 23:58:00 +08:00
DrSmoothl 8144dd9c27 feat(onebot): implement get_group_shut_list via member shutUpTime
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}.
2026-06-17 23:57:12 +08:00
DrSmoothl 16920b4444 chore(release): v1.9.12 2026-06-16 21:59:31 +08:00
DrSmoothl f014defd54 feat(notifications): node-config-style channel manager + lock disabled-channel opt-in
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).
2026-06-16 21:54:19 +08:00
DrSmoothl 0b7fb0c69d feat(notifications): P4 WebUI — channel manager, per-account opt-in, deliveries widget
- 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.
2026-06-16 19:53:31 +08:00
DrSmoothl c0af18e1c2 feat(notifications): P3 HTTP face — channel config CRUD + recent + test-send
Bearer-gated WebUI routes:
- GET/POST /api/notifications/config — read/normalize the global channel store
  (whole-config CRUD, mirroring the ui-config pattern).
- GET /api/notifications/recent?limit=N — in-memory delivery history (≤100).
- POST /api/notifications/test {channelId} — one-off test to a single channel
  (ignores enabled/opt-in, sample vars, reuses render+POST, not recorded).

NotificationManager.testSend() added; initWebUI takes the manager (optional).
Tests: testSend unit coverage. 16 manager tests green, typecheck clean.
Adversarial review: 0 blockers / 0 should-fix / 0 nits.
2026-06-16 19:30:54 +08:00
DrSmoothl 30bcd97a3f feat(notifications): P2 manager — debounce state machine + render/POST + history
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).
2026-06-16 19:20:55 +08:00
DrSmoothl 34d05f41f5 feat(notifications): P1 config layer — global channel store + per-UIN opt-in
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.
2026-06-16 19:02:01 +08:00
DrSmoothl bf5978fb51 chore(spike): remove KickNT body-capture probe — capture complete
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.
2026-06-16 18:37:22 +08:00
DrSmoothl 652a817568 chore(spike): retire KickNT force-offline probes, keep read-only body capture
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.
2026-06-16 18:17:46 +08:00
DrSmoothl fb567177b4 feat(webui): Apple-widgets dashboard editor — gallery drag in/out
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.
2026-06-16 14:57:39 +08:00
DrSmoothl 2913a7a19b test(webui): regression tests for ui-config normalizers (B4)
First test coverage for the WebUI config trust boundary + the B1–B3 schema
additions (22 cases in packages/core/tests):

- normalizeAppearance totality (garbage → defaults, clamps, bad enums); custom
  fonts accept free-form families but reject control chars/injection/over-length;
  cssVars keep only whitelisted tokens with break-out-proof colour values.
- normalizeLayout: overviewMobile/topbarItems order-preserving + de-duped +
  fallback; overviewBlocks coord clamping; per-widget config 4096-byte cap.
- normalizePages: logs preset oneOf (unknown → custom).
- sniffImageMime magic bytes; normalizeUiConfig never derives image fields from
  the value.
- fs-backed (isolated temp cwd + fresh module): saveUiConfig forces the
  server-managed image fields (client can't forge hasImage); publicAppearance
  strips customCss but keeps cssVars + other cosmetic fields.
2026-06-16 14:38:57 +08:00
DrSmoothl 7355fe9ea4 feat(webui): log buffer export + view presets (B3)
- 导出当前视图: 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.
2026-06-16 14:36:02 +08:00
DrSmoothl 1a0bc12ec0 feat(webui): kiosk (展示模式) for chrome-free wall displays (B2)
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.
2026-06-16 14:32:57 +08:00
DrSmoothl 72e0d6bcca feat(webui): static note / link / account widgets (B2)
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.
2026-06-16 14:28:56 +08:00
DrSmoothl 60d1f0b04f feat(webui): config forms for host + connections widgets (B2)
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.
2026-06-16 14:24:21 +08:00
DrSmoothl 23048894b5 feat(webui): top-bar element show/hide (B2)
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.
2026-06-16 14:20:23 +08:00
DrSmoothl 754621de04 feat(webui): independent single-column mobile overview (B2)
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.
2026-06-16 14:18:40 +08:00
DrSmoothl 45d651614b feat(webui): layout schema for mobile overview + topbar items (B2)
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.
2026-06-16 14:14:03 +08:00
DrSmoothl 6d4e8538ea fix(ui): add focus-visible ring to ToggleSwitch and Sheet close (B1)
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.
2026-06-16 14:10:04 +08:00
DrSmoothl 636189d7c9 feat(webui): CSS snippet templates + low-contrast accent advisory (B1)
- 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.
2026-06-16 14:08:09 +08:00
DrSmoothl 5b07f518cc feat(webui): custom fonts + theme-variable override panel (B1)
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.
2026-06-16 14:04:59 +08:00
DrSmoothl e0d5b47488 feat(msg-push): filter C2C control pushes by c2c_cmd, matching QQ NT (#102)
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.
2026-06-16 01:34:38 +08:00
DrSmoothl 2ffb6192dd fix(msg-push): drop blank "[空消息]" pushes in c2c/group history too (#102)
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).
2026-06-16 01:24:31 +08:00