Repository navigation
Preserve task history through storage and locking failures #2742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
433138a
318c935
a58cf84
bbcb173
06b38be
0a5268b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -656,6 +656,9 @@ export class ClineProvider | |
| elapsedMs: Date.now() - startedAt, | ||
| }) | ||
| this.log(`[initializeTaskHistoryStore] Error: ${error instanceof Error ? error.message : String(error)}`) | ||
| void vscode.window.showWarningMessage( | ||
| `Zoo could not load conversation history: ${error instanceof Error ? error.message : String(error)}. Check the configured storage path and restart VS Code after it is available.`, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2841,10 +2844,14 @@ export class ClineProvider | |
| taskId: id, | ||
| }) | ||
| try { | ||
| if (id !== this.getCurrentTask()?.taskId) { | ||
| // Non-current task. | ||
| const current = this.getCurrentTask() | ||
| if (id !== current?.taskId) { | ||
| const { historyItem } = await this.getTaskWithId(id) | ||
| await this.createTaskWithHistoryItem(historyItem) // Clears existing task. | ||
| await this.createTaskWithHistoryItem(historyItem) | ||
| } else if (current.abort || current.abandoned) { | ||
| // A failed cancellation lookup leaves the stopped task visible. | ||
| // A later history lookup can replace it once storage is available. | ||
| await this.restartTaskIfCurrent(current) | ||
| } | ||
|
|
||
| await this.postMessageToWebview({ type: "action", action: "chatButtonClicked" }) | ||
|
|
@@ -4516,20 +4523,14 @@ export class ClineProvider | |
| } | ||
|
|
||
| private async cancelTaskInternal(task: Task): Promise<void> { | ||
| let historyItem: HistoryItem | undefined | ||
| try { | ||
| const history = await this.getTaskWithId(task.taskId) | ||
| historyItem = history.historyItem | ||
| } catch (error) { | ||
| // During task startup there is a short window where currentTask exists | ||
| // but task history has not been persisted yet. Cancelling should still | ||
| // abort safely; we just skip post-cancel rehydration in that case. | ||
| if (error instanceof Error && error.message === "Task not found") { | ||
| this.log(`[cancelTask] task history missing for ${task.taskId}; skipping rehydrate`) | ||
| } else { | ||
| throw error | ||
| } | ||
| } | ||
| // Storage may be missing at startup or inaccessible. The history lookup | ||
| // is only needed for rehydration and must never delay aborting the request. | ||
| const historyRead = this.getTaskWithId(task.taskId) | ||
| .then(({ historyItem }) => historyItem) | ||
| .catch(() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this read fails, |
||
| this.log(`[cancelTask] task history unavailable for ${task.taskId}; skipping rehydrate`) | ||
| return undefined | ||
|
cartridgebasic marked this conversation as resolved.
Resolved
|
||
| }) | ||
|
|
||
| // Preserve parent and root task information for history item. | ||
| let rootTask = task.rootTask | ||
|
|
@@ -4573,6 +4574,7 @@ export class ClineProvider | |
| // Wait for abortTask to fully settle (including its final saveClineMessages write) | ||
| // before we persist "interrupted", so our write is always the last one. | ||
| await abortPromise.catch(() => {}) | ||
| let historyItem = await historyRead | ||
|
|
||
| // Defensive safeguard: if current instance already changed, skip rehydrate | ||
| const current = this.getCurrentTask() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests still pass if I remove this
true, or the one ingetTaskDirectoryPath. Could a test with the real storage helper and an unusable custom path make sure that nothing goes to the default root?