[Fix] Task history disappears when user reopens a task - #1319
[Fix] Task history disappears when user reopens a task#1319zoomote[bot] wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Looks like this might also contribute to fixing some of the things I've experienced in #1231, too |
| let fileContent: string | ||
| try { | ||
| fileContent = await fs.readFile(filePath, "utf8") | ||
| } catch (error) { |
There was a problem hiding this comment.
before throwing the error, I suggest we wait a random number of milliseconds 10-300 and retry. safe writes move the file away and then the new one in place. hence, there is a split-second where no file is accessible.
Throw if the second try fails as well
| export async function saveTaskMessages({ messages, taskId, globalStoragePath }: SaveTaskMessagesOptions) { | ||
| const taskDir = await getTaskDirectoryPath(globalStoragePath, taskId) | ||
| const filePath = path.join(taskDir, GlobalFileNames.uiMessages) | ||
| await safeWriteJson(filePath, messages) |
There was a problem hiding this comment.
I think we should apply the new merge-pattern provided by #1261
the same should be done here:
Zoo-Code/src/core/task-persistence/apiMessages.ts
Lines 109 to 121 in 1ad8f52
which is called from
https://github.com/Zoo-Code-Org/Zoo-Code/pull/1319/changes#diff-ec3b024cdaad55c3e92c0d0d4293bbc785e69f76bf646132cb0923f44fb3df22R992
|
|
||
| private async saveApiConversationHistory(): Promise<boolean> { | ||
| try { | ||
| await saveApiMessages({ |
There was a problem hiding this comment.
What changed
Why this change was made
Reopening or quickly leaving a saved task could replace valid history with an empty or shortened message list. This resolves #1279 and extends the lifecycle and persistence safety work tracked by #355 and #208.
Impact
Users keep their last saved task content when reopening or resuming tasks. Temporary storage failures no longer become destructive empty writes, and stale task instances cannot write after being evicted.
Related PRs