Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/cmd/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Argv } from "yargs"
import { cmd } from "./cmd"
import { Session } from "../../session"
import { Instance } from "../../project/instance"
import { bootstrap } from "../bootstrap"
import { UI } from "../ui"
import { Locale } from "../../util/locale"
Expand Down Expand Up @@ -86,7 +87,7 @@ export const SessionListCommand = cmd({
},
handler: async (args) => {
await bootstrap(process.cwd(), async () => {
const sessions = [...Session.list({ roots: true, limit: args.maxCount })]
const sessions = [...Session.list({ roots: true, limit: args.maxCount, directory: Instance.directory })]

if (sessions.length === 0) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function DialogSessionList() {

const [searchResults] = createResource(search, async (query) => {
if (!query) return undefined
const result = await sdk.client.session.list({ search: query, limit: 30 })
const result = await sdk.client.session.list({ search: query, limit: 30, directory: sdk.directory || sync.data.path.directory || undefined })
return result.data ?? []
})

Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/cli/cmd/tui/context/sdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ export const { use: useSDK, provider: SDKProvider } = createSimpleContext({
if (timer) clearTimeout(timer)
})

return { client: sdk, event: emitter, url: props.url }
return { client: sdk, event: emitter, url: props.url, directory: props.directory }
},
})
4 changes: 3 additions & 1 deletion packages/opencode/src/cli/cmd/tui/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
setStore("session", result.index, reconcile(event.properties.info))
break
}
// Only insert new sessions if they belong to the current directory
if (sdk.directory && event.properties.info.directory !== sdk.directory) break
setStore(
"session",
produce((draft) => {
Expand Down Expand Up @@ -350,7 +352,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
console.log("bootstrapping")
const start = Date.now() - 30 * 24 * 60 * 60 * 1000
const sessionListPromise = sdk.client.session
.list({ start: start })
.list({ start: start, directory: sdk.directory })
.then((x) => (x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)))

// blocking - include session.list when continuing a session
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/tui/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const TuiThreadCommand = cmd({

const tuiPromise = tui({
url,
directory: cwd,
fetch: customFetch,
events,
args: {
Expand Down
Loading