Skip to content

Ctrl+O (expand tools) crashes: "Theme not initialized" with pi-web-providers extension #4333

@beyondhumanwork

Description

@beyondhumanwork

Description

Pressing Ctrl+O (app.tools.expand) crashes with:

Error: Theme not initialized. Call initTheme() first.
    at Object.get (theme.js:536)
    at Object.bold (theme.js:920)
    at headingStyleFn (markdown.js:209)
    at Markdown.renderToken (markdown.js:213)

Root Cause

pi v0.74.0 moved from @mariozechner/pi-coding-agent to @earendil-works/pi-coding-agent. The theme is stored on a Symbol.for key:

Package Symbol key
@earendil-works/pi-coding-agent (v0.74.0) Symbol.for("@earendil-works/pi-coding-agent:theme")
@mariozechner/pi-coding-agent (v0.72.1, bundled by pi-web-providers) Symbol.for("@mariozechner/pi-coding-agent:theme")

When pi starts, initTheme() sets the @earendil-works slot. But pi-web-providers (v3.0.0) still bundles the old @mariozechner/pi-* packages (v0.72.1). Their markdown/TUI components read from the @mariozechner slot, which was never initialized → crash.

Steps to Reproduce

  1. Install pi-web-providers v3.0.0 as an extension alongside @earendil-works/pi-coding-agent v0.74.0
  2. Run any tool (e.g., ls)
  3. Press Ctrl+O to expand tool output
  4. Crash

Workaround

Patch pi-web-providers/node_modules/@mariozechner/pi-coding-agent/dist/modes/interactive/theme/theme.js to use the same Symbol key:

-const THEME_KEY = Symbol.for("@mariozechner/pi-coding-agent:theme");
+const THEME_KEY = Symbol.for("@earendil-works/pi-coding-agent:theme");

Suggested Fix

Option A (pi side): During initTheme(), set both Symbol keys so extensions using the old namespace continue to work:

function setGlobalTheme(t) {
    globalThis[Symbol.for("@earendil-works/pi-coding-agent:theme")] = t;
    globalThis[Symbol.for("@mariozechner/pi-coding-agent:theme")] = t; // backward compat
}

Option B (pi-web-providers side): Update dependencies from @mariozechner/pi-* to @earendil-works/pi-* and release a new version.

Option A is a one-line fix that prevents all existing extensions from breaking during the namespace migration.

Environment

  • pi: @earendil-works/pi-coding-agent v0.74.0
  • pi-web-providers: v3.0.0 (bundles @mariozechner/pi-coding-agent v0.72.1)
  • Node.js: v24.12.0
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions