Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Pressing **Ctrl+O** expands the row to inspect the full syntax-highlighted scrip
- **Space-Saving**: Replaces 10–20 rows of `codemode` output with a clean 1-line summary, from the first streamed argument to the final result. Before its first nested call, a running script shows the tools it references; a script without nested tool calls is named by its first code line.
- **Width-Aware**: Fits the actual rendering area, including shell padding, terminal resizing, and HTML exports. Narrow rows drop the `codemode` title and keep the status.
- **Key Metrics at a Glance**: Tools used, output line and image counts, execution time, and LLM cost (`$cost`).
- **Live Timing**: Updates elapsed time in the running summary every second, in whole seconds. Final results prefer Pi’s recorded duration, falling back to the script header for older sessions and Pi versions.
- **Live Timing**: Updates elapsed time in the running summary every second, in whole seconds. Final results prefer Pi’s recorded duration, falling back to the script header for HTML exports and sessions recorded before Pi 1.1.
- **Fully Expandable**: Press **Ctrl+O** anytime to inspect the full script source and raw output.

---

## Requirements

- **Pi Coding Agent**: `>= 1.0.1` (`1.2.0` or later recommended).
- **Pi Coding Agent**: `>= 1.2.0`.

---

Expand All @@ -64,8 +64,6 @@ Live timers stop on completion, errors, aborted runs, session changes, and reloa

## Known Limitations

- **Early Progress on Older Pi**: Live timing refreshes after the first partial result. Pi 1.2.0 emits one before the first nested call; older supported versions may wait until a nested tool call begins, and the call row stays in place until then.

- **Static Analysis Approximation**: The call line preview uses a lightweight scanner that skips strings, comments, and regex literals but keeps `${...}` interpolations. Dynamic property accesses (`tools[fn]`) and aliases (`const { read } = tools`) are omitted, and rare regex-versus-division ambiguities may hide or add a name. The result line always displays the authoritative runtime execution history once finished.

- **HTML Exports Keep Two Rows**: The exporter draws the call row before the result exists, so exported sessions still show the call summary above the titled result.
Expand Down
6 changes: 2 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* Expanding (Ctrl+O) reveals syntax-highlighted code, per-call timings, models cost, errors, and full output.
*
* Wiring: We register a renderer resolver (pi.registerToolRenderer, pi >= 1.0.1) that attaches the compact
* Wiring: We register a renderer resolver (pi.registerToolRenderer) that attaches the compact
* renderers to the `codemode` tool by name. The built-in extension's definition (execution, store
* persistence, models API, namespaces) stays untouched, so nothing is re-registered: no replacement
* warning, no mid-session tool redefinition, and the renderers apply no matter which extension or SDK
Expand Down Expand Up @@ -581,7 +581,7 @@ export function renderResult(
): Text {
const calls = result.details?.calls ?? [];
const { body, wallTime: headerSeconds } = splitScriptOutput(result.content ?? []);
// Compatibility for old sessions and HTML exports; remove `?? headerSeconds` to drop the fallback.
// HTML exports and sessions recorded before Pi 1.1 carry no durationMs; the script header still has the time.
const durationSeconds = recordedDurationSeconds(context.durationMs) ?? headerSeconds;
const images = result.content?.filter((item) => item.type === "image").length ?? 0;
const clock = executionClock(context);
Expand Down Expand Up @@ -643,8 +643,6 @@ export default function codemodeCompact(pi: ExtensionAPI): void {
if (!options.isPartial || context.isError) {
clocks.delete(clock);
} else if (clock.endedAt === undefined && !clock.interval) {
// ponytail: Pi < 1.2 can delay the first partial result until a nested call;
// upgrading Pi enables immediate ticks without replacing tool execution.
clock.interval = setInterval(() => context.invalidate(), 1000);
clock.interval.unref();
clocks.add(clock);
Expand Down
Loading