Skip to content

Commit 054764c

Browse files
committed
fix(cancelBookkeeping): check for existing cancelReason before overwriting
- Add conditional check to preserve existing cancelReason values - Only set cancelReason if it doesn't already exist - Addresses review feedback from daniel-lxs
1 parent e5be214 commit 054764c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/core/task-persistence/cancelBookkeeping.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ export async function addCancelReasonToLastApiReqStarted(args: {
3232

3333
try {
3434
const existing = uiMsgs[idx]?.text ? JSON.parse(uiMsgs[idx].text as string) : {}
35-
uiMsgs[idx].text = JSON.stringify({ ...existing, cancelReason: reason })
36-
await saveTaskMessages({ messages: uiMsgs as any, taskId, globalStoragePath })
35+
// Only set cancelReason if it doesn't already exist
36+
if (!existing.cancelReason) {
37+
uiMsgs[idx].text = JSON.stringify({ ...existing, cancelReason: reason })
38+
await saveTaskMessages({ messages: uiMsgs as any, taskId, globalStoragePath })
39+
}
40+
// If cancelReason already exists, preserve the original reason
3741
} catch {
3842
// Non-fatal parse or write failure
3943
return

0 commit comments

Comments
 (0)