Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ const getProcessOutputLabel = ({
isFailed: boolean;
}): string => {
const trimmedCommand = command?.trim() ?? "";
const intent = modelIntent
? sanitizeExecuteModelIntent(modelIntent, trimmedCommand)
: "";
const intent = sanitizeExecuteModelIntent(modelIntent, trimmedCommand);
if (intent) {
return intent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import * as apiModule from "#/api/api";
import { API } from "#/api/api";
import { workspaceByIdKey } from "#/api/queries/workspaces";
import { MockWorkspace, MockWorkspaceAgent } from "#/testHelpers/entities";
import { createTestQueryClient } from "#/testHelpers/renderHelpers";
import {
createTestQueryClient,
renderComponent,
} from "#/testHelpers/renderHelpers";
import { createMockWebSocket } from "#/testHelpers/websockets";
import { OneWayWebSocket } from "#/utils/OneWayWebSocket";
import { ChatWorkspaceContext } from "../../../context/ChatWorkspaceContext";
Expand Down Expand Up @@ -99,3 +102,25 @@ describe("Tool workspace lifecycle rows", () => {
},
);
});

describe("Tool generic rows", () => {
it("falls back to the tool name when the model intent is whitespace", () => {
renderComponent(
<QueryClientProvider client={createTestQueryClient()}>
<Tool
name="custom_tool"
status="completed"
args={{ query: "value" }}
isError={false}
modelIntent=" "
subagentTitles={new Map()}
subagentVariants={new Map()}
shellToolDisplayMode="auto"
codeDiffDisplayMode="auto"
/>
</QueryClientProvider>,
);

expect(screen.getByRole("button")).toHaveAccessibleName("custom_tool");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,7 @@ const GenericToolRenderer: React.FC<ToolRendererProps> = ({
iconUrl={mcpServer?.icon_url}
serverName={mcpServer?.display_name}
label={
modelIntent ? (
formatModelIntentLabel(modelIntent)
) : (
formatModelIntentLabel(modelIntent) || (
<ToolLabel
name={name}
args={args}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const useToolCallContext = () => {
/**
* Props for {@link ToolCall.Root}.
*
* The root can be controlled with `view` or `expanded`, or uncontrolled
* The root can be controlled with `expanded`, or uncontrolled
* with `defaultView` and `defaultExpanded`. When both uncontrolled props
* are provided, `defaultView` wins because it can represent the more
* specific `preview` state.
Expand All @@ -107,9 +107,7 @@ type ToolCallRootProps = Omit<React.ComponentProps<"div">, "children"> & {
defaultView?: ToolCallView;
expanded?: boolean;
onExpandedChange?: (expanded: boolean) => void;
onViewChange?: (view: ToolCallView) => void;
ariaLabel?: ToolCallAriaLabel;
view?: ToolCallView;
};

/**
Expand All @@ -129,22 +127,19 @@ const Root: React.FC<ToolCallRootProps> = ({
defaultView,
expanded: expandedProp,
onExpandedChange,
onViewChange,
ariaLabel,
className,
view: viewProp,
...divProps
}) => {
const [uncontrolledView, setUncontrolledView] = useState<ToolCallView>(
defaultView ?? (defaultExpanded ? "expanded" : "collapsed"),
);
const controlledView =
viewProp ??
(expandedProp === undefined
expandedProp === undefined
? undefined
: expandedProp
? "expanded"
: "collapsed");
: "collapsed";
const view = controlledView ?? uncontrolledView;
const expanded = view !== "collapsed";
const collapsible = hasContent;
Expand All @@ -155,7 +150,6 @@ const Root: React.FC<ToolCallRootProps> = ({
if (controlledView === undefined) {
setUncontrolledView(nextView);
}
onViewChange?.(nextView);
onExpandedChange?.(nextView !== "collapsed");
};

Expand Down Expand Up @@ -273,20 +267,15 @@ const LeadingIcon: React.FC<ToolCallLeadingIconProps> = ({
type ToolCallLabelProps = {
children: React.ReactNode;
className?: string;
shimmerWhenActive?: boolean;
};

const Label: React.FC<ToolCallLabelProps> = ({
children,
className,
shimmerWhenActive = true,
}) => {
const Label: React.FC<ToolCallLabelProps> = ({ children, className }) => {
const { active } = useToolCallContext();
const labelClassName = cn(
"min-w-0 truncate text-[13px] leading-6",
className,
);
if (active && shimmerWhenActive && typeof children === "string") {
if (active && typeof children === "string") {
return (
<Shimmer as="span" className={labelClassName}>
{children}
Expand Down Expand Up @@ -397,7 +386,6 @@ type ToolCallHeaderProps = {
secondaryLabel?: React.ReactNode;
trailing?: React.ReactNode;
showStatus?: boolean;
headerClassName?: string;
};

/**
Expand All @@ -417,10 +405,9 @@ const Header: React.FC<ToolCallHeaderProps> = ({
secondaryLabel,
trailing,
showStatus = true,
headerClassName,
}) => {
return (
<HeaderButton className={headerClassName}>
<HeaderButton>
<LeadingIcon name={iconName} iconUrl={iconUrl} serverName={serverName} />
<Label>{label}</Label>
{secondaryLabel}
Expand Down
Loading