Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

Merge branch 'main' into fix/scheduled-legacy-maintenance-review

vastsa31e747ed620e
diff --cc crates/host-core/src/rpc/scheduled_tools.rs
index 44b97c853,320330d3c..3fb868516
--- a/crates/host-core/src/rpc/scheduled_tools.rs
+++ b/crates/host-core/src/rpc/scheduled_tools.rs
@@@ -531,4 -568,4 +581,92 @@@ mod tests
Some(PermissionDecision::AllowOnce)
));
}
++
++ #[tokio::test]
++ async fn review_legacy_task_can_be_paused_without_arming_it() {
++ let dir = tempfile::tempdir().unwrap();
++ let mut st = AppState::open(dir.path()).unwrap();
++ st.handshook = true;
++ st.db
++ .set_setting("app", &json!({"defaultPermissionMode":"auto"}))
++ .unwrap();
++ scheduled::import_tasks(
++ &st.db,
++ &[json!({"id":"legacy", "prompt":"Review", "cadence":"daily"})],
++ )
++ .unwrap();
++ let session =
++ sessions::create_session(&st.db, None, Some("agent".into()), None, None, None).unwrap();
++ let state = Arc::new(Mutex::new(st));
++ let listed = call(&state, &session.id, "ScheduledTaskList", json!({})).await;
++ assert_eq!(listed["content"]["tasks"][0]["id"], "legacy");
++ let paused = call(
++ &state,
++ &session.id,
++ "ScheduledTaskUpdate",
++ json!({"id":"legacy","enabled":false}),
++ )
++ .await;
++ assert_eq!(
++ paused["ok"], true,
++ "Pausing must not require an automatic schedule: {paused}"
++ );
++ assert_eq!(paused["content"]["task"]["enabled"], false);
++ assert!(paused["content"]["task"].get("nextRunAt").is_none());
++ }
++
++ #[tokio::test]
++ async fn legacy_maintenance_preserves_data_but_does_not_silently_enable() {
++ for cadence in ["hourly", "daily", "weekly"] {
++ for enabled in [false, true] {
++ let dir = tempfile::tempdir().unwrap();
++ let mut st = AppState::open(dir.path()).unwrap();
++ st.handshook = true;
++ st.db
++ .set_setting("app", &json!({"defaultPermissionMode":"auto"}))
++ .unwrap();
++ scheduled::import_tasks(&st.db,&[json!({"id":"old","title":"Old","prompt":"Review","cadence":cadence,"enabled":enabled})]).unwrap();
++ let sid =
++ sessions::create_session(&st.db, None, Some("agent".into()), None, None, None)
++ .unwrap()
++ .id;
++ let state = Arc::new(Mutex::new(st));
++ for args in [
++ json!({"id":"old","title":"Renamed"}),
++ json!({"id":"old","prompt":"Updated"}),
++ json!({"id":"old","enabled":false}),
++ json!({"id":"old","cadence":cadence,"enabled":false}),
++ ] {
++ let result = call(&state, &sid, "ScheduledTaskUpdate", args).await;
++ assert_eq!(result["ok"], true, "{result}");
++ assert!(result["content"]["task"].get("schedule").is_none());
++ assert!(result["content"]["task"].get("nextRunAt").is_none());
++ }
++ let refused = call(
++ &state,
++ &sid,
++ "ScheduledTaskUpdate",
++ json!({"id":"old","enabled":true}),
++ )
++ .await;
++ assert_eq!(refused["errorCode"], "INVALID_PARAMS");
++ drop(state);
++ let mut st = AppState::open(dir.path()).unwrap();
++ st.handshook = true;
++ let saved = scheduled::get_task(&st.db, "old").unwrap().unwrap();
++ assert_eq!(saved.title, "Renamed");
++ assert_eq!(saved.prompt, "Updated");
++ assert!(!saved.enabled);
++ assert!(saved.schedule.is_none());
++ assert!(!saved.workspace_bound);
++ let state = Arc::new(Mutex::new(st));
++ let configured=call(&state,&sid,"ScheduledTaskUpdate",json!({"id":"old","cadence":cadence,"schedule":{"hour":9,"minute":30,"weekday":0},"enabled":true})).await;
++ assert_eq!(configured["ok"], true, "{configured}");
++ assert_eq!(
++ call(&state, &sid, "ScheduledTaskDelete", json!({"id":"old"})).await["ok"],
++ true
++ );
++ }
++ }
++ }
}
diff --cc docs/spec/03-runtime/06-host-rpc-protocol.md
index 83a72e7e2,aaa78ef0b..e720b9ce1
--- a/docs/spec/03-runtime/06-host-rpc-protocol.md
+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md
@@@ -1212,6 -1212,9 +1212,12 @@@ a schedule. Update takes an existing I
unspecified configuration. Exact local times remain supported despite the
UI's four period presets. No new DB schema or transport is introduced.
+### Scheduled tasks: legacy task maintenance
+
+Agent tools allow title, prompt and pause updates on legacy automatic tasks without a schedule, including an echoed unchanged cadence. These edits do not arm the task or capture the foreground workspace. Explicit enabling, a cadence change or a supplied schedule still follows schedule validation. Resume requires an explicit valid schedule; Manual-to-Hourly retains its existing default interval behavior.
+ ### Scheduled tasks: calendar intent
+
+ The optional config_json.calendarConfigured boolean distinguishes an explicitly configured Daily/Weekly calendar from Hourly's internal schedule placeholder. Without the key, legacy Daily/Weekly schedules are treated as configured; legacy Hourly schedules retain their values but require an explicit schedule when converting to Daily/Weekly. Known calendar intent survives Hourly and restart, including midnight. Clearing or replacing the calendar with a different non-calendar placeholder clears intent. This additive extension needs no table/schema migration; older versions ignore it and cannot enforce the new conversion guard. Metadata-only edits and Manual-to-Hourly remain unchanged.
+ ### Scheduled tasks: workspace identity
+
+ Stored workspace bindings use the existing project canonicalization contract on both write and read. On Windows, slash direction, case, trailing separators and extended path prefixes do not hide a task from its own project's conversation. The distinction between missing legacy bindings and explicit null remains unchanged. Foreign-project tools cannot list or mutate bound tasks.
diff --cc docs/spec/06-delivery/04-e2e-test-plan.md
index f43aa38bd,5404d2b37..d1e68e379
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@@ -14403,8 -14454,13 +14454,18 @@@ the latest destination. These assertion
cover ownership, deletion, repeated/bounded forks, retained checkpoint paths,
expired inputs, rollback, and symlink rejection.
+### E2E-SCHEDULED-legacy-pause
+
+- **Scenario:** Legacy task maintenance.
+- **Expected:** Agent tools allow title, prompt and pause updates on legacy automatic tasks without a schedule, including an echoed unchanged cadence. These edits do not arm the task or capture the foreground workspace. Explicit enabling, a cadence change or a supplied schedule still follows schedule validation. Resume requires an explicit valid schedule; Manual-to-Hourly retains its existing default interval behavior.
+- **Automation:** `node --experimental-strip-types scripts/e2e-scheduled-legacy-maintenance.mjs` uses an isolated real Host and SQLite profile. Inference is not sent to a live provider.
+ ### E2E-SCHEDULED-calendar-intent
+
+ - **Scenario:** Calendar intent.
+ - **Expected:** The optional config_json.calendarConfigured boolean distinguishes an explicitly configured Daily/Weekly calendar from Hourly's internal schedule placeholder. Without the key, legacy Daily/Weekly schedules are treated as configured; legacy Hourly schedules retain their values but require an explicit schedule when converting to Daily/Weekly. Known calendar intent survives Hourly and restart, including midnight. Clearing or replacing the calendar with a different non-calendar placeholder clears intent. This additive extension needs no table/schema migration; older versions ignore it and cannot enforce the new conversion guard. Metadata-only edits and Manual-to-Hourly remain unchanged.
+ - **Automation:** `node --experimental-strip-types scripts/e2e-scheduled-calendar-intent.mjs` uses an isolated real Host and SQLite profile. Inference is not sent to a live provider.
+ ### E2E-SCHEDULED-paths
+
+ - **Scenario:** Workspace identity.
+ - **Expected:** Stored workspace bindings use the existing project canonicalization contract on both write and read. On Windows, slash direction, case, trailing separators and extended path prefixes do not hide a task from its own project's conversation. The distinction between missing legacy bindings and explicit null remains unchanged. Foreign-project tools cannot list or mutate bound tasks.
+ - **Automation:** `node --experimental-strip-types scripts/e2e-scheduled-paths.mjs` uses an isolated real Host and SQLite profile. Inference is not sent to a live provider.
diff --cc docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md
index f2d8aa1a8,ec18f0291..c597beb5f
--- a/docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md
+++ b/docs/zh-CN/spec/03-runtime/06-host-rpc-protocol.md
@@@ -987,9 -987,16 +987,22 @@@ Host 重新检查会话的持久化模�
每天/每周自动任务需 schedule。修改使用已存在的 ID 并保留未指定字段。界面虽只提供四个
时段,工具仍支持具体本地时间。不新增数据库 schema 或传输协议。
+### 定时任务:旧任务维护
+
+Agent 工具允许对缺少 schedule 的旧版自动任务修改标题、提示词或暂停,也允许回传
+未变化的 cadence。这些维护操作不会启用任务,也不会捕获前台工作区。显式启用、
+改变 cadence 或提供 schedule 时仍执行 schedule 校验;恢复任务需要明确的合法
+schedule,Manual 转 Hourly 继续使用现有默认间隔行为。
+ ### 定时任务:日历配置意图
+
+ 可选的 `config_json.calendarConfigured` 布尔值用于区分用户明确设置的每日/每周
+ 日历时间与 Hourly 的内部占位 schedule。缺少该字段时,旧版 Daily/Weekly
+ 任务视为已设置日历;旧版 Hourly 保留现有值,但转换为 Daily/Weekly 时必须明确
+ 提供 schedule。已确认的日历配置在切换为 Hourly 和重启后仍会保留,包括午夜。
+ 清空日历或改为不同的非日历占位值会清除该意图。该扩展不修改表结构;旧版本会
+ 忽略该字段,无法执行新的转换保护。仅修改元数据以及 Manual 转 Hourly 的行为不变。
+ ### 定时任务:工作区身份
+
+ 保存和读取工作区绑定时统一使用现有项目路径规范化规则。在 Windows 上,
+ 斜杠方向、大小写、末尾分隔符和扩展路径前缀的差异不会再让同项目会话看不到任务。
+ 缺失的旧版绑定与显式 null 仍保持不同语义;其他项目的工具不能查询或修改绑定任务。
diff --cc docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 3fc67d357,31f663264..edca7967d
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@@ -8564,11 -8595,19 +8595,26 @@@ the latest destination. These assertion
- **验收 / 里程碑**:C、Quality / M6+。
- **状态**:组件与状态层用户路径由 `queue-pending-actions.test.mjs` 覆盖。
+### E2E-SCHEDULED-legacy-pause
+
+- **场景**:旧任务维护。
+- **预期**:Agent 工具可对缺少 schedule 的旧版自动任务修改标题、提示词或暂停,
+ 包括回传未变化的 cadence;维护不会启用任务或捕获前台工作区。显式启用、改变
+ cadence 或提供 schedule 时仍执行校验,Manual 转 Hourly 的默认间隔行为不变。
+- **自动化**:`node --experimental-strip-types scripts/e2e-scheduled-legacy-maintenance.mjs`
+ ### E2E-SCHEDULED-calendar-intent
+
+ - **场景**:日历配置意图。
+ - **预期**:可选的 `config_json.calendarConfigured` 区分明确设置的每日/每周
+ 日历时间与 Hourly 内部占位 schedule。旧版 Daily/Weekly 保留日历语义;
+ 旧版 Hourly 转换时必须明确提供 schedule。已知配置可跨 Hourly 与重启保留,
+ 包括午夜;仅修改元数据以及 Manual 转 Hourly 的行为不变。
+ - **自动化**:`node --experimental-strip-types scripts/e2e-scheduled-calendar-intent.mjs`
+ ### E2E-SCHEDULED-paths
+
+ - **场景**:工作区身份。
+ - **预期**:保存和读取工作区绑定时统一使用现有项目路径规范化规则。Windows
+ 路径的斜杠方向、大小写、末尾分隔符和扩展路径前缀差异不影响同项目会话;
+ 缺失的旧版绑定与显式 null 保持不同语义,其他项目不能查询或修改绑定任务。
+ - **自动化**:`node --experimental-strip-types scripts/e2e-scheduled-paths.mjs`
使用隔离的真实 Host 与 SQLite 配置,不向真实提供商发送推理请求。