Skip to content

BlockRenderer, postContent: parse plain-text markdown tables in messages#5839

Merged
dnbrwstr merged 19 commits into
developfrom
jamesacklin/md-table-blocks
May 19, 2026
Merged

BlockRenderer, postContent: parse plain-text markdown tables in messages#5839
dnbrwstr merged 19 commits into
developfrom
jamesacklin/md-table-blocks

Conversation

@jamesacklin
Copy link
Copy Markdown
Member

@jamesacklin jamesacklin commented May 13, 2026

Summary

Render GFM-style Markdown tables in messages as real tables instead of pipe-text. Detection runs client-side at receive time — wire format unchanged, old clients still see plaintext.

Why is this PR so big?

About 1,300 lines net but most of it is moved code, not new logic. Here's how to read it:

~870 lines of genuine new code — start here:

  • extractTables.ts (~415 lines) — the splitter
  • extractTables.test.ts (~290 lines) — 9 unit tests for the splitter
  • groupMentionPlugin.ts (~85 lines) — mirrors shipMentionPlugin.ts
  • postContentInlines.ts (~80 lines) — convertInlineContent extracted out of postContent.ts to break a cycle between convertContent and extractTablesFromContent

~160 lines of additions to existing files:

  • BlockRenderer.tsx — the TableBlock component (column-grouped layout, three-phase onLayout measurement)
  • postContent.tsTableBlockData type, BlockData union extension, plaintextPreviewOf case, single call to extractTablesFromContent at the end of convertContent
  • mdastToStory.tsisGroupMention type guard and handler in phrasingToInlines

The rest is a directory move (packages/shared/src/logic/markdown/packages/api/src/client/markdown/).

Changes

  • New TableBlockData block type + TableBlock renderer (column-grouped layout, two-pass onLayout measurement, capped at 280px wide, header-row dim styling).
  • Splitter at packages/api/src/client/markdown/extractTables.ts finds GFM tables in paragraph content, parses with remark-gfm, emits TableBlockData. Uses mdast-util-to-markdown for serialization so bold/links/mentions in cells survive intact.
  • New remarkGroupMentions plugin (parallel to remarkShipMentions) so @all / @admin round-trip through table cells.
  • Moved the entire markdown module from packages/shared/src/logic/markdown/packages/api/src/client/markdown/. api now owns content conversion end-to-end; convertContent calls extractTablesFromContent directly.

How did I test?

  • 9 new unit tests in extractTables.test.ts covering simple extraction, soft-wrap continuation merging, no-outer-pipe tables, bold/link/group-mention preservation in cells, and pre/post-paragraph splitting.
  • All 50 existing markdown tests + 51 storyToMarkdown tests + 58 roundTrip tests still pass.
  • Typecheck clean for files in this branch.
  • pnpm lint passes with zero errors (117 warnings, all pre-existing on develop).
  • Verified visually with a bot post whose cells contained bold + link inlines.

Risks and impact

  • Safe to rollback without consulting PR author? Yes
  • Affects important code area:
    • Onboarding
    • State / providers
    • Message sync
    • Channel display
    • Notifications
    • Other:

No wire-format or backend changes. New code path only fires on paragraphs whose text matches a GFM table signature.

Rollback plan

Revert the branch. To narrowly disable detection without removing the type, remove the extractTablesFromContent call at the end of api's convertContent.

Screenshots / videos

Appearance in chat:
image

Appearance in notebook:
image

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4076a78560

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/api/src/client/markdown/extractTables.ts
@jamesacklin
Copy link
Copy Markdown
Member Author

@claude review once

Comment thread packages/app/ui/components/PostContent/BlockRenderer.tsx
Comment thread packages/api/src/client/markdown/extractTables.ts
@blacksmith-sh

This comment has been minimized.

Copy link
Copy Markdown
Member

@patosullivan patosullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, but there are a few issues I think should probably be addressed before we merge. Most are pretty minor.

Comment thread packages/api/src/client/markdown/extractTables.ts Outdated
Comment thread packages/api/src/client/markdown/extractTables.ts Outdated
Comment thread packages/api/src/client/markdown/groupMentionPlugin.ts Outdated
Comment thread packages/api/src/client/markdown/extractTables.ts
Comment thread packages/api/src/client/markdown/extractTables.ts
Comment thread packages/api/src/client/markdown/extractTables.ts Outdated
Comment thread packages/app/ui/components/PostContent/BlockRenderer.tsx
Comment thread packages/api/src/client/postContent.ts Outdated
@jamesacklin jamesacklin requested a review from patosullivan May 14, 2026 23:38
Copy link
Copy Markdown
Member

@patosullivan patosullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dnbrwstr dnbrwstr merged commit 0b343be into develop May 19, 2026
4 checks passed
@dnbrwstr dnbrwstr deleted the jamesacklin/md-table-blocks branch May 19, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants