Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

fix: keep ctx.ui originals across jiti reloads - #142

Merged
joeshull merged 1 commit into
mainfrom
fix/ask-prompt-jiti-originals
Aug 14, 2026
Merged

fix: keep ctx.ui originals across jiti reloads#142
joeshull merged 1 commit into
mainfrom
fix/ask-prompt-jiti-originals

Conversation

@joeshull

@joeshull joeshull commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Closes #141
Related: #136

Test plan

  • vitest run packages/extension/src/__tests__/ctx-ui-session-start-repatch-regression.test.ts
  • Reload ~/.omp-dashboard from this branch and confirm ask stays open until answered
  • After reload, interactive select/input/batch must not RangeError

#116 stored the pristine-originals WeakMap in module scope. Jiti cache
invalidation created a new empty map, so the next session_start recaptured
PromptBus wrappers as natives and ask self-cancelled in ~30ms.

Store the map on process, matching BRIDGE_KEY.
@joeshull

Copy link
Copy Markdown
Author

Call

#141 and #136 are the same recapture hole. This PR is the keeper.

Does not fold into in-flight P0–P2 PRs (#137/#138/#139/#140/#143/#121). Those do not touch ctx-ui-originals.ts.

After merge, leftover on #136:

  • still caches a __isPromptBusWrapper after the warn
  • selectWrapper maps adapter error / missing answer → undefined → ask-tool user-cancel

@joeshull

Copy link
Copy Markdown
Author

Review

Strengths

  • Process-scoped WeakMap matches BRIDGE_KEY survival. The actual jiti hole.
  • vi.resetModules() + recapture test is real: native still called, wrapper not.
  • Required CI green (zge-gates, zge-typecheck, zge-upstream-sync).

Issues

Important (do not block #141)

  1. Still caches a wrapper after the warnctx-ui-originals.ts:36-52
    Detects __isPromptBusWrapper, logs, then bind+map.set anyway. bind() also drops the tag. First capture after a cold process (no prior native in the process map) still stores the cycle. PromptBus TUI originals recaptured as wrappers after jiti reload → infinite onRequest cycle #136 residual.
    Fix: refuse to store; return {} or walk off the wrapper. Never cache a tagged method.

  2. selectWrapper error → user cancelbridge.ts r.cancelled ? undefined : r.answer + ask-tool.ts selectedFromAnswer(undefined)
    Adapter {cancelled:false, error} still becomes User cancelled ask. Leave on PromptBus TUI originals recaptured as wrappers after jiti reload → infinite onRequest cycle #136.

Minor

  • Extra blank line in the new test (ctx-ui-session-start-repatch-regression.test.ts:73-75).

Assessment

Ready to merge for #141. Process map + reload test close the reported 30ms self-cancel after a prior good capture in the same process.

Do not close #136 until (1) is fixed.

@joeshull
joeshull merged commit ac37c7b into main Aug 14, 2026
4 checks passed
@joeshull
joeshull deleted the fix/ask-prompt-jiti-originals branch August 14, 2026 00:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ask self-cancels in ~30ms: jiti reload recaptures PromptBus wrappers as ctx.ui originals

1 participant