Skip to content

Exports Workspaces and Editor

CapsaicinBunny edited this page Jun 20, 2026 · 1 revision

Exports, Workspaces & Editor

Three ways to get value out of a graph: export it to a file, save the view to return to later, and jump from a node to its source in your editor.

Exports

Export the current graph for docs, diagrams, or other tools (lib/export/). The browser download is handled by lib/client/download.ts, which uses a native Save-As dialog on desktop and a normal browser download on the web.

Format Use it for
DOT (Graphviz) Re-layout or post-process with the Graphviz toolchain (rankdir is set from the current direction)
GraphML Import into yEd, Gephi, and other graph tools (label/kind/filePath/line travel as data keys)
Mermaid Drop a diagram straight into Markdown docs
JSON The raw graph for your own scripts
SVG A vector snapshot of the current view
Standalone HTML report A single self-contained file with the insights + a figure, no external assets — good for sharing a review

SVG can also be rasterized to PNG in the browser (svgToPngBlob) when you need a bitmap.

Workspaces

A workspace captures the current view so you can restore or share it later (lib/workspace/):

  • What's saved: filters, layout (engine + direction + density), camera (pan/zoom), and pins.
  • Where: persisted in localStorage under a versioned key (polygraph.workspaces.v1), so saved views survive reloads.
  • Operations: list / save / load / delete named workspaces. Storage failures degrade gracefully to no-ops.

Workspaces are the lightweight way to keep a curated view (e.g. "the auth subsystem, force layout, externals on") without re-deriving it each time.

Editor integration

Desktop-only. A selected node's detail panel shows an inline source preview — a syntax-highlighted slice of the file (via Shiki) — and an Open in editor action.

  • Editors: VS Code (--goto file:line:column) and JetBrains IDEs (--line N --column N file). The command builders live in lib/editor/commands.ts and are pure, returning an argv array.
  • How it opens: the Tauri shell (src-tauri/src/lib.rs) exposes spawn_detached, which launches the editor with an argv array and no shell — so there's no command-injection surface.
  • Where it reads: read_source_slice serves the preview, with reads constrained to the scanned project root via a canonicalized-path check (you can't escape the root with .. or a symlink).

This is the last step of the core loop: select → blast radius → edge evidence → open in editor at the exact line.

Clone this wiki locally