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 @@ -96,7 +96,7 @@ function AttachAgentDialog({
<Markdown body={commandInstructions} />
<CommandBlock
command={target.command(baseUrl, sessionId)}
contained
wrap
trackingId="projects.attach_agent.copy_command"
trackingMetadata={{ agent: target.id }}
/>
Expand Down
40 changes: 15 additions & 25 deletions src/routes/v2/shared/components/CommandBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { InlineStack } from "@/components/ui/layout";
import { Text } from "@/components/ui/typography";
import { cn } from "@/lib/utils";
import { CopyValueButton } from "@/routes/v2/shared/components/CopyValueButton";

export function CommandBlock({
command,
contained = false,
wrap = false,
trackingId,
trackingMetadata,
}: {
command: string;
contained?: boolean;
wrap?: boolean;
trackingId?: string;
trackingMetadata?: Record<string, unknown>;
}) {
Expand All @@ -20,29 +21,18 @@ export function CommandBlock({
wrap="nowrap"
className="w-full min-w-0 rounded-md border border-border bg-muted px-3 py-2"
>
{contained ? (
// Absolutely positioned so the long command never contributes to the
// intrinsic width of the dialog's nested grids, which would otherwise
// stretch the whole dialog wider than its box. The command then scrolls
// horizontally within the fixed-width container instead.
<div className="relative h-5 min-w-0 flex-1">
<Text
size="sm"
font="mono"
className="absolute inset-0 overflow-x-auto whitespace-pre leading-5"
>
{command}
</Text>
</div>
) : (
<Text
size="sm"
font="mono"
className="min-w-0 flex-1 overflow-x-auto whitespace-pre"
>
{command}
</Text>
)}
<Text
size="sm"
font="mono"
className={cn(
"min-w-0 flex-1",
wrap
? "whitespace-pre-wrap wrap-anywhere"
: "overflow-x-auto whitespace-pre",
)}
>
{command}
</Text>
<CopyValueButton
valueFn={() => command}
trackingId={trackingId}
Expand Down
Loading