Skip to content

refactor(agents): consolidate session text component reuse - #134105

Merged
vincentkoc merged 3 commits into
mainfrom
refactor/agents-session-text-component-reuse
Aug 31, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
refactor/agents-session-text-component-reuse

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Ten session tool text renderers independently repeated the same component construction, identity reuse, and text-cache invalidation sequence.

Why This Change Was Made

This consolidates that sequence in reuseTextComponent, preserving the existing unchecked render-slot cast while making the shared Text lifecycle explicit. The helper creates a zero-padding Text when absent, calls setText for every render, and returns the same component instance.

Installed @earendil-works/pi-tui source and types confirm the contract: Text implements Component, and setText clears the cached text, width, and rendered lines before the next render.

Renderer activation is explicitly out of scope. wrapToolDefinition currently drops these renderer hooks, so this PR does not claim a user-visible or live TUI behavior change.

User Impact

No user-visible change. Bash, read, write-error, find, grep, and ls session text renderers retain their existing output and component identity semantics with one canonical implementation.

Evidence

  • Owner tests: node scripts/run-vitest.mjs src/agents/sessions/tools/render-utils.test.ts - 14 passed, 1 platform skip.
  • New owner coverage proves zero-padding construction and same-instance replacement rendering after a prior cached render.
  • pnpm check:changed - passed on the rebased diff.
  • pnpm test:changed - first three partitions passed; the unit partition completed 10,807 passed and 17 skipped with one sparse-checkout fixture failure. Hydrating the tracked custodian-skills/ directory made that exact unrelated spec pass.
  • git diff --check - passed.
  • Pinned gpt-5.6-sol high autoreview - scoped-clean, no actionable findings, overall correctness 0.99.
  • Production LOC: +42/-49, net -7. Tests: +21. Tooling baseline: +3/-6.
  • Assertion-safety baseline shrinks with the removed duplicate caller casts.
  • Provenance commit: bb46b79d3c1479f194a90afcf3dd69a1858a7898.
  • Overlap refresh: fix(agents): preserve literal @-prefixed session paths #133815 is merged; its render blocks remain compatible with this consolidation. The latest main advance was Matrix/QA work and did not touch this owner surface.
  • Codex CLI contract check: codex-rs/cli/src/main.rs:220-245 and codex-rs/cli/src/main.rs:2840-2870 are unrelated completion/config-normalization paths.
  • No API, config, storage, security, protocol, changelog, Crabbox, PTY, or live-TUI change.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc vincentkoc self-assigned this Aug 31, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 31, 2026 12:43
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 10:57 AM ET / 14:57 UTC.

ClawSweeper review

What this changes

The PR centralizes session-tool terminal text-component reuse in a shared helper and applies it to Bash, read, write, find, grep, and ls renderers.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer review. The refactor is still necessary because current main retains the duplicated renderer sequence; the introduced helper preserves that sequence at each affected slot, with no concrete correctness or security finding.

Priority: P3
Reviewed head: 45333af79ccb15f69a1b44e02e987f3924bfe7ff

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative cleanup with source-equivalent callers and targeted component-lifecycle coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This repository-member internal refactor has no claimed user-visible change; the changed owner is covered by source-level identity and refreshed-render tests, while public wrapper paths omit these renderer hooks.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This repository-member internal refactor has no claimed user-visible change; the changed owner is covered by source-level identity and refreshed-render tests, while public wrapper paths omit these renderer hooks.
Evidence reviewed 6 items Introduced owner-boundary helper: The helper retains the prior Text cast, zero-padding construction, setText call, and returned instance in one canonical implementation.
Renderer-slot invariant: The context documents lastComponent as the previous component for the same render slot, and renderer hooks return Component; all affected callers pass that value to the helper.
Focused regression coverage: The added tests cover creation with no prior component and same-instance refreshed rendering after an earlier render.
Findings None None.
Security None None.

How this fits together

Session tools define call and result renderers for the interactive terminal UI. Each render slot receives its prior component, refreshes it with current text, and returns it for display.

flowchart LR
  A[Session tool call or result] --> B[Tool-specific renderer]
  B --> C[Shared text-component helper]
  C --> D[Pi TUI text component]
  D --> E[Interactive terminal UI]
Loading

Before merge

  • Complete next step (P2) - This maintainer-authored PR has no concrete repair finding; it needs normal exact-head CI and maintainer handling, not an automated repair lane.
Agent review details

Security

None.

PR surface

Source -7, Tests +21, Other -3. Total +11 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 7 42 49 -7
Tests 1 21 0 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 6 -3
Total 9 66 55 +11

Review metrics

Metric Value Why it matters
Production versus test delta production -7 net; tests +21; tooling baseline -3 net The cleanup removes repeated production code while adding focused coverage for component identity and refreshed rendering.

Technical review

Best possible solution:

Retain one shared helper for the identical Text lifecycle and land after normal exact-head CI and maintainer review.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR refactors existing terminal-renderer construction rather than addressing a reported user-visible failure.

Is this the best way to solve the issue?

Yes. A helper beside the existing rendering utilities removes repeated identical lifecycle code while preserving every affected renderer's slot-local behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 328f3ef8c20a.

Labels

Label justifications:

  • P3: This is a small internal maintainability refactor with no changed user-facing behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This repository-member internal refactor has no claimed user-visible change; the changed owner is covered by source-level identity and refreshed-render tests, while public wrapper paths omit these renderer hooks.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • qingminlong: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-31T12:50:23.601Z sha 61f6854 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 31, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper rank-up move processed:

  • Complete next step (P2): skipped because the review identifies no concrete repair, correctness defect, or security finding. The requested maintainer qualification continues through exact-head CI and native Testbox preparation.

@vincentkoc
vincentkoc merged commit 6704da3 into main Aug 31, 2026
233 of 237 checks passed
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@vincentkoc
vincentkoc deleted the refactor/agents-session-text-component-reuse branch August 31, 2026 16:30
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…134105)

* refactor(agents): consolidate session text component reuse

* chore: refresh CI after Windows worker repair

* chore: refresh CI after gateway test repair
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant