feat: cache the automation panel's open detail across view switches / 自动化面板详情打开状态缓存 - #9296
feat: cache the automation panel's open detail across view switches / 自动化面板详情打开状态缓存#9296ttmouse wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 642f76c610
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (task) { | ||
| setEditing({ ...task }); | ||
| setDetailOpen(true); |
There was a problem hiding this comment.
Avoid overwriting drafts during delayed cache restoration
When the initial config/workspace load is slow, the enabled New button can open an unsaved draft before this callback completes. These unconditional setters then replace that draft with the cached task, silently discarding any values the user entered; restore the cached selection only if no task or draft has been opened since the load began.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
已修复(commit daf73cc):新增 restoreBlockedRef——挂载时重置,openUnsavedDraft/点击任务行时置位,loadTasks().then 恢复前检查该标志,加载慢时用户先打开的草稿/任务不会被延迟的恢复回调覆盖。回归测试:'a draft opened during slow load is not overwritten by cache restoration'。
There was a problem hiding this comment.
已修复(commit daf73cc):新增 restoreBlockedRef——挂载时重置,openUnsavedDraft/点击任务行时置位,loadTasks().then 恢复前检查该标志,加载慢时用户先打开的草稿/任务不会被延迟的恢复回调覆盖。回归测试:a draft opened during slow load is not overwritten by cache restoration。
| unsavedDraftIdsRef.current.delete(task.id); | ||
| setEditing({ ...task }); | ||
| setDetailOpen(true); | ||
| writeDetailCache({ open: true, taskId: task.id }); |
There was a problem hiding this comment.
Cache a new task after its draft is saved
This cache write only runs for tasks selected from the list. If a user opens task A, creates and successfully saves task B, then switches views, the cache still points to A and remounting reopens A instead of the currently open B; with no prior cache, no detail is restored at all. Once handleSaveEdit promotes a draft to a persisted task, it should update the cache to that task ID.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
已修复(commit daf73cc):handleSaveEdit 保存成功后 writeDetailCache({ open: true, taskId: task.id })——新建任务保存后缓存指向当前打开的 B 而非之前的 A。回归测试:saving a new draft updates the cache to the new task id / remount restores the newly saved task instead of the previously opened one。
| unsavedDraftIdsRef.current.delete(task.id); | ||
| setEditing({ ...task }); | ||
| setDetailOpen(true); | ||
| writeDetailCache({ open: true, taskId: task.id }); |
There was a problem hiding this comment.
Clear cached selection when filtering closes the editor
After opening a task, entering a search or scope filter that excludes it makes the existing cleanup effect set editing to null, but this newly written cache remains open for that task. Switching away and back resets the filters and restores the task that the UI had already deselected, so implicit editor-closing paths should also clear or update the cache.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
已修复(commit daf73cc):过滤导致编辑任务不可见的 cleanup effect 改为 closeEditor helper,隐式关闭编辑器时同时 writeDetailCache(null),切走再回来不会恢复已被取消选中的任务。回归测试:filtering out the edited task closes its editor / implicit editor close clears the cache。
切换对话/视图导致自动化面板(HeartbeatView)unmount 时,把当前查看的 任务详情(taskId + open)写入 localStorage;重新进入面板后恢复该详情, 与已有 reasonix-heartbeat-list-width 拖拽比例缓存同一模式。 关闭详情或删除任务时清除缓存;缓存指向的任务已不存在时不恢复。 新增 heartbeat-detail-cache.test.tsx 覆盖打开/恢复/清除/失效四类行为。
642f76c to
daf73cc
Compare
…cross view switches / 自动化面板搜索与筛选状态缓存
…l cache / 加固详情缓存类型校验与删除路径测试
2026-08-23.10.33.38.mp4 |
Summary
自动化任务面板(Heartbeat)的查看状态目前不持久化:切换对话/视图导致面板 unmount 后,重新进入时回到初始态。本 PR 将两类状态缓存到 localStorage,切换对话再回到自动化面板时自动恢复:
reasonix-heartbeat-detail,存{open, taskId}):恢复上次查看的任务详情(与面板已有列表宽度缓存reasonix-heartbeat-list-width同一模式)reasonix-heartbeat-filter,存{searchQuery, statusFilter, scopeFilter}):恢复搜索词、状态筛选(全部/已开启/已暂停)、范围筛选,列表仍按恢复条件过滤关键行为:
mainView === "automation")卸载后再挂载 → 自动恢复上次的详情与过滤状态Issues
任务看板 issue R87850A56D62-8(自动化面板需要缓存更多内容,比如说搜索的状态),非 GitHub issue
Verification
heartbeat-detail-cache.test.tsx(22 项断言):打开写入缓存 / 重挂载自动恢复 / 关闭清除缓存 / 失效缓存不恢复 / 慢加载竞态(restoreBlocked)/ 保存后缓存新任务 / 搜索过滤隐式关闭清缓存 / 删除任务清缓存heartbeat-filter-cache.test.tsx(16 项断言):搜索词写入/恢复/清空 / 状态筛选写入/恢复 / 范围筛选恢复 / 与详情缓存组合tsc --noEmit与tsc --noEmit -p tsconfig.test.json通过composer-goal-toggle.test.tsx失败为基线预存(不 import heartbeat 代码,与本次改动无关)Documentation impact
Documentation-impact: none - 纯前端 UI 状态缓存功能,不涉及 CLI/配置/提供方行为,现有自动化面板相关文档仍准确,无需更新。
Cache impact
Cache-impact: none - 仅 desktop/frontend 前端改动,不触及 provider-visible 前缀或任何缓存敏感路径(internal/tool、internal/provider、internal/boot 等)。
Cache-guard: N/A - 前端行为由 heartbeat 测试套件覆盖(detail-cache 22 项 + filter-cache 16 项验证缓存读写/恢复/清除)。
System-prompt-review: N/A - 不触及 internal/config、internal/memory、internal/outputstyle、internal/skill、internal/boot。