feat(webui): streamline contextual message controls (#5831)
This commit is contained in:
1 parent
99a7ec256f
commit
920efd00b8
24 files changed
+1776
-955
No files matched your search
@@ -10,12 +10,7 @@ function renderShell(expanded: boolean) {
|
||||
active={false}
|
||||
expanded={expanded}
|
||||
label="Thought"
|
||||
viewportRef={() => undefined}
|
||||
contentRef={() => undefined}
|
||||
fadeTop={false}
|
||||
fadeBottom={false}
|
||||
onToggle={vi.fn()}
|
||||
onScroll={vi.fn()}
|
||||
>
|
||||
<button type="button">Hidden action</button>
|
||||
</ThinkingReasoningShell>,
|
||||
@@ -23,6 +18,64 @@ function renderShell(expanded: boolean) {
|
||||
}
|
||||
|
||||
describe("ThinkingReasoningShell", () => {
|
||||
it.each([false, true])("shows activity without clipping or edge fades (active: %s)", (active) => {
|
||||
render(
|
||||
<ThinkingReasoningShell
|
||||
active={active}
|
||||
expanded
|
||||
label={active ? "Working" : "Worked"}
|
||||
onToggle={vi.fn()}
|
||||
>
|
||||
{Array.from({ length: 16 }, (_, index) => <div key={index}>Activity {index + 1}</div>)}
|
||||
</ThinkingReasoningShell>
|
||||
);
|
||||
const content = screen.getByTestId("agent-activity-content");
|
||||
expect(content).not.toHaveClass("max-h-[180px]");
|
||||
expect(content).not.toHaveClass("overflow-y-auto");
|
||||
expect(screen.queryByTestId("activity-scroll-fade-top")).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId("activity-scroll-fade-bottom")).not.toBeInTheDocument();
|
||||
expect(screen.getByText("Activity 1")).toBeVisible();
|
||||
expect(screen.getByText("Activity 16")).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps the same header and content layout when live activity completes", () => {
|
||||
const shell = (active: boolean) => (
|
||||
<ThinkingReasoningShell active={active} expanded label={active ? "Working" : "Worked"}
|
||||
collapseLabel="Collapse activity details" onToggle={vi.fn()}>
|
||||
<p>A processing step</p>
|
||||
</ThinkingReasoningShell>
|
||||
);
|
||||
const view = render(shell(true));
|
||||
const button = screen.getByRole("button", { name: "Working · Collapse activity details" });
|
||||
const content = screen.getByTestId("agent-activity-content");
|
||||
const headerClass = button.className;
|
||||
const contentClass = content.className;
|
||||
expect(button.querySelector("svg")).toHaveClass("lucide-activity");
|
||||
expect(view.container.querySelector("[data-contextual-activity-guide]")).toBeInTheDocument();
|
||||
|
||||
view.rerender(shell(false));
|
||||
|
||||
expect(screen.getByRole("button", { name: "Worked · Collapse activity details" })).toBe(button);
|
||||
expect(button.className).toBe(headerClass);
|
||||
expect(screen.getByTestId("agent-activity-content")).toBe(content);
|
||||
expect(content.className).toBe(contentClass);
|
||||
});
|
||||
|
||||
it("aligns the waiting status with the disclosure shown when details arrive", () => {
|
||||
const shell = (hasDetails: boolean) => (
|
||||
<ThinkingReasoningShell active expanded hasDetails={hasDetails} label="Working"
|
||||
onToggle={vi.fn()}><p>A processing step</p></ThinkingReasoningShell>
|
||||
);
|
||||
const view = render(shell(false));
|
||||
const status = screen.getByRole("status", { name: "Working" });
|
||||
expect(status).toHaveClass("touch-target", "h-7", "px-1.5");
|
||||
expect(status.querySelector("svg")).toHaveClass("lucide-activity");
|
||||
expect(screen.queryByRole("button")).not.toBeInTheDocument();
|
||||
|
||||
view.rerender(shell(true));
|
||||
expect(screen.getByRole("button", { name: "Working" })).toHaveClass(...status.classList);
|
||||
});
|
||||
|
||||
it("mounts details on first expansion and preserves their state across folding", () => {
|
||||
const mounted = vi.fn();
|
||||
function Details() {
|
||||
@@ -31,8 +84,7 @@ describe("ThinkingReasoningShell", () => {
|
||||
}
|
||||
const shell = (expanded: boolean) => (
|
||||
<ThinkingReasoningShell active={false} expanded={expanded} label="Thought"
|
||||
viewportRef={null} contentRef={null} fadeTop={false} fadeBottom={false}
|
||||
onToggle={() => {}} onScroll={() => {}}><Details /></ThinkingReasoningShell>
|
||||
onToggle={() => {}}><Details /></ThinkingReasoningShell>
|
||||
);
|
||||
const view = render(shell(false));
|
||||
expect(mounted).toHaveBeenCalledTimes(0);
|
||||
@@ -46,7 +98,7 @@ describe("ThinkingReasoningShell", () => {
|
||||
it("makes collapsed descendants inert as well as visually hidden", () => {
|
||||
const { rerender } = renderShell(false);
|
||||
const disclosure = screen.getByRole("button", { name: "Thought" });
|
||||
const collapsible = disclosure.nextElementSibling;
|
||||
const collapsible = disclosure.parentElement?.nextElementSibling;
|
||||
|
||||
expect(collapsible).toHaveAttribute("inert");
|
||||
expect(collapsible).toHaveAttribute("aria-hidden", "true");
|
||||
@@ -56,18 +108,14 @@ describe("ThinkingReasoningShell", () => {
|
||||
active={false}
|
||||
expanded
|
||||
label="Thought"
|
||||
viewportRef={() => undefined}
|
||||
contentRef={() => undefined}
|
||||
fadeTop={false}
|
||||
fadeBottom={false}
|
||||
onToggle={vi.fn()}
|
||||
onScroll={vi.fn()}
|
||||
>
|
||||
<button type="button">Hidden action</button>
|
||||
</ThinkingReasoningShell>,
|
||||
);
|
||||
|
||||
expect(disclosure.nextElementSibling).not.toHaveAttribute("inert");
|
||||
expect(disclosure.nextElementSibling).toHaveAttribute("aria-hidden", "false");
|
||||
const expandedCollapsible = disclosure.parentElement?.nextElementSibling;
|
||||
expect(expandedCollapsible).not.toHaveAttribute("inert");
|
||||
expect(expandedCollapsible).toHaveAttribute("aria-hidden", "false");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user