From ff220fa41d925cfa629f99d5d3c08595bf482f8e Mon Sep 17 00:00:00 2001 From: Vegard Stikbakke Date: Thu, 23 Apr 2026 21:02:15 +0200 Subject: [PATCH] fix(coding-agent): tear down extension UI before runner invalidation on shutdown (#3597) Custom footers registered via ctx.ui.setFooter(...) whose render() closure touched ctx would crash pi on /quit: runtimeHost.dispose() invalidates the extension runner before the TUI stops rendering, so any still-attached footer render tick hit assertActive() and threw. Call resetExtensionUI() before runtimeHost.dispose() in the interactive shutdown path, matching the rebindCurrentSession() pattern. This disposes the custom footer (clearing its interval) and detaches it from the TUI tree before the runner goes stale. closes #3595 Co-authored-by: Mario Zechner --- packages/coding-agent/CHANGELOG.md | 1 + packages/coding-agent/src/modes/interactive/interactive-mode.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 43714316..287b835c 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- Fixed crash on `/quit` when an extension registers a custom footer whose `render()` accesses `ctx`, by tearing down extension-provided UI before invalidating the extension runner during shutdown ([#3595](https://github.com/badlogic/pi-mono/issues/3595)) - Fixed `pi-coding-agent` shipping `uuid@11`, which triggered `npm audit` moderate vulnerability reports for downstream installs; the package now depends on `uuid@14` ([#3577](https://github.com/badlogic/pi-mono/issues/3577)) - Fixed `ctx.ui.setWorkingMessage()` to persist across loader recreation, matching the behavior of `ctx.ui.setWorkingIndicator()` ([#3566](https://github.com/badlogic/pi-mono/issues/3566)) - Fixed coding-agent `fs.watch` error handling for theme and git-footer watchers to retry after transient watcher failures such as `EMFILE`, avoiding startup crashes in large repos ([#3564](https://github.com/badlogic/pi-mono/issues/3564)) diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts index 125eae96..cc015ad5 100644 --- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts +++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts @@ -3182,6 +3182,7 @@ export class InteractiveMode { if (this.isShuttingDown) return; this.isShuttingDown = true; this.unregisterSignalHandlers(); + this.resetExtensionUI(); await this.runtimeHost.dispose(); // Wait for any pending renders to complete