An open-source, faster Devin alternative
TypeScript
fix(web): unwrap session-create envelope + surface API error reason
Igor Zalutski679f3678aa7e
diff --git a/web/src/api/client.ts b/web/src/api/client.tsindex 4ec5bad3..8cde9b25 100644--- a/web/src/api/client.ts+++ b/web/src/api/client.ts@@ -401,13 +401,14 @@ export const getSessions = (status?: string) =>export const getSession = (id: string) =>apiFetch(`/v3/sessions/${id}`, {}, S.SessionSchema)-// /v3 wants { agent: <id>, input } and input is required (the first task).+// /v3 wants { agent: <id>, input } (input required). The response is an envelope+// { session, client_token } — return the session.export const createSession = (body: { agent: string; input: string }) =>apiFetch('/v3/sessions',{ method: 'POST', body: JSON.stringify(body) },- S.SessionSchema,- )+ z.object({ session: S.SessionSchema, client_token: z.string().optional() }),+ ).then((r) => r.session)export const cancelSession = (id: string) =>apiFetch<void>(`/v3/sessions/${id}/cancel`, { method: 'POST' })diff --git a/web/src/lib/errors.ts b/web/src/lib/errors.tsindex 3d1aaa37..0d52c733 100644--- a/web/src/lib/errors.ts+++ b/web/src/lib/errors.ts@@ -1,12 +1,18 @@import { toast } from 'sonner'/**- * Show a clear, human error toast and send the raw error to the console for- * debugging. Keeps raw messages, HTTP codes, and stack detail out of the UI —- * the toast says what failed in plain language; `console.error` keeps the- * detail for developers.+ * Show a clear, human error toast and send the raw error to the console.+ * `message` is the plain-language title; the underlying error's message (e.g. an+ * API reason like "no resolvable credential") rides along as the toast+ * description so failures are actionable, while stacks/HTTP detail stay in the+ * console.*/export function notifyError(message: string, error?: unknown): void {if (error !== undefined) console.error(message, error)- toast.error(message)+ const detail = error instanceof Error ? error.message : undefined+ // Don't echo the title back as its own description.+ toast.error(+ message,+ detail && detail !== message ? { description: detail } : undefined,+ )}