This repository was archived by the owner on Aug 17, 2026. It is now read-only.
fix: PromptBus wrapper-recapture crash + TUI auto-cancel (#136) - #145
Merged
Conversation
joeshull
enabled auto-merge (squash)
August 14, 2026 19:03
…e wrapper as original (#136) - Added unwrapPristine() to ctx-ui-originals: walks wrapper chain through __pristineOriginal stash (carried on the wrapper itself), never stores a PromptBus wrapper as an original. Back-fills stash on recovery so future captures in fresh vm contexts unwrap directly. - Added __pristineOriginal stashes on all bridge.ts wrappers (select, input, confirm, editor, notify) so the true native is reachable even when the process-parked WeakMap misses (isolated extension vm contexts). - Added hasComponentClaim() to PromptBus so the TUI adapter can detect when the dashboard is rendering the prompt and suppress an auto-cancel from a no-op native method (RPC-mode stub that returns undefined immediately). - TUI adapter present(): when the native ui method returns undefined AND the bus has a dashboard component claim, let the dashboard handle the prompt instead of winning the race with a spurious cancellation. - Updated regression tests; added explicit coverage for unwrap recovery and never-store-wrapper semantics.
joeshull
force-pushed
the
fix/136-pristine-originals
branch
from
August 14, 2026 19:24
fd1d3cd to
f61948a
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Fixes two ask-tool bugs in the extension bridge.
Bug 1: RangeError crash (#136)
WeakMap miss in isolated vm context captures wrapper as "original" — infinite recursion.
Fix:
getOrCreatePristineOriginalsunwraps via__pristineOriginalstash (carried on each wrapper by bridge.ts). Never stores a wrapper as originals. Cycle-guarded.Bug 2: Fresh-session ask immediately cancelled
TUI adapter's native
ctx.ui.selectis an RPC no-op returning undefined instantly — races dashboard with spuriouscancelled: true.Fix: TUI adapter checks
bus.hasComponentClaim(id). When dashboard holds a component claim, it suppresses the auto-cancel and lets the dashboard handle the prompt.Changes
ctx-ui-originals.tsunwrapPristine()with__pristineOriginalstash recoverybridge.ts__pristineOriginalon wrappers; TUI adapterhasComponentClaimgateprompt-bus.tshasComponentClaim(id)methodVerification