summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'packages/desktop/src/pages')
-rw-r--r--packages/desktop/src/pages/error.tsx26
-rw-r--r--packages/desktop/src/pages/layout.tsx7
2 files changed, 28 insertions, 5 deletions
diff --git a/packages/desktop/src/pages/error.tsx b/packages/desktop/src/pages/error.tsx
index 66fc81d98..352b9f3e8 100644
--- a/packages/desktop/src/pages/error.tsx
+++ b/packages/desktop/src/pages/error.tsx
@@ -1,5 +1,6 @@
import { TextField } from "@opencode-ai/ui/text-field"
import { Logo } from "@opencode-ai/ui/logo"
+import { Button } from "@opencode-ai/ui/button"
import { Component } from "solid-js"
import { usePlatform } from "@/context/platform"
import { Icon } from "@opencode-ai/ui/icon"
@@ -9,9 +10,17 @@ export type InitError = {
data: Record<string, unknown>
}
-function formatError(error: InitError | undefined): string {
- if (!error) return "Unknown error"
+function isInitError(error: unknown): error is InitError {
+ return (
+ typeof error === "object" &&
+ error !== null &&
+ "name" in error &&
+ "data" in error &&
+ typeof (error as InitError).data === "object"
+ )
+}
+function formatInitError(error: InitError): string {
const data = error.data
switch (error.name) {
case "MCPFailed":
@@ -53,8 +62,16 @@ function formatError(error: InitError | undefined): string {
}
}
+function formatError(error: unknown): string {
+ if (!error) return "Unknown error"
+ if (isInitError(error)) return formatInitError(error)
+ if (error instanceof Error) return `${error.name}: ${error.message}\n\n${error.stack}`
+ if (typeof error === "string") return error
+ return JSON.stringify(error, null, 2)
+}
+
interface ErrorPageProps {
- error: InitError | undefined
+ error: unknown
}
export const ErrorPage: Component<ErrorPageProps> = (props) => {
@@ -76,6 +93,9 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
label="Error Details"
hideLabel
/>
+ <Button size="large" onClick={platform.restart}>
+ Restart
+ </Button>
<div class="flex items-center justify-center gap-1">
Please report this error to the OpenCode team
<button
diff --git a/packages/desktop/src/pages/layout.tsx b/packages/desktop/src/pages/layout.tsx
index 5f4a5d797..626bceb22 100644
--- a/packages/desktop/src/pages/layout.tsx
+++ b/packages/desktop/src/pages/layout.tsx
@@ -69,7 +69,7 @@ export default function Layout(props: ParentProps) {
const command = useCommand()
onMount(async () => {
- if (platform.checkUpdate && platform.update) {
+ if (platform.checkUpdate && platform.update && platform.restart) {
const { updateAvailable, version } = await platform.checkUpdate()
if (updateAvailable) {
showToast({
@@ -80,7 +80,10 @@ export default function Layout(props: ParentProps) {
actions: [
{
label: "Install and restart",
- onClick: () => platform!.update!(),
+ onClick: async () => {
+ await platform.update!()
+ await platform.restart!()
+ },
},
{
label: "Not yet",