Bound serialized Chrome transcript bytes in IDE beta 8

This commit is contained in:
yilsem committed 2026-09-07 13:11:31 +03:00
1 parent 57876d11f0
commit fa63e03eb7
4 files changed
+25 -4

No files matched your search

+12 -2
View File
@@ -12,13 +12,23 @@ const contentText = value => typeof value === 'string' ? value : Array.isArray(v
? value.filter(part => part?.type === 'text').map(part => part.text || '').join('\n') : ''
export function publicMessages(rows) {
return (Array.isArray(rows) ? rows : []).filter(row =>
const messages = (Array.isArray(rows) ? rows : []).filter(row =>
['user', 'assistant'].includes(row.role) && row.display_kind !== 'hidden'
).slice(-40).map(row => ({
id: row.id ?? row.row_id,
id: typeof (row.id ?? row.row_id) === 'number' ? (row.id ?? row.row_id) : undefined,
role: row.role,
text: clip(contentText(row.display_content ?? row.content ?? row.text)),
}))
// The Chrome native limit counts UTF-8 JSON bytes, not JS characters.
// Reserve room for the opening response's in-flight text and metadata;
// escaped controls and CJK text must not disconnect a large transcript.
const messageBudget = Math.floor((MAX_FRAME - 128000) / Math.max(1, messages.length))
for (const message of messages) {
while (Buffer.byteLength(JSON.stringify(message)) > messageBudget) {
message.text = message.text.slice(0, Math.floor(message.text.length * 0.8))
}
}
return messages
}
export function validateRequest(message) {
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "aiturk-ide",
"productName": "AITURK IDE",
"private": true,
"version": "1.0.0-beta.7",
"version": "1.0.0-beta.8",
"description": "TurkServis resmi yapay zekâ geliştirme ortamı. Hermes Agent tabanlıdır.",
"author": "AITURK / TurkServis",
"repository": {