diff options
| author | Adam <[email protected]> | 2025-12-24 20:37:12 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-24 20:37:12 -0600 |
| commit | ad852d918656322acf2dc6645085fe3f06cff6f5 (patch) | |
| tree | 3663dec231b6ab4f33855299243bfb8f60833b2a | |
| parent | 8a9b4245b4dc75838e3b5ad0ff329c492a89cc41 (diff) | |
| download | opencode-ad852d918656322acf2dc6645085fe3f06cff6f5.tar.gz opencode-ad852d918656322acf2dc6645085fe3f06cff6f5.zip | |
chore: toast on file load error
| -rw-r--r-- | packages/app/src/context/local.tsx | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/packages/app/src/context/local.tsx b/packages/app/src/context/local.tsx index ea3fdb0d5..33b78cbec 100644 --- a/packages/app/src/context/local.tsx +++ b/packages/app/src/context/local.tsx @@ -9,6 +9,7 @@ import { base64Encode } from "@opencode-ai/util/encode" import { useProviders } from "@/hooks/use-providers" import { DateTime } from "luxon" import { persisted } from "@/utils/persist" +import { showToast } from "@opencode-ai/ui/toast" export type LocalFile = FileNode & Partial<{ @@ -336,17 +337,26 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ const load = async (path: string) => { const relativePath = relative(path) - await sdk.client.file.read({ path: relativePath }).then((x) => { - if (!store.node[relativePath]) return - setStore( - "node", - relativePath, - produce((draft) => { - draft.loaded = true - draft.content = x.data - }), - ) - }) + await sdk.client.file + .read({ path: relativePath }) + .then((x) => { + if (!store.node[relativePath]) return + setStore( + "node", + relativePath, + produce((draft) => { + draft.loaded = true + draft.content = x.data + }), + ) + }) + .catch((e) => { + showToast({ + variant: "error", + title: "Failed to load file", + description: e.message, + }) + }) } const fetch = async (path: string) => { |
