mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-30 17:14:40 +08:00
fix(tui): suppress expected disposal aborts
This commit is contained in:
@@ -62,6 +62,10 @@ export function eventLocation(metadata: { directory: string; workspace?: string
|
||||
if (metadata.directory === "global") return
|
||||
return { directory: metadata.directory, workspaceID: metadata.workspace }
|
||||
}
|
||||
|
||||
export function shouldReportDefaultLocationFailure(reason: unknown, disposed: boolean) {
|
||||
return !disposed || !(reason instanceof Error && reason.name === "AbortError")
|
||||
}
|
||||
// kilocode_change end
|
||||
|
||||
export const { use: useData, provider: DataProvider } = createSimpleContext({
|
||||
@@ -575,6 +579,11 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
||||
},
|
||||
}
|
||||
|
||||
// kilocode_change start - treat SDK cancellation during normal TUI disposal as expected
|
||||
let disposed = false
|
||||
onCleanup(() => {
|
||||
disposed = true
|
||||
})
|
||||
onMount(() => {
|
||||
void Promise.allSettled([
|
||||
result.location.refresh(),
|
||||
@@ -586,10 +595,14 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
||||
result.location.command.refresh(),
|
||||
result.location.skill.refresh(),
|
||||
]).then((settled) => {
|
||||
for (const failure of settled.filter((item) => item.status === "rejected"))
|
||||
for (const failure of settled) {
|
||||
if (failure.status !== "rejected") continue
|
||||
if (!shouldReportDefaultLocationFailure(failure.reason, disposed)) continue
|
||||
console.error("Failed to refresh default location data", failure.reason)
|
||||
}
|
||||
})
|
||||
})
|
||||
// kilocode_change end
|
||||
|
||||
return result
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { eventLocation } from "../../src/context/data"
|
||||
import { eventLocation, shouldReportDefaultLocationFailure } from "../../src/context/data"
|
||||
|
||||
describe("eventLocation", () => {
|
||||
test("uses the default location for global events", () => {
|
||||
@@ -13,3 +13,17 @@ describe("eventLocation", () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("shouldReportDefaultLocationFailure", () => {
|
||||
test("suppresses lifecycle aborts after disposal", () => {
|
||||
expect(shouldReportDefaultLocationFailure(new DOMException("aborted", "AbortError"), true)).toBe(false)
|
||||
})
|
||||
|
||||
test("reports aborts while mounted", () => {
|
||||
expect(shouldReportDefaultLocationFailure(new DOMException("aborted", "AbortError"), false)).toBe(true)
|
||||
})
|
||||
|
||||
test("reports non-abort failures after disposal", () => {
|
||||
expect(shouldReportDefaultLocationFailure(new Error("network failed"), true)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user