From 54ef439226a5d9621e2ed419154f6b1556995298 Mon Sep 17 00:00:00 2001 From: MT-Mint <798521692@qq.com> Date: Thu, 23 Apr 2026 10:12:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(08):=20=E7=94=A8=E4=B8=BB=E9=A2=98=E8=89=B2?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E7=95=99=E5=AD=98=E7=9A=84=20white/black=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=A2=9C=E8=89=B2,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .planning/REQUIREMENTS.md | 15 +++++++++++-- .planning/ROADMAP.md | 13 +++++++++++ .planning/STATE.md | 15 +++++++------ frontend/scripts/color-guard.mjs | 18 +++++++++++++-- .../app/workspace/chats/[thread_id]/page.tsx | 10 ++++----- frontend/src/app/workspace/layout.tsx | 4 ++-- .../src/components/ai-elements/message.tsx | 2 +- .../components/ai-elements/prompt-input.tsx | 4 ++-- .../artifacts/artifact-file-detail.tsx | 22 +++++++++---------- .../components/workspace/dev-todo-list.tsx | 2 +- .../workspace/iframe-test-panel.tsx | 10 ++++----- .../workspace/messages/message-group.tsx | 2 +- .../workspace/messages/message-list.tsx | 2 +- .../settings/appearance-settings-page.tsx | 2 +- .../src/components/workspace/todo-list.tsx | 2 +- .../workspace/workspace-sidebar.tsx | 2 +- .../e2e/thinking-and-secret-leak.spec.ts | 2 +- 17 files changed, 83 insertions(+), 44 deletions(-) diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index 72552275..ab61a617 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -37,6 +37,13 @@ - [ ] **ATREF-03**: 引用文件复用 `additional_kwargs.files` 提交,含来源元信息;失效引用软剔除并不阻断消息发送 - [ ] **ATREF-04**: 引用能力具备自动化回归验证(单测 + E2E)及按 style/logic/tests/docs 的提交分组计划 +### Theme Tokenization and Color Guard (Phase 8) + +- [ ] **P8-01**: Workspace 核心页面与组件(thread page、input box、artifact detail/list、workspace layout/header)中的 `bg-[#...]`/`text-[#...]`/`stroke="#..."` 等硬编码颜色迁移为 light/dark 主题 token +- [ ] **P8-02**: 建立颜色 token 注册表并满足“每个 distinct 颜色值对应一个 distinct token 名称”的唯一性约束(禁止多个不同颜色值映射到同名 token) +- [ ] **P8-03**: 增加自动化扫描守卫,阻止新增 `#hex` 与 `bg-[#...]`/`text-[#...]`(含同类 arbitrary color)回归 +- [ ] **P8-04**: 覆盖 workspace 关键页面与组件的 light/dark 回归验证(静态扫描 + 自动化用例 + 可复现命令) + ## v2 Requirements ### Tooling Improvements @@ -73,10 +80,14 @@ | ATREF-02 | Phase 6 | Pending | | ATREF-03 | Phase 6 | Pending | | ATREF-04 | Phase 6 | Pending | +| P8-01 | Phase 8 | Pending | +| P8-02 | Phase 8 | Pending | +| P8-03 | Phase 8 | Pending | +| P8-04 | Phase 8 | Pending | **Coverage:** -- v1 requirements: 17 total -- Mapped to phases: 17 +- v1 requirements: 21 total +- Mapped to phases: 21 - Unmapped: 0 --- diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 872d7ab0..3b96f39a 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -78,6 +78,19 @@ Plans: - [x] 07-01-PLAN.md — 提交态增强文本组装 + 三入口统一透传 + 显示态/提交态分离回归 - [x] 07-02-PLAN.md — gap closure:修复 ContextMenu 自动引用、提示前缀唯一化、Skill 使用 id 拼接 +### Phase 8: 现在系统中有非常多写死的颜色值比如bg-[#00000],text-[#000000],我想把这些颜色值都提升到浅色模式和深色模式里面 + +**Goal:** 将 workspace 核心页面/组件中的硬编码颜色迁移为 light/dark 主题 token,并建立防回归扫描守卫。 +**Requirements**: P8-01, P8-02, P8-03, P8-04 +**Depends on:** Phase 7 +**Plans:** 4 plans + +Plans: +- [ ] 08-01-PLAN.md — 建立颜色 token 注册表与扫描守卫基础能力 +- [ ] 08-02-PLAN.md — 迁移 chat/input/workspace 关键页面组件的硬编码颜色 +- [ ] 08-03-PLAN.md — 迁移 artifact 关键组件的硬编码颜色与局部样式变量 +- [ ] 08-04-PLAN.md — 建立回归验证闭环并固化防回归检查 + --- *Milestone status:* `complete` *Next command:* `/gsd-new-milestone` diff --git a/.planning/STATE.md b/.planning/STATE.md index ffad3890..3b43bdb0 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,15 +2,15 @@ gsd_state_version: 1.0 milestone: v1.0 milestone_name: milestone -status: v1.0 milestone complete -last_updated: "2026-04-22T02:08:30.000Z" -last_activity: 2026-04-22 +status: Executing Phase 8 +last_updated: "2026-04-23T01:22:12.681Z" +last_activity: 2026-04-23 progress: total_phases: 8 completed_phases: 7 - total_plans: 13 + total_plans: 17 completed_plans: 16 - percent: 100 + percent: 94 --- # STATE.md @@ -20,7 +20,7 @@ progress: See: .planning/PROJECT.md (updated 2026-04-07) **Core value:** Keep the frontend visually familiar while preserving and hardening new-system behavior end to end. -**Current focus:** Milestone v1.0 completed +**Current focus:** Phase 8 — 现在系统中有非常多写死的颜色值比如bg-[#00000],text-[#000000],我想把这些颜色值都提升到浅色模式和深色模式里面 ## Workflow State @@ -46,6 +46,7 @@ See: .planning/PROJECT.md (updated 2026-04-07) - Phase 6 added: 在输入框输入@时,可引用已生成文件和已上传附件 - Phase 7 added: 发送时拼接附件与Skill优先提示词并在消息区过滤 +- Phase 8 added: 现在系统中有非常多写死的颜色值比如bg-[#00000],text-[#000000],我想把这些颜色值都提升到浅色模式和深色模式里面 ### Quick Tasks Completed @@ -55,4 +56,4 @@ See: .planning/PROJECT.md (updated 2026-04-07) | 260416-koe | 归档 Phase 06 明确指代(“这张图”)语义修复到 GSD 流程(已验收,通过人工确认,免验证) | 2026-04-16 | pending | [260416-koe-phase-06](./quick/260416-koe-phase-06/) | | 260422-e2i | 后端为会话历史消息增加时间戳字段(前端不显示) | 2026-04-22 | pending | [260422-e2i-message-timestamp](./quick/260422-e2i-message-timestamp/) | -Last activity: 2026-04-22 +Last activity: 2026-04-23 diff --git a/frontend/scripts/color-guard.mjs b/frontend/scripts/color-guard.mjs index 79b491c4..6fd5f276 100644 --- a/frontend/scripts/color-guard.mjs +++ b/frontend/scripts/color-guard.mjs @@ -13,6 +13,8 @@ const TOKENS_PATH = path.join(SRC_ROOT, "styles", "workspace-color-tokens.ts"); const HEX_RE = /#[0-9a-fA-F]{3,8}\b/g; const ARBITRARY_COLOR_RE = /\b(?:bg|text|border|ring|from|to|via|fill|stroke)-\[[^\]]+\]/g; +const NAMED_COLOR_RE = + /\b(?:bg|text|border|ring|from|to|via|fill|stroke)-(?:white|black)(?:\/\d+)?\b/g; const EXCLUDED_HEX_FILES = new Set([GLOBALS_PATH, TOKENS_PATH]); const MODE = process.argv.includes("--mode=guard") ? "guard" : "audit"; @@ -53,6 +55,7 @@ function scanFullSource() { const report = { hex: [], arbitrary: [], + named: [], }; for (const file of files) { @@ -74,6 +77,10 @@ function scanFullSource() { for (const finding of arbitraryFindings) { report.arbitrary.push({ file, ...finding }); } + const namedFindings = collectMatchesInContent(content, NAMED_COLOR_RE, () => true); + for (const finding of namedFindings) { + report.named.push({ file, ...finding }); + } } return report; @@ -151,6 +158,7 @@ function scanAddedViolations() { const report = { hex: [], arbitrary: [], + named: [], }; for (const [file, lines] of addedLines.entries()) { @@ -165,6 +173,10 @@ function scanAddedViolations() { for (const match of content.matchAll(ARBITRARY_COLOR_RE)) { report.arbitrary.push({ file, line, match: match[0] }); } + NAMED_COLOR_RE.lastIndex = 0; + for (const match of content.matchAll(NAMED_COLOR_RE)) { + report.named.push({ file, line, match: match[0] }); + } } } @@ -276,10 +288,10 @@ async function main() { console.log(`[color-guard] mode=${MODE}`); console.log( - `[summary] full-scan hex=${fullScan.hex.length} arbitrary=${fullScan.arbitrary.length}`, + `[summary] full-scan hex=${fullScan.hex.length} arbitrary=${fullScan.arbitrary.length} named=${fullScan.named.length}`, ); console.log( - `[summary] added-violations hex=${addedViolations.hex.length} arbitrary=${addedViolations.arbitrary.length}`, + `[summary] added-violations hex=${addedViolations.hex.length} arbitrary=${addedViolations.arbitrary.length} named=${addedViolations.named.length}`, ); console.log( `[summary] ws-vars root=${globalsValidation.rootCount} dark=${globalsValidation.darkCount} inline=${globalsValidation.inlineCount}`, @@ -287,6 +299,7 @@ async function main() { printFindings("[added] hex violations", addedViolations.hex); printFindings("[added] arbitrary color violations", addedViolations.arbitrary); + printFindings("[added] named color violations", addedViolations.named); const semanticErrors = [...tokenValidation.errors, ...globalsValidation.errors]; if (semanticErrors.length > 0) { @@ -299,6 +312,7 @@ async function main() { const hasViolations = addedViolations.hex.length > 0 || addedViolations.arbitrary.length > 0 || + addedViolations.named.length > 0 || semanticErrors.length > 0; if (MODE === "guard" && hasViolations) { diff --git a/frontend/src/app/workspace/chats/[thread_id]/page.tsx b/frontend/src/app/workspace/chats/[thread_id]/page.tsx index 9ec2e452..1c2d7e5e 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/page.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/page.tsx @@ -400,7 +400,7 @@ export default function ChatPage() {
{/* 取消TodoList */} {/*