Skip to content

feat(tui): markdown preview panel - #43599

Draft
littledsw wants to merge 1 commit into
anomalyco:devfrom
littledsw:md-preview
Draft

feat(tui): markdown preview panel#43599
littledsw wants to merge 1 commit into
anomalyco:devfrom
littledsw:md-preview

Conversation

@littledsw

Copy link
Copy Markdown

Issue for this PR

Closes#43598

Type of change

  • New feature

What does this PR do?

Adds /preview to the session view. It opens the fuzzy file picker (same fs.find search as @-mentions) and renders the selected file as markdown in a panel to the right of the session: an inline split pane on wide terminals and a right-docked overlay on narrow ones, mirroring the sidebar layout. Running /preview again closes it. New keybind tokens preview_toggle / preview_close default to unbound.

The panel reuses the built-in <markdown> renderable with streaming={false}, so content renders exactly like assistant messages (headings, code blocks, grid tables). Related web/desktop request: #38047 — TUI has no file preview today.

How did you verify your code works?

  • bun test in packages/tui: adds test/cli/tui/markdown-preview.test.tsx (rendered file content + unreadable-file state). Full suite: 194 pass; the 1 failure (runtime.test.tsx expects ~/project but gets ~\project) is a pre-existing Windows path-separator issue that also fails on an unmodified checkout.
  • packages/tui typecheck passes (tsgo --noEmit). oxlint + prettier clean on touched files.
  • Verified manually with a headless testRender mount: frame below.

Screenshots / recordings

Headless testRender capture (side-by-side, dark theme):

``

鈼?session "shipping rules analysis" CHANGELOG.md

user: # Changelog

what shipped to Shanghai last week? ## 1.2.0

assistant: - add /preview panel for rendered markdown
- sidebar-respecting split layout
Found 1,284 orders across 3 hubs. Details in the table on the right 鈥?
SELECT city, count(*) AS cnt
鈻峚sk anything鈥? FROM orders
GROUP BY 1 ORDER BY 2 DESC;

 鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹攢鈹€鈹€鈹€鈹€鈹€鈹€鈹攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
鈹侳lag 鈹侱efault鈹侲ffect 鈹?
鈹溾攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹尖攢鈹€鈹€鈹€鈹€鈹€鈹€鈹尖攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
鈹俻review_toggle鈹俷one 鈹倀oggles the preview 鈹?
鈹? 鈹? 鈹俻anel 鈹?
鈹溾攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹尖攢鈹€鈹€鈹€鈹€鈹€鈹€鈹尖攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
鈹俻review_close 鈹俷one 鈹俢loses an open panel 鈹?
鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹粹攢鈹€鈹€鈹€鈹€鈹€鈹€鈹粹攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
See **CONTRIBUTING.md** for details.
/preview to close

``

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

/preview opens a fuzzy file picker and renders the selected file as
rendered markdown in a side panel next to the session: inline split on
wide terminals, right-docked overlay on narrow ones, matching the
sidebar layout pattern. Token-/command-configurable keybinds
preview_toggle and preview_close default to unbound.
@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference; please use your judgment.

  • packages/tui/src/routes/session/preview.tsx (createResource fetcher) — Bun.file(file).text() reads the whole file with no size guard; previewing a accidentally-selected large artifact (bundle, log, DB) will spike memory and can stall the TUI render loop while parsing — suggest capping read size (e.g. first ~512KB) and showing a "file too large to preview" notice instead.
  • packages/tui/src/routes/session/dialog-preview-file.tsx (files filter) — the picker accepts every type === "file" entry although the dialog title says "Preview markdown file"; selecting a binary or non-markdown file yields a raw/unparsed render — suggest filtering to .md/.mdx extensions or retitleing the dialog to "Preview file" to match behavior.
  • packages/tui/src/routes/session/dialog-preview-file.tsx (fetcher error path) — .catch(() => undefined) folds transport errors and empty results into the same [], so users can't distinguish "no matches" from "fs backend unavailable" — consider returning a discriminated error state and surfacing a one-line hint in the dialog.
  • nit — keybind.ts: both new keybinds default to "none", so the feature is only discoverable via the /preview slash command; consider binding preview_toggle to something like p by default or at least documenting it in the keymap help.

The inline vs overlay dual-mode layout and the contentWidth accounting look correct, including the wide() transition path.

— AI code review (automated)

@github-actionsgithub-actionsBot mentioned this pull request Aug 23, 2026
6 tasks
Sign up for freeto 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.

[FEATURE]: markdown preview of project files in the TUI

2 participants

@littledsw@Enough1122