diff options
| author | Dax Raad <[email protected]> | 2025-05-26 13:21:15 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-26 13:21:15 -0400 |
| commit | 2ed17f4877478e20022a0d68bb9f6e3b4f726bb1 (patch) | |
| tree | e6cd5777a13edf3f655960e5820699fce1d86dee /js/src/session | |
| parent | 80118212da3ce16babdee035974a67fa2f2b8ed9 (diff) | |
| download | opencode-2ed17f4877478e20022a0d68bb9f6e3b4f726bb1.tar.gz opencode-2ed17f4877478e20022a0d68bb9f6e3b4f726bb1.zip | |
exit properly
Diffstat (limited to 'js/src/session')
| -rw-r--r-- | js/src/session/session.ts | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/js/src/session/session.ts b/js/src/session/session.ts index 33add33fa..80812f697 100644 --- a/js/src/session/session.ts +++ b/js/src/session/session.ts @@ -100,15 +100,9 @@ export namespace Session { return match; } const result = [] as Message[]; - const list = await Storage.list("session/message/" + sessionID) - .then((x) => x.toArray()) - .catch(() => {}); - if (!list) return result; - for (const item of list) { - const messageID = path.basename(item.path, ".json"); - const read = await Storage.readJSON<Message>( - "session/message/" + sessionID + "/" + messageID, - ); + const list = Storage.list("session/message/" + sessionID); + for await (const p of list) { + const read = await Storage.readJSON<Message>(p); result.push(read); } state().messages.set(sessionID, result); @@ -116,13 +110,8 @@ export namespace Session { } export async function* list() { - try { - const result = await Storage.list("session/info"); - for await (const item of result) { - yield path.basename(item.path, ".json"); - } - } catch { - return; + for await (const item of Storage.list("session/info")) { + yield path.basename(item, ".json"); } } @@ -272,6 +261,7 @@ export namespace Session { session.tokens.input += usage.inputTokens || 0; session.tokens.output += usage.outputTokens || 0; session.tokens.reasoning += usage.reasoningTokens || 0; + console.log(session); await update(session); return next; } |
