From f3d532afd971e998ee7f72fcfc8a2940ff735ff4 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Thu, 12 Feb 2026 01:06:33 +0700 Subject: [PATCH] fix(cursor): address remaining LOW review items in protobuf module --- src/cursor/cursor-executor.ts | 2 ++ src/cursor/cursor-protobuf-decoder.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/cursor/cursor-executor.ts b/src/cursor/cursor-executor.ts index 9f166f7b..72e299a6 100644 --- a/src/cursor/cursor-executor.ts +++ b/src/cursor/cursor-executor.ts @@ -83,6 +83,7 @@ async function getHttp2() { /** * Decompress payload if needed + * NOTE: Uses synchronous gzip for single-request CLI tool. Async not warranted for small payloads. */ function decompressPayload(payload: Buffer, flags: number): Buffer { // Check if payload is JSON error @@ -556,6 +557,7 @@ export class CursorExecutor { transformProtobufToSSE(buffer: Buffer, model: string, _body: ExecutorParams['body']): Response { // TODO: Implement true streaming — currently buffers entire response before transforming. // This should pipe HTTP/2 data events through a TransformStream for incremental SSE output. + // NOTE: Chunk boundary splits may emit duplicate SSE messages if a frame spans multiple chunks. const responseId = `chatcmpl-cursor-${Date.now()}`; const created = Math.floor(Date.now() / 1000); diff --git a/src/cursor/cursor-protobuf-decoder.ts b/src/cursor/cursor-protobuf-decoder.ts index bf0af3d4..6111dd19 100644 --- a/src/cursor/cursor-protobuf-decoder.ts +++ b/src/cursor/cursor-protobuf-decoder.ts @@ -83,6 +83,7 @@ export function decodeMessage( const fields = new Map>(); let pos = 0; + // NOTE: If two fields share the same field number but different wire types, later values overwrite earlier ones. while (pos < data.length) { const [fieldNum, wireType, value, newPos] = decodeField(data, pos); if (fieldNum === null || wireType === null || value === null) break;