Skip to content

Commit fd4e931

Browse files
authored
feat: thinking block designs should occupy lesser space (#8685)
* match thinking block style with simple tool call ui * remove reasoning and use thinkingblockpeek instead * resolve comment
1 parent 9b5b7b8 commit fd4e931

File tree

3 files changed

+48
-194
lines changed

3 files changed

+48
-194
lines changed

gui/src/components/StepContainer/Reasoning.tsx

Lines changed: 0 additions & 138 deletions
This file was deleted.

gui/src/components/StepContainer/StepContainer.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { useDispatch } from "react-redux";
55
import { useAppSelector } from "../../redux/hooks";
66
import { selectUIConfig } from "../../redux/slices/configSlice";
77
import { deleteMessage } from "../../redux/slices/sessionSlice";
8+
import ThinkingBlockPeek from "../mainInput/belowMainInput/ThinkingBlockPeek";
89
import StyledMarkdownPreview from "../StyledMarkdownPreview";
910
import ConversationSummary from "./ConversationSummary";
10-
import Reasoning from "./Reasoning";
1111
import ResponseActions from "./ResponseActions";
1212
import ThinkingIndicator from "./ThinkingIndicator";
1313

@@ -85,7 +85,14 @@ export default function StepContainer(props: StepContainerProps) {
8585
</pre>
8686
) : (
8787
<>
88-
<Reasoning {...props} />
88+
{props.item.reasoning?.text && (
89+
<ThinkingBlockPeek
90+
content={props.item.reasoning.text}
91+
index={props.index}
92+
prevItem={props.index > 0 ? props.item : null}
93+
inProgress={!props.item.reasoning?.endAt}
94+
/>
95+
)}
8996

9097
<StyledMarkdownPreview
9198
isRenderingInStepContainer

gui/src/components/mainInput/belowMainInput/ThinkingBlockPeek.tsx

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,8 @@ import { ChatHistoryItem } from "core";
55
import { useEffect, useState } from "react";
66
import styled from "styled-components";
77

8-
import { vscBackground } from "../..";
98
import { AnimatedEllipsis } from "../../AnimatedEllipsis";
109
import StyledMarkdownPreview from "../../StyledMarkdownPreview";
11-
import { ButtonContent, SpoilerButton } from "../../ui/SpoilerButton";
12-
13-
const ThinkingTextContainer = styled.span`
14-
display: inline-block;
15-
min-width: fit-content;
16-
17-
padding-right: 1em; /* Reserve space for the ellipsis animation */
18-
`;
1910

2011
const MarkdownWrapper = styled.div`
2112
& > div > *:first-child {
@@ -39,7 +30,6 @@ function ThinkingBlockPeek({
3930
index,
4031
prevItem,
4132
inProgress,
42-
signature,
4333
tokens,
4434
}: ThinkingBlockPeekProps) {
4535
const [open, setOpen] = useState(false);
@@ -66,58 +56,53 @@ function ThinkingBlockPeek({
6656

6757
return duplicateRedactedThinkingBlock ? null : (
6858
<div className="thread-message">
69-
<div className="" style={{ backgroundColor: vscBackground }}>
70-
<div
71-
className="flex items-center justify-start pl-2 text-xs text-gray-300"
72-
data-testid="thinking-block-peek"
73-
>
74-
<SpoilerButton onClick={() => setOpen(!open)}>
75-
<ButtonContent>
76-
{inProgress ? (
77-
<span>
78-
{redactedThinking ? "Redacted Thinking" : "Thinking"}
79-
<AnimatedEllipsis />
80-
</span>
81-
) : redactedThinking ? (
82-
"Redacted Thinking"
83-
) : (
84-
"Thought" +
85-
(elapsedTime ? ` for ${elapsedTime}` : "") +
86-
(tokens ? ` (${tokens} tokens)` : "")
87-
)}
88-
{open ? (
89-
<ChevronUpIcon className="h-3 w-3" />
90-
) : (
91-
<ChevronDownIcon className="h-3 w-3" />
92-
)}
93-
</ButtonContent>
94-
</SpoilerButton>
59+
<div className="mt-1 flex flex-col px-4">
60+
<div className="flex min-w-0 flex-row items-center justify-between gap-2">
61+
<button
62+
type="button"
63+
className="text-description flex min-w-0 cursor-pointer flex-row items-center gap-1.5 text-xs transition-colors duration-200 ease-in-out hover:brightness-125"
64+
data-testid="thinking-block-peek"
65+
aria-expanded={open}
66+
aria-controls={`thinking-block-content-${index}`}
67+
onClick={() => setOpen(!open)}
68+
>
69+
{inProgress ? (
70+
<span>
71+
{redactedThinking ? "Redacted Thinking" : "Thinking"}
72+
<AnimatedEllipsis />
73+
</span>
74+
) : redactedThinking ? (
75+
"Redacted Thinking"
76+
) : (
77+
"Thought" +
78+
(elapsedTime ? ` for ${elapsedTime}` : "") +
79+
(tokens ? ` (${tokens} tokens)` : "")
80+
)}
81+
{open ? (
82+
<ChevronUpIcon className="h-3 w-3" />
83+
) : (
84+
<ChevronDownIcon className="h-3 w-3" />
85+
)}
86+
</button>
9587
</div>
9688
<div
97-
className={`ml-2 mt-2 overflow-y-auto transition-none duration-300 ease-in-out ${
98-
open ? "mb-2 mt-5 opacity-100" : "max-h-0 border-0 opacity-0"
89+
id={`thinking-block-content-${index}`}
90+
className={`mt-2 overflow-y-auto transition-all duration-300 ease-in-out ${
91+
open ? "max-h-[50vh] opacity-100" : "max-h-0 opacity-0"
9992
}`}
100-
style={{
101-
borderLeft:
102-
open && !redactedThinking
103-
? "2px solid var(--vscode-input-border, #606060)"
104-
: "none",
105-
}}
10693
>
10794
{redactedThinking ? (
108-
<div className="text-description-muted pl-4 text-xs">
95+
<div className="text-description pl-5 text-xs italic">
10996
Thinking content redacted due to safety reasons.
11097
</div>
11198
) : (
112-
<>
113-
<MarkdownWrapper className="-mt-1 px-0 pl-1">
114-
<StyledMarkdownPreview
115-
isRenderingInStepContainer
116-
source={content}
117-
itemIndex={index}
118-
/>
119-
</MarkdownWrapper>
120-
</>
99+
<MarkdownWrapper>
100+
<StyledMarkdownPreview
101+
isRenderingInStepContainer
102+
source={content}
103+
itemIndex={index}
104+
/>
105+
</MarkdownWrapper>
121106
)}
122107
</div>
123108
</div>

0 commit comments

Comments
 (0)