Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

[Fix] Studio: show "Using tool" for active tool calls (#10548)

Debojyoti Banerjee29463b255ac7
diff --git a/studio/frontend/src/components/assistant-ui/tool-arg-text.ts b/studio/frontend/src/components/assistant-ui/tool-arg-text.ts
index 3ab3fead547..2752da558d1 100644
--- a/studio/frontend/src/components/assistant-ui/tool-arg-text.ts
+++ b/studio/frontend/src/components/assistant-ui/tool-arg-text.ts
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import type { ToolCallMessagePartStatus } from "@assistant-ui/react";
+
/**
* How much of a serialised object a card shows. Only the JSON branch is capped,
* so every string argument is returned untouched.
@@ -47,3 +49,91 @@ export const toolArgText = (value: unknown): string => {
return "";
}
};
+
+// A part inherits the message status until it has a result, tested for
+// truthiness: a tool returning "" or 0 reads as running until the message does.
+export const isToolCallRunning = (
+ status?: ToolCallMessagePartStatus,
+): boolean => status?.type === "running";
+
+export const isToolCallCancelled = (
+ status?: ToolCallMessagePartStatus,
+): boolean => status?.type === "incomplete" && status.reason === "cancelled";
+
+export function toolFallbackLabel(status?: ToolCallMessagePartStatus): string {
+ if (isToolCallCancelled(status)) return "Cancelled tool";
+ return isToolCallRunning(status) ? "Using tool" : "Used tool";
+}
+
+export interface WebSearchToolNameState {
+ isRunning: boolean;
+ isFindInPage: boolean;
+ isUrlFetch: boolean;
+ isImageOnly: boolean;
+ foundImages: boolean;
+ displayDomain: string;
+ pattern: string;
+ query: string;
+ imageLabel: string;
+}
+
+// The trigger prefixes these with "Using tool" while the call runs.
+export function webSearchToolName(state: WebSearchToolNameState): string {
+ const {
+ isRunning,
+ isFindInPage,
+ isUrlFetch,
+ isImageOnly,
+ foundImages,
+ displayDomain,
+ pattern,
+ query,
+ imageLabel,
+ } = state;
+
+ if (isFindInPage) {
+ const page = displayDomain || "page";
+ if (isRunning) {
+ return pattern
+ ? `Finding "${pattern}" in ${page}…`
+ : `Searching ${page}…`;
+ }
+ // Neutral: the action carries no match status, so a finished call is not
+ // evidence the pattern was there.
+ return pattern
+ ? `Searched for "${pattern}" in ${page}`
+ : `Searched ${page}`;
+ }
+ if (isUrlFetch) {
+ if (isRunning) return `Reading ${displayDomain || "page"}…`;
+ return displayDomain ? `Read ${displayDomain}` : "Read page";
+ }
+ if (isImageOnly) {
+ if (isRunning) return `Finding images for “${imageLabel}”`;
+ return foundImages
+ ? `Found images for “${imageLabel}”`
+ : `No images for “${imageLabel}”`;
+ }
+ if (!query) return isRunning ? "Searching…" : "Web Search";
+ if (isRunning) return `Searching for "${query}"…`;
+ return imageLabel && foundImages
+ ? `Searched "${query}" · images for ${imageLabel}`
+ : `Searched "${query}"`;
+}
+
+export interface KnowledgeBaseToolNameState {
+ isRunning: boolean;
+ query: string;
+}
+
+export function knowledgeBaseToolName(
+ state: KnowledgeBaseToolNameState,
+): string {
+ const { isRunning, query } = state;
+ if (isRunning) {
+ return query
+ ? `Searching documents for "${query}"…`
+ : "Searching documents…";
+ }
+ return query ? `Searched documents for "${query}"` : "Knowledge search";
+}
diff --git a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx b/studio/frontend/src/components/assistant-ui/tool-fallback.tsx
index e5d6eee5d41..aa649e2125b 100644
--- a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-fallback.tsx
@@ -39,7 +39,12 @@ import {
useRef,
useState,
} from "react";
-import { toolArgText } from "./tool-arg-text";
+import {
+ isToolCallCancelled,
+ isToolCallRunning,
+ toolArgText,
+ toolFallbackLabel,
+} from "./tool-arg-text";
import { syncToolActivityPreference } from "./tool-activity-open-state";
const ANIMATION_DURATION = 200;
@@ -163,12 +168,11 @@ function ToolFallbackTrigger({
icon?: ElementType;
}) {
const statusType = status?.type ?? "complete";
- const isRunning = statusType === "running";
- const isCancelled =
- status?.type === "incomplete" && status.reason === "cancelled";
+ const isRunning = isToolCallRunning(status);
+ const isCancelled = isToolCallCancelled(status);
const StatusIcon = statusIconMap[statusType];
- const label = isCancelled ? "Cancelled tool" : "Used tool";
+ const label = toolFallbackLabel(status);
const name = toolArgText(toolName);
const displayName = formatMcpToolName(name, mcpServer) ?? name;
@@ -423,8 +427,7 @@ const ToolFallbackImpl: ToolCallMessagePartComponent = ({
const mcpServer = mcpServerFromProvenance(
(rest as { provenance?: unknown }).provenance,
);
- const isCancelled =
- status?.type === "incomplete" && status.reason === "cancelled";
+ const isCancelled = isToolCallCancelled(status);
return (
<ToolFallbackRoot className={cn(isCancelled && "bg-muted/30")}>
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-code-execution.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-code-execution.tsx
index 4183a64623b..f2cd05eab42 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-code-execution.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-code-execution.tsx
@@ -14,7 +14,7 @@ import { CopyIcon, FileTextIcon, TerminalIcon } from "lucide-react";
import { Tick02Icon } from "@/lib/tick-icon";
import { HugeiconsIcon } from "@hugeicons/react";
import { Spinner } from "@/components/ui/spinner";
-import { toolArgText } from "./tool-arg-text";
+import { isToolCallRunning, toolArgText } from "./tool-arg-text";
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useToolAwaitingApproval } from "@/features/chat";
import {
@@ -141,7 +141,7 @@ const CodeExecutionToolUIImpl: ToolCallMessagePartComponent = ({
const kind = parsedArgs.kind ?? "bash";
const command = toolArgText(parsedArgs.command);
const path = toolArgText(parsedArgs.path);
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
const commandLabel = command ? truncateCommandLabel(command) : "";
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx
index 444f309796d..ba98f72c45d 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx
@@ -14,7 +14,7 @@ import type { CSSProperties, MouseEvent } from "react";
import { memo, useCallback, useEffect, useRef, useState } from "react";
import { useGeneratedImageOverlay } from "./generated-image-overlay-context";
import { downloadImagePart } from "./image";
-import { toolArgText } from "./tool-arg-text";
+import { isToolCallRunning, toolArgText } from "./tool-arg-text";
import {
ToolFallbackContent,
ToolFallbackRoot,
@@ -171,7 +171,7 @@ const ImageGenerationToolUIImpl: ToolCallMessagePartComponent = ({
const { openOverlay } = useGeneratedImageOverlay();
const parsedArgs = (args as ImageGenerationArgs) ?? {};
const prompt = toolArgText(parsedArgs.prompt);
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
const isImageResult =
!!result &&
@@ -226,7 +226,7 @@ const ImageGenerationToolUIImpl: ToolCallMessagePartComponent = ({
canExpand: boolean;
} | null>(null);
const captionRef = useRef<HTMLDivElement | null>(null);
- const isPendingImage = !imagePart && status?.type === "running";
+ const isPendingImage = !imagePart && isRunning;
const promptOverflowMeasured = promptOverflow?.prompt === captionPrompt;
const promptCanExpand = promptOverflowMeasured
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-knowledge-base.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-knowledge-base.tsx
index 7d6bcbc29a3..d72f31b6b43 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-knowledge-base.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-knowledge-base.tsx
@@ -14,7 +14,11 @@ import { useToolAwaitingApproval } from "@/features/chat";
import { stringifyToolResult } from "@/lib/strip-ansi";
import { memo, useMemo } from "react";
import { Badge } from "./badge";
-import { toolArgText } from "./tool-arg-text";
+import {
+ isToolCallRunning,
+ knowledgeBaseToolName,
+ toolArgText,
+} from "./tool-arg-text";
import {
ToolFallbackContent,
ToolFallbackRoot,
@@ -81,7 +85,7 @@ const KnowledgeBaseToolUIImpl: ToolCallMessagePartComponent = ({
toolCallId,
}) => {
const query = toolArgText((args as { query?: unknown })?.query);
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
const resultText = result == null ? "" : stringifyToolResult(result);
const citations = useMemo(() => parseCitations(result), [result]);
@@ -111,7 +115,7 @@ const KnowledgeBaseToolUIImpl: ToolCallMessagePartComponent = ({
awaitingApproval={awaitingApproval}
>
<ToolFallbackTrigger
- toolName={query ? `Searched documents for "${query}"` : "Knowledge search"}
+ toolName={knowledgeBaseToolName({ isRunning, query })}
status={status}
icon={LibraryBigIcon}
/>
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx
index 911cb86b779..af2f4b8e8fc 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx
@@ -23,7 +23,7 @@ import { memo } from "react";
import { pythonToolImagePath } from "./python-tool-image-path";
import { useSandboxImage } from "./use-sandbox-image";
import { CopyBtn, ToolCodeCell } from "./tool-code-cell";
-import { toolArgText } from "./tool-arg-text";
+import { isToolCallRunning, toolArgText } from "./tool-arg-text";
import {
ToolFallbackContent,
ToolFallbackRoot,
@@ -84,7 +84,7 @@ const PythonToolUIImpl: ToolCallMessagePartComponent = ({
}) => {
const code = toolArgText((args as { code?: unknown })?.code);
const firstLine = code.split("\n")[0]?.slice(0, 60) ?? "";
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
// Args still streaming = the model is WRITING the code, not running it yet.
const { propStatus } = useToolArgsStatus();
const isWritingCode = isRunning && propStatus.code === "streaming";
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-render-html.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-render-html.tsx
index d9c1fbaf6d0..aef4a3077f7 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-render-html.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-render-html.tsx
@@ -16,6 +16,7 @@ import {
import { BrowserIcon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { memo, useEffect } from "react";
+import { isToolCallRunning } from "./tool-arg-text";
// Per Context7 assistant-ui docs: tool UIs read streaming args via
// useToolArgsStatus, so render_html need not wait for tool completion.
@@ -38,7 +39,7 @@ const RenderHtmlToolUIImpl: ToolCallMessagePartComponent = ({
const hasCode = code.trim().length > 0;
const title =
typeof parsedArgs.title === "string" ? parsedArgs.title : "HTML canvas";
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
const codeIsStreaming = propStatus.code === "streaming";
// Surface the backend error when the tool call completed with invalid args.
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-terminal.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-terminal.tsx
index e7744dce95e..9e63889dbbf 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-terminal.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-terminal.tsx
@@ -13,8 +13,8 @@ import {
ToolFallbackRoot,
ToolFallbackTrigger,
} from "./tool-fallback";
+import { isToolCallRunning, toolArgText } from "./tool-arg-text";
import { CopyBtn, ToolCodeCell } from "./tool-code-cell";
-import { toolArgText } from "./tool-arg-text";
import { ToolLiveOutput } from "./tool-live-output";
import { ToolResultOutput } from "./tool-result-output";
import { SandboxFiles } from "./sandbox-files-view";
@@ -36,7 +36,7 @@ const TerminalToolUIImpl: ToolCallMessagePartComponent = ({
status,
}) => {
const command = toolArgText((args as { command?: unknown })?.command);
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
// Args still streaming = the model is WRITING the command, not running it yet.
const { propStatus } = useToolArgsStatus();
const isWritingCommand = isRunning && propStatus.command === "streaming";
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-web-search.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-web-search.tsx
index 527483967b7..9d8aee16f2a 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-web-search.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-web-search.tsx
@@ -18,7 +18,11 @@ import { stringifyToolResult } from "@/lib/strip-ansi";
import { memo } from "react";
import { SearchImageThumb } from "./search-image";
import { Source, SourceIcon, SourceTitle } from "./sources";
-import { toolArgText } from "./tool-arg-text";
+import {
+ isToolCallRunning,
+ toolArgText,
+ webSearchToolName,
+} from "./tool-arg-text";
import {
ToolFallbackContent,
ToolFallbackRoot,
@@ -135,7 +139,7 @@ const WebSearchToolUIImpl: ToolCallMessagePartComponent = ({
return "";
}
})();
- const isRunning = status?.type === "running";
+ const isRunning = isToolCallRunning(status);
const withImages = isSearchImagesToolResult(result);
const resultText =
result == null
@@ -160,6 +164,18 @@ const WebSearchToolUIImpl: ToolCallMessagePartComponent = ({
const awaitingApproval = useToolAwaitingApproval(toolCallId);
const [open, setOpen] = useToolActivityOpen(isRunning, hasText);
+ const toolName = webSearchToolName({
+ isRunning,
+ isFindInPage,
+ isUrlFetch,
+ isImageOnly,
+ foundImages,
+ displayDomain,
+ pattern,
+ query,
+ imageLabel,
+ });
+
return (
<ToolFallbackRoot
open={open}
@@ -167,29 +183,7 @@ const WebSearchToolUIImpl: ToolCallMessagePartComponent = ({
awaitingApproval={awaitingApproval}
>
<ToolFallbackTrigger
- toolName={
- isFindInPage
- ? // Neutral: the action carries no match status, so a finished call
- // is not evidence the pattern was there.
- pattern
- ? `Searched for "${pattern}" in ${displayDomain || "page"}`
- : `Searched ${displayDomain || "page"}`
- : isUrlFetch
- ? displayDomain
- ? `Read ${displayDomain}`
- : "Read page"
- : isImageOnly
- ? isRunning
- ? `Finding images for “${imageLabel}”`
- : foundImages
- ? `Found images for “${imageLabel}”`
- : `No images for “${imageLabel}”`
- : query
- ? imageLabel && foundImages
- ? `Searched "${query}" · images for ${imageLabel}`
- : `Searched "${query}"`
- : "Web Search"
- }
+ toolName={toolName}
status={status}
icon={GlobeIcon}
/>
diff --git a/studio/frontend/tests/tool-fallback-label.test.ts b/studio/frontend/tests/tool-fallback-label.test.ts
new file mode 100644
index 00000000000..b1c4fa396ef
--- /dev/null
+++ b/studio/frontend/tests/tool-fallback-label.test.ts
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ isToolCallCancelled,
+ isToolCallRunning,
+ knowledgeBaseToolName,
+ toolFallbackLabel,
+} from "../src/components/assistant-ui/tool-arg-text.ts";
+
+test("a call still in flight says it is being used", () => {
+ assert.equal(toolFallbackLabel({ type: "running" }), "Using tool");
+ assert.equal(isToolCallRunning({ type: "running" }), true);
+});
+
+// A resultless part inherits the message's terminal status; restored history has none.
+test("every settled status says the call is over", () => {
+ assert.equal(toolFallbackLabel({ type: "complete" }), "Used tool");
+ assert.equal(toolFallbackLabel(undefined), "Used tool");
+ assert.equal(
+ toolFallbackLabel({ type: "requires-action", reason: "interrupt" }),
+ "Used tool",
+ );
+ assert.equal(
+ toolFallbackLabel({ type: "incomplete", reason: "error" }),
+ "Used tool",
+ );
+ assert.equal(
+ toolFallbackLabel({ type: "incomplete", reason: "length" }),
+ "Used tool",
+ );
+ assert.equal(isToolCallRunning({ type: "complete" }), false);
+ assert.equal(isToolCallRunning(undefined), false);
+});
+
+test("cancellation outranks the in-flight wording", () => {
+ assert.equal(
+ toolFallbackLabel({ type: "incomplete", reason: "cancelled" }),
+ "Cancelled tool",
+ );
+ assert.equal(
+ isToolCallCancelled({ type: "incomplete", reason: "cancelled" }),
+ true,
+ );
+ // The other incomplete reasons are failures, which keep the plain label.
+ assert.equal(
+ isToolCallCancelled({ type: "incomplete", reason: "error" }),
+ false,
+ );
+ assert.equal(isToolCallCancelled({ type: "running" }), false);
+});
+
+test("a running search is never named in the past tense", () => {
+ assert.equal(
+ knowledgeBaseToolName({ isRunning: true, query: "adapters" }),
+ 'Searching documents for "adapters"…',
+ );
+ assert.equal(
+ knowledgeBaseToolName({ isRunning: true, query: "" }),
+ "Searching documents…",
+ );
+});
+
+test("a finished search keeps the wording it shipped with", () => {
+ assert.equal(
+ knowledgeBaseToolName({ isRunning: false, query: "adapters" }),
+ 'Searched documents for "adapters"',
+ );
+ assert.equal(
+ knowledgeBaseToolName({ isRunning: false, query: "" }),
+ "Knowledge search",
+ );
+});
+
+test("the query reaches the header, whichever tense it is in", () => {
+ for (const isRunning of [true, false]) {
+ assert.match(
+ knowledgeBaseToolName({ isRunning, query: "quantisation" }),
+ /quantisation/,
+ );
+ assert.doesNotMatch(
+ knowledgeBaseToolName({ isRunning, query: "" }),
+ /""|undefined/,
+ );
+ }
+});
diff --git a/studio/frontend/tests/web-search-action-variants.test.ts b/studio/frontend/tests/web-search-action-variants.test.ts
index fef128a0672..ed4a936b246 100644
--- a/studio/frontend/tests/web-search-action-variants.test.ts
+++ b/studio/frontend/tests/web-search-action-variants.test.ts
@@ -6,6 +6,11 @@ import test from "node:test";
import { readSrc } from "./helpers/kit.ts";
+import {
+ type WebSearchToolNameState,
+ webSearchToolName,
+} from "../src/components/assistant-ui/tool-arg-text.ts";
+
const CARD = readSrc("components/assistant-ui/tool-ui-web-search.tsx");
test("the card tells the three action types apart", () => {
@@ -23,11 +28,19 @@ test("the card tells the three action types apart", () => {
test("a finished find_in_page does not claim it found the pattern", () => {
// The action names the pattern the model looked for and nothing about whether
// it matched, so a completed call is not evidence that it did.
- assert.doesNotMatch(CARD, /`Found "\$\{pattern\}"/);
- assert.match(
- CARD,
- /`Searched for "\$\{pattern\}" in \$\{displayDomain \|\| "page"\}`/,
- );
+ const finished = webSearchToolName({
+ isRunning: false,
+ isFindInPage: true,
+ isUrlFetch: false,
+ isImageOnly: false,
+ foundImages: false,
+ displayDomain: "example.com",
+ pattern: "needle",
+ query: "",
+ imageLabel: "",
+ });
+ assert.equal(finished, 'Searched for "needle" in example.com');
+ assert.doesNotMatch(finished, /Found/);
});
test("the url variants show the page they read, whatever else the card has", () => {
@@ -71,3 +84,104 @@ test("the read-page link opens in Desktop, not just the browser", () => {
assert.match(anchor, /openLink\(safeUrl\)/);
assert.match(anchor, /e\.preventDefault\(\)/);
});
+
+const BASE: WebSearchToolNameState = {
+ isRunning: false,
+ isFindInPage: false,
+ isUrlFetch: false,
+ isImageOnly: false,
+ foundImages: false,
+ displayDomain: "",
+ pattern: "",
+ query: "",
+ imageLabel: "",
+};
+
+const name = (state: Partial<WebSearchToolNameState>) =>
+ webSearchToolName({ ...BASE, ...state });
+
+test("a running call is never named in the past tense", () => {
+ const running = [
+ name({
+ isRunning: true,
+ isFindInPage: true,
+ pattern: "todo",
+ displayDomain: "example.com",
+ }),
+ name({ isRunning: true, isFindInPage: true, displayDomain: "example.com" }),
+ name({ isRunning: true, isFindInPage: true }),
+ name({ isRunning: true, isUrlFetch: true, displayDomain: "example.com" }),
+ name({ isRunning: true, isUrlFetch: true }),
+ name({ isRunning: true, isImageOnly: true, imageLabel: "otters" }),
+ name({ isRunning: true, query: "unsloth" }),
+ name({ isRunning: true }),
+ ];
+ for (const label of running) {
+ assert.doesNotMatch(
+ label,
+ /^(Searched|Read|Found|No images)\b/,
+ `"${label}" reads as a finished call`,
+ );
+ }
+ assert.deepEqual(running, [
+ 'Finding "todo" in example.com…',
+ "Searching example.com…",
+ "Searching page…",
+ "Reading example.com…",
+ "Reading page…",
+ "Finding images for “otters”",
+ 'Searching for "unsloth"…',
+ "Searching…",
+ ]);
+});
+
+test("a settled call keeps the wording it shipped with", () => {
+ assert.equal(
+ name({ isFindInPage: true, pattern: "todo", displayDomain: "example.com" }),
+ 'Searched for "todo" in example.com',
+ );
+ assert.equal(
+ name({ isFindInPage: true, displayDomain: "example.com" }),
+ "Searched example.com",
+ );
+ assert.equal(name({ isFindInPage: true }), "Searched page");
+ assert.equal(
+ name({ isUrlFetch: true, displayDomain: "example.com" }),
+ "Read example.com",
+ );
+ assert.equal(name({ isUrlFetch: true }), "Read page");
+ assert.equal(name({ query: "unsloth" }), 'Searched "unsloth"');
+ assert.equal(name({}), "Web Search");
+});
+
+test("the image header only claims images that came back", () => {
+ assert.equal(
+ name({ isImageOnly: true, imageLabel: "otters", foundImages: true }),
+ "Found images for “otters”",
+ );
+ assert.equal(
+ name({ isImageOnly: true, imageLabel: "otters" }),
+ "No images for “otters”",
+ );
+ // Same rule on the combined query + images header.
+ assert.equal(
+ name({ query: "otters", imageLabel: "otters", foundImages: true }),
+ 'Searched "otters" · images for otters',
+ );
+ assert.equal(
+ name({ query: "otters", imageLabel: "otters" }),
+ 'Searched "otters"',
+ );
+ // Images can come back for a plain query that named none of its own.
+ assert.equal(
+ name({ query: "otters", foundImages: true }),
+ 'Searched "otters"',
+ );
+});
+
+test("a url fetch names the page, not the query the call may carry", () => {
+ assert.equal(
+ name({ isUrlFetch: true, displayDomain: "example.com", query: "unsloth" }),
+ "Read example.com",
+ );
+});