Skip to content

Commit 3a897bb

Browse files
committed
feat: refactor SessionPulseWidget to use client queries for hourly data and interruptions
refactor: remove focus detection from TodoWidget to simplify component logic feat: enhance WidgetWindow with improved focus handling and auto-blur functionality test: update FocusCoachWidget tests to reflect new API structure for focus session management test: extend PetWidget tests to cover new features including favorite messages and quiet mode test: improve SessionPulseWidget tests to align with updated data fetching methods test: add comprehensive tests for settingsStore to ensure persistence and default values fix: add ambient declaration for Node.js fs module to support test file reading test: introduce WidgetWindow tests to validate blur behavior on unfocus
1 parent 568aa2c commit 3a897bb

95 files changed

Lines changed: 2631 additions & 400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ All notable changes to TimeLens are documented here.
44
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
55
---
66

7-
## [2.3.0] - 2026-08-28
7+
## [2.3.0] - 2026-10-03
88

99
### Added
1010

1111
- **Skin Studio** — added separate local background images for the TimeLens app and widget windows, with live preview, clear/reset actions, `cover` / `contain` / `stretch` fit modes, configurable overlay strength, and per-widget skin overrides.
1212
- **Built-in skin palettes** — added Default, Ocean, Forest, Sunset, and Monochrome palettes that update surface, text, border, and accent colors across the app and widgets.
13+
- **Skin blur level** — app and widget backgrounds now have independent 0–100% blur sliders in Settings, applied live across all windows and included in skin diagnostics.
14+
- **Pet studio improvements** — the desktop pet gains a pack preview strip (idle/focus/rest states), favorite messages (star to save, tapped first), quiet mode (suppresses greeting rotation), scheduled appearance (active hours with overnight range support), and a compact display mode; all preferences persist per-widget through the Widget Gateway.
1315
- **Widget layout presets** — save, apply, replace, delete, import, and export named widget layouts; built-in Work, Focus, Break, Coding, and Review presets are created automatically.
1416
- **Backup-compatible layout settings** — layout presets are included in Backup & Restore packages and restored with the backup payload.
1517
- **Scheduled layout switching** — switch layouts automatically by local time or focus state without relying on a cloud service.
1618
- **Widget health center** — added heartbeat, memory, CPU time, consecutive failure, pause, suspension, last error, and recovery information for installed widgets.
1719
- **Official experience widgets** — added Skin Preview, Layout Switcher, Widget Health, and Focus Streak widgets.
1820
- **Widget diagnostics** — added redacted skin snapshot export, contrast checking, reduced-motion support, compact widget mode, and Widget Dev Harness diagnostics with capability simulation, hash inspection, logs, and auto-reload.
1921
- **Update flow tests** — added coverage for update checking, download confirmation, download progress, install confirmation, and unavailable updater states.
22+
- **Validation gate coverage** — added layout recovery tests (invalid bounds clamping, monitor-shrink recovery, corrupt preset merging), layout preset round-trip and profile isolation tests, skin persistence contract tests, and accessibility contract tests for motion, compact mode, and root-class theming.
2023
- **Scoped Local API credentials** — API credentials now have a nickname and independently configured data-access and operation permissions, with revocation and one-time secret reveal/copy behavior.
2124
- **Local API permission picker** — Settings now provides localized multi-select controls for the Local API's supported read, subscription, and write scopes.
2225
- **Animation & Motion Control Center** — Added user-selectable motion preset controls (`Full Animations`, `Reduced Motion`, `Disable All Animations`) in Settings.
@@ -28,7 +31,12 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
2831
- Chart & Data Animations
2932
- Pulse & Status Effects
3033
- **Multi-language Support (i18n)** — Added full translation strings for all animation modes and granular toggle items across English (`en`), Simplified Chinese (`zh-CN`), and Traditional Chinese (`zh-TW`).
31-
34+
- **Widget network consent gating** — widget `network_fetch` and `media_load` requests now require class-level consent (`network.general.http`/`https`, `media.image.remote.read`) before any outbound request, replacing the previous unauthenticated proxy behavior.
35+
- **Per-domain network consent** — the gateway now evaluates each network target against a built-in high-risk domain blocklist (auth, payment, file-hosting, sensitive-upload categories), per-widget domain allow/deny rules, and per-widget per-domain runtime consent (`network:domain:<host>`) with a structured `consent_required` denial so widgets prompt the user before the first request to a new domain.
36+
- **Remote video opt-in** — media responses with `video/` content type require a separate `media.video.remote.read` consent before the payload is returned, keeping remote video always explicit opt-in per the widget runtime policy.
37+
- **High-risk consent warnings** — the widget consent prompt now shows an amber warning block for high-risk scopes (detailed sessions, remote video, local API) and an info note for medium-risk scopes, with the risk level persisted alongside each grant/deny decision.
38+
- **Gateway query expansion** — widgets can now query `interruptions` (sliding-window interruption fragments), `hourly` (hourly usage distribution), and `health` (per-widget runtime health) through the Widget Gateway.
39+
- **Gateway focus session writes** — widgets can start and stop focus sessions through the new `focus_session_write` gateway capability (`settings:write` scope), with `focus-session-changed` events broadcast to subscribers after each transition.
3240

