Skip to content

v0.2.0

Choose a tag to compare

@heyhuynhgiabuu heyhuynhgiabuu released this 25 Jun 16:26

v0.2.0

Demo

▶ 89s background-task walkthrough (MP4)

Spawning a background subagent in a tmux pane, watching live tool-call progress in the parent pane, reading the final result via the session JSONL.

Changed

  • Modular refactor of src/. The single-file index.ts is now a thin wiring layer; the implementation is split across focused modules:
    • src/tool/renderCall, renderResult, taskComplete, prompt, schema.
    • src/lifecycle/polling, completion, toolStats, widget, restore.
    • src/subagent/buildArgv, runSdk, tmux, waitCompletion.
    • src/conversation.tsfindJsonlSessionByName, registry and task-session-history helpers.
    • src/constants.tsBACKGROUND_CHECK_MS, COUNT_POLL_MS, TASK_TIMEOUT_MS, MAX_POLL_ERRORS.
    • src/types.tsBackgroundTask, RegistryEntry, TaskSessionHistoryEntry, TaskDetails.
  • Session JSONL is now the single source of truth for task results. RESULT.md is no longer read for completion detection or result text — the final assistant message in ~/.pi/agent/sessions/.../<id>.jsonl is the authoritative result. This removes mid-write EACCES and "stale truncated RESULT.md" failure modes entirely.
  • Completion detection is gated on stopReason. hasAgentFinished() in src/session-text.ts only treats an assistant message as final when its stopReason is stop, endTurn, length, error, or aborted. toolUse mid-turn streaming text is correctly ignored.
  • Background polling is hardened. checkInFlight guard prevents overlapping poll ticks. MAX_POLL_ERRORS = 3 per-task counter absorbs transient filesystem errors. Try/catch around checkTaskCompletion() keeps the interval alive on one-off failures.
  • Reordered completion check flow. Session JSONL is consulted before pane liveness, so remain-on-exit panes no longer block detection.

Added

  • renderCall / renderResult / task-complete renderers with Ctrl+O expand/collapse (via keyHint("app.tools.expand")) on the task tool. Foreground results show stats + preview; expanded shows the full result text. The keybinding hint falls back to Ctrl+O if the app.tools.expand keybinding is not registered.
  • Foreground real-time tool-call progress. The foreground execute path now polls the session file and emits _onUpdate callbacks while waiting, so the parent pane shows a live ${n} tool calls count alongside the spawned subagent pane.

Fixed

  • Duplicate "scout - Description" / "scout — Description" header in foreground results: renderResult no longer re-renders the header that renderCall already rendered.
  • The ( to expand) empty-keybinding hint: now falls back to a plain Ctrl+O to expand label when keyText("app.tools.expand") is empty.

Verified

  • npm run typecheck passes
  • npm run build passes
  • npm run smoke passes
  • npm pack --dry-run succeeds (115.5 kB tarball, 61 files)