Repository navigation
Auto-reload after an update: Pi reloads itself when idle; OpenCode 2 installer updates the running plugin - #2356
Draft
backnotprop wants to merge 2 commits into
Draft
backnotprop wants to merge 2 commits into
backnotprop wants to merge 2 commits into
Conversation
…installer updates the running plugin Pi (0.84.2+): when the Plannotator extension on disk is newer than the one loaded, Pi reloads itself through the extension's own /plannotator-reload command once nothing can be lost (stable version 10 s, no run, queued message, compaction, pending prompt, extension dialog, open review / plan review / Ask, nothing typed 15 s, empty editor; re-checked in the command; one try per version). Off, older Pi and Oh My Pi: the /reload (/restart) note once per version. autoReload / PLANNOTATOR_AUTO_RELOAD, default on. install.sh: when the OpenCode 2 service is running with an unpinned @plannotator/opencode spec, run opencode2 plugin update <spec> (bounded, stdin /dev/null, exit code checked, version read back), keep the OC2 cache while the service has the plugin; any failure prints the command and changes nothing else. Ported from the auto-reload spike (spike/auto-reload, never pushed).
…ry per version per process Pi writes its own "Reloaded …" status after the extensions' session_start, and a status line written right after another one replaces it, so the line sent from session_start was gone a moment later (real host, Pi 0.84.4). The new instance now shows it at its first poll. The tried versions live in globalThis, so a reload that loads the old version again cannot loop, and that case gets the /reload note from the new instance (the old context is stale after the reload).
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
After a Plannotator update, the running agent loads the new version by itself where that is safe. The design comes from the auto-reload spike; this PR ports it by hand onto current main.
What users see
Pi (0.84.2 or newer): after
pi update --extensionsor the install script, each open Pi session reloads itself once nothing can be lost. Pi shows its own "Reloading…" box for a moment, then one line in place of its "Reloaded …" status:Plannotator updated to 0.29.1. Pi reloaded while idle.The old "Plannotator was updated … Type /reload" note is not shown while Pi will reload by itself.
OpenCode 2: when its service is running with
@plannotator/opencodeor@plannotator/opencode@latest, the install script runsopencode2 plugin update <that spec>. The service loads the new plugin without stopping anything. The script prints one of:OpenCode 2: the running service now uses Plannotator X. Nothing was restarted.OpenCode 2: the running service already uses Plannotator X.OpenCode 2: the Plannotator plugin is pinned to X; left as it is.OpenCode 2: the running service still uses Plannotator Y (<reason>). To load X, run: opencode2 models && opencode2 plugin update <spec>When the service is not running, the script does what it did before, and the next start loads the newest plugin.
Oh My Pi: only the note, once per version (
… Type /restart …). Oh My Pi never restarts by itself.Guards
Pi. A reload happens only when all of these hold. The extension checks them every 2 s, and checks them again inside the command just before it reloads:
Other rules:
/reloadnote, and Pi does not try again.sendUserMessagewould send the command text to the model.Installer. The update step never fails the install. It only asks the service and writes nothing itself:
opencode2call has a time limit (90 s for the update, 15 s for the others) and stdin from/dev/null, and its exit code is checked;opencode2 plugin list, because a broken package or a registry that is down also exits 0;--version, with the same rule as the Claude Code plugin step) and for--skip-opencode;How to turn it off
PLANNOTATOR_AUTO_RELOAD=0, or add{ "autoReload": false }to~/.plannotator/config.json. The env var wins. When it is off, the session shows the/reloadnote once per version. It is on by default (owner's call); the default is one constant,AUTO_RELOAD_DEFAULT.--skip-opencode, or pin the plugin inopencode.json.Dropped, and why
opencode2 reloadcancels pending permissions and question forms. The idle check also races the reload.plugin updatedoes the same job without cancelling anything, so it needs no idle gate. This action was never built, so nothing is removed./restartin Oh My Pi. Extensions cannot call it, and it kills a running turn./reloador/restartin the editor. Pi does not need it. In Oh My Pi, what the person types next would be appended to it.Tests
apps/pi-extension/auto-reload.test.ts: every guard, the command's re-check, one try per version, the version gate, the notes and the setting, all against a fake Pi.scripts/install.test.ts, "install.sh updates a running OpenCode 2 service's plugin": a fakeopencode2in a sandbox HOME. It covers success, a late load, a first "No plugins found", current, pinned, other specs, stopped, no row, registry down, a broken package, a non-zero exit, hangs, a pinned versus an auto-update run, the opt-out, noopencode2and nomktemp.npm packof this branch. Results:/reloadnote was shown once and nothing reloaded./restartnote was shown once, 9–11 s after the update, and Oh My Pi never restarted.install.shexited 0 every time.session_start, and that status replaced our line a moment later. The new instance now shows the line at its first poll, about 2 s after the reload. Rerun twice for idle and an open review: the line was still on the last screen 6 s later.