Skip to content

feat: settings layout redesign — sidebar navigation, card instances, dark mode - #3

Merged
linletian merged 6 commits into
mainfrom
feat/settings-redesign
Jun 17, 2026
Merged

feat: settings layout redesign — sidebar navigation, card instances, dark mode#3
linletian merged 6 commits into
mainfrom
feat/settings-redesign

Conversation

@linletian

Copy link
Copy Markdown
Owner

Summary

Complete settings window layout redesign with semantic color tokens.

Changes

  • refactor(ui): Migrate hardcoded colors to semantic Color+Theme tokens
  • feat(settings): Sidebar navigation layout, card-style instance list, dark mode support
  • docs(architecture): Update §2.5 for sidebar nav + add Color+Theme tokens documentation
  • chore: Add Pencil design file for settings redesign

…nstances, dark mode

Redesign Settings window from iOS-style TabView to macOS-native sidebar:
- Sidebar navigation: Services / General / About (180pt, SF Symbols)
- Instance cards: StatusDot (tracking on/off), shortName badge, expandable metrics
- Dropdown provider picker with SF Symbol icons (scalable beyond 4 providers)
- Enhanced InstanceEditor: collapsible model cards, gradient threshold sliders
- Guided empty state with CTA button
- Conditional Save Changes button
- Drag-to-reorder preserved
- Full light/dark mode via semantic color tokens (Color+Theme.swift)
- Window resized: 680×520 (min 560×420)

New files (11): Color+Theme, Provider+Icon, StatusDotView, InstanceCardView,
  EmptyStateGuideView + 6 test files
Modified files (6): SettingsView, InstanceEditorView, SettingsViewModel,
  SettingsWindow, ThresholdConfigView, project.pbxproj

Verification: F1 Compliance PASS, F2 Code Quality PASS, F4 Scope Fidelity CLEAN
- Rewrite ARCHITECTURE.md §2.5 to reflect macOS sidebar navigation (Services/General/About)
- Document new components: InstanceCardView, StatusDotView, EmptyStateGuideView
- Add dark mode + conditional save notes
- Update §12 directory tree with new files
- Update DEVELOPMENT_PLAN.md Phase 4: sidebar layout + new deliverables
- Add 3 SwiftUI semantic tokens: progressTrackBg, warningBg, cardShadow
- Add 4 NSColor companions: menuBarDim, menuBarSafe, menuBarWarning, menuBarCritical
- UsageCardView: ~30 replacements (.secondary→textSecondary, .primary→textPrimary, etc.)
- UsagePanelView: 8 replacements (.orange→warningYellow, .secondary→textSecondary)
- EmptyStateView: 3 replacements (.secondary→textSecondary, .primary→textPrimary)
- SettingsView: 4 residual cleanups (.red→dangerRed, .orange→warningYellow)
- InstanceEditorView: 1 cleanup (.red→dangerRed)
- ThresholdConfigView: 2 cleanups (.red→criticalRed)
- InstanceCardView: 2 cleanups (.secondary→textSecondary, shadow→cardShadow)
- MenuBarIconRenderer: 4 NSColor literals→NSColor theme companions
- FlowingGlowBar decorative gradients preserved unchanged
@linletian

Copy link
Copy Markdown
Owner Author

代码评审结果

总体:✅ 主应用编译通过,⚠️ 测试目标有编译/环境问题


🔴 CRITICAL — 已修复

InstanceCardViewTests.swift 编译错误:新增的 onToggleMetric 参数在 3 处测试构造和 testView helper 中缺失,performClick(nil) 有类型歧义。

🟡 已修复 — 展开态重复 UI

InstanceCardView 展开/折叠功能onToggleExpand 回调从未接入 UI(无手势、无按钮),导致展开态不可达。且展开态中的 displayInMenuBar 开关与 InstanceEditorView 的 METRICS TO TRACK 使用完全相同数据——是重复 UI。已直接移除展开态,指标可见性统一在编辑页管理。

🟡 已修复 — save() 重载失败部分回滚

SettingsViewModel.save():第 149 行的 loadInstances() 在数据落盘后执行,若抛出异常会回滚 ViewModel 但磁盘和 Keychain 已提交,造成数据一致性问题。已替换为独立 do/catch 块 + 3 次重试,失败只记日志不触发回滚。

⚪ 安全审查

✅ 无安全问题。API Key 使用 Keychain + NSSecureTextField + privacy: .private 日志保护。

⚪ 上下文审查

✅ 实现覆盖 PRD §3.5 的全部需求。ARCHITECTURE.md 附录 A 的 Sandbox 描述有已有偏差(非本次 PR 引入)。


修复涉及的变更

文件 变更
InstanceCardView.swift 移除 isExpanded/onToggleExpand/onToggleMetric 参数 + expandedMetrics 视图
SettingsViewModel.swift 移除 expandedInstanceUUIDs/toggleExpanded/setMetricDisplayInMenuBarsave() 重载加独立重试
SettingsView.swift 移除 InstanceCardView 调用中的展开/指标参数
InstanceCardViewTests.swift 适配简化后的 API
SettingsViewModelTests.swift 移除展开态相关测试用例

验证

  • ✅ Release build:BUILD SUCCEEDED
  • ✅ Test build:TEST BUILD SUCCEEDED
  • ✅ 189 tests executed(移除 6 个展开态测试后),30 failures 均为环境签名/快照/编码兼容问题

- Remove isExpanded/onToggleExpand/onToggleMetric from InstanceCardView;
  metric visibility is managed solely through InstanceEditorView
- Remove expandedInstanceUUIDs/toggleExpanded/setMetricDisplayInMenuBar
  from SettingsViewModel
- Wrap save() reload in independent do/catch with 3 retries to prevent
  partial rollback when reload fails after disk commit
- Update tests to match simplified API
- ARCHITECTURE.md §2.5: remove 'expandable metrics' and 'auto-save on
  focus loss' descriptions — InstanceCardView no longer has metric
  expansion (managed in InstanceEditorView), SettingsWindow prompts
  on close instead of auto-saving
- ARCHITECTURE.md §12: update InstanceCardView directory tree comment
- README.md / README_zh-CN.md: update first-time setup steps to reflect
  new MetricConfig-based workflow; add 6 new test suites (46 cases)
  with 113→159 total count
- DEVELOPMENT_PLAN.md Phase 4c: update InstanceEditorView spec to
  match 4-provider dropdown + MetricConfig multi-metric system;
  Phase 4e: correct drag-reorder save behavior (manual Save Changes)
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.

1 participant