fix: phantom input bug on wsl#200
Merged
adamdotdevin merged 1 commit intoanomalyco:devfrom Jun 20, 2025
Merged
Conversation
Contributor
Author
achembarpu
pushed a commit
to achembarpu/opencode
that referenced
this pull request
Aug 4, 2025
m-pa
pushed a commit
to m-pa/opencode
that referenced
this pull request
Dec 4, 2025
…st” error (anomalyco#200) Resolves anomalyco/opentui#199 ## The Bug When inserting a React element in the middle of a list inside a `<scrollbox>`, the application crashes with: ``` Error: Anchor does not exist at insertBefore (packages/core/src/Renderable.ts:1118:17) at insertBefore (packages/react/src/reconciler/host-config.ts:65:12) ``` ## Root Cause ScrollBox has an internal wrapper structure where user content is added to a nested child (`this.content`), not directly to the ScrollBox instance. The component hierarchy looks like: ``` ScrollBox ├── wrapper (scroll-box-wrapper) │ └── viewport │ └── content ← User children go here └── scrollbar (scroll-box-vertical-scrollbar) ``` ScrollBox correctly overrides `add()` and `remove()` to delegate to `this.content`: - `add(obj, index)` → `this.content.add(obj, index)` ✓ - `remove(id)` → `this.content.remove(id)` ✓ **However, ScrollBox was missing an override for `insertBefore()`.** When React inserts an element in the middle of a list (e.g., when a conditional element appears after initial render), it calls: ```typescript parent.insertBefore(newChild, anchorChild) ``` Without the override, this uses the base `Renderable.insertBefore()` which: 1. Looks for `anchorChild` in the parent's direct children via `renderableMapById` 2. Fails because `anchorChild` is actually in `this.content` (the wrapper), not in ScrollBox's direct children ## The Fix Added `insertBefore()` override in ScrollBox to delegate to `this.content`, matching the pattern used for `add()` and `remove()`: ## Impact Analysis ### Affected Components - ✅ **ScrollBox** - Fixed by adding `insertBefore()` override - ✅ **TextRenderable** - Already had proper `insertBefore()` delegation ### Affected Renderers - ❌ **React** - Was affected (uses `insertBefore()` directly) - ✅ **Solid** - Not affected (uses `add(node, anchorIndex)` pattern) - ✅ **Vue** - Not affected (uses `add(node, anchorIndex)` pattern)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

this is basically just working around the issue. wsl users will be defaulted to dark mode no matter what settings are.
will test this on my work laptop tomorrow. related: #127