summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/components/dialog-select-server.tsx
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-27 06:27:27 -0600
committeradamelmore <[email protected]>2026-01-27 06:29:20 -0600
commit095328faf439fbdc62506f3653875fbfec5c60ab (patch)
tree707036011dcafaa2ad13d05eb52b041ea6f0d951 /packages/app/src/components/dialog-select-server.tsx
parent743e83d9bfc050183be5bfb0f241ebe5faac6b35 (diff)
downloadopencode-095328faf439fbdc62506f3653875fbfec5c60ab.tar.gz
opencode-095328faf439fbdc62506f3653875fbfec5c60ab.zip
fix(app): non-fatal error handling
Diffstat (limited to 'packages/app/src/components/dialog-select-server.tsx')
-rw-r--r--packages/app/src/components/dialog-select-server.tsx43
1 files changed, 35 insertions, 8 deletions
diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx
index 774ad51cc..910b05ad4 100644
--- a/packages/app/src/components/dialog-select-server.tsx
+++ b/packages/app/src/components/dialog-select-server.tsx
@@ -14,6 +14,7 @@ import { useLanguage } from "@/context/language"
import { DropdownMenu } from "@opencode-ai/ui/dropdown-menu"
import { Tooltip } from "@opencode-ai/ui/tooltip"
import { useGlobalSDK } from "@/context/global-sdk"
+import { showToast } from "@opencode-ai/ui/toast"
type ServerStatus = { healthy: boolean; version?: string }
@@ -40,10 +41,11 @@ interface EditRowProps {
}
async function checkHealth(url: string, platform: ReturnType<typeof usePlatform>): Promise<ServerStatus> {
+ const signal = (AbortSignal as unknown as { timeout?: (ms: number) => AbortSignal }).timeout?.(3000)
const sdk = createOpencodeClient({
baseUrl: url,
fetch: platform.fetch,
- signal: AbortSignal.timeout(3000),
+ signal,
})
return sdk.global
.health()
@@ -149,9 +151,18 @@ export function DialogSelectServer() {
})
const [defaultUrl, defaultUrlActions] = createResource(
async () => {
- const url = await platform.getDefaultServerUrl?.()
- if (!url) return null
- return normalizeServerUrl(url) ?? null
+ try {
+ const url = await platform.getDefaultServerUrl?.()
+ if (!url) return null
+ return normalizeServerUrl(url) ?? null
+ } catch (err) {
+ showToast({
+ variant: "error",
+ title: language.t("common.requestFailed"),
+ description: err instanceof Error ? err.message : String(err),
+ })
+ return null
+ }
},
{ initialValue: null },
)
@@ -508,8 +519,16 @@ export function DialogSelectServer() {
<Show when={canDefault() && defaultUrl() !== i}>
<DropdownMenu.Item
onSelect={async () => {
- await platform.setDefaultServerUrl?.(i)
- defaultUrlActions.mutate(i)
+ try {
+ await platform.setDefaultServerUrl?.(i)
+ defaultUrlActions.mutate(i)
+ } catch (err) {
+ showToast({
+ variant: "error",
+ title: language.t("common.requestFailed"),
+ description: err instanceof Error ? err.message : String(err),
+ })
+ }
}}
>
<DropdownMenu.ItemLabel>
@@ -520,8 +539,16 @@ export function DialogSelectServer() {
<Show when={canDefault() && defaultUrl() === i}>
<DropdownMenu.Item
onSelect={async () => {
- await platform.setDefaultServerUrl?.(null)
- defaultUrlActions.mutate(null)
+ try {
+ await platform.setDefaultServerUrl?.(null)
+ defaultUrlActions.mutate(null)
+ } catch (err) {
+ showToast({
+ variant: "error",
+ title: language.t("common.requestFailed"),
+ description: err instanceof Error ? err.message : String(err),
+ })
+ }
}}
>
<DropdownMenu.ItemLabel>