From 83b2dfd08e5353bb461e930c0ff262db54883991 Mon Sep 17 00:00:00 2001 From: Unsloth Date: Fri, 29 May 2026 02:38:11 -0700 Subject: [PATCH] studio: sync compare-composer reasoning state and harden compare id - Compare composer: keep "Preserve thinking" consistent with reasoning, matching the main composer. Enabling it now turns reasoning on, and disabling reasoning (the None option or the Thinking toggle) turns it off, so the invalid "preserve on while thinking off" state can't occur. - Guard crypto.randomUUID in the Compare action. It is undefined in non-secure contexts (HTTP over a LAN IP) and would throw; fall back to a timestamped random id, matching createNavigationNonce. --- .../frontend/src/components/assistant-ui/thread.tsx | 7 ++++++- .../frontend/src/features/chat/shared-composer.tsx | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx index c33ec403f4..85989b1a41 100644 --- a/studio/frontend/src/components/assistant-ui/thread.tsx +++ b/studio/frontend/src/components/assistant-ui/thread.tsx @@ -1315,7 +1315,12 @@ const ComposerToolsMenu: FC<{ side?: "top" | "bottom" }> = ({ const store = useChatRuntimeStore.getState(); store.setActiveThreadId(null); store.setContextUsage(null); - navigate({ to: "/chat", search: { compare: crypto.randomUUID() } }); + // crypto.randomUUID is undefined in non-secure contexts (HTTP over a LAN IP). + const compareId = + typeof globalThis.crypto?.randomUUID === "function" + ? globalThis.crypto.randomUUID() + : `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`; + navigate({ to: "/chat", search: { compare: compareId } }); }, [navigate]); return ( diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx index e7dbe94d95..01a6a27b2d 100644 --- a/studio/frontend/src/features/chat/shared-composer.tsx +++ b/studio/frontend/src/features/chat/shared-composer.tsx @@ -1038,6 +1038,8 @@ export function SharedComposer({ onSelect={() => { setReasoningEnabled(false); applyQwenThinkingParams(false); + // Preserve thinking needs thinking on, so turn it off too. + setPreserveThinking(false); }} > { e.preventDefault(); - setPreserveThinking(!preserveThinking); + const next = !preserveThinking; + setPreserveThinking(next); + // Preserve thinking requires thinking on. + if (next) { + setReasoningEnabled(true); + applyQwenThinkingParams(true); + } }} >