Extension API: support custom read-only file previews #59598
Replies: 1 comment 1 reply
|
This proposal would also help with a concrete Use case: agent workflows often generate standalone local HTML artifacts for review: implementation matrices, PR triage boards, design critiques, status reports, and temporary working documents. Today the practical loop is "generate file in Zed, switch to an external browser, open/reload it, switch back." The useful Zed behavior would be "open preview to the side" for the For this proposal, I think there are two possible shapes:
The MVP requirements are modest:
This is not asking for a full browser. It is a file-preview workflow for local artifacts, similar in spirit to Markdown/SVG/CSV preview but with HTML as the rendered document format. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add an Extension API that allows extensions to register custom read-only file previews for specific file types, rendered inside a normal Zed tab.
Problem
Zed extensions can currently add many editor capabilities, but they do not appear to have a supported way to register a visual file viewer/custom preview for non-text or structured files.
This makes it difficult for the community to build lightweight viewers for files such as:
.xlsxspreadsheets.csv/.tsvgrid previews.svgpreviews.pdfpreviews.drawio/.excalidrawdiagramsFor example, an
.xlsxextension may only need to open a spreadsheet as a simple read-only grid inside a tab. It does not need full Excel compatibility, formulas, charts, macros, or advanced editing. Today, the realistic workaround is to convert the file to.csv,.tsv, or Markdown and open that generated file, which works but does not feel integrated.Proposed solution
Introduce a small, safe Custom Preview API for extensions.
The first version could be intentionally limited to read-only previews. Extensions would be able to declare that they handle certain file extensions or glob patterns, and return a structured preview model that Zed renders using native UI components.
Conceptually:
The response could initially support a small set of safe preview types, for example:
For the spreadsheet case, a
TableModelwould be enough for a useful MVP:Why not start with full WebView/custom editor support?
This is related to #21208, but the goal here is narrower.
A full WebView/custom editor API would be powerful, but it also introduces larger questions around security, performance, theming, keyboard handling, extension lifecycle, and consistency with Zed's UI.
A native read-only preview API would provide a smaller stepping stone that enables many practical use cases without immediately exposing arbitrary HTML/JS or a fully interactive editor surface.
Example use case: XLSX viewer
An extension could register itself for
.xlsxfiles and render a simple grid preview:data.xlsxin Zed..xlsx.This would already be useful for projects that keep small spreadsheets, exported reports, test fixtures, translation tables, or data files in the repository.
Possible MVP scope
A first implementation could avoid editing entirely:
Markdown,PlainText, and/orTablepreview responsesFuture versions could consider:
Alternatives considered
Current workarounds include:
.xlsxto.csv,.tsv, or Markdown and opening the generated fileThese workarounds either feel less integrated or do not scale well across many file formats. A small extension-based preview API would allow the community to implement file viewers without requiring Zed core to own every format-specific viewer.
Additional context
This proposal is intentionally scoped as a discussion starter. The main goal is to explore whether Zed would accept a smaller native preview API before considering a larger custom editor or WebView API.
All reactions