Skip to content

fix: session previews alter identifiers and examples inside inline code - #196554

Closed
liugedragon wants to merge 1 commit into
openclaw:mainfrom
liugedragon:fix/preserve-inline-code-previews
Closed

liugedragon wants to merge 1 commit into
openclaw:mainfrom
liugedragon:fix/preserve-inline-code-previews

Conversation

@liugedragon

Copy link
Copy Markdown

Closes #196530
Related: #184411

What Problem This Solves

Fixes session previews changing inline-code identifiers such as __init__ to init, dropping Markdown examples, and altering globs such as **/*.ts.

User Impact

Newly computed previews and excerpts retain literal code while still flattening surrounding links and emphasis. Stored messages remain unchanged.

Why This Change Was Made

The preview flattener preserves its existing single-backtick spans until prose formatting finishes. It reads link destinations from the original text first, keeping backticks, spaces, and parentheses in URLs from changing link recognition.

This fixes the lightweight preview path; #184411 fixed web_fetch extraction. The public stripInlineLinks behavior and completed-fence handling stay intact. Importing the full Markdown parser here would create a dependency cycle because markdown-core already depends on normalization-core.

Evidence

Windows x64, Node.js 24.22.1, base c96584ab3a4e34af744bbb36534a66b58c1ffe85.

  • Red on base: three normalizer regressions and the session-preview assertion fail for the intended text changes; 55 controls pass.
  • Candidate: 202 passed across the normalizer (43), session display projection (16), web_fetch extraction (62), session branch headlines (5), mention Inbox (31), and sidebar narration (45).
  • Template source checks: 44 passed, two pre-existing Windows rename failures. Both failures reproduce on base with EPERM when promoting an existing source directory.
  • The normalization package production typecheck, scoped type-aware lint, formatter, and whitespace checks pass. Independent local source review and direct Node probes found no remaining actionable issues.
  • Test growth is 22 lines, covered by its dedicated allocation; production growth is 26 lines. The owner suite takes 3.96 seconds (0.523 seconds in test cases); the projection shard takes 5.03 seconds. CI timing is pending.

The local test-line ratchet remains red because of an inherited 293-line overage: base has 6,619,298 test lines against a 6,619,005 ceiling; candidate adds 22 test lines and a 22-line allocation, retaining the same overage. Base reports that overage as a notice with zero delta; candidate exits 1 for positive delta. No extra budget or unrelated test removal is included.

Validation is source-level. A packaged Gateway, browser rendering, and a live model turn were not exercised.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Preserve literal inline-code contents while flattening surrounding Markdown in session previews and excerpts.

Example: A message contains: Use __init__ now.

  • Before: Use init now.
  • After: Use init now.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful, focused implementation with no definite introduced defect found, but required shipped-behavior evidence is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Session previews silently change literal code identifiers, globs, and Markdown examples.
Reason: Restoring literal code in existing plain-text projections provides clear value without adding configuration, dependencies, or another owner.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR addresses a current preview bug with a focused shared-owner fix; the overlapping PR does not yet establish safe supersession.

Priority: P2
Reviewed head: 4fe7e9549c35921a8101e7aab86e7f13216563db

Before merge

  • Add real behavior proof - Submitted tests exercise the normalizer and in-process session projection, but no shipped Gateway or UI exercises this candidate head; the overlapping PR's Gateway output does not prove this implementation. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Low-value test packages/normalization-core/src/markdown-plain-text.test.ts: Remove the standalone literal-glob row: the formatted-prose row already exercises the same glob-preservation failure at this owner.
  • Missing end-to-end proof: Supply candidate Gateway sessions.list output showing preserved identifiers, globs, and literal links, with surrounding formatting, preview limits, and unchanged chat.history controls; redact credentials and private endpoints.
Agent review details

How this fits together

The shared normalizer receives Markdown message text and produces plain text for Gateway previews, sidebar narration, headlines, and excerpts before callers apply length limits.

flowchart TD
  A[Message Markdown] --> B[Shared plain text normalizer]
  B --> C[Gateway session projection]
  B --> D[Sidebar narration]
  B --> E[Headlines and excerpts]
  C --> F[Session list clients]
Loading

Technical review

Best possible solution:

Preserve literals in the existing shared normalizer while retaining link parsing, completed-fence handling, preview limits, and the exported link-stripper contract.

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

Current-main transformation order and the production projection caller establish the failure path; the linked report supplies exact source-level inputs and outputs, but this read-only review executed no target code.

Is this the best way to solve the issue?

The patch fixes literal preservation at the existing shared owner, and its private link-parsing mode avoids changing the public behavior used by web_fetch.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Inline-code transformation order changes intended behavior with a stated reason (9a947e4: Move the earlier sidebar flattener into a shared producer-side normalizer so consumers receive readable previews.)
  • Link matching and exported stripping behavior keeps the original intent (e73028f: Recognize nested labels and valid destinations without leaking URLs or consuming surrounding prose.)
  • Emphasis processing keeps the original intent (6ed337b: Bound unmatched-emphasis scanning while preserving delimiter rules and pass order.)
  • Completed-fence handling keeps the original intent (047084b: Remove completed longer backtick and tilde fences while preserving existing inline and unfinished-fence handling.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9a947e4 adds packages/normalization-core/src/markdown-plain-text.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9a947e4bb8d0; files: packages/normalization-core/src/markdown-plain-text.ts)
  • Vincent Koc: Raw commit 6ed337b adds packages/normalization-core/src/markdown-plain-text.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6ed337b3c222; files: packages/normalization-core/src/markdown-plain-text.ts)
  • 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)

PR surface

Source +26, Tests +22, Other +2. Total +50 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 34 8 +26
Tests 2 22 0 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 58 8 +50

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.

Root-cause cluster

Relationship: same_root_cause
Canonical: #196530
Summary: Two open PRs address the reported preview transformation order; the earlier web_fetch fix concerns a separate extraction path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: Incorrect derived previews misrepresent code identifiers and examples, while original messages remain available.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: Incorrect derived previews misrepresent code identifiers and examples, while original messages remain available.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide redacted output from the built candidate Gateway demonstrating corrected session previews.

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 10, 2026, 4:37 AM ET / 09:37 UTC.

obviyus added a commit that referenced this pull request Nov 10, 2026
…**/*.ts (#196547)

fix: keep inline code literal in session previews

Session previews changed literal code names and Markdown examples: `__init__` became init, `**/*.ts` became /*.ts and `**literal**` lost its markers. The shared normalizer that builds the stored preview, flattenMarkdownToPlainText, removed backticks first and then stripped links, line markers and bold or italic markers across the whole text, so code was treated as Markdown. Links are now stripped first with brackets inside code ignored, and each code span is held as a placeholder until stripping is done. Formatting around code still flattens, and no wording is new.

Evidence: a built Gateway on node:24.22.1 in secretless Docker with a local stand-in model replying with the issue's examples, previews read through sessions.list, two runs each. Main showed "keep init, match /*.ts, and show **literal as typed"; this change shows "keep __init__, match **/*.ts, and show **literal** as typed", and the Markdown examples case is exact. Ordinary prose, the 240-character cut, emoji and a link whose address contains backticks are identical on both, and chat.history returns the original text in every run. Details: #196547 (comment).

Closes #196530. Thanks @liugedragon for the report and for the link-address cases in #196554.

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @liugedragon for reporting #196530 and for this fix. The same change landed in #196547 (802bc3c), which was opened a few minutes earlier; it covers your test cases, including the link-address ones, and credits you. Closing this one as a duplicate.

@obviyus obviyus closed this Nov 10, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…**/*.ts (openclaw#196547)

fix: keep inline code literal in session previews

Session previews changed literal code names and Markdown examples: `__init__` became init, `**/*.ts` became /*.ts and `**literal**` lost its markers. The shared normalizer that builds the stored preview, flattenMarkdownToPlainText, removed backticks first and then stripped links, line markers and bold or italic markers across the whole text, so code was treated as Markdown. Links are now stripped first with brackets inside code ignored, and each code span is held as a placeholder until stripping is done. Formatting around code still flattens, and no wording is new.

Evidence: a built Gateway on node:24.22.1 in secretless Docker with a local stand-in model replying with the issue's examples, previews read through sessions.list, two runs each. Main showed "keep init, match /*.ts, and show **literal as typed"; this change shows "keep __init__, match **/*.ts, and show **literal** as typed", and the Markdown examples case is exact. Ordinary prose, the 240-character cut, emoji and a link whose address contains backticks are identical on both, and chat.history returns the original text in every run. Details: openclaw#196547 (comment).

Closes openclaw#196530. Thanks @liugedragon for the report and for the link-address cases in openclaw#196554.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Session previews change literal code identifiers and Markdown examples

2 participants