Skip to content

fix: OpenCode v1.14–v1.16 compatibility — api.keybind + Uint16Array buffer - #8

Open
yingmanwumen wants to merge 2 commits into
anomalyco:mainfrom
yingmanwumen:main
Open

fix: OpenCode v1.14–v1.16 compatibility — api.keybind + Uint16Array buffer#8
yingmanwumen wants to merge 2 commits into
anomalyco:mainfrom
yingmanwumen:main

Conversation

@yingmanwumen

Copy link
Copy Markdown

Closes #7
Closes #5 (Uint16Array fix is a more complete version of the approach in #6)

Two separate commits addressing two independent bugs:

Commit 1: fix: replace deprecated api.keybind with direct keybind string

api.keybind.create() was removed in @opencode-ai/plugin v1.16.0 (@opentui/core >= 0.3.x). The plugin was throwing TypeError on initialization, causing "Failed to update oc-plugin-rainbow".

  • Removed the api.keybind.create() call (tui.tsx:139)
  • Pass splashKeybind string directly to api.command.register() which natively accepts keybind?: string
  • Removed orphaned obj() helper

Commit 2: fix: support Uint16Array buffer format in OpenCode >= v1.14

@opentui/core >= 0.2.2 changed OptimizedBuffer.buffers.fg/bg from Float32Array (0.0–1.0) to Uint16Array (0–255). Float writes were truncated to 0, making the rainbow effect invisible.

  • Added isUint16() / readColor() / writeColor() helpers with runtime buffer-type detection
  • Scale: read = value / 255, write = Math.round(value * 255)
  • Fully backward compatible with old Float32Array buffers
  • Updated all function signatures and pixel operations in rainbow-post-process.ts

Testing

Verified working on OpenCode v1.16.0, Linux (Kitty). Foreground rainbow and logo splash both functional.

api.keybind.create() was removed in @opencode-ai/plugin v1.16.0
(@opentui/core >= 0.3.x). The plugin now passes the keybind
string directly to api.command.register() entries, matching the
current TuiCommand.keybind?: string API.

Also removes the unused obj() helper function.
@opentui/core >= 0.2.2 changed OptimizedBuffer.buffers.fg/bg from
Float32Array (0.0-1.0) to Uint16Array (0-255). The old code wrote
float values directly, which were truncated to 0, making the rainbow
effect invisible.

Adds isUint16()/readColor()/writeColor() helpers that detect the
buffer type at runtime and scale between float (0-1) and integer
(0-255) as needed. Backward compatible with Float32Array buffers.

Closes anomalyco#5
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.

Plugin fails to initialize on OpenCode v1.16.0: api.keybind undefined + Uint16Array buffer invisible does not work in version 1.14.40

1 participant