Skip to content

Show clear message for unsupported file types in preview pane#56

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/improve-ui-disable-preview
Draft

Show clear message for unsupported file types in preview pane#56
Copilot wants to merge 4 commits intomainfrom
copilot/improve-ui-disable-preview

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Opening non-markdown files (e.g., .tsx, .js) displayed confusing "broken" preview content. Preview now shows an informative message for unsupported file types.

Changes

  • Document model: Added isPreviewSupported computed property checking file extension against supported markdown types (.md, .markdown, .mdown, .mkd)
  • Preview UI: Added PreviewUnsupportedView component displaying file type and keyboard shortcut hint
  • Tests: 7 test cases covering markdown files, non-markdown files, untitled documents, and edge cases
  • Docs: Updated preview.md and FAQ.md with file type support information

Implementation

// Document.swift
var isPreviewSupported: Bool {
    guard let fileURL = fileURL else { return true }  // Untitled docs supported
    let ext = fileURL.pathExtension.lowercased()
    return ["md", "markdown", "mdown", "mkd"].contains(ext)
}

// PreviewView.swift
if !appState.currentDocument.isPreviewSupported {
    PreviewUnsupportedView(fileExtension: fileURL?.pathExtension ?? "")
} else {
    MarkdownWebView(html: renderedHTML, baseURL: resourceBaseURL)
}

Preview behavior unchanged for markdown files.

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve UI: file types that can't be previewed should have preview disabled</issue_title>
<issue_description>Example:

A user opens a .tsx file. The Preview appears "broken", but it's actually just not supported.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 27, 2026 23:54
- Add isPreviewSupported property to Document model
- Show unsupported message for non-markdown files (e.g., .tsx)
- Add comprehensive tests for preview support detection

Co-authored-by: kristinaquinones <5562083+kristinaquinones@users.noreply.github.com>
- Make keyboard shortcut hint consistent ("toggle" instead of "hide")
- Add test for files without extensions (README, LICENSE)

Co-authored-by: kristinaquinones <5562083+kristinaquinones@users.noreply.github.com>
- Add file type support section to preview.md
- Add FAQ entry explaining when preview is not available

Co-authored-by: kristinaquinones <5562083+kristinaquinones@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve UI by disabling preview for unsupported file types Show clear message for unsupported file types in preview pane Jan 27, 2026
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.

Improve UI: file types that can't be previewed should have preview disabled

2 participants