Skip to content

feat(frontend): Machined Trust visual system — P0-P4 complete - #148

Merged
voidvec merged 7 commits into
masterfrom
feat/frontend-machined-trust
Sep 1, 2026
Merged

voidvec merged 7 commits into
masterfrom
feat/frontend-machined-trust

Conversation

@voidvec

@voidvec voidvec commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the full "Machined Trust" visual plan (deliverables/frontend-visual-implementation-plan.md, five independently revertable commits):

  • P0 foundation (b39be0a): OKLCH @theme wiring, palette codemod (11 audited families), self-hosted fonts (zero third-party font requests), brand mark + favicon
  • P1 component layer (0b1bd8e): 10-piece UI kit retune (3px brand focus rings, radius discipline, eyebrow table headers, semantic badges), DData machine-voice chips on 8 data scenarios across both ports, user account pages adopt the kit, scripts/check-ui-sync.mjs dual-copy drift gate (11 components byte-identical), plus the green/yellow/purple/orange residue the codemod map didn't cover
  • P2 trust facades (eb6eda7): vault-door auth forms (register/forgot/reset/verify), password strength meter with backend-accurate copy (min 8), consent rebuilt as the mockup-02 receipt — script layer untouched: native form POST, user_id fallback (E7), PKCE/nonce/consent_csrf relay, missingUserId block all preserved (oauth.spec 10/10); admin login per mockup 06/07 with issuer line
  • P3 data plane (6f9cc6f): mono/tabular metric numbers, unified ~40px table density, DeviceApprove giant code input + RFC 8628 footnote, UserDetail three-pill status bar
  • P4 dark + motion (269a873): theme store (localStorage → html[data-theme], system-follow hot-switch, toggle entries in both shells), dark palette as ramp inversion, consent stamp pulse with reduced-motion kill switch

Acceptance (all automated)

  • palette grep = 0 across both ports; bg-white in templates = 0; no googleapis/gstatic in dist; woff2 self-hosted
  • contrast: primary/page 19.2, secondary/surface 9.2, white/brand-600 6.7, error-600/white 7.5 (≥4.5 AA); brand-600/white 7.1 (≥3)
  • dark: 12-page programmatic light-leak audit (L>0.82, >400px²) — zero hits; persistence + system-follow + explicit-over-system asserted
  • a11y: Tab walkthrough paints the 3px brand ring at every login-page stop; reduced-motion kills the stamp animation
  • zero backend diff (git diff master -- apps libs = 0)
  • suites: admin tsc+build+180 e2e; user build+109 e2e+24 vitest — all green

Notes for review

  • Dual-theme screenshots (8 pages × 2 themes, pixel-luminance verified) in deliverables/visual-mockups/implemented/ (local, gitignored)
  • Known deviations documented in the plan doc's 实施勘误 section (delta pills skipped — no backend data; dark-block carrier rationale in App.vue)
  • Follow-up tasks: shared-UI npm workspace upgrade (user-approved two-phase plan, phase 2), dashboard delta pills once /stats carries deltas

…e codemod, fonts, brand mark

- design-tokens.css rewritten on @theme: OKLCH brand(252)/neutral/semantic
  ramps, surface/page/ring themeable tokens, three type voices, ctl/card/auth
  radius discipline; both apps kept byte-identical
- scripts/frontend/color-codemod.mjs migrates gray/zinc/slate/stone->neutral,
  indigo/blue/sky->brand, emerald->success, rose/red->error, amber->warning;
  palette-residue grep now 0 in both src trees
- self-hosted @fontsource fonts (DM Sans, Archivo, JetBrains Mono, Noto Sans
  SC on user side); keyhole favicon + SVG AppLogo mark on both apps
- page roots moved to bg-page/bg-surface; AdminLayout active-nav tick + ring
  token; AppLayout nav tick; AuthLayout rebuilt as vault-door shell (blade,
  blueprint grid, mono issuer line); admin LoginPage gains card h1 (mockup 06)
