Pi Chatview
中文说明 · English
Pi Chatview is a small, read-only local companion for the Pi terminal. It opens the current Pi session in a browser as a smooth Markdown and KaTeX timeline, while Pi remains the place to prompt, run tools, and edit files.
It is intentionally not a web-based Pi replacement: there is no prompt box, agent control panel, project tree, or file editor.
Highlights
- Markdown, fenced code, GFM tables, inline math
$...$, and display math $$...$$.
- KaTeX wide accents such as
$\widehat{A_h^n}$.
- A continuous user / assistant timeline with incremental updates over Server-Sent Events.
- A foreground refresh and a polling fallback when a browser tab resumes.
- Adjustable font size, line height, reading width, and history window; preferences are local to the browser.
- Source-aware copy: selecting rendered content and pressing
Ctrl+C copies editable original Markdown / LaTeX, not rendered Unicode text.
- Source-aware atomic copy for math, links, emphasis, code, headings, lists, quotes, and tables.
- Previous-message loading, per-card source copy, scroll controls, and a new-message notice.
- Local-only server: it binds to
127.0.0.1 and selects an available ephemeral port.
Install
From a Git repository
After this project is published, install a tagged release globally with Pi:
pi install git:github.com/oopjoy/Pi-Chatview@v0.1.0
For a project-local installation shared with a trusted project:
pi install -l git:github.com/oopjoy/Pi-Chatview@v0.1.0
Pi installs package dependencies automatically. Restart Pi or run /reload, then use:
/chatview
From a local clone or extracted archive
cd pi-chatview
npm install --omit=dev
pi install .
On macOS/Linux, use pi install . from the repository directory. The local path is registered without copying it, so keep the directory in place.
Manual extension installation
Alternatively, copy or clone this directory to one of Pi's auto-discovered extension locations, install runtime dependencies, then reload Pi:
~/.pi/agent/extensions/pi-chatview/
cd ~/.pi/agent/extensions/pi-chatview
npm install --omit=dev
Commands
/chatview Start the local viewer and open the current Pi session.
/chatview 50 Open with the latest 50 user turns selected.
/chatview status Show the local URL, session, SSE count, and sync revision.
/chatview stop Stop the local HTTP/SSE server.
/chatview help Show command help.
The allowed history windows are 5, 10, 20, 50, and 0 (0 means all). The server is started only when /chatview or /chatview status is used.
Security and privacy
- The viewer listens only on
127.0.0.1; it is not intentionally reachable from a LAN or the internet.
- It has no remote backend, telemetry, account, or cloud synchronization.
- The page exposes text from the currently active Pi session to browsers and processes running under the same local user account. Do not install untrusted local software while viewing sensitive sessions.
- Pi extensions run with the user's system permissions. Review the source before installing any third-party extension, including this one.
Source-aware copy
A card's 复制 button copies the full original message. More importantly, select a part of a rendered card and press Ctrl+C:
- Math is copied as a complete
$...$ or $$...$$ source fragment.
- Rich Markdown constructs are copied as complete valid source nodes.
- A selection spanning multiple messages is separated with
<!-- User --> and <!-- Pi --> comments.
For a wide hat covering the whole symbol, group its argument:
$\widehat{A_h^n}$
Without braces, \widehat A_h^n applies the accent only to A.
Development
Requirements:
- Node.js
>=22
- A current Pi installation for extension type definitions
- Chrome, Edge, or Chromium for the browser regression test
npm ci
npm run typecheck
npm run test:browser
The test auto-detects Chrome, Edge, or Chromium. To choose one explicitly:
CHATVIEW_BROWSER_PATH=/path/to/browser npm run test:browser
Windows PowerShell example:
$env:CHATVIEW_BROWSER_PATH = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
npm run test:browser
npm run test:browser is development-only. Puppeteer is not a runtime dependency and is not included in the published package.
Project layout
pi-chatview/
├── index.ts # Pi extension and localhost HTTP/SSE service
├── public/
│ ├── app.js # Timeline, sync, reading settings, source copy
│ ├── app.css # Responsive reading UI
│ ├── index.html
│ └── source-renderer.js # Markdown/KaTeX rendering with source offsets
├── tests/browser-smoke.mjs # Development browser regression test
└── package.json # Pi package manifest and runtime dependencies
Release checklist
- Run
npm ci && npm test.
- Review
npm run pack:check to ensure no node_modules, local settings, screenshots, or sessions are published.
- Commit and create a version tag such as
v0.1.0.
- Push the tag to GitHub.
- Install the exact tag with
pi install git:github.com/oopjoy/Pi-Chatview@v0.1.0.
License
MIT.
中文说明
Pi Chatview 是 Pi 终端的一个只读本地对话阅读副屏:Pi 终端继续承担提问、推理、工具调用和文件操作;浏览器页面负责连续阅读、Markdown / KaTeX 渲染与可编辑源码复制。
它刻意不做网页输入框、工程树、文件编辑器、模型管理或完整 Agent 工作台。
安装与启动
可使用固定版本安装:
pi install git:github.com/oopjoy/Pi-Chatview@v0.1.0
然后重启 Pi 或执行:
/reload
/chatview
若从本地目录试用:
cd pi-chatview
npm install --omit=dev
pi install .
常用命令
/chatview 启动并打开当前 Pi 会话
/chatview 50 默认显示最近 50 轮
/chatview status 查看本地地址、会话和同步状态
/chatview stop 停止本地服务
服务仅绑定到 127.0.0.1,端口自动选择,不会主动暴露到局域网。
功能
- user / assistant 连续时间线、历史加载与自动跟随。
- Markdown、代码块、表格、行内
$...$ 与独立 $$...$$ KaTeX 公式。
- 自动同步、前台恢复补拉和轮询兜底。
- 字号、行距、阅读宽度、显示轮数可调,并保存在浏览器本地。
- 单条复制,或选中正文后按
Ctrl+C 复制原始 Markdown / LaTeX 源码。
- 数学公式、链接、粗体、代码块、标题、列表、引用和表格会按完整有效源码复制。
需要让宽帽覆盖整个带上下标符号时,请写:
$\widehat{A_h^n}$
而不是 \widehat A_h^n;后者只会给 A 加帽。
隐私与安全
页面不发送会话内容到远程服务,也没有遥测或账户系统。但 Pi 扩展拥有用户权限,且同一用户下的本地进程理论上可访问回环地址,因此不要从不可信来源安装扩展,也不要在不可信本地环境中查看敏感会话。