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

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

Description

@joeshull

Summary

Follow-up to #115 / #116. After the WeakMap originals cache, ask still self-cancels in ~30ms on a TUI session with no user dismiss. #116 stores pristineUiMap as a module WeakMap. Jiti module-cache invalidation (already called out for BRIDGE_KEY on process in bridge.ts) creates a new empty map, then getOrCreatePristineOriginals recaptures PromptBus wrappers as "natives".

The TUI adapter re-enters the bus. selectWrapper maps { cancelled: false, error } / missing answer to undefined. Dashboard ask-tool.ts treats any undefined as a user cancel (User cancelled ask.).

Observed 2026-08-13 on live ~/.omp-dashboard 0.5.4 with #116 already present, OMP 17.3.0, session source: tui.

Evidence (this session)

ask start → end
1 21:52:25.605 → .638 (33ms)
2 22:10:06.998 → .027 (29ms)

Session: ~/.omp/agent/sessions/-code-zge-workspace/2026-08-13T21-52-14-327Z_019ffd1c-8bf7-7000-9129-177229e74139.jsonl

Tool result text is unique to packages/extension/src/ask-tool.ts (User cancelled ask.\nsample: []). Core OMP AskTool says User cancelled the selection.

Not the 300s PromptBus timeout. User did not dismiss.

Mechanism

  1. ctx-ui-originals.ts const pristineUiMap = new WeakMap(...) dies on jiti reload.
  2. Next session_start cache-misses and binds current ctx.ui.select (already __isPromptBusWrapper).
  3. TUI adapter originals.select → wrapper → bus.request → TUI adapter → recurse.
  4. Adapter error path from fix: stop ctx.ui re-patch nesting on session_start #116 (cancelled: false, error: ...) is still rendered as user cancel:
    • selectWrapper: r.cancelled ? undefined : r.answer
    • selectedFromAnswer(undefined)cancelled: true

Repro (unit)

vi.resetModules() then re-import getOrCreatePristineOriginals and recapture the same ctx.ui after patching. Current main recaptures the wrapper (native select call count 0).

Suggested fix

Store the WeakMap on process (same pattern as BRIDGE_KEY / __pi_dashboard_bridge__), e.g. __pi_dashboard_pristine_ui__.

Also stop mapping adapter error / missing answer to user cancel in selectWrapper / ask-tool.ts.

Worktree with the process-map + failing-then-passing jiti test:
~/code/zge-workspace/worktrees/omp-dashboard/ask-prompt-jiti-originals (fix/ask-prompt-jiti-originals). Not shipped to ~/.omp-dashboard yet.

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions