Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
ADR 0169: Classified file preview and live workspace events for plugin views
- Status: Accepted
- Date: 2026-09-06
- Related: ADR 0104 · ADR 0105 · ADR 0109 · ADR 0111 · D332 · E2E-153
Context
The bundled pi.files view is a public plugin consumer (ADR 0105). After it
replaced the host Files tool, fs.readText could not classify images, binaries, or
oversized files, Open with default app had left the UI with reveal (ADR 0111),
panel events reached only detached ui.panel windows, and the view polled
workspace.get because workspace:changed did not exist.
Decision
- Add
pi.fs.readPreview(pathFromRoot)and the panel channelfs.readPreview, gated byfs.readand the declared-scope checks, classifying one existing regular file astext,image,binary, ortooLargeunder the host Files tab size caps; images return a data URL, binary and oversized files return no payload bytes, and directories are rejected. - Broadcast every plugin panel event to detached windows and live docked views
over the same
pi-plugin-panel-event:<event>preload channel. - Deliver
workspace:changedto panels and plugin processes whenever the cached workspace path changes, with theworkspace.get()payload{ path, name } | null. - Restore Open with default app, add search through
fs.glob, copy the root-relative path from a user gesture, and preview images throughfs.readPreview, all on public APIs.
Consequences
- Plugins can preview images and oversized files without a second read API.
- A docked view follows theme, locale, and project switches live.
- The Files plugin stays a public-API consumer; transcript
file:<path>tabs stay host-owned.
Alternatives
- Detect images in the plugin from
fs.readText: rejected, UTF-8 decoding of PNG or JPEG is lossy and cannot produce a data URL. - A private Files IPC channel: rejected, it recreates the host/plugin exception ADR 0105 removed.