Skip to content

feat: cache the automation panel's open detail across view switches / 自动化面板详情打开状态缓存 - #9296

Open
ttmouse wants to merge 3 commits into
esengine:main-v2from
ttmouse:feat/heartbeat-cache-detail
Open

feat: cache the automation panel's open detail across view switches / 自动化面板详情打开状态缓存#9296
ttmouse wants to merge 3 commits into
esengine:main-v2from
ttmouse:feat/heartbeat-cache-detail

Conversation

@ttmouse

@ttmouse ttmouse commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

自动化任务面板(Heartbeat)的查看状态目前不持久化:切换对话/视图导致面板 unmount 后,重新进入时回到初始态。本 PR 将两类状态缓存到 localStorage,切换对话再回到自动化面板时自动恢复:

  1. 详情打开状态reasonix-heartbeat-detail,存 {open, taskId}):恢复上次查看的任务详情(与面板已有列表宽度缓存 reasonix-heartbeat-list-width 同一模式)
  2. 搜索/筛选状态reasonix-heartbeat-filter,存 {searchQuery, statusFilter, scopeFilter}):恢复搜索词、状态筛选(全部/已开启/已暂停)、范围筛选,列表仍按恢复条件过滤

关键行为:

  • 打开任务详情 / 输入搜索词 / 切换筛选 → 写入缓存(详情从磁盘最新数据恢复,而非过期快照)
  • 面板因条件渲染(mainView === "automation")卸载后再挂载 → 自动恢复上次的详情与过滤状态
  • 关闭详情 / 删除当前任务 / 隐式关闭(过滤掉编辑中任务)→ 清除对应缓存;缓存指向的任务已不存在(被删除)时不恢复
  • 恢复的搜索词过滤掉缓存详情任务时,编辑器关闭并清除详情缓存(复用既有 clear-editing 逻辑),不会展示被过滤任务
  • 新建草稿(Add / 建议区)不写缓存,恢复无意义

Issues

任务看板 issue R87850A56D62-8(自动化面板需要缓存更多内容,比如说搜索的状态),非 GitHub issue

Verification

  • heartbeat-detail-cache.test.tsx(22 项断言):打开写入缓存 / 重挂载自动恢复 / 关闭清除缓存 / 失效缓存不恢复 / 慢加载竞态(restoreBlocked)/ 保存后缓存新任务 / 搜索过滤隐式关闭清缓存 / 删除任务清缓存
  • heartbeat-filter-cache.test.tsx(16 项断言):搜索词写入/恢复/清空 / 状态筛选写入/恢复 / 范围筛选恢复 / 与详情缓存组合
  • tsc --noEmittsc --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。

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Aug 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +246 to +248
if (task) {
setEditing({ ...task });
setDetailOpen(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复(commit daf73cc):新增 restoreBlockedRef——挂载时重置,openUnsavedDraft/点击任务行时置位,loadTasks().then 恢复前检查该标志,加载慢时用户先打开的草稿/任务不会被延迟的恢复回调覆盖。回归测试:'a draft opened during slow load is not overwritten by cache restoration'。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复(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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复(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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复(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 覆盖打开/恢复/清除/失效四类行为。
@ttmouse
ttmouse force-pushed the feat/heartbeat-cache-detail branch from 642f76c to daf73cc Compare August 22, 2026 18:08
…cross view switches / 自动化面板搜索与筛选状态缓存
…l cache / 加固详情缓存类型校验与删除路径测试
@ttmouse

ttmouse commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author
2026-08-23.10.33.38.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant