fix(desktop): preserve lazy Sentry loading (#45776)

This commit is contained in:
Luke Parker 2026-08-28 09:41:09 +10:00 committed by GitHub
parent 62d9aa9838
commit 84fa689686
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
import { TextField } from "@opencode-ai/ui/text-field"
import { captureException, isEnabled } from "@sentry/solid"
import type { captureException } from "@sentry/solid"
import { Logo } from "@opencode-ai/ui/logo"
import { Button } from "@opencode-ai/ui/button"
import { Component, createSignal, onMount, Show } from "solid-js"
@ -227,6 +227,7 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
let recordedFatalError: Promise<void> | undefined
const [store, setStore] = createStore({
actionError: undefined as string | undefined,
captureException: undefined as typeof captureException | undefined,
})
function ensureFatalErrorRecorded() {
@ -243,6 +244,11 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
onMount(() => {
void ensureFatalErrorRecorded().catch(() => undefined)
void import("@sentry/solid")
.then(({ captureException, isEnabled }) => {
if (isEnabled()) setStore("captureException", () => captureException)
})
.catch(() => undefined)
})
async function checkForUpdates() {
@ -311,15 +317,15 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
{language.t("error.page.action.exportLogs")}
</Button>
</Show>
<Show when={isEnabled}>
{(_) => {
<Show when={store.captureException}>
{(capture) => {
const [reported, setReported] = createSignal(false)
return (
<Button
size="large"
disabled={reported()}
onClick={() => {
captureException(props.error)
capture()(props.error)
setReported(true)
}}
>