Skip to content

refactor(terminal): replay wrapped prefixes in one pass - #139240

Merged
steipete merged 1 commit into
mainfrom
codex/perf-sep05-terminal-replay-array-join
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-sep05-terminal-replay-array-join

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR.

What Problem This Solves

Wrapped terminal cells traversed the same emitted prefix separately to collect text, reconstruct SGR styles, and reconstruct OSC-8 links. Two single-use helpers duplicated the replay structure.

Why This Change Was Made

Collect token values and update both continuation states in one local pass, then join the values once. The emitted prefix remains the sole owner of continuation state; buffered suffixes, style category order, and close/reopen ordering retain their existing behavior.

User Impact

The same table output with fewer token traversals and 14 fewer production lines. Wrapping, colors, links, Unicode widths, tabs/newlines and large-buffer handling retain their existing contracts.

Evidence

  • The unchanged three-file suite passed 164 cases before and 164 after: 81 table, 77 ANSI and 6 skills-formatting cases. Complete case inventories match; no assertions changed.
  • The full normal changed-code gate passed. Seven managed review passes found no actionable P0–P2 issue; an independent reviewer checked the full owner/caller/parser boundary and recomputed the numerical results.
  • Fixed B0/C0/C1/B1 source-render study: 3,192 total calls, including a 24-call output proof; 384 batch means. Complete strings, UTF-8 bytes/hashes and line widths match across all six workloads. The timed operation includes rendering plus UTF-8/hash consumption.
Workload Forward median change Reverse median change
Plugin-like table, width 120 −3.40% −2.65%
Unicode skills-like table −1.67% −2.46%
Dense ANSI control tail −1.20% −0.98%
Fitting ASCII +5.68% −3.01%
Plugin-like table, width 80 −1.16% +0.24%
Unchanged no-border control +2.19% +12.17%

All 2,196 metric comparisons, including 897 adverse-direction values, remain recorded. Dense-control batch tails worsened in both orders, and first-call/memory results were mixed. These modest component gains support the local simplification; they do not establish a general CLI/Gateway latency or memory improvement. Actual terminal-emulator behavior was not part of this source-render comparison.

Current-main composition at 426ca0d50f303c7cbec46741be7ff51e99145a18 is clean and the relevant table/parser/test owners are unchanged from the measured base. Production +22/−36, tests unchanged. No dependency, public API, configuration or intended visual-output change.

@steipete steipete self-assigned this Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@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 Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 2:02 PM ET / 18:02 UTC.

ClawSweeper review

What this changes

The PR combines text collection and style/link reconstruction into one pass when wrapping terminal table cells, preserving the existing output.

Merge readiness

✅ Ready for maintainer review

This remains a useful simplification absent from fetched main. No actionable correctness or security findings; the protected maintainer PR should remain open.

Priority: P3
Reviewed head: 161b967434fd073d73bcd247c95dfcf162adb604

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with preserved ordering, relevant existing coverage, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor gate does not apply to this maintainer-authored, behavior-neutral refactor; supplied before/after renderTable measurements report matching output across six workloads, while explicitly excluding terminal-emulator coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor gate does not apply to this maintainer-authored, behavior-neutral refactor; supplied before/after renderTable measurements report matching output across six workloads, while explicitly excluding terminal-emulator coverage.
Evidence reviewed 10 items Introduced change: The independently inspected merge-base-to-head diff contains only the local prefix replay consolidation. Parsing rules, buffer splitting, style-category order, and both continuation branches retain their existing behavior.
Current-main necessity: Fetched main has no differences from the PR merge base in the table renderer, ANSI helpers, scanner, or table tests; it still contains the separate replay passes.
Verified merge composition: Raw test-merge parents match the pinned base followed by the exact PR head. Comparing that merge result with its base reproduces only the intended renderer refactor.
Findings None None.
Security None None.

How this fits together

The shared terminal table renderer turns CLI report rows into aligned text. It preserves colors and hyperlinks across wrapped cells before adding padding and borders.

flowchart LR
  A[CLI report rows] --> B[Table layout]
  B --> C[Text and control tokens]
  C --> D[Select emitted prefix]
  D --> E[Collect text and continuation state]
  E --> F[Close styles and links]
  F --> G[Pad and print table]
  E --> H[Reopen state for remaining text]
  H --> D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -14. Total -14 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 22 36 -14
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 22 36 -14

Review metrics

