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
Zi keeps runtime ownership records (functions, widgets, key bindings) per plugin ID and restores each plugin from its own snapshot on unload. #582 (squash 8bbd62c on next) fixed the same-plugin part of #113: a repeated load of one plugin keeps its records when no other plugin took a recorded widget or binding over in between. Three cases remain, all recorded on #113:
Interleaved takeover: another plugin takes the widget or binding over between two loads of the same plugin (zi load p; zi load q; zi load p). Zi then falls back to resetting the records, as next did before fix(unload): keep ownership across repeated loads of one plugin #582, so unloading in either order can restore the wrong prior owner or leave a widget pointing at a deleted function. Measured during fix(unload): keep ownership across repeated loads of one plugin #582: unloading q then p removed p's live widget and binding when records were relinked, and without relinking the order p then q left a widget bound to a deleted function.
The root cause is that unload restores from per-plugin snapshots, not from an ownership chain, so it cannot tell who held a widget or binding immediately before the instance being removed.
Proposed improvement
Design, before any code, a chain-aware restore:
A minimal per-load identity (for example a load counter stored with each record) for function, widget and bindkey records.
An ownership chain per widget and per (keymap, key) binding: an ordered list of (load instance, previous value) entries, so unloading any instance in any order restores the immediately preceding live owner and relinks the next one.
Detection of changes made without records: compare the recorded previous value with the live value at load and unload, and decide whether the chain treats such a change as a new owner or stops restoring.
Deliverable of this issue: a written decision (comment or ADR draft) with the data model, the unload algorithm, the test matrix (two-plugin widget and bindkey chains, interleaved same-plugin loads, out-of-order unload, linked main keymaps from #583, user change between loads) and an effort estimate, for the maintainer to approve before implementation. #113's remaining acceptance criteria move here; #113 can close once this design is delivered and implemented, or once the maintainer descopes it.
Current limitation
Zi keeps runtime ownership records (functions, widgets, key bindings) per plugin ID and restores each plugin from its own snapshot on unload. #582 (squash
8bbd62connext) fixed the same-plugin part of #113: a repeated load of one plugin keeps its records when no other plugin took a recorded widget or binding over in between. Three cases remain, all recorded on #113:zi load p; zi load q; zi load p). Zi then falls back to resetting the records, asnextdid before fix(unload): keep ownership across repeated loads of one plugin #582, so unloading in either order can restore the wrong prior owner or leave a widget pointing at a deleted function. Measured during fix(unload): keep ownership across repeated loads of one plugin #582: unloadingqthenpremovedp's live widget and binding when records were relinked, and without relinking the orderpthenqleft a widget bound to a deleted function.The root cause is that unload restores from per-plugin snapshots, not from an ownership chain, so it cannot tell who held a widget or binding immediately before the instance being removed.
Proposed improvement
Design, before any code, a chain-aware restore:
tests/repeated-load-ownership.zshfrom fix(unload): keep ownership across repeated loads of one plugin #582 stay unchanged; the public-contract manifest is checked for output or ordering changes.Deliverable of this issue: a written decision (comment or ADR draft) with the data model, the unload algorithm, the test matrix (two-plugin widget and bindkey chains, interleaved same-plugin loads, out-of-order unload, linked
mainkeymaps from #583, user change between loads) and an effort estimate, for the maintainer to approve before implementation. #113's remaining acceptance criteria move here; #113 can close once this design is delivered and implemented, or once the maintainer descopes it.Self-service
Project policies