fix(webui): use file-type icons in file change activity
This commit is contained in:
1 parent
d076e4ef13
commit
8de03ac0a2
8 files changed
+132
-68
No files matched your search
@@ -31,6 +31,7 @@ interface FileReferenceChipProps {
|
|||||||
path: string;
|
path: string;
|
||||||
tooltipPath?: string;
|
tooltipPath?: string;
|
||||||
display?: "name" | "path";
|
display?: "name" | "path";
|
||||||
|
showIcon?: boolean;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
textClassName?: string;
|
textClassName?: string;
|
||||||
@@ -43,6 +44,7 @@ export function FileReferenceChip({
|
|||||||
path,
|
path,
|
||||||
tooltipPath,
|
tooltipPath,
|
||||||
display = "name",
|
display = "name",
|
||||||
|
showIcon = true,
|
||||||
active = false,
|
active = false,
|
||||||
className,
|
className,
|
||||||
textClassName,
|
textClassName,
|
||||||
@@ -97,7 +99,7 @@ export function FileReferenceChip({
|
|||||||
],
|
],
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<FileReferenceIcon kind={kind} className="translate-y-[0.12em]" />
|
{showIcon ? <FileReferenceIcon kind={kind} className="translate-y-[0.12em]" /> : null}
|
||||||
<span
|
<span
|
||||||
data-sheen-text={active ? displayText : undefined}
|
data-sheen-text={active ? displayText : undefined}
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -258,6 +260,10 @@ const FILE_ICONS = {
|
|||||||
video: FileVideo2,
|
video: FileVideo2,
|
||||||
} satisfies Record<FileReferenceKind, LucideIcon>;
|
} satisfies Record<FileReferenceKind, LucideIcon>;
|
||||||
|
|
||||||
|
export function fileIconForPath(path: string): LucideIcon {
|
||||||
|
return FILE_ICONS[fileKindForPath(path)];
|
||||||
|
}
|
||||||
|
|
||||||
/** The same file silhouette and stroke in replies, tabs, and attachment tiles. */
|
/** The same file silhouette and stroke in replies, tabs, and attachment tiles. */
|
||||||
export function FileReferenceIcon({ kind, className }: { kind: FileReferenceKind; className?: string }) {
|
export function FileReferenceIcon({ kind, className }: { kind: FileReferenceKind; className?: string }) {
|
||||||
const Icon = FILE_ICONS[kind];
|
const Icon = FILE_ICONS[kind];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { LucideIcon } from "lucide-react";
|
|||||||
|
|
||||||
import { StreamingLabelSheen } from "@/components/ui/streaming-label-sheen";
|
import { StreamingLabelSheen } from "@/components/ui/streaming-label-sheen";
|
||||||
import { formControlFocusClassName } from "@/components/ui/form-control";
|
import { formControlFocusClassName } from "@/components/ui/form-control";
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
import { HoverHint, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
export type ActivityStepTone = "neutral" | "active" | "success" | "error";
|
export type ActivityStepTone = "neutral" | "active" | "success" | "error";
|
||||||
@@ -11,6 +11,7 @@ export type ActivityStepTone = "neutral" | "active" | "success" | "error";
|
|||||||
export interface ActivityStepProps {
|
export interface ActivityStepProps {
|
||||||
icon?: LucideIcon;
|
icon?: LucideIcon;
|
||||||
marker?: ReactNode;
|
marker?: ReactNode;
|
||||||
|
markerLabel?: string;
|
||||||
showMarker?: boolean;
|
showMarker?: boolean;
|
||||||
label: ReactNode;
|
label: ReactNode;
|
||||||
detail?: string;
|
detail?: string;
|
||||||
@@ -30,6 +31,7 @@ export interface ActivityStepProps {
|
|||||||
export function ActivityStep({
|
export function ActivityStep({
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
marker,
|
marker,
|
||||||
|
markerLabel,
|
||||||
showMarker = true,
|
showMarker = true,
|
||||||
label,
|
label,
|
||||||
detail,
|
detail,
|
||||||
@@ -48,6 +50,30 @@ export function ActivityStep({
|
|||||||
const lineRef = useRef<HTMLDivElement>(null);
|
const lineRef = useRef<HTMLDivElement>(null);
|
||||||
const [hintOpen, setHintOpen] = useState(false);
|
const [hintOpen, setHintOpen] = useState(false);
|
||||||
const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined;
|
const textLabel = typeof label === "string" ? [label, detail].filter(Boolean).join("\n") : undefined;
|
||||||
|
const activityMarker = (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"flex h-5 w-[1.125rem] shrink-0 items-start justify-center pt-[3px]",
|
||||||
|
markerLabel && ["rounded-sm", formControlFocusClassName],
|
||||||
|
)}
|
||||||
|
aria-hidden={markerLabel ? undefined : true}
|
||||||
|
role={markerLabel ? "img" : undefined}
|
||||||
|
aria-label={markerLabel}
|
||||||
|
tabIndex={markerLabel ? 0 : undefined}
|
||||||
|
>
|
||||||
|
{marker ?? (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"grid h-3.5 w-3.5 place-items-center transition-colors",
|
||||||
|
tone === "error" ? "text-destructive/[0.78]" : "text-muted-foreground",
|
||||||
|
markerClassName,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{Icon ? <Icon className="h-3.5 w-3.5" strokeWidth={1.75} aria-hidden /> : null}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
const line = (
|
const line = (
|
||||||
<div
|
<div
|
||||||
ref={lineRef}
|
ref={lineRef}
|
||||||
@@ -92,26 +118,9 @@ export function ActivityStep({
|
|||||||
)}
|
)}
|
||||||
style={style}
|
style={style}
|
||||||
>
|
>
|
||||||
{showMarker ? (
|
{showMarker ? markerLabel ? (
|
||||||
<span
|
<HoverHint content={markerLabel}>{activityMarker}</HoverHint>
|
||||||
className={cn(
|
) : activityMarker : null}
|
||||||
"flex h-5 w-[1.125rem] shrink-0 items-start justify-center pt-[3px]",
|
|
||||||
)}
|
|
||||||
aria-hidden
|
|
||||||
>
|
|
||||||
{marker ?? (
|
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
"grid h-3.5 w-3.5 place-items-center transition-colors",
|
|
||||||
tone === "error" ? "text-destructive/[0.78]" : "text-muted-foreground",
|
|
||||||
markerClassName,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{Icon ? <Icon className="h-3.5 w-3.5" strokeWidth={1.75} /> : null}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
<div className={cn("min-w-0", contentClassName)}>
|
<div className={cn("min-w-0", contentClassName)}>
|
||||||
{typeof label === "string" ? (
|
{typeof label === "string" ? (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
ChevronUp,
|
ChevronUp,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { FileReferenceChip } from "@/components/FileReferenceChip";
|
import { FileReferenceChip, fileIconForPath } from "@/components/FileReferenceChip";
|
||||||
import { codeLanguageFromPath } from "@/lib/code-language";
|
import { codeLanguageFromPath } from "@/lib/code-language";
|
||||||
import {
|
import {
|
||||||
hasRenderableFileDiff,
|
hasRenderableFileDiff,
|
||||||
@@ -98,7 +98,8 @@ function FileEditRow({
|
|||||||
return (
|
return (
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<ActivityStep
|
<ActivityStep
|
||||||
showMarker={false}
|
icon={fileIconForPath(edit.absolute_path || edit.path)}
|
||||||
|
markerLabel={action}
|
||||||
active={editing}
|
active={editing}
|
||||||
tone={failed ? "error" : editing ? "active" : "success"}
|
tone={failed ? "error" : editing ? "active" : "success"}
|
||||||
className="text-xs"
|
className="text-xs"
|
||||||
@@ -107,24 +108,16 @@ function FileEditRow({
|
|||||||
? t("message.fileEditPreparing", { defaultValue: "Preparing file edit…" })
|
? t("message.fileEditPreparing", { defaultValue: "Preparing file edit…" })
|
||||||
: (
|
: (
|
||||||
<span className="flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap">
|
<span className="flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap">
|
||||||
<Trans
|
<FileReferenceChip
|
||||||
i18nKey="message.agentActivity.actionTargetRich"
|
path={edit.path}
|
||||||
values={{ action }}
|
previewPath={edit.absolute_path || edit.path}
|
||||||
components={{
|
onOpen={onOpenFilePreview}
|
||||||
action: <span className={cn("shrink-0", failed && "text-destructive/80")} />,
|
display="path"
|
||||||
target: (
|
showIcon={false}
|
||||||
<FileReferenceChip
|
active={editing}
|
||||||
path={edit.path}
|
className="min-w-0"
|
||||||
previewPath={edit.absolute_path || edit.path}
|
textClassName="truncate text-[12px]"
|
||||||
onOpen={onOpenFilePreview}
|
testId="activity-file-reference"
|
||||||
display="path"
|
|
||||||
active={editing}
|
|
||||||
className="min-w-0"
|
|
||||||
textClassName="truncate text-[12px]"
|
|
||||||
testId="activity-file-reference"
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
{hasCountedDiff ? <DiffPair added={edit.added} deleted={edit.deleted} /> : null}
|
{hasCountedDiff ? <DiffPair added={edit.added} deleted={edit.deleted} /> : null}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -73,14 +73,21 @@ function ActivityPreview() {
|
|||||||
|
|
||||||
function FilesPreview() {
|
function FilesPreview() {
|
||||||
const [state, setState] = useState<"done" | "editing" | "error">("done");
|
const [state, setState] = useState<"done" | "editing" | "error">("done");
|
||||||
|
const [operation, setOperation] = useState<"create" | "edit" | "delete">("edit");
|
||||||
const [display, setDisplay] = useState<"summary" | "diff" | "collapsed_diff">("diff");
|
const [display, setDisplay] = useState<"summary" | "diff" | "collapsed_diff">("diff");
|
||||||
const [opened, setOpened] = useState("");
|
const [opened, setOpened] = useState("");
|
||||||
|
const diffs = {
|
||||||
|
create: '@@ -0,0 +1 @@\n+export const greeting = "Hello, Nanobot";\n',
|
||||||
|
edit: '@@ -1,2 +1,2 @@\n-export const greeting = "Hello";\n+export const greeting = "Hello, Nanobot";\n export const ready = true;\n',
|
||||||
|
delete: '@@ -1 +0,0 @@\n-export const greeting = "Hello";\n',
|
||||||
|
};
|
||||||
const edit: FileEditSummary = {
|
const edit: FileEditSummary = {
|
||||||
key: "example-edit", path: "src/greeting.ts", added: 1, deleted: 1, approximate: false, binary: false,
|
key: "example-edit", path: "src/greeting.ts", added: operation === "delete" ? 0 : 1, deleted: operation === "create" ? 0 : 1, approximate: false, binary: false,
|
||||||
status: state, pending: state === "editing", operation: "edit", error: state === "error" ? "Example edit could not be applied." : undefined,
|
status: state, pending: state === "editing", operation, error: state === "error" ? "Example edit could not be applied." : undefined,
|
||||||
diff: { format: "unified", text: '@@ -1,2 +1,2 @@\n-export const greeting = "Hello";\n+export const greeting = "Hello, Nanobot";\n export const ready = true;\n' },
|
diff: { format: "unified", text: diffs[operation] },
|
||||||
};
|
};
|
||||||
return <><StatePicker label="File edit state" value={state} options={["done", "editing", "error"]} onChange={setState} />
|
return <><StatePicker label="File edit state" value={state} options={["done", "editing", "error"]} onChange={setState} />
|
||||||
|
<StatePicker label="File operation" value={operation} options={["create", "edit", "delete"]} onChange={setOperation} />
|
||||||
<StatePicker label="Diff display" value={display} options={["summary", "diff", "collapsed_diff"]} onChange={setDisplay} />
|
<StatePicker label="Diff display" value={display} options={["summary", "diff", "collapsed_diff"]} onChange={setDisplay} />
|
||||||
<FileEditGroup edits={[edit]} displayMode={display} onOpenFilePreview={setOpened} />
|
<FileEditGroup edits={[edit]} displayMode={display} onOpenFilePreview={setOpened} />
|
||||||
<p role="status" className="mt-4 text-xs text-muted-foreground">{opened ? `Selected file: ${opened}` : "Select a file reference to exercise its callback."}</p></>;
|
<p role="status" className="mt-4 text-xs text-muted-foreground">{opened ? `Selected file: ${opened}` : "Select a file reference to exercise its callback."}</p></>;
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { cleanup, render, screen, within } from "@testing-library/react";
|
import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import { afterEach, expect, it } from "vitest";
|
import { FileCode2 } from "lucide-react";
|
||||||
|
import { afterEach, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import { ActivityStep } from "@/components/thread/activity/ActivityStep";
|
import { ActivityStep } from "@/components/thread/activity/ActivityStep";
|
||||||
|
|
||||||
afterEach(cleanup);
|
afterEach(() => {
|
||||||
|
cleanup();
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
it("animates a running label with details and keeps the completed activity readable", () => {
|
it("animates a running label with details and keeps the completed activity readable", () => {
|
||||||
const { rerender } = render(<ActivityStep label="Running Blender" detail="--json project new" active />);
|
const { rerender } = render(<ActivityStep label="Running Blender" detail="--json project new" active />);
|
||||||
@@ -32,3 +36,29 @@ it("keeps truncated activity details available on keyboard focus", async () => {
|
|||||||
const tooltip = await screen.findByRole("tooltip");
|
const tooltip = await screen.findByRole("tooltip");
|
||||||
expect(within(tooltip).getByText(/Used Blender/)).toHaveTextContent("--json project new");
|
expect(within(tooltip).getByText(/Used Blender/)).toHaveTextContent("--json project new");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("describes a named operation marker on keyboard focus before the file action", async () => {
|
||||||
|
render(<ActivityStep icon={FileCode2} markerLabel="Created" label={<button>src/app.tsx</button>} />);
|
||||||
|
|
||||||
|
await userEvent.tab();
|
||||||
|
|
||||||
|
const marker = screen.getByRole("img", { name: "Created" });
|
||||||
|
expect(marker).toHaveFocus();
|
||||||
|
expect(marker.closest('[aria-hidden="true"]')).toBeNull();
|
||||||
|
expect(screen.getByRole("tooltip")).toHaveTextContent("Created");
|
||||||
|
|
||||||
|
await userEvent.tab();
|
||||||
|
expect(screen.getByRole("button", { name: "src/app.tsx" })).toHaveFocus();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses the shared hover delay for a named operation marker", () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
render(<ActivityStep icon={FileCode2} markerLabel="Created" label={<span>src/app.tsx</span>} />);
|
||||||
|
const marker = screen.getByRole("img", { name: "Created" });
|
||||||
|
|
||||||
|
fireEvent.pointerMove(marker, { pointerType: "mouse" });
|
||||||
|
act(() => vi.advanceTimersByTime(499));
|
||||||
|
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
||||||
|
act(() => vi.advanceTimersByTime(1));
|
||||||
|
expect(screen.getByRole("tooltip")).toHaveTextContent("Created");
|
||||||
|
});
|
||||||
@@ -162,7 +162,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
expect(screen.getByText(`Reading file ${path}`)).toBeInTheDocument();
|
expect(screen.getByText(`Reading file ${path}`)).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText("Using Blender, --json --background scene.blend")).toBeInTheDocument();
|
expect(screen.getByLabelText("Using Blender, --json --background scene.blend")).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText("Opening example.com, Browserbase")).toBeInTheDocument();
|
expect(screen.getByLabelText("Opening example.com, Browserbase")).toBeInTheDocument();
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent(path);
|
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent(path);
|
||||||
|
|
||||||
await act(async () => setAppLanguage("zh-CN"));
|
await act(async () => setAppLanguage("zh-CN"));
|
||||||
@@ -171,7 +171,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
expect(screen.getByText(`正在读取文件 ${path}`)).toBeInTheDocument();
|
expect(screen.getByText(`正在读取文件 ${path}`)).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText("正在使用 Blender, --json --background scene.blend")).toBeInTheDocument();
|
expect(screen.getByLabelText("正在使用 Blender, --json --background scene.blend")).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText("正在打开 example.com, Browserbase")).toBeInTheDocument();
|
expect(screen.getByLabelText("正在打开 example.com, Browserbase")).toBeInTheDocument();
|
||||||
expect(screen.getByText("编辑")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "编辑", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent(path);
|
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent(path);
|
||||||
|
|
||||||
await act(async () => setAppLanguage("ja"));
|
await act(async () => setAppLanguage("ja"));
|
||||||
@@ -180,8 +180,9 @@ describe("AgentActivityCluster", () => {
|
|||||||
expect(screen.getByText(`${path} ファイルを読み取り中`)).toBeInTheDocument();
|
expect(screen.getByText(`${path} ファイルを読み取り中`)).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText("Blender を使用中, --json --background scene.blend")).toBeInTheDocument();
|
expect(screen.getByLabelText("Blender を使用中, --json --background scene.blend")).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText("example.com 開いています, Browserbase")).toBeInTheDocument();
|
expect(screen.getByLabelText("example.com 開いています, Browserbase")).toBeInTheDocument();
|
||||||
|
expect(screen.getByRole("img", { name: "編集", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.getByTestId("activity-file-reference").closest('[data-testid="activity-step"]'))
|
expect(screen.getByTestId("activity-file-reference").closest('[data-testid="activity-step"]'))
|
||||||
.toHaveTextContent(`${path} 編集`);
|
.toHaveAttribute("aria-label", `${path} 編集`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("loads deferred trace details only after completed activity is expanded", async () => {
|
it("loads deferred trace details only after completed activity is expanded", async () => {
|
||||||
@@ -535,7 +536,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
assertBetween(screen.getByText("Editing"));
|
assertBetween(screen.getByRole("img", { name: "Editing", exact: true }));
|
||||||
|
|
||||||
rerender(
|
rerender(
|
||||||
<AgentActivityCluster
|
<AgentActivityCluster
|
||||||
@@ -545,7 +546,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
assertBetween(screen.getByText("Edited"));
|
assertBetween(screen.getByRole("img", { name: "Edited", exact: true }));
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(["diff", "collapsed_diff"] as const)(
|
it.each(["diff", "collapsed_diff"] as const)(
|
||||||
@@ -676,7 +677,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
expect(screen.getByTestId("file-edit-diff")).toBeInTheDocument();
|
expect(screen.getByTestId("file-edit-diff")).toBeInTheDocument();
|
||||||
expect(screen.getByText("return <Old />;")).toBeInTheDocument();
|
expect(screen.getByText("return <Old />;")).toBeInTheDocument();
|
||||||
expect(screen.getByText("return <New />;")).toBeInTheDocument();
|
expect(screen.getByText("return <New />;")).toBeInTheDocument();
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent("src/app.tsx");
|
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent("src/app.tsx");
|
||||||
expect(screen.getAllByTestId("activity-diff-pair")).toHaveLength(1);
|
expect(screen.getAllByTestId("activity-diff-pair")).toHaveLength(1);
|
||||||
|
|
||||||
@@ -684,7 +685,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, fileEditDisplayMode: "summary" });
|
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, fileEditDisplayMode: "summary" });
|
||||||
});
|
});
|
||||||
expect(screen.queryByTestId("file-edit-diff")).not.toBeInTheDocument();
|
expect(screen.queryByTestId("file-edit-diff")).not.toBeInTheDocument();
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, fileEditDisplayMode: "diff" });
|
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, fileEditDisplayMode: "diff" });
|
||||||
@@ -977,9 +978,10 @@ describe("AgentActivityCluster", () => {
|
|||||||
hasBodyBelow={false}
|
hasBodyBelow={false}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
expect(screen.getByText("Created")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Created", exact: true }).querySelector("svg"))
|
||||||
|
.toHaveClass("lucide-file-text");
|
||||||
expect(screen.getByLabelText("Created tmp.txt")).toBeInTheDocument();
|
expect(screen.getByLabelText("Created tmp.txt")).toBeInTheDocument();
|
||||||
expect(screen.queryByText("Edited")).not.toBeInTheDocument();
|
expect(screen.queryByRole("img", { name: "Edited", exact: true })).not.toBeInTheDocument();
|
||||||
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent("tmp.txt");
|
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent("tmp.txt");
|
||||||
expect(!!screen.queryByTestId("file-edit-diff")).toBe(hasDiff);
|
expect(!!screen.queryByTestId("file-edit-diff")).toBe(hasDiff);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1015,8 +1017,9 @@ describe("AgentActivityCluster", () => {
|
|||||||
);
|
);
|
||||||
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
||||||
|
|
||||||
expect(screen.getByText("Deleted")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Deleted", exact: true }).querySelector("svg"))
|
||||||
expect(screen.queryByText("Edited")).not.toBeInTheDocument();
|
.toHaveClass("lucide-file-code2");
|
||||||
|
expect(screen.queryByRole("img", { name: "Edited", exact: true })).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders file-only edits without a redundant disclosure", () => {
|
it("renders file-only edits without a redundant disclosure", () => {
|
||||||
@@ -1048,8 +1051,11 @@ describe("AgentActivityCluster", () => {
|
|||||||
|
|
||||||
expect(screen.queryByRole("button", { name: /edited app\.tsx/i })).not.toBeInTheDocument();
|
expect(screen.queryByRole("button", { name: /edited app\.tsx/i })).not.toBeInTheDocument();
|
||||||
expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument();
|
expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument();
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.queryByTestId("activity-header-file-reference")).not.toBeInTheDocument();
|
expect(screen.queryByTestId("activity-header-file-reference")).not.toBeInTheDocument();
|
||||||
|
const marker = screen.getByRole("img", { name: "Edited", exact: true });
|
||||||
|
expect(marker.querySelector("svg")).toHaveClass("lucide-file-code2");
|
||||||
|
expect(marker.closest('[data-testid="activity-step"]')?.querySelectorAll("svg")).toHaveLength(1);
|
||||||
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent("src/app.tsx");
|
expect(screen.getByTestId("activity-file-reference")).toHaveTextContent("src/app.tsx");
|
||||||
expect(screen.getByText("+12")).toBeInTheDocument();
|
expect(screen.getByText("+12")).toBeInTheDocument();
|
||||||
expect(screen.getByText("-3")).toBeInTheDocument();
|
expect(screen.getByText("-3")).toBeInTheDocument();
|
||||||
@@ -1798,7 +1804,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
);
|
);
|
||||||
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
||||||
|
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.queryByText("+0")).not.toBeInTheDocument();
|
expect(screen.queryByText("+0")).not.toBeInTheDocument();
|
||||||
expect(screen.queryByText("-0")).not.toBeInTheDocument();
|
expect(screen.queryByText("-0")).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@@ -1893,7 +1899,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
);
|
);
|
||||||
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
||||||
|
|
||||||
const row = screen.getByText("Could not edit").closest('[data-testid="activity-step"]');
|
const row = screen.getByRole("img", { name: "Could not edit", exact: true }).closest('[data-testid="activity-step"]');
|
||||||
expect(row).toBeInTheDocument();
|
expect(row).toBeInTheDocument();
|
||||||
expect(row).not.toHaveAttribute("title");
|
expect(row).not.toHaveAttribute("title");
|
||||||
expect(screen.queryByText("Target text was not found in angry-birds.html.")).not.toBeInTheDocument();
|
expect(screen.queryByText("Target text was not found in angry-birds.html.")).not.toBeInTheDocument();
|
||||||
@@ -1927,7 +1933,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
);
|
);
|
||||||
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
||||||
|
|
||||||
const row = screen.getByText("Could not edit").closest('[data-testid="activity-step"]');
|
const row = screen.getByRole("img", { name: "Could not edit", exact: true }).closest('[data-testid="activity-step"]');
|
||||||
expect(row).toBeInTheDocument();
|
expect(row).toBeInTheDocument();
|
||||||
expect(row).not.toHaveAttribute("title");
|
expect(row).not.toHaveAttribute("title");
|
||||||
expect(screen.queryByText("No permission to change this location.")).not.toBeInTheDocument();
|
expect(screen.queryByText("No permission to change this location.")).not.toBeInTheDocument();
|
||||||
@@ -2008,7 +2014,7 @@ describe("AgentActivityCluster", () => {
|
|||||||
const fileRefs = screen.getAllByTestId("activity-file-reference");
|
const fileRefs = screen.getAllByTestId("activity-file-reference");
|
||||||
expect(fileRefs).toHaveLength(3);
|
expect(fileRefs).toHaveLength(3);
|
||||||
expect(fileRefs.every((ref) => ref.textContent?.includes("minecraft-fps/index.html"))).toBe(true);
|
expect(fileRefs.every((ref) => ref.textContent?.includes("minecraft-fps/index.html"))).toBe(true);
|
||||||
const failedRow = screen.getByText("Could not edit").closest(
|
const failedRow = screen.getByRole("img", { name: "Could not edit", exact: true }).closest(
|
||||||
'[data-testid="activity-step"]',
|
'[data-testid="activity-step"]',
|
||||||
);
|
);
|
||||||
expect(failedRow).toBeInTheDocument();
|
expect(failedRow).toBeInTheDocument();
|
||||||
@@ -2066,8 +2072,8 @@ describe("AgentActivityCluster", () => {
|
|||||||
);
|
);
|
||||||
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
fireEvent.click(screen.getByRole("button", { name: /^Worked/ }));
|
||||||
|
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.getByText("Could not edit")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Could not edit", exact: true })).toBeInTheDocument();
|
||||||
expect(screen.getAllByTestId("activity-file-reference")).toHaveLength(2);
|
expect(screen.getAllByTestId("activity-file-reference")).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,19 @@ describe("shared file icons", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it("keeps iconless activity references named and keyboard-operable", () => {
|
||||||
|
const open = vi.fn();
|
||||||
|
render(<FileReferenceChip path="src/app.tsx" previewPath="/repo/src/app.tsx"
|
||||||
|
display="path" showIcon={false} onOpen={open} />);
|
||||||
|
|
||||||
|
const reference = screen.getByRole("button", { name: "src/app.tsx" });
|
||||||
|
expect(reference).toHaveTextContent("src/app.tsx");
|
||||||
|
expect(reference.querySelector("svg")).toBeNull();
|
||||||
|
expect(reference).toHaveAttribute("tabindex", "0");
|
||||||
|
fireEvent.keyDown(reference, { key: "Enter" });
|
||||||
|
expect(open).toHaveBeenCalledWith("/repo/src/app.tsx");
|
||||||
|
});
|
||||||
|
|
||||||
it.each(["image", "video"] as const)("retains %s identity when its attachment is unavailable", (kind) => {
|
it.each(["image", "video"] as const)("retains %s identity when its attachment is unavailable", (kind) => {
|
||||||
const { container } = render(<AttachmentTile attachment={{ kind, name: "Unavailable" }} />);
|
const { container } = render(<AttachmentTile attachment={{ kind, name: "Unavailable" }} />);
|
||||||
expect(container.querySelector("svg")).toHaveClass(kind === "image" ? "lucide-file-image" : "lucide-file-video2");
|
expect(container.querySelector("svg")).toHaveClass(kind === "image" ? "lucide-file-image" : "lucide-file-video2");
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ describe("ThreadMessages", () => {
|
|||||||
const assertIndependentDiff = () => {
|
const assertIndependentDiff = () => {
|
||||||
const diff = screen.getByTestId("file-edit-diff");
|
const diff = screen.getByTestId("file-edit-diff");
|
||||||
expect(diff).toBeVisible();
|
expect(diff).toBeVisible();
|
||||||
expect(screen.getByText("Edited")).toBeInTheDocument();
|
expect(screen.getByRole("img", { name: "Edited", exact: true })).toBeInTheDocument();
|
||||||
expect(diff.closest('[aria-hidden="true"], [inert], [data-testid="agent-activity-content"]'))
|
expect(diff.closest('[aria-hidden="true"], [inert], [data-testid="agent-activity-content"]'))
|
||||||
.toBeNull();
|
.toBeNull();
|
||||||
expect(screen.getByText("File updated")).toBeVisible();
|
expect(screen.getByText("File updated")).toBeVisible();
|
||||||
|
|||||||
Reference in new issue
Block a user