Repository navigation
fix(sessions): session previews rewrite code names like __init__ and **/*.ts - #196547
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Gateway proof for #196530: built Gateway ( Assistant replies (stand-in fixtures):
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesPreserve literal inline-code contents while flattening surrounding Markdown in session previews and excerpts. Example: A session message contains: Use
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a current preview bug, resolves both prior findings, and has no remaining actionable defects identified. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared normalizer converts Markdown messages into plain text for Gateway session projections, sidebar narration, and excerpts before consumers apply length limits. flowchart TD
A[Markdown messages] --> B[Shared plain text normalizer]
B --> C[Gateway session projection]
B --> D[Sidebar narration]
B --> E[Headlines and excerpts]
C --> F[Session list clients]
Technical reviewBest possible solution: Land the focused shared-normalizer correction while retaining existing fence handling, surrounding Markdown flattening, and preview limits. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the transformation-order defect, and supplied base Gateway output demonstrates it; this read-only review executed no target code. Is this the best way to solve the issue? The patch restores literal preservation at the existing shared owner with a small local representation and a focused regression, without adding dependencies or competing implementations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 63f4933167bf. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +11, Tests 0. Total +11 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 10, 2026, 4:43 AM ET / 09:43 UTC (Revision 2). |
|
Gateway proof for head d62121c: built Gateway ( Assistant replies (stand-in fixtures):
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 802bc3c. Thanks @liugedragon for the report. |
…**/*.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]>
Closes #196530. Thanks @liugedragon for the clear report and reproduction, and for the link-destination and NUL cases in #196554, which this PR covers.
What Problem This Solves
Fixes: session previews rewrite text inside inline code when a message contains code names or Markdown examples.
Use `__init__` nowshowed asUse init now,`**/*.ts`as*/.ts, and`[x](url)`asx.User Impact
Session list previews (
lastMessagePreview), sidebar narration, title backfill and Template excerpts show code names, globs and Markdown examples exactly as written. The stored transcript was never affected.Why This Change Was Made
flattenMarkdownToPlainTextremoved the inline-code backticks first and then ran link, block-marker and emphasis stripping over the whole string, so code contents were treated as Markdown. Now link stripping runs first and skips brackets inside code spans (link destinations are still parsed on the raw text, so a destination likehttps://example.com/`v1`is still removed). Each code span is then held in an indexed NUL-delimited placeholder through block-marker and emphasis stripping and put back before whitespace collapsing; NULs outside code are doubled so they can't look like a placeholder. Formatting around a code span still flattens:**`__init__`**gives__init__,[`**/*`](u)gives**/*. Fence handling and preview truncation are unchanged.Evidence
sessions.list(includeLastMessage: true). Main and candidate, two runs each. Full output: fix(sessions): session previews rewrite code names like __init__ and **/*.ts #196547 (comment)Rename it to snake_case_name, keep init, match /*.ts, and show **literal as typed.Candidate:Rename it to snake_case_name, keep __init__, match **/*.ts, and show **literal** as typed.chat.historyreturns the original text on both.markdown-plain-text.test.tsnow covers identifiers, globs, link syntax inside code, outer emphasis and link flattening, backticks in a link destination, and NULs inside and beside a code span. It fails on main and passes here.