Skip to content

refactor: share ANSI compatibility matching - #146998

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/ansi-compatibility-match-20260913
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/ansi-compatibility-match-20260913

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

ANSI stripping repeats compatibility matcher setup on both sides of its CSI decision.

User Impact

Output stays the same. Complete OSC handling, compatibility matching, control cancellation/restarts and incomplete streaming CSI are preserved.

Why This Change Was Made

Compute the existing conditional match once, at the same point after the canonical scanner. Production: −4 lines; tests unchanged.

Evidence

  • Normal CI34755488151, attempt1 and the required aggregate gate passed at bcb5025ad36448cb08db4b46df9506ccf3a3ffa4. Actual ANSI/safe-text execution passed 86 ANSI cases and eight safe-text cases. Shell-utils execution passed 34 cases with one platform-specific skip. Selected type, lint and formatting gates passed.
  • Actual public stripping functions and canonical OSC/CSI scanners matched 272,432 output and sticky-index comparisons over 68,108 inputs. This supplementary proof uses Node builtins; width helpers and the independent incremental state-machine class are outside its scope.
  • Existing ANSI assertions cover final bytes, longer compatibility matches, cancellation/restart, embedded controls, OSC, interleaved scans and pending stream boundaries. Terminal-buffer suite execution is not claimed.
  • Complete owner, scanner contracts, callers, sibling tests and relevant history were reviewed. Root and independent source reviews, P2, diff checks and commit formatting passed. The latest exact-head ClawSweeper review has no findings, Before merge items or Rank-up moves.

@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 11:50
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 13, 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 2:34 PM ET / 18:34 UTC (Revision 2).

ClawSweeper review

What this changes

The PR shares ANSI escape compatibility matching across two terminal-text stripping branches without changing their output.

Merge readiness

✅ Ready for maintainer review

No actionable findings. This is a focused, behavior-preserving cleanup that remains absent from current main; the member-authored, protected PR stays open.

Priority: P3
Reviewed head: bcb5025ad36448cb08db4b46df9506ccf3a3ffa4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, well-scoped refactor with preserved control flow, relevant existing coverage, and successful exact-head CI.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored internal refactor is exempt from external-contributor runtime proof; focused CI and reported equivalence checks supplement source review of the stripping owner.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored internal refactor is exempt from external-contributor runtime proof; focused CI and reported equivalence checks supplement source review of the stripping owner.
Evidence reviewed 8 items Introduced change preserves execution order: The pinned introduction diff moves identical matcher setup immediately after the CSI scan. Both original branches already performed that setup exactly once, with no intervening side effects; the complete-OSC early exit remains unchanged.
Scanner and shared-state contract: The complete scanner module confirms CSI scanning is synchronous and does not access the compatibility regex. OSC matching uses its own sticky regex, so sharing the compatibility setup introduces no cross-scanner state change.
Existing observable coverage: The unchanged tests assert longer compatibility matches, all CSI final bytes, cancellation/restart, OSC stripping, embedded controls, interleaved scans, and pending stream boundaries. Tests were inspected, not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

Terminal Core removes escape sequences from shell output and terminal buffers before other OpenClaw components display or sanitize the text. Its scanner preserves the existing distinctions between standard escapes, compatibility sequences, and incomplete streaming input.

flowchart TD
  A[Shell output or terminal buffer] --> B[Terminal Core stripping]
  B --> C[Complete OSC sequence]
  C -->|Present| D[Remove sequence]
  C -->|Absent| E[CSI scan and compatibility match]
  E --> F[Preserve controls and pending input as configured]
  D --> G[Text for display or sanitization]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -4. Total -4 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 4 8 -4
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 4 8 -4

Review metrics

None.

Technical review

Best possible solution:

Keep compatibility matching in the existing stripping owner with the same scanner ordering, grammar, and streaming behavior.

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

Not applicable: this PR reports duplicated implementation, not broken user behavior; the duplication is directly visible on current main.

Is this the best way to solve the issue?

Yes: hoisting the identical setup preserves both branches' execution order and avoids introducing another helper or parsing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 29517dc5f3ad.

Labels

Label justifications:

  • P3: This internal cleanup preserves existing terminal output and introduces no capability or configuration change.
  • 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 MEMBER-authored internal refactor is exempt from external-contributor runtime proof; focused CI and reported equivalence checks supplement source review of the stripping owner.

Evidence

What I checked:

  • Introduced change preserves execution order: The pinned introduction diff moves identical matcher setup immediately after the CSI scan. Both original branches already performed that setup exactly once, with no intervening side effects; the complete-OSC early exit remains unchanged. (packages/terminal-core/src/ansi.ts:76, bcb5025ad364)
  • Scanner and shared-state contract: The complete scanner module confirms CSI scanning is synchronous and does not access the compatibility regex. OSC matching uses its own sticky regex, so sharing the compatibility setup introduces no cross-scanner state change. (packages/terminal-core/src/ansi-sequences.ts:13, bcb5025ad364)
  • Existing observable coverage: The unchanged tests assert longer compatibility matches, all CSI final bytes, cancellation/restart, OSC stripping, embedded controls, interleaved scans, and pending stream boundaries. Tests were inspected, not executed during this read-only review. (packages/terminal-core/src/ansi.test.ts:186, bcb5025ad364)
  • Current main still contains the duplication: The fetched main revision retains separate compatibility matcher setup in the CSI and non-CSI branches; this cleanup remains distinct. (packages/terminal-core/src/ansi.ts:76, 29517dc5f3ad)
  • Latest-release comparison: The supplied latest release, v2026.9.4, also retains the duplicated matcher setup. (packages/terminal-core/src/ansi.ts:76, 3a9d69db306c)
  • Exact-head CI: GitHub confirms run 34755488151, attempt 1, succeeded at the reviewed head. The captured PR body additionally reports focused ANSI, safe-text, shell-utils, and supplementary equivalence checks; those reports are supporting validation, not a claimed live application run. (bcb5025ad364)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jincheng-xydt: 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-13T11:56:36.376Z sha bcb5025 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc merged commit 2dc608d into main Sep 13, 2026
188 of 189 checks passed
@vincentkoc
vincentkoc deleted the refactor/ansi-compatibility-match-20260913 branch September 13, 2026 18:44
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '28887b564210326174413d0d8ade72b38268d5f3': (1827 commits)
  fix(qa): bind coverage IDs to producer assertions (#144000)
  fix(linux): explain FreeBSD desktop setup prerequisites (#147211)
  fix(memory): split embedding batches rejected for an input array item cap (#139541)
  test: isolate timing metadata persistence from inherited settings (#147112)
  refactor(status): retire test-only helper publication (#147071)
  improve: reduce workspace agent lookup work for large fleets (#147144)
  refactor(macos): share connect credential selection (#144214)
  fix(plugins): restore Slack onboarding after core updates (#147109)
  refactor: share ANSI compatibility matching (#146998)
  fix(test): settle Models catalog before picker open (#147215)
  test(ui): reuse panel tab drag fixture (#147250)
  fix(install): use system Node for FreeBSD CLI setup (#147204)
  fix(cli): explain MCP probes with no enabled servers (#147216)
  docs: require UI screenshots in chat and PR (#147263)
  docs(skills): clarify remote gog OAuth setup for Gateway hosts (#145945)
  test: replace idle account catalog waits with synchronization (#147228)
  feat(qa): preserve maturity decision context (#147219)
  feat(macos): clarify agent activity in native chat (#147197)
  fix(runtime): complete Bun compatibility follow-ups (#147085)
  fix(ui): release closed chat panes after queued updates (#147240)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 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: XS 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