Skip to content

feat(tui): terminal markdown table renderer with Unicode box-drawing …#420

Merged
Nomikfk1215 merged 1 commit into1024XEngineer:mainfrom
mickey-228:codex/table-renderer
May 9, 2026
Merged

feat(tui): terminal markdown table renderer with Unicode box-drawing …#420
Nomikfk1215 merged 1 commit into1024XEngineer:mainfrom
mickey-228:codex/table-renderer

Conversation

@mickey-228
Copy link
Copy Markdown
Collaborator

重写 markdown 表格渲染,提供规整的终端原生表格:

  • Unicode 制表符绘制边框(┌┬┐├┼┤└┴┘│─),边框完整包裹 cell 内边距
  • 列宽按最小宽度/理想宽度/比例分配三步算法,支持 CJK 等宽字符
  • 两种展现模式:
    • 水平网格表格(默认),表头居中、数据按 markdown 对齐方式渲染
    • 垂直 key-value 模式(终端太窄或行数超 4 行时自动切换)
  • ANSI 感知的文本换行(单词边界断行 + 硬断行两种模式)
  • 同行 cell 行数不一致时自动垂直居中

改动文件

  • tui/markdown_renderer.go — 新增/重写表格渲染函数和辅助工具
  • tui/assistant_render_pipeline.go — assistant 输出切换到 goldmark 渲染路径

验证

  • go build ./... 编译通过
  • go test ./tui/ -count=1 全部测试通过
  • 水平模式:Unicode 边框 + 表头居中 + 数据对齐
  • 垂直模式:窄终端/多行时自动切换
  • CJK 字符列宽正确
  • Emoji 内容(✅ 🔄 ⏳ 📋)宽度计算正确

…and adaptive layout

Replace markdown table rendering with a robust implementation:

- Unicode box-drawing chars (┌┬┐├┼┤└┴┘│─) for properly enclosed cells
- Min/ideal/proportional column width algorithm, CJK-aware via runewidth
- Two modes: horizontal grid (default) and vertical key-value (fallback)
- Per-column alignment support (left/center/right from markdown :---/:---:/---:)
- Header rows always center-aligned
- ANSI-aware text wrapping (word-wrap + hard-break modes)
- Vertical cell centering for multi-line rows

Changes:
- tui/markdown_renderer.go: new table rendering engine + helpers
- tui/assistant_render_pipeline.go: route assistant through goldmark path
@mickey-228
Copy link
Copy Markdown
Collaborator Author

image

@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

❌ Patch coverage is 75.87940% with 48 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
tui/markdown_renderer.go 76.28% 38 Missing and 8 partials ⚠️
tui/assistant_render_pipeline.go 60.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Nomikfk1215 Nomikfk1215 merged commit ae47145 into 1024XEngineer:main May 9, 2026
6 checks passed
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.

2 participants