Skip to content

fix(markdown): align code tables by display width#55596

Merged
steipete merged 7 commits into
openclaw:mainfrom
sparkyrider:fix/55512-cjk-table-width
Jul 9, 2026
Merged

fix(markdown): align code tables by display width#55596
steipete merged 7 commits into
openclaw:mainfrom
sparkyrider:fix/55512-cjk-table-width

Conversation

@sparkyrider

@sparkyrider sparkyrider commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Markdown tables rendered in code mode used JavaScript UTF-16 string length to size columns. CJK and emoji cells therefore received the wrong padding, so table borders did not align in shared Telegram and Discord output.

Closes #55512.

Why This Change Was Made

This branch was rewritten on current main after the Markdown renderer moved into packages/markdown-core. The renderer now reuses terminal-core's canonical grapheme-aware visibleWidth implementation for both width collection and row padding. The shared width helper was also tightened to distinguish Unicode text presentation from valid emoji, keycap, flag, and ZWJ sequences without adding a dependency or duplicating width policy.

User Impact

Code-formatted Markdown tables containing CJK text, emoji, or mixed-width cells now keep their columns aligned. Narrow text-presentation symbols stay narrow, and terminal tables share the corrected emoji-sequence behavior. ASCII-only tables are unchanged. There are no config, protocol, dependency, or migration changes.

Evidence

  • Exact head 1f04e303d5a46857519486c69de93474571993df.
  • Compared with the previously reviewed b0b5d055be352bba656cbf8ca3ca2eddcac5f8e7, the production and test tree is unchanged. The only content removal was the contributor-branch CHANGELOG.md line, deferred to the maintainer release-note lane; the commits were then rebased and ancestry-preserving force-pushed with all seven PR-local commits maintainer-signed and both contributor co-author trailers intact.
  • Exact Markdown output regressions cover CJK, family ZWJ emoji, text-default symbols, and incomplete selectors. Terminal width regressions cover text/emoji selectors, narrow and EAW-wide VS15 bases, qualified and unqualified keycaps, malformed and minimally-qualified ZWJ sequences, and lone/pair/triplet regional indicators.
  • Sanitized public-network AWS Crabbox (cbx_eca8262d6ca3) focused proof: 41/41 tests passed in run_23d254b679b5.
  • Sanitized AWS Crabbox changed-surface gate, full build, and plugin-SDK declaration build passed in run_b6927ff19465.
  • Negative control: replacing only the renderer with base 4f9a371c9530e9d2eb2912a44054a44228a59612 produced both expected regression failures in run_6a494e96909b.
  • Fresh exact-head CI passed 43 jobs with 12 expected skips and no failures; the exact-head dependency guard also passed after the ancestry repair.
  • The prior exact-tree native Telegram Desktop proof and its baseline/candidate artifact show shifted CJK/emoji cells on the base and aligned columns on the candidate. Fresh exact-head AWS attempt 29044668245 failed before either lane ran because Crabbox desktop lease creation returned coordinator 502/500 errors; its failure manifest marks both lanes skipped and carries no product verdict. A Hetzner retry is active at 29046675260. Known gap: no fresh post-rebase screenshot is available yet; this does not change the prior exact-tree visual result because all production and test blobs are identical, and fresh exact-head output tests, build/declarations, CI, dependency guard, and autoreview are clean.
  • Fresh GPT-5.5 high-reasoning autoreview of the exact head: clean (0.82), with no accepted or actionable findings.

Original contribution preserved with co-author credit to @sparkyrider.

@sparkyrider sparkyrider changed the title fix(CLI) Markdown table columns misaligned with CJK characters on Telegram and Discord #55512 fix(CLI) Markdown table columns misaligned with CJK characters on Telegram and Discord Mar 27, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 9, 2026, 3:47 PM ET / 19:47 UTC.

Summary
The PR updates markdown-core code-table rendering to use terminal-core display widths and adds Markdown/terminal Unicode width regression tests.

PR surface: Source +25, Tests +67. Total +92 across 4 files.

Reproducibility: yes. Current main still uses UTF-16 string length for markdown code-table sizing, and the inspected Telegram baseline proof shows the CJK/emoji column shift that the candidate corrects.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #55512
Summary: This PR is the active candidate fix for the canonical Markdown CJK/emoji code-table alignment issue.

Members:

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

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The fresh exact-head native Telegram Mantis run was still in progress during this review, so maintainers should wait for that workflow if it is treated as a required merge gate.

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared markdown-core and terminal-core width fix after required checks and the active exact-head Mantis proof finish, then let the linked Markdown table alignment issue close from the merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No ClawSweeper repair is needed; the remaining action is normal maintainer merge handling after the active exact-head proof or required checks finish.

