summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-12-27 05:19:03 -0600
committerAdam <[email protected]>2025-12-27 14:33:22 -0600
commitc523ca412747d66e0236865a4fa2481f7d50f64e (patch)
treebffa7666e7ef44abd5a039223bd66989652e2180
parent685f3ea324cf5d0401f7b0895a78560149bf8a4b (diff)
downloadopencode-c523ca412747d66e0236865a4fa2481f7d50f64e.tar.gz
opencode-c523ca412747d66e0236865a4fa2481f7d50f64e.zip
wip(desktop): handle more errors
-rw-r--r--packages/app/src/components/header.tsx4
-rw-r--r--packages/app/src/components/prompt-input.tsx60
-rw-r--r--packages/app/src/components/terminal.tsx32
-rw-r--r--packages/app/src/context/terminal.tsx60
-rw-r--r--packages/desktop/vite.config.ts3
5 files changed, 100 insertions, 59 deletions
diff --git a/packages/app/src/components/header.tsx b/packages/app/src/components/header.tsx
index 3eae0e05d..74c49f07a 100644
--- a/packages/app/src/components/header.tsx
+++ b/packages/app/src/components/header.tsx
@@ -188,6 +188,10 @@ export function Header(props: {
shareURL = await globalSDK.client.session
.share({ sessionID: session.id, directory: currentDirectory() })
.then((r) => r.data?.share?.url)
+ .catch((e) => {
+ console.error("Failed to share session", e)
+ return undefined
+ })
}
return shareURL
},
diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx
index 2407fe97a..f1bb9132a 100644
--- a/packages/app/src/components/prompt-input.tsx
+++ b/packages/app/src/components/prompt-input.tsx
@@ -643,9 +643,11 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
}
const abort = () =>
- sdk.client.session.abort({
- sessionID: params.id!,
- })
+ sdk.client.session
+ .abort({
+ sessionID: params.id!,
+ })
+ .catch(() => {})
const addToHistory = (prompt: Prompt, mode: "normal" | "shell") => {
const text = prompt
@@ -883,12 +885,16 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
const agent = local.agent.current()!.name
if (isShellMode) {
- sdk.client.session.shell({
- sessionID: existing.id,
- agent,
- model,
- command: text,
- })
+ sdk.client.session
+ .shell({
+ sessionID: existing.id,
+ agent,
+ model,
+ command: text,
+ })
+ .catch((e) => {
+ console.error("Failed to send shell command", e)
+ })
return
}
@@ -897,13 +903,17 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
const commandName = cmdName.slice(1)
const customCommand = sync.data.command.find((c) => c.name === commandName)
if (customCommand) {
- sdk.client.session.command({
- sessionID: existing.id,
- command: commandName,
- arguments: args.join(" "),
- agent,
- model: `${model.providerID}/${model.modelID}`,
- })
+ sdk.client.session
+ .command({
+ sessionID: existing.id,
+ command: commandName,
+ arguments: args.join(" "),
+ agent,
+ model: `${model.providerID}/${model.modelID}`,
+ })
+ .catch((e) => {
+ console.error("Failed to send command", e)
+ })
return
}
}
@@ -929,13 +939,17 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
model,
})
- sdk.client.session.prompt({
- sessionID: existing.id,
- agent,
- model,
- messageID,
- parts: requestParts,
- })
+ sdk.client.session
+ .prompt({
+ sessionID: existing.id,
+ agent,
+ model,
+ messageID,
+ parts: requestParts,
+ })
+ .catch((e) => {
+ console.error("Failed to send prompt", e)
+ })
}
return (
diff --git a/packages/app/src/components/terminal.tsx b/packages/app/src/components/terminal.tsx
index c05ddfbf6..abf03fc06 100644
--- a/packages/app/src/components/terminal.tsx
+++ b/packages/app/src/components/terminal.tsx
@@ -82,13 +82,15 @@ export const Terminal = (props: TerminalProps) => {
window.addEventListener("resize", handleResize)
term.onResize(async (size) => {
if (ws && ws.readyState === WebSocket.OPEN) {
- await sdk.client.pty.update({
- ptyID: local.pty.id,
- size: {
- cols: size.cols,
- rows: size.rows,
- },
- })
+ await sdk.client.pty
+ .update({
+ ptyID: local.pty.id,
+ size: {
+ cols: size.cols,
+ rows: size.rows,
+ },
+ })
+ .catch(() => {})
}
})
term.onData((data) => {
@@ -106,13 +108,15 @@ export const Terminal = (props: TerminalProps) => {
// })
ws.addEventListener("open", () => {
console.log("WebSocket connected")
- sdk.client.pty.update({
- ptyID: local.pty.id,
- size: {
- cols: term.cols,
- rows: term.rows,
- },
- })
+ sdk.client.pty
+ .update({
+ ptyID: local.pty.id,
+ size: {
+ cols: term.cols,
+ rows: term.rows,
+ },
+ })
+ .catch(() => {})
})
ws.addEventListener("message", (event) => {
term.write(event.data)
diff --git a/packages/app/src/context/terminal.tsx b/packages/app/src/context/terminal.tsx
index 6f7c11dea..e9a07077c 100644
--- a/packages/app/src/context/terminal.tsx
+++ b/packages/app/src/context/terminal.tsx
@@ -36,35 +36,49 @@ export const { use: useTerminal, provider: TerminalProvider } = createSimpleCont
all: createMemo(() => Object.values(store.all)),
active: createMemo(() => store.active),
new() {
- sdk.client.pty.create({ title: `Terminal ${store.all.length + 1}` }).then((pty) => {
- const id = pty.data?.id
- if (!id) return
- setStore("all", [
- ...store.all,
- {
- id,
- title: pty.data?.title ?? "Terminal",
- },
- ])
- setStore("active", id)
- })
+ sdk.client.pty
+ .create({ title: `Terminal ${store.all.length + 1}` })
+ .then((pty) => {
+ const id = pty.data?.id
+ if (!id) return
+ setStore("all", [
+ ...store.all,
+ {
+ id,
+ title: pty.data?.title ?? "Terminal",
+ },
+ ])
+ setStore("active", id)
+ })
+ .catch((e) => {
+ console.error("Failed to create terminal", e)
+ })
},
update(pty: Partial<LocalPTY> & { id: string }) {
setStore("all", (x) => x.map((x) => (x.id === pty.id ? { ...x, ...pty } : x)))
- sdk.client.pty.update({
- ptyID: pty.id,
- title: pty.title,
- size: pty.cols && pty.rows ? { rows: pty.rows, cols: pty.cols } : undefined,
- })
+ sdk.client.pty
+ .update({
+ ptyID: pty.id,
+ title: pty.title,
+ size: pty.cols && pty.rows ? { rows: pty.rows, cols: pty.cols } : undefined,
+ })
+ .catch((e) => {
+ console.error("Failed to update terminal", e)
+ })
},
async clone(id: string) {
const index = store.all.findIndex((x) => x.id === id)
const pty = store.all[index]
if (!pty) return
- const clone = await sdk.client.pty.create({
- title: pty.title,
- })
- if (!clone.data) return
+ const clone = await sdk.client.pty
+ .create({
+ title: pty.title,
+ })
+ .catch((e) => {
+ console.error("Failed to clone terminal", e)
+ return undefined
+ })
+ if (!clone?.data) return
setStore("all", index, {
...pty,
...clone.data,
@@ -88,7 +102,9 @@ export const { use: useTerminal, provider: TerminalProvider } = createSimpleCont
setStore("active", previous?.id)
}
})
- await sdk.client.pty.remove({ ptyID: id })
+ await sdk.client.pty.remove({ ptyID: id }).catch((e) => {
+ console.error("Failed to close terminal", e)
+ })
},
move(id: string, to: number) {
const index = store.all.findIndex((f) => f.id === id)
diff --git a/packages/desktop/vite.config.ts b/packages/desktop/vite.config.ts
index 123a2028c..6d4f62dc2 100644
--- a/packages/desktop/vite.config.ts
+++ b/packages/desktop/vite.config.ts
@@ -10,6 +10,9 @@ export default defineConfig({
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
+ build: {
+ sourcemap: true,
+ },
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,