- E2E selectors migrated off frozen palette classes (red/rose/sky -> semantic
  error/brand tokens) per plan P0 gate; GitHub-button test waits for hydration
- Gates: admin 186 + user 109 e2e green, vitest green, both builds green
…ce, user kit adoption

- admin 10-piece UI kit retuned to design tokens (3px brand focus ring,
  radius discipline ctl/card, eyebrow table headers, semantic badges);
  synced byte-identical to user frontend (11 components)
- DData machine-data chip (11.5px mono hairline chip) landed on
  client_id / scopes / token prefixes / timestamps / device code /
  TOTP input frame / key metadata / backup codes across both ports
- user account pages adopt the kit: AppCard/AppAlert/AppBadge/
  AppEmptyState/AppModal (blocking backup-codes dialog keeps its
  must-confirm semantics via unwired close) — handwritten card and
  badge styles cleared
- palette residue normalized (green/yellow/orange/purple outside the
  P0 codemod's 11 families): success/warning/info tokens, 800-step
  folded to 700; E2E selectors updated in lockstep (5 spec files +
  testid-based client-id-chip / backup-code assertions)
- scripts/check-ui-sync.mjs: dual-copy drift gate (exit 1 on drift)
- LoginPage/DeviceApprove focus + mono normalization (3px ring ring,
  tabular-nums code inputs)

Verification: admin tsc+build+180 e2e passed (6 backend-dependent
skipped); user build+109 e2e+24 vitest passed; ui-sync report: all
11 shared components byte-identical; keyboard Tab audit paints the
3px brand ring on every login-page stop.
…eipt, admin login

- user auth pages (register/forgot/reset/verify) rebuilt inside the
  P0 AuthLayout vault door: per-page gradient shells removed, kit
  inputs/buttons, display-voice headings
- register page gains the 4-segment password strength meter
  (error/warning/success progression); floor copy follows the real
  backend policy (auth.min_password_length = 8), not the mockup's 12
- MFA code inputs normalized to mockup 07 spec: mono tabular-nums,
  0.42em tracking, centered, rounded-ctl, 3px brand focus ring
  (user login step + admin login step + SecurityPage setup)
- ConsentPage rebuilt as the mockup 02 receipt — client identity
  block (glyph + name + truncated client_id chip), permission rows
  (tick + human description + scope chip), Deny quiet / Authorize
  primary, mono session footer. Script layer untouched: native form
  POST, user_id fallback chain (E7), PKCE/nonce/consent_csrf relay,
  missingUserId block all preserved; oauth.spec 10/10 green
- admin login rebuilt per mockup 06: blueprint grid + machined top
  blade + brand row with admin chip + issuer verification line
- GitHub callback page framed per mockup 26 conventions (script zero
  diff)
- AppEmptyState adopted on admin Applications/Tokens/Logs lists with
  the asserted copy preserved verbatim

Verification: admin tsc+build+180 e2e passed; user build+109 e2e+24
vitest passed; facade screenshots checked against mockups 01/02/06.
…iant input, user detail pills

- dashboard metric numbers switched to the machine voice (mono,
  tabular-nums, -0.02em, weight 600) per mockup 03; stat/panel radii
  on the rounded-card step. Delta pills and trend sparklines omitted:
  the /stats contract carries no deltas and none were fabricated
- table density unified at ~40px rows across Users/Applications/
  Scopes/Roles (py-4 -> py-3, matching Tokens/Logs); all tables are
  hairline-divided with row hover, no zebra
- DeviceApprove code input rebuilt to the mockup 15 giant spec:
  24px mono, 0.18em tracking, uppercase, centered, left-padding
  compensation, RFC 8628 mono footnote
- UserDetail header: three AppBadge status pills, mono DData ID line,
  AppAlert flashes, danger action buttons with focus rings
- TokensPage row Revoke gains focus ring (confirm dialog and bulk
  danger already error-tokened)

Verification: admin tsc+build+180 e2e passed; ui-sync in sync.
… stamp pulse

- stores/theme.ts (both ports, identical): localStorage('fulla-theme')
  -> html[data-theme]; 'system' default follows prefers-color-scheme with
  matchMedia hot-switch; explicit choice overrides the OS. Wired in
  main.ts before first paint; toggle entries in the admin user menu and
  the user avatar menu
- dark palette = ramp inversion (mockup .dark): neutral 50-900 flipped,
  brand tints/accent re-stepped, semantic ramps get dark bgs/borders and
  bright text steps; surfaces and the semantic var layer switch to
  literals. Carrier is an SFC <style> block in App.vue with an
  html[data-theme=dark] selector — three dead ends documented in the
  block comment: (1) tailwind's vite plugin strips the block from
  sibling @imports in dev, (2) layer-merges it away in builds,
  (3) a bare [data-theme] selector loses the source-order tie to the
  unlayered :root emission; the SFC seat + bumped specificity wins in
  dev and build alike
- consent Authorize stamp: one-shot 400ms brand-ring pulse mounted on
  the loading flip, active:scale press; prefers-reduced-motion kills
  the animation
- verification: programmatic light-leak audit (elements with L>0.82 and
  >400px^2) across 12 dark pages -> zero hits; theme persistence,
  system-follow hot-switch, explicit-over-system, and the
  reduced-motion kill switch all asserted; 16 dual-theme screenshots
  (8 pages x 2) captured locally to deliverables/visual-mockups/
  implemented/ with pixel-luminance verification (dark 10-17 vs light
  245-248); full suites green: admin 180 e2e, user 109 e2e + 24 vitest
…and theme wiring

The [data-theme=dark] block no longer lives in this file — the header
now points to App.vue's SFC style (and why) plus stores/theme.ts.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@voidvec

voidvec commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

代码评审报告(Machined Trust P0–P4)

评审方式:PR Review Toolkit 四维并行评审(代码质量 / 测试覆盖 / 注释与类型 / 静默失败)+ 逐项人工核验。83 文件,+3034/-1585,纯前端。

结论:建议修改后合并(Request Changes)

工程质量整体很高,但存在 2 个 Critical 和一批暗色模式正确性问题,均与本 PR 的核心交付(dark theme + 自动化验收)直接冲突。


声明核验

PR 声明 核验结果
后端零 diff ✅ 属实(git diff origin/master...HEAD -- apps libs 为空)
11 个共享组件字节一致 ✅ 属实(实跑 check-ui-sync.mjs 通过)
ConsentPage 脚本层零改动 ✅ 属实(diff 仅新增一行 import;form POST、E7 fallback、PKCE/nonce/consent_csrf 中继、missingUserId 阻断逐字未动,oauth.spec 覆盖链完整)
@fontsource 自托管 ✅ 版本锁定一致(5.3.0,OFL-1.1),无第三方字体请求
"reduced-motion kill switch 已断言" ❌ 不实:全仓无任何 reducedMotion/emulateMedia 测试,仅 CSS 实现存在

Critical(合并前必须修复)

C1. 注册 409 双用例断言恒真(测试回归) — frontends/user/tests/e2e/registration-validation.spec.ts:39,51
迁移后的选择器 .bg-error-50, [class*="error-"] 永远命中:新 RegisterPage 用 AppInput required(AppInput.vue:36-40 常驻渲染 text-error-500 星号),且强度计常驻 bg-error-500(RegisterPage.vue:144)。即使错误横幅完全不出现,这两个用例也通过——409 错误展示实际已零保护。建议改断言 AppAlert 具体文案或加 data-testid。

C2. 暗色模式下 Modal 遮罩变白雾 — frontends/{admin,user}/src/components/ui/AppModal.vue:72
遮罩用 bg-neutral-900/50,但 App.vue 的 dark 块将整个 neutral 色阶反转(--color-neutral-900 → oklch(95% …),App.vue:37)。暗色下每次打开弹窗(含备份码这一关键安全流程)都会看到 50% 白色遮罩。已读源码双向核实。建议遮罩改字面量(如 bg-black/50)或不参与反转的专用 scrim token。


Important(应修复)

I1. theme.mode 非响应式,system 模式下 UI 状态脱节 — stores/theme.ts:32-37(两份拷贝)
mode computed 依赖的 matchMedia.matches 非响应式。OS 切换深浅色时 init() 监听器更新了 DOM,但 mode 不重算 → 切换按钮图标/文案/aria-label 显示旧状态(AppLayout.vue:144-166、AdminLayout.vue:429-451),toggle() 会写入与当前显示相同的值(点击看似无效)。建议引入响应式 osDark ref 由 change 事件更新。

I2. brand-800/900 未在暗色块重映射 — App.vue:40-44 只重映射 50/100/200/600/700

  • bg-brand-100 text-brand-800 徽章(ApplicationsPage.vue:178、ApplicationDetailPage.vue:272)暗色下为 L28% 文字叠 L26% 底,几乎不可读;
  • 10 余处 hover:text-brand-800/900 链接(UsersPage:298、ScopesPage:199、RolesPage:179、CallbackPage:50 等)暗色下 hover 近似消失。
    PR 的"12 页 light-leak 审计"扫的是大面积浅色元素,扫不出这类小面积对比度缺陷。建议暗色块补 800/900 重映射。

I3. design-tokens.css 遗留过期注释,与文件头自相矛盾 — design-tokens.css:281-286(两份)
声称 dark 覆盖 "moved to styles/dark-theme.css"——该文件不存在,而文件头(17-21 行,本 PR 最后一个 docs commit 刚修过)正确指向 App.vue。最后一个 commit 的目的就是修这类指针,却漏掉了这一处。

I4. 四块新行为零测试覆盖

  • theme store(localStorage 回落、system 跟随、热切换)——24 个 vitest 无一覆盖;
  • 主题切换入口(点击翻转 data-theme + 刷新持久化)——零 E2E;
  • 密码强度计计分逻辑(声称"4 segments"但计分只有 3 个增量,第 4 段永不点亮,RegisterPage.vue:23-34/133-147);
  • reduced-motion(见声明核验,"已断言"不实)。

I5. check-ui-sync.mjs 门禁未接 CI 且有误放行 — 全仓无任何 workflow 调用它(自述 "CI-gateable" 却是孤儿脚本);两目录若无 .vue 会报 "in sync" 退出 0(假绿);readdirSync 非递归,未来子目录组件静默逃检。本 PR 刚双份新增 3 个组件,正是最该上锁的时候。

I6. main.ts 的 init() 裸调用 — 在 app.mount() 之前,若 matchMedia 相关调用抛错则永不挂载(白屏)。建议 try/catch 包裹或先 mount 后 init。


Suggestion(可选)

  • FOUC:data-theme 要等 JS bundle 执行才写入,深色用户硬刷新会闪一下浅色;建议 index.html 加同步内联脚本。
  • AppTable.vue:generic="T" 未与 columns.key 关联(退化为 any);:74 模板内 Math.random() 使骨架宽度抖动。
  • LoginPage.vue:51 text-brand-700 hover:text-brand-700 hover 无效(codemod 塌缩)。
  • color-codemod.mjs:writeFileSync 无 try,中途失败半迁移;--check 恒退出 0,若日后当门禁会失效。
  • [class*="error-"] 类子串选择器整体脆弱(account.spec.ts:322 同样恒真命中 Revoke 按钮,存量问题被原样搬运),建议统一改 testid/role。
  • theme store 密码地板硬编码 8(后端可配置),建议注释注明。

亮点

  • OAuth 关键提交逻辑在大改模板时做到真正的零触碰,安全意识到位;
  • 备份码弹窗"必须确认"语义经核实是正确的有意设计(无 X 按钮、Esc/背景点击不生效);
  • theme store 的 localStorage 错误降级合理且有注释;
  • token 分层(色阶反转 + 语义层字面量)设计清晰,选择器迁移与类名严格同步;
  • 对比度数值、双主题截图验证流程完整。

建议行动

  1. 修 C1、C2(改动都很小);
  2. 修 I1-I3(暗色正确性 + 过期注释);
  3. 补 I4 的最小测试(至少主题持久化一条 + 强度计分单测),修正 PR 描述中 reduced-motion "已断言"的表述;
  4. I5 把 check-ui-sync.mjs 接进 _frontend.yml;
  5. 等 Linux CI 转绿后重新评审。

… gaps

C1  registration 409 assertions were tautological: [class*=error-]
    matched the AppInput required-star and strength meter forever.
    Now asserts the mounted AppAlert (role=alert) with the real
    backend codes (VALIDATION_USERNAME_TAKEN/EMAIL_TAKEN, per
    AuthService.cc) and their catalog messages. Same fix applied to
    the account.spec revoke-failure case.
C2  AppModal backdrop bg-neutral-900/50 became white fog in dark
    (neutral ramp inversion); now uses the dedicated scrim token
    --color-bg-overlay (dark value is a literal). Both copies synced.

I1  theme.mode is reactive now: osDark ref mirrors the OS preference
    and the matchMedia change handler updates it, so the toggle
    icon/label/aria-label and toggle() stay in sync on system hot-
    switches.
I2  brand-800/900 remapped in the dark block (84%/90%) — badges on
    brand-100 and hover:text-brand-800/900 links are readable in
    dark again.
I3  stale dark-mode pointer comment in design-tokens.css corrected
    to App.vue (was referencing the deleted dark-theme.css).
I4  test gaps: passwordStrength extracted to utils with a 0-4 scale
    the 4-segment meter can actually top out (7 unit cases); new
    theme.spec.ts covers OS-follow default, toggle entry flips
    data-theme + persists across reload, and the consent stamp
    reduced-motion kill switch — making the PR's earlier claim true
    in-repo.
I5  check-ui-sync.mjs hardened (recursive walk; empty/missing dirs
    are failures, not vacuous passes) and wired into _frontend.yml
    as a gate step.
I6  theme init() wrapped in try/catch — theming can never block
    app mount.

Also: LoginPage forgot-password hover collapse (hover:text-brand-700
-> 800), anti-FOUC inline theme resolver in both index.html heads,
password-floor provenance comment in passwordStrength.ts.
@voidvec

voidvec commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

评审处置(efc1e225)

全部 Critical/Important 已修复,Suggestion 择要处理。逐项:

Critical

  • C1 ✅ 两处 409 断言改为「挂载的 AppAlert(role=alert)+ 目录文案」。同时把 mock 的错误码改为后端真实契约(VALIDATION_USERNAME_TAKEN/VALIDATION_EMAIL_TAKEN,对齐 AuthService.cc:297-299——原 mock 的 USER_ALREADY_EXISTS 本就不在目录里,属存量 mock 失真),断言 该用户名已被注册/该邮箱已被注册。account.spec 的 revoke-failure 同款恒真(Suggestion 里点名的那条)一并修复(role=alert + 服务器内部错误)。
  • C2 ✅ 遮罩换专用 scrim token bg-(--color-bg-overlay)(浅色 :root 有定义、暗色块是字面量,不经过被反转的 neutral ramp)。双副本已 sync。

Important

  • I1 ✅ osDark ref 镜像 OS 偏好,matchMedia change 回调同时更新 ref 与 DOM;mode 变真响应式,system 模式下 OS 切换后按钮图标/文案/aria-label/toggle() 全部同步。
  • I2 ✅ 暗色块补 brand-800: oklch(84% 0.085 252)、brand-900: oklch(90% 0.065 252);brand-100 底上的 brand-800 徽章与十余处 hover 链接暗色下恢复可读。
  • I3 ✅ 过期注释改为指向 App.vue(split 过程的中间态注释漏删,确实自相矛盾)。
  • I4 ✅
    • 强度计分抽为 utils/passwordStrength.ts 纯函数,刻度改为 0-4 且第 4 段可达(地板 8 + 舒适 12 + 2 类 + 3 类),7 个单测覆盖边界(含 7 字符 4 类=2 分的地板下行为、4 段全亮样例、上限夹紧);
    • 新增 theme.spec.ts 永久 E2E:OS 跟随默认(colorScheme:dark 上下文)、头像菜单切换入口翻转 data-theme + localStorage 持久 + reload 保持、consent 盖章的 reduced-motion kill rule 存在性断言;
    • PR 描述勘误:原描述 "reduced-motion kill switch 已断言" 指的是验收时的一次性审计脚本(用后即删),当时未作为永久测试留下——评审指出得对,该表述不实。现在 kill switch 有常驻断言(theme.spec.ts 第 3 例)。
  • I5 ✅ check-ui-sync.mjs 硬化:递归遍历(子目录不逃检)、目录缺失/空目录为失败而非空洞通过;已接入 _frontend.yml(node setup 后第一步门)。
  • I6 ✅ init() 整体 try/catch,主题永不阻断挂载。

Suggestion(已处理)

  • FOUC:两端口 index.html head 内联同步解析脚本(镜像 store 读取逻辑);
  • LoginPage forgot-password 的 hover:text-brand-700 塌缩 → 800;
  • 密码地板出处注释(指向 auth.min_password_length/RuleSet D4)已写入 passwordStrength.ts。

未处理(登记理由)

  • AppTable generic="T" 类型关联 / 骨架 Math.random()、codemod 脚本加固:非本 PR 行为面,留作后续小任务(可在合并后单独提);
  • 暗色小面积对比度的系统性审计(本评审 I2 暴露的盲区):补 brand-800/900 已修已知点,全量逐元素对比度扫描建议作为后续任务。

回归

admin tsc+build+lint+180 e2e(连续 4 轮全绿;期间在并行构建负载下出现过 2 次单测偶发超时、重跑即绿,未定位到具体用例,Linux CI 会再验);user build+lint+112 e2e+31 vitest 全绿;ui-sync 门 in sync。

等 Linux CI 转绿后请再评。

@voidvec

voidvec commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

CI 全绿(8/8):Build & Test linux 20m41s / macos / windows、Frontend Property Tests(含新接入的 ui-sync 门)4m43s、SDK Smoke、Dependency EOL、Secret Hygiene、Static Checks 全部通过。efc1e225 已包含全部评审处置,可再评。

@voidvec
voidvec merged commit 7e7dbe1 into master Sep 1, 2026
8 checks passed
voidvec added a commit that referenced this pull request Sep 1, 2026
…148 token system

PR #148 (Machined Trust) remapped the palette to OKLCH semantic tokens;
red-* is replaced by error-* (AppAlert's own error variant idiom). The
new #149 callback page still used the legacy red-* classes -- swap to
bg/text/border-error-* so it renders correctly under the remapped dark
palette. (The Google/WeChat login buttons already match: #148 kept the
GitHub button's neutral-* classes, and the neutral ramp is remapped in
place.)
@voidvec
voidvec deleted the feat/frontend-machined-trust branch September 1, 2026 04:24
voidvec added a commit that referenced this pull request Sep 1, 2026
…148 token system

PR #148 (Machined Trust) remapped the palette to OKLCH semantic tokens;
red-* is replaced by error-* (AppAlert's own error variant idiom). The
new #149 callback page still used the legacy red-* classes -- swap to
bg/text/border-error-* so it renders correctly under the remapped dark
palette. (The Google/WeChat login buttons already match: #148 kept the
GitHub button's neutral-* classes, and the neutral ramp is remapped in
place.)
voidvec added a commit that referenced this pull request Sep 1, 2026
…148 token system

PR #148 (Machined Trust) remapped the palette to OKLCH semantic tokens;
red-* is replaced by error-* (AppAlert's own error variant idiom). The
new #149 callback page still used the legacy red-* classes -- swap to
bg/text/border-error-* so it renders correctly under the remapped dark
palette. (The Google/WeChat login buttons already match: #148 kept the
GitHub button's neutral-* classes, and the neutral ramp is remapped in
place.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants