From 6ebbcb3179119e6e2e1c35e41eb20ed283c0952c Mon Sep 17 00:00:00 2001 From: adamdottv <2363879+adamdottv@users.noreply.github.com> Date: Fri, 30 May 2025 12:29:27 -0500 Subject: wip: refactoring tui --- js/src/tool/view.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'js/src') diff --git a/js/src/tool/view.ts b/js/src/tool/view.ts index b36fa94f6..3ba36470d 100644 --- a/js/src/tool/view.ts +++ b/js/src/tool/view.ts @@ -97,13 +97,15 @@ export const view = Tool.define({ `This is an image file of type: ${isImage}\nUse a different tool to process images`, ); const lines = await file.text().then((text) => text.split("\n")); - const content = lines.slice(offset, offset + limit).map((line, index) => { - line = - line.length > MAX_LINE_LENGTH - ? line.substring(0, MAX_LINE_LENGTH) + "..." - : line; + const raw = lines.slice(offset, offset + limit).map((line) => { + return line.length > MAX_LINE_LENGTH + ? line.substring(0, MAX_LINE_LENGTH) + "..." + : line; + }); + const content = raw.map((line, index) => { return `${(index + offset + 1).toString().padStart(5, "0")}| ${line}`; }); + const preview = raw.slice(0, 20).join("\n"); let output = "\n"; output += content.join("\n"); @@ -121,6 +123,9 @@ export const view = Tool.define({ return { output, + metadata: { + preview, + }, }; }, }); -- cgit v1.2.3