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/readpage/read-page.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/domains/readpage') diff --git a/src/domains/readpage/read-page.ts b/src/domains/readpage/read-page.ts index 7bf2fdb..bc1a2b1 100644 --- a/src/domains/readpage/read-page.ts +++ b/src/domains/readpage/read-page.ts @@ -10,6 +10,7 @@ import { openIsolatedTab, waitForIsolatedLoad, } from "../isolated-tab"; +import { renderExpandableText } from "../render"; import { buildPageCaptureExpr } from "./capture"; import { extractReadable, type PageCapture, type ReadablePage } from "./readability"; @@ -42,12 +43,18 @@ const captureToResult = async (raw: unknown): Promise> = const page: ReadablePage = extractReadable(parsed); const header = `# ${page.title}\n${page.url}\n(${page.wordCount} words)\n\n`; const truncated = await applyTruncation(header + page.text, "readpage"); + const summary = `${page.title} ยท ${page.wordCount} words`; return ok({ text: truncated.text, details: { title: page.title, url: page.url, wordCount: page.wordCount, + render: { + summary, + body: page.text, + ...(truncated.fullOutputPath !== undefined ? { fullOutputPath: truncated.fullOutputPath } : {}), + }, ...(truncated.fullOutputPath !== undefined ? { fullOutputPath: truncated.fullOutputPath } : {}), }, }); @@ -106,4 +113,7 @@ export const readPageTool = defineBrowserTool({ if (args.targetId !== undefined && args.targetId.length > 0) return readOwnedTab(client, args.targetId); return err({ kind: "invalid_state", message: "provide either url or targetId" }); }, + renderResult(result, expanded, theme) { + return renderExpandableText("read_page", result, expanded, theme); + }, }); -- cgit v1.2.3