Skip to content

improve: ship less JavaScript for sidebar previews in Chat and New Session - #201252

Merged
roboclaw-bot merged 6 commits into
mainfrom
openclaw/briny-shrimp
Nov 18, 2026
Merged

roboclaw-bot merged 6 commits into
mainfrom
openclaw/briny-shrimp

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #200929

CI note (14:47 UTC): the only red check on head 27cdbb76 is android-access-native (16384, google_apis_ps16k), which failed in :app:connectedPlayDebugAndroidTest because Gradle could not download com.android.tools.utp test-runner artifacts from dl.google.com ("Resource missing"). That is a CI infrastructure failure, not something this TypeScript-only Markdown flattener change can affect; every UI, unit, lint and performance check passed. I'm not bypassing it: the branch will pick up main once the New Session red-main fix (#201268) lands, and that fresh head gets a clean Android run before merge. cc @vyctorbrzezowski

What Problem This Solves

Chat and New Session both download the code that turns Markdown into plain text for live sidebar previews. Its link scanner kept three separate maps to decide which markup to remove, and both routes are already over their startup JavaScript budgets.

User Impact

No visible change. Sidebar preview text, and when it appears, stay the same. Chat and New Session each download 321 fewer gzip bytes of JavaScript, with no added requests.

Why This Change Was Made

The shared plain-text flattener now records the link markup to skip in one map and applies the edits in source order. It keeps the preview's existing treatment of nested labels, escaped image markers, empty links and unfinished Markdown, without adding a dependency or deferring work. Swapping in micromark was ruled out: it treats empty links, nested links and unfinished fences differently from what the preview intentionally shows.

Evidence

The paired performance comparison against fb34e996e8e469035e3238734bba3afb1236eb19 passed: Chat and New Session boot JS each −321 B gzip, startup unchanged, request counts unchanged at 21, 17 and 3. A differential run matched the previous output across 49 owner-fixture calls, 1,310 transcript fixtures and streamed prefixes, and 100,000 generated inputs in flatten, label and omit modes. New committed cases cover composed linked images, escaped bangs, empty labels and nested image omission. 412 focused tests (shared scanner, sidebar roster and narration, Cron, server consumers), lint, formatting and the UI typecheck passed.

Requested by @vyctorbrzezowski.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 2 commits November 18, 2026 13:55
…ssion

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 1e6838bb-fd8a-8c7a-9b77-9e35d1906974
@clawsweeper

clawsweeper Bot commented Nov 18, 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.

roboclaw-bot and others added 3 commits November 18, 2026 14:12
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 911e09ff-1d13-8433-8da4-36d3f75bf576
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR simplifies Markdown link scanning to reduce JavaScript downloaded by Chat and New Session while preserving text output.

Example: Open Chat or New Session.

  • Before: The existing shared scanner contributes to each route’s JavaScript download.
  • After: The reported paired comparison saves 321 gzip bytes per route, with unchanged previews and request counts.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, compact refactor supported by preservation tests and a passing performance gate; the strongest behavioral evidence remains unit-level.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor intentionally preserves runtime output; its applicable evidence is the reported differential comparison, focused consumer validation, and passing exact-head bundle-size check.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Chat and New Session download avoidable scanner code on routes already above their startup JavaScript budgets.
Reason: The maintainer-authored direction is established, and a modest measured saving comes with less production code, unchanged APIs, and no dependency or configuration changes.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused, measured reduction to shared preview code, with no actionable correctness or security defect found.

Priority: P3
Reviewed head: 27cdbb767beb4b01dbec8e8060db10f349c3cc67

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared normalization package converts Markdown into plain-text previews for UI and Gateway consumers, and removes link destinations and images for web_fetch text extraction.

flowchart TD
  A[Markdown text] --> B[Shared link scanner]
  B --> C[Plain text flattener]
  C --> D[Sidebar and session previews]
  C --> E[Cron and other excerpts]
  B --> F[Web fetch text extraction]
Loading

Technical review

Best possible solution:

Land the compact scanner through the existing shared owner once the exact-head CI gate is resolved.

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

This is a behavior-preserving optimization rather than a bug report; source inspection confirms the redundant representations, and no target code was executed during review.

Is this the best way to solve the issue?

The change follows the smallest complete approach: retain the parser and its contracts, record removal ranges once, and delete the redundant helper and maps without adding another owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Balanced labels, destinations, and iterative link scanning keeps the original intent (e73028f: Prevent nested brackets and balanced or escaped destination parentheses from leaking markup or consuming trailing preview text.)
  • Image omission for fetched text keeps the original intent (9c39447: Share balanced-link parsing with web extraction while preserving image labels in previews and omitting images from fetched text.)
  • Escaped image markers keeps the original intent (4b4c689: Retain ordinary link labels preceded by an escaped exclamation mark while preserving actual-image handling.)
  • Code-span exclusion keeps the original intent (802bc3c: Keep Markdown examples and code names inside inline code from being reinterpreted as formatting.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jay Zhou: Raw commit e73028f adds packages/normalization-core/src/markdown-plain-text.ts:31 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e73028f81cda; files: packages/normalization-core/src/markdown-plain-text.ts)
  • Ayaan Zaidi: Raw commit 802bc3c adds packages/normalization-core/src/markdown-plain-text.ts:227 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 802bc3c61b56; files: packages/normalization-core/src/markdown-plain-text.ts)
  • Vyctor H. Brzezowski: Raw commit c84e8d0 adds packages/normalization-core/src/markdown-plain-text.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c84e8d0d5b10; files: packages/normalization-core/src/markdown-plain-text.ts)

PR surface

Source -25, Tests +20. Total -5 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 33 58 -25
Tests 1 21 1 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 54 59 -5

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +33/−58; tests +21/−1 The implementation shrinks while adding focused coverage for composed links and nested image omission.

Labels

Label changes:

  • add P3: This is a small download-size optimization with intentionally unchanged user-facing behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a small download-size optimization with intentionally unchanged user-facing behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 18, 2026, 9:29 AM ET / 14:29 UTC.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Visual proof: no visible change

Six Markdown fixtures (links, nested links, images, escaped markers and unfinished Markdown) were run through both sidebar live narration and tool-progress previews, on desktop and on phone. Rendered text and row geometry match at every checkpoint, and the subtitle pixels match across 1,855 settled video frames. In addition, 100,000 synthetic inputs produced the same output as main in both image modes. The unfinished-link fixture shows com/open( text on both builds; that is existing behavior, not a regression.

Before (main 5d106ddc) After (27cdbb76)
Before: live narration preview After: live narration preview, identical
Before: tool progress preview on phone After: tool progress preview on phone, identical

These used synthetic Gateway fixtures in the dark theme. The videos appended below are, in order: before desktop, after desktop, before phone, after phone.

cc @vyctorbrzezowski

before-desktop.mp4
after-desktop.mp4
before-phone.mp4
after-phone.mp4

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Re-ran checks-fast-baseline-ratchets once. It failed because GitHub's hosted runner lost contact with the server, not because of a test result. cc @vyctorbrzezowski

@roboclaw-bot
roboclaw-bot merged commit 753e9de into main Nov 18, 2026
173 of 175 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/briny-shrimp branch November 18, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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