mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 02:58:29 +00:00
fix(tui): handle session search fetch failures without crashing (#36149)
This commit is contained in:
parent
8fe78c8f8d
commit
9ff7ef3fb0
1 changed files with 17 additions and 10 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue