From 3f65a30e3f78e749110ad0d883e265b3a59dec13 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Wed, 8 Jul 2026 21:31:37 +0530 Subject: feat: add expand/collapse (Ctrl+O) rendering to web_search and read_page Both tools dumped full output into the TUI. Add a shared renderExpandableText helper (src/domains/render.ts) mirroring browser_execute_js: a compact preview by default, full body on expand via keyHint("app.tools.expand"). Tools stash a {summary, body, fullOutputPath} render payload in details; the full text still goes to the LLM via ToolOk.text. Also surfaces engine + result count in the web_search summary line (closes the S4 observability gap). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/domains/search/web-search.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/domains/search') diff --git a/src/domains/search/web-search.ts b/src/domains/search/web-search.ts index e5d343d..41a0f36 100644 --- a/src/domains/search/web-search.ts +++ b/src/domains/search/web-search.ts @@ -9,6 +9,7 @@ import { openIsolatedTab, waitForIsolatedLoad, } from "../isolated-tab"; +import { renderExpandableText } from "../render"; import { buildSerpExtractionExpr } from "./extract"; import { classifySerp, parseGoogleSerp, type SearchResult, type SerpExtraction } from "./google-serp"; @@ -81,13 +82,19 @@ export const webSearchTool = defineBrowserTool({ }); } - const truncated = await applyTruncation(formatResults(args.query, results), "search"); + const body = formatResults(args.query, results); + const truncated = await applyTruncation(body, "search"); return ok({ text: truncated.text, details: { results, engine: "google", query: args.query, + render: { + summary: `${results.length} result(s) · google · "${args.query}"`, + body, + ...(truncated.fullOutputPath !== undefined ? { fullOutputPath: truncated.fullOutputPath } : {}), + }, ...(truncated.fullOutputPath !== undefined ? { fullOutputPath: truncated.fullOutputPath } : {}), }, }); @@ -95,6 +102,9 @@ export const webSearchTool = defineBrowserTool({ await closeIsolatedTab(client, tab); } }, + renderResult(result, expanded, theme) { + return renderExpandableText("web_search", result, expanded, theme); + }, }); const safeParse = (text: string): unknown => { -- cgit v1.2.3