3341
### Changed
3442

@@ -50,6 +58,8 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5058
- **High-Contrast Segmented Controls & Tab Buttons** — Replaced low-contrast white-on-light selection states with high-contrast `bg-accent-blue/15 text-accent-blue border border-accent-blue/30` styling across Widget Center, Browser Usage, Dashboard Insights, Quick Capture, and Timer widgets.
5159
- **Unified Hover Micro-Interactions** — Standardized hover states across sidebars, search buttons, settings items, and tab options to use consistent soft blue tinting (`bg-accent-blue/10 text-accent-blue`).
5260
- **Collapsible Widget Center Layout** — Compacted top "Layout Presets" and "Widget Health Center" cards into collapsible sections (collapsed by default) to maximize space for the main widget list.
61+
- **Official widget permission alignment** — official widget capabilities now match their actual gateway usage (todo/quick-capture gain write access, browser-activity gains the new `read_browser` capability, focus-coach gains write access, focus-streak gains metric read); a new permission reconciliation pass runs at widget create, open, and app startup restore to self-heal missing permissions on existing widgets while never re-granting scopes the user explicitly revoked.
62+
- **Remaining widget gateway migration** — Session Pulse (interruptions/hourly), Focus Coach (focus session start/stop), Widget Health (runtime health), and Focus Streak (focus sessions) now go through the Widget Gateway instead of direct Tauri API calls.
5363

5464
### Fixed
5565

@@ -68,11 +78,13 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6878
- **Sidebar Hover CSS Specificity** — Removed CSS `!important` overrides that interfered with hover state specificity on navigation items.
6979
- **Settings Card Background Noise** — Removed dark container card background wrappers around motion controls, making animation options render seamlessly as standard SettingsRows.
7080
- **Removed Motion Bounce & Translate Y Shifts** — Eliminated unwanted button/card jump, scale, and translateY bouncing on click and setting toggle events.
81+
- **Broken official widgets** — fixed todo, quick-capture, and browser-activity widgets being denied by the gateway because their install-time permissions did not cover the scopes they actually use; restored widgets self-heal automatically on next open or app launch.
7182

7283
### Security
7384

7485
- **Managed local resources** — image imports enforce allowed extensions, file signatures, size limits, managed-directory boundaries, and traversal protection.
7586
- **Gateway request governance** — network, media, local API, and notification requests continue through permission checks, audit logging, timeouts, response limits, and normalized errors.
87+
- **Revocation termination** — resetting widget permissions now revokes all runtime consent decisions for that widget and emits a `widget-permission-revoked` event (`all: true`) so widgets immediately enter a degraded state; single-scope revocations are also written to the access audit log.
7688
- **Dependency audit** — `npm audit --audit-level=high` reports zero vulnerabilities for the v2.3.0 dependency tree.
7789

7890

‎docs/WIDGET_RUNTIME_REWRITE_IMPLEMENTATION_PLAN.md‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ Deliverables:
553553
- Migrated first-party widgets.
554554
- External widget beta path.
555555

556-
### Phase D: Media and Sensitive Access Hardening
556+
### Phase D: Media and Sensitive Access Hardening ✅ Completed
557557

558558
Deliverables:
559559

@@ -673,6 +673,7 @@ After this plan is reviewed, the next artifact should be a narrow RFC that freez
673673
- **Phase A — 契约与 Schema 冻结**:已完成。
674674
- **Phase B — Kernel 与 Gateway Core**:已完成。
675675
- **Phase C — JS/TS Runtime 迁移**:已完成(SDK、ExternalWidgetHost、运行时同意提示、全部适用 Gateway 的官方组件迁移、SDK 测试均已落地)。
676+
- **Phase D — 媒体与敏感访问加固**:已完成(网络/媒体类级同意、内置高风险域名封锁、按域名运行时同意、远程视频单独 opt-in、高风险同意警告 UI、撤权终止与审计)。
676677

677678
### 关键交付物
678679

