refactor(chatCore): extrai resolução de endpoint/formato para leaf puro (#3501) - #4507
diegosouzapw merged 2 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Code Review
This pull request refactors open-sse/handlers/chatCore.ts by extracting the endpoint and format resolution logic into a new module open-sse/handlers/chatCore/requestFormat.ts and adding corresponding unit tests. Feedback is provided to improve type safety by replacing an unsafe type assertion with the standard headers.entries() method when iterating over headers.
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.
| if (headers instanceof Headers) { | ||
| for (const [key, value] of headers as unknown as Iterable<[string, string]>) { | ||
| if (isMatch(key) || isMatch(value)) return true; | ||
| } | ||
| } else if (headers && typeof headers === "object") { |
There was a problem hiding this comment.
Instead of using an unsafe type assertion (as unknown as Iterable<[string, string]>), you can use the standard headers.entries() method which returns an IterableIterator<[string, string]>. This is fully type-safe and cleaner.
if (headers instanceof Headers) {
for (const [key, value] of headers.entries()) {
if (isMatch(key) || isMatch(value)) return true;
}
}67df544 to
c0fd352
Compare
…ro (#3501) Move o bloco de resolução de formato do topo de handleChatCore (endpointPath / sourceFormat / isResponsesEndpoint / nativeCodexPassthrough / isDroidCLI / copilotCompatibleReasoning / clientResponseFormat) para o novo leaf puro open-sse/handlers/chatCore/requestFormat.ts (resolveChatCoreRequestFormat), ao lado de resolveChatCoreRequestSetup (fase de request-setup). O handler agora desestrutura o resultado, então todo uso downstream fica byte-idêntico. A função local isCopilotClient (usada só por esse bloco) vira helper privado do leaf; o import órfão detectFormatFromEndpoint migra junto (getTargetFormat permanece no import de provider). shouldUseNativeCodexPassthrough e FORMATS seguem importados no handler (re-exportado / usado em vários pontos). chatCore.ts 5019->4993 (shrink -26, cruza abaixo de 5000); baseline file-size ratchetado. complexity 1905=1905 (neutro). Coberto por tests/unit/chatcore-request-format.test.ts (7 casos, incluindo o downgrade OpenAI-Responses->OpenAI e sua supressão pelo Droid CLI).
c0fd352 to
ac7779e
Compare
…ves orphaned from release by churn (diegosouzapw#3501) (diegosouzapw#4547) Re-applies the endpoint/format (requestFormat.ts, diegosouzapw#4507) and Claude effort-variant (claudeEffortVariant.ts, diegosouzapw#4511) extractions that were orphaned from release/v3.8.33 by a parallel force-push. 19/19 chatCore tests pass. Integrated into release/v3.8.33.
O quê
Próximo incremento da decomposição do god-file
chatCore.ts(QG v2 Fase 9 T5, #3501). Move o bloco de resolução de endpoint/formato do topo dehandleChatCorepara o novo leaf puroopen-sse/handlers/chatCore/requestFormat.ts(resolveChatCoreRequestFormat), ao lado deresolveChatCoreRequestSetup(fase de request-setup).Como (preservação de comportamento)
endpointPath/sourceFormat/isResponsesEndpoint/nativeCodexPassthrough/isDroidCLI/copilotCompatibleReasoning/clientResponseFormat) movem byte-idênticos para o leaf puro; o handler desestrutura o resultado, então todo uso downstream fica inalterado.isCopilotClient(usada só por esse bloco) vira helper privado do leaf.detectFormatFromEndpointmigra para o leaf (getTargetFormatpermanece no import deprovider.ts).shouldUseNativeCodexPassthrougheFORMATSseguem no handler (re-exportado / usado em 26 pontos).ReturnType<typeof resolveChatCoreRequestFormat>(sem anotação manual divergente).Gates
chatCore.ts5019→4993 (shrink −26, cruza abaixo de 5000); baseline ratchetado.tests/unit/chatcore-request-format.test.ts— 7 casos (incl. o downgradeOpenAI-Responses → OpenAIquando a forma Responses chega por endpoint não-/responsese não-Droid, e a supressão desse downgrade pelo Droid CLI; delegação donativeCodexPassthrough; detecção Copilot por header/UA).chatcore-imports-cleanly✓ + 207/207 na suíte chatcore +sse-auth(excluído só otranslation-pathsflaky pré-existente).Extração de god-file sem mudança de comportamento em runtime.