Background
Currently, nansen.App holds a MetaTable instance and plugin (session task) methods are invoked without a direct reference to it. To allow plugins to modify the table that is loaded in the App and trigger a UI update, a per-filepath instance cache was introduced in MetaTable.open() (a global in disguise).
Problem
The cache is semantically a global variable. While the coupling is intentional (plugins and App must share the same instance), globals are still a pragmatic compromise rather than a clean design. They hide dependencies, complicate testing, and make lifetime management implicit.
Proposed improvement
Since App is the one invoking plugin methods (via SessionTaskMenu), it could pass app.MetaTable explicitly as an argument to plugin methods that need it. This would:
- Make the dependency visible at the call site
- Remove the need for the instance cache entirely
- Make plugin methods independently testable (inject any MetaTable)
- Keep
MetaTable.open() stateless
What needs investigation
- How plugin methods are currently invoked in
SessionTaskMenu and App
- What signature changes would be required for plugin methods that modify the table
- Whether a protocol/interface should be defined (e.g. plugins declare whether they need a MetaTable reference)
- Backwards compatibility with existing plugin methods that do not need the table
Related
Introduced as a workaround in the MetaTable shared-instance PR. The cache (MetaTable.getInstanceCache) and MetaTable.clearCache() could be removed once this is implemented.
Background
Currently,
nansen.Appholds aMetaTableinstance and plugin (session task) methods are invoked without a direct reference to it. To allow plugins to modify the table that is loaded in the App and trigger a UI update, a per-filepath instance cache was introduced inMetaTable.open()(a global in disguise).Problem
The cache is semantically a global variable. While the coupling is intentional (plugins and App must share the same instance), globals are still a pragmatic compromise rather than a clean design. They hide dependencies, complicate testing, and make lifetime management implicit.
Proposed improvement
Since App is the one invoking plugin methods (via
SessionTaskMenu), it could passapp.MetaTableexplicitly as an argument to plugin methods that need it. This would:MetaTable.open()statelessWhat needs investigation
SessionTaskMenuandAppRelated
Introduced as a workaround in the MetaTable shared-instance PR. The cache (
MetaTable.getInstanceCache) andMetaTable.clearCache()could be removed once this is implemented.