feat: scope AI draft and session resume state#712
Conversation
- persist drafts, panel views, and active sessions per terminal/workspace scope - restore scoped AI session selection on reconnect and cold mount - prefer unsent drafts over implicit history fallback - avoid redundant active session map rewrites during scoped cleanup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75dc3dd72b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Eric 辛苦了,这个改动整体看下来挺扎实的,把 draft / panelView 按 scope 隔离这个思路解了好几个之前的体验问题,纯函数那几个模块的测试也写得非常细致,后面的 c5d15a1 那一手 churn 修复也很到位。 本地仔细看了一下,有两处小地方想和你讨论下,觉得合并前稍微收一下可能会更稳,麻烦你看看: 1.
如果方便的话,或许可以把副作用挪到 updater 返回之后再执行,或者让 2. 这种写法下,如果恰好有另一个 scope 的并发编辑, 另外在翻代码的时候顺手注意到,`application/state/useFileUpload.ts` 里那个 `useFileUpload` hook 重构之后好像已经没有调用点了(只剩 `convertFilesToUploads` 和 `UploadedFile` 类型再导出还在用)。不知道你是有意保留还是漏删的,如果没别的用途,顺手清掉会清爽一些;`ChatInput.tsx:14` 那处 `UploadedFile` 的 import 也可以直接指向 `infrastructure/ai/types`,少一层中转。 剩下几处都是小细节,不阻塞这个 PR,只是记录一下,有空再看:
以上只是一些观察,最终怎么取舍听你的。辛苦了 🙏 |
|
OK. 我这边在修复看看 |
|
已修复,你那边用了什么hardness来让他不停的检查吗?agent查几轮就偷懒了 |
这次这个PR我用claude + superpower 简单的review一下。此前我是让claude循环调用codex的review来找问题,不过这次PR比较大,对于500+ 行数变更的PR,如果用codex不停的review 可能会一直在边缘的case打转,而且很费token。。codex单次review的时间也很长。 所以等会我再简单查一下,如果没大问题就先合并了,小问题不严重的 日后发现了再慢慢修复。 |
|
我这边也用了superpowers,但是在迭代review方面似乎也不太理想,还得手动换新的session来review会检查出问题 |
Summary
This PR scopes AI chat draft, panel view, and active session state by terminal/workspace target instead of sharing a single global view.
That makes AI chat behavior more predictable when switching terminals or workspaces:
Changes
useAIStateto persist and restore active AI session selection per scopeAIChatSidePanelandTerminalLayerValidation
npm run lint -- --quietnpm run buildnode --test application/state/aiDraftState.test.ts application/state/aiScopeCleanup.test.ts components/ai/aiPanelViewState.test.ts components/ai/userSkillsState.test.ts