From df863386a4675287f76683d1774b1130295c2cff Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 11:35:12 +0000 Subject: [PATCH 01/18] docs: design spec for closable right slot and file preview pane Scopes a preview mode for the right workspace slot: images, text, Markdown and code read through bounded main-process IPC, follow-selection, and disabled cross-pane ops when the peer is not a listing. --- .../specs/2026-11-30-preview-pane-design.md | 315 ++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100644 docs/superpowers/specs/2026-11-30-preview-pane-design.md diff --git a/docs/superpowers/specs/2026-11-30-preview-pane-design.md b/docs/superpowers/specs/2026-11-30-preview-pane-design.md new file mode 100644 index 0000000..627adcb --- /dev/null +++ b/docs/superpowers/specs/2026-11-30-preview-pane-design.md @@ -0,0 +1,315 @@ +# Design spec — Closable right slot and file preview pane + +- **Date:** 2026-11-30 +- **Status:** Draft for review +- **Scope:** ZeroG FileMan v0.4 slice +- **Related:** ADR-0004 (F5/F6 to other pane), ADR-0006 (to be written with this slice), SPEC M1–M10, ROADMAP P1.4 / P3.1 + +## 1. Problem + +The workspace is a fixed two-slot grid. Both slots must be directory listings, so the +second pane is wasted when the user only wants to look at a file that the first pane +lists. Users should be able to: + +1. close the right slot so the left listing fills the window; +2. reopen the right slot, either as a listing or as a preview of the selected file; +3. see images, plain text, Markdown, and source code previewed in the right slot, + following the selection in the left listing. + +## 2. Decisions (agreed in brainstorm 2026-11-30) + +| # | Decision | +|---|----------| +| D1 | Two content slots. The state model allows either slot to host a listing or a preview, but the v1 UI exposes preview and close on the **right** slot only; the left slot is always a listing. | +| D2 | Preview **follows the selection** in the left listing, debounced. It follows while the right slot is in preview mode; switching the slot to Directory or Closed stops following (no separate follow toggle in v1). The toolbar and context menu also open a preview explicitly. | +| D3 | v1 preview types: **images, plain text, Markdown (sanitized), source code** — read-only. Everything else shows an unsupported card with Open. | +| D4 | When the opposing pane is not a listing (preview or closed), **F5/F6, Copy →, Move → and cross-pane drops are disabled** with an explicit status hint. | +| D5 | Approach B: `FilePane` stays listing-only; a new `PreviewPane` component owns preview rendering. The right slot's mode lives in workspace layout state. | + +Non-goals for v1: editing/saving, PDF/audio/video/HTML *rendering*, SVG preview, tabs, +syntax highlighting, file watching, closing the left pane, UTF-16/legacy encodings. + +## 3. State model + +### 3.1 Workspace layout (`src/shared/pane-layout.ts`) + +```ts +export type RightSlot = 'browse' | 'preview' | 'closed'; + +export type WorkspaceLayoutState = { + layout: WorkspaceLayout; // 'split-v' | 'split-h' + maximized: PaneSide | null; + ratio: number; + rightSlot: RightSlot; // new; default 'browse' +}; +``` + +Rules: + +- `parseWorkspaceLayoutState` defaults `rightSlot` to `'browse'` for older stored + values and rejects unknown strings the same way it rejects bad `layout` values. +- Invariant: `rightSlot === 'closed'` implies `maximized === null`. Parsing and every + transition enforce it; closing the right slot clears `maximized`. +- `workspaceGridTemplate` returns a single `1fr / 1fr` cell when `rightSlot === 'closed'` + (the gutter element is not rendered). `maximized` behaviour is unchanged otherwise. +- `maximized: 'right'` is only reachable while `rightSlot !== 'closed'`. + +### 3.2 App state (`src/renderer/main.tsx`) + +- Existing `left: PaneState | null` and `right: PaneState | null` stay **loaded while the + right slot is closed**, preserving the right listing's path and history. Closing only + changes `workspaceLayout.rightSlot`. +- New `previewTarget: PreviewTarget | null`: + +```ts +export type PreviewTarget = { + path: string; + name: string; + size: number; + modified?: string; +}; +``` + +- `active: 'left' | 'right'` is unchanged. A preview-active right slot registers no + `PaneCommands`, so listing commands become unavailable while it is active. Closing the + right slot while it is active sets `active = 'left'`. + +### 3.3 Persistence + +- `zerogfileman.workspace-layout` gains `rightSlot` (existing helpers in + `src/renderer/layout-prefs.ts`). +- New key `zerogfileman.preview-path` stores the last previewed absolute path. + On startup, if `rightSlot === 'preview'` and a path is stored, the renderer calls + `previewFile(path)`; a missing file yields the unsupported/missing card, and the + header metadata comes from the preview result. + +## 4. Classification and reads + +### 4.1 Shared classifier (`src/shared/preview.ts`, new) + +```ts +export type PreviewKind = 'image' | 'text' | 'markdown' | 'code' | 'unsupported'; + +export function previewKindFor( + name: string, + size: number, + kind: 'file' | 'directory' | 'symlink' +): PreviewKind; +``` + +| Kind | Rules | Notes | +|------|-------|-------| +| image | extension in `jpg jpeg png gif webp bmp ico` | Same allowlist as listing thumbnails; SVG excluded | +| markdown | `md markdown` | | +| text | `txt log csv`; names `LICENSE LICENCE README CHANGELOG COPYING NOTICE .gitignore .editorconfig` | | +| code | `ts tsx js jsx mjs cjs json jsonc css scss sass less html htm xml yml yaml toml ini cfg conf py rb php go rs java kt c h cpp hpp cs swift sql sh bash zsh ps1 bat cmd vue svelte graphql gql`; names `Dockerfile Makefile` | HTML/XML are shown as **source text**, never rendered | +| unsupported | unknown extensions and any non-`file` kind | | + +The classifier is extension/name-only and does **not** apply byte caps; caps are enforced +once, in the main process (§4.2), so the renderer cannot widen them. + +Rules: + +- Extension matching is case-insensitive (reuse `fileExtension` from + `src/shared/listing-view.ts`). +- An empty file (`size === 0`) with a text/markdown/code name is previewable and shows + an empty body, not an error. + +Caps (exported constants): + +```ts +PREVIEW_IMAGE_MAX_BYTES = 32 * 1024 * 1024; +PREVIEW_IMAGE_MAX_EDGE = 4096; +PREVIEW_TEXT_MAX_BYTES = 1024 * 1024; // 1 MiB, truncated beyond +``` + +### 4.2 Main-process read (`src/main/preview-fs.ts`, new) + +One handler, one round trip: main classifies, validates, and reads. + +```ts +export type PreviewResult = + | { kind: 'image'; path: string; name: string; size: number; modified?: string; + dataUrl: string; width: number; height: number } + | { kind: 'text' | 'markdown' | 'code'; path: string; name: string; size: number; + modified?: string; text: string; truncated: boolean } + | { kind: 'unsupported'; path: string; name: string; size: number; modified?: string; + reason: 'folder' | 'symlink' | 'not-found' | 'too-large' | 'binary' | 'decode-failed' | 'unsupported-type' }; + +export function readPreview(path: unknown): Promise; +``` + +Behaviour: + +1. `resolveLocalPath(path)` — absolute-path rule applies; invalid input **rejects**. +2. `lstat`; `ENOENT` → `unsupported/not-found`; directory → `unsupported/folder`; + symlink → `unsupported/symlink` (no follow-through in v1). +3. Classify with `previewKindFor(name, size, 'file')`. +4. Image → decode through the shared Electron image helper at + `PREVIEW_IMAGE_MAX_EDGE`. Listings keep their existing 512 px cap. Decode failure → + `unsupported/decode-failed`; over cap → `unsupported/too-large`. +5. Text-like → read at most `PREVIEW_TEXT_MAX_BYTES` + 1 byte to detect truncation. + If the first 8 KiB contains a NUL byte → `unsupported/binary`. Strip a UTF-8 BOM, + decode with `TextDecoder('utf-8')` (non-fatal replacement). Permission/IO errors + other than `ENOENT` reject with a readable message. +6. Unsupported type → `unsupported/unsupported-type`. + +`src/main/thumbnails.ts` gains an internal `decodeImage(target, edge): Promise` +shared by `readThumbnail` (existing 32–512 clamp) and `readPreview` (new clamp up to +`PREVIEW_IMAGE_MAX_EDGE`, minimum 64). Listing behaviour and its tests are unchanged. + +### 4.3 IPC surface + +| Layer | Addition | +|-------|----------| +| `main.ts` | `handle('fs:preview', (_e, path) => readPreview(path))` behind the existing origin check | +| `preload.cjs` | `previewFile: (path) => ipcRenderer.invoke('fs:preview', path)` | +| `types.ts` | `previewFile(path: string): Promise` on `FileManApi`; re-export `PreviewResult`, `PreviewKind`, `RightSlot` types | +| `main.ts` | `handle('shell:openUrl', ...)` — `shell.openExternal` only for `http:`/`https:` URLs parsed with `new URL` | + +No new protocol, no `file://` in the renderer, no renderer filesystem access. + +## 5. Renderer — `src/renderer/preview-pane.tsx` (new) + +Props: `{ target: PreviewTarget | null; onOpen(path): void; onBrowseFolder(path): void; onClose(): void; onActivate(): void; active: boolean }`. + +### 5.1 Layout + +- Rendered by `App` in the right grid cell when `rightSlot !== 'closed'`. When + `rightSlot === 'preview'` it replaces `FilePane` for the right slot. +- Header: file name (truncated, `title` full path), meta line + (`kind label · size · modified`), actions **Open**, **Browse this folder**, **Close ×**. +- Body states: empty (`Select a file to preview`), loading, error (message + Retry), + unsupported card (reason text + Open), image, text/code, Markdown. +- Clicking anywhere in the pane calls `onActivate()`; the cyan active-pane glow follows + the existing `.pane` styling. + +### 5.2 Rendering + +- **Image:** `` with `object-fit: contain`, max 100% of the body; `alt` = file name. +- **Text / code:** `
` in JetBrains Mono, horizontal scroll, no wrapping. A banner
+  reads `Showing the first 1 MiB of ` when `truncated`.
+- **Markdown:** `react-markdown` + `remark-gfm`, raw HTML **not** rendered
+  (react-markdown's default; no `rehype-raw`, no `dangerouslySetInnerHTML`).
+  Links: absolute `http(s)` links call `shell:openUrl`; any other href renders inert.
+  Remote images stay blocked by CSP (`img-src 'self' data:`), so they surface as alt
+  text — an intentional privacy default.
+- **Unsupported:** icon, name, size, a one-line reason
+  (folder / symbolic link / missing / too large / binary / cannot decode / no preview),
+  and the Open button.
+
+### 5.3 Follow-selection
+
+- Effect in `App`: when `workspaceLayout.rightSlot === 'preview'`, the **left** pane is
+  the only listing; its single-selection (or the primary of a multi-selection) drives the
+  preview. On change, set a 180 ms debounce timer, then `previewTarget`.
+- The pane requests `previewFile` whenever `target.path` changes. Each request carries a
+  sequence number; stale responses are dropped. Header metadata comes from the result.
+- Directories and unsupported files still become the target so the user sees *why*
+  nothing is previewed. Multi-select previews the primary (last-selected) entry.
+- Re-selecting a file re-reads it. There is no filesystem watcher in v1.
+
+## 6. Slot lifecycle and toolbar
+
+- Right pane header gains a mode chip (`Directory` / `Preview`) and `×` close.
+  Switching to Preview previews the current left selection (or shows the empty state).
+- When the right slot is closed the toolbar shows:
+  - **Split** — reopen as a listing (restores the remembered right path),
+  - **Preview** — reopen as preview of the active left selection.
+- Layout toolbar (Side by side / Stacked / Maximize) is unchanged; Maximize-right is
+  hidden while the slot is closed. Closing the right slot clears `maximized` and moves
+  `active` to `left` if it was there.
+- On startup a closed slot stays closed; a preview slot restores its last path.
+
+## 7. Guards
+
+- New pure helper (shared, tested):
+
+```ts
+export function otherPaneIsListing(
+  active: 'left' | 'right',
+  rightSlot: RightSlot
+): boolean; // active left → rightSlot === 'browse'; active right is always a listing
+```
+
+- F5 / F6 / Copy → / Move → / context-menu equivalents: when `otherPaneIsListing` is
+  false, the buttons render disabled and any attempted shortcut logs
+  `Target pane is not a listing.` to the transcript bus. No silent retargeting.
+- Cross-pane drag targets exist only inside the opposing `FilePane`; a preview or closed
+  slot offers none, so drops onto the preview pane are ignored (no handler).
+- Paste inside the same listing, in-pane drag, and all local CRUD are unaffected.
+- Tab still cycles left ↔ right; when the preview slot is active, listing shortcuts
+  (F2/F5/F6/F7/Delete) are no-ops because no `PaneCommands` are registered.
+- Voice jewels render only inside `FilePane`; the preview pane has none in v1.
+
+## 8. Security and trust boundary
+
+- Renderer stays sandboxed with `contextIsolation`, no Node. Every new capability is an
+  IPC channel behind the existing `isAppUrl` sender check.
+- Paths: both file channels call `resolveLocalPath` in main (absolute only, NUL and
+  length checks). `shell:openUrl` takes no path — it parses a URL and rejects anything
+  that is not `http:`/`https:`.
+- Reads are bounded (32 MiB image / 1 MiB text) and regular-file-only; symlinks and
+  directories are refused rather than followed.
+- Markdown cannot execute script (no raw HTML, no inline HTML events); HTML files are
+  displayed as source text. Remote resources are blocked by CSP.
+- `shell:openUrl` accepts only `http:`/`https:` after `new URL()` parsing, mirroring the
+  `updates:openRelease` pattern.
+
+## 9. Verification
+
+### Unit (vitest)
+
+- `tests/preview.test.ts`: `previewKindFor` — every allowlisted extension (mixed case),
+  known names, unknown extension, directory/symlink, 0-byte text file, classification
+  independent of byte size, exported constants.
+- `tests/preview-fs.test.ts` (temp dirs, same style as `tests/local-fs.test.ts`):
+  UTF-8 text round-trip, BOM strip, truncation at 1 MiB with banner flag, NUL-byte
+  binary refusal, `ENOENT` → `not-found`, directory → `folder`, relative path rejects.
+  Image decode is covered with a mocked `nativeImage` (empty image → `decode-failed`,
+  oversized file → `too-large`).
+- `tests/pane-layout.test.ts` (extend): `rightSlot` default/normalisation, closed
+  clears `maximized`, collapsed grid template, changes to `setLayout`/`toggleMaximize`.
+- Guard helper tests: all four active/slot combinations.
+
+### Hidden-Electron smoke (same harness style as the drag-drop slice)
+
+1. Open preview from the toolbar with a file selected.
+2. Click an image on the left → image renders in the right slot.
+3. Click `.txt`, `.md`, `.ts` → text, rendered Markdown, mono code.
+4. Select a `.pdf` → unsupported card with Open.
+5. Select a 1 MiB+ text file → truncation banner.
+6. Close the right slot → left fills the window; Split and Preview reappear.
+7. Reopen as listing → remembered path returns.
+8. F5 with preview slot active as target → disabled + transcript hint.
+9. Relaunch with preview slot → last file restored.
+10. Delete the previewed file, re-select → missing card.
+11. Markdown with a remote image → alt text, no network image.
+12. `.html` → source text, not rendered.
+
+Gate: `npm run typecheck`, `npm test`, `npm run build`, then manual dual-pane + jewel
+smoke (V3), owner adversarial pass (V4).
+
+## 10. Files
+
+New: `src/shared/preview.ts`, `src/main/preview-fs.ts`, `src/renderer/preview-pane.tsx`,
+`tests/preview.test.ts`, `tests/preview-fs.test.ts`,
+`docs/adr/0006-right-slot-modes-and-preview.md`.
+
+Changed: `src/shared/pane-layout.ts`, `src/shared/types.ts`, `src/main/main.ts`,
+`src/main/preload.cjs`, `src/main/thumbnails.ts`, `src/renderer/main.tsx`,
+`src/renderer/layout-prefs.ts`, `src/renderer/styles.css`, `tests/pane-layout.test.ts`,
+`SPEC.md`, `ROADMAP.md`, `PROGRESS.md`.
+
+Dependencies added: `react-markdown`, `remark-gfm` (renderer only; no transitive Node
+access). Nothing added to main.
+
+## 11. Alternatives considered
+
+- **Listing pane grows a mode (A):** fewer types, but pushes preview responsibilities
+  into `FilePane` and grows `main.tsx` further; rejected.
+- **Tabbed right slot (C):** more UI machinery than v1 needs; noted as the natural place
+  to add a Terminal tab later; rejected for now.
+- **Custom protocol for images/media:** unnecessary for the v1 type set; data-URL reads
+  reuse the proven thumbnail path. Revisit with PDF/video.
+- **Retarget F5/F6 into the previewed file's folder:** invisible destination; rejected.

From a1ebb716f2c3c5423361785ae2b888b597a8ad17 Mon Sep 17 00:00:00 2001
From: Stephen Phillips 
Date: Mon, 30 Nov 2026 11:55:59 +0000
Subject: [PATCH 02/18] docs: implementation plan for closable right slot and
 preview

---
 .../plans/2026-11-30-preview-pane.md          | 2055 +++++++++++++++++
 1 file changed, 2055 insertions(+)
 create mode 100644 docs/superpowers/plans/2026-11-30-preview-pane.md

diff --git a/docs/superpowers/plans/2026-11-30-preview-pane.md b/docs/superpowers/plans/2026-11-30-preview-pane.md
new file mode 100644
index 0000000..a778dad
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-30-preview-pane.md
@@ -0,0 +1,2055 @@
+# Closable Right Slot and File Preview Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Let the user close and reopen the right workspace slot, and fill it with a read-only preview of the selected file (images, text, Markdown, source code).
+
+**Architecture:** The right slot becomes `browse | preview | closed` in the persisted workspace layout; `FilePane` stays listing-only and a new `PreviewPane` renders previews. All reads go through one bounded main-process channel (`fs:preview`) that classifies, validates and caps them, returning a discriminated payload. Cross-pane operations are disabled whenever the peer is not a listing.
+
+**Tech Stack:** Electron 43, React 19, TypeScript (NodeNext, strict), Vite, Vitest, react-markdown + remark-gfm (renderer only).
+
+**Spec:** `docs/superpowers/specs/2026-11-30-preview-pane-design.md`
+
+## Global Constraints
+
+- TypeScript `strict` with `module: NodeNext` — every relative import ends in `.js` (`.tsx` files import `./thing.js`).
+- Renderer never imports `node:fs`; all file access goes through `window.fileman` IPC.
+- Every path passed to main goes through `resolveLocalPath` (absolute only).
+- Caps, enforced only in main: image `32 * 1024 * 1024` bytes, `4096` px decode edge; text `1024 * 1024` bytes (truncate, never reject).
+- Preview is read-only; HTML/XML render as source text, never as markup.
+- No new main-process dependencies; renderer gains only `react-markdown` and `remark-gfm`.
+- Verification gate per task: `npm run typecheck` and `npx vitest run `; full gate in Task 7: `npm run ci` (`typecheck && test && build`).
+- Commit style: conventional commits, one commit per task.
+
+---
+
+### Task 1: Right-slot layout state and preview-path persistence
+
+**Files:**
+- Modify: `src/shared/pane-layout.ts`
+- Modify: `src/renderer/layout-prefs.ts`
+- Test: `tests/pane-layout.test.ts` (full replacement below)
+
+**Interfaces:**
+- Consumes: nothing new.
+- Produces:
+  - `type RightSlot = 'browse' | 'preview' | 'closed'`
+  - `WorkspaceLayoutState.rightSlot: RightSlot` (required)
+  - `isRightSlot(value: unknown): value is RightSlot`
+  - `setRightSlot(state: WorkspaceLayoutState, slot: RightSlot): WorkspaceLayoutState`
+  - `otherPaneIsListing(active: PaneSide, rightSlot: RightSlot): boolean`
+  - `loadStoredPreviewPath(): string | null`, `storeStoredPreviewPath(path: string | null): void`
+
+- [ ] **Step 1: Replace the layout test file with the failing expectations**
+
+Replace `tests/pane-layout.test.ts` entirely:
+
+```ts
+import { describe, expect, it } from 'vitest';
+import {
+  clampSplitRatio,
+  otherPaneIsListing,
+  parseWorkspaceLayoutState,
+  setLayout,
+  setRightSlot,
+  toggleMaximize,
+  workspaceGridTemplate
+} from '../src/shared/pane-layout.js';
+
+describe('pane-layout', () => {
+  it('clamps ratios and parses defaults', () => {
+    expect(clampSplitRatio(0.05)).toBe(0.2);
+    expect(clampSplitRatio(0.95)).toBe(0.8);
+    expect(parseWorkspaceLayoutState(null)).toEqual({
+      layout: 'split-v',
+      maximized: null,
+      ratio: 0.5,
+      rightSlot: 'browse'
+    });
+  });
+
+  it('normalises the right-slot value and clears maximize when closed', () => {
+    expect(parseWorkspaceLayoutState({ rightSlot: 'preview' }).rightSlot).toBe('preview');
+    expect(parseWorkspaceLayoutState({ rightSlot: 'nonsense' }).rightSlot).toBe('browse');
+    expect(parseWorkspaceLayoutState({ rightSlot: 'closed', maximized: 'right' })).toEqual({
+      layout: 'split-v',
+      maximized: null,
+      ratio: 0.5,
+      rightSlot: 'closed'
+    });
+  });
+
+  it('builds grid templates for vertical and horizontal splits', () => {
+    expect(
+      workspaceGridTemplate({ layout: 'split-v', maximized: null, ratio: 0.4, rightSlot: 'browse' })
+    ).toEqual({
+      columns: '40.00% 6px 60.00%',
+      rows: '1fr'
+    });
+    expect(
+      workspaceGridTemplate({ layout: 'split-h', maximized: null, ratio: 0.5, rightSlot: 'browse' })
+    ).toEqual({
+      columns: '1fr',
+      rows: '50.00% 6px 50.00%'
+    });
+    expect(
+      workspaceGridTemplate({ layout: 'split-v', maximized: 'left', ratio: 0.5, rightSlot: 'browse' })
+    ).toEqual({
+      columns: '1fr',
+      rows: '1fr'
+    });
+  });
+
+  it('collapses to a single cell when the right slot is closed', () => {
+    expect(
+      workspaceGridTemplate({ layout: 'split-v', maximized: null, ratio: 0.4, rightSlot: 'closed' })
+    ).toEqual({ columns: '1fr', rows: '1fr' });
+    expect(
+      workspaceGridTemplate({ layout: 'split-h', maximized: null, ratio: 0.4, rightSlot: 'closed' })
+    ).toEqual({ columns: '1fr', rows: '1fr' });
+  });
+
+  it('toggles maximize and clears it when changing layout', () => {
+    const base = { layout: 'split-v' as const, maximized: null, ratio: 0.5, rightSlot: 'browse' as const };
+    const maxed = toggleMaximize(base, 'right');
+    expect(maxed.maximized).toBe('right');
+    expect(toggleMaximize(maxed, 'right').maximized).toBeNull();
+    expect(setLayout(maxed, 'split-h')).toEqual({
+      layout: 'split-h',
+      maximized: null,
+      ratio: 0.5,
+      rightSlot: 'browse'
+    });
+  });
+
+  it('closing the right slot clears maximize and ignores later toggles', () => {
+    const maxed = { layout: 'split-v' as const, maximized: 'right' as const, ratio: 0.5, rightSlot: 'browse' as const };
+    const closed = setRightSlot(maxed, 'closed');
+    expect(closed.rightSlot).toBe('closed');
+    expect(closed.maximized).toBeNull();
+    expect(toggleMaximize(closed, 'right').maximized).toBeNull();
+  });
+
+  it('knows when the opposing pane is a listing', () => {
+    expect(otherPaneIsListing('left', 'browse')).toBe(true);
+    expect(otherPaneIsListing('left', 'preview')).toBe(false);
+    expect(otherPaneIsListing('left', 'closed')).toBe(false);
+    expect(otherPaneIsListing('right', 'browse')).toBe(true);
+    expect(otherPaneIsListing('right', 'preview')).toBe(true);
+  });
+});
+```
+
+- [ ] **Step 2: Run the test to verify it fails**
+
+Run: `npx vitest run tests/pane-layout.test.ts`
+Expected: FAIL — `otherPaneIsListing` and `setRightSlot` are not exported; `parseWorkspaceLayoutState` results lack `rightSlot`.
+
+- [ ] **Step 3: Implement the layout changes**
+
+In `src/shared/pane-layout.ts`, replace the type block and parse/grid/transition functions with:
+
+```ts
+export type WorkspaceLayout = 'split-v' | 'split-h';
+
+export type PaneSide = 'left' | 'right';
+
+/** What the right workspace slot shows. */
+export type RightSlot = 'browse' | 'preview' | 'closed';
+
+export type WorkspaceLayoutState = {
+  layout: WorkspaceLayout;
+  /** Which pane fills the workspace, if any. */
+  maximized: PaneSide | null;
+  /** Fraction for the first pane along the split axis (0.2–0.8). */
+  ratio: number;
+  rightSlot: RightSlot;
+};
+
+export const DEFAULT_SPLIT_RATIO = 0.5;
+export const SPLIT_RATIO_MIN = 0.2;
+export const SPLIT_RATIO_MAX = 0.8;
+
+export const LAYOUT_LABELS: Record = {
+  'split-v': 'Side by side',
+  'split-h': 'Stacked'
+};
+
+export function isWorkspaceLayout(value: unknown): value is WorkspaceLayout {
+  return value === 'split-v' || value === 'split-h';
+}
+
+export function isPaneSide(value: unknown): value is PaneSide {
+  return value === 'left' || value === 'right';
+}
+
+export function isRightSlot(value: unknown): value is RightSlot {
+  return value === 'browse' || value === 'preview' || value === 'closed';
+}
+
+export function clampSplitRatio(value: number): number {
+  if (!Number.isFinite(value)) return DEFAULT_SPLIT_RATIO;
+  return Math.min(SPLIT_RATIO_MAX, Math.max(SPLIT_RATIO_MIN, value));
+}
+
+export function parseWorkspaceLayoutState(raw: unknown): WorkspaceLayoutState {
+  if (!raw || typeof raw !== 'object') {
+    return { layout: 'split-v', maximized: null, ratio: DEFAULT_SPLIT_RATIO, rightSlot: 'browse' };
+  }
+  const source = raw as Partial;
+  const rightSlot = isRightSlot(source.rightSlot) ? source.rightSlot : 'browse';
+  return {
+    layout: isWorkspaceLayout(source.layout) ? source.layout : 'split-v',
+    maximized:
+      rightSlot === 'closed' ? null : isPaneSide(source.maximized) ? source.maximized : null,
+    ratio: clampSplitRatio(typeof source.ratio === 'number' ? source.ratio : DEFAULT_SPLIT_RATIO),
+    rightSlot
+  };
+}
+
+/** CSS grid template for the workspace (pane | gutter | pane), or single when maximized/closed. */
+export function workspaceGridTemplate(state: WorkspaceLayoutState): {
+  columns: string;
+  rows: string;
+} {
+  if (state.maximized || state.rightSlot === 'closed') {
+    return { columns: '1fr', rows: '1fr' };
+  }
+  const a = `${(state.ratio * 100).toFixed(2)}%`;
+  const b = `${((1 - state.ratio) * 100).toFixed(2)}%`;
+  if (state.layout === 'split-h') {
+    return { columns: '1fr', rows: `${a} 6px ${b}` };
+  }
+  return { columns: `${a} 6px ${b}`, rows: '1fr' };
+}
+
+export function toggleMaximize(
+  state: WorkspaceLayoutState,
+  side: PaneSide
+): WorkspaceLayoutState {
+  if (state.rightSlot === 'closed') return { ...state, maximized: null };
+  return {
+    ...state,
+    maximized: state.maximized === side ? null : side
+  };
+}
+
+export function setLayout(
+  state: WorkspaceLayoutState,
+  layout: WorkspaceLayout
+): WorkspaceLayoutState {
+  return { ...state, layout, maximized: null };
+}
+
+export function setRightSlot(
+  state: WorkspaceLayoutState,
+  slot: RightSlot
+): WorkspaceLayoutState {
+  return { ...state, rightSlot: slot, maximized: slot === 'closed' ? null : state.maximized };
+}
+
+/** May the active pane copy/move into the other pane? Only when the other is a listing. */
+export function otherPaneIsListing(active: PaneSide, rightSlot: RightSlot): boolean {
+  return active === 'left' ? rightSlot === 'browse' : true;
+}
+```
+
+- [ ] **Step 4: Add preview-path persistence to `src/renderer/layout-prefs.ts`**
+
+Append after the existing exports:
+
+```ts
+const PREVIEW_PATH_KEY = 'zerogfileman.preview-path';
+
+export function loadStoredPreviewPath(): string | null {
+  try {
+    const raw = localStorage.getItem(PREVIEW_PATH_KEY);
+    return raw && raw.length <= 4096 ? raw : null;
+  } catch {
+    return null;
+  }
+}
+
+export function storeStoredPreviewPath(path: string | null): void {
+  try {
+    if (path) localStorage.setItem(PREVIEW_PATH_KEY, path);
+    else localStorage.removeItem(PREVIEW_PATH_KEY);
+  } catch {
+    /* ignore */
+  }
+}
+```
+
+- [ ] **Step 5: Run the tests and typecheck**
+
+Run: `npx vitest run tests/pane-layout.test.ts && npm run typecheck`
+Expected: PASS. If typecheck flags other `WorkspaceLayoutState` literals, they will be only inside `tests/` (not compiled) — none should exist in `src/`.
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add src/shared/pane-layout.ts src/renderer/layout-prefs.ts tests/pane-layout.test.ts
+git commit -m "feat(layout): add right-slot modes and collapsed grid"
+```
+
+---
+
+### Task 2: Preview classifier and shared result types
+
+**Files:**
+- Create: `src/shared/preview.ts`
+- Test: `tests/preview.test.ts`
+- Modify: `docs/superpowers/specs/2026-11-30-preview-pane-design.md` (§4.1 signature)
+
+**Interfaces:**
+- Consumes: `fileExtension` from `src/shared/listing-view.ts`.
+- Produces:
+  - `type PreviewKind = 'image' | 'text' | 'markdown' | 'code' | 'unsupported'`
+  - `type PreviewReason = 'folder' | 'symlink' | 'not-found' | 'too-large' | 'binary' | 'decode-failed' | 'unsupported-type'`
+  - `type PreviewTarget = { path: string; name: string; size: number; modified?: string }`
+  - `type PreviewResult` (discriminated union used by IPC, see Task 4)
+  - `previewKindFor(name: string, kind: 'file' | 'directory' | 'symlink'): PreviewKind`
+  - `PREVIEW_IMAGE_MAX_BYTES`, `PREVIEW_IMAGE_MAX_EDGE`, `PREVIEW_TEXT_MAX_BYTES`
+
+- [ ] **Step 1: Write the failing test**
+
+Create `tests/preview.test.ts`:
+
+```ts
+import { describe, expect, it } from 'vitest';
+import {
+  PREVIEW_IMAGE_MAX_BYTES,
+  PREVIEW_IMAGE_MAX_EDGE,
+  PREVIEW_TEXT_MAX_BYTES,
+  previewKindFor
+} from '../src/shared/preview.js';
+
+describe('previewKindFor', () => {
+  it('classifies every allowed extension, case-insensitively', () => {
+    for (const name of ['a.jpg', 'b.JPEG', 'c.Png', 'd.gif', 'e.webp', 'f.bmp', 'g.ico']) {
+      expect(previewKindFor(name, 'file')).toBe('image');
+    }
+    for (const name of ['notes.md', 'GUIDE.Markdown']) {
+      expect(previewKindFor(name, 'file')).toBe('markdown');
+    }
+    for (const name of ['a.txt', 'b.log', 'c.CSV']) {
+      expect(previewKindFor(name, 'file')).toBe('text');
+    }
+    for (const name of ['a.ts', 'b.TSX', 'c json.json', 'styles.css', 'main.py', 'run.SH', 'x.yaml', 'qa.htm']) {
+      expect(previewKindFor(name, 'file')).toBe('code');
+    }
+  });
+
+  it('recognises well-known extension-less names', () => {
+    for (const name of ['LICENSE', 'readme', 'CHANGELOG', '.gitignore', '.editorconfig', 'NOTICE']) {
+      expect(previewKindFor(name, 'file')).toBe('text');
+    }
+    for (const name of ['Dockerfile', 'Makefile']) {
+      expect(previewKindFor(name, 'file')).toBe('code');
+    }
+  });
+
+  it('refuses unknown types and non-files', () => {
+    expect(previewKindFor('archive.zip', 'file')).toBe('unsupported');
+    expect(previewKindFor('drawing.svg', 'file')).toBe('unsupported');
+    expect(previewKindFor('photo.jpg', 'directory')).toBe('unsupported');
+    expect(previewKindFor('photo.jpg', 'symlink')).toBe('unsupported');
+  });
+
+  it('classifies by extension only, regardless of size', () => {
+    expect(previewKindFor('huge.png', 'file')).toBe('image');
+    expect(previewKindFor('empty.txt', 'file')).toBe('text');
+  });
+
+  it('exposes the byte and pixel caps', () => {
+    expect(PREVIEW_IMAGE_MAX_BYTES).toBe(32 * 1024 * 1024);
+    expect(PREVIEW_IMAGE_MAX_EDGE).toBe(4096);
+    expect(PREVIEW_TEXT_MAX_BYTES).toBe(1024 * 1024);
+  });
+});
+```
+
+- [ ] **Step 2: Run it to verify it fails**
+
+Run: `npx vitest run tests/preview.test.ts`
+Expected: FAIL — cannot resolve `../src/shared/preview.js`.
+
+- [ ] **Step 3: Create `src/shared/preview.ts`**
+
+```ts
+/** Read-only preview classification and the payload main returns for a pane. */
+
+import { fileExtension } from './listing-view.js';
+
+export type PreviewKind = 'image' | 'text' | 'markdown' | 'code' | 'unsupported';
+
+export type PreviewReason =
+  | 'folder'
+  | 'symlink'
+  | 'not-found'
+  | 'too-large'
+  | 'binary'
+  | 'decode-failed'
+  | 'unsupported-type';
+
+export type PreviewTarget = {
+  path: string;
+  name: string;
+  size: number;
+  modified?: string;
+};
+
+type PreviewBase = {
+  path: string;
+  name: string;
+  size: number;
+  modified?: string;
+};
+
+export type PreviewResult =
+  | (PreviewBase & { kind: 'image'; dataUrl: string; width: number; height: number })
+  | (PreviewBase & { kind: 'text' | 'markdown' | 'code'; text: string; truncated: boolean })
+  | (PreviewBase & { kind: 'unsupported'; reason: PreviewReason });
+
+/** Decode caps live in main; the classifier is extension-only. */
+export const PREVIEW_IMAGE_MAX_BYTES = 32 * 1024 * 1024;
+export const PREVIEW_IMAGE_MAX_EDGE = 4096;
+export const PREVIEW_TEXT_MAX_BYTES = 1024 * 1024;
+
+const IMAGE_EXTENSIONS = new Set(['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'ico']);
+const MARKDOWN_EXTENSIONS = new Set(['md', 'markdown']);
+const TEXT_EXTENSIONS = new Set(['txt', 'log', 'csv']);
+const CODE_EXTENSIONS = new Set([
+  'ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json', 'jsonc', 'css', 'scss', 'sass', 'less',
+  'html', 'htm', 'xml', 'yml', 'yaml', 'toml', 'ini', 'cfg', 'conf', 'py', 'rb', 'php',
+  'go', 'rs', 'java', 'kt', 'c', 'h', 'cpp', 'hpp', 'cs', 'swift', 'sql', 'sh', 'bash',
+  'zsh', 'ps1', 'bat', 'cmd', 'vue', 'svelte', 'graphql', 'gql'
+]);
+const TEXT_NAMES = new Set([
+  'license', 'licence', 'readme', 'changelog', 'copying', 'notice', '.gitignore',
+  '.editorconfig'
+]);
+const CODE_NAMES = new Set(['dockerfile', 'makefile']);
+
+export function previewKindFor(
+  name: string,
+  kind: 'file' | 'directory' | 'symlink'
+): PreviewKind {
+  if (kind !== 'file') return 'unsupported';
+  const base = (name.split(/[/\\]/).pop() ?? name).toLowerCase();
+  const ext = fileExtension(base);
+  if (IMAGE_EXTENSIONS.has(ext)) return 'image';
+  if (MARKDOWN_EXTENSIONS.has(ext)) return 'markdown';
+  if (TEXT_EXTENSIONS.has(ext)) return 'text';
+  if (CODE_EXTENSIONS.has(ext)) return 'code';
+  if (TEXT_NAMES.has(base)) return 'text';
+  if (CODE_NAMES.has(base)) return 'code';
+  return 'unsupported';
+}
+```
+
+- [ ] **Step 4: Run the test to verify it passes**
+
+Run: `npx vitest run tests/preview.test.ts`
+Expected: PASS (5 tests).
+
+- [ ] **Step 5: Bring the spec in line with the implemented signature**
+
+The spec used a `size` parameter that the implementation does not take (classification is extension-only). Make two edits in `docs/superpowers/specs/2026-11-30-preview-pane-design.md`.
+
+Replace the §4.1 signature block:
+
+```ts
+export function previewKindFor(
+  name: string,
+  size: number,
+  kind: 'file' | 'directory' | 'symlink'
+): PreviewKind;
+```
+
+with:
+
+```ts
+export function previewKindFor(
+  name: string,
+  kind: 'file' | 'directory' | 'symlink'
+): PreviewKind;
+```
+
+And in the read-path list (§4.2), change:
+
+```markdown
+3. Classify with `previewKindFor(name, size, 'file')`.
+```
+
+to:
+
+```markdown
+3. Classify with `previewKindFor(name, 'file')`.
+```
+
+Leave every other sentence as-is (the empty-file note at §4.1 still holds).
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add src/shared/preview.ts tests/preview.test.ts docs/superpowers/specs/2026-11-30-preview-pane-design.md
+git commit -m "feat(preview): file-type classifier and preview payload types"
+```
+
+---
+
+### Task 3: Bounded preview reader in main (text, images, unsupported)
+
+**Files:**
+- Modify: `src/main/thumbnails.ts` (extract `decodeImage`)
+- Create: `src/main/preview-fs.ts`
+- Test: `tests/preview-fs.test.ts`
+
+**Interfaces:**
+- Consumes: `resolveLocalPath` (`src/main/local-fs.ts`), `previewKindFor` + caps + `PreviewResult` (Task 2).
+- Produces:
+  - `type DecodedImage = { dataUrl: string; width: number; height: number }` (exported from `thumbnails.ts`)
+  - `decodeImage(target: string, edge: number): Promise`
+  - `type PreviewDeps = { decodeImage: (target: string, edge: number) => Promise }`
+  - `readPreview(path: unknown, deps?: PreviewDeps): Promise`
+
+- [ ] **Step 1: Write the failing test**
+
+Create `tests/preview-fs.test.ts`:
+
+```ts
+import { mkdtempSync, mkdirSync, rmSync, truncateSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { PREVIEW_IMAGE_MAX_BYTES, PREVIEW_TEXT_MAX_BYTES } from '../src/shared/preview.js';
+
+vi.mock('electron', () => ({
+  nativeImage: {
+    createFromPath: () => null,
+    createThumbnailFromPath: async () => null
+  }
+}));
+
+const { readPreview } = await import('../src/main/preview-fs.js');
+
+const fakeImage = async () => ({ dataUrl: 'data:image/png;base64,AA', width: 10, height: 10 });
+const noImage = async () => null;
+const deps = { decodeImage: fakeImage };
+
+let root: string;
+
+beforeEach(() => {
+  root = mkdtempSync(join(tmpdir(), 'zerog-preview-'));
+});
+afterEach(() => {
+  rmSync(root, { recursive: true, force: true });
+});
+
+describe('readPreview', () => {
+  it('returns UTF-8 text and strips a byte-order mark', async () => {
+    const file = join(root, 'note.md');
+    writeFileSync(file, '\uFEFF# Title\n\nBody');
+    const result = await readPreview(file, deps);
+    expect(result.kind).toBe('markdown');
+    if (result.kind !== 'markdown') throw new Error('unreachable');
+    expect(result.text).toBe('# Title\n\nBody');
+    expect(result.truncated).toBe(false);
+    expect(result.size).toBe(Buffer.byteLength('\uFEFF# Title\n\nBody'));
+  });
+
+  it('truncates text at the cap and reports it', async () => {
+    const file = join(root, 'big.txt');
+    writeFileSync(file, Buffer.alloc(PREVIEW_TEXT_MAX_BYTES + 10, 0x61));
+    const result = await readPreview(file, deps);
+    if (result.kind !== 'text') throw new Error('expected text');
+    expect(result.truncated).toBe(true);
+    expect(result.text.length).toBe(PREVIEW_TEXT_MAX_BYTES);
+  });
+
+  it('refuses binary content', async () => {
+    const file = join(root, 'blob.log');
+    writeFileSync(file, Buffer.from([0x41, 0x00, 0x42]));
+    const result = await readPreview(file, deps);
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'binary' });
+  });
+
+  it('reads source code without truncation', async () => {
+    const file = join(root, 'main.ts');
+    writeFileSync(file, 'export const answer = 42;\n');
+    const result = await readPreview(file, deps);
+    expect(result).toMatchObject({ kind: 'code', truncated: false });
+  });
+
+  it('reports a missing file instead of rejecting', async () => {
+    const result = await readPreview(join(root, 'gone.txt'), deps);
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'not-found' });
+  });
+
+  it('reports folders', async () => {
+    const dir = join(root, 'folder');
+    mkdirSync(dir);
+    const result = await readPreview(dir, deps);
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'folder' });
+  });
+
+  it('rejects relative paths', async () => {
+    await expect(readPreview('relative.txt', deps)).rejects.toThrow(/absolute/i);
+  });
+
+  it('decodes images through the injected decoder', async () => {
+    const file = join(root, 'photo.png');
+    writeFileSync(file, Buffer.from([0x89, 0x50, 0x4e, 0x47]));
+    const result = await readPreview(file, deps);
+    expect(result).toMatchObject({
+      kind: 'image',
+      dataUrl: 'data:image/png;base64,AA',
+      width: 10,
+      height: 10
+    });
+  });
+
+  it('refuses images over the byte cap before decoding', async () => {
+    const file = join(root, 'huge.png');
+    writeFileSync(file, '');
+    truncateSync(file, PREVIEW_IMAGE_MAX_BYTES + 1);
+    const result = await readPreview(file, { decodeImage: noImage });
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'too-large' });
+  });
+
+  it('reports failed decodes', async () => {
+    const file = join(root, 'broken.gif');
+    writeFileSync(file, Buffer.from([0x47, 0x49, 0x46]));
+    const result = await readPreview(file, { decodeImage: noImage });
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'decode-failed' });
+  });
+
+  it('reports unsupported types', async () => {
+    const file = join(root, 'data.zip');
+    writeFileSync(file, 'PK');
+    const result = await readPreview(file, deps);
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'unsupported-type' });
+  });
+
+  it.runIf(process.platform !== 'win32')('refuses symlinks', async () => {
+    const target = join(root, 'real.txt');
+    writeFileSync(target, 'x');
+    const link = join(root, 'link.txt');
+    (await import('node:fs')).symlinkSync(target, link);
+    const result = await readPreview(link, deps);
+    expect(result).toMatchObject({ kind: 'unsupported', reason: 'symlink' });
+  });
+});
+```
+
+- [ ] **Step 2: Run it to verify it fails**
+
+Run: `npx vitest run tests/preview-fs.test.ts`
+Expected: FAIL — cannot resolve `../src/main/preview-fs.js`.
+
+- [ ] **Step 3: Refactor `src/main/thumbnails.ts`**
+
+Replace the whole file with (behaviour for `readThumbnail` is unchanged: same 32–512 clamp, same eligibility checks):
+
+```ts
+import { lstat } from 'node:fs/promises';
+import { nativeImage, type NativeImage } from 'electron';
+import { isThumbnailCandidate, THUMBNAIL_MAX_BYTES } from '../shared/listing-view.js';
+import { resolveLocalPath } from './local-fs.js';
+
+export type ThumbnailResult = {
+  dataUrl: string;
+  width: number;
+  height: number;
+};
+
+export type DecodedImage = ThumbnailResult;
+
+/**
+ * Ask the OS thumbnailer first (Windows shell / macOS Quick Look): it runs off
+ * the main thread and reuses the system thumbnail cache. Linux has no such
+ * API, and the OS may have no handler for a format, so fall back to a full
+ * decode — synchronous, but bounded by the caller's size cap.
+ */
+async function decode(target: string, edge: number): Promise {
+  if (process.platform === 'win32' || process.platform === 'darwin') {
+    try {
+      const thumb = await nativeImage.createThumbnailFromPath(target, { width: edge, height: edge });
+      if (!thumb.isEmpty()) return thumb;
+    } catch {
+      /* no OS thumbnail for this file — decode it ourselves */
+    }
+  }
+  return nativeImage.createFromPath(target);
+}
+
+/** Decode a local image at `edge` and return a data URL scaled to fit. */
+export async function decodeImage(target: string, edge: number): Promise {
+  const image = await decode(target, edge);
+  if (!image || image.isEmpty()) return null;
+  const size = image.getSize();
+  if (!size.width || !size.height) return null;
+  const longest = Math.max(size.width, size.height);
+  const scaled =
+    longest > edge
+      ? image.resize({
+          width: Math.max(1, Math.round((size.width * edge) / longest)),
+          height: Math.max(1, Math.round((size.height * edge) / longest))
+        })
+      : image;
+  const out = scaled.getSize();
+  return { dataUrl: scaled.toDataURL(), width: out.width, height: out.height };
+}
+
+/**
+ * Decode a local image via Electron nativeImage and return a small data URL.
+ * Returns null when the path is ineligible or cannot be decoded.
+ */
+export async function readThumbnail(path: unknown, maxEdge = 256): Promise {
+  const target = resolveLocalPath(path);
+  const edge = Math.max(32, Math.min(512, Math.floor(maxEdge)));
+  let info;
+  try {
+    info = await lstat(target);
+  } catch {
+    return null;
+  }
+  if (!info.isFile()) return null;
+  if (!isThumbnailCandidate(target, info.size, 'file')) return null;
+  if (info.size > THUMBNAIL_MAX_BYTES) return null;
+  return decodeImage(target, edge);
+}
+```
+
+- [ ] **Step 4: Create `src/main/preview-fs.ts`**
+
+```ts
+import { lstat, open } from 'node:fs/promises';
+import { basename } from 'node:path';
+import {
+  PREVIEW_IMAGE_MAX_BYTES,
+  PREVIEW_IMAGE_MAX_EDGE,
+  PREVIEW_TEXT_MAX_BYTES,
+  previewKindFor,
+  type PreviewReason,
+  type PreviewResult
+} from '../shared/preview.js';
+import { resolveLocalPath } from './local-fs.js';
+import { decodeImage, type DecodedImage } from './thumbnails.js';
+
+export type PreviewDeps = {
+  decodeImage: (target: string, edge: number) => Promise;
+};
+
+const BINARY_SNIFF_BYTES = 8 * 1024;
+
+function unsupported(
+  path: string,
+  name: string,
+  size: number,
+  reason: PreviewReason,
+  modified?: string
+): PreviewResult {
+  return { kind: 'unsupported', path, name, size, modified, reason };
+}
+
+function errorCode(error: unknown): string | undefined {
+  return typeof error === 'object' && error !== null
+    ? (error as NodeJS.ErrnoException).code
+    : undefined;
+}
+
+async function readText(
+  target: string,
+  name: string,
+  size: number,
+  modified: string | undefined,
+  kind: 'text' | 'markdown' | 'code'
+): Promise {
+  const limit = Math.min(size, PREVIEW_TEXT_MAX_BYTES);
+  const handle = await open(target, 'r');
+  try {
+    const buffer = Buffer.alloc(limit);
+    const { bytesRead } = await handle.read(buffer, 0, limit, 0);
+    const bytes = buffer.subarray(0, bytesRead);
+    if (bytes.subarray(0, BINARY_SNIFF_BYTES).includes(0)) {
+      return unsupported(target, name, size, 'binary', modified);
+    }
+    const text = new TextDecoder('utf-8').decode(bytes);
+    return {
+      kind,
+      path: target,
+      name,
+      size,
+      modified,
+      text,
+      truncated: size > PREVIEW_TEXT_MAX_BYTES
+    };
+  } finally {
+    await handle.close();
+  }
+}
+
+/**
+ * Classify, validate and read one local file for the preview pane.
+ * Invalid paths reject; everything else is reported as an `unsupported` result.
+ */
+export async function readPreview(
+  path: unknown,
+  deps: PreviewDeps = { decodeImage }
+): Promise {
+  const target = resolveLocalPath(path);
+  const name = basename(target);
+  let info;
+  try {
+    info = await lstat(target);
+  } catch (error) {
+    if (errorCode(error) === 'ENOENT') return unsupported(target, name, 0, 'not-found');
+    throw error;
+  }
+  const modified = info.mtime.toISOString();
+  if (info.isSymbolicLink()) return unsupported(target, name, 0, 'symlink', modified);
+  if (info.isDirectory()) return unsupported(target, name, 0, 'folder', modified);
+  if (!info.isFile()) return unsupported(target, name, 0, 'unsupported-type', modified);
+
+  const kind = previewKindFor(name, 'file');
+  if (kind === 'unsupported') {
+    return unsupported(target, name, info.size, 'unsupported-type', modified);
+  }
+  if (kind === 'image') {
+    if (info.size > PREVIEW_IMAGE_MAX_BYTES) {
+      return unsupported(target, name, info.size, 'too-large', modified);
+    }
+    const decoded = await deps.decodeImage(target, PREVIEW_IMAGE_MAX_EDGE);
+    if (!decoded) return unsupported(target, name, info.size, 'decode-failed', modified);
+    return { kind: 'image', path: target, name, size: info.size, modified, ...decoded };
+  }
+  return readText(target, name, info.size, modified, kind);
+}
+```
+
+- [ ] **Step 5: Run the test to verify it passes**
+
+Run: `npx vitest run tests/preview-fs.test.ts && npm run typecheck`
+Expected: PASS (12 tests, one skipped on Windows for symlinks).
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add src/main/thumbnails.ts src/main/preview-fs.ts tests/preview-fs.test.ts
+git commit -m "feat(preview): bounded main-process preview reader"
+```
+
+---
+
+### Task 4: URL helper and IPC wiring
+
+**Files:**
+- Create: `src/shared/open-url.ts`
+- Test: `tests/open-url.test.ts`
+- Modify: `src/main/main.ts`
+- Modify: `src/main/preload.cjs`
+- Modify: `src/shared/types.ts`
+
+**Interfaces:**
+- Consumes: `readPreview` (Task 3), `PreviewResult` (Task 2).
+- Produces:
+  - `safeExternalUrl(value: unknown): string | null`
+  - `FileManApi.previewFile(path: string): Promise`
+  - `FileManApi.openExternalUrl(url: string): Promise`
+  - IPC channels `fs:preview`, `shell:openUrl`
+  - `types.ts` re-exports `PreviewKind`, `PreviewResult`, `PreviewTarget`
+
+- [ ] **Step 1: Write the failing URL test**
+
+Create `tests/open-url.test.ts`:
+
+```ts
+import { describe, expect, it } from 'vitest';
+import { safeExternalUrl } from '../src/shared/open-url.js';
+
+describe('safeExternalUrl', () => {
+  it('accepts absolute http and https links', () => {
+    expect(safeExternalUrl('https://example.com/a?b=1')).toBe('https://example.com/a?b=1');
+    expect(safeExternalUrl('http://localhost:8080/')).toBe('http://localhost:8080/');
+  });
+
+  it('rejects other schemes and credentials', () => {
+    expect(safeExternalUrl('javascript:alert(1)')).toBeNull();
+    expect(safeExternalUrl('file:///C:/Windows/win.ini')).toBeNull();
+    expect(safeExternalUrl('data:text/html,hi')).toBeNull();
+    expect(safeExternalUrl('https://user:pass@example.com/')).toBeNull();
+  });
+
+  it('rejects junk values', () => {
+    expect(safeExternalUrl(null)).toBeNull();
+    expect(safeExternalUrl(42)).toBeNull();
+    expect(safeExternalUrl('')).toBeNull();
+    expect(safeExternalUrl('not a url')).toBeNull();
+    expect(safeExternalUrl(`https://example.com/${'a'.repeat(2048)}`)).toBeNull();
+  });
+});
+```
+
+- [ ] **Step 2: Run it to verify it fails**
+
+Run: `npx vitest run tests/open-url.test.ts`
+Expected: FAIL — cannot resolve `../src/shared/open-url.js`.
+
+- [ ] **Step 3: Create `src/shared/open-url.ts`**
+
+```ts
+/** Only absolute web links may be handed to the system browser. */
+export function safeExternalUrl(value: unknown): string | null {
+  if (typeof value !== 'string' || !value || value.length > 2048) return null;
+  let url: URL;
+  try {
+    url = new URL(value);
+  } catch {
+    return null;
+  }
+  if (url.protocol !== 'http:' && url.protocol !== 'https:') return null;
+  if (url.username || url.password) return null;
+  return url.href;
+}
+```
+
+- [ ] **Step 4: Run the test to verify it passes**
+
+Run: `npx vitest run tests/open-url.test.ts`
+Expected: PASS (3 tests).
+
+- [ ] **Step 5: Wire main.ts**
+
+Add imports near the existing `local-fs` import block in `src/main/main.ts`:
+
+```ts
+import { readPreview } from './preview-fs.js';
+import { safeExternalUrl } from '../shared/open-url.js';
+```
+
+Add handlers next to `handle('fs:thumbnail', …)`:
+
+```ts
+handle('fs:preview', (_e, path: unknown) => readPreview(path));
+```
+
+Add next to the `shell:` handlers:
+
+```ts
+handle('shell:openUrl', async (_e, url: unknown) => {
+  const safe = safeExternalUrl(url);
+  if (!safe) throw new Error('Only web links can be opened.');
+  await shell.openExternal(safe);
+});
+```
+
+- [ ] **Step 6: Wire preload.cjs**
+
+In the exposed object in `src/main/preload.cjs`, after `readThumbnail`:
+
+```js
+previewFile: (path) => ipcRenderer.invoke('fs:preview', path),
+```
+
+and after `showItemInFolder`:
+
+```js
+openExternalUrl: (url) => ipcRenderer.invoke('shell:openUrl', url),
+```
+
+- [ ] **Step 7: Extend `src/shared/types.ts`**
+
+Add to the imports/re-exports at the top:
+
+```ts
+import type { PreviewKind, PreviewResult, PreviewTarget } from './preview.js';
+export type { PreviewKind, PreviewResult, PreviewTarget };
+```
+
+Add to `FileManApi`, after `readThumbnail`:
+
+```ts
+  /** Bounded, read-only preview payload (image / text / unsupported). */
+  previewFile(path: string): Promise;
+```
+
+and after `showItemInFolder`:
+
+```ts
+  /** Open an http(s) link from previewed Markdown in the system browser. */
+  openExternalUrl(url: string): Promise;
+```
+
+- [ ] **Step 8: Typecheck and run the unit tests**
+
+Run: `npm run typecheck && npx vitest run tests/open-url.test.ts`
+Expected: PASS.
+
+- [ ] **Step 9: Commit**
+
+```bash
+git add src/shared/open-url.ts tests/open-url.test.ts src/main/main.ts src/main/preload.cjs src/shared/types.ts
+git commit -m "feat(preview): expose preview and web-link IPC"
+```
+
+---
+
+### Task 5: PreviewPane component and styles
+
+**Files:**
+- Create: `src/renderer/preview-pane.tsx`
+- Modify: `src/renderer/styles.css` (append at end of the Panes section)
+- Modify: `package.json`, `package-lock.json` (via npm install)
+
+**Interfaces:**
+- Consumes: `window.fileman.previewFile`, `openExternalUrl` (Task 4); `PreviewTarget`, `PreviewReason`, `PreviewResult` (Task 2); `formatSize`, `formatModified`, `baseName` from `src/shared/files.ts`; `describeError` from `src/shared/file-op.ts`; `Icon` from `./icons.js`.
+- Produces: `PreviewPane` React component with props
+  `{ target: PreviewTarget | null; active: boolean; onActivate(): void; onOpen(path: string): void; onBrowseFolder(path: string): void; onClose(): void }`
+
+- [ ] **Step 1: Install the Markdown renderer**
+
+Run: `npm install react-markdown remark-gfm`
+Expected: both appear under `dependencies`; no other packages change except their transitive ESM deps.
+
+- [ ] **Step 2: Create `src/renderer/preview-pane.tsx`**
+
+```tsx
+import { useEffect, useRef, useState, type ReactNode } from 'react';
+import ReactMarkdown from 'react-markdown';
+import remarkGfm from 'remark-gfm';
+import type { PreviewReason, PreviewResult, PreviewTarget } from '../shared/preview.js';
+import { formatModified, formatSize } from '../shared/files.js';
+import { describeError } from '../shared/file-op.js';
+import { Icon } from './icons.js';
+
+const REASONS: Record = {
+  folder: 'Folders have no preview.',
+  symlink: 'Symbolic links are not previewed.',
+  'not-found': 'This file no longer exists.',
+  'too-large': 'This image is too large to preview.',
+  binary: 'This file looks binary, not text.',
+  'decode-failed': 'This image could not be decoded.',
+  'unsupported-type': 'No preview for this file type.'
+};
+
+function sizeLabel(size: number, name: string): string {
+  return formatSize({ name, kind: 'file', size });
+}
+
+function kindLabel(result: PreviewResult | null): string {
+  if (!result) return 'File';
+  if (result.kind === 'unsupported') return 'No preview';
+  if (result.kind === 'image') return 'Image';
+  if (result.kind === 'markdown') return 'Markdown';
+  if (result.kind === 'code') return 'Source';
+  return 'Text';
+}
+
+export function PreviewPane(props: {
+  target: PreviewTarget | null;
+  active: boolean;
+  onActivate: () => void;
+  onOpen: (path: string) => void;
+  onBrowseFolder: (path: string) => void;
+  onClose: () => void;
+}) {
+  const { target, active, onActivate, onOpen, onBrowseFolder, onClose } = props;
+  const [result, setResult] = useState(null);
+  const [error, setError] = useState(null);
+  const [loading, setLoading] = useState(false);
+  const [attempt, setAttempt] = useState(0);
+  const seq = useRef(0);
+
+  useEffect(() => {
+    if (!target) {
+      setResult(null);
+      setError(null);
+      setLoading(false);
+      return;
+    }
+    const current = ++seq.current;
+    setLoading(true);
+    setError(null);
+    void window.fileman
+      .previewFile(target.path)
+      .then((next) => {
+        if (current !== seq.current) return;
+        setResult(next);
+        setLoading(false);
+      })
+      .catch((reason: unknown) => {
+        if (current !== seq.current) return;
+        setResult(null);
+        setError(describeError(reason));
+        setLoading(false);
+      });
+  }, [target, attempt]);
+
+  const name = result?.name ?? target?.name ?? '';
+  const size = result?.size ?? target?.size ?? 0;
+  const modified = result?.modified ?? target?.modified;
+
+  let body: ReactNode;
+  if (!target) {
+    body = 
Select a file to preview.
; + } else if (loading) { + body =
Loading…
; + } else if (error) { + body = ( +
+

{error}

+ +
+ ); + } else if (!result) { + body =
No preview.
; + } else if (result.kind === 'unsupported') { + body = ( +
+

{REASONS[result.reason]}

+ {result.reason !== 'folder' && result.reason !== 'not-found' ? ( + + ) : null} +
+ ); + } else if (result.kind === 'image') { + body = ( +
+ {result.name} +
+ ); + } else { + const banner = result.truncated ? ( +
+ Showing the first 1 MiB of {sizeLabel(result.size, result.name)}. +
+ ) : null; + body = + result.kind === 'markdown' ? ( +
+ {banner} + + href && /^https?:\/\//i.test(href) ? ( + { + event.preventDefault(); + void window.fileman.openExternalUrl(href); + }} + > + {children} + + ) : ( + {children} + ) + }} + > + {result.text} + +
+ ) : ( + <> + {banner} +
{result.text}
+ + ); + } + + return ( +
+
+
+
+ + {active ? 'Active' : 'Idle'} + + + {name || 'Preview'} +
+
+ + + +
+
+
+ {target + ? `${kindLabel(result)} · ${sizeLabel(size, name)}${modified ? ` · ${formatModified(modified)}` : ''}` + : 'Right pane preview'} +
+
+
{body}
+
+ ); +} +``` + +- [ ] **Step 3: Append styles to `src/renderer/styles.css`** + +After the `.pane.active { … }` rule (inside the Panes section), add: + +```css +/* —— Preview pane —— */ +.preview-head-title { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; +} + +.preview-name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-family: var(--mono); + font-size: 12px; +} + +.preview-meta { + color: var(--muted); + font-size: 11px; + font-family: var(--mono); +} + +.preview-body { + flex: 1; + min-height: 0; + overflow: auto; + padding: 12px; + display: flex; + flex-direction: column; +} + +.preview-empty, +.preview-error { + margin: auto; + max-width: 36ch; + text-align: center; + color: var(--muted); + font-size: 13px; + line-height: 1.5; +} + +.preview-error button { + margin-top: 12px; +} + +.preview-banner { + margin-bottom: 8px; + padding: 6px 10px; + border: 1px solid var(--border); + border-radius: 6px; + background: color-mix(in srgb, var(--panel-2) 80%, transparent); + color: var(--muted); + font-size: 11px; + font-family: var(--mono); +} + +.preview-text { + margin: 0; + font-family: var(--mono); + font-size: 12px; + line-height: 1.55; + white-space: pre; + tab-size: 2; +} + +.preview-image-wrap { + flex: 1; + min-height: 0; + display: grid; + place-items: center; +} + +.preview-image-wrap img { + max-width: 100%; + max-height: 100%; + object-fit: contain; +} + +.preview-markdown { + max-width: 78ch; + font-size: 13px; + line-height: 1.6; +} + +.preview-markdown pre { + font-family: var(--mono); + font-size: 12px; + overflow: auto; +} + +.preview-markdown a { + color: var(--accent); +} + +.slot-modes { + display: flex; + align-items: center; + gap: 4px; +} +``` + +- [ ] **Step 4: Typecheck and build the component** + +Run: `npm run typecheck && npm run build` +Expected: PASS. The `PreviewPane` is not yet mounted (Task 6), but it must compile. + +- [ ] **Step 5: Commit** + +```bash +git add package.json package-lock.json src/renderer/preview-pane.tsx src/renderer/styles.css +git commit -m "feat(preview): react preview pane for images, text, markdown and code" +``` + +--- + +### Task 6: App wiring — slot lifecycle, follow-selection, toolbar, context menu + +**Files:** +- Modify: `src/renderer/main.tsx` +- Modify: `src/shared/context-menu.ts` +- Test: `tests/context-menu.test.ts` (extend) + +**Interfaces:** +- Consumes: everything from Tasks 1–5. +- Produces: working right-slot modes; `item:preview` menu command; `FilePane` prop `slotControls`. + +- [ ] **Step 1: Update the context-menu test (failing two ways)** + +The existing exact-array assertion at `tests/context-menu.test.ts` ("offers the file actions…") will break when Preview is inserted, and the new behaviour needs its own test. Make both edits now. + +In that exact-array expectation, insert `'item:preview'` after `'item:open'`: + +```ts + expect(commands(win)).toEqual([ + 'item:open', + 'item:preview', + 'file:open-notepad', + 'item:open-cursor', +``` + +Then add the new test after the existing file-actions test: + +```ts + it('offers Preview only for files', () => { + const file = buildContextMenu({ kind: 'file', canPaste: false, canTransfer: true }, 'win32'); + expect(commands(file)).toContain('item:preview'); + const dir = buildContextMenu({ kind: 'directory', canPaste: false, canTransfer: true }, 'win32'); + expect(commands(dir)).not.toContain('item:preview'); + }); +``` + +- [ ] **Step 2: Run it to verify it fails** + +Run: `npx vitest run tests/context-menu.test.ts` +Expected: FAIL — `item:preview` missing. + +- [ ] **Step 3: Add the menu command** + +In `src/shared/context-menu.ts`: + +- Extend `ContextMenuCommand`: + +```ts +export type ContextMenuCommand = + | 'item:open' + | 'item:preview' + | 'item:open-cursor' + | 'item:copy-path' + | 'item:terminal' + | 'item:favorite'; +``` + +- In `buildContextMenu`, for the non-folder branch, insert Preview after Open: + +```ts + : [ + item('Open', 'item:open'), + item('Preview in Pane', 'item:preview'), + ...(windows ? [item('Open with Notepad', 'file:open-notepad')] : []), + item('Open with Cursor', 'item:open-cursor'), + ...(target.openWith ?? []).map((app) => item(`Open with ${app.label}`, `item:open-app:${app.appId}`)) + ]; +``` + +Run: `npx vitest run tests/context-menu.test.ts` → PASS. + +- [ ] **Step 4: Update imports and state in `src/renderer/main.tsx`** + +Extend the pane-layout import: + +```ts +import { + clampSplitRatio, + otherPaneIsListing, + setLayout, + setRightSlot, + toggleMaximize, + workspaceGridTemplate, + type RightSlot, + type WorkspaceLayoutState +} from '../shared/pane-layout.js'; +``` + +Add: + +```ts +import type { PreviewTarget } from '../shared/preview.js'; +import { PreviewPane } from './preview-pane.js'; +``` + +Extend the layout-prefs import: + +```ts +import { + loadStoredPreviewPath, + loadStoredWorkspaceLayout, + storeStoredPreviewPath, + storeWorkspaceLayout +} from './layout-prefs.js'; +``` + +Add state after `workspaceLayout`: + +```tsx + const [previewTarget, setPreviewTarget] = useState(() => { + const path = loadStoredPreviewPath(); + return path ? { path, name: baseName(path), size: 0 } : null; + }); +``` + +- [ ] **Step 5: Add slot and preview helpers** + +Immediately after `updateWorkspaceLayout`: + +```tsx + const updatePreviewTarget = useCallback((target: PreviewTarget | null) => { + setPreviewTarget(target); + storeStoredPreviewPath(target?.path ?? null); + }, []); + + const setSlot = useCallback( + (slot: RightSlot) => { + updateWorkspaceLayout(setRightSlot(workspaceLayout, slot)); + if (slot === 'closed' && active === 'right') setActive('left'); + if (slot === 'preview' && left) { + const name = primarySelected(left.selected); + const entry = name ? left.entries.find((item) => item.name === name) : undefined; + if (name && entry) { + updatePreviewTarget({ + path: joinLocal(left.path, name), + name, + size: entry.size, + modified: entry.modified + }); + } + } + }, + [active, left, updatePreviewTarget, updateWorkspaceLayout, workspaceLayout] + ); +``` + +After `const cmds = …`, add: + +```tsx + const activeListingPane = useCallback((): PaneState | null => { + if (active === 'left') return left; + return workspaceLayout.rightSlot === 'browse' ? right : null; + }, [active, left, right, workspaceLayout.rightSlot]); +``` + +- [ ] **Step 6: Replace `goActive` with a side-aware helper** + +Replace the existing `goActive` block with: + +```tsx + const goSide = useCallback( + async (side: 'left' | 'right', path: string) => { + const setter = side === 'left' ? setLeft : setRight; + try { + const next = await loadPane(path); + setter((prev) => { + if (!prev) return prev; + const hist = pushPath(historyOf(prev), next.path); + return { + ...prev, + ...next, + ...hist, + ...emptySelection(), + matchNames: new Set(), + status: next.path, + listening: null + }; + }); + pushLog(`[${stamp()}] jump → ${next.path}`); + } catch (error) { + pushLog(error instanceof Error ? error.message : String(error)); + } + }, + [pushLog] + ); + + const goActive = useCallback((path: string) => goSide(active, path), [active, goSide]); +``` + +- [ ] **Step 7: Replace `addCurrentFavorite`'s pane lookup** + +Replace the first two lines of the callback body: + +```tsx + const addCurrentFavorite = useCallback(async (path?: string) => { + const target = path ?? activeListingPane()?.path; + if (!target) return; +``` + +and change its dependency array to `[activeListingPane, pushLog]`. + +- [ ] **Step 8: Add the follow-selection effect** + +Immediately after the existing keyboard `useEffect` (the one ending with `}, [active, addCurrentFavorite, focusJump]);`), add: + +```tsx + useEffect(() => { + if (workspaceLayout.rightSlot !== 'preview' || !left) return; + const name = primarySelected(left.selected); + if (!name) return; + const entry = left.entries.find((item) => item.name === name); + const timer = window.setTimeout(() => { + updatePreviewTarget({ + path: joinLocal(left.path, name), + name, + size: entry?.size ?? 0, + modified: entry?.modified + }); + }, 180); + return () => window.clearTimeout(timer); + }, [left?.entries, left?.path, left?.selected, updatePreviewTarget, workspaceLayout.rightSlot]); +``` + +- [ ] **Step 9: Guard Tab and extend the keyboard effect deps** + +Replace the Tab block with: + +```tsx + if (event.key === 'Tab') { + event.preventDefault(); + setActive((side) => { + if (side === 'left') return workspaceLayout.rightSlot === 'closed' ? 'left' : 'right'; + return 'left'; + }); + return; + } +``` + +and change that effect's dependency array from `[active, addCurrentFavorite, focusJump]` to: + +```tsx + }, [active, addCurrentFavorite, focusJump, workspaceLayout.rightSlot]); +``` + +- [ ] **Step 10: Handle `item:preview` in the menu-command switch** + +Insert after the `item:open-cursor` case: + +```tsx + case 'item:preview': { + const pane = activeListingPane(); + const name = pane ? primarySelected(pane.selected) : null; + const entry = name && pane ? pane.entries.find((item) => item.name === name) : undefined; + if (pane && name) { + updatePreviewTarget({ + path: joinLocal(pane.path, name), + name, + size: entry?.size ?? 0, + modified: entry?.modified + }); + setSlot('preview'); + } + break; + } +``` + +Change that effect's dependency array to include the new callbacks: + +```tsx + }, [ + active, + activeListingPane, + addCurrentFavorite, + checkForUpdatesNow, + detectedFileApps, + fileAppPrefs, + focusJump, + launchApp, + pushLog, + setSlot, + updatePreviewTarget + ]); +``` + +- [ ] **Step 11: Use the listing pane for active-path and Cursor** + +Replace: + +```tsx + const activePath = (active === 'left' ? left : right)?.path ?? ''; +``` + +with: + +```tsx + const activePath = activeListingPane()?.path ?? ''; +``` + +In the toolbar Cursor button, replace the body: + +```tsx + onClick={() => { + const pane = activeListingPane(); + if (!pane) return; + const focusName = primarySelected(pane.selected); + const target = focusName ? joinLocal(pane.path, focusName) : pane.path; + void api().openWith(target, 'cursor'); + }} +``` + +and add `disabled={!activeListingPane()}` to that `ToolButton`. + +For Back/Forward buttons, replace the `disabled` expressions with: + +```tsx + disabled={(() => { + const pane = activeListingPane(); + return !pane || !canGoBack(historyOf(pane)); + })()} +``` + +and + +```tsx + disabled={(() => { + const pane = activeListingPane(); + return !pane || !canGoForward(historyOf(pane)); + })()} +``` + +- [ ] **Step 12: Add Split/Preview to the layout toolbar group** + +Inside `
`, before the `split-v` button: + +```tsx + {workspaceLayout.rightSlot === 'closed' ? ( + <> + setSlot('browse')} + /> + setSlot('preview')} + /> + + ) : null} +``` + +- [ ] **Step 13: Render the right slot by mode** + +In the workspace JSX, replace everything between the opening `
` element and the closing `
` (the left cell, gutter, and right cell) with: + +```tsx + {workspaceLayout.maximized !== 'right' ? ( + setActive('left')} + onChange={setLeft} + onLog={pushLog} + onClipboard={setClipboard} + onToggleMaximize={() => updateWorkspaceLayout(toggleMaximize(workspaceLayout, 'left'))} + onRefreshPeer={() => refreshSide('right')} + askText={askText} + onOpenFile={openFile} + openWithFor={openWithFor} + onRegisterCommands={(c) => { + leftCommands.current = c; + }} + /> + ) : null} + {!workspaceLayout.maximized && workspaceLayout.rightSlot !== 'closed' ? ( +
{ + const box = workspaceRef.current?.getBoundingClientRect(); + if (!box) return; + event.preventDefault(); + (event.target as HTMLElement).setPointerCapture(event.pointerId); + dragRef.current = { + start: workspaceLayout.layout === 'split-h' ? event.clientY : event.clientX, + ratio: workspaceLayout.ratio, + vertical: workspaceLayout.layout === 'split-v' + }; + }} + onPointerMove={(event) => { + const drag = dragRef.current; + const box = workspaceRef.current?.getBoundingClientRect(); + if (!drag || !box) return; + const span = drag.vertical ? box.width : box.height; + if (span <= 0) return; + const delta = (drag.vertical ? event.clientX : event.clientY) - drag.start; + updateWorkspaceLayout({ + ...workspaceLayout, + ratio: clampSplitRatio(drag.ratio + delta / span) + }); + }} + onPointerUp={() => { + dragRef.current = null; + }} + onPointerCancel={() => { + dragRef.current = null; + }} + onDoubleClick={() => + updateWorkspaceLayout({ ...workspaceLayout, ratio: 0.5 }) + } + /> + ) : null} + {workspaceLayout.rightSlot !== 'closed' && workspaceLayout.maximized !== 'left' ? ( + workspaceLayout.rightSlot === 'preview' ? ( + setActive('right')} + onOpen={(path) => void openFile(path, baseName(path))} + onBrowseFolder={(path) => { + setSlot('browse'); + void goSide('right', parentLocal(path)); + }} + onClose={() => setSlot('closed')} + /> + ) : ( + setSlot(mode), + onClose: () => setSlot('closed') + }} + onActivate={() => setActive('right')} + onChange={setRight} + onLog={pushLog} + onClipboard={setClipboard} + onToggleMaximize={() => updateWorkspaceLayout(toggleMaximize(workspaceLayout, 'right'))} + onRefreshPeer={() => refreshSide('left')} + askText={askText} + onOpenFile={openFile} + openWithFor={openWithFor} + onRegisterCommands={(c) => { + rightCommands.current = c; + }} + /> + ) + ) : null} +``` + +`goSide` is declared in the callback section above the JSX, and `parentLocal` / `baseName` are already imported in `main.tsx`. + +- [ ] **Step 14: Add slot controls to `FilePane`** + +In `FilePane`'s props type, change `otherPath: string;` to `otherPath: string | null;`. Then add after it (Step 16 guards every use): + +```tsx + slotControls?: { + mode: 'browse' | 'preview'; + onSelect: (mode: 'browse' | 'preview') => void; + onClose: () => void; + }; +``` + +Destructure `slotControls` with the other props. In the `.pane-pills` markup, insert **before** the maximize button: + +```tsx + {slotControls ? ( +
+ + + +
+ ) : null} +``` + +- [ ] **Step 15: Guard context-menu transfer** + +In `FilePane`'s context-menu description, change: + +```tsx + canTransfer: otherPath !== pane.path, +``` + +to: + +```tsx + canTransfer: otherPath !== null && otherPath !== pane.path, +``` + +- [ ] **Step 16: Guard `transferToOther`** + +At the top of the callback body, before `requireSelections()`: + +```tsx + if (!otherPath) { + onLog('Target pane is not a listing.'); + return; + } +``` + +TypeScript narrows `otherPath` to `string` for the rest of the function, so the existing `copyLocalEntry` / `moveLocalEntry` calls compile unchanged. + +- [ ] **Step 17: Disable F5/F6 toolbar buttons** + +Add to both the `Copy →` and `Move →` `ToolButton`s (order of props does not matter): + +```tsx + disabled={!otherPaneIsListing(active, workspaceLayout.rightSlot)} +``` + +- [ ] **Step 18: Disable listing-only toolbar groups while a preview is active** + +Add `disabled={!activeListingPane()}` to the New Folder, New File, Rename, Delete, Copy, Cut buttons in the second and third tool groups, and to the three view-mode buttons (Details/Icons/Thumbnails). + +- [ ] **Step 19: Typecheck, run all unit tests, build** + +Run: `npm run typecheck && npm test && npm run build` +Expected: PASS. Then launch `npm start` and confirm: + +- F5/Copy→ are greyed while the right slot is a preview and the transcript reads `Target pane is not a listing.` when F5 is pressed from the left listing. +- `×` on the right listing collapses it; **Split** reopens it at the remembered path. +- Clicking an image/`.txt`/`.md` on the left updates the right preview. +- Tab cycles listing ↔ preview. + +- [ ] **Step 20: Commit** + +```bash +git add src/renderer/main.tsx src/shared/context-menu.ts tests/context-menu.test.ts +git commit -m "feat(preview): right slot modes, follow-selection and cross-pane guards" +``` + +--- + +### Task 7: ADR, docs, full verification and smoke + +**Files:** +- Create: `docs/adr/0006-right-slot-modes-and-preview.md` +- Modify: `SPEC.md` +- Modify: `ROADMAP.md` +- Modify: `PROGRESS.md` + +- [ ] **Step 1: Write ADR-0006** + +Create `docs/adr/0006-right-slot-modes-and-preview.md`: + +```markdown +# 0006 — Right slot modes and main-process file preview + +- **Status:** Accepted +- **Date:** 2026-11-30 + +## Context + +The workspace had two fixed directory listings. Users asked to close the right +pane and to preview files (images, text, Markdown, code) in it instead of +launching an external app for a glance. + +## Decision + +1. The right slot is `browse | preview | closed`, persisted with the workspace + layout. Left stays a listing; closing the right slot collapses the grid to + one cell and never leaves a maximized ghost. +2. `FilePane` remains listing-only. A separate `PreviewPane` renders previews; + preview follows the left listing's selection (180 ms debounce, primary of a + multi-selection). +3. One IPC channel, `fs:preview`, classifies, validates and reads in main and + returns a discriminated payload. Caps live only in main: 32 MiB images at a + 4096 px decode edge, 1 MiB text with a truncation flag, NUL-byte binary + sniff, regular files only, symlinks refused. +4. Markdown renders with `react-markdown` + `remark-gfm` and no raw HTML. + HTML/XML files are shown as source. Remote images stay blocked by CSP. + Markdown links open through `shell:openUrl`, which accepts only http(s). +5. When the opposing pane is not a listing, F5/F6, Copy→/Move→, cross-pane + drops and the context-menu transfer items are disabled with a transcript + hint. No retargeting into an invisible folder. + +## Consequences + +- Preview is read-only; editing stays in external editors (ZeroG Edit, Notepad, + Cursor) through the existing file-app associations. +- PDF, audio, video, SVG and syntax highlighting are deferred; they need a + custom protocol or a heavier renderer. +- The slot union leaves room for a future Terminal tab without another model + change. +``` + +- [ ] **Step 2: Update SPEC.md** + +Append to the acceptance table: + +```markdown +| M11 | Right pane closes (left fills the window) and reopens as a listing or a preview | +| M12 | Right pane previews images, text, Markdown (sanitized) and source code; HTML shows as source | +| M13 | Copy/move-to-other and cross-pane drops are disabled with a hint when the other pane is not a listing | +``` + +- [ ] **Step 3: Update ROADMAP.md** + +Add to the `Done` table: + +```markdown +| D18 | Closable right slot + file preview | P3.7 preview pane; F5/F6 guard | +``` + +Add to `P3 — Layout & density`: + +```markdown +| P3.7 | Right-slot preview | Close/reopen; images, text, Markdown, code; bounded IPC caps | done | +``` + +- [ ] **Step 4: Update PROGRESS.md** + +Add to `Delivered`: + +```markdown +- Closable right slot with a read-only preview: images, text, Markdown (no raw HTML) and source code follow the left selection through one bounded `fs:preview` channel (32 MiB image / 1 MiB text caps, binary sniff, symlinks refused); HTML shows as source; F5/F6 and cross-pane drops disable when the peer isn't a listing +``` + +- [ ] **Step 5: Run the full gate** + +Run: `npm run ci` +Expected: typecheck PASS, all tests PASS, build PASS. + +- [ ] **Step 6: Manual smoke in the real app** + +Run: `npm start`, then verify: + +1. Toolbar **Preview** with a file selected opens the right slot in preview mode. +2. Clicking an image, `.txt`, `.md`, `.ts` on the left updates the right preview. +3. A `.pdf` shows the unsupported card with **Open**. +4. A file over 1 MiB shows the truncation banner. +5. `×` on the right pane collapses it; **Split** reopens the remembered listing; **Preview** reopens preview. +6. With preview open, F5/Copy→ are disabled and the menu's transfer items are greyed. +7. Relaunch with preview open → last file restored; delete it and re-select → "no longer exists" card. +8. Markdown with a remote image shows alt text and makes no network request. +9. `.html` shows source text. +10. Tab cycles listing ↔ preview; listing shortcuts no-op while preview is active. + +If any check fails, fix and re-run `npm run ci` before committing. + +- [ ] **Step 7: Commit** + +```bash +git add docs/adr/0006-right-slot-modes-and-preview.md SPEC.md ROADMAP.md PROGRESS.md +git commit -m "docs: ADR-0006 and preview-slice progress" +``` + +- [ ] **Step 8: Checkpoint with Spine** + +If the Spine MCP is available, call `checkpoint` with the executing agent's name, summary of the slice, and any follow-ups (PDF/media preview, in-pane editing). + +--- + +## Self-Review Notes + +- Spec §3.1 → Task 1; §4.1 → Task 2; §4.2 → Task 3; §4.3 → Task 4; §5 → Task 5; + §6/§5.3/§7 → Task 6; §8 → Tasks 3–5; §9 → Tasks 1–4 and Task 7; + §10 → all tasks. +- Signatures used later match their definitions: `readPreview(path, deps?)`, + `PreviewResult` union, `setRightSlot`, `otherPaneIsListing`, + `PreviewPane` props, `FilePane.slotControls`, nullable `otherPath`. +- No placeholder text; every code step contains the content to paste. From 677d716dfc603d7b21948651109bb9956ebc496f Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:10:37 +0000 Subject: [PATCH 03/18] feat(layout): add right-slot modes and collapsed grid --- src/renderer/layout-prefs.ts | 20 ++++++++++++ src/shared/pane-layout.ts | 34 ++++++++++++++++++--- tests/pane-layout.test.ts | 59 ++++++++++++++++++++++++++++++++---- 3 files changed, 102 insertions(+), 11 deletions(-) diff --git a/src/renderer/layout-prefs.ts b/src/renderer/layout-prefs.ts index 95be7c9..579d182 100644 --- a/src/renderer/layout-prefs.ts +++ b/src/renderer/layout-prefs.ts @@ -22,3 +22,23 @@ export function storeWorkspaceLayout(state: WorkspaceLayoutState): void { /* ignore */ } } + +const PREVIEW_PATH_KEY = 'zerogfileman.preview-path'; + +export function loadStoredPreviewPath(): string | null { + try { + const raw = localStorage.getItem(PREVIEW_PATH_KEY); + return raw && raw.length <= 4096 ? raw : null; + } catch { + return null; + } +} + +export function storeStoredPreviewPath(path: string | null): void { + try { + if (path) localStorage.setItem(PREVIEW_PATH_KEY, path); + else localStorage.removeItem(PREVIEW_PATH_KEY); + } catch { + /* ignore */ + } +} diff --git a/src/shared/pane-layout.ts b/src/shared/pane-layout.ts index 620b6f6..8978dac 100644 --- a/src/shared/pane-layout.ts +++ b/src/shared/pane-layout.ts @@ -4,12 +4,16 @@ export type WorkspaceLayout = 'split-v' | 'split-h'; export type PaneSide = 'left' | 'right'; +/** What the right workspace slot shows. */ +export type RightSlot = 'browse' | 'preview' | 'closed'; + export type WorkspaceLayoutState = { layout: WorkspaceLayout; /** Which pane fills the workspace, if any. */ maximized: PaneSide | null; /** Fraction for the first pane along the split axis (0.2–0.8). */ ratio: number; + rightSlot: RightSlot; }; export const DEFAULT_SPLIT_RATIO = 0.5; @@ -29,6 +33,10 @@ export function isPaneSide(value: unknown): value is PaneSide { return value === 'left' || value === 'right'; } +export function isRightSlot(value: unknown): value is RightSlot { + return value === 'browse' || value === 'preview' || value === 'closed'; +} + export function clampSplitRatio(value: number): number { if (!Number.isFinite(value)) return DEFAULT_SPLIT_RATIO; return Math.min(SPLIT_RATIO_MAX, Math.max(SPLIT_RATIO_MIN, value)); @@ -36,22 +44,25 @@ export function clampSplitRatio(value: number): number { export function parseWorkspaceLayoutState(raw: unknown): WorkspaceLayoutState { if (!raw || typeof raw !== 'object') { - return { layout: 'split-v', maximized: null, ratio: DEFAULT_SPLIT_RATIO }; + return { layout: 'split-v', maximized: null, ratio: DEFAULT_SPLIT_RATIO, rightSlot: 'browse' }; } const source = raw as Partial; + const rightSlot = isRightSlot(source.rightSlot) ? source.rightSlot : 'browse'; return { layout: isWorkspaceLayout(source.layout) ? source.layout : 'split-v', - maximized: isPaneSide(source.maximized) ? source.maximized : null, - ratio: clampSplitRatio(typeof source.ratio === 'number' ? source.ratio : DEFAULT_SPLIT_RATIO) + maximized: + rightSlot === 'closed' ? null : isPaneSide(source.maximized) ? source.maximized : null, + ratio: clampSplitRatio(typeof source.ratio === 'number' ? source.ratio : DEFAULT_SPLIT_RATIO), + rightSlot }; } -/** CSS grid template for the workspace (pane | gutter | pane), or single when maximized. */ +/** CSS grid template for the workspace (pane | gutter | pane), or single when maximized/closed. */ export function workspaceGridTemplate(state: WorkspaceLayoutState): { columns: string; rows: string; } { - if (state.maximized) { + if (state.maximized || state.rightSlot === 'closed') { return { columns: '1fr', rows: '1fr' }; } const a = `${(state.ratio * 100).toFixed(2)}%`; @@ -66,6 +77,7 @@ export function toggleMaximize( state: WorkspaceLayoutState, side: PaneSide ): WorkspaceLayoutState { + if (state.rightSlot === 'closed') return { ...state, maximized: null }; return { ...state, maximized: state.maximized === side ? null : side @@ -78,3 +90,15 @@ export function setLayout( ): WorkspaceLayoutState { return { ...state, layout, maximized: null }; } + +export function setRightSlot( + state: WorkspaceLayoutState, + slot: RightSlot +): WorkspaceLayoutState { + return { ...state, rightSlot: slot, maximized: slot === 'closed' ? null : state.maximized }; +} + +/** May the active pane copy/move into the other pane? Only when the other is a listing. */ +export function otherPaneIsListing(active: PaneSide, rightSlot: RightSlot): boolean { + return active === 'left' ? rightSlot === 'browse' : true; +} diff --git a/tests/pane-layout.test.ts b/tests/pane-layout.test.ts index b64ed15..de1ab28 100644 --- a/tests/pane-layout.test.ts +++ b/tests/pane-layout.test.ts @@ -1,8 +1,10 @@ import { describe, expect, it } from 'vitest'; import { clampSplitRatio, + otherPaneIsListing, parseWorkspaceLayoutState, setLayout, + setRightSlot, toggleMaximize, workspaceGridTemplate } from '../src/shared/pane-layout.js'; @@ -14,33 +16,78 @@ describe('pane-layout', () => { expect(parseWorkspaceLayoutState(null)).toEqual({ layout: 'split-v', maximized: null, - ratio: 0.5 + ratio: 0.5, + rightSlot: 'browse' + }); + }); + + it('normalises the right-slot value and clears maximize when closed', () => { + expect(parseWorkspaceLayoutState({ rightSlot: 'preview' }).rightSlot).toBe('preview'); + expect(parseWorkspaceLayoutState({ rightSlot: 'nonsense' }).rightSlot).toBe('browse'); + expect(parseWorkspaceLayoutState({ rightSlot: 'closed', maximized: 'right' })).toEqual({ + layout: 'split-v', + maximized: null, + ratio: 0.5, + rightSlot: 'closed' }); }); it('builds grid templates for vertical and horizontal splits', () => { - expect(workspaceGridTemplate({ layout: 'split-v', maximized: null, ratio: 0.4 })).toEqual({ + expect( + workspaceGridTemplate({ layout: 'split-v', maximized: null, ratio: 0.4, rightSlot: 'browse' }) + ).toEqual({ columns: '40.00% 6px 60.00%', rows: '1fr' }); - expect(workspaceGridTemplate({ layout: 'split-h', maximized: null, ratio: 0.5 })).toEqual({ + expect( + workspaceGridTemplate({ layout: 'split-h', maximized: null, ratio: 0.5, rightSlot: 'browse' }) + ).toEqual({ columns: '1fr', rows: '50.00% 6px 50.00%' }); - expect(workspaceGridTemplate({ layout: 'split-v', maximized: 'left', ratio: 0.5 })).toEqual({ + expect( + workspaceGridTemplate({ layout: 'split-v', maximized: 'left', ratio: 0.5, rightSlot: 'browse' }) + ).toEqual({ columns: '1fr', rows: '1fr' }); }); + it('collapses to a single cell when the right slot is closed', () => { + expect( + workspaceGridTemplate({ layout: 'split-v', maximized: null, ratio: 0.4, rightSlot: 'closed' }) + ).toEqual({ columns: '1fr', rows: '1fr' }); + expect( + workspaceGridTemplate({ layout: 'split-h', maximized: null, ratio: 0.4, rightSlot: 'closed' }) + ).toEqual({ columns: '1fr', rows: '1fr' }); + }); + it('toggles maximize and clears it when changing layout', () => { - const maxed = toggleMaximize({ layout: 'split-v', maximized: null, ratio: 0.5 }, 'right'); + const base = { layout: 'split-v' as const, maximized: null, ratio: 0.5, rightSlot: 'browse' as const }; + const maxed = toggleMaximize(base, 'right'); expect(maxed.maximized).toBe('right'); expect(toggleMaximize(maxed, 'right').maximized).toBeNull(); expect(setLayout(maxed, 'split-h')).toEqual({ layout: 'split-h', maximized: null, - ratio: 0.5 + ratio: 0.5, + rightSlot: 'browse' }); }); + + it('closing the right slot clears maximize and ignores later toggles', () => { + const maxed = { layout: 'split-v' as const, maximized: 'right' as const, ratio: 0.5, rightSlot: 'browse' as const }; + const closed = setRightSlot(maxed, 'closed'); + expect(closed.rightSlot).toBe('closed'); + expect(closed.maximized).toBeNull(); + expect(toggleMaximize(closed, 'right').maximized).toBeNull(); + }); + + it('knows when the opposing pane is a listing', () => { + expect(otherPaneIsListing('left', 'browse')).toBe(true); + expect(otherPaneIsListing('left', 'preview')).toBe(false); + expect(otherPaneIsListing('left', 'closed')).toBe(false); + expect(otherPaneIsListing('right', 'browse')).toBe(true); + expect(otherPaneIsListing('right', 'preview')).toBe(true); + }); }); From f70671a2b0414d1abbfc1a3de792e06d65263150 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:12:34 +0000 Subject: [PATCH 04/18] feat(preview): file-type classifier and preview payload types --- .../specs/2026-11-30-preview-pane-design.md | 3 +- src/shared/preview.ts | 69 +++++++++++++++++++ tests/preview.test.ts | 51 ++++++++++++++ 3 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 src/shared/preview.ts create mode 100644 tests/preview.test.ts diff --git a/docs/superpowers/specs/2026-11-30-preview-pane-design.md b/docs/superpowers/specs/2026-11-30-preview-pane-design.md index 627adcb..2527e75 100644 --- a/docs/superpowers/specs/2026-11-30-preview-pane-design.md +++ b/docs/superpowers/specs/2026-11-30-preview-pane-design.md @@ -92,7 +92,6 @@ export type PreviewKind = 'image' | 'text' | 'markdown' | 'code' | 'unsupported' export function previewKindFor( name: string, - size: number, kind: 'file' | 'directory' | 'symlink' ): PreviewKind; ``` @@ -144,7 +143,7 @@ Behaviour: 1. `resolveLocalPath(path)` — absolute-path rule applies; invalid input **rejects**. 2. `lstat`; `ENOENT` → `unsupported/not-found`; directory → `unsupported/folder`; symlink → `unsupported/symlink` (no follow-through in v1). -3. Classify with `previewKindFor(name, size, 'file')`. +3. Classify with `previewKindFor(name, 'file')`. 4. Image → decode through the shared Electron image helper at `PREVIEW_IMAGE_MAX_EDGE`. Listings keep their existing 512 px cap. Decode failure → `unsupported/decode-failed`; over cap → `unsupported/too-large`. diff --git a/src/shared/preview.ts b/src/shared/preview.ts new file mode 100644 index 0000000..2bbd411 --- /dev/null +++ b/src/shared/preview.ts @@ -0,0 +1,69 @@ +/** Read-only preview classification and the payload main returns for a pane. */ + +import { fileExtension } from './listing-view.js'; + +export type PreviewKind = 'image' | 'text' | 'markdown' | 'code' | 'unsupported'; + +export type PreviewReason = + | 'folder' + | 'symlink' + | 'not-found' + | 'too-large' + | 'binary' + | 'decode-failed' + | 'unsupported-type'; + +export type PreviewTarget = { + path: string; + name: string; + size: number; + modified?: string; +}; + +type PreviewBase = { + path: string; + name: string; + size: number; + modified?: string; +}; + +export type PreviewResult = + | (PreviewBase & { kind: 'image'; dataUrl: string; width: number; height: number }) + | (PreviewBase & { kind: 'text' | 'markdown' | 'code'; text: string; truncated: boolean }) + | (PreviewBase & { kind: 'unsupported'; reason: PreviewReason }); + +/** Decode caps live in main; the classifier is extension-only. */ +export const PREVIEW_IMAGE_MAX_BYTES = 32 * 1024 * 1024; +export const PREVIEW_IMAGE_MAX_EDGE = 4096; +export const PREVIEW_TEXT_MAX_BYTES = 1024 * 1024; + +const IMAGE_EXTENSIONS = new Set(['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'ico']); +const MARKDOWN_EXTENSIONS = new Set(['md', 'markdown']); +const TEXT_EXTENSIONS = new Set(['txt', 'log', 'csv']); +const CODE_EXTENSIONS = new Set([ + 'ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json', 'jsonc', 'css', 'scss', 'sass', 'less', + 'html', 'htm', 'xml', 'yml', 'yaml', 'toml', 'ini', 'cfg', 'conf', 'py', 'rb', 'php', + 'go', 'rs', 'java', 'kt', 'c', 'h', 'cpp', 'hpp', 'cs', 'swift', 'sql', 'sh', 'bash', + 'zsh', 'ps1', 'bat', 'cmd', 'vue', 'svelte', 'graphql', 'gql' +]); +const TEXT_NAMES = new Set([ + 'license', 'licence', 'readme', 'changelog', 'copying', 'notice', '.gitignore', + '.editorconfig' +]); +const CODE_NAMES = new Set(['dockerfile', 'makefile']); + +export function previewKindFor( + name: string, + kind: 'file' | 'directory' | 'symlink' +): PreviewKind { + if (kind !== 'file') return 'unsupported'; + const base = (name.split(/[/\\]/).pop() ?? name).toLowerCase(); + const ext = fileExtension(base); + if (IMAGE_EXTENSIONS.has(ext)) return 'image'; + if (MARKDOWN_EXTENSIONS.has(ext)) return 'markdown'; + if (TEXT_EXTENSIONS.has(ext)) return 'text'; + if (CODE_EXTENSIONS.has(ext)) return 'code'; + if (TEXT_NAMES.has(base)) return 'text'; + if (CODE_NAMES.has(base)) return 'code'; + return 'unsupported'; +} diff --git a/tests/preview.test.ts b/tests/preview.test.ts new file mode 100644 index 0000000..6bc4594 --- /dev/null +++ b/tests/preview.test.ts @@ -0,0 +1,51 @@ +import { describe, expect, it } from 'vitest'; +import { + PREVIEW_IMAGE_MAX_BYTES, + PREVIEW_IMAGE_MAX_EDGE, + PREVIEW_TEXT_MAX_BYTES, + previewKindFor +} from '../src/shared/preview.js'; + +describe('previewKindFor', () => { + it('classifies every allowed extension, case-insensitively', () => { + for (const name of ['a.jpg', 'b.JPEG', 'c.Png', 'd.gif', 'e.webp', 'f.bmp', 'g.ico']) { + expect(previewKindFor(name, 'file')).toBe('image'); + } + for (const name of ['notes.md', 'GUIDE.Markdown']) { + expect(previewKindFor(name, 'file')).toBe('markdown'); + } + for (const name of ['a.txt', 'b.log', 'c.CSV']) { + expect(previewKindFor(name, 'file')).toBe('text'); + } + for (const name of ['a.ts', 'b.TSX', 'c json.json', 'styles.css', 'main.py', 'run.SH', 'x.yaml', 'qa.htm']) { + expect(previewKindFor(name, 'file')).toBe('code'); + } + }); + + it('recognises well-known extension-less names', () => { + for (const name of ['LICENSE', 'readme', 'CHANGELOG', '.gitignore', '.editorconfig', 'NOTICE']) { + expect(previewKindFor(name, 'file')).toBe('text'); + } + for (const name of ['Dockerfile', 'Makefile']) { + expect(previewKindFor(name, 'file')).toBe('code'); + } + }); + + it('refuses unknown types and non-files', () => { + expect(previewKindFor('archive.zip', 'file')).toBe('unsupported'); + expect(previewKindFor('drawing.svg', 'file')).toBe('unsupported'); + expect(previewKindFor('photo.jpg', 'directory')).toBe('unsupported'); + expect(previewKindFor('photo.jpg', 'symlink')).toBe('unsupported'); + }); + + it('classifies by extension only, regardless of size', () => { + expect(previewKindFor('huge.png', 'file')).toBe('image'); + expect(previewKindFor('empty.txt', 'file')).toBe('text'); + }); + + it('exposes the byte and pixel caps', () => { + expect(PREVIEW_IMAGE_MAX_BYTES).toBe(32 * 1024 * 1024); + expect(PREVIEW_IMAGE_MAX_EDGE).toBe(4096); + expect(PREVIEW_TEXT_MAX_BYTES).toBe(1024 * 1024); + }); +}); From 1c5268fd398c2f750a3ad1f408bc0e7053081f5c Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:14:36 +0000 Subject: [PATCH 05/18] feat(preview): bounded main-process preview reader --- src/main/preview-fs.ts | 102 ++++++++++++++++++++++++++++++++ src/main/thumbnails.ts | 42 +++++++------- tests/preview-fs.test.ts | 122 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+), 20 deletions(-) create mode 100644 src/main/preview-fs.ts create mode 100644 tests/preview-fs.test.ts diff --git a/src/main/preview-fs.ts b/src/main/preview-fs.ts new file mode 100644 index 0000000..514b012 --- /dev/null +++ b/src/main/preview-fs.ts @@ -0,0 +1,102 @@ +import { lstat, open } from 'node:fs/promises'; +import { basename } from 'node:path'; +import { + PREVIEW_IMAGE_MAX_BYTES, + PREVIEW_IMAGE_MAX_EDGE, + PREVIEW_TEXT_MAX_BYTES, + previewKindFor, + type PreviewReason, + type PreviewResult +} from '../shared/preview.js'; +import { resolveLocalPath } from './local-fs.js'; +import { decodeImage, type DecodedImage } from './thumbnails.js'; + +export type PreviewDeps = { + decodeImage: (target: string, edge: number) => Promise; +}; + +const BINARY_SNIFF_BYTES = 8 * 1024; + +function unsupported( + path: string, + name: string, + size: number, + reason: PreviewReason, + modified?: string +): PreviewResult { + return { kind: 'unsupported', path, name, size, modified, reason }; +} + +function errorCode(error: unknown): string | undefined { + return typeof error === 'object' && error !== null + ? (error as NodeJS.ErrnoException).code + : undefined; +} + +async function readText( + target: string, + name: string, + size: number, + modified: string | undefined, + kind: 'text' | 'markdown' | 'code' +): Promise { + const limit = Math.min(size, PREVIEW_TEXT_MAX_BYTES); + const handle = await open(target, 'r'); + try { + const buffer = Buffer.alloc(limit); + const { bytesRead } = await handle.read(buffer, 0, limit, 0); + const bytes = buffer.subarray(0, bytesRead); + if (bytes.subarray(0, BINARY_SNIFF_BYTES).includes(0)) { + return unsupported(target, name, size, 'binary', modified); + } + const text = new TextDecoder('utf-8').decode(bytes); + return { + kind, + path: target, + name, + size, + modified, + text, + truncated: size > PREVIEW_TEXT_MAX_BYTES + }; + } finally { + await handle.close(); + } +} + +/** + * Classify, validate and read one local file for the preview pane. + * Invalid paths reject; everything else is reported as an `unsupported` result. + */ +export async function readPreview( + path: unknown, + deps: PreviewDeps = { decodeImage } +): Promise { + const target = resolveLocalPath(path); + const name = basename(target); + let info; + try { + info = await lstat(target); + } catch (error) { + if (errorCode(error) === 'ENOENT') return unsupported(target, name, 0, 'not-found'); + throw error; + } + const modified = info.mtime.toISOString(); + if (info.isSymbolicLink()) return unsupported(target, name, 0, 'symlink', modified); + if (info.isDirectory()) return unsupported(target, name, 0, 'folder', modified); + if (!info.isFile()) return unsupported(target, name, 0, 'unsupported-type', modified); + + const kind = previewKindFor(name, 'file'); + if (kind === 'unsupported') { + return unsupported(target, name, info.size, 'unsupported-type', modified); + } + if (kind === 'image') { + if (info.size > PREVIEW_IMAGE_MAX_BYTES) { + return unsupported(target, name, info.size, 'too-large', modified); + } + const decoded = await deps.decodeImage(target, PREVIEW_IMAGE_MAX_EDGE); + if (!decoded) return unsupported(target, name, info.size, 'decode-failed', modified); + return { kind: 'image', path: target, name, size: info.size, modified, ...decoded }; + } + return readText(target, name, info.size, modified, kind); +} diff --git a/src/main/thumbnails.ts b/src/main/thumbnails.ts index df71308..c4b61c6 100644 --- a/src/main/thumbnails.ts +++ b/src/main/thumbnails.ts @@ -9,11 +9,13 @@ export type ThumbnailResult = { height: number; }; +export type DecodedImage = ThumbnailResult; + /** * Ask the OS thumbnailer first (Windows shell / macOS Quick Look): it runs off * the main thread and reuses the system thumbnail cache. Linux has no such * API, and the OS may have no handler for a format, so fall back to a full - * decode — synchronous, but bounded by THUMBNAIL_MAX_BYTES. + * decode — synchronous, but bounded by the caller's size cap. */ async function decode(target: string, edge: number): Promise { if (process.platform === 'win32' || process.platform === 'darwin') { @@ -27,6 +29,24 @@ async function decode(target: string, edge: number): Promise return nativeImage.createFromPath(target); } +/** Decode a local image at `edge` and return a data URL scaled to fit. */ +export async function decodeImage(target: string, edge: number): Promise { + const image = await decode(target, edge); + if (!image || image.isEmpty()) return null; + const size = image.getSize(); + if (!size.width || !size.height) return null; + const longest = Math.max(size.width, size.height); + const scaled = + longest > edge + ? image.resize({ + width: Math.max(1, Math.round((size.width * edge) / longest)), + height: Math.max(1, Math.round((size.height * edge) / longest)) + }) + : image; + const out = scaled.getSize(); + return { dataUrl: scaled.toDataURL(), width: out.width, height: out.height }; +} + /** * Decode a local image via Electron nativeImage and return a small data URL. * Returns null when the path is ineligible or cannot be decoded. @@ -43,23 +63,5 @@ export async function readThumbnail(path: unknown, maxEdge = 256): Promise THUMBNAIL_MAX_BYTES) return null; - - const image = await decode(target, edge); - if (!image || image.isEmpty()) return null; - const size = image.getSize(); - if (!size.width || !size.height) return null; - const longest = Math.max(size.width, size.height); - const scaled = - longest > edge - ? image.resize({ - width: Math.max(1, Math.round((size.width * edge) / longest)), - height: Math.max(1, Math.round((size.height * edge) / longest)) - }) - : image; - const out = scaled.getSize(); - return { - dataUrl: scaled.toDataURL(), - width: out.width, - height: out.height - }; + return decodeImage(target, edge); } diff --git a/tests/preview-fs.test.ts b/tests/preview-fs.test.ts new file mode 100644 index 0000000..fe309ef --- /dev/null +++ b/tests/preview-fs.test.ts @@ -0,0 +1,122 @@ +import { mkdtempSync, mkdirSync, rmSync, truncateSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { PREVIEW_IMAGE_MAX_BYTES, PREVIEW_TEXT_MAX_BYTES } from '../src/shared/preview.js'; + +vi.mock('electron', () => ({ + nativeImage: { + createFromPath: () => null, + createThumbnailFromPath: async () => null + } +})); + +const { readPreview } = await import('../src/main/preview-fs.js'); + +const fakeImage = async () => ({ dataUrl: 'data:image/png;base64,AA', width: 10, height: 10 }); +const noImage = async () => null; +const deps = { decodeImage: fakeImage }; + +let root: string; + +beforeEach(() => { + root = mkdtempSync(join(tmpdir(), 'zerog-preview-')); +}); +afterEach(() => { + rmSync(root, { recursive: true, force: true }); +}); + +describe('readPreview', () => { + it('returns UTF-8 text and strips a byte-order mark', async () => { + const file = join(root, 'note.md'); + writeFileSync(file, '\uFEFF# Title\n\nBody'); + const result = await readPreview(file, deps); + expect(result.kind).toBe('markdown'); + if (result.kind !== 'markdown') throw new Error('unreachable'); + expect(result.text).toBe('# Title\n\nBody'); + expect(result.truncated).toBe(false); + expect(result.size).toBe(Buffer.byteLength('\uFEFF# Title\n\nBody')); + }); + + it('truncates text at the cap and reports it', async () => { + const file = join(root, 'big.txt'); + writeFileSync(file, Buffer.alloc(PREVIEW_TEXT_MAX_BYTES + 10, 0x61)); + const result = await readPreview(file, deps); + if (result.kind !== 'text') throw new Error('expected text'); + expect(result.truncated).toBe(true); + expect(result.text.length).toBe(PREVIEW_TEXT_MAX_BYTES); + }); + + it('refuses binary content', async () => { + const file = join(root, 'blob.log'); + writeFileSync(file, Buffer.from([0x41, 0x00, 0x42])); + const result = await readPreview(file, deps); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'binary' }); + }); + + it('reads source code without truncation', async () => { + const file = join(root, 'main.ts'); + writeFileSync(file, 'export const answer = 42;\n'); + const result = await readPreview(file, deps); + expect(result).toMatchObject({ kind: 'code', truncated: false }); + }); + + it('reports a missing file instead of rejecting', async () => { + const result = await readPreview(join(root, 'gone.txt'), deps); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'not-found' }); + }); + + it('reports folders', async () => { + const dir = join(root, 'folder'); + mkdirSync(dir); + const result = await readPreview(dir, deps); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'folder' }); + }); + + it('rejects relative paths', async () => { + await expect(readPreview('relative.txt', deps)).rejects.toThrow(/absolute/i); + }); + + it('decodes images through the injected decoder', async () => { + const file = join(root, 'photo.png'); + writeFileSync(file, Buffer.from([0x89, 0x50, 0x4e, 0x47])); + const result = await readPreview(file, deps); + expect(result).toMatchObject({ + kind: 'image', + dataUrl: 'data:image/png;base64,AA', + width: 10, + height: 10 + }); + }); + + it('refuses images over the byte cap before decoding', async () => { + const file = join(root, 'huge.png'); + writeFileSync(file, ''); + truncateSync(file, PREVIEW_IMAGE_MAX_BYTES + 1); + const result = await readPreview(file, { decodeImage: noImage }); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'too-large' }); + }); + + it('reports failed decodes', async () => { + const file = join(root, 'broken.gif'); + writeFileSync(file, Buffer.from([0x47, 0x49, 0x46])); + const result = await readPreview(file, { decodeImage: noImage }); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'decode-failed' }); + }); + + it('reports unsupported types', async () => { + const file = join(root, 'data.zip'); + writeFileSync(file, 'PK'); + const result = await readPreview(file, deps); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'unsupported-type' }); + }); + + it.runIf(process.platform !== 'win32')('refuses symlinks', async () => { + const target = join(root, 'real.txt'); + writeFileSync(target, 'x'); + const link = join(root, 'link.txt'); + (await import('node:fs')).symlinkSync(target, link); + const result = await readPreview(link, deps); + expect(result).toMatchObject({ kind: 'unsupported', reason: 'symlink' }); + }); +}); From fe58078d1f4b3f70a62b033173b66918682d6d24 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:17:30 +0000 Subject: [PATCH 06/18] fix(preview): accumulate short reads in text preview --- src/main/preview-fs.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/preview-fs.ts b/src/main/preview-fs.ts index 514b012..7b2b203 100644 --- a/src/main/preview-fs.ts +++ b/src/main/preview-fs.ts @@ -44,8 +44,17 @@ async function readText( const handle = await open(target, 'r'); try { const buffer = Buffer.alloc(limit); - const { bytesRead } = await handle.read(buffer, 0, limit, 0); - const bytes = buffer.subarray(0, bytesRead); + // A single pread may return fewer than `limit` bytes (short read), and a + // short read would otherwise pass as a complete document because + // `truncated` is derived from the stat size. Accumulate until the cap or + // EOF, advancing the position by what we actually got. + let total = 0; + while (total < limit) { + const { bytesRead } = await handle.read(buffer, total, limit - total, total); + if (bytesRead === 0) break; + total += bytesRead; + } + const bytes = buffer.subarray(0, total); if (bytes.subarray(0, BINARY_SNIFF_BYTES).includes(0)) { return unsupported(target, name, size, 'binary', modified); } From 22c24d2c3d5d1a2b054b6d6e43a3c8198fdf945b Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:19:14 +0000 Subject: [PATCH 07/18] feat(preview): expose preview and web-link IPC --- src/main/main.ts | 8 ++++++++ src/main/preload.cjs | 2 ++ src/shared/open-url.ts | 13 +++++++++++++ src/shared/types.ts | 6 ++++++ tests/open-url.test.ts | 24 ++++++++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 src/shared/open-url.ts create mode 100644 tests/open-url.test.ts diff --git a/src/main/main.ts b/src/main/main.ts index 06dd47e..331296b 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -36,8 +36,10 @@ import { resolveLocalPath, searchLocalShallow } from './local-fs.js'; +import { readPreview } from './preview-fs.js'; import { defaultSecretsPath, SecretStore, SPEECH_API_KEY } from './secret-store.js'; import { spawnDetached } from './safe-spawn.js'; +import { safeExternalUrl } from '../shared/open-url.js'; import { openSystemTerminal, openTerminalForPath } from './terminal-launch.js'; import { readThumbnail } from './thumbnails.js'; import type { FileEntry, SpeechApiKeyStatus } from '../shared/types.js'; @@ -169,6 +171,7 @@ handle('fs:search', (_e, path: unknown, maxDepth?: unknown) => handle('fs:thumbnail', (_e, path: unknown, maxEdge?: unknown) => readThumbnail(path, typeof maxEdge === 'number' ? maxEdge : 256) ); +handle('fs:preview', (_e, path: unknown) => readPreview(path)); handle('fs:mkdir', (_e, path: unknown) => createLocalDirectory(String(path))); handle('fs:create-file', (_e, path: unknown, content?: unknown) => createLocalFile(String(path), typeof content === 'string' ? content : '') @@ -197,6 +200,11 @@ handle('shell:openPath', async (_e, path: unknown) => { handle('shell:showItem', (_e, path: unknown) => { shell.showItemInFolder(resolveLocalPath(path)); }); +handle('shell:openUrl', async (_e, url: unknown) => { + const safe = safeExternalUrl(url); + if (!safe) throw new Error('Only web links can be opened.'); + await shell.openExternal(safe); +}); handle('shell:openWith', async (_e, path: unknown, appName: unknown) => { const target = resolveLocalPath(path); const which = typeof appName === 'string' ? appName.trim().toLowerCase() : 'default'; diff --git a/src/main/preload.cjs b/src/main/preload.cjs index b240b4c..db26535 100644 --- a/src/main/preload.cjs +++ b/src/main/preload.cjs @@ -4,6 +4,7 @@ contextBridge.exposeInMainWorld('fileman', { listLocalDirectory: (path) => ipcRenderer.invoke('fs:list', path), searchLocalShallow: (path, maxDepth) => ipcRenderer.invoke('fs:search', path, maxDepth), readThumbnail: (path, maxEdge) => ipcRenderer.invoke('fs:thumbnail', path, maxEdge), + previewFile: (path) => ipcRenderer.invoke('fs:preview', path), createLocalDirectory: (path) => ipcRenderer.invoke('fs:mkdir', path), createLocalFile: (path, content) => ipcRenderer.invoke('fs:create-file', path, content), renameLocalEntry: (from, to) => ipcRenderer.invoke('fs:rename', from, to), @@ -19,6 +20,7 @@ contextBridge.exposeInMainWorld('fileman', { copyText: (text) => ipcRenderer.invoke('clipboard:write', text), openPath: (path) => ipcRenderer.invoke('shell:openPath', path), showItemInFolder: (path) => ipcRenderer.invoke('shell:showItem', path), + openExternalUrl: (url) => ipcRenderer.invoke('shell:openUrl', url), openWith: (path, app) => ipcRenderer.invoke('shell:openWith', path, app), detectFileApps: (root) => ipcRenderer.invoke('apps:detect', root), openWithApp: (request) => ipcRenderer.invoke('apps:open', request), diff --git a/src/shared/open-url.ts b/src/shared/open-url.ts new file mode 100644 index 0000000..19d387c --- /dev/null +++ b/src/shared/open-url.ts @@ -0,0 +1,13 @@ +/** Only absolute web links may be handed to the system browser. */ +export function safeExternalUrl(value: unknown): string | null { + if (typeof value !== 'string' || !value || value.length > 2048) return null; + let url: URL; + try { + url = new URL(value); + } catch { + return null; + } + if (url.protocol !== 'http:' && url.protocol !== 'https:') return null; + if (url.username || url.password) return null; + return url.href; +} diff --git a/src/shared/types.ts b/src/shared/types.ts index 6a3432f..5f4e7a9 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -4,9 +4,11 @@ import type { DetectedApp } from './file-apps.js'; import type { ServerTranscriptionInput } from './speech-server.js'; import type { TerminalLauncher } from './terminal-launcher.js'; import type { UpdateState } from './update.js'; +import type { PreviewKind, PreviewResult, PreviewTarget } from './preview.js'; export type { Favorite }; export type { TerminalLauncher, TerminalPrefs } from './terminal-launcher.js'; +export type { PreviewKind, PreviewResult, PreviewTarget }; export interface FileEntry { name: string; @@ -77,6 +79,8 @@ export interface FileManApi { listLocalDirectory(path?: string): Promise; searchLocalShallow(path: string, maxDepth?: number): Promise; readThumbnail(path: string, maxEdge?: number): Promise; + /** Bounded, read-only preview payload (image / text / unsupported). */ + previewFile(path: string): Promise; createLocalDirectory(path: string): Promise; createLocalFile(path: string, content?: string): Promise; renameLocalEntry(from: string, to: string): Promise; @@ -93,6 +97,8 @@ export interface FileManApi { copyText(text: string): Promise; openPath(path: string): Promise; showItemInFolder(path: string): Promise; + /** Open an http(s) link from previewed Markdown in the system browser. */ + openExternalUrl(url: string): Promise; openWith(path: string, app: OpenWithApp | string): Promise; /** Scan the development store for apps that declare file associations. */ detectFileApps(root?: string): Promise; diff --git a/tests/open-url.test.ts b/tests/open-url.test.ts new file mode 100644 index 0000000..d99cf81 --- /dev/null +++ b/tests/open-url.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from 'vitest'; +import { safeExternalUrl } from '../src/shared/open-url.js'; + +describe('safeExternalUrl', () => { + it('accepts absolute http and https links', () => { + expect(safeExternalUrl('https://example.com/a?b=1')).toBe('https://example.com/a?b=1'); + expect(safeExternalUrl('http://localhost:8080/')).toBe('http://localhost:8080/'); + }); + + it('rejects other schemes and credentials', () => { + expect(safeExternalUrl('javascript:alert(1)')).toBeNull(); + expect(safeExternalUrl('file:///C:/Windows/win.ini')).toBeNull(); + expect(safeExternalUrl('data:text/html,hi')).toBeNull(); + expect(safeExternalUrl('https://user:pass@example.com/')).toBeNull(); + }); + + it('rejects junk values', () => { + expect(safeExternalUrl(null)).toBeNull(); + expect(safeExternalUrl(42)).toBeNull(); + expect(safeExternalUrl('')).toBeNull(); + expect(safeExternalUrl('not a url')).toBeNull(); + expect(safeExternalUrl(`https://example.com/${'a'.repeat(2048)}`)).toBeNull(); + }); +}); From a27c5731b2e9e4dbe95de4a1cc91dbee679255d0 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:21:57 +0000 Subject: [PATCH 08/18] feat(preview): react preview pane for images, text, markdown and code --- package-lock.json | 1589 +++++++++++++++++++++++++++++++-- package.json | 4 +- src/renderer/preview-pane.tsx | 202 +++++ src/renderer/styles.css | 100 +++ 4 files changed, 1832 insertions(+), 63 deletions(-) create mode 100644 src/renderer/preview-pane.tsx diff --git a/package-lock.json b/package-lock.json index b957246..927bf39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,9 @@ "@huggingface/transformers": "^4.3.2", "electron-updater": "^6.8.11", "react": "^19.1.1", - "react-dom": "^19.1.1" + "react-dom": "^19.1.1", + "react-markdown": "^10.1.0", + "remark-gfm": "^4.0.1" }, "bin": { "zerogfileman": "bin/zerogfileman.cjs" @@ -2437,7 +2439,6 @@ "version": "4.1.13", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", - "dev": true, "license": "MIT", "dependencies": { "@types/ms": "*" @@ -2454,9 +2455,17 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", - "dev": true, "license": "MIT" }, + "node_modules/@types/estree-jsx": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree-jsx/-/estree-jsx-1.0.5.tgz", + "integrity": "sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==", + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/@types/fs-extra": { "version": "9.0.13", "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", @@ -2467,6 +2476,15 @@ "@types/node": "*" } }, + "node_modules/@types/hast": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz", + "integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/http-cache-semantics": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", @@ -2484,11 +2502,19 @@ "@types/node": "*" } }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/ms": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", - "dev": true, "license": "MIT" }, "node_modules/@types/node": { @@ -2504,7 +2530,6 @@ "version": "19.3.0", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", - "dev": true, "license": "MIT", "dependencies": { "csstype": "^3.2.2" @@ -2530,6 +2555,18 @@ "@types/node": "*" } }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/@ungap/structured-clone": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz", + "integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==", + "license": "ISC" + }, "node_modules/@vitejs/plugin-react": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz", @@ -3047,6 +3084,16 @@ "dev": true, "license": "MIT" }, + "node_modules/bail": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", + "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -3284,6 +3331,16 @@ ], "license": "CC-BY-4.0" }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/chai": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", @@ -3331,6 +3388,46 @@ "node": ">=8" } }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-reference-invalid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", + "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/check-error": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz", @@ -3435,6 +3532,16 @@ "node": ">= 0.8" } }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/commander": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", @@ -3552,7 +3659,6 @@ "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", - "dev": true, "license": "MIT" }, "node_modules/debug": { @@ -3572,6 +3678,19 @@ } } }, + "node_modules/decode-named-character-reference": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz", + "integrity": "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==", + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/decompress-response": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", @@ -3665,6 +3784,15 @@ "node": ">=0.4.0" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -3682,6 +3810,19 @@ "license": "MIT", "optional": true }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/dir-compare": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-4.2.0.tgz", @@ -4141,6 +4282,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/estree-util-is-identifier-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", + "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", @@ -4168,6 +4319,12 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "license": "MIT" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4604,6 +4761,46 @@ "node": ">= 0.4" } }, + "node_modules/hast-util-to-jsx-runtime": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.7.tgz", + "integrity": "sha512-F7DNV2NMcTxA4GqPVHnXzX+mpoPHAIY9rJAVH3CZ1FdBZOcBUEjUuvMkMpHVs/sicEtznh9tMGj5WUR9S4E2rg==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "devlop": "^1.0.0", + "estree-util-is-identifier-name": "^3.0.0", + "hast-util-whitespace": "^3.0.0", + "mdast-util-mdx-expression": "^2.0.0", + "mdast-util-mdx-jsx": "^3.0.0", + "mdast-util-mdxjs-esm": "^2.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "style-to-object": "^2.0.0", + "unist-util-position": "^5.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hosted-git-info": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", @@ -4637,6 +4834,16 @@ "dev": true, "license": "ISC" }, + "node_modules/html-url-attributes": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", + "integrity": "sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/http-cache-semantics": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.3.0.tgz", @@ -4705,6 +4912,46 @@ "dev": true, "license": "ISC" }, + "node_modules/inline-style-parser": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.9.tgz", + "integrity": "sha512-IttN8BqKLxzUrnTqHI+/hwAJQItBAUjdoHERCDv+oOuX48VP6bzW8+QjOXSfoevzq3YrYAwX1uLHp8TqO9yIeg==", + "license": "MIT" + }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -4715,6 +4962,28 @@ "node": ">=8" } }, + "node_modules/is-hexadecimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz", + "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-plain-obj": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", + "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -4904,6 +5173,16 @@ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", "license": "Apache-2.0" }, + "node_modules/longest-streak": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", + "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/loupe": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", @@ -4941,6 +5220,16 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/markdown-table": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.1.0.tgz", + "integrity": "sha512-xpeSCdM+B+6P3ncfgaB7FoDbtJ30xAe6Z18TGT7AgXJsHqCElCICZovQqdRMm7kHgpTyYv36EupqewoFFSB8vw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/matcher": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/matcher/-/matcher-4.0.0.tgz", @@ -4966,89 +5255,959 @@ "node": ">= 0.4" } }, - "node_modules/mime": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", - "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", - "dev": true, + "node_modules/mdast-util-find-and-replace": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.5.tgz", + "integrity": "sha512-of3wZLEBWpK8mSYy8wmKnwyxfUKjhCkXxGLz45DVBqfcahTP37LscCK+0oAZh+ReZ5OunPDkB2zdGMIxrojLhw==", "license": "MIT", - "bin": { - "mime": "cli.js" + "dependencies": { + "@types/mdast": "^4.0.0", + "escape-string-regexp": "^5.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.1.0" }, - "engines": { - "node": ">=4.0.0" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, + "node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", "license": "MIT", "engines": { - "node": ">= 0.6" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, + "node_modules/mdast-util-from-markdown": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.1.0.tgz", + "integrity": "sha512-KRLgmPaP2H1ul2bpoJkOS+9pAcDAAj9Nu1mqLnh8NLeJG5tlvj42TH80PIGBpROWlRXLk0lDrWNuZCFy/tsB4A==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz", + "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==", "license": "MIT", "dependencies": { - "mime-db": "1.52.0" + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm-autolink-literal": "^2.0.0", + "mdast-util-gfm-footnote": "^2.0.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" }, - "engines": { - "node": ">= 0.6" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", - "dev": true, + "node_modules/mdast-util-gfm-autolink-literal": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.1.2.tgz", + "integrity": "sha512-rAlbZBGZfv2YRr6lSFGHTN305KkNawOYRRlbldFyPHnTlHJZwlGdzVwyIDvr3fxbhRbmJOSZc06c8H5Fgfu8Ng==", "license": "MIT", - "engines": { - "node": ">=4" + "dependencies": { + "@types/mdast": "^4.0.0", + "ccount": "^2.0.0", + "devlop": "^1.0.0", + "mdast-util-find-and-replace": "^3.0.0", + "micromark-util-character": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", - "dev": true, - "license": "BlueOak-1.0.0", + "node_modules/mdast-util-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==", + "license": "MIT", "dependencies": { - "brace-expansion": "^5.0.8" - }, - "engines": { - "node": "18 || 20 || >=22" + "@types/mdast": "^4.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, + "node_modules/mdast-util-gfm-strikethrough": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.1.tgz", + "integrity": "sha512-OuJHqvr455pwu2OaOrir7dbzqs4jlWKOtlu9L6GjcIjjQwNyw02VntQsr/Ek6/A13vgnXfUhBekWRUP1OkNivw==", "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minipass": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", - "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=16 || 14 >=14.17" + "node_modules/mdast-util-gfm-table": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.1.tgz", + "integrity": "sha512-fiIjPrAy4kz68/eFbPHhsiWDGHhqUSVoU1XsfLM5DsEPXw7MxgiVVyulUggFRckVWeT1KXQXkg5vm3kv4oMSOA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "mdast-util-to-string": "^4.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/minizlib": { + "node_modules/mdast-util-gfm-task-list-item": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.1.tgz", + "integrity": "sha512-jXVO1hvB2hs82g1esi7I9nIJDqiijbQLIyH2jDUb5s7jIAZMr/79h0VHSq7XHKTqpLARRm+DDNjduB7S9+6XZA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdx-expression": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz", + "integrity": "sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==", + "license": "MIT", + "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdx-jsx": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.2.2.tgz", + "integrity": "sha512-/0FHaZMv2fSjIL3z/NYmXnQTSdzYyamPpI1BXpSCngTUqpSvMNIlERa26ABz+Z6UFQbrh3I5Yhzp448WZsPfMA==", + "license": "MIT", + "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "parse-entities": "^4.0.0", + "stringify-entities": "^4.0.0", + "unist-util-stringify-position": "^4.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdxjs-esm": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz", + "integrity": "sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==", + "license": "MIT", + "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.2.tgz", + "integrity": "sha512-l2pnmOuqs+SGLVpTVXnRLQu5v1AzvDe181404fbXzzqObVxrAnnVxapAP27pUwzLBL/ABIkgUhGlPVU7QSvIFg==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-markdown": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.2.5.tgz", + "integrity": "sha512-mxOMQQ8NgisvTarkSUqZwi6GmzNo490V932DpEK/0+OETIeVJBzq4QuMt45fqqcsF5EYMlJENjSSAZxh89VJsg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.3.tgz", + "integrity": "sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-edit-map": "^1.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.4.tgz", + "integrity": "sha512-wxEeE8v8XVvOrxn1TZj74qYhAtTQsSqufHVS3uNVyT1MupXxhyaHk8/9xDNPh9BmL77QNDgWTkZ3RsYHB2ry7w==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.1.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-edit-map": "^1.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.3" + } + }, + "node_modules/micromark-extension-gfm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz", + "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==", + "license": "MIT", + "dependencies": { + "micromark-extension-gfm-autolink-literal": "^2.0.0", + "micromark-extension-gfm-footnote": "^2.0.0", + "micromark-extension-gfm-strikethrough": "^2.0.0", + "micromark-extension-gfm-table": "^2.0.0", + "micromark-extension-gfm-tagfilter": "^2.0.0", + "micromark-extension-gfm-task-list-item": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-autolink-literal": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", + "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-strikethrough": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz", + "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-table": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.2.tgz", + "integrity": "sha512-pRzm4kDTu0MjlmBkxmS9yYhw60nncfcEwu9NNdPFSQEFXS95ZKyIIyTSHu/o3ReBUrLKYEq+7YaXCRn/bPB4MA==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-tagfilter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz", + "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==", + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-task-list-item": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz", + "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.1.0.tgz", + "integrity": "sha512-fS8hnLIjnjvdQIj39Geug8wWsR0HrYZ43KShKxNfwT7t2LOHo/LbWZEzEaSOjwtjdCsjoE6syHhonEzW0zv0+Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-edit-map": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-edit-map/-/micromark-util-edit-map-1.0.0.tgz", + "integrity": "sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.3.tgz", + "integrity": "sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minizlib": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", @@ -5367,6 +6526,31 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-entities": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.2.tgz", + "integrity": "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^2.0.0", + "character-entities-legacy": "^3.0.0", + "character-reference-invalid": "^2.0.0", + "decode-named-character-reference": "^1.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0", + "is-hexadecimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/parse-entities/node_modules/@types/unist": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", + "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", + "license": "MIT" + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -5593,6 +6777,16 @@ "signal-exit": "^3.0.2" } }, + "node_modules/property-information": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz", + "integrity": "sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/protobufjs": { "version": "7.6.6", "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.6.6.tgz", @@ -5681,6 +6875,33 @@ "react": "^19.3.1" } }, + "node_modules/react-markdown": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", + "integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "hast-util-to-jsx-runtime": "^2.0.0", + "html-url-attributes": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.0.0", + "unified": "^11.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + }, + "peerDependencies": { + "@types/react": ">=18", + "react": ">=18" + } + }, "node_modules/react-refresh": { "version": "0.17.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz", @@ -5720,6 +6941,72 @@ "util-deprecate": "~1.0.1" } }, + "node_modules/remark-gfm": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", + "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-gfm": "^3.0.0", + "micromark-extension-gfm": "^3.0.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-parse": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz", + "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-rehype": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-11.1.2.tgz", + "integrity": "sha512-Dh7l57ianaEoIpzbp0PC9UKAdCSVklD8E5Rpw7ETfbTl3FqcOOgq5q2LVDhgGCkaBv7p24JXikPdvhhmHvKMsw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "mdast-util-to-hast": "^13.0.0", + "unified": "^11.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-stringify": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz", + "integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-to-markdown": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -6111,6 +7398,16 @@ "source-map": "^0.6.0" } }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/sprintf-js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", @@ -6168,6 +7465,20 @@ "node": ">=8" } }, + "node_modules/stringify-entities": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.5.tgz", + "integrity": "sha512-jNuI2fNNw5ecxrWmgm90R3iH0Kc/94AQwoQWoSUYphWzvmUA2pjFG34H56Z7Z3FkvH3FpYwwewKAa97oQnPFhw==", + "license": "MIT", + "dependencies": { + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -6201,6 +7512,15 @@ "dev": true, "license": "MIT" }, + "node_modules/style-to-object": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-2.0.2.tgz", + "integrity": "sha512-QmbXPUylqU80HAgTOJeEOdbA40W9KtxmjMhQy+tq+b8F2aoh3aQLuy82hh2jm2qsC9hR9eI0+eQidTMydKcqRA==", + "license": "MIT", + "dependencies": { + "inline-style-parser": "0.2.9" + } + }, "node_modules/sumchecker": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", @@ -6400,6 +7720,26 @@ "tree-kill": "cli.js" } }, + "node_modules/trim-lines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/trough": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz", + "integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/truncate-utf8-bytes": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz", @@ -6460,6 +7800,93 @@ "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", "license": "MIT" }, + "node_modules/unified": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", + "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "bail": "^2.0.0", + "devlop": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^4.0.0", + "trough": "^2.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-is": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz", + "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", + "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.2.0.tgz", + "integrity": "sha512-fpsYs/VVoZxfGY9/j3FQpZmN8wdLJaV1Pt38AaJNZu9uKIHcFU3halCdBveEq1HGKO1OEfJY65w1zvoFV1b3qQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.1.0.tgz", + "integrity": "sha512-vKXxz6O38sKDj1mtx/k2cWvkkFBuYGx6uGrlzBkVeWCRF/F8sdI0j3Wbkz/5rVNRRuVc8UrgRdbCxNhmYXgP3w==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", @@ -6543,6 +7970,34 @@ "dev": true, "license": "MIT" }, + "node_modules/vfile": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", + "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.4.tgz", + "integrity": "sha512-66ycRswIkNmHH9PHku7ADtv5RVwgIrOcuv3J8Svz6h4qgGRrKVa+9/neuKyJZUXyOpYwLTvS+whZ4R2urHHgQg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/vite": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.7.tgz", @@ -6854,6 +8309,16 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } } } } diff --git a/package.json b/package.json index a81c9ea..506f3d2 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,9 @@ "@huggingface/transformers": "^4.3.2", "electron-updater": "^6.8.11", "react": "^19.1.1", - "react-dom": "^19.1.1" + "react-dom": "^19.1.1", + "react-markdown": "^10.1.0", + "remark-gfm": "^4.0.1" }, "devDependencies": { "@fontsource-variable/inter": "^5.3.0", diff --git a/src/renderer/preview-pane.tsx b/src/renderer/preview-pane.tsx new file mode 100644 index 0000000..fa38943 --- /dev/null +++ b/src/renderer/preview-pane.tsx @@ -0,0 +1,202 @@ +import { useEffect, useRef, useState, type ReactNode } from 'react'; +import ReactMarkdown from 'react-markdown'; +import remarkGfm from 'remark-gfm'; +import type { PreviewReason, PreviewResult, PreviewTarget } from '../shared/preview.js'; +import { formatModified, formatSize } from '../shared/files.js'; +import { describeError } from '../shared/file-op.js'; +import { Icon } from './icons.js'; + +const REASONS: Record = { + folder: 'Folders have no preview.', + symlink: 'Symbolic links are not previewed.', + 'not-found': 'This file no longer exists.', + 'too-large': 'This image is too large to preview.', + binary: 'This file looks binary, not text.', + 'decode-failed': 'This image could not be decoded.', + 'unsupported-type': 'No preview for this file type.' +}; + +function sizeLabel(size: number, name: string): string { + return formatSize({ name, kind: 'file', size }); +} + +function kindLabel(result: PreviewResult | null): string { + if (!result) return 'File'; + if (result.kind === 'unsupported') return 'No preview'; + if (result.kind === 'image') return 'Image'; + if (result.kind === 'markdown') return 'Markdown'; + if (result.kind === 'code') return 'Source'; + return 'Text'; +} + +export function PreviewPane(props: { + target: PreviewTarget | null; + active: boolean; + onActivate: () => void; + onOpen: (path: string) => void; + onBrowseFolder: (path: string) => void; + onClose: () => void; +}) { + const { target, active, onActivate, onOpen, onBrowseFolder, onClose } = props; + const [result, setResult] = useState(null); + const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); + const [attempt, setAttempt] = useState(0); + const seq = useRef(0); + + useEffect(() => { + if (!target) { + setResult(null); + setError(null); + setLoading(false); + return; + } + const current = ++seq.current; + setLoading(true); + setError(null); + void window.fileman + .previewFile(target.path) + .then((next) => { + if (current !== seq.current) return; + setResult(next); + setLoading(false); + }) + .catch((reason: unknown) => { + if (current !== seq.current) return; + setResult(null); + setError(describeError(reason)); + setLoading(false); + }); + }, [target, attempt]); + + const name = result?.name ?? target?.name ?? ''; + const size = result?.size ?? target?.size ?? 0; + const modified = result?.modified ?? target?.modified; + + let body: ReactNode; + if (!target) { + body =
Select a file to preview.
; + } else if (loading) { + body =
Loading…
; + } else if (error) { + body = ( +
+

{error}

+ +
+ ); + } else if (!result) { + body =
No preview.
; + } else if (result.kind === 'unsupported') { + body = ( +
+

{REASONS[result.reason]}

+ {result.reason !== 'folder' && result.reason !== 'not-found' ? ( + + ) : null} +
+ ); + } else if (result.kind === 'image') { + body = ( +
+ {result.name} +
+ ); + } else { + const banner = result.truncated ? ( +
+ Showing the first 1 MiB of {sizeLabel(result.size, result.name)}. +
+ ) : null; + body = + result.kind === 'markdown' ? ( +
+ {banner} + + href && /^https?:\/\//i.test(href) ? ( + { + event.preventDefault(); + void window.fileman.openExternalUrl(href); + }} + > + {children} + + ) : ( + {children} + ) + }} + > + {result.text} + +
+ ) : ( + <> + {banner} +
{result.text}
+ + ); + } + + return ( +
+
+
+
+ + {active ? 'Active' : 'Idle'} + + + {name || 'Preview'} +
+
+ + + +
+
+
+ {target + ? `${kindLabel(result)} · ${sizeLabel(size, name)}${modified ? ` · ${formatModified(modified)}` : ''}` + : 'Right pane preview'} +
+
+
{body}
+
+ ); +} diff --git a/src/renderer/styles.css b/src/renderer/styles.css index cb513c3..9283552 100644 --- a/src/renderer/styles.css +++ b/src/renderer/styles.css @@ -610,6 +610,106 @@ select { 0 0 20px -3px var(--accent-soft); } +/* —— Preview pane —— */ +.preview-head-title { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; +} + +.preview-name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-family: var(--mono); + font-size: 12px; +} + +.preview-meta { + color: var(--muted); + font-size: 11px; + font-family: var(--mono); +} + +.preview-body { + flex: 1; + min-height: 0; + overflow: auto; + padding: 12px; + display: flex; + flex-direction: column; +} + +.preview-empty, +.preview-error { + margin: auto; + max-width: 36ch; + text-align: center; + color: var(--muted); + font-size: 13px; + line-height: 1.5; +} + +.preview-error button { + margin-top: 12px; +} + +.preview-banner { + margin-bottom: 8px; + padding: 6px 10px; + border: 1px solid var(--border); + border-radius: 6px; + background: color-mix(in srgb, var(--panel-2) 80%, transparent); + color: var(--muted); + font-size: 11px; + font-family: var(--mono); +} + +.preview-text { + margin: 0; + font-family: var(--mono); + font-size: 12px; + line-height: 1.55; + white-space: pre; + tab-size: 2; +} + +.preview-image-wrap { + flex: 1; + min-height: 0; + display: grid; + place-items: center; +} + +.preview-image-wrap img { + max-width: 100%; + max-height: 100%; + object-fit: contain; +} + +.preview-markdown { + max-width: 78ch; + font-size: 13px; + line-height: 1.6; +} + +.preview-markdown pre { + font-family: var(--mono); + font-size: 12px; + overflow: auto; +} + +.preview-markdown a { + color: var(--accent); +} + +.slot-modes { + display: flex; + align-items: center; + gap: 4px; +} + .pane-head { display: flex; flex-direction: column; From a09217630ae3bafe715d78532f9b2ed751340f5c Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:26:47 +0000 Subject: [PATCH 09/18] fix(preview): key pane fetch to path and reset stale state --- src/renderer/preview-pane.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/renderer/preview-pane.tsx b/src/renderer/preview-pane.tsx index fa38943..1580392 100644 --- a/src/renderer/preview-pane.tsx +++ b/src/renderer/preview-pane.tsx @@ -38,6 +38,7 @@ export function PreviewPane(props: { onClose: () => void; }) { const { target, active, onActivate, onOpen, onBrowseFolder, onClose } = props; + const path = target?.path ?? null; const [result, setResult] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); @@ -45,17 +46,22 @@ export function PreviewPane(props: { const seq = useRef(0); useEffect(() => { - if (!target) { + // Invalidate any in-flight response before the early return so a target + // cleared mid-fetch cannot be repopulated by the stale reply. + const current = ++seq.current; + if (!path) { setResult(null); setError(null); setLoading(false); return; } - const current = ++seq.current; - setLoading(true); + // Drop the previous file's payload so the header falls back to `target` + // metadata instead of showing stale name/size/modified while loading. + setResult(null); setError(null); + setLoading(true); void window.fileman - .previewFile(target.path) + .previewFile(path) .then((next) => { if (current !== seq.current) return; setResult(next); @@ -67,7 +73,7 @@ export function PreviewPane(props: { setError(describeError(reason)); setLoading(false); }); - }, [target, attempt]); + }, [path, attempt]); const name = result?.name ?? target?.name ?? ''; const size = result?.size ?? target?.size ?? 0; From 0e97dbe33c6deb69729e62063a16c2a1f7389160 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:30:45 +0000 Subject: [PATCH 10/18] feat(preview): right slot modes, follow-selection and cross-pane guards --- src/renderer/main.tsx | 286 ++++++++++++++++++++++++++++++------- src/shared/context-menu.ts | 2 + tests/context-menu.test.ts | 8 ++ 3 files changed, 243 insertions(+), 53 deletions(-) diff --git a/src/renderer/main.tsx b/src/renderer/main.tsx index c637d23..bf1341e 100644 --- a/src/renderer/main.tsx +++ b/src/renderer/main.tsx @@ -88,11 +88,15 @@ import { } from '../shared/pane-selection.js'; import { clampSplitRatio, + otherPaneIsListing, setLayout, + setRightSlot, toggleMaximize, workspaceGridTemplate, + type RightSlot, type WorkspaceLayoutState } from '../shared/pane-layout.js'; +import type { PreviewTarget } from '../shared/preview.js'; import { clampTranscriptHeight, effectiveTranscriptHeight, @@ -109,8 +113,14 @@ import type { import { shouldPrompt, type UpdateState } from '../shared/update.js'; import { shouldStopJewelOnRelease } from '../shared/voice-jewel.js'; import { Icon } from './icons.js'; -import { loadStoredWorkspaceLayout, storeWorkspaceLayout } from './layout-prefs.js'; +import { + loadStoredPreviewPath, + loadStoredWorkspaceLayout, + storeStoredPreviewPath, + storeWorkspaceLayout +} from './layout-prefs.js'; import { loadStoredListingPrefs, storePaneListingPrefs } from './listing-prefs.js'; +import { PreviewPane } from './preview-pane.js'; import { SpeechClient, type SpeechWorker } from './speech.js'; import { describeDownload, @@ -424,7 +434,12 @@ function FilePane(props: { terminalPrefs: TerminalPrefs; demoText: string; clipboard: FileClip | null; - otherPath: string; + otherPath: string | null; + slotControls?: { + mode: 'browse' | 'preview'; + onSelect: (mode: 'browse' | 'preview') => void; + onClose: () => void; + }; onActivate: () => void; onChange: (next: PaneState) => void; onLog: (message: string) => void; @@ -448,6 +463,7 @@ function FilePane(props: { demoText, clipboard, otherPath, + slotControls, onActivate, onChange, onLog, @@ -469,7 +485,7 @@ function FilePane(props: { .showContextMenu({ kind, canPaste: Boolean(clipboard), - canTransfer: otherPath !== pane.path, + canTransfer: otherPath !== null && otherPath !== pane.path, ...(openWith.length ? { openWith } : {}) }) .catch((error: unknown) => onLog(`Context menu failed: ${describeError(error)}`)); @@ -696,6 +712,10 @@ function FilePane(props: { const transferToOther = useCallback( async (mode: 'copy' | 'move') => { + if (!otherPath) { + onLog('Target pane is not a listing.'); + return; + } const items = requireSelections(); if (!items) return; if (otherPath === pane.path) { @@ -1554,6 +1574,39 @@ function FilePane(props: { > + {slotControls ? ( +
+ + + +
+ ) : null}
- cmds()?.newFolder()} /> - cmds()?.newFile()} /> - cmds()?.rename()} /> - cmds()?.delete()} /> + cmds()?.newFolder()} /> + cmds()?.newFile()} /> + cmds()?.rename()} /> + cmds()?.delete()} />
- cmds()?.copy()} /> - cmds()?.cut()} /> + cmds()?.copy()} /> + cmds()?.cut()} /> cmds()?.paste()} /> - cmds()?.copyToOther()} /> - cmds()?.moveToOther()} /> + cmds()?.copyToOther()} /> + cmds()?.moveToOther()} /> cmds()?.copyPath()} />
@@ -2583,8 +2723,10 @@ function App() { icon="bot" label="Cursor" title="Open selection in Cursor" + disabled={!activeListingPane()} onClick={() => { - const pane = active === 'left' ? left : right; + const pane = activeListingPane(); + if (!pane) return; const focusName = primarySelected(pane.selected); const target = focusName ? joinLocal(pane.path, focusName) : pane.path; void api().openWith(target, 'cursor'); @@ -2595,6 +2737,7 @@ function App() { { const setter = active === 'left' ? setLeft : setRight; setter((prev) => { @@ -2608,6 +2751,7 @@ function App() { { const setter = active === 'left' ? setLeft : setRight; setter((prev) => { @@ -2621,6 +2765,7 @@ function App() { { const setter = active === 'left' ? setLeft : setRight; setter((prev) => { @@ -2633,6 +2778,22 @@ function App() { />
+ {workspaceLayout.rightSlot === 'closed' ? ( + <> + setSlot('browse')} + /> + setSlot('preview')} + /> + + ) : null} setActive('left')} onChange={setLeft} onLog={pushLog} @@ -2689,7 +2850,7 @@ function App() { }} /> ) : null} - {!workspaceLayout.maximized ? ( + {!workspaceLayout.maximized && workspaceLayout.rightSlot !== 'closed' ? (
) : null} - {workspaceLayout.maximized !== 'left' ? ( - setActive('right')} - onChange={setRight} - onLog={pushLog} - onClipboard={setClipboard} - onToggleMaximize={() => updateWorkspaceLayout(toggleMaximize(workspaceLayout, 'right'))} - onRefreshPeer={() => refreshSide('left')} - askText={askText} - onOpenFile={openFile} - openWithFor={openWithFor} - onRegisterCommands={(c) => { - rightCommands.current = c; - }} - /> + {workspaceLayout.rightSlot !== 'closed' && workspaceLayout.maximized !== 'left' ? ( + workspaceLayout.rightSlot === 'preview' ? ( + setActive('right')} + onOpen={(path) => void openFile(path, baseName(path))} + onBrowseFolder={(path) => { + setSlot('browse'); + void goSide('right', parentLocal(path)); + }} + onClose={() => setSlot('closed')} + /> + ) : ( + setSlot(mode), + onClose: () => setSlot('closed') + }} + onActivate={() => setActive('right')} + onChange={setRight} + onLog={pushLog} + onClipboard={setClipboard} + onToggleMaximize={() => updateWorkspaceLayout(toggleMaximize(workspaceLayout, 'right'))} + onRefreshPeer={() => refreshSide('left')} + askText={askText} + onOpenFile={openFile} + openWithFor={openWithFor} + onRegisterCommands={(c) => { + rightCommands.current = c; + }} + /> + ) ) : null} diff --git a/src/shared/context-menu.ts b/src/shared/context-menu.ts index 1568fd9..90ea025 100644 --- a/src/shared/context-menu.ts +++ b/src/shared/context-menu.ts @@ -25,6 +25,7 @@ export type ContextMenuTarget = { /** Commands only the context menu sends; they act on the selected entry. */ export type ContextMenuCommand = | 'item:open' + | 'item:preview' | 'item:open-cursor' | 'item:copy-path' | 'item:terminal' @@ -97,6 +98,7 @@ export function buildContextMenu(target: ContextMenuTarget, platform: NodeJS.Pla ? [item('Open', 'item:open'), item('Open in Terminal', 'item:terminal'), item('Open with Cursor', 'item:open-cursor')] : [ item('Open', 'item:open'), + item('Preview in Pane', 'item:preview'), ...(windows ? [item('Open with Notepad', 'file:open-notepad')] : []), item('Open with Cursor', 'item:open-cursor'), ...(target.openWith ?? []).map((app) => item(`Open with ${app.label}`, `item:open-app:${app.appId}`)) diff --git a/tests/context-menu.test.ts b/tests/context-menu.test.ts index 0a28724..34ddab1 100644 --- a/tests/context-menu.test.ts +++ b/tests/context-menu.test.ts @@ -28,6 +28,7 @@ describe('buildContextMenu', () => { const win = buildContextMenu(target, 'win32'); expect(commands(win)).toEqual([ 'item:open', + 'item:preview', 'file:open-notepad', 'item:open-cursor', 'file:reveal', @@ -45,6 +46,13 @@ describe('buildContextMenu', () => { expect(byCommand(buildContextMenu(target, 'darwin'), 'file:reveal').label).toBe('Reveal in Finder'); }); + it('offers Preview only for files', () => { + const file = buildContextMenu({ kind: 'file', canPaste: false, canTransfer: true }, 'win32'); + expect(commands(file)).toContain('item:preview'); + const dir = buildContextMenu({ kind: 'directory', canPaste: false, canTransfer: true }, 'win32'); + expect(commands(dir)).not.toContain('item:preview'); + }); + it('offers terminal and favorites for folders, not Notepad', () => { const items = buildContextMenu({ kind: 'directory', canPaste: true, canTransfer: true }, 'win32'); expect(commands(items)).toContain('item:terminal'); From 83614c523e0e2c0bdf78b904d4d2f27848aa7efc Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:36:48 +0000 Subject: [PATCH 11/18] fix(preview): explicit preview target wins; disable F5/F6 without a listing pane item:preview now seeds the recommended target through setSlot('preview', target), so the follow-selection effect must not re-seed from the left listing on slot entry; a signature ref gates it to later left selection changes. F5/Copy-> and F6/Move-> also go dead-disabled with a log when no listing pane is active, instead of resolving to a null command set and silently doing nothing. --- src/renderer/main.tsx | 88 ++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/src/renderer/main.tsx b/src/renderer/main.tsx index bf1341e..342ffd6 100644 --- a/src/renderer/main.tsx +++ b/src/renderer/main.tsx @@ -1894,6 +1894,12 @@ function looksLikeAbsolutePath(query: string): boolean { return false; } +/** Single seeding rule for a preview target, so every writer agrees on size/modified. */ +function previewTargetFor(pane: PaneState, name: string): PreviewTarget { + const entry = pane.entries.find((item) => item.name === name); + return { path: joinLocal(pane.path, name), name, size: entry?.size ?? 0, modified: entry?.modified }; +} + function App() { const [left, setLeft] = useState(null); const [right, setRight] = useState(null); @@ -1940,6 +1946,7 @@ function App() { const workspaceRef = useRef(null); const dragRef = useRef<{ start: number; ratio: number; vertical: boolean } | null>(null); const transcriptResizeRef = useRef<{ startY: number; startHeight: number } | null>(null); + const followPreviewRef = useRef(null); const updateWorkspaceLayout = useCallback((next: WorkspaceLayoutState) => { setWorkspaceLayout(next); @@ -1952,19 +1959,25 @@ function App() { }, []); const setSlot = useCallback( - (slot: RightSlot) => { + (slot: RightSlot, target?: PreviewTarget | null) => { updateWorkspaceLayout(setRightSlot(workspaceLayout, slot)); if (slot === 'closed' && active === 'right') setActive('left'); - if (slot === 'preview' && left) { - const name = primarySelected(left.selected); - const entry = name ? left.entries.find((item) => item.name === name) : undefined; - if (name && entry) { - updatePreviewTarget({ - path: joinLocal(left.path, name), - name, - size: entry.size, - modified: entry.modified - }); + if (slot === 'preview') { + if (target !== undefined) { + updatePreviewTarget(target); + return; + } + if (left) { + const name = primarySelected(left.selected); + const entry = name ? left.entries.find((item) => item.name === name) : undefined; + if (name && entry) { + updatePreviewTarget({ + path: joinLocal(left.path, name), + name, + size: entry.size, + modified: entry.modified + }); + } } } }, @@ -2334,11 +2347,19 @@ function App() { } if (event.key === 'F5') { event.preventDefault(); + if (!activeListingPane()) { + pushLog('No listing pane is active.'); + return; + } c?.copyToOther(); return; } if (event.key === 'F6') { event.preventDefault(); + if (!activeListingPane()) { + pushLog('No listing pane is active.'); + return; + } c?.moveToOther(); return; } @@ -2359,20 +2380,29 @@ function App() { }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); - }, [active, addCurrentFavorite, focusJump, workspaceLayout.rightSlot]); + }, [active, activeListingPane, addCurrentFavorite, focusJump, pushLog, workspaceLayout.rightSlot]); useEffect(() => { - if (workspaceLayout.rightSlot !== 'preview' || !left) return; + if (workspaceLayout.rightSlot !== 'preview' || !left) { + followPreviewRef.current = null; + return; + } const name = primarySelected(left.selected); - if (!name) return; + if (!name) { + followPreviewRef.current = null; + return; + } const entry = left.entries.find((item) => item.name === name); + const sig = `${left.path}\u0000${name}\u0000${entry?.size ?? 0}\u0000${entry?.modified ?? ''}\u0000${left.entries.length}`; + if (sig === followPreviewRef.current) return; + if (followPreviewRef.current === null) { + // Slot entry: setSlot already chose the target, so record and let it stand. + followPreviewRef.current = sig; + return; + } + followPreviewRef.current = sig; const timer = window.setTimeout(() => { - updatePreviewTarget({ - path: joinLocal(left.path, name), - name, - size: entry?.size ?? 0, - modified: entry?.modified - }); + updatePreviewTarget(previewTargetFor(left, name)); }, 180); return () => window.clearTimeout(timer); }, [left?.entries, left?.path, left?.selected, updatePreviewTarget, workspaceLayout.rightSlot]); @@ -2464,16 +2494,7 @@ function App() { case 'item:preview': { const pane = activeListingPane(); const name = pane ? primarySelected(pane.selected) : null; - const entry = name && pane ? pane.entries.find((item) => item.name === name) : undefined; - if (pane && name) { - updatePreviewTarget({ - path: joinLocal(pane.path, name), - name, - size: entry?.size ?? 0, - modified: entry?.modified - }); - setSlot('preview'); - } + if (pane && name) setSlot('preview', previewTargetFor(pane, name)); break; } case 'item:copy-path': @@ -2521,8 +2542,7 @@ function App() { focusJump, launchApp, pushLog, - setSlot, - updatePreviewTarget + setSlot ]); const runGlobalJump = async () => { @@ -2713,8 +2733,8 @@ function App() { cmds()?.copy()} /> cmds()?.cut()} /> cmds()?.paste()} /> - cmds()?.copyToOther()} /> - cmds()?.moveToOther()} /> + cmds()?.copyToOther()} /> + cmds()?.moveToOther()} /> cmds()?.copyPath()} />
From af695a10696f7f61225ebcdde2a35d45fe1bd2d5 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:38:14 +0000 Subject: [PATCH 12/18] fix(preview): follow first selection after an empty preview open --- src/renderer/main.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/renderer/main.tsx b/src/renderer/main.tsx index 342ffd6..0e88ab4 100644 --- a/src/renderer/main.tsx +++ b/src/renderer/main.tsx @@ -1947,6 +1947,7 @@ function App() { const dragRef = useRef<{ start: number; ratio: number; vertical: boolean } | null>(null); const transcriptResizeRef = useRef<{ startY: number; startHeight: number } | null>(null); const followPreviewRef = useRef(null); + const prevRightSlotRef = useRef(workspaceLayout.rightSlot); const updateWorkspaceLayout = useCallback((next: WorkspaceLayoutState) => { setWorkspaceLayout(next); @@ -2383,24 +2384,22 @@ function App() { }, [active, activeListingPane, addCurrentFavorite, focusJump, pushLog, workspaceLayout.rightSlot]); useEffect(() => { + const justOpened = prevRightSlotRef.current !== 'preview' && workspaceLayout.rightSlot === 'preview'; + prevRightSlotRef.current = workspaceLayout.rightSlot; if (workspaceLayout.rightSlot !== 'preview' || !left) { followPreviewRef.current = null; return; } const name = primarySelected(left.selected); - if (!name) { - followPreviewRef.current = null; - return; - } + if (!name) return; const entry = left.entries.find((item) => item.name === name); const sig = `${left.path}\u0000${name}\u0000${entry?.size ?? 0}\u0000${entry?.modified ?? ''}\u0000${left.entries.length}`; if (sig === followPreviewRef.current) return; - if (followPreviewRef.current === null) { + followPreviewRef.current = sig; + if (justOpened) { // Slot entry: setSlot already chose the target, so record and let it stand. - followPreviewRef.current = sig; return; } - followPreviewRef.current = sig; const timer = window.setTimeout(() => { updatePreviewTarget(previewTargetFor(left, name)); }, 180); From 5b2f0391f353487878b51d33a4adcb2ceae5c8f3 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:41:44 +0000 Subject: [PATCH 13/18] docs: ADR-0006 and preview-slice progress --- PROGRESS.md | 1 + ROADMAP.md | 2 + SPEC.md | 3 ++ docs/adr/0006-right-slot-modes-and-preview.md | 38 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 docs/adr/0006-right-slot-modes-and-preview.md diff --git a/PROGRESS.md b/PROGRESS.md index 4d27082..b1aab98 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -33,6 +33,7 @@ Open check: builtin Whisper model download under the narrowed CSP `connect-src` - In-app name dialog replaces `window.prompt` (Electron never implements it): New Folder, New File type/name, Rename (F2) and favorite naming now work in both panes; inline validation, Esc/Cancel aborts, new folders land selected - Explorer-style drag-drop inside and between panes: drag = move, Ctrl = copy, Shift = force move, cross-drive defaults to copy; targets are folder rows/tiles, pane background, ".." and breadcrumbs; whole-selection drag; both panes refresh and the transcript logs each op; same-folder moves and drops into a folder's own subtree are no-ops - Name dialog + drag-drop rules covered by 24 new tests (188 total); `npm run ci` passes; verified in a real hidden Electron window against a temp filesystem: 14/14 UI checks (dialog in the right pane, invalid-name error, Esc cancel, F2 rename, cross-pane move, Ctrl copy, folder-row drop, same-folder no-op) +- Closable right slot with a read-only preview: images, text, Markdown (no raw HTML) and source code follow the left selection through one bounded `fs:preview` channel (32 MiB image / 1 MiB text caps, binary sniff, symlinks refused); HTML shows as source; F5/F6 and cross-pane drops disable when the peer isn't a listing ## Next diff --git a/ROADMAP.md b/ROADMAP.md index 5fec4a9..b842221 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -27,6 +27,7 @@ Repo: [HappyMonkeyAI/ZeroGFileMan](https://github.com/HappyMonkeyAI/ZeroGFileMan | D15 | Split layouts | Side-by-side / stacked + maximize; draggable gutter | | D16 | Terminal launcher pref | System / ZeroG Term / custom command from Settings | | D17 | App updates | Consent-based GitHub release checks; NSIS installs, portable notifies | +| D18 | Closable right slot + file preview | P3.7 preview pane; F5/F6 guard | ## Near-term (ordered) @@ -70,6 +71,7 @@ Repo: [HappyMonkeyAI/ZeroGFileMan](https://github.com/HappyMonkeyAI/ZeroGFileMan | P3.4 | Column sort | Name / size / modified click-to-sort; persist per pane | done | | P3.5 | Listing view modes | Explorer-style **Details** / **Icons** / **Thumbnails**; per-pane toolbar; **Ctrl+wheel** zooms icon/thumbnail size | done | | P3.6 | Drive picker | Dropdown next to drive letter in pane path; lists mounted Windows roots | done | +| P3.7 | Right-slot preview | Close/reopen; images, text, Markdown, code; bounded IPC caps | done | ### P4 — Packaging & polish diff --git a/SPEC.md b/SPEC.md index ce71a2f..c332d9d 100644 --- a/SPEC.md +++ b/SPEC.md @@ -18,6 +18,9 @@ Local dual-pane file browser for developers with push-to-talk **Navigate** and * | M8 | Action jewel: copy path / copy / cut / paste / delete / rename / new folder / open / notepad / cursor / terminal / reveal / refresh | | M9 | Favorites jump (Home / Documents / development when present); add/remove; persist in userData | | M10 | `typecheck`, unit tests, and `build` pass | +| M11 | Right pane closes (left fills the window) and reopens as a listing or a preview | +| M12 | Right pane previews images, text, Markdown (sanitized) and source code; HTML shows as source | +| M13 | Copy/move-to-other and cross-pane drops are disabled with a hint when the other pane is not a listing | ## Voice modes diff --git a/docs/adr/0006-right-slot-modes-and-preview.md b/docs/adr/0006-right-slot-modes-and-preview.md new file mode 100644 index 0000000..869b801 --- /dev/null +++ b/docs/adr/0006-right-slot-modes-and-preview.md @@ -0,0 +1,38 @@ +# 0006 — Right slot modes and main-process file preview + +- **Status:** Accepted +- **Date:** 2026-11-30 + +## Context + +The workspace had two fixed directory listings. Users asked to close the right +pane and to preview files (images, text, Markdown, code) in it instead of +launching an external app for a glance. + +## Decision + +1. The right slot is `browse | preview | closed`, persisted with the workspace + layout. Left stays a listing; closing the right slot collapses the grid to + one cell and never leaves a maximized ghost. +2. `FilePane` remains listing-only. A separate `PreviewPane` renders previews; + preview follows the left listing's selection (180 ms debounce, primary of a + multi-selection). +3. One IPC channel, `fs:preview`, classifies, validates and reads in main and + returns a discriminated payload. Caps live only in main: 32 MiB images at a + 4096 px decode edge, 1 MiB text with a truncation flag, NUL-byte binary + sniff, regular files only, symlinks refused. +4. Markdown renders with `react-markdown` + `remark-gfm` and no raw HTML. + HTML/XML files are shown as source. Remote images stay blocked by CSP. + Markdown links open through `shell:openUrl`, which accepts only http(s). +5. When the opposing pane is not a listing, F5/F6, Copy→/Move→, cross-pane + drops and the context-menu transfer items are disabled with a transcript + hint. No retargeting into an invisible folder. + +## Consequences + +- Preview is read-only; editing stays in external editors (ZeroG Edit, Notepad, + Cursor) through the existing file-app associations. +- PDF, audio, video, SVG and syntax highlighting are deferred; they need a + custom protocol or a heavier renderer. +- The slot union leaves room for a future Terminal tab without another model + change. From 9a44c9c1a87c2f6d7174b375c2493025f87cfeec Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:50:59 +0000 Subject: [PATCH 14/18] fix(preview): clear stale targets, bound image decode, close guard gaps --- docs/adr/0006-right-slot-modes-and-preview.md | 9 +- .../specs/2026-11-30-preview-pane-design.md | 5 +- src/main/image-dims.ts | 156 +++++++++++++++ src/main/preview-fs.ts | 13 +- src/main/thumbnails.ts | 31 ++- src/renderer/main.tsx | 18 +- src/renderer/preview-pane.tsx | 11 +- tests/image-dims.test.ts | 188 ++++++++++++++++++ tests/preview-fs.test.ts | 9 + tests/thumbnails.test.ts | 84 ++++++++ 10 files changed, 499 insertions(+), 25 deletions(-) create mode 100644 src/main/image-dims.ts create mode 100644 tests/image-dims.test.ts create mode 100644 tests/thumbnails.test.ts diff --git a/docs/adr/0006-right-slot-modes-and-preview.md b/docs/adr/0006-right-slot-modes-and-preview.md index 869b801..36ecc19 100644 --- a/docs/adr/0006-right-slot-modes-and-preview.md +++ b/docs/adr/0006-right-slot-modes-and-preview.md @@ -19,14 +19,15 @@ launching an external app for a glance. multi-selection). 3. One IPC channel, `fs:preview`, classifies, validates and reads in main and returns a discriminated payload. Caps live only in main: 32 MiB images at a - 4096 px decode edge, 1 MiB text with a truncation flag, NUL-byte binary - sniff, regular files only, symlinks refused. + 4096 px display edge, plus a pre-decode pixel bound (40 MP) on the + synchronous decode fallback, 1 MiB text with a truncation flag, NUL-byte + binary sniff, regular files only, symlinks refused. 4. Markdown renders with `react-markdown` + `remark-gfm` and no raw HTML. HTML/XML files are shown as source. Remote images stay blocked by CSP. Markdown links open through `shell:openUrl`, which accepts only http(s). 5. When the opposing pane is not a listing, F5/F6, Copy→/Move→, cross-pane - drops and the context-menu transfer items are disabled with a transcript - hint. No retargeting into an invisible folder. + drops and the context-menu transfer items are disabled. No retargeting into + an invisible folder. ## Consequences diff --git a/docs/superpowers/specs/2026-11-30-preview-pane-design.md b/docs/superpowers/specs/2026-11-30-preview-pane-design.md index 2527e75..008c4f5 100644 --- a/docs/superpowers/specs/2026-11-30-preview-pane-design.md +++ b/docs/superpowers/specs/2026-11-30-preview-pane-design.md @@ -146,7 +146,10 @@ Behaviour: 3. Classify with `previewKindFor(name, 'file')`. 4. Image → decode through the shared Electron image helper at `PREVIEW_IMAGE_MAX_EDGE`. Listings keep their existing 512 px cap. Decode failure → - `unsupported/decode-failed`; over cap → `unsupported/too-large`. + `unsupported/decode-failed`; over cap → `unsupported/too-large`. The synchronous + `createFromPath` fallback probes the image header first and refuses images over 40 MP + (`IMAGE_FALLBACK_MAX_PIXELS`) or with unreadable headers, returning + `unsupported/decode-failed`. 5. Text-like → read at most `PREVIEW_TEXT_MAX_BYTES` + 1 byte to detect truncation. If the first 8 KiB contains a NUL byte → `unsupported/binary`. Strip a UTF-8 BOM, decode with `TextDecoder('utf-8')` (non-fatal replacement). Permission/IO errors diff --git a/src/main/image-dims.ts b/src/main/image-dims.ts new file mode 100644 index 0000000..fa12434 --- /dev/null +++ b/src/main/image-dims.ts @@ -0,0 +1,156 @@ +/** + * Header-only image dimension probes. + * + * The preview pane follows the selection, and its synchronous + * `nativeImage.createFromPath` fallback decodes at full resolution before the + * display resize happens. A legal file can therefore declare a canvas whose + * RGBA buffer is far larger than the file itself, so the header is read first + * and oversized images are refused before any decode runs. + */ + +/** Largest width × height (pixels) allowed through the synchronous decode fallback. */ +export const IMAGE_FALLBACK_MAX_PIXELS = 40_000_000; + +export type ImageDimensions = { width: number; height: number }; + +const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]; +const GIF_SIGNATURE = [0x47, 0x49, 0x46, 0x38]; +const ICO_SIGNATURE = [0x00, 0x00, 0x01, 0x00]; + +/** SOF0–SOF3, SOF5–SOF7, SOF9–SOF11, SOF13–SOF15 carry the frame size. */ +const SOF_MARKERS = new Set([ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf +]); + +function matches(bytes: Uint8Array, signature: readonly number[], offset = 0): boolean { + if (bytes.length < offset + signature.length) return false; + return signature.every((byte, index) => bytes[offset + index] === byte); +} + +function be16(bytes: Uint8Array, at: number): number { + return (bytes[at] << 8) | bytes[at + 1]; +} + +function be32(bytes: Uint8Array, at: number): number { + return bytes[at] * 0x1000000 + (bytes[at + 1] << 16) + (bytes[at + 2] << 8) + bytes[at + 3]; +} + +function le16(bytes: Uint8Array, at: number): number { + return bytes[at] | (bytes[at + 1] << 8); +} + +function le24(bytes: Uint8Array, at: number): number { + return bytes[at] | (bytes[at + 1] << 8) | (bytes[at + 2] << 16); +} + +function le32(bytes: Uint8Array, at: number): number { + return (bytes[at] | (bytes[at + 1] << 8) | (bytes[at + 2] << 16)) + bytes[at + 3] * 0x1000000; +} + +/** Signed 32-bit read, used for the BMP fields that may be negative. */ +function le32Signed(bytes: Uint8Array, at: number): number { + const value = le32(bytes, at); + return value > 0x7fffffff ? value - 0x100000000 : value; +} + +function pngDimensions(bytes: Uint8Array): ImageDimensions | null { + if (bytes.length < 24) return null; + // IHDR is the first chunk: width at 16, height at 20. + return { width: be32(bytes, 16), height: be32(bytes, 20) }; +} + +function jpegDimensions(bytes: Uint8Array): ImageDimensions | null { + let i = 2; + while (i + 1 < bytes.length && bytes[i] === 0xff) { + const marker = bytes[i + 1]; + if (marker === 0xff) { + // Fill byte: skip just the one so the 0xFF-prefixed next marker parses. + i++; + continue; + } + if (marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) { + // TEM and RSTn are standalone; everything else carries a length field. + i += 2; + continue; + } + if (i + 4 > bytes.length) return null; + const segmentLength = be16(bytes, i + 2); + if (segmentLength < 2) return null; + if (SOF_MARKERS.has(marker)) { + if (i + 9 > bytes.length) return null; + // Length(2) + precision(1) precede the two 16-bit frame dimensions. + return { width: be16(bytes, i + 7), height: be16(bytes, i + 5) }; + } + i += 2 + segmentLength; + } + return null; +} + +function gifDimensions(bytes: Uint8Array): ImageDimensions | null { + if (bytes.length < 10) return null; + return { width: le16(bytes, 6), height: le16(bytes, 8) }; +} + +function bmpDimensions(bytes: Uint8Array): ImageDimensions | null { + if (bytes.length < 26) return null; + const width = le32Signed(bytes, 18); + // A negative height only means the rows are stored top-down. + const height = Math.abs(le32Signed(bytes, 22)); + if (width <= 0 || height <= 0) return null; + return { width, height }; +} + +function webpDimensions(bytes: Uint8Array): ImageDimensions | null { + if (bytes.length < 16) return null; + if (matches(bytes, [0x56, 0x50, 0x38, 0x20], 12)) { + // "VP8 ": lossy bitstream, 14-bit dimensions after the 3-byte frame tag. + if (bytes.length < 30) return null; + return { width: le16(bytes, 26) & 0x3fff, height: le16(bytes, 28) & 0x3fff }; + } + if (matches(bytes, [0x56, 0x50, 0x38, 0x4c], 12)) { + // "VP8L": 14-bit (width - 1) then 14-bit (height - 1), bit-packed. + if (bytes.length < 25) return null; + const width = (bytes[21] | ((bytes[22] & 0x3f) << 8)) + 1; + const height = ((bytes[22] >> 6) | (bytes[23] << 2) | ((bytes[24] & 0x0f) << 10)) + 1; + return { width, height }; + } + if (matches(bytes, [0x56, 0x50, 0x38, 0x58], 12)) { + // "VP8X": 24-bit (canvas size - 1) fields. + if (bytes.length < 30) return null; + return { width: le24(bytes, 24) + 1, height: le24(bytes, 27) + 1 }; + } + return null; +} + +function icoDimensions(bytes: Uint8Array): ImageDimensions | null { + if (bytes.length < 22) return null; + const count = le16(bytes, 4); + if (count < 1) return null; + // A stored 0 means 256 px. + return { width: bytes[6] || 256, height: bytes[7] || 256 }; +} + +/** Read dimensions from an image header; null when the format is unknown or truncated. */ +export function probeImageDimensions(bytes: Uint8Array): ImageDimensions | null { + let size: ImageDimensions | null; + if (matches(bytes, PNG_SIGNATURE)) { + size = pngDimensions(bytes); + } else if (bytes.length >= 2 && bytes[0] === 0xff && bytes[1] === 0xd8) { + size = jpegDimensions(bytes); + } else if (matches(bytes, GIF_SIGNATURE)) { + size = gifDimensions(bytes); + } else if (bytes.length >= 2 && bytes[0] === 0x42 && bytes[1] === 0x4d) { + size = bmpDimensions(bytes); + } else if ( + matches(bytes, [0x52, 0x49, 0x46, 0x46]) && + matches(bytes, [0x57, 0x45, 0x42, 0x50], 8) + ) { + size = webpDimensions(bytes); + } else if (matches(bytes, ICO_SIGNATURE)) { + size = icoDimensions(bytes); + } else { + return null; + } + if (!size || size.width <= 0 || size.height <= 0) return null; + return size; +} diff --git a/src/main/preview-fs.ts b/src/main/preview-fs.ts index 7b2b203..ca9df8b 100644 --- a/src/main/preview-fs.ts +++ b/src/main/preview-fs.ts @@ -40,14 +40,15 @@ async function readText( modified: string | undefined, kind: 'text' | 'markdown' | 'code' ): Promise { - const limit = Math.min(size, PREVIEW_TEXT_MAX_BYTES); + // One byte past the cap is enough to tell truncated from complete. + const limit = Math.min(size, PREVIEW_TEXT_MAX_BYTES + 1); const handle = await open(target, 'r'); try { const buffer = Buffer.alloc(limit); // A single pread may return fewer than `limit` bytes (short read), and a - // short read would otherwise pass as a complete document because - // `truncated` is derived from the stat size. Accumulate until the cap or - // EOF, advancing the position by what we actually got. + // short read would otherwise pass as a complete document. Accumulate until + // the cap or EOF, advancing the position by what we actually got; the + // truncation flag then follows the bytes read, not the stat size. let total = 0; while (total < limit) { const { bytesRead } = await handle.read(buffer, total, limit - total, total); @@ -58,7 +59,7 @@ async function readText( if (bytes.subarray(0, BINARY_SNIFF_BYTES).includes(0)) { return unsupported(target, name, size, 'binary', modified); } - const text = new TextDecoder('utf-8').decode(bytes); + const text = new TextDecoder('utf-8').decode(bytes.subarray(0, PREVIEW_TEXT_MAX_BYTES)); return { kind, path: target, @@ -66,7 +67,7 @@ async function readText( size, modified, text, - truncated: size > PREVIEW_TEXT_MAX_BYTES + truncated: total > PREVIEW_TEXT_MAX_BYTES }; } finally { await handle.close(); diff --git a/src/main/thumbnails.ts b/src/main/thumbnails.ts index c4b61c6..afb8134 100644 --- a/src/main/thumbnails.ts +++ b/src/main/thumbnails.ts @@ -1,6 +1,7 @@ -import { lstat } from 'node:fs/promises'; +import { lstat, open } from 'node:fs/promises'; import { nativeImage, type NativeImage } from 'electron'; import { isThumbnailCandidate, THUMBNAIL_MAX_BYTES } from '../shared/listing-view.js'; +import { IMAGE_FALLBACK_MAX_PIXELS, probeImageDimensions } from './image-dims.js'; import { resolveLocalPath } from './local-fs.js'; export type ThumbnailResult = { @@ -11,11 +12,34 @@ export type ThumbnailResult = { export type DecodedImage = ThumbnailResult; +const HEADER_PROBE_BYTES = 65_536; + +/** Read a file's leading bytes so the header can be probed before decoding. */ +async function readHeader(target: string): Promise { + let handle; + try { + handle = await open(target, 'r'); + const buffer = Buffer.alloc(HEADER_PROBE_BYTES); + let total = 0; + while (total < buffer.length) { + const { bytesRead } = await handle.read(buffer, total, buffer.length - total, total); + if (bytesRead === 0) break; + total += bytesRead; + } + return buffer.subarray(0, total); + } catch { + return null; + } finally { + if (handle) await handle.close().catch(() => {}); + } +} + /** * Ask the OS thumbnailer first (Windows shell / macOS Quick Look): it runs off * the main thread and reuses the system thumbnail cache. Linux has no such * API, and the OS may have no handler for a format, so fall back to a full - * decode — synchronous, but bounded by the caller's size cap. + * decode — synchronous and at full resolution, so the header is probed first + * and images over `IMAGE_FALLBACK_MAX_PIXELS` are refused rather than decoded. */ async function decode(target: string, edge: number): Promise { if (process.platform === 'win32' || process.platform === 'darwin') { @@ -26,6 +50,9 @@ async function decode(target: string, edge: number): Promise /* no OS thumbnail for this file — decode it ourselves */ } } + const header = await readHeader(target); + const size = header ? probeImageDimensions(header) : null; + if (!size || size.width * size.height > IMAGE_FALLBACK_MAX_PIXELS) return null; return nativeImage.createFromPath(target); } diff --git a/src/renderer/main.tsx b/src/renderer/main.tsx index 0e88ab4..019a7b2 100644 --- a/src/renderer/main.tsx +++ b/src/renderer/main.tsx @@ -1970,16 +1970,13 @@ function App() { } if (left) { const name = primarySelected(left.selected); - const entry = name ? left.entries.find((item) => item.name === name) : undefined; - if (name && entry) { - updatePreviewTarget({ - path: joinLocal(left.path, name), - name, - size: entry.size, - modified: entry.modified - }); + if (name && left.entries.some((item) => item.name === name)) { + updatePreviewTarget(previewTargetFor(left, name)); + return; } } + // No usable seed: clear rather than leaving a stale target behind. + updatePreviewTarget(null); } }, [active, left, updatePreviewTarget, updateWorkspaceLayout, workspaceLayout] @@ -2731,7 +2728,7 @@ function App() {
cmds()?.copy()} /> cmds()?.cut()} /> - cmds()?.paste()} /> + cmds()?.paste()} /> cmds()?.copyToOther()} /> cmds()?.moveToOther()} /> cmds()?.copyPath()} /> @@ -2816,16 +2813,19 @@ function App() { updateWorkspaceLayout(setLayout(workspaceLayout, 'split-v'))} /> updateWorkspaceLayout(setLayout(workspaceLayout, 'split-h'))} /> updateWorkspaceLayout(toggleMaximize(workspaceLayout, active))} />
diff --git a/src/renderer/preview-pane.tsx b/src/renderer/preview-pane.tsx index 1580392..965cb37 100644 --- a/src/renderer/preview-pane.tsx +++ b/src/renderer/preview-pane.tsx @@ -39,6 +39,9 @@ export function PreviewPane(props: { }) { const { target, active, onActivate, onOpen, onBrowseFolder, onClose } = props; const path = target?.path ?? null; + // Re-selecting the same path must re-read (it may have changed on disk), so + // the effect keys on the file's identity plus its metadata, not just `path`. + const key = target ? `${target.path}\u0000${target.size}\u0000${target.modified ?? ''}` : null; const [result, setResult] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); @@ -49,7 +52,7 @@ export function PreviewPane(props: { // Invalidate any in-flight response before the early return so a target // cleared mid-fetch cannot be repopulated by the stale reply. const current = ++seq.current; - if (!path) { + if (!key || !path) { setResult(null); setError(null); setLoading(false); @@ -73,7 +76,7 @@ export function PreviewPane(props: { setError(describeError(reason)); setLoading(false); }); - }, [path, attempt]); + }, [key, attempt]); const name = result?.name ?? target?.name ?? ''; const size = result?.size ?? target?.size ?? 0; @@ -132,7 +135,9 @@ export function PreviewPane(props: { rel="noreferrer" onClick={(event) => { event.preventDefault(); - void window.fileman.openExternalUrl(href); + void window.fileman + .openExternalUrl(href) + .catch(() => setError('Could not open that link.')); }} > {children} diff --git a/tests/image-dims.test.ts b/tests/image-dims.test.ts new file mode 100644 index 0000000..b6b792f --- /dev/null +++ b/tests/image-dims.test.ts @@ -0,0 +1,188 @@ +import { describe, expect, it } from 'vitest'; +import { probeImageDimensions } from '../src/main/image-dims.js'; + +function be16(bytes: Uint8Array, offset: number, value: number): void { + bytes[offset] = (value >>> 8) & 0xff; + bytes[offset + 1] = value & 0xff; +} + +function be32(bytes: Uint8Array, offset: number, value: number): void { + bytes[offset] = (value >>> 24) & 0xff; + bytes[offset + 1] = (value >>> 16) & 0xff; + bytes[offset + 2] = (value >>> 8) & 0xff; + bytes[offset + 3] = value & 0xff; +} + +function le16(bytes: Uint8Array, offset: number, value: number): void { + bytes[offset] = value & 0xff; + bytes[offset + 1] = (value >>> 8) & 0xff; +} + +function le24(bytes: Uint8Array, offset: number, value: number): void { + bytes[offset] = value & 0xff; + bytes[offset + 1] = (value >>> 8) & 0xff; + bytes[offset + 2] = (value >>> 16) & 0xff; +} + +function le32(bytes: Uint8Array, offset: number, value: number): void { + bytes[offset] = value & 0xff; + bytes[offset + 1] = (value >>> 8) & 0xff; + bytes[offset + 2] = (value >>> 16) & 0xff; + bytes[offset + 3] = (value >>> 24) & 0xff; +} + +/** Signature + IHDR width/height fields; enough for a header probe, not a real image. */ +function png(width: number, height: number): Uint8Array { + const bytes = new Uint8Array(24); + bytes.set([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], 0); + be32(bytes, 16, width); + be32(bytes, 20, height); + return bytes; +} + +/** SOI, one APP0 segment, then an SOF0 frame header. */ +function jpeg(width: number, height: number): Uint8Array { + const bytes = new Uint8Array(24); + bytes.set([0xff, 0xd8], 0); + bytes.set([0xff, 0xe0, 0x00, 0x04], 2); + bytes.set([0xff, 0xc0], 8); + be16(bytes, 10, 0x0011); + bytes[12] = 0x08; + be16(bytes, 13, height); + be16(bytes, 15, width); + return bytes; +} + +function gif(width: number, height: number): Uint8Array { + const bytes = new Uint8Array(10); + bytes.set([0x47, 0x49, 0x46, 0x38, 0x39, 0x61], 0); + le16(bytes, 6, width); + le16(bytes, 8, height); + return bytes; +} + +function bmp(width: number, height: number): Uint8Array { + const bytes = new Uint8Array(54); + bytes.set([0x42, 0x4d], 0); + le32(bytes, 18, width >>> 0); + le32(bytes, 22, height >>> 0); + return bytes; +} + +function webpChunk(fourCc: string, size = 30): Uint8Array { + const bytes = new Uint8Array(size); + bytes.set([0x52, 0x49, 0x46, 0x46], 0); + le32(bytes, 4, size - 8); + bytes.set([0x57, 0x45, 0x42, 0x50], 8); + for (let i = 0; i < 4; i++) bytes[12 + i] = fourCc.charCodeAt(i); + return bytes; +} + +function webpLossy(width: number, height: number): Uint8Array { + const bytes = webpChunk('VP8 '); + le16(bytes, 26, width); + le16(bytes, 28, height); + return bytes; +} + +function webpLossless(width: number, height: number): Uint8Array { + const bytes = webpChunk('VP8L', 25); + const w = width - 1; + const h = height - 1; + bytes[21] = w & 0xff; + bytes[22] = ((w >>> 8) & 0x3f) | ((h & 0x03) << 6); + bytes[23] = (h >>> 2) & 0xff; + bytes[24] = (h >>> 10) & 0x0f; + return bytes; +} + +function webpExtended(width: number, height: number): Uint8Array { + const bytes = webpChunk('VP8X'); + le24(bytes, 24, width - 1); + le24(bytes, 27, height - 1); + return bytes; +} + +function ico(width: number, height: number, count = 1): Uint8Array { + const bytes = new Uint8Array(22); + bytes.set([0x00, 0x00, 0x01, 0x00], 0); + le16(bytes, 4, count); + bytes[6] = width === 256 ? 0 : width; + bytes[7] = height === 256 ? 0 : height; + return bytes; +} + +describe('probeImageDimensions', () => { + it('reads PNG width and height', () => { + expect(probeImageDimensions(png(1234, 567))).toEqual({ width: 1234, height: 567 }); + }); + + it('reads JPEG dimensions from an SOF segment', () => { + expect(probeImageDimensions(jpeg(1920, 1080))).toEqual({ width: 1920, height: 1080 }); + }); + + it('skips fill bytes and standalone JPEG markers', () => { + const bytes = new Uint8Array(28); + bytes.set([0xff, 0xd8], 0); + // Fill bytes: two 0xFF in a row are skipped one at a time. + bytes.set([0xff, 0xff, 0xe0, 0x00, 0x04], 2); + // RST0 is standalone: no length field, so advance by two. + bytes.set([0xff, 0xd0], 9); + bytes.set([0xff, 0x02, 0x00, 0x02], 11); + bytes.set([0xff, 0xc2], 15); + be16(bytes, 17, 0x0011); + bytes[19] = 0x08; + be16(bytes, 20, 720); + be16(bytes, 22, 1280); + expect(probeImageDimensions(bytes)).toEqual({ width: 1280, height: 720 }); + }); + + it('reads GIF width and height', () => { + expect(probeImageDimensions(gif(64, 48))).toEqual({ width: 64, height: 48 }); + }); + + it('reads BMP dimensions and tolerates a negative (top-down) height', () => { + expect(probeImageDimensions(bmp(320, 200))).toEqual({ width: 320, height: 200 }); + expect(probeImageDimensions(bmp(320, -200))).toEqual({ width: 320, height: 200 }); + }); + + it('reads WebP VP8 (lossy) dimensions', () => { + expect(probeImageDimensions(webpLossy(640, 480))).toEqual({ width: 640, height: 480 }); + }); + + it('reads WebP VP8L (lossless) dimensions', () => { + expect(probeImageDimensions(webpLossless(258, 300))).toEqual({ width: 258, height: 300 }); + }); + + it('reads WebP VP8X (extended) dimensions', () => { + expect(probeImageDimensions(webpExtended(1000, 500))).toEqual({ width: 1000, height: 500 }); + }); + + it('reads ICO dimensions, mapping a stored 0 to 256', () => { + expect(probeImageDimensions(ico(16, 32))).toEqual({ width: 16, height: 32 }); + expect(probeImageDimensions(ico(256, 256))).toEqual({ width: 256, height: 256 }); + }); + + it('returns null for unknown or empty input', () => { + expect(probeImageDimensions(new Uint8Array(0))).toBeNull(); + expect(probeImageDimensions(new Uint8Array(64))).toBeNull(); + expect(probeImageDimensions(new Uint8Array([0x50, 0x4b, 0x03, 0x04]))).toBeNull(); + }); + + it('returns null for truncated headers', () => { + expect(probeImageDimensions(png(10, 10).subarray(0, 20))).toBeNull(); + expect(probeImageDimensions(jpeg(10, 10).subarray(0, 12))).toBeNull(); + expect(probeImageDimensions(gif(10, 10).subarray(0, 8))).toBeNull(); + expect(probeImageDimensions(bmp(10, 10).subarray(0, 24))).toBeNull(); + expect(probeImageDimensions(webpLossy(10, 10).subarray(0, 28))).toBeNull(); + expect(probeImageDimensions(webpLossless(10, 10).subarray(0, 23))).toBeNull(); + expect(probeImageDimensions(webpExtended(10, 10).subarray(0, 27))).toBeNull(); + expect(probeImageDimensions(ico(10, 10).subarray(0, 6))).toBeNull(); + }); + + it('returns null for zero dimensions or an empty ICO directory', () => { + expect(probeImageDimensions(png(0, 10))).toBeNull(); + expect(probeImageDimensions(gif(0, 10))).toBeNull(); + expect(probeImageDimensions(ico(16, 16, 0))).toBeNull(); + }); +}); diff --git a/tests/preview-fs.test.ts b/tests/preview-fs.test.ts index fe309ef..0621fce 100644 --- a/tests/preview-fs.test.ts +++ b/tests/preview-fs.test.ts @@ -47,6 +47,15 @@ describe('readPreview', () => { expect(result.text.length).toBe(PREVIEW_TEXT_MAX_BYTES); }); + it('reads a file exactly at the cap without reporting truncation', async () => { + const file = join(root, 'exact.txt'); + writeFileSync(file, Buffer.alloc(PREVIEW_TEXT_MAX_BYTES, 0x61)); + const result = await readPreview(file, deps); + if (result.kind !== 'text') throw new Error('expected text'); + expect(result.truncated).toBe(false); + expect(result.text.length).toBe(PREVIEW_TEXT_MAX_BYTES); + }); + it('refuses binary content', async () => { const file = join(root, 'blob.log'); writeFileSync(file, Buffer.from([0x41, 0x00, 0x42])); diff --git a/tests/thumbnails.test.ts b/tests/thumbnails.test.ts new file mode 100644 index 0000000..0d41b06 --- /dev/null +++ b/tests/thumbnails.test.ts @@ -0,0 +1,84 @@ +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + +const { createFromPath, createThumbnailFromPath } = vi.hoisted(() => ({ + createFromPath: vi.fn(), + createThumbnailFromPath: vi.fn() +})); + +vi.mock('electron', () => ({ + nativeImage: { createFromPath, createThumbnailFromPath } +})); + +const { decodeImage } = await import('../src/main/thumbnails.js'); + +type Size = { width: number; height: number }; + +function fakeImage(size: Size = { width: 10, height: 10 }) { + const image: { + isEmpty: () => boolean; + getSize: () => Size; + resize: (next: Size) => unknown; + toDataURL: () => string; + } = { + isEmpty: () => false, + getSize: () => size, + resize: (next: Size) => fakeImage(next), + toDataURL: () => 'data:image/png;base64,AAAA' + }; + return image; +} + +/** PNG signature plus IHDR width/height; enough for the header probe. */ +function pngHeader(width: number, height: number): Buffer { + const bytes = Buffer.alloc(24); + Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]).copy(bytes, 0); + bytes.writeUInt32BE(width, 16); + bytes.writeUInt32BE(height, 20); + return bytes; +} + +let root: string; + +beforeEach(() => { + root = mkdtempSync(join(tmpdir(), 'zerog-thumbs-')); + // The OS thumbnailer has no result here, so the fallback decode path runs. + createThumbnailFromPath.mockResolvedValue({ isEmpty: () => true }); + createFromPath.mockReset(); + createFromPath.mockReturnValue(fakeImage()); +}); +afterEach(() => { + rmSync(root, { recursive: true, force: true }); +}); + +describe('decodeImage', () => { + it('decodes a small image through the fallback path', async () => { + const file = join(root, 'small.png'); + writeFileSync(file, pngHeader(10, 10)); + const result = await decodeImage(file, 64); + expect(result).toMatchObject({ dataUrl: 'data:image/png;base64,AAAA', width: 10, height: 10 }); + expect(createFromPath).toHaveBeenCalledTimes(1); + expect(createFromPath).toHaveBeenCalledWith(file); + }); + + it('refuses to decode an image over the fallback pixel bound', async () => { + const file = join(root, 'huge.png'); + writeFileSync(file, pngHeader(20_000, 20_000)); + expect(await decodeImage(file, 4096)).toBeNull(); + expect(createFromPath).not.toHaveBeenCalled(); + }); + + it('refuses to decode a file whose header is unreadable', async () => { + const file = join(root, 'blob.png'); + writeFileSync(file, Buffer.alloc(4096)); + expect(await decodeImage(file, 64)).toBeNull(); + expect(createFromPath).not.toHaveBeenCalled(); + }); + + it('refuses to decode a file that cannot be read', async () => { + expect(await decodeImage(join(root, 'missing.png'), 64)).toBeNull(); + expect(createFromPath).not.toHaveBeenCalled(); + }); +}); From fad858e636e286286ebcfc778e4b6ff5003ab78a Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 12:55:24 +0000 Subject: [PATCH 15/18] fix(thumbnails): probe a 1 MiB JPEG header window Real JPEGs carry 100 KB+ of ICC/EXIF/XMP APPn segments before the SOF marker, so the 64 KiB probe window from 9a44c9c rejected files the synchronous createFromPath fallback had always decoded, losing preview and listing thumbnails. Raise the window to 1 MiB and cover the layout with a crafted SOF-beyond-64-KiB JPEG in both the decode and probe tests. --- src/main/thumbnails.ts | 9 +++++++-- tests/image-dims.test.ts | 27 +++++++++++++++++++++++++++ tests/thumbnails.test.ts | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/main/thumbnails.ts b/src/main/thumbnails.ts index afb8134..c5fe279 100644 --- a/src/main/thumbnails.ts +++ b/src/main/thumbnails.ts @@ -12,14 +12,19 @@ export type ThumbnailResult = { export type DecodedImage = ThumbnailResult; -const HEADER_PROBE_BYTES = 65_536; +/** + * Bytes read for the pre-decode header probe. JPEGs routinely carry 100 KB+ of + * ICC/EXIF/XMP APPn segments before the SOF marker, so a smaller window would + * reject files the synchronous fallback can actually decode. + */ +const IMAGE_HEADER_PROBE_BYTES = 1024 * 1024; /** Read a file's leading bytes so the header can be probed before decoding. */ async function readHeader(target: string): Promise { let handle; try { handle = await open(target, 'r'); - const buffer = Buffer.alloc(HEADER_PROBE_BYTES); + const buffer = Buffer.alloc(IMAGE_HEADER_PROBE_BYTES); let total = 0; while (total < buffer.length) { const { bytesRead } = await handle.read(buffer, total, buffer.length - total, total); diff --git a/tests/image-dims.test.ts b/tests/image-dims.test.ts index b6b792f..cc5f73a 100644 --- a/tests/image-dims.test.ts +++ b/tests/image-dims.test.ts @@ -53,6 +53,29 @@ function jpeg(width: number, height: number): Uint8Array { return bytes; } +/** + * SOI, APP1 chunks totalling ~70 KiB (a segment length field is 16-bit, so real + * ICC/EXIF/XMP blobs arrive as several chunks), then an SOF0 frame header. + */ +function jpegWithLargeApp1(width: number, height: number): Uint8Array { + const payloadLengths = [65_533, 5000]; + const sofAt = payloadLengths.reduce((at, n) => at + 4 + n, 2); + const bytes = new Uint8Array(sofAt + 19); + bytes.set([0xff, 0xd8], 0); + let at = 2; + for (const payloadLength of payloadLengths) { + bytes.set([0xff, 0xe1], at); + be16(bytes, at + 2, payloadLength + 2); + at += 4 + payloadLength; + } + bytes.set([0xff, 0xc0], sofAt); + be16(bytes, sofAt + 2, 0x0011); + bytes[sofAt + 4] = 0x08; + be16(bytes, sofAt + 5, height); + be16(bytes, sofAt + 7, width); + return bytes; +} + function gif(width: number, height: number): Uint8Array { const bytes = new Uint8Array(10); bytes.set([0x47, 0x49, 0x46, 0x38, 0x39, 0x61], 0); @@ -121,6 +144,10 @@ describe('probeImageDimensions', () => { expect(probeImageDimensions(jpeg(1920, 1080))).toEqual({ width: 1920, height: 1080 }); }); + it('reads JPEG dimensions from an SOF segment past a large APP1 block', () => { + expect(probeImageDimensions(jpegWithLargeApp1(640, 480))).toEqual({ width: 640, height: 480 }); + }); + it('skips fill bytes and standalone JPEG markers', () => { const bytes = new Uint8Array(28); bytes.set([0xff, 0xd8], 0); diff --git a/tests/thumbnails.test.ts b/tests/thumbnails.test.ts index 0d41b06..46a9f13 100644 --- a/tests/thumbnails.test.ts +++ b/tests/thumbnails.test.ts @@ -40,6 +40,29 @@ function pngHeader(width: number, height: number): Buffer { return bytes; } +/** + * SOI, then APP1 chunks totalling ~70 KiB (a segment length field is 16-bit, so + * real ICC/EXIF/XMP blobs arrive as several chunks), then an SOF0 frame header — + * the SOF marker therefore sits well past a 64 KiB header window. + */ +function jpegHeaderBeyond64KiB(width = 640, height = 480): Buffer { + const parts: Buffer[] = [Buffer.from([0xff, 0xd8])]; + for (const payloadLength of [65_533, 5000]) { + const header = Buffer.alloc(4); + header.set([0xff, 0xe1], 0); + header.writeUInt16BE(payloadLength + 2, 2); + parts.push(header, Buffer.alloc(payloadLength)); + } + const sof = Buffer.alloc(19); + sof.set([0xff, 0xc0], 0); + sof.writeUInt16BE(0x0011, 2); + sof[4] = 0x08; + sof.writeUInt16BE(height, 5); + sof.writeUInt16BE(width, 7); + parts.push(sof); + return Buffer.concat(parts); +} + let root: string; beforeEach(() => { @@ -63,6 +86,15 @@ describe('decodeImage', () => { expect(createFromPath).toHaveBeenCalledWith(file); }); + it('decodes a JPEG whose SOF marker sits beyond a 64 KiB header window', async () => { + const file = join(root, 'large-app1.jpg'); + writeFileSync(file, jpegHeaderBeyond64KiB(640, 480)); + const result = await decodeImage(file, 64); + expect(result).toMatchObject({ dataUrl: 'data:image/png;base64,AAAA' }); + expect(createFromPath).toHaveBeenCalledTimes(1); + expect(createFromPath).toHaveBeenCalledWith(file); + }); + it('refuses to decode an image over the fallback pixel bound', async () => { const file = join(root, 'huge.png'); writeFileSync(file, pngHeader(20_000, 20_000)); From fc80b8cccb3819e78c72dcb72fbabc5c2a6ce20c Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 16:34:24 +0000 Subject: [PATCH 16/18] chore: release v0.3.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 927bf39..6e328df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "zerogfileman", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zerogfileman", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "dependencies": { "@huggingface/transformers": "^4.3.2", diff --git a/package.json b/package.json index 506f3d2..eeef707 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zerogfileman", - "version": "0.3.0", + "version": "0.3.1", "description": "Local-first multi-pane voice-enabled file manager", "license": "MIT", "author": "Stephen Phillips", From a9af259c16502a941d8c9a242fa644fdb25ce715 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 16:56:08 +0000 Subject: [PATCH 17/18] chore: record spine memories for preview-pane slice --- ...-preview-pane-plan-safeexternalurl-help.md | 37 ++++++++++++++++ ...ane-slice-complete-on-branch-feat-previ.md | 44 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .agent/memories/history/2026-11-30T1219Z-task-4-of-preview-pane-plan-safeexternalurl-help.md create mode 100644 .agent/memories/history/2026-11-30T1256Z-preview-pane-slice-complete-on-branch-feat-previ.md diff --git a/.agent/memories/history/2026-11-30T1219Z-task-4-of-preview-pane-plan-safeexternalurl-help.md b/.agent/memories/history/2026-11-30T1219Z-task-4-of-preview-pane-plan-safeexternalurl-help.md new file mode 100644 index 0000000..50d42ac --- /dev/null +++ b/.agent/memories/history/2026-11-30T1219Z-task-4-of-preview-pane-plan-safeexternalurl-help.md @@ -0,0 +1,37 @@ +--- +kind: checkpoint +created: 2026-11-30T12:19:30Z +agent: cursor +sha: 22c24d2 +branch: feat/preview-pane +task_id: 4 +verification: {V0: pass, V1: pass} +id: 2026-11-30T1219Z-task-4-of-preview-pane-plan-safeexternalurl-help +--- +# Checkpoint: Task 4 of preview-pane plan: safeExternalUrl helper, fs:preview and shell:openU… + +## Summary + +Task 4 of preview-pane plan: safeExternalUrl helper, fs:preview and shell:openUrl IPC channels, preload + FileManApi types. Committed 22c24d2. + +## Done + +- src/shared/open-url.ts with safeExternalUrl (http/https only, no credentials, <=2048 chars) +- tests/open-url.test.ts (3 tests, RED then GREEN) +- main.ts handlers fs:preview (readPreview) and shell:openUrl (validated shell.openExternal) +- preload.cjs previewFile/openExternalUrl; types.ts previewFile/openExternalUrl + preview type re-exports +- Full suite 240 passed / 1 skipped, typecheck clean + +## Next + +- Task 5: PreviewPane component and styles +- Task 6: App wiring, guards, context menu, toolbar +- Task 7: ADR, docs, full verification and smoke + +## Blockers + +- (none) + +## Decisions + +- (none) diff --git a/.agent/memories/history/2026-11-30T1256Z-preview-pane-slice-complete-on-branch-feat-previ.md b/.agent/memories/history/2026-11-30T1256Z-preview-pane-slice-complete-on-branch-feat-previ.md new file mode 100644 index 0000000..15c94da --- /dev/null +++ b/.agent/memories/history/2026-11-30T1256Z-preview-pane-slice-complete-on-branch-feat-previ.md @@ -0,0 +1,44 @@ +--- +kind: checkpoint +created: 2026-11-30T12:56:11Z +agent: qoder +sha: fad858e +branch: feat/preview-pane +task_id: preview-pane +paths: [.superpowers/sdd/2026-11-30-preview-pane/progress.md, docs/adr/0006-right-slot-modes-and-preview.md, docs/superpowers/specs/2026-11-30-preview-pane-design.md] +verification: {V0: pass, V1: pass, V2: pass, V3: skip, V4: skip} +id: 2026-11-30T1256Z-preview-pane-slice-complete-on-branch-feat-previ +--- +# Checkpoint: Preview pane slice complete on branch feat/preview-pane (13 commits, a1ebb71..f… + +## Summary + +Preview pane slice complete on branch feat/preview-pane (13 commits, a1ebb71..fad858e). Right slot is browse|preview|closed; bounded fs:preview IPC with 32 MiB/4096 px/1 MiB caps, binary sniff, symlinks refused, pre-decode 40 MP header probe on the sync fallback; markdown without raw HTML, http(s)-only external links; F5/F6 + cross-pane guards when the peer isn't a listing. All 7 tasks passed per-task review; final whole-branch review fixed 2 Important + 6 minors; residual JPEG probe window fixed after re-review. + +## Done + +- T1 right-slot layout state + preview-path persistence +- T2 preview classifier + shared types +- T3 bounded main-process reader +- T4 URL helper + IPC (fs:preview, shell:openUrl) +- T5 PreviewPane + styles (react-markdown, remark-gfm) +- T6 slot lifecycle, follow-selection, context menu, toolbar guards +- T7 ADR-0006, SPEC M11-M13, ROADMAP D18/P3.7, PROGRESS +- Final review fixes: stale target clearing, 40 MP pre-decode bound, guard sweep, docs wording, 1 MiB JPEG probe window +- npm run ci at fad858e: typecheck clean, 36 files / 260 passed / 1 skipped, build OK + +## Next + +- Owner manual smoke (10-point checklist) on a real display +- Finish branch: merge to main / open PR / keep (user decision) +- Deferred minors in .superpowers/sdd/2026-11-30-preview-pane/progress.md + +## Blockers + +- Manual UI smoke not runnable in this environment (no display) — owner pass pending + +## Decisions + +- Explicit 'Preview in Pane' target beats the 180 ms follow-selection on slot entry +- Pre-decode pixel bound (40 MP) only on the synchronous createFromPath fallback; OS thumbnailer path unchanged +- Follow-selection clears previewTarget to null when no left selection (spec empty state) From f819f00b57aeb70b5a0c0728eafb05b18cbf68b3 Mon Sep 17 00:00:00 2001 From: Stephen Phillips Date: Mon, 30 Nov 2026 17:02:36 +0000 Subject: [PATCH 18/18] fix: hide Open action for symlink preview refusals --- src/renderer/preview-pane.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/preview-pane.tsx b/src/renderer/preview-pane.tsx index 965cb37..c7c21e7 100644 --- a/src/renderer/preview-pane.tsx +++ b/src/renderer/preview-pane.tsx @@ -102,7 +102,7 @@ export function PreviewPane(props: { body = (

{REASONS[result.reason]}

- {result.reason !== 'folder' && result.reason !== 'not-found' ? ( + {result.reason !== 'folder' && result.reason !== 'not-found' && result.reason !== 'symlink' ? (