Skip to content

fix(v0.2.2): use real Theme instance for cursor colors, not EditorTheme#3

Merged
rz1989s merged 1 commit into
mainfrom
fix/editor-theme-instance
Jul 20, 2026
Merged

fix(v0.2.2): use real Theme instance for cursor colors, not EditorTheme#3
rz1989s merged 1 commit into
mainfrom
fix/editor-theme-instance

Conversation

@rz1989s

@rz1989s rz1989s commented Jul 20, 2026

Copy link
Copy Markdown
Member

Root cause

Pi crashed on startup with theme.getFgAnsi is not a function on the first render tick.

The editor factory registered via ctx.ui.setEditorComponent receives an EditorTheme ({ borderColor, selectList }) — not the full Theme instance. v0.2.0 assumed that param exposed getFgAnsi/getColorMode and invoked theme.getFgAnsi("accent") in resolveFocusedColortransformFocusedcomposeRenderCursorEditor.renderTUI.doRender timer. Boom.

Fix

Resolve the live Theme from ctx.ui.theme (the readonly theme getter on ExtensionUIContext that always returns the current theme, so theme switches are reflected) and pass it into CursorEditor via a new deps.getTheme accessor. The EditorTheme factory arg is still forwarded to super() for border/autocomplete styling.

  • lib/editor.ts: drop the bogus cursorTheme = theme as Theme; read this.deps.getTheme() in applyCursorMode and render.
  • extensions/cursor.ts: pass getTheme: () => ctx.ui.theme.
  • tests/editor.test.ts: supply getTheme in all harnesses.

Verification

  • pnpm typecheck
  • pnpm test:run ✅ 122 pass, 0 fail
  • Installed copy at ~/.pi/agent/npm/node_modules/@getpipher/cursor patched locally so pi starts now (before this releases).

Release

Bumps to 0.2.2. Merge → tag v0.2.2 → CI publishes to npm under the getpipher NPM_TOKEN.

The editor factory registered via ctx.ui.setEditorComponent receives an
EditorTheme ({ borderColor, selectList }) — NOT the full Theme instance.
v0.2.0 assumed that param had getFgAnsi/getColorMode and called
theme.getFgAnsi("accent") at render time, crashing pi on startup with
"theme.getFgAnsi is not a function" on the first render tick.

Resolve the live Theme from ctx.ui.theme (readonly getter on
ExtensionUIContext that always returns the current theme, so theme
switches are reflected) and pass it into CursorEditor via a new
deps.getTheme accessor. The EditorTheme factory arg is still forwarded
to super() for border/autocomplete styling.

Tests updated to supply getTheme; 122 pass, typecheck clean.
@rz1989s
rz1989s merged commit 58e4d06 into main Jul 20, 2026
1 check passed
@rz1989s
rz1989s deleted the fix/editor-theme-instance branch July 20, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant