feat: add Pi chat sidebar plugin #1

Merged
BlackHatMagic merged 5 commits from feat/chat-panel into master 2026-10-23 08:59:11 +00:00

PR Type Selection

  • 🎯 Feature - New capability or functionality

Summary

Adds Pi Chat, a desktop Obsidian plugin that runs the installed Pi coding agent in the right sidebar. It spawns the normal pi CLI in --mode rpc with the vault root as the working directory, streams assistant/reasoning/tool activity, and uses the vault's active theme through Obsidian CSS variables.

The interface follows the T3 Chat / Pi web workspace layout, adapted to Obsidian's narrower sidebar: native view actions, model and reasoning selectors, a compact status row, collapsible tool and reasoning blocks, and a composer with steering/follow-up modes.

None. This is the initial plugin implementation.

Design Overview

  • Core idea: Keep the plugin a thin client for the user's existing Pi installation instead of bundling a second agent runtime or handling credentials. A long-lived child process speaks Pi's documented JSONL RPC protocol; the view reduces events into chat state and renders with Obsidian APIs.
  • Data structures / algorithms: ChatState holds display messages, tool states, queue, model catalog, and session metadata. applyRecord incrementally reconstructs streaming message blocks from message_update deltas and applies completion events authoritatively. Full transcript renders are signature-gated so token deltas update only the live text nodes.
  • Interfaces added/changed: New ItemView (pi-chat-view), ribbon icon, four commands (open, new chat, restart, compact), and a settings tab. PiClient is a typed RPC command/response client with process lifecycle handling. PiSession owns Pi startup, hydration, model/thinking persistence, prompts, abort, and compaction.

Implementation Notes

  • Sessions use --session-dir <plugin>/sessions --session-id <id>; they persist across reloads but stay out of the vault and Obsidian Sync.
  • The CLI is resolved from an explicit setting, PI_OBSIDIAN_PI, augmented PATH (including mise shims), known install locations, then mise exec -- pi. GUI-launched Obsidian often does not inherit the shell's PATH, so this fallback matters.
  • Extension dialogs (select, confirm, input, editor) map to an Obsidian modal; extension notifications map to Notice; fire-and-forget widgets are intentionally not rendered.
  • All colors come from theme variables (--background-primary, --text-muted, --interactive-accent, etc.). No plugin palette or theme toggle.
  • Streaming text is plain until message_end, then Markdown is rendered by Obsidian so links, tables, and code highlighting behave natively.
  • Rejected alternatives: bundling the Pi SDK (larger, duplicates CLI config), a local HTTP bridge (extra daemon), and a custom color palette (breaks theme support).

Testing Evidence

  • Added tests: tests/chat-state.test.ts (stream reconstruction, tool-result attachment, history, queues, skill blocks, hidden custom/system messages); tests/launcher.test.ts (PATH lookup, explicit path, child environment).
  • bun run check passes: tsc --noEmit plus 9 tests.
  • bun run build produces main.js.
  • Manual verification: started a real pi --mode rpc child through PiClient and PiSession; hydrated 29 models and thinking levels; ran a prompt end-to-end (OK), ran a real read tool call against a temp note and confirmed tool/result blocks, then stopped and restarted the session and confirmed transcript restoration.
  • UI verified in light and dark theme tokens with a static DOM harness at 380px sidebar width.

Documentation

  • README updated with requirements, install, usage, architecture, security, and development notes
  • Design doc added/updated
  • Code comments added where behavior is non-obvious

Checklist (Feature-Specific)

  • Issue(s) linked (or rationale if none)
  • Tests added and passing
  • No Lint / Style violations
  • No dead / Debug / Commented-Out code
  • Follows course integrity guidelines

Additional Notes

  • The plugin is desktop-only by design (isDesktopOnly: true).
  • It trusts the user's Pi install and can run shell commands in the vault; README documents this.
  • Review focus: RPC lifecycle edge cases, event reducer reconstruction, and Obsidian theme/API compatibility.
## PR Type Selection - [x] 🎯 **Feature** - New capability or functionality ## Summary Adds **Pi Chat**, a desktop Obsidian plugin that runs the installed Pi coding agent in the right sidebar. It spawns the normal `pi` CLI in `--mode rpc` with the vault root as the working directory, streams assistant/reasoning/tool activity, and uses the vault's active theme through Obsidian CSS variables. The interface follows the T3 Chat / Pi web workspace layout, adapted to Obsidian's narrower sidebar: native view actions, model and reasoning selectors, a compact status row, collapsible tool and reasoning blocks, and a composer with steering/follow-up modes. ## Related Issues None. This is the initial plugin implementation. ## Design Overview - **Core idea:** Keep the plugin a thin client for the user's existing Pi installation instead of bundling a second agent runtime or handling credentials. A long-lived child process speaks Pi's documented JSONL RPC protocol; the view reduces events into chat state and renders with Obsidian APIs. - **Data structures / algorithms:** `ChatState` holds display messages, tool states, queue, model catalog, and session metadata. `applyRecord` incrementally reconstructs streaming message blocks from `message_update` deltas and applies completion events authoritatively. Full transcript renders are signature-gated so token deltas update only the live text nodes. - **Interfaces added/changed:** New `ItemView` (`pi-chat-view`), ribbon icon, four commands (open, new chat, restart, compact), and a settings tab. `PiClient` is a typed RPC command/response client with process lifecycle handling. `PiSession` owns Pi startup, hydration, model/thinking persistence, prompts, abort, and compaction. ## Implementation Notes - Sessions use `--session-dir <plugin>/sessions --session-id <id>`; they persist across reloads but stay out of the vault and Obsidian Sync. - The CLI is resolved from an explicit setting, `PI_OBSIDIAN_PI`, augmented `PATH` (including mise shims), known install locations, then `mise exec -- pi`. GUI-launched Obsidian often does not inherit the shell's PATH, so this fallback matters. - Extension dialogs (`select`, `confirm`, `input`, `editor`) map to an Obsidian modal; extension notifications map to `Notice`; fire-and-forget widgets are intentionally not rendered. - All colors come from theme variables (`--background-primary`, `--text-muted`, `--interactive-accent`, etc.). No plugin palette or theme toggle. - Streaming text is plain until `message_end`, then Markdown is rendered by Obsidian so links, tables, and code highlighting behave natively. - Rejected alternatives: bundling the Pi SDK (larger, duplicates CLI config), a local HTTP bridge (extra daemon), and a custom color palette (breaks theme support). ## Testing Evidence - Added tests: `tests/chat-state.test.ts` (stream reconstruction, tool-result attachment, history, queues, skill blocks, hidden custom/system messages); `tests/launcher.test.ts` (PATH lookup, explicit path, child environment). - `bun run check` passes: `tsc --noEmit` plus 9 tests. - `bun run build` produces `main.js`. - Manual verification: started a real `pi --mode rpc` child through `PiClient` and `PiSession`; hydrated 29 models and thinking levels; ran a prompt end-to-end (`OK`), ran a real `read` tool call against a temp note and confirmed tool/result blocks, then stopped and restarted the session and confirmed transcript restoration. - UI verified in light and dark theme tokens with a static DOM harness at 380px sidebar width. ## Documentation - [x] README updated with requirements, install, usage, architecture, security, and development notes - [ ] Design doc added/updated - [x] Code comments added where behavior is non-obvious ## Checklist (Feature-Specific) - [x] Issue(s) linked (or rationale if none) - [x] Tests added and passing - [x] No Lint / Style violations - [x] No dead / Debug / Commented-Out code - [x] Follows course integrity guidelines ## Additional Notes - The plugin is desktop-only by design (`isDesktopOnly: true`). - It trusts the user's Pi install and can run shell commands in the vault; README documents this. - Review focus: RPC lifecycle edge cases, event reducer reconstruction, and Obsidian theme/API compatibility.
Run the installed Pi CLI in RPC mode from an Obsidian right-sidebar view.
Stream assistant text, reasoning and tool activity with Obsidian-themed
rendering; expose model and reasoning selection, steering/follow-up
messages, stop, restart, new chat, compaction, extension dialogs, persistent
sessions and draft preservation.
Code-Reviewer left a comment

