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) => {
|
const [searchResults] = createResource(search, async (query) => {
|
||||||
if (!query) return
|
if (!query) return
|
||||||
const location = data.location.default()
|
const location = data.location.default()
|
||||||
const response = await sdk.api.session.list({
|
try {
|
||||||
search: query,
|
const response = await sdk.api.session.list({
|
||||||
limit: 50,
|
search: query,
|
||||||
order: "desc",
|
limit: 50,
|
||||||
parentID: null,
|
order: "desc",
|
||||||
directory: location.directory,
|
parentID: null,
|
||||||
workspace: location.workspaceID,
|
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[] }
|
// 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))
|
const currentSessionID = createMemo(() => (route.data.type === "session" ? route.data.sessionID : undefined))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue