You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8408b96
Browse filesBrowse the repository at this point in the historyBrowse files
Persist volatile runtime state across v2 reloads and restarts
v2 hosts the plugin per location and rebuilds that graph on plugin file
change, so in-memory state died with every reload. The runtime now
journals it to a runtime_state SQLite table (extraction buffer and
accepted entries, child bookkeeping with buffer snapshots and metrics,
wrap-up arms, watcher definitions), written through at the mutation
points. On setup, rows written by the current process (a reload) are
rehydrated and re-armed; rows from a dead process are pruned unless the
session is the -c/-s startup resume, which inherits state (crash
recovery - new on v1 too). dispose() deliberately leaves the journal
intact; the setup-time partition owns pruning.
The embedding model is pooled per db path with a refcount, so the
location instances of one v2 serve share a single resident model; it is
disposed when the last holder releases (the ONNX sessions must still be
closed explicitly before process exit).
resumedSession becomes a Set - one instance can serve several resumed
sessions (shared-server tabs in one directory).
Plan: docs/plans/plugin-state-persistence.md.
Copy file name to clipboardExpand all lines: docs/dev/features/opencode-plugin.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,7 @@ the shared runtime needs. It is the lifecycle-level sibling of `CoreContext`
73
73
| compaction trigger |`client.tui.executeCommand("session_compact")`| none | degrade (no `session.compact` on the promise domain's Pick, and the built-in `/compact` is a TUI palette action calling the server endpoint directly - the server command registry only knows config/plugin-registered names; the wrap-up checklist and flush still run, the automatic compaction is skipped) |
74
74
| toasts |`client.tui.showToast`| none reachable | degrade (the `tui.toast.show` event has no producer surface from the promise context) |
75
75
| TUI app exit |`client.tui.publish`| none | degrade (the wrap-up exit's checklist and flush run; the process exit does not - upstream [anomalyco/opencode#50984](https://github.com/anomalyco/opencode/issues/50984)) |
76
-
| dispose |`dispose` hook | cleanup returned from `setup`| must be idempotent: v2 auto-reloads plugins on file change, and a non-idempotent cleanup doubles pollers/pumps/nudges. A reload also re-runs `setup()` from scratch and discards the in-memory state: the watcher registry, extraction buffer, pending wrap-up arms, `pendingInjections`, and `sessionDirs`. Dev-shim users hit this on every plugin file save; npm users on `opencode plugin update`. Persistence of that state is a planned fix (see scratch/main-repo-bugs.md)|
76
+
| dispose |`dispose` hook | cleanup returned from `setup`| must be idempotent: v2 auto-reloads plugins on file change, and a non-idempotent cleanup doubles pollers/pumps/nudges. Volatile runtime state (extraction buffer + accepted entries, child bookkeeping, wrap-up arms, watcher definitions) is journaled to the `runtime_state` table and rehydrated on the next `setup()`: rows written by the same process (a reload) all restore; rows from a dead process are pruned unless the session is the `-c`/`-s` startup resume (crash recovery). The embedding model is refcounted per db path, so N location instances share one resident model|
0 commit comments