Files
OmniRoute/open-sse/services/claudeCodeCompatibleThinkingDisplay.ts
Randi f7e5d2c268 feat(cc): add summarized thinking display toggle (#5055)
Integrated into release/v3.8.38 (leva 5)
2026-06-26 11:18:22 -03:00

35 lines
978 B
TypeScript

const COPILOT_REASONING_SUMMARY_MARKER = "_omnirouteCopilotReasoningSummary";
export function applyClaudeCodeCompatibleThinkingDisplay(
thinking: Record<string, unknown>,
options: {
normalizedBody?: Record<string, unknown> | null;
summarizeThinking?: boolean;
} = {}
) {
if (thinking.type === "disabled") {
return thinking;
}
const markerRequestsSummary =
options.normalizedBody?.[COPILOT_REASONING_SUMMARY_MARKER] === "summarized";
const connectionRequestsSummary = options.summarizeThinking === true;
if (!markerRequestsSummary && !connectionRequestsSummary) {
return thinking;
}
const hasExplicitDisplay =
Object.prototype.hasOwnProperty.call(thinking, "display") &&
thinking.display !== undefined &&
thinking.display !== null &&
String(thinking.display).trim().length > 0;
if (hasExplicitDisplay && !markerRequestsSummary) {
return thinking;
}
return {
...thinking,
display: "summarized",
};
}