mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 10:14:22 +01:00
fix race
This commit is contained in:
@@ -101,22 +101,6 @@ cli
|
||||
},
|
||||
],
|
||||
});
|
||||
await Session.summarize({
|
||||
sessionID: session.id,
|
||||
providerID,
|
||||
modelID,
|
||||
});
|
||||
await Session.chat({
|
||||
sessionID: session.id,
|
||||
providerID,
|
||||
modelID,
|
||||
parts: [
|
||||
{
|
||||
type: "text",
|
||||
text: "This is a test message",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
for (const part of result.parts) {
|
||||
if (part.type === "text") {
|
||||
|
||||
@@ -110,7 +110,8 @@ export namespace Session {
|
||||
const result = [] as Message.Info[];
|
||||
const list = Storage.list("session/message/" + sessionID);
|
||||
for await (const p of list) {
|
||||
const read = await Storage.readJSON<Message.Info>(p);
|
||||
const read = await Storage.readJSON<Message.Info>(p).catch(() => {});
|
||||
if (!read) continue;
|
||||
result.push(read);
|
||||
}
|
||||
result.sort((a, b) => (a.id > b.id ? 1 : -1));
|
||||
@@ -250,6 +251,7 @@ export namespace Session {
|
||||
tool: {},
|
||||
},
|
||||
};
|
||||
await updateMessage(next);
|
||||
const result = streamText({
|
||||
onStepFinish: async (step) => {
|
||||
const assistant = next.metadata!.assistant!;
|
||||
@@ -266,8 +268,6 @@ export namespace Session {
|
||||
tools,
|
||||
model: model.instance,
|
||||
});
|
||||
|
||||
msgs.push(next);
|
||||
let text: Message.TextPart | undefined;
|
||||
const reader = result.toUIMessageStream().getReader();
|
||||
while (true) {
|
||||
|
||||
Reference in New Issue
Block a user