fix(combo): resolve cross-provider thinking 400 and http clipboard (#1444)

Integrated into release/v3.7.0
This commit is contained in:
diegosouzapw
2026-04-21 04:36:16 -03:00
parent b38e57d452
commit 1d3d99bb9e
3 changed files with 13 additions and 9 deletions

View File

@@ -247,10 +247,16 @@ export function prepareClaudeRequest(
let hasToolUse = false;
let hasThinking = false;
// Always replace signature for all thinking blocks
// Convert thinking blocks to redacted_thinking and replace signature.
// When requests cross provider boundaries (e.g., combo fallback), the
// original thinking signature is invalid for the new provider, causing
// "Invalid signature in thinking block" 400 errors. redacted_thinking
// blocks are accepted without signature validation.
for (const block of content) {
if (block.type === "thinking" || block.type === "redacted_thinking") {
block.type = "redacted_thinking";
block.signature = DEFAULT_THINKING_CLAUDE_SIGNATURE;
delete block.thinking;
hasThinking = true;
}
if (block.type === "tool_use") hasToolUse = true;

View File

@@ -11,13 +11,10 @@
* @returns true if copy succeeded, false otherwise
*/
export async function copyToClipboard(text: string): Promise<boolean> {
// Method 1: Clipboard API (requires HTTPS / secure context)
if (
typeof navigator !== "undefined" &&
navigator.clipboard &&
typeof window !== "undefined" &&
window.isSecureContext
) {
// Method 1: Clipboard API
// Works on HTTPS, localhost (treated as secure context), and some browsers
// even on HTTP. Try unconditionally — the catch handles failures.
if (typeof navigator !== "undefined" && navigator.clipboard) {
try {
await navigator.clipboard.writeText(text);
return true;

View File

@@ -306,9 +306,10 @@ test("claudeHelper validates content, ordering and request preparation branches"
assert.equal(prepared.messages[4].content[0].type, "tool_result");
assert.deepEqual(
prepared.messages[5].content.map((block) => block.type),
["thinking", "text"]
["redacted_thinking", "text"]
);
assert.ok(prepared.messages[5].content[0].signature);
assert.equal(prepared.messages[5].content[0].thinking, undefined);
assert.equal(prepared.tools.length, 2);
assert.equal(prepared.tools[0].cache_control, undefined);
assert.deepEqual(prepared.tools[1].cache_control, { type: "ephemeral", ttl: "1h" });