Skip to content
Open
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
21 changes: 17 additions & 4 deletions packages/opencode/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,30 @@ export namespace Session {
export async function* list() {
const project = Instance.project
for (const item of await Storage.list(["session", project.id])) {
yield Storage.read<Info>(item)
try {
const session = await Storage.read<Info>(item)
if (session && session.id) {
yield session
}
} catch (e) {
log.warn("skipping corrupted session file", { path: item.join("/"), error: e })
}
}
}

export const children = fn(Identifier.schema("session"), async (parentID) => {
const project = Instance.project
const result = [] as Session.Info[]
for (const item of await Storage.list(["session", project.id])) {
const session = await Storage.read<Info>(item)
if (session.parentID !== parentID) continue
result.push(session)
try {
const session = await Storage.read<Info>(item)
if (!session || !session.id) continue
if (session.parentID !== parentID) continue
result.push(session)
} catch (e) {
log.warn("skipping corrupted session file", { path: item.join("/"), error: e })
continue
}
}
return result
})
Expand Down