Skip to content

feat(coding-agent): add turn boundary renderer hook - #44

Merged
quick-ricon merged 6 commits into
mainfrom
quick/turn-boundary-renderer-20260807
Aug 7, 2026
Merged

feat(coding-agent): add turn boundary renderer hook#44
quick-ricon merged 6 commits into
mainfrom
quick/turn-boundary-renderer-20260807

Conversation

@quick-ricon

Copy link
Copy Markdown

Summary

Add a dedicated, chainable registerTurnBoundaryRenderer extension hook for rendering the boundary before non-initial user turns.

The default remains Pi's existing blank Spacer(1). Extensions can wrap or replace that fallback without taking over user-message rendering.

Behavior

  • Pass a cloned user message, optional InputSource, and isReplay through TurnBoundaryContext.
  • Compose transforms in extension/load order, with later transforms outermost and safe fallback when an extension throws or returns an invalid component.
  • Correlate source only where Pi has exact live prompt provenance; direct public steer/follow-up calls remain unspecified rather than guessed.
  • Mark reconstructed session turns as replayed while live turns use isReplay: false.
  • Preserve the first-message behavior and place the boundary outside skill-block rendering so special skill turns retain their internal spacing.
  • Document the API and include a focused ── turn ── example.

Validation

  • Focused coding-agent tests: 58 passed across turn-boundary composition, interactive placement, extension registration, and prompt-source lifecycle coverage.
  • git diff --check: passed.
  • npm run check: formatting passed; the check then reached two unrelated AI test/type failures caused by live model-catalog drift (claude-opus-4-1 membership and current maxTokensField compatibility typing). Generated model files were restored byte-for-byte with no AI diff.
  • ./test.sh with direct NVM Node/npm: agent package reached 235 passed / 1 skipped with two baseline workspace-resolution failures; AI reached 753 passed / 785 skipped with the same two live-catalog expectation failures. Coding-agent continued without an observed patch failure until the bounded 900-second run timed out. No orphan processes or temporary suite artifacts remain.

No changelog entry is included, per this repository's contributing guidance.

@baby-joel baby-joel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review of exact head 471f50211e5194afba12cb427d317ae0ab989bf4 found two change requests.

  1. packages/coding-agent/src/modes/interactive/components/turn-boundary-renderer.ts:35: when a transform mutates context and then throws or returns an invalid component, the fallback receives that same mutated object. This breaks per-layer fallback isolation: a failed extension can still change what the previous renderer displays. Fix and regression test: #45.

  2. packages/coding-agent/src/modes/interactive/interactive-mode.ts:3350: chatContainer.children.length treats any prior transcript component as a prior user turn. A startup notice, custom message, or bash item therefore invokes the extension hook for the first rendered user message, contrary to the public contract. The existing default spacer should remain, but the hook should start only after a rendered user/skill turn. Fix and regression test: #46.

I also traced later-transform wrapping order, direct and queued prompt source correlation and cleanup, default no-extension spacing, replay rebuilds, skill rendering, and public type exports. Queued source identity is preserved because agent-core enqueues and emits the same message object; source entries are consumed on delivery and direct entries are removed in finally.

Focused validation after hydrating the repository's ignored model data: turn-boundary renderer and interactive-mode tests (6 passed), agent-session prompt tests (13 passed), plus focused Biome and git diff --check for each fix. Root typecheck and hosted CI remain red on the same two unrelated packages/ai/test errors (abort.test.ts:157 and openai-completions-tool-choice.test.ts:1416).

@baby-joel

Copy link
Copy Markdown

Additional change request from release-surface closeout: packages/coding-agent/src/core/extensions/types.ts:1413 adds a public extension API, but this PR does not add it to packages/coding-agent/CHANGELOG.md under Unreleased. Fix: #47.

…y-fallback-isolation

fix(coding-agent): isolate turn boundary fallbacks
…oundary

fix(coding-agent): skip boundary hook for first user turn
@quick-ricon
quick-ricon merged commit abb16ef into main Aug 7, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants