-
Notifications
You must be signed in to change notification settings - Fork 212
feat(chat): add compact tool UI mode for executed tool blocks (#322) #327
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
fd5ecdd
d356ab6
e9068ea
8f2079e
a6a2f28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,7 @@ import { | |||||||
| Split, | ||||||||
| ArrowRight, | ||||||||
| Check, | ||||||||
| ChevronRight, | ||||||||
| } from "lucide-react" | ||||||||
| import { cn } from "@/lib/utils" | ||||||||
| import { PathTooltip } from "../ui/PathTooltip" | ||||||||
|
|
@@ -182,8 +183,16 @@ export const ChatRowContent = ({ | |||||||
| }: ChatRowContentProps) => { | ||||||||
| const { t, i18n } = useTranslation() | ||||||||
|
|
||||||||
| const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration, clineMessages, currentTaskItem } = | ||||||||
| useExtensionState() | ||||||||
| const { | ||||||||
| mcpServers, | ||||||||
| alwaysAllowMcp, | ||||||||
| currentCheckpoint, | ||||||||
| mode, | ||||||||
| apiConfiguration, | ||||||||
| clineMessages, | ||||||||
| currentTaskItem, | ||||||||
| compactToolUI, | ||||||||
| } = useExtensionState() | ||||||||
| const { info: model } = useSelectedModel(apiConfiguration) | ||||||||
| const [isEditing, setIsEditing] = useState(false) | ||||||||
| const [editedContent, setEditedContent] = useState("") | ||||||||
|
|
@@ -1405,6 +1414,26 @@ export const ChatRowContent = ({ | |||||||
| const sayTool = safeJsonParse<ClineSayTool>(message.text) | ||||||||
| if (!sayTool) return null | ||||||||
|
|
||||||||
| // Compact mode (#322): collapse executed (history) tool blocks to a single | ||||||||
| // clickable line, hiding verbose params/payloads until expanded. Only applies | ||||||||
| // to `say` tool rows here — approval prompts (`ask`) are never compacted. | ||||||||
| if (compactToolUI && !isExpanded) { | ||||||||
| const compactLabel = sayTool.path ? `${sayTool.tool}: ${sayTool.path}` : sayTool.tool | ||||||||
| return ( | ||||||||
| <div | ||||||||
| onClick={handleToggleExpand} | ||||||||
| className="flex items-center gap-2 py-0.5 cursor-pointer text-vscode-descriptionForeground hover:text-vscode-foreground" | ||||||||
| data-testid="compact-tool-row" | ||||||||
| title={t("chat:compactTool.expandHint")}> | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would adding
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call — added |
||||||||
| <ChevronRight className="w-3.5 h-3.5 shrink-0" /> | ||||||||
| <PocketKnife className="w-3.5 h-3.5 shrink-0" /> | ||||||||
| <span className="truncate text-sm"> | ||||||||
| {t("chat:compactTool.label", { tool: compactLabel })} | ||||||||
| </span> | ||||||||
| </div> | ||||||||
| ) | ||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||
| } | ||||||||
|
|
||||||||
| switch (sayTool.tool) { | ||||||||
| case "runSlashCommand": { | ||||||||
| const slashCommandInfo = sayTool | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & { | |
| maxOpenTabsContext: number | ||
| maxWorkspaceFiles: number | ||
| showRooIgnoredFiles?: boolean | ||
| compactToolUI?: boolean | ||
| enableSubfolderRules?: boolean | ||
| maxImageFileSize?: number | ||
| maxTotalImageSize?: number | ||
|
|
@@ -50,6 +51,7 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & { | |
| | "maxOpenTabsContext" | ||
| | "maxWorkspaceFiles" | ||
| | "showRooIgnoredFiles" | ||
| | "compactToolUI" | ||
| | "enableSubfolderRules" | ||
| | "maxImageFileSize" | ||
| | "maxTotalImageSize" | ||
|
|
@@ -70,6 +72,7 @@ export const ContextManagementSettings = ({ | |
| maxOpenTabsContext, | ||
| maxWorkspaceFiles, | ||
| showRooIgnoredFiles, | ||
| compactToolUI, | ||
| enableSubfolderRules, | ||
| setCachedStateField, | ||
| maxImageFileSize, | ||
|
|
@@ -229,6 +232,23 @@ export const ContextManagementSettings = ({ | |
| </div> | ||
| </SearchableSetting> | ||
|
|
||
| <SearchableSetting | ||
| settingId="context-compact-tool-ui" | ||
| section="contextManagement" | ||
| label={t("settings:contextManagement.compactToolUI.label")}> | ||
| <VSCodeCheckbox | ||
| checked={compactToolUI} | ||
| onChange={(e: any) => setCachedStateField("compactToolUI", e.target.checked)} | ||
| data-testid="compact-tool-ui-checkbox"> | ||
| <label className="block font-medium mb-1"> | ||
| {t("settings:contextManagement.compactToolUI.label")} | ||
| </label> | ||
| </VSCodeCheckbox> | ||
| <div className="text-vscode-descriptionForeground text-sm mt-1 mb-3"> | ||
| {t("settings:contextManagement.compactToolUI.description")} | ||
| </div> | ||
| </SearchableSetting> | ||
|
Comment on lines
+235
to
+250
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this live in |
||
|
|
||
| <SearchableSetting | ||
| settingId="context-enable-subfolder-rules" | ||
| section="contextManagement" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,7 @@ describe("ContextManagementSettings", () => { | |
| maxOpenTabsContext: 20, | ||
| maxWorkspaceFiles: 200, | ||
| showRooIgnoredFiles: false, | ||
| compactToolUI: false, | ||
| profileThresholds: {}, | ||
| includeDiagnosticMessages: true, | ||
| maxDiagnosticMessages: 50, | ||
|
|
@@ -150,6 +151,23 @@ describe("ContextManagementSettings", () => { | |
| }) | ||
| }) | ||
|
|
||
| it("renders the compact tool UI toggle", () => { | ||
| render(<ContextManagementSettings {...defaultProps} />) | ||
| expect(screen.getByTestId("compact-tool-ui-checkbox")).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it("calls setCachedStateField when the compact tool UI checkbox is toggled", async () => { | ||
| const setCachedStateField = vi.fn() | ||
| render(<ContextManagementSettings {...defaultProps} setCachedStateField={setCachedStateField} />) | ||
|
|
||
| const checkbox = screen.getByTestId("compact-tool-ui-checkbox").querySelector("input")! | ||
| fireEvent.click(checkbox) | ||
|
|
||
| await waitFor(() => { | ||
| expect(setCachedStateField).toHaveBeenCalledWith("compactToolUI", true) | ||
| }) | ||
| }) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These cover the settings toggle nicely. Would it be worth also adding a test that mounts
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done — added |
||
|
|
||
| it("calls setCachedStateField when max diagnostic messages slider is changed", async () => { | ||
| const setCachedStateField = vi.fn() | ||
| render(<ContextManagementSettings {...defaultProps} setCachedStateField={setCachedStateField} />) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.