diff --git a/gui/src/components/mainInput/ThinkingBlockPeek.tsx b/gui/src/components/mainInput/ThinkingBlockPeek.tsx new file mode 100644 index 000000000..969b67606 --- /dev/null +++ b/gui/src/components/mainInput/ThinkingBlockPeek.tsx @@ -0,0 +1,100 @@ +// src/components/ThinkingBlockPeek.tsx +import { + ChevronDownIcon, + ChevronRightIcon, + LightBulbIcon, +} from "@heroicons/react/24/outline"; +import { ChatHistoryItem } from "core"; +import { useState } from "react"; +import styled from "styled-components"; +import { lightGray, vscBackground } from ".."; +import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; + +const MarkdownWrapper = styled.div` + & > div > *:first-child { + margin-top: 0 !important; + } +`; + +interface ThinkingBlockPeekProps { + content: string; + redactedThinking?: string; + index: number; + prevItem: ChatHistoryItem | null; + signature?: string; +} + +function ThinkingBlockPeek({ + content, + redactedThinking, + index, + prevItem, + signature, +}: ThinkingBlockPeekProps) { + const [open, setOpen] = useState(false); + + const duplicateRedactedThinkingBlock = + prevItem && + prevItem.message.role === "thinking" && + redactedThinking && + prevItem.message.redactedThinking; + + return duplicateRedactedThinkingBlock ? null : ( +
+
+
setOpen((prev) => !prev)} + data-testid="thinking-block-peek" + > +
+ + +
+ + + {redactedThinking ? "Redacted Thinking" : "AI Reasoning"} + +
+ +
+ {redactedThinking ? ( +
+ Thinking content redacted due to safety reasons. +
+ ) : ( + <> + + + + + )} +
+
+
+ ); +} + +export default ThinkingBlockPeek; diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 51c164799..a5fb7481a 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -7,7 +7,7 @@ import { import { Editor, JSONContent } from "@tiptap/react"; import { InputModifiers, RangeInFileWithContents, ToolCallState } from "core"; import { streamResponse } from "core/llm/stream"; -import { stripImages } from "core/util/messageContent"; +import { renderChatMessage, stripImages } from "core/util/messageContent"; import { usePostHog } from "posthog-js/react"; import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { ErrorBoundary } from "react-error-boundary"; @@ -28,6 +28,7 @@ import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks"; import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; import { NewSessionButton } from "../../components/mainInput/NewSessionButton"; import resolveEditorContent from "../../components/mainInput/resolveInput"; +import ThinkingBlockPeek from "../../components/mainInput/ThinkingBlockPeek"; import { TutorialCard } from "../../components/mainInput/TutorialCard"; import AssistantSelect from "../../components/modelSelection/platform/AssistantSelect"; import { @@ -448,6 +449,14 @@ export function Chat() { ); })} + ) : item.message.role === "thinking" ? ( + 0 ? history[index - 1] : null} + signature={item.message.signature} + /> ) : (