summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJase Kraft <[email protected]>2025-07-14 19:32:00 -0500
committerGitHub <[email protected]>2025-07-14 20:32:00 -0400
commit294a11752e8cc4b315b22a4df320ef5ce9fa5345 (patch)
treeac0f519e626c30b5d97894fbaadae51e2578e7f5
parent1cf1d1f63417ba447f9652db6905fa72d89d97e5 (diff)
downloadopencode-294a11752e8cc4b315b22a4df320ef5ce9fa5345.tar.gz
opencode-294a11752e8cc4b315b22a4df320ef5ce9fa5345.zip
fix: --continue pull the latest session id consistently (#918)
Co-authored-by: Dax Raad <[email protected]>
-rw-r--r--packages/opencode/src/session/index.ts9
-rw-r--r--packages/opencode/src/storage/storage.ts19
2 files changed, 14 insertions, 14 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts
index e2f456997..3a92cbeae 100644
--- a/packages/opencode/src/session/index.ts
+++ b/packages/opencode/src/session/index.ts
@@ -230,8 +230,7 @@ export namespace Session {
info: MessageV2.Info
parts: MessageV2.Part[]
}[]
- const list = Storage.list("session/message/" + sessionID)
- for await (const p of list) {
+ for (const p of await Storage.list("session/message/" + sessionID)) {
const read = await Storage.readJSON<MessageV2.Info>(p)
result.push({
info: read,
@@ -248,7 +247,7 @@ export namespace Session {
export async function parts(sessionID: string, messageID: string) {
const result = [] as MessageV2.Part[]
- for await (const item of Storage.list("session/part/" + sessionID + "/" + messageID)) {
+ for (const item of await Storage.list("session/part/" + sessionID + "/" + messageID)) {
const read = await Storage.readJSON<MessageV2.Part>(item)
result.push(read)
}
@@ -257,7 +256,7 @@ export namespace Session {
}
export async function* list() {
- for await (const item of Storage.list("session/info")) {
+ for (const item of await Storage.list("session/info")) {
const sessionID = path.basename(item, ".json")
yield get(sessionID)
}
@@ -265,7 +264,7 @@ export namespace Session {
export async function children(parentID: string) {
const result = [] as Session.Info[]
- for await (const item of Storage.list("session/info")) {
+ for (const item of await Storage.list("session/info")) {
const sessionID = path.basename(item, ".json")
const session = await get(sessionID)
if (session.parentID !== parentID) continue
diff --git a/packages/opencode/src/storage/storage.ts b/packages/opencode/src/storage/storage.ts
index 22876ee40..442ce82b0 100644
--- a/packages/opencode/src/storage/storage.ts
+++ b/packages/opencode/src/storage/storage.ts
@@ -121,18 +121,19 @@ export namespace Storage {
}
const glob = new Bun.Glob("**/*")
- export async function* list(prefix: string) {
+ export async function list(prefix: string) {
const dir = await state().then((x) => x.dir)
try {
- for await (const item of glob.scan({
- cwd: path.join(dir, prefix),
- onlyFiles: true,
- })) {
- const result = path.join(prefix, item.slice(0, -5))
- yield result
- }
+ const result = await Array.fromAsync(
+ glob.scan({
+ cwd: path.join(dir, prefix),
+ onlyFiles: true,
+ }),
+ )
+ result.sort()
+ return result
} catch {
- return
+ return []
}
}
}