openvibers/openvibe.link Commits

Link: a desk host installed with allow_desk is a desk host (#171)

OP OpenVibers committed 9 h ago · 3920ed60f9 · 2 files, +17 −1

The installer writes a desk host's desks as allow_desk (desk_dir, max_desks …) on the computer plugin; the role
check looked only for a nested desk object, so ov-node-01 (a shared desk host) logged that the desks.host role was
not applied. Either layout counts now; desks off still does not.

Changes

ddiff --git a/internal/agent/agent.go b/internal/agent/agent.go
iindex 4b811b9..2948cb6 100644
---- a/internal/agent/agent.go
++++ b/internal/agent/agent.go
@@@ -651,12 +651,17 @@ func (n *Agent) startWorker(why string) bool {
return true
}
--// hasDeskHost says whether this machine was installed as a desk host: the computer plugin with a desk of its own.
++// hasDeskHost says whether this machine was installed as a desk host: the computer plugin with desks of its own.
++// The installer writes them as allow_desk (with desk_dir, max_desks …) on the plugin's config; an older layout nested
++// them under desk. Either one is a desk host (2026-11-12: ov-node-01, a shared desk host, said it had none).
func (n *Agent) hasDeskHost() bool {
for _, p := range n.opt.Config.Plugins {
if p.Name != "computer" && p.Name != "computer.py" {
continue
}
++ if on, ok := p.Config["allow_desk"].(bool); ok && on {
++ return true
++ }
if d, ok := p.Config["desk"].(map[string]any); ok && len(d) > 0 {
return true
}
ddiff --git a/internal/agent/roles_test.go b/internal/agent/roles_test.go
iindex cff4d8d..a9df1ab 100644
---- a/internal/agent/roles_test.go
++++ b/internal/agent/roles_test.go
@@@ -108,6 +108,17 @@ func TestRoleFeatures(t *testing.T) {
if !n.hasAIHost() {
t.Error("the ai plugin serves the machine's own models")
}
++ // The installer's own layout: allow_desk on the plugin's config (a shared desk host writes it so).
++ flat := config.Default()
++ flat.Plugins = []config.PluginConfig{{Name: "computer", Config: map[string]any{"allow_desk": true, "desk_dir": "/var/lib/openvibe-desk/desks", "max_desks": 7}}}
++ if !(&Agent{opt: Options{Config: flat}}).hasDeskHost() {
++ t.Error("the installer's allow_desk is a desk host")
++ }
++ off := config.Default()
++ off.Plugins = []config.PluginConfig{{Name: "computer", Config: map[string]any{"allow_desk": false, "level": "trusted"}}}
++ if (&Agent{opt: Options{Config: off}}).hasDeskHost() {
++ t.Error("a computer plugin with desks off is not a desk host")
++ }
plain := &Agent{opt: Options{Config: config.Default()}}
if plain.hasDeskHost() || plain.hasAIHost() {
t.Error("a machine with neither plugin has neither feature")