truncate width

This commit is contained in:
2026-06-03 08:58:59 -04:00
parent 462c6681f2
commit d476821d74
2 changed files with 12 additions and 8 deletions

View File

@@ -21,7 +21,12 @@ import type {
ExtensionContext, ExtensionContext,
} from "@earendil-works/pi-coding-agent"; } from "@earendil-works/pi-coding-agent";
import { Type } from "typebox"; import { Type } from "typebox";
import { Box, Text } from "@earendil-works/pi-tui"; import {
Box,
Text,
truncateToWidth,
visibleWidth,
} from "@earendil-works/pi-tui";
import { runDeepResearch, type ResearchProgress } from "./src/research"; import { runDeepResearch, type ResearchProgress } from "./src/research";
import { isFirecrawlReachable } from "./src/firecrawl"; import { isFirecrawlReachable } from "./src/firecrawl";
import type { ResearchConfig, ResearchReport, Audience } from "./src/types"; import type { ResearchConfig, ResearchReport, Audience } from "./src/types";
@@ -157,21 +162,20 @@ function createProgressWidget(
(tui: { requestRender(): void }, _theme: any) => { (tui: { requestRender(): void }, _theme: any) => {
widgetTui = tui; widgetTui = tui;
return { return {
render: () => { render: (width: number) => {
const spinner = SPINNER_FRAMES[spinnerIdx]; const spinner = SPINNER_FRAMES[spinnerIdx];
const icon = PHASE_ICONS[state.phase] ?? ""; const icon = PHASE_ICONS[state.phase] ?? "";
const roundInfo = const roundInfo =
state.round && state.totalRounds state.round && state.totalRounds
? ` Round ${state.round}/${state.totalRounds}` ? ` Round ${state.round}/${state.totalRounds}`
: ""; : "";
const lines: string[] = [ const firstLine = `${spinner} ${icon} ${state.message}${roundInfo}`;
`${spinner} ${icon} ${truncate(state.message, 80)}${roundInfo}`, const lines: string[] = [truncateToWidth(firstLine, width)];
];
if (state.detail) { if (state.detail) {
lines.push(` ${truncate(state.detail, 76)}`); lines.push(truncateToWidth(` ${state.detail}`, width));
} }
if (state.fraction > 0) { if (state.fraction > 0) {
const barLen = 15; const barLen = Math.min(15, Math.max(3, width - 4));
const filled = Math.round(barLen * state.fraction); const filled = Math.round(barLen * state.fraction);
const bar = "█".repeat(filled) + "░".repeat(barLen - filled); const bar = "█".repeat(filled) + "░".repeat(barLen - filled);
lines.push(` ${bar}`); lines.push(` ${bar}`);

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mikefreno/deepi-research", "name": "@mikefreno/deepi-research",
"version": "0.1.0", "version": "0.1.1",
"description": "Deep research extension for pi — parallel web research via Firecrawl with iterative query refinement", "description": "Deep research extension for pi — parallel web research via Firecrawl with iterative query refinement",
"keywords": [ "keywords": [
"pi-package", "pi-package",