Keep plugin services alive across config writes

Every ConfigService write rebuilt PluginHost's hosted array, and the
Instantiator recreated all plugins for it. A wallpaper change thus
restarted the screen recorder's replay buffer and left the new
instance's IpcHandler shadowed by the old one. Mirror the list into a
ListModel that only adds or removes plugins whose state changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-13 16:17:52 +02:00
1 parent ebc81e8b46
commit d7f0498ba0
1 file changed
+25 -3
+25 -3
View File
@@ -24,12 +24,34 @@ Scope {
}
readonly property var hosted: PluginService.plugins.filter(p => PluginService.isEnabled(p.id)).map(p => p.id)
// Every config write (a wallpaper change, say) rebuilds `hosted`, and an
// Instantiator handed a new array recreates all its delegates, restarting
// long-running services such as a replay buffer. Mirror it into a model
// that only changes for plugins that were actually enabled or disabled.
ListModel {
id: hostedModel
}
function syncHosted() {
for (let i = hostedModel.count - 1; i >= 0; i--) {
if (!hosted.includes(hostedModel.get(i).pluginId))
hostedModel.remove(i);
}
const present = [];
for (let i = 0; i < hostedModel.count; i++)
present.push(hostedModel.get(i).pluginId);
for (const id of hosted) {
if (!present.includes(id))
hostedModel.append({ pluginId: id });
}
}
onHostedChanged: syncHosted()
Component.onCompleted: syncHosted()
Instantiator {
model: root.hosted
model: hostedModel
delegate: Scope {
id: slot
required property string modelData
readonly property string pluginId: modelData
required property string pluginId
readonly property var kinds: PluginService.kinds(pluginId)
readonly property var manifest: (PluginService.plugin(pluginId) || {}).manifest || {}
readonly property bool noctalia: PluginService.ecosystem(pluginId) === "noctalia"