Metric Value Why it matters
Production versus tests Production net −14 lines; tests unchanged The refactor removes single-use replay helpers without adding another abstraction or validation burden.

Technical review

Best possible solution:

Keep prefix replay inside the table renderer, using one local traversal and the existing parsers and continuation rules.

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

Not applicable: this proposes a behavior-preserving refactor, not a reported failure; source confirms the repeated prefix traversals.

Is this the best way to solve the issue?

Yes. Consolidating the independent text/style/link passes at their existing owner is simpler than retaining single-use helpers or adding a shared abstraction; parsing and caller contracts remain intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7af054ec87ad.

Labels

Label justifications:

  • P3: This is a bounded internal simplification with no intended change to terminal output.
  • 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: The external-contributor gate does not apply to this maintainer-authored, behavior-neutral refactor; supplied before/after renderTable measurements report matching output across six workloads, while explicitly excluding terminal-emulator coverage.

Evidence

What I checked:

  • Introduced change: The independently inspected merge-base-to-head diff contains only the local prefix replay consolidation. Parsing rules, buffer splitting, style-category order, and both continuation branches retain their existing behavior. (packages/terminal-core/src/table.ts:273, 161b967434fd)
  • Current-main necessity: Fetched main has no differences from the PR merge base in the table renderer, ANSI helpers, scanner, or table tests; it still contains the separate replay passes. (packages/terminal-core/src/table.ts:205, 7af054ec87ad)
  • Verified merge composition: Raw test-merge parents match the pinned base followed by the exact PR head. Comparing that merge result with its base reproduces only the intended renderer refactor. (packages/terminal-core/src/table.ts:279, 9af0b126f4d1)
  • Caller, owner, and implementation boundary: Read the complete renderer, ANSI scanner/helpers, display formatter, safe-text wrapper, skills formatter, plugin-list command, and sibling note wrapper. CLI callers share renderTable; replay remains local to table wrapping. Imports and implementation establish no Codex runtime or protocol dependency; a Codex-named display fixture does not change that boundary. (packages/terminal-core/src/table.ts:1, 161b967434fd)
  • Existing behavioral coverage: Read the unchanged table, ANSI, and skills-formatting suites. They cover selective SGR resets, OSC-8 close/reopen behavior, soft-wrap suffixes, CRLF, tabs, Unicode widths, and large-buffer argument limits. Tests were inspected, not executed in this read-only review. (packages/terminal-core/src/table.test.ts:590, 161b967434fd)
  • Documented operator contract: The skills CLI documentation explicitly states that table tabs become single spaces to preserve neighboring-column alignment; the refactor leaves token normalization and width measurement unchanged. Public docs: docs/cli/skills.md. (docs/cli/skills.md:101, 161b967434fd)

Likely related people:

  • Peter Steinberger: 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-09-05T17:56:10.020Z sha 161b967 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit bf84a36 into main Sep 5, 2026
135 checks passed
@steipete
steipete deleted the codex/perf-sep05-terminal-replay-array-join branch September 5, 2026 18:08
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* commit '911d7d5b0c107f7274f2415ca9655dcc6105f0e8': (867 commits)
  fix(skills): deliver pending Workshop approval controls (#139248)
  fix(gateway): deliver loopback ask_user prompts to the originating channel (#138831)
  docs: keep root agent instructions focused on repository policy (#139258)
  fix(matrix): exclude archived state roots from scans and selection (#112329)
  perf(agents): prepare exact tool names once per catalog batch (#139267)
  fix: preserve Swarm progress and simplify owner plumbing (#139269)
  fix(tailscale): release claims after gateway process-group exit (#139261)
  refactor(cli): simplify lazy command registration (#139108)
  test(ui): retain synthetic widget failure evidence (#139229)
  fix(buzz): keep implicit replies at thread root (#138879)
  test(diagnostics): await graceful Gateway shutdown before cleanup (#139247)
  fix(ci): unblock releases with different tooling package managers (#139259)
  feat(ui): add social preview links for private sessions (#139250)
  fix(codex): retain failed conversations for guarded continuation (#139246)
  chore(ui): refresh control ui locales (#139200)
  fix(ci): run browser checks for real-gateway inputs (#139256)
  fix(llama-cpp): reconcile managed router state before requests (#136363)
  chore(i18n): refresh native locales (#139237)
  refactor(worker): unify inference payload handling (#139245)
  refactor(terminal): replay wrapped prefixes in one pass (#139240)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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