Skip to content

Commit b492bda

Browse files
shuv1337triklozoid
authored andcommitted
fix(tui): pass attach directory to sdk client (anomalyco#6715)
Co-authored-by: shuv <shuv@shuv.dev>
1 parent 49a4d6c commit b492bda

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
9696
})
9797
}
9898

99-
export function tui(input: { url: string; args: Args; onExit?: () => Promise<void> }) {
99+
export function tui(input: { url: string; args: Args; directory?: string; onExit?: () => Promise<void> }) {
100100
// promise to prevent immediate exit
101101
return new Promise<void>(async (resolve) => {
102102
const mode = await getTerminalBackgroundColor()
@@ -116,7 +116,7 @@ export function tui(input: { url: string; args: Args; onExit?: () => Promise<voi
116116
<KVProvider>
117117
<ToastProvider>
118118
<RouteProvider>
119-
<SDKProvider url={input.url}>
119+
<SDKProvider url={input.url} directory={input.directory}>
120120
<SyncProvider>
121121
<ThemeProvider mode={mode}>
122122
<LocalProvider>

packages/opencode/src/cli/cmd/tui/attach.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ export const AttachCommand = cmd({
2222
}),
2323
handler: async (args) => {
2424
if (args.dir) process.chdir(args.dir)
25+
const directory = process.cwd()
2526
await tui({
2627
url: args.url,
2728
args: { sessionID: args.session },
29+
directory,
2830
})
2931
},
3032
})

packages/opencode/src/cli/cmd/tui/context/sdk.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { batch, onCleanup, onMount } from "solid-js"
55

66
export const { use: useSDK, provider: SDKProvider } = createSimpleContext({
77
name: "SDK",
8-
init: (props: { url: string }) => {
8+
init: (props: { url: string; directory?: string }) => {
99
const abort = new AbortController()
1010
const sdk = createOpencodeClient({
1111
baseUrl: props.url,
1212
signal: abort.signal,
13+
directory: props.directory,
1314
})
1415

1516
const emitter = createGlobalEmitter<{

0 commit comments

Comments
 (0)