@@ -699,44 +700,55 @@ After this plan is reviewed, the next artifact should be a narrow RFC that freez
699700
| SDK 测试 | `src/widgets/sdk/__tests__/WidgetClient.test.ts` | mock gateway 覆盖 query/state/subscribe/consent retry |
700701
| 官方组件全量测试 | `src/widgets/__tests__/*.test.tsx` | 覆盖 Clock/Todo/Note/Status/GoalProgress/SessionPulse/FocusCoach/Pet/QuickCapture/Timer/BrowserActivity |
701702
| 权限治理 UX | `src/pages/WidgetCenter/index.tsx` | 权限矩阵支持单个权限撤销,保留「撤销全部」入口 |
703+
| Phase D 网络防火墙 | `src-tauri/src/widget_gateway/policy_firewall.rs` | 内置高风险域名分类封锁(auth/payment/file-hosting/sensitive-upload)、域名规则匹配(精确/子域,deny 优先) |
704+
| Phase D 类级同意 | `src-tauri/src/widget_gateway/capability_resolver.rs` | `network_fetch` → `network.general.http/https`(按 URL scheme),`media_load` → `media.image.remote.read` |
705+
| Phase D 域名同意网关 | `src-tauri/src/widget_gateway/mod.rs` | `evaluate_network_target` 门控:封锁列表/拒绝规则硬拒绝 → 按域名同意(`network:domain:<host>`,consent_required)→ 放行;`DispatchFailure` 结构化拒绝路径;远程视频需 `media.video.remote.read` 二次 opt-in |
706+
| Phase D 撤权终止 | `src-tauri/src/commands/widget_runtime_cmd.rs`、`src-tauri/src/widget_kernel/mod.rs` | 重置权限后发 `widget-permission-revoked`(all: true);撤权写入审计;重置时撤销全部运行时同意决定 |
707+
| Phase D 同意 UX | `src/widgets/sdk/index.ts`、`src/widgets/ExternalWidgetHost.tsx`、`src/components/WidgetConsentPrompt.tsx` | SDK 透传 `error.scope`;风险分级(high/medium/low);高风险琥珀警告块 + 中风险提示;riskLevel 随 grant/deny 落库 |
708+
| Phase D i18n | `src/i18n/locales/*/widgets.json` | `consentPrompt.riskHigh` / `consentPrompt.riskMedium` 8 语言 |
709+
| Phase D 测试 | `src-tauri/src/widget_gateway/mod.rs`(9 个新 Rust 测试)、`WidgetClient.test.ts`(+2) | 覆盖 scope 映射、封锁分类、域名规则、类级/域名级同意拒绝、视频同意、错误 scope 透传 |
702710

703711
### 验证结果
704712

705713
- `npm run typecheck` ✅
706-
- `npm run lint` ✅(0 errors,8 pre-existing warnings)
707-
- `npm run test` ✅(56/56,含 11 个 WidgetClient 测试 + 34 个官方组件测试)
714+
- `npm run lint` ✅(0 errors)
715+
- `npm run test` ✅(74/74,含 21 个 WidgetClient 测试)
708716
- `cargo check` ✅
709-
- `cargo test` ✅(38/38)
717+
- `cargo test` ✅(59/59)
718+
- 环境备注:本机 Windows 更新后 comctl32 v5 缺失 `TaskDialogIndirect`,test 二进制需嵌入 Common Controls v6 manifest 才能启动(pre-existing 问题,与代码无关)。
710719

711720
### 当前限制
712721

713722
- Gateway 已实现 `network_fetch`、`media_load`、`local_api_call`、`notification_send` 的受限代理逻辑:公网 HTTP(S)、5 秒超时、2 MiB 响应上限、媒体 MIME 白名单、本地 API scope 校验和 Windows 原生通知。
714723
- 旧 widget 的 `widget_permissions` 被 Gateway 视为已授权,保证迁移期兼容。
715724
- `WidgetClient.fetch` 返回代理后的标准 `Response`,`loadMedia` 返回受限的 `data:` URL 引用。
716725
- `notification_send` 已通过 Tauri notification provider 支持 Windows、macOS 和 Linux,实际显示仍受操作系统通知权限和桌面环境影响。
717-
- TimerWidget、QuickCaptureWidget、BrowserActivityWidget 仍使用直接 `tauriApi` 调用,待 Gateway 暴露对应能力后再迁移;但其渲染与交互已纳入官方组件测试覆盖。
726+
- **官方组件权限对齐与 Gateway 能力补齐(2026-10-03)**:官方组件 capabilities 已按真实 Gateway 用量修正(todo/quick-capture 补 `write_data`、browser-activity 新增 `read_browser` capability → `browser:read`、focus-coach 补 `write_data`、focus-streak 补 `read_metrics`);新增 `ensure_official_widget_permissions` 权限 reconcile,在 create/open/启动恢复三个时机自动补齐缺失权限,并尊重用户显式撤销(审计最新动作为 revoke 的 scope 不再自动补发)。Gateway 新增 `interruptions`/`hourly`/`health` 查询命名空间与 `focus_session_write` 写能力(scope `settings:write`,start/stop 后广播 `focus-session-changed`);SessionPulse、FocusCoach、Widget Health、Focus Streak 组件已迁移至 Gateway(`client.query("interruptions"|"hourly"|"health")`、`client.startFocusSession/stopFocusSession`)。TimerWidget 为自包含实现(localStorage),无需 Gateway;PetWidget 的 pack 导入与 active-window 订阅仍为受控直接 API。
718727

