fix: --continue pull the latest session id consistently (#918)
Some checks are pending
deploy / deploy (push) Waiting to run
publish / publish (push) Waiting to run

Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
Jase Kraft 2025-07-14 19:32:00 -05:00 committed by GitHub
parent 1cf1d1f634
commit 294a11752e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 14 deletions

View file

@ -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

View file

@ -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 []
}
}
}