-
Notifications
You must be signed in to change notification settings - Fork 2.7k
ux: Collapse thinking blocks by default (but control all of them with a keyboard shortcut) #8254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e42dbe9
feat: Add collapsed/expanded states to ReasoningBlock
roomote 164d732
feat: Add global setting and keyboard shortcut for reasoning blocks
roomote fb0c262
Simpler collapsed state, improvements to 'Roo said' blocks which help…
brunobergher 16a00ae
Switches the keyboard shortcut to be a proper, global, customizable one
brunobergher 08b0680
Roo has the need to comment on everything
brunobergher 20413b1
feat: add missing translations for toggleThinkingBlocks and newTaskRe…
brunobergher da3717b
Final twaks
brunobergher 77db77d
Update webview-ui/src/i18n/locales/it/chat.json
brunobergher 02e158e
Update webview-ui/src/i18n/locales/zh-CN/chat.json
brunobergher c41a8e9
Fix trailing comma
mrubens 4f576e6
Visual fixes
brunobergher a917cd0
Makes collapsed default a setting in a new 'UI' tab in settings; remo…
brunobergher c1a6afd
i18n fixes
brunobergher acd8333
More i18n fixes
brunobergher 59c0c22
Merge conflict fixes
brunobergher 285ced2
Merge remote-tracking branch 'origin/main' into feature/collapse-thin…
mrubens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { HTMLAttributes } from "react" | ||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||
| import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" | ||
| import { Glasses } from "lucide-react" | ||
| import { telemetryClient } from "@/utils/TelemetryClient" | ||
|
|
||
| import { SetCachedStateField } from "./types" | ||
| import { SectionHeader } from "./SectionHeader" | ||
| import { Section } from "./Section" | ||
| import { ExtensionStateContextType } from "@/context/ExtensionStateContext" | ||
|
|
||
| interface UISettingsProps extends HTMLAttributes<HTMLDivElement> { | ||
| reasoningBlockCollapsed: boolean | ||
| setCachedStateField: SetCachedStateField<keyof ExtensionStateContextType> | ||
| } | ||
|
|
||
| export const UISettings = ({ reasoningBlockCollapsed, setCachedStateField, ...props }: UISettingsProps) => { | ||
| const { t } = useAppTranslation() | ||
|
|
||
| const handleReasoningBlockCollapsedChange = (value: boolean) => { | ||
| setCachedStateField("reasoningBlockCollapsed", value) | ||
|
|
||
| // Track telemetry event | ||
| telemetryClient.capture("ui_settings_collapse_thinking_changed", { | ||
| enabled: value, | ||
| }) | ||
| } | ||
|
|
||
| return ( | ||
| <div {...props}> | ||
| <SectionHeader> | ||
| <div className="flex items-center gap-2"> | ||
| <Glasses className="w-4" /> | ||
| <div>{t("settings:sections.ui")}</div> | ||
| </div> | ||
| </SectionHeader> | ||
|
|
||
| <Section> | ||
| <div className="space-y-6"> | ||
| {/* Collapse Thinking Messages Setting */} | ||
| <div className="flex flex-col gap-1"> | ||
| <VSCodeCheckbox | ||
| checked={reasoningBlockCollapsed} | ||
| onChange={(e: any) => handleReasoningBlockCollapsedChange(e.target.checked)} | ||
| data-testid="collapse-thinking-checkbox"> | ||
| <span className="font-medium">{t("settings:ui.collapseThinking.label")}</span> | ||
| </VSCodeCheckbox> | ||
| <div className="text-vscode-descriptionForeground text-sm ml-5 mt-1"> | ||
| {t("settings:ui.collapseThinking.description")} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </Section> | ||
| </div> | ||
| ) | ||
| } |
43 changes: 43 additions & 0 deletions
43
webview-ui/src/components/settings/__tests__/UISettings.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { render, fireEvent, waitFor } from "@testing-library/react" | ||
| import { describe, it, expect, vi } from "vitest" | ||
| import { UISettings } from "../UISettings" | ||
|
|
||
| describe("UISettings", () => { | ||
| const defaultProps = { | ||
| reasoningBlockCollapsed: false, | ||
| setCachedStateField: vi.fn(), | ||
| } | ||
|
|
||
| it("renders the collapse thinking checkbox", () => { | ||
| const { getByTestId } = render(<UISettings {...defaultProps} />) | ||
| const checkbox = getByTestId("collapse-thinking-checkbox") | ||
| expect(checkbox).toBeTruthy() | ||
| }) | ||
|
|
||
| it("displays the correct initial state", () => { | ||
| const { getByTestId } = render(<UISettings {...defaultProps} reasoningBlockCollapsed={true} />) | ||
| const checkbox = getByTestId("collapse-thinking-checkbox") as HTMLInputElement | ||
| expect(checkbox.checked).toBe(true) | ||
| }) | ||
|
|
||
| it("calls setCachedStateField when checkbox is toggled", async () => { | ||
| const setCachedStateField = vi.fn() | ||
| const { getByTestId } = render(<UISettings {...defaultProps} setCachedStateField={setCachedStateField} />) | ||
|
|
||
| const checkbox = getByTestId("collapse-thinking-checkbox") | ||
| fireEvent.click(checkbox) | ||
|
|
||
| await waitFor(() => { | ||
| expect(setCachedStateField).toHaveBeenCalledWith("reasoningBlockCollapsed", true) | ||
| }) | ||
| }) | ||
|
|
||
| it("updates checkbox state when prop changes", () => { | ||
| const { getByTestId, rerender } = render(<UISettings {...defaultProps} reasoningBlockCollapsed={false} />) | ||
| const checkbox = getByTestId("collapse-thinking-checkbox") as HTMLInputElement | ||
| expect(checkbox.checked).toBe(false) | ||
|
|
||
| rerender(<UISettings {...defaultProps} reasoningBlockCollapsed={true} />) | ||
| expect(checkbox.checked).toBe(true) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.