Preview
Preview is ryOS's lightweight document viewer. It opens images, PDFs, HTML, Markdown, and structured text from Finder, Desktop aliases, drag and drop, or imported device files, then keeps the current document tied to the window so restored sessions reopen the same file.
Overview
Preview is the default read-only target for most inspectable file types in the virtual file system. Finder and open command file associations route images, PDFs, HTML, JSON, CSV, XML, and generic documents to Preview, while editable text and Markdown can still be handed off to TextEdit through Open With.
The app focuses on safe inspection and quick handoff. Images render from object URLs with zoom and Fit to Window controls, PDFs render in an iframe, HTML opens in a sandboxed iframe with scripts disabled, Markdown renders through Streamdown with raw HTML skipped, and text-like formats display in a monospaced preformatted view. Save As creates a new virtual-file-system copy, while Export downloads the current content back to the host device.
Features
- Multi-format viewing: Supports PNG, JPEG, GIF, WebP, BMP, SVG, PDF, HTML, TXT, Markdown, JSON, CSV, and XML.
- Image scaling: View images at actual size, zoom in/out, or keep Fit to Window enabled for large images.
- Safe document rendering: Sandboxes HTML and skips embedded HTML in Markdown previews.
- Finder integration: Acts as the default app for previewable files and exposes compatible Open With targets.
- Virtual file workflow: Imports device files into
/Imagesor/Documents, saves copies, emits file-save events, and exports blobs back to the device. - Window restoration: Persists only the current document path so multi-window sessions restore without serializing file contents.
User Guide
Getting Started
Double-click a supported file in Finder or use a Desktop alias to open it in Preview. If Preview starts empty, click the empty state or choose File > Import from Device... to pick a local file and copy it into the ryOS file system. You can also drag a supported host file onto an open Preview window.
Key Actions
- Open from ryOS:
File > Openopens Finder at the root so you can choose a virtual file.
- Open with another app:
File > Open Withsends images to Paint, text/Markdown to TextEdit, and HTML to Applet Viewer where supported. - Save a copy:
File > Save As...writes the current content into/Imagesfor images or/Documentsfor other formats. - Export:
File > Export...downloads the current previewed content to the host device.
Tips & Shortcuts
- Use
View > Actual Sizeto disable Fit to Window before inspecting image details.
- JSON files are pretty-printed when they contain valid JSON and shown unchanged otherwise.
- Unsupported formats show an inline error instead of attempting to mutate or import the file.
Technical Details
Window Configuration
- Default Size: 760 x 560px
- Minimum Size: 420 x 320px
Component Architecture
The app consists of two component files:
src/apps/preview/components/PreviewAppComponent.tsx: Renders the shell, empty/loading/error states, iframes, image view, text view, Save As dialog, and Help/About dialogs.
src/apps/preview/components/PreviewMenuBar.tsx: Defines File and View menu actions, Open With targets, zoom controls, and Preview Help/About labels.
Hooks & Utilities
src/apps/preview/hooks/usePreviewLogic.ts: Owns file loading, native-file import/export, Save As writes, object URL lifecycle, Open With handoff, help/about state, and per-window initial-data updates.
src/utils/fileAssociations.ts: Classifies previewable file kinds, accepted import extensions, default app associations, and Open With options.
Preview keeps view state local to the hook and persists only a document path through updateInstanceInitialData. getRestorablePreviewInitialData() filters that data during app-store restoration so windows reopen by path without storing blob or string content in persisted app state.
Related Apps
- Finder: Browses files and launches Preview for supported virtual documents.
- TextEdit: Edits text and Markdown files that Preview can inspect.
- Paint: Edits raster images after opening them from Preview's Open With menu.
- Applet Store: Runs HTML documents as applets when Preview's sandboxed read-only view is not enough.