Conversation
There was a problem hiding this comment.
Code Review
This pull request modularizes the SSE streaming utility code by splitting it into several smaller files under open-sse/utils/stream/. The review feedback highlights critical correctness issues across multiple files due to missing imports and undefined references (such as FORMATS, initState, and FETCH_BODY_TIMEOUT_MS) that will cause compilation and runtime failures. Additionally, the reviewer pointed out a repository style guide violation for not including tests with these production code changes, as well as several instances of unused imports that should be cleaned up.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| * @param {object} options.body - Request body (for input token estimation) | ||
| * @param {function} options.onComplete - Callback when stream finishes: ({ status, usage }) => void | ||
| */ | ||
| export function createSSEStream(options: StreamOptions = {}) { |
There was a problem hiding this comment.
Critical Correctness Issue: Missing Imports and Undefined References
During the modularization of stream.ts, several essential constants, helper functions, and external dependencies were not imported or defined in streamCore.ts. This will cause the file to fail compilation and crash at runtime.
Please ensure the following are properly imported or defined:
- Constants/Enums:
FORMATS,STREAM_IDLE_TIMEOUT_MS,HTTP_STATUS,OMIT_STREAMING_CHUNK_MARKER - Functions:
initState,generateSessionId,consumeToolFinishTime,parseTextualToolCallCandidate,formatSSE,sanitizeStreamingChunk,extractThinkingFromContent,estimateUsage,filterUsageForFormat,addBufferToUsage,calculateCost,buildOmniRouteSseMetadataComment,trackPendingRequest,appendRequestLog,parseSSELine,extractUsage,fixInvalidId,recordToolLatency,markToolFinish,unwrapGeminiChunk,translateResponse,buildErrorBody,logUsage,buildStreamSummaryFromEvents
| onFailure?: ((payload: StreamFailurePayload) => void | Promise<void>) | null; | ||
| }; | ||
|
|
||
| export type TranslateState = ReturnType<typeof initState> & { |
| import { JsonRecord, ToolCall } from "./types.ts"; | ||
|
|
||
| export function parseTextualToolCallFromContent(text: unknown): { name: string; args: unknown } | null { | ||
| const candidate = parseTextualToolCallCandidate(text); |
There was a problem hiding this comment.
| */ | ||
| export function withBodyTimeout<T>( | ||
| promise: Promise<T>, | ||
| timeoutMs: number = FETCH_BODY_TIMEOUT_MS |
| @@ -0,0 +1,9 @@ | |||
| export * from "./types.ts"; | |||
There was a problem hiding this comment.
Style Guide Violation: Missing Tests for Production Code Changes
This PR modularizes production code under open-sse/utils/stream/ but does not include any new or updated unit/integration tests. This violates Rule 9 of the Repository Style Guide.
Please add appropriate tests under the tests/ directory to cover the new modularized stream logic.
References
- Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | ||
| import { v4 as uuidv4 } from "uuid"; | ||
|
|
||
| import { asRecord } from "./utils.ts"; | ||
| import { JsonRecord, ToolCall } from "./types.ts"; |
There was a problem hiding this comment.
Maintainability: Unused Imports
The imports convertOpenAIToResponsesToolCall and uuidv4 are completely unused in this file and should be removed to keep the codebase clean.
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | |
| import { v4 as uuidv4 } from "uuid"; | |
| import { asRecord } from "./utils.ts"; | |
| import { JsonRecord, ToolCall } from "./types.ts"; | |
| import { asRecord } from "./utils.ts"; | |
| import { JsonRecord, ToolCall } from "./types.ts"; |
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | ||
| import { v4 as uuidv4 } from "uuid"; | ||
|
|
||
| import { asRecord } from "./utils.ts"; | ||
| import { JsonRecord, ToolCall } from "./types.ts"; |
There was a problem hiding this comment.
Maintainability: Unused Imports
The imports convertOpenAIToResponsesToolCall and uuidv4 are completely unused in this file and should be removed to keep the codebase clean.
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | |
| import { v4 as uuidv4 } from "uuid"; | |
| import { asRecord } from "./utils.ts"; | |
| import { JsonRecord, ToolCall } from "./types.ts"; | |
| import { asRecord } from "./utils.ts"; | |
| import { JsonRecord, ToolCall } from "./types.ts"; |
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | ||
| import { v4 as uuidv4 } from "uuid"; | ||
|
|
||
|
|
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | ||
| import { v4 as uuidv4 } from "uuid"; | ||
|
|
||
| import { createSSEStream } from "./streamCore.ts"; | ||
| import { JsonRecord } from "./types.ts"; |
There was a problem hiding this comment.
Maintainability: Unused Imports
The imports convertOpenAIToResponsesToolCall, uuidv4, and createSSEStream are completely unused in this file and should be removed to keep the codebase clean.
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | |
| import { v4 as uuidv4 } from "uuid"; | |
| import { createSSEStream } from "./streamCore.ts"; | |
| import { JsonRecord } from "./types.ts"; | |
| import { JsonRecord } from "./types.ts"; |
| import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts"; | ||
| import { v4 as uuidv4 } from "uuid"; | ||
|
|
…d docs audit report - README advertised a stale '177 providers'; the canonical generator (gen-provider-reference.ts) reports 226 unique provider IDs. Updated the README badges/anchors/heading and regenerated docs/reference/PROVIDER_REFERENCE.md (223→226) to match the source of truth. - Adds DOCUMENTATION_AUDIT_REPORT.md (docs/i18n sync audit + plan). Docs-only; carried over from in-progress working-tree changes and verified against the generator.
…iegosouzapw#3894) Document the real pipeline (Session-Dedup, CCR, RTK, Headroom, Caveman, LLMLingua-2, Lite, Aggressive, Ultra) that replaced the old RTK+Caveman framing; presets table kept. '7 options' -> '9 engines'.
…root (diegosouzapw#3896) Move the committed quality-gate state files out of the repo root into config/quality/ and the v3.8.24 documentation audit into docs/ops/, then re-point every gate script, test and .gitignore entry at the new paths. Refresh docs/architecture/REPOSITORY_MAP.md (stale since v3.8.2) to match the current layout. Moved -> config/quality/: quality-baseline.json, complexity-baseline.json, duplication-baseline.json, file-size-baseline.json, test-discovery-baseline.json, dependency-allowlist.json, .license-allowlist.json (generated quality-metrics.json now written here too; still gitignored) Moved -> docs/ops/: DOCUMENTATION_AUDIT_REPORT.md (+ meta.json entry + fabricated-docs skip) Path updates: check-{complexity,duplication,file-size,test-discovery,deps, licenses,dead-code,cognitive-complexity,type-coverage}.mjs, check-quality- ratchet.mjs, collect-metrics.mjs, check-tracked-artifacts.mjs (+ its test and check-deps test). Also gitignore /logs/ (was untracked-not-ignored). Tracked root files: 56 -> 48. Tool configs left in root on purpose: most are auto-discovered there, and the tsconfig variants have location-relative files:[] arrays that would need 46 path rewrites for a 2-file gain.
diegosouzapw#3900) The wiki has no native generator and drifts each release — it lacked SUPPLY_CHAIN plus 24 other docs pages, and the cover counts went stale (212+/14/37 vs 226/15/87). Adds: - scripts/docs/sync-wiki.mjs — adds docs/ pages missing from the wiki (curated; internal reports/plans/index excluded) and syncs the four Home.md cover counts. Matches the hand-curated, non-deterministic wiki page names by a normalized fuzzy key and writes the EXISTING name, so it never creates duplicate pages. Overwriting existing-page content is opt-in (--update-existing) and intentionally OFF by default: several docs sources still carry stale counts (e.g. ARCHITECTURE.md says "177 providers / 37 MCP tools" while the wiki cover is 226/87), so a blind overwrite would REGRESS the wiki. Full parity is gated on regenerating those sources — see docs/ops/DOCUMENTATION_AUDIT_REPORT.md. - .github/workflows/wiki-sync.yml — runs the sync on every push to main that touches docs/ (or a count source) + workflow_dispatch, pushing via GITHUB_TOKEN. - tests/unit/sync-wiki.test.ts — pure-function coverage (8 tests). The first run already pushed the 25 missing pages to the wiki.
Integrated into release/v3.8.26
Integrated into release/v3.8.26
Integrated into release/v3.8.26
…apw#3885) Integrated into release/v3.8.26
…sing (diegosouzapw#3887) Integrated into release/v3.8.26
Integrated into release/v3.8.26
- extracted types, utils, responsesLifecycle, textualToolCalls, sseFormatters, errors, claudeLifecycle, openaiChunks, and streamCore to domain files - stream.ts is now a facade re-exporting modules
… fix ctx.* object key prefixes in streamCore.ts
…mCore.ts and stream.ts - Restore working stream.ts from release/v3.8.26 (2584 lines) - Keep modular stream/ directory for future incremental PRs - Update file-size-baseline.json: streamCore.ts 2212, stream.ts 2584 - All tests pass: 49/49 stream-utils, 14/14 stream-handler - Typecheck, lint, cycles, file-size: all clean
Clean re-cut of PR #3651 — modularizes
open-sse/utils/stream.ts(2709→9 lines) intoopen-sse/utils/stream/with 10 focused modules.Cherry-picked only the modularization commit (
b9ed863b9) onto currentrelease/v3.8.24. No stacked dependencies, no unrelated changes.New modules:
streamCore.ts— SSE parsing, streaming logic (1947 lines)claudeLifecycle.ts— Claude message lifecycle handlingresponsesLifecycle.ts— Responses API lifecyclesseFormatters.ts— SSE event formattingerrors.ts— Stream error typesopenaiChunks.ts— OpenAI chunk formattextualToolCalls.ts— Text-based tool call handlingtypes.ts— Stream typesutils.ts— Stream utilitiesindex.ts— Public API re-exports