repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

feat(ultra): show phases and runs in collapsed tool view

a9ba080beab49a07a5bf7a3c42bde95aeb85a7b8

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (2)

extensions/ultra/__tests__/ui.test.ts

Modified
255 255 expect(collapsed).toContain("1 active");
256 256 expect(collapsed).toContain("1 queued");
257 257 expect(collapsed).toContain("2 later");
258 - expect(collapsed).not.toContain("active#0");
258 + expect(collapsed).toContain("▶ active");
259 + expect(collapsed).toContain("active#0 · Review active path");
260 + expect(collapsed).toContain("active#1 · Check failed path");
261 + expect(collapsed).not.toContain("transport: rate limited");
261 264 it("truncation keeps ellipsis in the surrounding style span", () => {
317 - it("collapsed: shows phase/agent counts + summary + expand hint, never bodies", () => {
320 + it("collapsed: shows phase and run summaries without actions or transcripts", () => {
318 321 const out = toolText(scripted, { expanded: false, isPartial: true });
319 322 // aggregate counts + phase counter present
320 323 expect(out).toContain("phase 1/1");
322 325 expect(out).toContain("1✗");
323 326 // the collapsed expand affordance
324 327 expect(out).toContain("to expand");
325 - // NEVER emits per-agent action lines or transcript bodies when collapsed
328 + expect(out).toContain("▶ review");
329 + expect(out).toContain("󰐌 a");
330 + expect(out).toContain("󰅙 b");
326 331 expect(out).not.toContain("/SECRET-ACTION");
327 332 expect(out).not.toContain("SECRET-TRANSCRIPT-BODY");
328 - // not even the per-agent ids
329 - expect(out).not.toContain("agentId");
333 + expect(out).not.toContain("rate limited");
334 + });
336 + it("collapsed: bounds visible phases and runs while keeping the active phase", () => {
337 + const phases = ["prepare", "scan", "review", "verify", "publish"].map(
338 + (phase) => ({ phase, status: "resolved" as const, agentIds: [] }),
339 + );
340 + let state = reduceProgress(initialReducerState(), {
341 + kind: "plan",
342 + startedAt: Date.now(),
343 + phases,
344 + });
345 + state = reduceProgress(state, {
346 + kind: "phase",
347 + phase: "verify",
348 + status: "resolved",
349 + agentIds: ["verify#0", "verify#1", "verify#2", "verify#3", "verify#4"],
350 + });
351 + for (let index = 0; index < 5; index++) {
352 + state = reduceProgress(
353 + state,
354 + pe({
355 + agentId: `verify#${index}`,
356 + phase: "verify",
357 + kind: "prompt",
358 + summary: `Run ${index}`,
359 + prompt: "SECRET EXACT PROMPT",
360 + }),
361 + );
362 + state = reduceProgress(
363 + state,
364 + pe({ agentId: `verify#${index}`, phase: "verify", kind: "start" }),
365 + );
367 + for (const width of [24, 54, 120]) {
368 + const lines = renderTool(
369 + state,
370 + { expanded: false, isPartial: true },
371 + width,
372 + );
373 + const out = lines.join("\n");
374 + expect(out).toContain("▶ verify");
375 + expect(out).toContain("earlier phases");
376 + expect(out).toContain("more runs");
377 + expect(out).toContain("verify#0");
378 + expect(out).not.toContain("SECRET EXACT PROMPT");
379 + expect(
380 + lines.every((line) => stripVTControlCharacters(line).length <= width),
381 + ).toBe(true);
332 385 it("expanded: shows authored summaries but never exact prompts", () => {

extensions/ultra/ui.ts

Modified
357 357 * Pure board renderer for the tool surface. Collapsed = aggregate counts +
358 - * one-line summary + the expand hint (NEVER any per-agent line or transcript
359 - * body). Expanded = phase-first summaries with active and failed phases opened,
358 + * bounded phase and run summaries + the expand hint (never action or transcript
359 + * bodies). Expanded = phase-first summaries with active and failed phases opened,
360 360 * plus model/usage metadata and the final outcome. The drill-in transcript is
361 361 * the OVERLAY's job, never the tool sink's, so `state.transcripts` is never read here.
377 377 lines.push(theme.fg("muted", fitLine(metrics, w)));
379 379 if (!options.expanded) {
380 + const focus = Math.max(
381 + 0,
382 + state.phases.findIndex((phase) => phase.phase === state.phase),
383 + );
384 + const first = Math.max(0, Math.min(focus - 1, state.phases.length - 3));
385 + if (first > 0)
386 + lines.push(theme.fg("dim", fitLine(` ${first} earlier phases`, w)));
387 + for (const phase of state.phases.slice(first, first + 3))
388 + lines.push(
389 + theme.fg("muted", fitLine(` ${phaseLabel(state, phase, false)}`, w)),
390 + );
391 + const remaining = state.phases.length - first - 3;
392 + if (remaining > 0)
393 + lines.push(theme.fg("dim", fitLine(` ${remaining} later phases`, w)));
395 + const current =
396 + state.phase ??
397 + state.phases.find((phase) => phase.status === "resolved")?.phase;
398 + const runs = current ? rowsInPhase(state, current) : [];
399 + const ranked = (["running", "dropped", "queued", "done"] as const).flatMap(
400 + (status) => runs.filter((row) => row.status === status),
401 + );
402 + for (const row of ranked.slice(0, 3)) {
403 + const summary = row.summary?.trim();
404 + const label = summary ? `${row.agentId} · ${summary}` : row.agentId;
405 + lines.push(
406 + theme.fg(
407 + row.status === "dropped" ? "error" : "muted",
408 + fitLine(` ${STATUS_ICON[row.status]} ${label}`, w),
409 + ),
410 + );
412 + if (ranked.length > 3)
413 + lines.push(
414 + theme.fg("dim", fitLine(` ${ranked.length - 3} more runs`, w)),
415 + );
380 416 if (state.workflowResult?.fullOutputPath)
381 417 lines.push(
382 418 theme.fg(
384 420 fitLine(`Evidence: ${state.workflowResult.fullOutputPath}`, w),
387 - // Collapsed: summary + expand hint only. No bodies, ever.
388 423 lines.push(theme.fg("muted", fitLine(expandHint(), w)));
389 424 return lines.map((l) => fitLine(l, w));