perf: optimize message loading based on streaming state

Decreased message limit to 90 for historical views when not streaming.
Add fetch buffer to preload additional messages for efficient syncing.
This commit is contained in:
Bohdan Triapitsyn
2026-01-17 02:32:22 +02:00
parent 195355ae8b
commit 8a3e432dd0
4 changed files with 31 additions and 21 deletions
+3 -2
View File
@@ -354,10 +354,11 @@ class OpencodeService {
return response.data;
}
async getSessionMessages(id: string): Promise<{ info: Message; parts: Part[] }[]> {
async getSessionMessages(id: string, limit?: number): Promise<{ info: Message; parts: Part[] }[]> {
const response = await this.client.session.messages({
sessionID: id,
...(this.currentDirectory ? { directory: this.currentDirectory } : {})
...(this.currentDirectory ? { directory: this.currentDirectory } : {}),
...(typeof limit === 'number' ? { limit } : {}),
});
return response.data || [];
}