Pi code review

8 new actionable findings

  • [P2] Queued steering/follow-up chips not rendered while streaming — src/chat-view.ts:357
  • [P2] Windows npm Pi shims cannot be spawned without shell — src/pi-client.ts:53
  • [P2] Failed send overwrites newer composer draft — src/chat-view.ts:259
  • [P2] Initially empty streaming text block never appears — src/chat-view.ts:516
  • [P2] Reasoning text does not update while streaming — src/chat-view.ts:604
  • [P2] Invalid configured Pi path silently falls back to another binary — src/launcher.ts:119
  • [P2] Status dot always shows error/pulse state — styles.css:110
  • [P2] README and package claim MIT but LICENSE is AGPL-3.0 — README.md:127

Reviewed initial Pi Chat plugin covering RPC client, session lifecycle, reducer, sidebar rendering, launcher and styling. This is a static aggregation of three independent read-only reviews without builds, tests, or live Pi execution.

Change walkthrough
Area Files Changes
Other code (14) .gitignore, manifest.json, src/chat-state.ts, src/chat-view.ts (+10 more) New ignore rules for build output, data.json, and sessions New desktop-only plugin manifest New transcript reducer over Pi RPC records New ItemView rendering chat state with signature-gated re-renders
Documentation (1) README.md Rewritten for Pi Chat install, usage, architecture, and security
Deployment & tooling (4) bun.lock, esbuild.config.mjs, package.json, tsconfig.json Added lockfile for dev dependencies New esbuild build/watch configuration New package metadata and build/test scripts New strict TypeScript configuration
Tests (2) tests/chat-state.test.ts, tests/launcher.test.ts Reducer tests for streaming, tools, history, and queues Launcher tests for PATH lookup and child environment

Review effort: 3/5.

Static observations (not validation results)
Observation Detail
⚠️ Diff size 21 files, +4119/-15. Large diff; review coverage may be incomplete.
Binary changes No binary changes reported by this diff.
Credential patterns No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit.

Reviewed 5ec02574dc4ab89823e83e4c2ae6644e1368ed78 with proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3. Automated advisory review; no project commands or tests were executed.

<!-- forgejo-pi-review:7e0101475b9b4eeb74e936ece7c0968c673a29f6382ad4ba9827a20e8dc30c64 --> ## Pi code review **8 new actionable findings** - **[P2] Queued steering/follow-up chips not rendered while streaming** — `src/chat-view.ts:357` - **[P2] Windows npm Pi shims cannot be spawned without shell** — `src/pi-client.ts:53` - **[P2] Failed send overwrites newer composer draft** — `src/chat-view.ts:259` - **[P2] Initially empty streaming text block never appears** — `src/chat-view.ts:516` - **[P2] Reasoning text does not update while streaming** — `src/chat-view.ts:604` - **[P2] Invalid configured Pi path silently falls back to another binary** — `src/launcher.ts:119` - **[P2] Status dot always shows error/pulse state** — `styles.css:110` - **[P2] README and package claim MIT but LICENSE is AGPL-3.0** — `README.md:127` Reviewed initial Pi Chat plugin covering RPC client, session lifecycle, reducer, sidebar rendering, launcher and styling. This is a static aggregation of three independent read-only reviews without builds, tests, or live Pi execution. <details> <summary>Change walkthrough</summary> | Area | Files | Changes | | --- | --- | --- | | Other code (14) | `.gitignore`, `manifest.json`, `src/chat-state.ts`, `src/chat-view.ts` (+10 more) | New ignore rules for build output, data.json, and sessions New desktop-only plugin manifest New transcript reducer over Pi RPC records New ItemView rendering chat state with signature-gated re-renders | | Documentation (1) | `README.md` | Rewritten for Pi Chat install, usage, architecture, and security | | Deployment & tooling (4) | `bun.lock`, `esbuild.config.mjs`, `package.json`, `tsconfig.json` | Added lockfile for dev dependencies New esbuild build/watch configuration New package metadata and build/test scripts New strict TypeScript configuration | | Tests (2) | `tests/chat-state.test.ts`, `tests/launcher.test.ts` | Reducer tests for streaming, tools, history, and queues Launcher tests for PATH lookup and child environment | Review effort: **3/5**. </details> <details> <summary>Static observations (not validation results)</summary> | Observation | Detail | | --- | --- | | ⚠️ Diff size | 21 files, +4119/-15. Large diff; review coverage may be incomplete. | | Binary changes | No binary changes reported by this diff. | | Credential patterns | No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit. | </details> --- Reviewed `5ec02574dc4ab89823e83e4c2ae6644e1368ed78` with `proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3`. Automated advisory review; no project commands or tests were executed.
README.md Outdated
@ -35,0 +124,4 @@
## License
MIT. See [LICENSE.md](LICENSE.md).
Collaborator

[P2] README and package claim MIT but LICENSE is AGPL-3.0

README states MIT and package.json declares MIT while referenced LICENSE.md is AGPL-3.0, giving contradictory terms for same code.

Trigger: Anyone reading README, package metadata, or LICENSE.md.

Impact: License confusion with legal consequences for redistribution under wrong terms.

Evidence: LICENSE.md at head is GNU AFFERO GENERAL PUBLIC LICENSE Version 3; README License section says MIT; package.json sets license MIT.