719728
### 建议下一步
720729

721730
后续可选的 Runtime 强化工作:
722731

723732
1. 为非 Windows 平台补充统一的原生通知 provider。
724-
2. 为高风险详细数据访问增加更细粒度的二次确认和降级 UI。
725-
3. 处理撤权后的长连接主动终止与显式 revoked 事件。
733+
2. ~~为高风险详细数据访问增加更细粒度的二次确认和降级 UI。~~(Phase D 已落地:高风险琥珀警告 + 视频/域名二级同意)
734+
3. ~~处理撤权后的长连接主动终止与显式 revoked 事件。~~(Phase D 已落地:`widget-permission-revoked` 含 reset 全量事件;网络请求为短连接 5s 超时,天然无长连接残留)
726735
4. 评估是否将 `buildLegacyChannel` 标记为 deprecated,并更新 `WIDGET_SDK_v2_MIGRATION.md`。
736+
5. 在 Widget Center/设置中暴露用户自定义域名 denylist 管理界面(`widget_network_domain_rules` 表已支持 `policy_source: 'user'`,目前仅缺 UI 与写入命令)。
737+
6. 评估为 test 二进制嵌入 Common Controls v6 manifest,修复本机 `cargo test` 无法直接启动的问题。
727738

728739
---
729740

730741
## Agent 下一步计划(由当前 Kimi Code agent 制定)
731742

732743
- [x] Phase C 官方组件全量测试流程已落地。
733744
- [x] LLM 集成与 AI 洞察对话管理已落地:多模型配置、数据共享设置、分析范围选择、对话持久化(SQLite)、归档/置顶/删除、上下文 Summarize。
745+
- [x] Phase D 媒体与敏感访问加固已落地(2026-10-03):类级网络/媒体同意、内置高风险域名封锁、按域名运行时同意、远程视频单独 opt-in、高风险同意警告 UI、撤权终止事件与审计。
734746

735-
基于 Phase C 与 LLM 功能已完成,当前建议继续推进 v2.2.0 剩余需求:
747+
下一阶段建议(按优先级):
736748

737-
1. **桌宠重写**:改为纯宠物资源包模式,支持用户导入 JSON pack(参考 Codex 宠物)。
738-
2. **快速记录后待办/便签页面自动刷新**:保存后触发对应 widget 刷新事件。
739-
3. **错误日志筛选失效**:当前筛选输入不生效,所有行被隐藏。
740-
4. **自动更新弹窗与下载安装**:应用内检测更新、每次下载/安装需用户确认、支持关闭/仅提示。
749+
1. **Phase E — Java Runtime Beta**:JVM host、Java SDK、Java 包校验器、示例 widget(工程量大,需先确认优先级)。
750+
2. **域名防火墙设置 UI**:在 Widget Center 或设置中允许用户管理按域名拒绝/允许规则(后端表已就绪)。
751+
3. **PetWidget Gateway 化**:pet pack 导入、active-window 订阅、`getAllWidgets`/`getMonitorStatus` 仍走直接 API,可评估迁入 Gateway(新增 media/本机状态命名空间)。
752+
4. **v2.3.0 Widget Experience 收尾**:对照 ROADMAP v2.3.0 检查 Skin Studio、布局预设、Widget Health 的完成度。
741753

742-
如果用户继续输入「继续」,则默认从第 1 项开始:桌宠重写为可导入宠物包。
754+
如果用户继续输入「继续」,默认从第 2 项开始:域名防火墙设置 UI(范围小、用户可感知)。

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "timelens",
33
"private": true,
4-
"version": "2.3.0-alpha1",
4+
"version": "2.3.0",
55
"license": "MIT",
66
"authors": [
77
"Shan Wenxiao"

‎src-tauri/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "timelens"
3-
version = "2.3.0-alpha1"
3+
version = "2.3.0"
44
description = "A screen time tracker and desktop widget manager"
55
authors = ["Shan Wenxiao"]
66
license = "MIT"

0 commit comments

Comments
 (0)