Security
Cleared: No security or supply-chain concern found; the diff touches Markdown/terminal rendering code and tests without workflow, dependency, secret, install, or permission changes.

Review details

Best possible solution:

Land the shared markdown-core and terminal-core width fix after required checks and the active exact-head Mantis proof finish, then let the linked Markdown table alignment issue close from the merge.

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

Yes. Current main still uses UTF-16 string length for markdown code-table sizing, and the inspected Telegram baseline proof shows the CJK/emoji column shift that the candidate corrects.

Is this the best way to solve the issue?

Yes. Reusing terminal-core visibleWidth in the shared markdown-core table renderer is the narrow maintainable fix; channel-specific patches or a new width dependency would create drift.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority rendering correctness fix for internationalized Telegram and Discord table readability with limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Native Telegram Desktop before/after screenshots show the baseline table misalignment and the candidate aligned output; the latest behavior files match the proven tree, with only release-note churn removed afterward.
  • proof: sufficient: Contributor real behavior proof is sufficient. Native Telegram Desktop before/after screenshots show the baseline table misalignment and the candidate aligned output; the latest behavior files match the proven tree, with only release-note churn removed afterward.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Native Telegram Desktop before/after screenshots show the baseline table misalignment and the candidate aligned output; the latest behavior files match the proven tree, with only release-note churn removed afterward.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram Markdown table output, and native Telegram Desktop proof is useful for confirming aligned chat rendering.
Evidence reviewed

PR surface:

Source +25, Tests +67. Total +92 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 29 4 +25
Tests 2 68 1 +67
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 97 5 +92

What I checked:

  • Current main still uses code-unit table widths: Current main measures and pads code-table cells with cell?.text.length, which undercounts CJK and emoji display columns in the reported renderer path. (packages/markdown-core/src/ir.ts:653, ee9d9ea6dbb7)
  • PR applies shared visible-width measurement: At the PR head, renderTableAsCode uses visibleWidth for both width collection and row padding, keeping the fix in the shared markdown-core table renderer. (packages/markdown-core/src/ir.ts:653, 1f04e303d5a4)
  • Terminal width helper is tightened for emoji sequences: The PR refines terminal-core width classification for RGI emoji, flags, keycaps, text presentation, and ZWJ sequences before markdown-core reuses that helper. (packages/terminal-core/src/ansi.ts:145, 1f04e303d5a4)
  • Regression tests cover the reported width cases: The PR adds markdown-core table output tests for CJK, family ZWJ emoji, text-presentation symbols, and incomplete selector sequences, plus terminal-core width tests for related emoji and flag cases. (packages/markdown-core/src/ir.table-code.test.ts:5, 1f04e303d5a4)
  • Affected channels use the shared converter: Telegram passes table mode into markdownToIR, and Discord resolves table mode then calls convertMarkdownTables, so the shared markdown-core fix covers the reported channel surfaces. (extensions/telegram/src/format.ts:162, ee9d9ea6dbb7)
  • Real Telegram proof inspected: The downloaded Mantis screenshots show baseline Telegram code-table columns shifted for wide cells and candidate output with aligned columns; MP4 preprocessing lacked ffprobe, but the static proof images were viewable. (b0b5d055be35)

