pi-mono/packages/coding-agent/src/modes
Petr Houška 80d4d3c869
fix(coding-agent): remove all extension overlays on /reload and session switch (#11853)
## Problem

`InteractiveMode.resetExtensionUI()` runs on `/reload` and before a
session is invalidated (session switch, new session, fork). For overlays
it called `this.ui.hideOverlay()` once, which pops only the topmost
entry of the TUI overlay stack.

Trace: an extension opens two overlays with `ctx.ui.custom({ overlay:
true })`, then the user runs `/reload`. Reset removes the upper overlay;
the lower one stays on screen, gets focus back and keeps receiving
input, although the extension instance that created it is gone. A hidden
overlay (`handle.setHidden(true)`) also stays in the stack and can be
shown again by stale code.

Blindly clearing the whole stack is not correct either: pi opens its own
overlays (the header logo easter egg in `components/easter-egg-3d.ts`).
With the old code, a reset while the easter egg was topmost removed the
easter egg and left the extension overlay.

## Fix

`showExtensionCustom` records each overlay it opens in
`extensionOverlays` (handle -> removal function). The same function
serves `done()` and `resetExtensionUI()`: it hides the overlay, clears
its blocked program status (#11851) and disposes its component. Deleting
the map entry first makes a second call a no-op, so a late `done()`
after reset does not dispose twice. Reset calls it for every recorded
overlay, newest first, including hidden ones. Overlays not opened by
extensions are left alone. This replaces the separate
`blockingOverlaySources` set and reset loop added in #11851.

Pending `ctx.ui.custom()` promises of removed overlays stay unsettled,
matching how reset already treats inline dialogs.

## Testing

- New regression test in `test/interactive-mode-status.test.ts`: a
pi-internal overlay plus three extension overlays (one hidden), then
reset. Checks that the extension overlays are gone and disposed, the
internal overlay remains and receives input. Fails without the fix.
- `test/interactive-mode-status.test.ts`,
`test/interactive-mode-extension-dialogs.test.ts`,
`test/interactive-mode-paste.test.ts`,
`test/suite/regressions/5943-session-start-notify.test.ts` pass.
- `npm run check` clean.
2026-11-05 23:30:54 +01:00
..
interactive fix(coding-agent): remove all extension overlays on /reload and session switch (#11853) 2026-11-05 23:30:54 +01:00
rpc fix(coding-agent): let a started RPC or print shutdown finish; only a repeated signal forces exit (#11752) 2026-11-03 22:21:44 +01:00
index.ts fix(coding-agent): make JSON streaming output linear (#7394) 2026-08-03 18:33:22 +02:00
json-event.ts fix(coding-agent): expose tool metadata at stream start (#7953) 2026-08-19 12:24:30 +02:00
print-mode.ts fix(coding-agent): let a started RPC or print shutdown finish; only a repeated signal forces exit (#11752) 2026-11-03 22:21:44 +01:00