test(css): restore renderer style contracts and governance - #264
test(css): restore renderer style contracts and governance#264somewan820 wants to merge 2 commits into
Conversation
|
@somewan820 @WAWQAQ 看完了,方向很好但 base 太旧、会回归我今天合的 selector 状态契约,建议先 rebase 再 review/merge。 大方向同意
关键 blocker:base 太旧导致 selector 状态回归这个 PR 的 base 是 1.
|
|
收到,感谢详细的 review。会先 rebase 到 origin/main,重点修 [data-active] → |
- point contract tests at the real renderer CSS graph - keep styles.css entry-only and audit !important usage - split renderer CSS into surface files with guarded layering - add dead CSS checks and frontend CSS governance guidance
ed0b70d to
ffaf3f9
Compare
|
@jackwener 已经修改好了🥺非常抱歉,下次一定注意~ |
…anup contract PR #264's scope is CSS governance — moving styles.css → styles/*.css split, adding contract tests, and a dead-CSS script. The settings-roadmap-cleanup contract pins the Daily Review fallback copy ("当前版本仅本地数字聚合,定时生 成 / LLM 摘要尚未连接到后端。") which an unrelated edit had rewritten to "…仍以本地汇总为主;…", breaking the existing pin. Revert the copy to match the pinned vocabulary so the contract stays green without expanding this PR's footprint into copy edits.
|
@somewan820 rebase looks great — base is now on
But running the full contract test suite turned up 2 more issues I think need fixing before merge: 1.
|
|
Superseded by #269 (rebase + 2 fixup commits for motion-token + roadmap-cleanup contracts). Same intent, all 431 contract tests green there. Thank you for the big CSS-split work @somewan820 — credit preserved in #269's commits ffaf3f9 + 8154f4e. |
…anded CSS Follow-up to QuinnWan's styles.css split (PR #264). `readAllRendererCss()` now expands `@import` chains, so the styles blob includes maka-tokens.css — including the legitimate `--ease-out-strong: cubic-bezier(0.16, 1, 0.3, 1);` token declaration. The bare-curve assertion was tripping on the token file's own definition. Strip TOKEN_DECL from the merged styles blob (mirroring the same strip the test already does for the tokens-file branch) so only NON-declaration spellings count as violations. Verifies green: apps/desktop$ npx tsx --test src/main/__tests__/motion-token-converge-contract.test.ts
…anup contract PR #264's scope is CSS governance — moving styles.css → styles/*.css split, adding contract tests, and a dead-CSS script. The settings-roadmap-cleanup contract pins the Daily Review fallback copy ("当前版本仅本地数字聚合,定时生 成 / LLM 摘要尚未连接到后端。") which an unrelated edit had rewritten to "…仍以本地汇总为主;…", breaking the existing pin. Revert the copy to match the pinned vocabulary so the contract stays green without expanding this PR's footprint into copy edits.
* test(css): restore renderer style contracts and governance - point contract tests at the real renderer CSS graph - keep styles.css entry-only and audit !important usage - split renderer CSS into surface files with guarded layering - add dead CSS checks and frontend CSS governance guidance * test(css): align contracts with latest settings primitives * test(motion): strip --ease-out-strong declaration before scanning expanded CSS Follow-up to QuinnWan's styles.css split (PR #264). `readAllRendererCss()` now expands `@import` chains, so the styles blob includes maka-tokens.css — including the legitimate `--ease-out-strong: cubic-bezier(0.16, 1, 0.3, 1);` token declaration. The bare-curve assertion was tripping on the token file's own definition. Strip TOKEN_DECL from the merged styles blob (mirroring the same strip the test already does for the tokens-file branch) so only NON-declaration spellings count as violations. Verifies green: apps/desktop$ npx tsx --test src/main/__tests__/motion-token-converge-contract.test.ts * fix(daily-review): revert unrelated copy edit that breaks roadmap-cleanup contract PR #264's scope is CSS governance — moving styles.css → styles/*.css split, adding contract tests, and a dead-CSS script. The settings-roadmap-cleanup contract pins the Daily Review fallback copy ("当前版本仅本地数字聚合,定时生 成 / LLM 摘要尚未连接到后端。") which an unrelated edit had rewritten to "…仍以本地汇总为主;…", breaking the existing pin. Revert the copy to match the pinned vocabulary so the contract stays green without expanding this PR's footprint into copy edits. --------- Co-authored-by: QuinnWan <144975606+somewan820@users.noreply.github.com>
背景
这是一版保守的 CSS 治理提交,目标是先把 renderer CSS 的真实结构、契约测试和治理护栏重新对齐,避免
styles.css路径漂移、入口文件失真,以及 Tailwind v4 layer/cascade 回归。本次提交参考了:
主要改动
1. 恢复 contract tests 对真实 renderer CSS 的覆盖
css-test-helpers.ts/contract-css-helpers.tsapps/desktop/src/renderer/styles.css改为读取真实 renderer CSS 聚合内容
styles/**/*.css拆分后,测试仍然覆盖真实规则位置,而不是扫一个已经失真的入口文件2. 将
styles.css收敛为真正的 entry fileapps/desktop/src/renderer/styles.css现在只保留:@import@source@theme inlinestyles/子文件renderer-styles-entry-contract.test.ts,锁定 entry-only 约束3. 拆分 renderer CSS,并保留对 Tailwind utility 覆盖的安全策略
apps/desktop/src/renderer/styles/多个按 surface 拆分的子文件@layer componentsrenderer-style-layer-cascade-contract.test.ts.maka-nav-row.settingsHealthRefresh.settingsPermissionRefresh.settingsBotList button等需要压过 Tailwind utility 的选择器
4. 补充 CSS 治理护栏
renderer-important-audit-contract.test.tsscripts/check-dead-css.mjsscripts/check-dead-css-baseline.json5. 文档化前端 CSS 规范
docs/frontend-css-governance.md为什么这样做
这次没有继续激进推进“全部 layer 化”,而是优先做了更安全的治理动作:
styles.css回到入口文件职责!important、dead CSS、entry-only、cascade 风险固定下来这样后续如果继续推进 Round G / Round H,可以在更可信的安全网下逐步演进,而不是在失真的测试覆盖上改结构。
验证
已验证:
npm run build:mainnode scripts/check-dead-css.mjs --check关键 contract tests 已通过:
renderer-important-audit-contractrenderer-style-layer-cascade-contractrenderer-styles-entry-contractproject-context-badgebot-settings-ui-contractlocal-memory-ui-contract风险说明
主要风险仍然集中在 Tailwind v4 的 cascade 顺序:
base -> components -> utilities@layer components,都会静默失效