mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-25 04:35:37 -04:00
fix(tui): handle session search fetch failures without crashing (#36149)
This commit is contained in:
@@ -35,16 +35,23 @@ export function DialogSessionList() {
|
||||
const [searchResults] = createResource(search, async (query) => {
|
||||
if (!query) return
|
||||
const location = data.location.default()
|
||||
const response = await sdk.api.session.list({
|
||||
search: query,
|
||||
limit: 50,
|
||||
order: "desc",
|
||||
parentID: null,
|
||||
directory: location.directory,
|
||||
workspace: location.workspaceID,
|
||||
})
|
||||
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- generated client output is readonly; session list UI reuses legacy mutable session types.
|
||||
return { query, sessions: structuredClone(response.data) as SessionInfo[] }
|
||||
try {
|
||||
const response = await sdk.api.session.list({
|
||||
search: query,
|
||||
limit: 50,
|
||||
order: "desc",
|
||||
parentID: null,
|
||||
directory: location.directory,
|
||||
workspace: location.workspaceID,
|
||||
})
|
||||
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- generated client output is readonly; session list UI reuses legacy mutable session types.
|
||||
return { query, sessions: structuredClone(response.data) as SessionInfo[] }
|
||||
} catch (error) {
|
||||
// A transient transport failure must degrade search, not crash the TUI
|
||||
// through the root ErrorBoundary when the errored resource is read.
|
||||
toast.show({ message: errorMessage(error), variant: "error", duration: 5000 })
|
||||
return { query, sessions: [] as SessionInfo[] }
|
||||
}
|
||||
})
|
||||
|
||||
const currentSessionID = createMemo(() => (route.data.type === "session" ? route.data.sessionID : undefined))
|
||||
|
||||
Reference in New Issue
Block a user