Skip to content

Comments

Improve MarkdownDef formats#4029

Open
lukemelia wants to merge 4 commits intomainfrom
cs-10221-improve-markdown-def-formats
Open

Improve MarkdownDef formats#4029
lukemelia wants to merge 4 commits intomainfrom
cs-10221-improve-markdown-def-formats

Conversation

@lukemelia
Copy link
Contributor

@lukemelia lukemelia commented Feb 19, 2026

Summary

  • Isolated: Renders full markdown content via MarkdownTemplate (headings, lists, code blocks, tables, syntax highlighting); falls back to title when content is empty
  • Embedded: Title header + rendered markdown content with max-height: 200px and gradient fade-out mask to indicate more content
  • Fitted: MarkdownIcon + title + plain-text excerpt with container queries adapting layout for portrait tall/short, landscape, and very small (≤57px) sizes
  • Atom: Inline 16px MarkdownIcon + title with ellipsis overflow
  • Deletes the now-unused markdown-file-preview.gts (single component previously shared across all formats)
Screen.Recording.2026-02-19.at.6.02.29.PM.mov

Test plan

  • Verify build succeeds (template lint passes, no dangling imports)
  • Existing extraction tests in markdown-file-def-test.gts pass unchanged
  • Manual visual verification: open a markdown file in isolated, embedded, fitted, and atom contexts
  • Verify fitted format adapts correctly at different container sizes

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   1h 42m 1s ⏱️ -57s
1 856 tests +2  1 842 ✅ +2  14 💤 ±0  0 ❌ ±0 
1 871 runs  +2  1 857 ✅ +2  14 💤 ±0  0 ❌ ±0 

Results for commit d19686c. ± Comparison against base commit 975718c.

♻️ This comment has been updated with latest results.

Previously MarkdownDef used a single MarkdownFilePreview component for all
formats, showing only title + plain-text excerpt. Now each format has a
purpose-built component: isolated renders full markdown via MarkdownTemplate,
embedded shows title + rendered content with fade-out, fitted uses icon + title
+ excerpt with container queries, and atom shows icon + title inline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lukemelia lukemelia force-pushed the cs-10221-improve-markdown-def-formats branch from 52455a9 to fbd39f3 Compare February 19, 2026 22:45
…rgin

- Add Head format with OG/Twitter meta tags using title and excerpt
- Skip duplicate title in Embedded when content starts with matching heading
- Add padding to Embedded format
- Suppress top margin on first heading in Isolated and Embedded formats

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lukemelia lukemelia marked this pull request as ready for review February 19, 2026 23:03
@lukemelia lukemelia requested review from a team and jurgenwerk February 19, 2026 23:04
@lukemelia lukemelia changed the title CS-10221: Improve MarkdownDef formats Improve MarkdownDef formats Feb 19, 2026
@backspace
Copy link
Contributor

Maybe this is a separate issue but I’d expect changes to the Markdown to be reflected in the preview, I had to refresh to see them:

screencast 2026-02-20 08-36-07

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors MarkdownDef’s presentation formats so markdown files render richer previews across isolated/embedded/fitted/atom contexts, and removes the previously shared preview component.

Changes:

  • Replace the single shared MarkdownFilePreview with dedicated Isolated, Embedded, Fitted, Atom, and Head components inside markdown-file-def.gts.
  • Render full markdown via MarkdownTemplate for isolated/embedded formats (with embedded height clamping + fade mask).
  • Remove the unused packages/base/markdown-file-preview.gts component and document a .gts regex/content-tag parsing gotcha in AGENTS.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/base/markdown-file-preview.gts Deleted the old shared preview component now replaced by per-format implementations.
packages/base/markdown-file-def.gts Adds per-format components (isolated/embedded/fitted/atom/head), uses MarkdownTemplate, updates excerpt parsing/truncation.
AGENTS.md Documents content-tag lexer pitfalls with certain regex literals in .gts files and recommended workarounds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return markdown.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
}

const FENCED_CODE_RE = /```[\s\S]*?```/g;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

FENCED_CODE_RE is still a regex literal containing backticks (```), but the new guidance/comment indicates content-tag can misparse backticks in regex literals in .gts files. To avoid reintroducing the same parsing failure, consider defining this via `new RegExp()` (string pattern) as well, or otherwise ensure no backticks appear in regex literals in this file.

Suggested change
const FENCED_CODE_RE = /```[\s\S]*?```/g;
const FENCED_CODE_RE = new RegExp('```[\\s\\S]*?```', 'g');

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +110
class Isolated extends Component<typeof MarkdownDef> {
get title() {
return (
this.args.model?.title ?? this.args.model?.name ?? 'Untitled markdown'
);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The title getter logic is duplicated across multiple format components (Isolated/Embedded/Fitted/Atom/Head). This duplication makes it easy for the formats to drift (e.g., changing fallback text in one place but not the others). Consider extracting a shared helper (or a small base class) to compute the title once and reuse it across these components.

Suggested change
class Isolated extends Component<typeof MarkdownDef> {
get title() {
return (
this.args.model?.title ?? this.args.model?.name ?? 'Untitled markdown'
);
function computeMarkdownTitle(
model: { title?: string | null; name?: string | null } | null | undefined,
): string {
return model?.title ?? model?.name ?? 'Untitled markdown';
}
class Isolated extends Component<typeof MarkdownDef> {
get title() {
return computeMarkdownTitle(this.args.model);

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@backspace backspace left a comment

Choose a reason for hiding this comment

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

I tried this locally and the previews look good across the different formats, I assume the lack of live updating is an existing problem

@habdelra
Copy link
Contributor

habdelra commented Feb 20, 2026

I tried this locally and the previews look good across the different formats, I assume the lack of live updating is an existing problem

I tried this locally and the previews look good across the different formats, I assume the lack of live updating is an existing problem

the not live updating makes me wonder how the store is handling realm update events for file-defs. perhaps there is a bug there. we def need test coverage around that scenario.

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