feat(webui): unify icons and refine interaction feedback (#6074)

* feat(webui): unify product icons and refine interaction feedback

* test(webui): align layout and tooltip expectations with icon refresh

* test(webui): verify temporary chat uses shared icon controls

* fix(webui): toggle workspace access directly and restore send arrow

* fix(webui): keep the send control circular

* fix(webui): clear workspace toggle background on pointer leave

* test(webui): isolate GitHub navigation in star prompt tests

* test(webui): prevent external default navigation during star link clicks
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-06 00:46:38 +08:00
1 parent 9dc0abae4f
commit 63bdd40280
59 files changed
+615 -505

No files matched your search

+4 -4
View File
@@ -840,7 +840,7 @@ describe("App layout", () => {
const newTopicButton = within(sidebar).getByRole("button", { name: "New topic" });
expect(newTopicButton).toHaveAttribute("aria-current", "page");
expect(newTopicButton).toHaveClass("transition-[width,padding,color]");
expect(newTopicButton).toHaveClass("transition-[width,padding,color,background-color]");
expect(newTopicButton).toBeEnabled();
});
@@ -986,11 +986,11 @@ describe("App layout", () => {
fireEvent.click(within(sidebar).getByRole("button", { name: "New topic" }));
const temporaryToggle = screen.getByRole("button", { name: "Temporary chat" });
expect(temporaryToggle).toHaveClass("h-8", "w-8", "rounded-full");
expect(temporaryToggle).toHaveClass("h-8", "w-8", "rounded-xl");
expect(within(temporaryToggle).queryByText("Temporary chat")).not.toBeInTheDocument();
fireEvent.click(temporaryToggle);
expect(temporaryToggle).toHaveAttribute("aria-pressed", "true");
expect(temporaryToggle).toHaveClass("bg-transparent", "shadow-none", "hover:bg-transparent");
expect(temporaryToggle).toHaveClass("icon-action");
expect(within(temporaryToggle).getByTestId("temporary-chat-icon")).toHaveClass(
"motion-safe:duration-150",
"text-[var(--temporary-control-active)]",
@@ -2977,7 +2977,7 @@ describe("App layout", () => {
expect(overviewButton).toHaveAttribute("aria-current", "page");
expect(overviewButton).not.toHaveClass("bg-sidebar-accent");
expect(overviewButton).toHaveClass("transition-[color]");
expect(overviewButton).toHaveClass("transition-[color,background-color]");
expect(settingsHighlight).toHaveAttribute("data-active-id", "overview");
fireEvent.click(modelsButton);
+12 -6
View File
@@ -32,11 +32,14 @@ beforeEach(() => window.localStorage.clear());
afterEach(() => { cleanup(); vi.restoreAllMocks(); });
describe("host switcher", () => {
it("announces the host only once when its display name is the hostname", () => {
it("announces the host only once when its display name is the hostname", async () => {
const value = { ...picker(1), name: "team-host", hostname: "team-host" };
render(<HostNavigationContext.Provider value={value}><HostSwitcher /></HostNavigationContext.Provider>);
expect(screen.getByRole("status").textContent).toBe("team-host · Connected");
expect(screen.getByRole("button", { name: "Switch host" })).toHaveAttribute("title", "team-host · Connected");
const trigger = screen.getByRole("button", { name: "Switch host" });
expect(trigger).not.toHaveAttribute("title");
await userEvent.hover(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent("team-host · Connected");
});
it("does not borrow the local socket's Connected status while restoring a remote", () => {
@@ -56,7 +59,8 @@ describe("host switcher", () => {
render(<HostNavigationContext.Provider value={value}><HostSwitcher /></HostNavigationContext.Provider>);
const trigger = screen.getByRole("button", { name: "Switch host" });
expect(within(trigger).getByText("Local", { exact: true })).toBeVisible();
expect(trigger).toHaveAttribute("title", expect.stringContaining("Connecting to Server 1"));
await userEvent.hover(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent("Connecting to Server 1");
expect(within(trigger).getByRole("status")).toHaveTextContent("Local · My-Mac · Connected · Connecting to Server 1");
await userEvent.click(trigger);
expect(screen.getByRole("menuitem", { name: "Local nanobot My-Mac" })).toHaveAttribute("aria-current", "true");
@@ -68,7 +72,8 @@ describe("host switcher", () => {
render(<HostNavigationContext.Provider value={value}><HostSwitcher /></HostNavigationContext.Provider>);
const trigger = screen.getByRole("button", { name: "Switch host" });
expect(within(trigger).getByRole("status")).toHaveTextContent("Local · My-Mac · Connected");
expect(trigger).toHaveAttribute("title", expect.stringContaining(value.error));
await userEvent.hover(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent(value.error);
expect(trigger).not.toHaveTextContent("Offline");
await userEvent.click(trigger);
expect(screen.getByRole("alert")).toHaveTextContent(value.error);
@@ -80,7 +85,7 @@ describe("host switcher", () => {
expect(screen.getByRole("status")).toHaveTextContent("Team server · team-host · Server connection lost");
});
it("keeps remote sidebar identity and connection status separate from pending or failed switches", () => {
it("keeps remote sidebar identity and connection status separate from pending or failed switches", async () => {
const value = { kind: "embedded" as const, name: "Team server", hostname: "team-host", pendingName: "Another server", open: vi.fn() };
const view = render(<HostNavigationContext.Provider value={value}><HostSwitcher /></HostNavigationContext.Provider>);
const trigger = screen.getByRole("button", { name: "Switch host" });
@@ -88,7 +93,8 @@ describe("host switcher", () => {
expect(within(trigger).getByRole("status")).toHaveTextContent("Team server · team-host · Connected · Connecting to Another server");
view.rerender(<HostNavigationContext.Provider value={{ ...value, pendingName: undefined, error: "Destination SSH is unreachable" }}><HostSwitcher /></HostNavigationContext.Provider>);
expect(within(trigger).getByRole("status")).toHaveTextContent("Team server · team-host · Connected");
expect(trigger).toHaveAttribute("title", expect.stringContaining("Destination SSH is unreachable"));
await userEvent.hover(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent("Destination SSH is unreachable");
});
it.each([0, 1, 5])("keeps %i saved hosts simple without search", async (count) => {
await openMenu(picker(count));
+4 -4
View File
@@ -10,7 +10,7 @@ const presets = [
];
describe("ModelPresetBadge setup tooltip", () => {
it.each([true, false])("hides model details on hover and focus (hero: %s)", async (isHero) => {
it.each([true, false])("keeps setup actionable without repeating its prompt in a tooltip (hero: %s)", async (isHero) => {
const user = userEvent.setup();
const onClick = vi.fn();
render(
@@ -27,12 +27,12 @@ describe("ModelPresetBadge setup tooltip", () => {
const trigger = screen.getByRole("button", { name: "Choose your AI" });
await user.hover(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent(/^Choose your AI$/);
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
await user.unhover(trigger);
fireEvent.keyDown(trigger, { key: "Escape" });
await waitFor(() => expect(screen.queryByRole("tooltip")).not.toBeInTheDocument());
fireEvent.focus(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent(/^Choose your AI$/);
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
await user.click(trigger);
expect(onClick).toHaveBeenCalledTimes(1);
});
@@ -56,7 +56,7 @@ describe("ModelPresetBadge setup tooltip", () => {
expect(trigger).toHaveTextContent("选择你的 AI");
expect(trigger.querySelector("[data-fallback]")).toBeNull();
fireEvent.focus(trigger);
expect(await screen.findByRole("tooltip")).toHaveTextContent(/^选择你的 AI$/);
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
},
);
});
+6 -3
View File
@@ -413,7 +413,7 @@ describe("PaneWorkbench", () => {
expect(screen.queryByTestId("workbench-pane-gamma")).not.toBeInTheDocument();
});
it("explains why the desktop add-pane control is disabled", () => {
it("explains why the desktop add-pane control is disabled", async () => {
render(
<PaneWorkbench
panes={[{ key: "alpha", title: "Alpha" }]}
@@ -430,8 +430,11 @@ describe("PaneWorkbench", () => {
/>,
);
expect(screen.getByRole("button", { name: "Add pane" }))
.toHaveAttribute("title", "Maximum 4 panes");
const addPane = screen.getByRole("button", { name: "Add pane" });
expect(addPane).toBeDisabled();
expect(addPane).not.toHaveAttribute("title");
fireEvent.pointerMove(addPane.parentElement!, { pointerType: "mouse" });
expect(await screen.findByRole("tooltip")).toHaveTextContent("Maximum 4 panes");
});
it("fills the workbench through alternating binary splits", () => {
+7 -1
View File
@@ -4,12 +4,18 @@ import { expect, it } from "vitest";
import { ReasoningRow } from "@/components/thread/activity/ReasoningRow";
it("shows the reasoning preview in the shared tooltip on hover and keyboard focus", async () => {
it("shows clipped reasoning in the shared tooltip on hover and keyboard focus", async () => {
const user = userEvent.setup();
const text = 'The user is saying "hi" again. I should respond in Chinese, concisely and in a friendly manner.';
const { container } = render(<ReasoningRow text={text} streaming={false} />);
const line = screen.getByTestId("activity-line");
const clippedLabel = line.querySelector(".truncate") as HTMLElement;
Object.defineProperties(clippedLabel, {
clientWidth: { value: 100 },
scrollWidth: { value: 200 },
});
expect(container.querySelector("[title]")).toBeNull();
await user.hover(line);
expect(await screen.findByRole("tooltip")).toHaveTextContent(text);
+3 -3
View File
@@ -710,7 +710,7 @@ describe("remote instance UX", () => {
const switcher = await screen.findByRole("button", { name: "Switch host" });
expect(screen.queryByRole("button", { name: "Remote connections" })).not.toBeInTheDocument();
expect(switcher).toHaveClass("w-8", "h-8");
expect(switcher).toHaveAttribute("title", expect.stringContaining("Xubin-Mac"));
expect(within(switcher).getByRole("status")).toHaveTextContent("Xubin-Mac");
await openDirectory();
});
@@ -801,7 +801,7 @@ describe("remote instance UX", () => {
expect(frame).toHaveAttribute("src", connection.url);
expect(frame).toHaveAttribute("sandbox", expect.not.stringContaining("allow-top-navigation"));
expect(document.querySelector('[data-host-view="local"]')).toHaveAttribute("inert");
expect(screen.getByRole("button", { name: "Switch host" })).toHaveAttribute("title", expect.stringContaining("Team server · team-host"));
expect(within(screen.getByRole("button", { name: "Switch host" })).getByRole("status")).toHaveTextContent("Team server · team-host");
expect(mocks.request).toHaveBeenCalledWith("remote.connect", { id: profile.id }, 65_000);
expect(window.sessionStorage.getItem("nanobot.remote-instance")).not.toContain("secret");
expect(readRecentRemotes()).toEqual([profile.id]);
@@ -1200,7 +1200,7 @@ describe("remote instance UX", () => {
view();
const identity = await screen.findByRole("button", { name: "Switch host" });
expect(identity).toHaveTextContent("Local");
expect(identity).toHaveAttribute("title", expect.stringContaining("Xubin-Mac"));
expect(within(identity).getByRole("status")).toHaveTextContent("Xubin-Mac");
expect(screen.getByRole("navigation", { name: "Sidebar navigation" })).toContainElement(identity);
expect(document.querySelector("header")).toBeNull();
fireEvent.pointerDown(identity, { button: 0, ctrlKey: false });
@@ -336,7 +336,6 @@ describe("SettingsView Apps catalog", () => {
));
const connected = await screen.findByRole("button", { name: "Manage team-docs" });
expect(connected).toHaveTextContent("Manage");
expect(connected.querySelector(".lucide-check")).not.toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Ready" }));
const readyHeading = await screen.findByRole("heading", { name: "team-docs" });
expect(within(readyHeading.closest("article") as HTMLElement).getByText("MCP"))
+8 -3
View File
@@ -29,6 +29,11 @@ async function enter() {
await act(async () => { await Promise.resolve(); });
}
async function clickStarLink(link: HTMLElement) {
link.addEventListener("click", (event) => event.preventDefault(), { once: true });
await act(async () => fireEvent.click(link));
}
it("claims once on entry and lets users skip without permanently dismissing", async () => {
const view = render(<StarPrompt ready />);
await enter();
@@ -95,7 +100,7 @@ it("the About link opens GitHub and persists permanent dismissal", async () => {
const link = screen.getByRole("link", { name: "Star nanobot on GitHub" });
expect(link).toHaveAttribute("href", "https://github.com/HKUDS/nanobot");
expect(link).toHaveAttribute("target", "_blank");
await act(async () => fireEvent.click(link));
await clickStarLink(link);
expect(action).toHaveBeenCalledWith(client, "dismiss");
});
@@ -167,10 +172,10 @@ it("keeps the GitHub action a real link and retries failed preference saves", as
expect(link).toHaveAttribute("target", "_blank");
expect(link.querySelector(".star-prompt-decoration")).toHaveAttribute("aria-hidden", "true");
action.mockRejectedValueOnce(new Error("offline"));
await act(async () => fireEvent.click(link));
await clickStarLink(link);
expect(screen.getByRole("alert")).toBeVisible();
expect(screen.getByRole("dialog")).toBeVisible();
await act(async () => fireEvent.click(link));
await clickStarLink(link);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
expect(action.mock.calls.map(([, command]) => command)).toEqual(["claim", "dismiss", "dismiss"]);
});
+32 -29
View File
@@ -6,7 +6,7 @@ import { ThreadComposer } from "@/components/thread/ThreadComposer";
import { ComposerDraftStore } from "@/lib/composer-draft";
import { encodeImage } from "@/lib/imageEncode";
import { SESSION_DRAG_TYPE } from "@/lib/session-drag";
import type { ChatSummary, CliAppInfo, McpPresetInfo, SlashCommand } from "@/lib/types";
import type { ChatSummary, CliAppInfo, McpPresetInfo, SlashCommand, WorkspaceScopePayload } from "@/lib/types";
vi.mock("@/lib/imageEncode", () => ({
encodeImage: vi.fn(async (file: File) => ({
@@ -801,7 +801,6 @@ describe("ThreadComposer", () => {
expect(input.parentElement?.parentElement?.className).toContain("max-w-[49.5rem]");
expect(input.parentElement?.parentElement?.className).toContain("rounded-panel");
expect(input.parentElement?.parentElement?.className).not.toContain("shadow-");
expect(screen.getByRole("button", { name: "Attach files" }).className).toContain("bg-card");
expect(screen.getByRole("button", { name: "Send message" }).className).toContain("bg-foreground");
expect(screen.queryByText(/Enter to send/)).not.toBeInTheDocument();
});
@@ -1093,7 +1092,7 @@ describe("ThreadComposer", () => {
);
const voiceButton = screen.getByRole("button", { name: "Voice input" });
expect(voiceButton).toHaveAttribute("title", "Click to dictate or hold");
expect(voiceButton).not.toHaveAttribute("title");
expect(voiceButton).toHaveAttribute("aria-keyshortcuts", "Control+Shift+D");
fireEvent.keyDown(window, { code: "KeyD", ctrlKey: true, key: "D", shiftKey: true });
expect(await screen.findByLabelText("Recording 0:00")).toBeInTheDocument();
@@ -1343,33 +1342,37 @@ describe("ThreadComposer", () => {
expect(screen.getByRole("progressbar", { name: "Context 50%" })).toBeVisible();
});
it("renders and changes workspace access mode", async () => {
it("toggles workspace access directly by click and keyboard", async () => {
const user = userEvent.setup();
const onWorkspaceScopeChange = vi.fn();
render(
<ThreadComposer
onSend={vi.fn()}
placeholder="Type your message..."
workspaceScope={{
project_path: "/tmp/project",
project_name: "project",
access_mode: "restricted",
restrict_to_workspace: true,
}}
workspaceControls={{ can_change_project: true, can_use_full_access: true }}
onWorkspaceScopeChange={onWorkspaceScopeChange}
/>,
);
fireEvent.pointerDown(screen.getByRole("button", { name: /Workspace access mode/ }));
fireEvent.click(await screen.findByRole("menuitem", { name: /Full Access/ }));
expect(onWorkspaceScopeChange).toHaveBeenCalledWith(
expect.objectContaining({
project_path: "/tmp/project",
access_mode: "full",
restrict_to_workspace: false,
}),
const restricted: WorkspaceScopePayload = {
project_path: "/tmp/project", project_name: "project",
access_mode: "restricted", restrict_to_workspace: true,
};
const composer = (workspaceScope: WorkspaceScopePayload, canUseFullAccess = true) => (
<ThreadComposer onSend={vi.fn()} placeholder="Type your message..."
workspaceScope={workspaceScope}
workspaceControls={{ can_change_project: true, can_use_full_access: canUseFullAccess }}
onWorkspaceScopeChange={onWorkspaceScopeChange} />
);
const { rerender } = render(composer(restricted));
const access = screen.getByRole("button", { name: /Workspace access mode/ });
expect(access).toHaveAttribute("aria-pressed", "false");
await user.click(access);
expect(screen.queryByRole("menu")).not.toBeInTheDocument();
const full = { ...restricted, access_mode: "full" as const, restrict_to_workspace: false };
expect(onWorkspaceScopeChange).toHaveBeenLastCalledWith(full);
rerender(composer(full));
expect(access).toHaveAttribute("aria-pressed", "true");
expect(access).toHaveAccessibleName("Workspace access mode: Full Access");
expect(access).toHaveFocus();
await user.keyboard("{Enter}");
expect(onWorkspaceScopeChange).toHaveBeenLastCalledWith(restricted);
rerender(composer(restricted, false));
expect(access).toBeDisabled();
onWorkspaceScopeChange.mockClear();
await user.click(access);
expect(onWorkspaceScopeChange).not.toHaveBeenCalled();
});
it("exposes full and compact workspace labels for container-driven compression", () => {
@@ -1394,7 +1397,7 @@ describe("ThreadComposer", () => {
});
const fullLabel = within(accessButton).getByText("Full Access");
const shortLabel = within(accessButton).getByText("Full");
expect(accessButton).toHaveAttribute("title", "Full Access");
expect(accessButton).not.toHaveAttribute("title");
expect(fullLabel).toHaveClass("thread-composer-access-label-full");
expect(shortLabel).toHaveClass("thread-composer-access-label-short");
expect(shortLabel).toHaveClass("hidden");
-1
View File
@@ -755,7 +755,6 @@ describe("ThreadMessages", () => {
"h-[var(--message-block-control-size)]",
"w-[var(--message-block-action-width)]",
"rounded-control",
"group-hover:bg-muted/70",
);
expect(disclosure.querySelector("svg")).toBeInTheDocument();
const toolbar = menu.querySelector("[data-message-block-toolbar]");
+2 -2
View File
@@ -1450,7 +1450,7 @@ describe("ThreadShell", () => {
expect(screen.queryByText(/This response used a fallback model/)).not.toBeInTheDocument();
});
it.each([false, true])("hides unconfigured model details in setup tooltips (existing history: %s)", async (hasHistory) => {
it.each([false, true])("keeps model setup actionable without a repeated tooltip (existing history: %s)", async (hasHistory) => {
const client = makeClient();
const settings = modelSettings("anthropic/claude-opus-4-5", "anthropic");
settings.agent.has_api_key = false;
@@ -1479,7 +1479,7 @@ describe("ThreadShell", () => {
await screen.findByText(hasHistory ? "Previous message" : HERO_GREETING_PATTERN);
const badge = screen.getByRole("button", { name: "Choose your AI" });
fireEvent.focus(badge);
expect(await screen.findByRole("tooltip")).toHaveTextContent(/^Choose your AI$/);
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
fireEvent.click(badge);
expect(onOpenModelSettings).toHaveBeenCalledTimes(1);
expect(client.sendMessage).not.toHaveBeenCalled();