fix(coding-agent): removed redundant tool-name line in custom render
- Fixed custom-rendered tools with `mergeCallAndResult` (e.g. `lsp`) emitting a redundant tool-name line above the framed result. - Collapsed the leading blank line for self-delimiting framed boxes. - Added gallery fidelity routing `lsp`/`task` through the custom-tool branch via a `customRendered` fixture flag. - Added gallery harness tests guarding state coverage and the custom-branch fallback label.
This commit is contained in:
@@ -45,10 +45,26 @@ const GENERIC_ERROR: GalleryResult = {
|
||||
isError: true,
|
||||
};
|
||||
|
||||
/** Build the fake `AgentTool` the component needs for its label and edit mode. */
|
||||
/**
|
||||
* Build the fake `AgentTool` the component needs for its label, edit mode, and —
|
||||
* for `customRendered` fixtures — the renderer functions that route it through
|
||||
* the same custom-tool branch production uses (see {@link GalleryFixture}).
|
||||
*/
|
||||
function fakeToolFor(name: string, fixture: GalleryFixture | undefined): AgentTool | undefined {
|
||||
if (!fixture?.label && !fixture?.editMode) return undefined;
|
||||
return { name, label: fixture.label ?? name, mode: fixture.editMode } as unknown as AgentTool;
|
||||
if (!fixture?.label && !fixture?.editMode && !fixture?.customRendered) return undefined;
|
||||
const tool: Record<string, unknown> = { name, label: fixture.label ?? name, mode: fixture.editMode };
|
||||
if (fixture.customRendered) {
|
||||
const renderer = toolRenderers[name] as
|
||||
| { renderCall?: unknown; renderResult?: unknown; mergeCallAndResult?: unknown; inline?: unknown }
|
||||
| undefined;
|
||||
if (renderer) {
|
||||
tool.renderCall = renderer.renderCall;
|
||||
tool.renderResult = renderer.renderResult;
|
||||
tool.mergeCallAndResult = renderer.mergeCallAndResult;
|
||||
tool.inline = renderer.inline;
|
||||
}
|
||||
}
|
||||
return tool as unknown as AgentTool;
|
||||
}
|
||||
|
||||
/** The curated fixture for a tool, or a generic one for registry tools lacking sample data. */
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { GalleryFixture } from "./types";
|
||||
export const agenticFixtures: Record<string, GalleryFixture> = {
|
||||
task: {
|
||||
label: "Task",
|
||||
customRendered: true,
|
||||
// Streaming: agent chosen, first task fully arrived, second still landing.
|
||||
streamingArgs: {
|
||||
agent: "task",
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { GalleryFixture } from "./types";
|
||||
export const codeintelFixtures: Record<string, GalleryFixture> = {
|
||||
lsp: {
|
||||
label: "LSP",
|
||||
customRendered: true,
|
||||
streamingArgs: {
|
||||
action: "references",
|
||||
file: "src/server/auth.ts",
|
||||
|
||||
@@ -16,6 +16,15 @@ export interface GalleryFixture {
|
||||
label?: string;
|
||||
/** Edit mode for edit-like tools so the streaming preview dispatches correctly. */
|
||||
editMode?: EditMode;
|
||||
/**
|
||||
* Set for tools whose real `AgentTool` attaches `renderCall`/`renderResult`
|
||||
* directly on the instance (e.g. `lsp`, `task`). The harness then attaches
|
||||
* the registry renderer onto the fake tool so the component routes through
|
||||
* the custom-tool branch — the same path production takes — instead of the
|
||||
* built-in registry branch. The two branches can diverge, so exercising the
|
||||
* real one keeps the gallery honest for these tools.
|
||||
*/
|
||||
customRendered?: boolean;
|
||||
/**
|
||||
* Arguments shown during the streaming state — a partial view of {@link args}
|
||||
* as if the tool-call JSON were still arriving. May include `__partialJson`
|
||||
|
||||
Reference in New Issue
Block a user