Skip to content

Commit 04e6b5e

Browse files
authored
feat: Improve long command display and auto-collapse plan edits (#1168)
Closes #1140 1. Wrap long commands in permission dialog with scrollable container and word-break 2. Truncate command text in ExecuteToolView to 120 chars for cleaner inline display 3. Auto-collapse EditToolView for plan file edits via useEffect
1 parent 2296698 commit 04e6b5e

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

apps/code/src/renderer/components/permissions/ExecutePermission.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ActionSelector } from "@components/ActionSelector";
2-
import { Code } from "@radix-ui/themes";
2+
import { Box, Code } from "@radix-ui/themes";
33
import { compactHomePath } from "@utils/path";
44
import {
55
type BasePermissionProps,
@@ -20,9 +20,16 @@ export function ExecutePermission({
2020
title={toolCall.title ?? "Execute command"}
2121
pendingAction={
2222
command ? (
23-
<Code variant="ghost" size="1" title={command}>
24-
{compactHomePath(command)}
25-
</Code>
23+
<Box className="max-h-[30vh] overflow-auto">
24+
<Code
25+
variant="ghost"
26+
size="1"
27+
title={command}
28+
className="whitespace-pre-wrap break-all"
29+
>
30+
{compactHomePath(command)}
31+
</Code>
32+
</Box>
2633
) : undefined
2734
}
2835
question="Do you want to proceed?"

apps/code/src/renderer/features/sessions/components/session-update/EditToolView.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
PencilSimple,
55
} from "@phosphor-icons/react";
66
import { Box, Flex, IconButton, Text } from "@radix-ui/themes";
7-
import { useState } from "react";
7+
import { useEffect, useState } from "react";
88
import { CodePreview } from "./CodePreview";
99
import { FileMentionChip } from "./FileMentionChip";
1010
import {
@@ -74,6 +74,12 @@ export function EditToolView({
7474
const isPlanFile = filePath.includes("claude/plans/");
7575
const [isExpanded, setIsExpanded] = useState(!isPlanFile);
7676

77+
useEffect(() => {
78+
if (isPlanFile) {
79+
setIsExpanded(false);
80+
}
81+
}, [isPlanFile]);
82+
7783
return (
7884
<Box className="max-w-4xl overflow-hidden rounded-lg border border-gray-6">
7985
<button

apps/code/src/renderer/features/sessions/components/session-update/ExecuteToolView.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import {
99
StatusIndicators,
1010
ToolTitle,
1111
type ToolViewProps,
12+
truncateText,
1213
useToolCallStatus,
1314
} from "./toolCallUtils";
1415

1516
const ANSI_REGEX = new RegExp(`${String.fromCharCode(0x1b)}\\[[0-9;]*m`, "g");
17+
const MAX_COMMAND_LENGTH = 120;
1618

1719
interface ExecuteRawInput {
1820
command?: string;
@@ -65,9 +67,9 @@ export function ExecuteToolView({
6567
<Flex align="center" gap="2" wrap="wrap">
6668
{description && <ToolTitle>{description}</ToolTitle>}
6769
{command && (
68-
<ToolTitle>
70+
<ToolTitle className="truncate">
6971
<span className="font-mono text-accent-11" title={command}>
70-
{compactHomePath(command)}
72+
{truncateText(compactHomePath(command), MAX_COMMAND_LENGTH)}
7173
</span>
7274
</ToolTitle>
7375
)}

0 commit comments

Comments
 (0)