Likely related people:

  • steipete: Peter Steinberger committed the original per-channel markdown table conversion and is the current live assignee on this PR; his review comment also records the best-fix and proof judgment for the exact head. (role: recent area contributor and assigned reviewer; confidence: high; commits: b77e73065775, 04c976b43d50; files: src/markdown/ir.ts, src/config/markdown-tables.ts, packages/markdown-core/src/ir.ts)
  • odysseus0: The merged per-channel markdown table conversion commit is credited to odysseus0, and that feature introduced the table-mode behavior exercised by this PR. (role: original table-mode feature contributor; confidence: high; commits: b77e73065775; files: src/markdown/ir.ts, src/config/markdown-tables.ts)
  • jbetala7: Jayesh Betala authored the recent terminal-core wide-grapheme table fix, the closest merged precedent for the display-width helper behavior reused here. (role: adjacent width-helper contributor; confidence: medium; commits: 29dd7847fd96; files: packages/terminal-core/src/ansi.ts, packages/terminal-core/src/table.ts, packages/terminal-core/src/table.test.ts)
  • scoootscooob: scoootscooob moved the Discord channel implementation into the current extension path that calls the shared Markdown table converter. (role: recent Discord channel refactor contributor; confidence: medium; commits: 5682ec37fada; files: extensions/discord/src/send.outbound.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (6 earlier review cycles)
  • reviewed 2026-07-03T04:25:34.526Z sha 63a157a :: needs changes before merge. :: [P1] Port the width fix to markdown-core
  • reviewed 2026-07-05T16:25:27.884Z sha 63a157a :: needs changes before merge. :: [P1] Port the width fix to markdown-core
  • reviewed 2026-07-09T16:25:57.369Z sha b0b5d05 :: needs changes before merge. :: [P3] Drop the release-owned changelog entry
  • reviewed 2026-07-09T16:33:56.847Z sha b0b5d05 :: needs changes before merge. :: [P3] Drop the release-owned changelog entry
  • reviewed 2026-07-09T16:41:52.651Z sha b0b5d05 :: needs changes before merge. :: [P3] Drop the release-owned changelog entry
  • reviewed 2026-07-09T19:40:05.702Z sha 1f04e30 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 11, 2026
@obviyus

obviyus commented May 11, 2026

Copy link
Copy Markdown
Contributor

@openclaw-mantis please generate the Telegram desktop proof for this PR.

@openclaw-mantis

openclaw-mantis Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIFs showing Markdown code tables with CJK and emoji cells shifting on Main and aligning in this PR.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-55596/run-29046675260-1/index.json

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. labels May 19, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Pearl Branchling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: keeps receipts.
Image traits: location status garden; accessory green check lantern; palette cobalt, lime, and pearl; mood focused; pose guarding a tiny green check; shell brushed metal shell; lighting warm desk-lamp glow; background small green status lights.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Pearl Branchling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@giodl73-repo giodl73-repo removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@steipete
steipete marked this pull request as ready for review May 22, 2026 20:08
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer review is complete and land-ready at exact head 1f04e303d5a46857519486c69de93474571993df, with the fresh native-capture infrastructure gap disclosed below.

Best-fix judgment: yes. The shared Markdown renderer now calls terminal-core's existing visibleWidth, so Telegram, Discord, and plugin-SDK consumers use one width contract. This avoids the original branch's local width clone, a new dependency, and channel-specific fixes. No config, protocol, dependency, or migration surfaces change.

Proof:

  • Sanitized public-network AWS Crabbox cbx_eca8262d6ca3: pnpm test packages/markdown-core/src/ir.table-code.test.ts packages/markdown-core/src/tables.test.ts packages/terminal-core/src/ansi.test.ts packages/terminal-core/src/table.test.ts passed 41/41 in run_23d254b679b5.
  • The changed-surface gate, full build, and plugin-SDK declaration build passed in run_b6927ff19465: pnpm check:changed && pnpm build && pnpm build:plugin-sdk:dts.
  • Negative control run_6a494e96909b: replacing only packages/markdown-core/src/ir.ts with base 4f9a371c9530e9d2eb2912a44054a44228a59612 made both new Markdown alignment regressions fail as expected.
  • Fresh exact-head CI passed 43 jobs with 12 expected skips and no failures. The exact-head dependency guard also passed after the ancestry repair.
  • The prior exact-tree native Telegram Desktop proof and durable baseline/candidate artifact show the visual regression and correction. Fresh exact-head AWS attempt 29044668245 failed before either lane ran because Crabbox desktop lease creation returned coordinator 502/500 errors; its failure manifest marks baseline and candidate skipped with no product verdict. A Hetzner retry is active at 29046675260. Known gap: no fresh post-rebase screenshot is available yet; the earlier exact-tree visual proof remains applicable because every production/test blob is identical, and all fresh exact-head deterministic gates are clean.
  • Fresh GPT-5.5 high-reasoning autoreview of the exact head: clean (0.82), no accepted or actionable findings.

Lineage/content recheck: compared with previously reviewed head b0b5d055be352bba656cbf8ca3ca2eddcac5f8e7, all production and test blobs are unchanged. The only content removal was the contributor-branch CHANGELOG.md line, deferred to the consolidated maintainer release-note lane. The exact tree was rebased and repaired with one ancestry-preserving force-with-lease push; all seven PR-local commits are maintainer-signed, and both Sparkyrider co-author trailers remain.

Current-main recheck: main still uses UTF-16 length in the Markdown table renderer and the older broad emoji-width heuristic. The branch is mergeable with current main; no equivalent or conflicting fix has landed.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 1f04e303d5a46857519486c69de93474571993df

@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

Markdown table columns misaligned with CJK characters on Telegram and Discord

4 participants