**[P2] README and package claim MIT but LICENSE is AGPL-3.0** README states MIT and package.json declares MIT while referenced LICENSE.md is AGPL-3.0, giving contradictory terms for same code. **Trigger:** Anyone reading README, package metadata, or LICENSE.md. **Impact:** License confusion with legal consequences for redistribution under wrong terms. **Evidence:** LICENSE.md at head is GNU AFFERO GENERAL PUBLIC LICENSE Version 3; README License section says MIT; package.json sets license MIT.
src/chat-view.ts Outdated
@ -0,0 +256,4 @@
try {
await this.plugin.getSession().prompt(text, this.behavior);
} catch (error) {
this.composer.value = text;
Collaborator

[P2] Failed send overwrites newer composer draft

send() clears the composer then awaits prompt without locking editing; on failure it unconditionally restores the old text and draft, discarding anything typed while waiting.

Trigger: Send a message, start typing the next message, then the outstanding start/prompt request fails from Pi exit or timeout.

Impact: Newer unsent user text and its localStorage draft are lost with no recovery.

Evidence: src/chat-view.ts send clears composer before await PiSession.prompt and assigns captured text back in catch without checking current value; input stays editable and persists newer text, while PiSession.prompt/PiClient reject on process failure or timeout.

**[P2] Failed send overwrites newer composer draft** send() clears the composer then awaits prompt without locking editing; on failure it unconditionally restores the old text and draft, discarding anything typed while waiting. **Trigger:** Send a message, start typing the next message, then the outstanding start/prompt request fails from Pi exit or timeout. **Impact:** Newer unsent user text and its localStorage draft are lost with no recovery. **Evidence:** src/chat-view.ts send clears composer before await PiSession.prompt and assigns captured text back in catch without checking current value; input stays editable and persists newer text, while PiSession.prompt/PiClient reject on process failure or timeout.
@ -0,0 +354,4 @@
if (force || signature !== this.renderedMessageSignature || toolSignature !== this.renderedToolSignature) {
this.renderMessages(state);
this.renderedMessageSignature = signature;
this.renderedToolSignature = toolSignature;
Collaborator

[P2] Queued steering/follow-up chips not rendered while streaming

The fast live-update path returns after updating only text and tool nodes, skipping renderQueue. Queue changes do not affect message or tool signatures, so chips stay stale for the whole streaming run until a full re-render.

Trigger: While a live assistant message is streaming, a queue_update arrives, e.g. user sends Next step/After task while Pi works or Pi consumes a queued item.

Impact: Users get no or stale confirmation that steering/follow-up was queued or consumed, defeating the queue UI purpose.

Evidence: src/chat-view.ts render(): if (canUpdateLive && live) { this.updateLiveMessage(live); this.updateToolNodes(state); return; } skips renderQueue; queue_update only writes state.queue and messageSignature/toolSignature cover only messages/tools.

Suggested fix:

if (canUpdateLive && live) {
       this.updateLiveMessage(live);
       this.updateToolNodes(state);
+      this.renderQueue(state);
       return;
     }
**[P2] Queued steering/follow-up chips not rendered while streaming** The fast live-update path returns after updating only text and tool nodes, skipping renderQueue. Queue changes do not affect message or tool signatures, so chips stay stale for the whole streaming run until a full re-render. **Trigger:** While a live assistant message is streaming, a queue_update arrives, e.g. user sends Next step/After task while Pi works or Pi consumes a queued item. **Impact:** Users get no or stale confirmation that steering/follow-up was queued or consumed, defeating the queue UI purpose. **Evidence:** src/chat-view.ts render(): `if (canUpdateLive && live) { this.updateLiveMessage(live); this.updateToolNodes(state); return; }` skips renderQueue; queue_update only writes state.queue and messageSignature/toolSignature cover only messages/tools. Suggested fix: ```diff if (canUpdateLive && live) { this.updateLiveMessage(live); this.updateToolNodes(state); + this.renderQueue(state); return; } ```
src/chat-view.ts Outdated
@ -0,0 +513,4 @@
private renderBlock(parent: HTMLElement, block: ChatBlock, message: ChatMessage, index: number): void {
if (block.type === "text") {
if (!block.text.trim()) return;
Collaborator

[P2] Initially empty streaming text block never appears

renderBlock omits empty text blocks, but later deltas use the incremental path that cannot create the missing node, so the answer stays invisible until a structural re-render.

Trigger: Pi emits text_start and first nonempty text_delta arrives after next animation frame, with no new block added during the answer.

Impact: Primary streaming response is hidden until message_end instead of streaming visibly.

Evidence: src/chat-state.ts applyAssistantDelta creates empty text block for text_start; src/chat-view.ts renderBlock returns early if !block.text.trim(); messageSignature excludes streaming text lengths so canUpdateLive holds and updateLiveMessage queries absent data-block-index and skips.

**[P2] Initially empty streaming text block never appears** renderBlock omits empty text blocks, but later deltas use the incremental path that cannot create the missing node, so the answer stays invisible until a structural re-render. **Trigger:** Pi emits text_start and first nonempty text_delta arrives after next animation frame, with no new block added during the answer. **Impact:** Primary streaming response is hidden until message_end instead of streaming visibly. **Evidence:** src/chat-state.ts applyAssistantDelta creates empty text block for text_start; src/chat-view.ts renderBlock returns early if !block.text.trim(); messageSignature excludes streaming text lengths so canUpdateLive holds and updateLiveMessage queries absent data-block-index and skips.
src/chat-view.ts Outdated
@ -0,0 +601,4 @@
if (!(el instanceof HTMLElement)) continue;
if (el.classList.contains("pi-chat-streaming-text") && block.type === "text" && el.textContent !== block.text) {
el.setText(block.text);
} else if (el.classList.contains("pi-chat-thinking-text") && block.type === "thinking" && el.textContent !== block.text) {
Collaborator

[P2] Reasoning text does not update while streaming

Incremental updater selects the details element carrying data-block-index but tests it for the child-only thinking-text class, so the condition never succeeds and expanded reasoning stays frozen.

Trigger: Use reasoning model with thinking block expanded or Expand thinking enabled while thinking deltas arrive for same block.

Impact: Users cannot monitor ongoing reasoning; content stays empty or stale until full render.

Evidence: src/chat-view.ts places data-block-index on details and pi-chat-thinking-text on nested div; updateLiveMessage selects data-block-index element and tests same element for pi-chat-thinking-text; streaming thinking does not change messageSignature.

**[P2] Reasoning text does not update while streaming** Incremental updater selects the details element carrying data-block-index but tests it for the child-only thinking-text class, so the condition never succeeds and expanded reasoning stays frozen. **Trigger:** Use reasoning model with thinking block expanded or Expand thinking enabled while thinking deltas arrive for same block. **Impact:** Users cannot monitor ongoing reasoning; content stays empty or stale until full render. **Evidence:** src/chat-view.ts places data-block-index on details and pi-chat-thinking-text on nested div; updateLiveMessage selects data-block-index element and tests same element for pi-chat-thinking-text; streaming thinking does not change messageSignature.
@ -0,0 +116,4 @@
for (const path of knownPiPaths(homedir())) {
if (existsSync(path)) candidates.push({ command: path, args: bases, source: "Known install location" });
}
for (const candidate of candidates) {
Collaborator

[P2] Invalid configured Pi path silently falls back to another binary

resolvePiLaunch treats explicit setting as just one candidate and returns first executable, so a typo or non-executable configured path falls through to PATH/known locations/mise instead of erroring.

Trigger: Set Settings Pi executable to non-existent or non-executable path while working pi exists on augmented PATH or known location.

Impact: Runs a different Pi binary than user pinned, defeating explicit configuration and hiding the error; may run unexpected binary.

Evidence: src/launcher.ts loops candidates and returns first executable; configuredValue only changes final throw message, contradicting comment that explicit setting always wins.

Suggested fix:

--- a/src/launcher.ts
+++ b/src/launcher.ts
@@
   const configuredValue = configured.trim();
   if (configuredValue) {
-    candidates.push({
-      command: resolve(expandHome(configuredValue)),
-      args: bases,
-      source: "Configured path",
-    });
+    const command = resolve(expandHome(configuredValue));
+    if (!executable(command, platform)) {
+      throw new PiNotFoundError(`Could not run the configured Pi executable: ${configuredValue}`);
+    }
+    return { command, args: bases, display: command, source: "Configured path" };
   }
**[P2] Invalid configured Pi path silently falls back to another binary** resolvePiLaunch treats explicit setting as just one candidate and returns first executable, so a typo or non-executable configured path falls through to PATH/known locations/mise instead of erroring. **Trigger:** Set Settings Pi executable to non-existent or non-executable path while working pi exists on augmented PATH or known location. **Impact:** Runs a different Pi binary than user pinned, defeating explicit configuration and hiding the error; may run unexpected binary. **Evidence:** src/launcher.ts loops candidates and returns first executable; configuredValue only changes final throw message, contradicting comment that explicit setting always wins. Suggested fix: ```diff --- a/src/launcher.ts +++ b/src/launcher.ts @@ const configuredValue = configured.trim(); if (configuredValue) { - candidates.push({ - command: resolve(expandHome(configuredValue)), - args: bases, - source: "Configured path", - }); + const command = resolve(expandHome(configuredValue)); + if (!executable(command, platform)) { + throw new PiNotFoundError(`Could not run the configured Pi executable: ${configuredValue}`); + } + return { command, args: bases, display: command, source: "Configured path" }; } ```
src/pi-client.ts Outdated
@ -0,0 +50,4 @@
async start(timeoutMs = 20_000): Promise<void> {
if (this.child) return;
const { cwd, launch, env } = this.options;
const child = spawn(launch.command, launch.args, {
Collaborator

[P2] Windows npm Pi shims cannot be spawned without shell

Launcher accepts Windows .CMD/.BAT and extensionless shims as winning candidates, but PiClient spawns the path directly with no shell, which Node/Electron rejects for .cmd/.bat and cannot execute POSIX sh shims.

Trigger: Open chat on Windows with Pi installed via npm with its shim directory on PATH, or configured as pi.cmd.

Impact: Pi child fails to start so chat is unavailable on a common Windows install layout.

Evidence: src/launcher.ts pathExtensions includes ""/.CMD/.BAT and executable() skips format checks on win32, so findOnPath can return pi.cmd or POSIX pi; src/pi-client.ts spawn uses {cwd, env, stdio, windowsHide:true} with no shell option, and PiSession.doStart uses that launch unchanged.

**[P2] Windows npm Pi shims cannot be spawned without shell** Launcher accepts Windows .CMD/.BAT and extensionless shims as winning candidates, but PiClient spawns the path directly with no shell, which Node/Electron rejects for .cmd/.bat and cannot execute POSIX sh shims. **Trigger:** Open chat on Windows with Pi installed via npm with its shim directory on PATH, or configured as pi.cmd. **Impact:** Pi child fails to start so chat is unavailable on a common Windows install layout. **Evidence:** src/launcher.ts pathExtensions includes ""/.CMD/.BAT and executable() skips format checks on win32, so findOnPath can return pi.cmd or POSIX pi; src/pi-client.ts spawn uses {cwd, env, stdio, windowsHide:true} with no shell option, and PiSession.doStart uses that launch unchanged.
styles.css Outdated
@ -0,0 +107,4 @@
white-space: nowrap;
}
.pi-chat-status-dot {
Collaborator

[P2] Status dot always shows error/pulse state

Busy and error dot rules are written as plain .pi-chat-status-dot so they unconditionally override idle style; qualifiers were applied to text element instead.

Trigger: Open Pi Chat in any state and observe status dot.

Impact: Idle chats show red pulsing dot, misrepresenting busy/error and removing dot distinction for real errors.

Evidence: styles.css defines idle faint dot, then unconditionally sets accent+animation and later error background on .pi-chat-status-dot; .is-busy/.is-error qualifiers only target .pi-chat-status-text.

Suggested fix:

--- a/styles.css
+++ b/styles.css
@@
-.pi-chat-status-dot {
+.pi-chat-status.is-busy .pi-chat-status-dot {
   background: var(--pi-accent);
   animation: pi-chat-pulse 1.4s ease-in-out infinite;
 }
@@
-.pi-chat-status-dot {
+.pi-chat-status.is-error .pi-chat-status-dot {
   background: var(--pi-error);
 }
**[P2] Status dot always shows error/pulse state** Busy and error dot rules are written as plain .pi-chat-status-dot so they unconditionally override idle style; qualifiers were applied to text element instead. **Trigger:** Open Pi Chat in any state and observe status dot. **Impact:** Idle chats show red pulsing dot, misrepresenting busy/error and removing dot distinction for real errors. **Evidence:** styles.css defines idle faint dot, then unconditionally sets accent+animation and later error background on .pi-chat-status-dot; .is-busy/.is-error qualifiers only target .pi-chat-status-text. Suggested fix: ```diff --- a/styles.css +++ b/styles.css @@ -.pi-chat-status-dot { +.pi-chat-status.is-busy .pi-chat-status-dot { background: var(--pi-accent); animation: pi-chat-pulse 1.4s ease-in-out infinite; } @@ -.pi-chat-status-dot { +.pi-chat-status.is-error .pi-chat-status-dot { background: var(--pi-error); } ```
- Render queued instructions in the live streaming fast path.
- Preserve a newer composer draft when a send fails.
- Render empty streaming text nodes so the first delta is visible.
- Update streaming reasoning through the inner text node.
- Fail on an invalid explicit Pi path instead of silently falling back.
- Spawn Windows cmd/bat Pi shims through the shell and skip POSIX
  extensionless shims during PATH lookup.
- Scope status-dot busy/error CSS to the status element.
- Align README and package license with the AGPL-3.0 LICENSE.md.
Code-Reviewer left a comment

Pi code review

2 new actionable findings

  • [P2] Windows shell launches do not preserve paths containing spaces — src/pi-client.ts:53
  • [P2] Overlapping New chat operations can lose the persisted session reference — src/session.ts:320
Earlier findings: 8 rechecked
  • Resolved: Windows npm Pi shims cannot be spawned without shell (src/pi-client.ts:53, first reported in review #230) — src/launcher.ts pathExtensions() excludes extensionless candidates on win32, needsShell() marks .cmd/.bat, and src/pi-client.ts spawn passes shell: launch.shell.
  • Resolved: README and package claim MIT but LICENSE is AGPL-3.0 (README.md:127, first reported in review #230) — package.json license is AGPL-3.0-only, README License section reads AGPL-3.0, matching LICENSE.md AGPL text.
  • Resolved: Invalid configured Pi path silently falls back to another binary (src/launcher.ts:119, first reported in review #230) — src/launcher.ts resolvePiLaunch() throws PiNotFoundError when a non-empty configured value cannot be resolved to an executable file and returns it directly instead of falling back.
  • Resolved: Failed send overwrites newer composer draft (src/chat-view.ts:259, first reported in review #230) — src/chat-view.ts send() catch only restores the captured text when the current composer is empty after trimming, preserving newer drafts.
  • Resolved: Status dot always shows error/pulse state (styles.css:110, first reported in review #230) — styles.css scopes accent/pulse to .pi-chat-status.is-busy .pi-chat-status-dot and error color to .pi-chat-status.is-error .pi-chat-status-dot.
  • Uncertain — kept for recheck: Queued steering/follow-up chips not rendered while streaming (src/chat-view.ts:357, first reported in review #230) — Not rechecked by this review; kept open for the next one.
  • Uncertain — kept for recheck: Initially empty streaming text block never appears (src/chat-view.ts:516, first reported in review #230) — Not rechecked by this review; kept open for the next one.
  • Uncertain — kept for recheck: Reasoning text does not update while streaming (src/chat-view.ts:604, first reported in review #230) — Not rechecked by this review; kept open for the next one.

Merged three candidate reviews of the initial Pi Chat plugin at b18c4a5; verified current code by inspection without running builds or Pi/Obsidian runtimes. All eight prior findings are fixed in head, with two residual concurrency and Windows launch defects carried forward.

Change walkthrough
Area Files Changes
Other code (10) src/main.ts, src/pi-client.ts, src/session.ts, src/launcher.ts (+6 more) Registers sidebar view, commands, settings, and session host. Adds child-process management and correlated JSONL RPC requests. Adds startup, hydration, prompts, and session lifecycle operations. Adds executable discovery, Windows shim selection, and child environment.

Review effort: 4/5.

Static observations (not validation results)
Observation Detail
⚠️ Diff size 21 files, +4162/-15. Large diff; review coverage may be incomplete.
Binary changes No binary changes reported by this diff.
Credential patterns No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit.

Reviewed b18c4a538df4bcf0586fbbcdc4b8522bd8316ccf with proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3. Automated advisory review; no project commands or tests were executed.

<!-- forgejo-pi-review:83c71006dc15e4c8d4b415ae8844e6928f2819d6aac38776296128d62220c89e --> ## Pi code review **2 new actionable findings** - **[P2] Windows shell launches do not preserve paths containing spaces** — `src/pi-client.ts:53` - **[P2] Overlapping New chat operations can lose the persisted session reference** — `src/session.ts:320` <details> <summary>Earlier findings: 8 rechecked</summary> - **Resolved:** Windows npm Pi shims cannot be spawned without shell (`src/pi-client.ts:53`, first reported in review #230) — src/launcher.ts pathExtensions() excludes extensionless candidates on win32, needsShell() marks .cmd/.bat, and src/pi-client.ts spawn passes shell: launch.shell. - **Resolved:** README and package claim MIT but LICENSE is AGPL-3.0 (`README.md:127`, first reported in review #230) — package.json license is AGPL-3.0-only, README License section reads AGPL-3.0, matching LICENSE.md AGPL text. - **Resolved:** Invalid configured Pi path silently falls back to another binary (`src/launcher.ts:119`, first reported in review #230) — src/launcher.ts resolvePiLaunch() throws PiNotFoundError when a non-empty configured value cannot be resolved to an executable file and returns it directly instead of falling back. - **Resolved:** Failed send overwrites newer composer draft (`src/chat-view.ts:259`, first reported in review #230) — src/chat-view.ts send() catch only restores the captured text when the current composer is empty after trimming, preserving newer drafts. - **Resolved:** Status dot always shows error/pulse state (`styles.css:110`, first reported in review #230) — styles.css scopes accent/pulse to .pi-chat-status.is-busy .pi-chat-status-dot and error color to .pi-chat-status.is-error .pi-chat-status-dot. - **Uncertain — kept for recheck:** Queued steering/follow-up chips not rendered while streaming (`src/chat-view.ts:357`, first reported in review #230) — Not rechecked by this review; kept open for the next one. - **Uncertain — kept for recheck:** Initially empty streaming text block never appears (`src/chat-view.ts:516`, first reported in review #230) — Not rechecked by this review; kept open for the next one. - **Uncertain — kept for recheck:** Reasoning text does not update while streaming (`src/chat-view.ts:604`, first reported in review #230) — Not rechecked by this review; kept open for the next one. </details> Merged three candidate reviews of the initial Pi Chat plugin at b18c4a5; verified current code by inspection without running builds or Pi/Obsidian runtimes. All eight prior findings are fixed in head, with two residual concurrency and Windows launch defects carried forward. <details> <summary>Change walkthrough</summary> | Area | Files | Changes | | --- | --- | --- | | Other code (10) | `src/main.ts`, `src/pi-client.ts`, `src/session.ts`, `src/launcher.ts` (+6 more) | Registers sidebar view, commands, settings, and session host. Adds child-process management and correlated JSONL RPC requests. Adds startup, hydration, prompts, and session lifecycle operations. Adds executable discovery, Windows shim selection, and child environment. | Review effort: **4/5**. </details> <details> <summary>Static observations (not validation results)</summary> | Observation | Detail | | --- | --- | | ⚠️ Diff size | 21 files, +4162/-15. Large diff; review coverage may be incomplete. | | Binary changes | No binary changes reported by this diff. | | Credential patterns | No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit. | </details> --- Reviewed `b18c4a538df4bcf0586fbbcdc4b8522bd8316ccf` with `proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3`. Automated advisory review; no project commands or tests were executed.
@ -0,0 +50,4 @@
async start(timeoutMs = 20_000): Promise<void> {
if (this.child) return;
const { cwd, launch, env } = this.options;
const child = spawn(launch.command, launch.args, {
Collaborator

[P2] Windows shell launches do not preserve paths containing spaces

Enabling shell execution for .cmd/.bat shims passes the executable and session directory to cmd.exe without shell quoting. Node shell-mode spawn joins command and arguments into a command string rather than preserving argv boundaries, so spaces in the install or vault path break the launch or truncate the session-directory argument.

Trigger: Open chat on Windows using an npm pi.cmd shim with a space in its executable path or the vault/plugin path, such as a vault named My Notes.

Impact: Chat can fail to start on a common Windows layout, or Pi can receive a truncated session directory and store sessions outside the intended plugin folder.

Evidence: src/launcher.ts needsShell() enables shell execution for .cmd/.bat; src/session.ts appends the raw host.sessionDir as an argument derived from the vault/plugin folder in src/main.ts; src/pi-client.ts passes those raw values directly to spawn with shell: launch.shell with no quoting or shim-to-native conversion. The Windows launcher test only checks resolution and the shell flag, not execution with these paths.

**[P2] Windows shell launches do not preserve paths containing spaces** Enabling shell execution for .cmd/.bat shims passes the executable and session directory to cmd.exe without shell quoting. Node shell-mode spawn joins command and arguments into a command string rather than preserving argv boundaries, so spaces in the install or vault path break the launch or truncate the session-directory argument. **Trigger:** Open chat on Windows using an npm pi.cmd shim with a space in its executable path or the vault/plugin path, such as a vault named My Notes. **Impact:** Chat can fail to start on a common Windows layout, or Pi can receive a truncated session directory and store sessions outside the intended plugin folder. **Evidence:** src/launcher.ts needsShell() enables shell execution for .cmd/.bat; src/session.ts appends the raw host.sessionDir as an argument derived from the vault/plugin folder in src/main.ts; src/pi-client.ts passes those raw values directly to spawn with shell: launch.shell with no quoting or shim-to-native conversion. The Windows launcher test only checks resolution and the shell flag, not execution with these paths.
@ -0,0 +317,4 @@
}
async newSession(): Promise<void> {
await this.stop();
Collaborator

[P2] Overlapping New chat operations can lose the persisted session reference

newSession() does not serialize the stop/save/start sequence. A second invocation can start a new child while the first is still stopping the old child; the first invocation then overwrites the saved session ID, but start() reuses the second invocation's already-running or starting child.

Trigger: Invoke New chat twice while an existing child is stopping, for example by double-clicking the settings tab New chat button. PiClient.stop() can remain pending for several seconds.

Impact: The running chat and settings can refer to different session IDs. Messages written by the running child are not restored after reload because startup opens the other saved ID, leaving the conversation apparently lost.

Evidence: src/settings.ts exposes an async New chat button without disabling or serializing it, and src/main.ts startNewSession() forwards directly to session.newSession(). In src/session.ts stop() sets this.client to null before awaiting client.stop(), allowing a second stop() to finish immediately. Each newSession() independently saves a fresh ID while start()/doStart() reuse this.starting or an already-running child rather than checking which session ID that child owns.

**[P2] Overlapping New chat operations can lose the persisted session reference** newSession() does not serialize the stop/save/start sequence. A second invocation can start a new child while the first is still stopping the old child; the first invocation then overwrites the saved session ID, but start() reuses the second invocation's already-running or starting child. **Trigger:** Invoke New chat twice while an existing child is stopping, for example by double-clicking the settings tab New chat button. PiClient.stop() can remain pending for several seconds. **Impact:** The running chat and settings can refer to different session IDs. Messages written by the running child are not restored after reload because startup opens the other saved ID, leaving the conversation apparently lost. **Evidence:** src/settings.ts exposes an async New chat button without disabling or serializing it, and src/main.ts startNewSession() forwards directly to session.newSession(). In src/session.ts stop() sets this.client to null before awaiting client.stop(), allowing a second stop() to finish immediately. Each newSession() independently saves a fresh ID while start()/doStart() reuse this.starting or an already-running child rather than checking which session ID that child owns.
- Run start, stop, restart, and new-session operations in submission order
  so overlapping New chat clicks cannot leave settings and the live child
  pointing at different session IDs.
- Spawn .cmd/.bat shims through an explicitly quoted cmd.exe command line
  instead of Node's unquoted shell mode, preserving paths with spaces.
- Expose the hydrated Pi session id in chat state for lifecycle tests.
- Add Windows command-line quoting tests.
Code-Reviewer left a comment

Pi code review

3 new actionable findings

  • [P2] Long streamed answers stop following the transcript bottom — src/chat-view.ts:357
  • [P2] Active-note suggestions omit the note's identity — src/chat-view.ts:221
  • [P2] Windows shim launches can orphan the pi process on stop/restart — src/pi-client.ts:224
Earlier findings: 5 rechecked
  • Resolved: Queued steering/follow-up chips not rendered while streaming (src/chat-view.ts:357, first reported in review #230) — src/chat-view.ts render() canUpdateLive branch now calls this.renderQueue(state) before returning, so queue chips update during streaming.
  • Resolved: Windows shell launches do not preserve paths containing spaces (src/pi-client.ts:53, first reported in review #232) — src/pi-client.ts builds quoted cmd /d /s /c line via quoteWindowsArgument/windowsShellInvocation with windowsVerbatimArguments:true; tests/pi-client.test.ts asserts quoting for paths with spaces.
  • Resolved: Overlapping New chat operations can lose the persisted session reference (src/session.ts:320, first reported in review #232) — src/session.ts routes start/stop/restart/newSession through enqueue()/lifecycle promise chain, so overlapping New chat sequences run in submission order.
  • Resolved: Initially empty streaming text block never appears (src/chat-view.ts:516, first reported in review #230) — src/chat-view.ts renderBlock() only skips empty text when !message.streaming and renders .pi-chat-streaming-text node with data-block-index for live updates.
  • Resolved: Reasoning text does not update while streaming (src/chat-view.ts:604, first reported in review #230) — src/chat-view.ts thinking text div now carries data-block-index and updateLiveMessage queries .pi-chat-thinking-text[data-block-index], matching the live node.

Reviewed the initial Pi Chat plugin at head against its feature intent, covering RPC lifecycle, reducer, sidebar UI, launcher and docs. Verification was read-only from current code and candidate evidence with no builds, tests, or live Pi/Obsidian runs.

Change walkthrough
Area Files Changes
Other code (9) src/chat-view.ts, src/chat-state.ts, src/session.ts, src/pi-client.ts (+5 more) Sidebar view with streaming render, selectors, composer and queue Event reducer for streaming deltas, history and tool results Serialized lifecycle, hydration, prompts and compaction Long-lived RPC process with quoted Windows shell invocation
Tests (1) tests/chat-state.test.ts Reducer tests for streaming, tools and history

Review effort: 4/5.

Static observations (not validation results)
Observation Detail
⚠️ Diff size 22 files, +4234/-15. Large diff; review coverage may be incomplete.
Binary changes No binary changes reported by this diff.
Credential patterns No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit.

Reviewed eed88bff6e6770a961c73dcee45cc20ffc358ffb with proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3. Automated advisory review; no project commands or tests were executed.

<!-- forgejo-pi-review:129ffd4121fc1b289211c81cb8c5b51b7c6be6991e9dab02c8b05a4435e1e7a2 --> ## Pi code review **3 new actionable findings** - **[P2] Long streamed answers stop following the transcript bottom** — `src/chat-view.ts:357` - **[P2] Active-note suggestions omit the note's identity** — `src/chat-view.ts:221` - **[P2] Windows shim launches can orphan the pi process on stop/restart** — `src/pi-client.ts:224` <details> <summary>Earlier findings: 5 rechecked</summary> - **Resolved:** Queued steering/follow-up chips not rendered while streaming (`src/chat-view.ts:357`, first reported in review #230) — src/chat-view.ts render() canUpdateLive branch now calls this.renderQueue(state) before returning, so queue chips update during streaming. - **Resolved:** Windows shell launches do not preserve paths containing spaces (`src/pi-client.ts:53`, first reported in review #232) — src/pi-client.ts builds quoted cmd /d /s /c line via quoteWindowsArgument/windowsShellInvocation with windowsVerbatimArguments:true; tests/pi-client.test.ts asserts quoting for paths with spaces. - **Resolved:** Overlapping New chat operations can lose the persisted session reference (`src/session.ts:320`, first reported in review #232) — src/session.ts routes start/stop/restart/newSession through enqueue()/lifecycle promise chain, so overlapping New chat sequences run in submission order. - **Resolved:** Initially empty streaming text block never appears (`src/chat-view.ts:516`, first reported in review #230) — src/chat-view.ts renderBlock() only skips empty text when !message.streaming and renders .pi-chat-streaming-text node with data-block-index for live updates. - **Resolved:** Reasoning text does not update while streaming (`src/chat-view.ts:604`, first reported in review #230) — src/chat-view.ts thinking text div now carries data-block-index and updateLiveMessage queries .pi-chat-thinking-text[data-block-index], matching the live node. </details> Reviewed the initial Pi Chat plugin at head against its feature intent, covering RPC lifecycle, reducer, sidebar UI, launcher and docs. Verification was read-only from current code and candidate evidence with no builds, tests, or live Pi/Obsidian runs. <details> <summary>Change walkthrough</summary> | Area | Files | Changes | | --- | --- | --- | | Other code (9) | `src/chat-view.ts`, `src/chat-state.ts`, `src/session.ts`, `src/pi-client.ts` (+5 more) | Sidebar view with streaming render, selectors, composer and queue Event reducer for streaming deltas, history and tool results Serialized lifecycle, hydration, prompts and compaction Long-lived RPC process with quoted Windows shell invocation | | Tests (1) | `tests/chat-state.test.ts` | Reducer tests for streaming, tools and history | Review effort: **4/5**. </details> <details> <summary>Static observations (not validation results)</summary> | Observation | Detail | | --- | --- | | ⚠️ Diff size | 22 files, +4234/-15. Large diff; review coverage may be incomplete. | | Binary changes | No binary changes reported by this diff. | | Credential patterns | No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit. | </details> --- Reviewed `eed88bff6e6770a961c73dcee45cc20ffc358ffb` with `proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3`. Automated advisory review; no project commands or tests were executed.
@ -0,0 +218,4 @@
});
const suggestions = this.emptyEl.createDiv({ cls: "pi-chat-suggestions" });
for (const [icon, label, prompt] of [
["file-search", "Summarize the active note", "Summarize the note I'm currently viewing. Mention its main ideas and open questions."],
Collaborator

[P2] Active-note suggestions omit the note's identity

The Summarize the active note and Find related notes suggestions populate only generic referring text and never supply the active file path, so Pi cannot identify the intended note.

Trigger: Open a note in a multi-note vault, click either active-note suggestion in an empty chat, and send it without separately using the file-path insertion button.

Impact: Advertised shortcuts cannot reliably perform their task; Pi must ask for the missing note or infer a potentially wrong target.

Evidence: src/chat-view.ts buildEmptyState defines prompts containing only currently viewing/active note and the click handler assigns that literal to the composer; send() forwards trimmed text via PiSession.prompt() with only streamingBehavior, while cwd is the vault root and insertActiveNote() is a separate explicit action never invoked by the suggestions.

**[P2] Active-note suggestions omit the note's identity** The Summarize the active note and Find related notes suggestions populate only generic referring text and never supply the active file path, so Pi cannot identify the intended note. **Trigger:** Open a note in a multi-note vault, click either active-note suggestion in an empty chat, and send it without separately using the file-path insertion button. **Impact:** Advertised shortcuts cannot reliably perform their task; Pi must ask for the missing note or infer a potentially wrong target. **Evidence:** src/chat-view.ts buildEmptyState defines prompts containing only currently viewing/active note and the click handler assigns that literal to the composer; send() forwards trimmed text via PiSession.prompt() with only streamingBehavior, while cwd is the vault root and insertActiveNote() is a separate explicit action never invoked by the suggestions.
@ -0,0 +354,4 @@
signature === this.renderedMessageSignature &&
toolSignature === this.renderedToolSignature;
if (canUpdateLive && live) {
this.updateLiveMessage(live);
Collaborator

[P2] Long streamed answers stop following the transcript bottom

The incremental live-update path grows the live message without preserving bottom-following, so once a single text block streams past the viewport the new output falls below the visible scroll position.

Trigger: Transcript is scrollable with user at bottom and an assistant text block streams enough content to extend more than 100px below the viewport without adding another block, staying in the canUpdateLive path.

Impact: Users must repeatedly scroll manually to monitor normal long answers and can remain above the completed answer after streaming ends.

Evidence: src/chat-view.ts render() canUpdateLive branch updates live text via updateLiveMessage() which only changes textContent and returns without checking scroll; isNearBottom()/scrollToBottom() are only used in renderMessages(), whose near-bottom check runs after scrollHeight already grew so it restores stale previousScroll.

Suggested fix:

--- a/src/chat-view.ts
+++ b/src/chat-view.ts
@@
     if (canUpdateLive && live) {
+      const stick = this.isNearBottom();
       this.updateLiveMessage(live);
       this.updateToolNodes(state);
       this.renderQueue(state);
+      if (stick) this.scrollToBottom();
       return;
     }
**[P2] Long streamed answers stop following the transcript bottom** The incremental live-update path grows the live message without preserving bottom-following, so once a single text block streams past the viewport the new output falls below the visible scroll position. **Trigger:** Transcript is scrollable with user at bottom and an assistant text block streams enough content to extend more than 100px below the viewport without adding another block, staying in the canUpdateLive path. **Impact:** Users must repeatedly scroll manually to monitor normal long answers and can remain above the completed answer after streaming ends. **Evidence:** src/chat-view.ts render() canUpdateLive branch updates live text via updateLiveMessage() which only changes textContent and returns without checking scroll; isNearBottom()/scrollToBottom() are only used in renderMessages(), whose near-bottom check runs after scrollHeight already grew so it restores stale previousScroll. Suggested fix: ```diff --- a/src/chat-view.ts +++ b/src/chat-view.ts @@ if (canUpdateLive && live) { + const stick = this.isNearBottom(); this.updateLiveMessage(live); this.updateToolNodes(state); this.renderQueue(state); + if (stick) this.scrollToBottom(); return; } ```
@ -0,0 +221,4 @@
}
const exit = new Promise<void>((resolve) => child.once("exit", () => resolve()));
child.stdin.end();
const terminate = setTimeout(() => child.kill("SIGTERM"), 2_000);
Collaborator

[P2] Windows shim launches can orphan the pi process on stop/restart

When Pi is launched through a .cmd/.bat shim the direct child is cmd.exe and stop() kills only that child, so a pi grandchild that does not exit promptly on stdin EOF can survive with no controlling client.

Trigger: Windows with npm pi.cmd shim via PATH/PATHEXT with stop/restart/new-chat while pi does not exit within the 2s grace after stdin EOF, e.g. during an in-flight run.

Impact: Surviving pi keeps holding the session file with no UI supervision and a subsequent restart reuses the same --session-id, risking interleaved transcript writes and unsupervised vault/tool activity.

Evidence: src/pi-client.ts stop() does child.stdin.end() then child.kill("SIGTERM"/"SIGKILL") against the direct child which is cmd.exe via windowsShellInvocation; src/launcher.ts needsShell() routes .cmd/.bat to this path and src/session.ts restart()/doStop()/doStart() reuse the same saved sessionId for the replacement child.

**[P2] Windows shim launches can orphan the pi process on stop/restart** When Pi is launched through a .cmd/.bat shim the direct child is cmd.exe and stop() kills only that child, so a pi grandchild that does not exit promptly on stdin EOF can survive with no controlling client. **Trigger:** Windows with npm pi.cmd shim via PATH/PATHEXT with stop/restart/new-chat while pi does not exit within the 2s grace after stdin EOF, e.g. during an in-flight run. **Impact:** Surviving pi keeps holding the session file with no UI supervision and a subsequent restart reuses the same --session-id, risking interleaved transcript writes and unsupervised vault/tool activity. **Evidence:** src/pi-client.ts stop() does child.stdin.end() then child.kill("SIGTERM"/"SIGKILL") against the direct child which is cmd.exe via windowsShellInvocation; src/launcher.ts needsShell() routes .cmd/.bat to this path and src/session.ts restart()/doStop()/doStart() reuse the same saved sessionId for the replacement child.
- Keep the transcript pinned to the bottom when a live text block grows
  if the user was already at the bottom.
- Include the active note path in the summarize/related-note suggestions.
- Terminate the cmd.exe tree with taskkill for Windows shim launches so a
  restart cannot leave an orphaned pi child behind.
Code-Reviewer left a comment

Pi code review

0 new actionable findings

No new actionable findings. Previously reported issues, if any, are tracked below.

Earlier findings: 3 rechecked
  • Resolved: Long streamed answers stop following the transcript bottom (src/chat-view.ts:357, first reported in review #234) — src/chat-view.ts render() canUpdateLive branch now captures const stick = this.isNearBottom() before updateLiveMessage()/updateToolNodes() and calls if (stick) this.scrollToBottom(), preserving bottom-follow during streaming growth.
  • Resolved: Active-note suggestions omit the note's identity (src/chat-view.ts:221, first reported in review #234) — src/chat-view.ts buildEmptyState() marks two suggestions needsNote=true, resolves getActiveFile() on click, and appends Active note: ${note.path} to composer text when a note is active.
  • Resolved: Windows shim launches can orphan the pi process on stop/restart (src/pi-client.ts:224, first reported in review #234) — src/pi-client.ts terminate() spawns taskkill /pid <pid> /t /f for launch.shell on win32 with child.kill fallback, and stop()/fail() route through terminate(), killing the cmd shim tree rather than only cmd.exe.

Merged three independent reviews of the initial Pi Chat plugin at head 85f5816; all prior threads verified fixed in current code via static inspection only, with no live Obsidian, build, or test execution.

Change walkthrough
Area Files Changes
Other code (12) src/chat-view.ts, src/chat-state.ts, src/pi-client.ts, src/session.ts (+8 more) Chat view with incremental rendering, scroll-follow fix, and active-note suggestions Event reducer for streaming reconstruction, tool results, and history JSONL RPC client with process lifecycle and Windows shim tree termination Session startup, hydration, prompting, and serialized lifecycle
Tests (3) tests/chat-state.test.ts, tests/launcher.test.ts, tests/pi-client.test.ts Reducer tests for streaming, tools, history, and filtering Launcher discovery and environment tests Windows shell quoting tests
Documentation (1) README.md Full plugin documentation replacing template
Deployment & tooling (3) package.json, esbuild.config.mjs, tsconfig.json Build, typecheck, and test scripts Bundling config for dev and production Strict TypeScript configuration

Review effort: 3/5.

Static observations (not validation results)
Observation Detail
⚠️ Diff size 22 files, +4255/-15. Large diff; review coverage may be incomplete.
Binary changes No binary changes reported by this diff.
Credential patterns No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit.

Reviewed 85f5816a9d2be7f682aa38054c3686c6228823b7 with proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3. Automated advisory review; no project commands or tests were executed.

<!-- forgejo-pi-review:9d54cea24e254997bef1f79a62416db8b5c44769ac024da82f99fd6662ea7089 --> ## Pi code review **0 new actionable findings** No new actionable findings. Previously reported issues, if any, are tracked below. <details> <summary>Earlier findings: 3 rechecked</summary> - **Resolved:** Long streamed answers stop following the transcript bottom (`src/chat-view.ts:357`, first reported in review #234) — src/chat-view.ts render() canUpdateLive branch now captures const stick = this.isNearBottom() before updateLiveMessage()/updateToolNodes() and calls if (stick) this.scrollToBottom(), preserving bottom-follow during streaming growth. - **Resolved:** Active-note suggestions omit the note's identity (`src/chat-view.ts:221`, first reported in review #234) — src/chat-view.ts buildEmptyState() marks two suggestions needsNote=true, resolves getActiveFile() on click, and appends Active note: ${note.path} to composer text when a note is active. - **Resolved:** Windows shim launches can orphan the pi process on stop/restart (`src/pi-client.ts:224`, first reported in review #234) — src/pi-client.ts terminate() spawns taskkill /pid &lt;pid&gt; /t /f for launch.shell on win32 with child.kill fallback, and stop()/fail() route through terminate(), killing the cmd shim tree rather than only cmd.exe. </details> Merged three independent reviews of the initial Pi Chat plugin at head 85f5816; all prior threads verified fixed in current code via static inspection only, with no live Obsidian, build, or test execution. <details> <summary>Change walkthrough</summary> | Area | Files | Changes | | --- | --- | --- | | Other code (12) | `src/chat-view.ts`, `src/chat-state.ts`, `src/pi-client.ts`, `src/session.ts` (+8 more) | Chat view with incremental rendering, scroll-follow fix, and active-note suggestions Event reducer for streaming reconstruction, tool results, and history JSONL RPC client with process lifecycle and Windows shim tree termination Session startup, hydration, prompting, and serialized lifecycle | | Tests (3) | `tests/chat-state.test.ts`, `tests/launcher.test.ts`, `tests/pi-client.test.ts` | Reducer tests for streaming, tools, history, and filtering Launcher discovery and environment tests Windows shell quoting tests | | Documentation (1) | `README.md` | Full plugin documentation replacing template | | Deployment & tooling (3) | `package.json`, `esbuild.config.mjs`, `tsconfig.json` | Build, typecheck, and test scripts Bundling config for dev and production Strict TypeScript configuration | Review effort: **3/5**. </details> <details> <summary>Static observations (not validation results)</summary> | Observation | Detail | | --- | --- | | ⚠️ Diff size | 22 files, +4255/-15. Large diff; review coverage may be incomplete. | | Binary changes | No binary changes reported by this diff. | | Credential patterns | No matches after excluding known examples/placeholders. Added-line heuristics only; not a security audit. | </details> --- Reviewed `85f5816a9d2be7f682aa38054c3686c6228823b7` with `proxy/glm-5.3-flash + proxy/gpt-6.1-sol + proxy/muse-spark-1.3 → proxy/muse-spark-1.3`. Automated advisory review; no project commands or tests were executed.
BlackHatMagic deleted branch feat/chat-panel 2026-10-23 08:59:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
BlackHatMagic/Pi-Obsidian!1
No description provided.