openvibers/openvibe.link Commits
Link: a desk host installed with allow_desk is a desk host (#171)
Changes
@@@ -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}@@@ -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")
@@ -651,12 +651,17 @@ func (n *Agent) startWorker(why string) bool {
@@ -651,12 +651,17 @@ func (n *Agent) startWorker(why string) bool {
return true
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 {
func (n *Agent) hasDeskHost() bool {
for _, p := range n.opt.Config.Plugins {
for _, p := range n.opt.Config.Plugins {
if p.Name != "computer" && p.Name != "computer.py" {
if p.Name != "computer" && p.Name != "computer.py" {
continue
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 {
if d, ok := p.Config["desk"].(map[string]any); ok && len(d) > 0 {
return true
return true
}
}
@@ -108,6 +108,17 @@ func TestRoleFeatures(t *testing.T) {
@@ -108,6 +108,17 @@ func TestRoleFeatures(t *testing.T) {
if !n.hasAIHost() {
if !n.hasAIHost() {
t.Error("the ai plugin serves the machine's own models")
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()}}
plain := &Agent{opt: Options{Config: config.Default()}}
if plain.hasDeskHost() || plain.hasAIHost() {
if plain.hasDeskHost() || plain.hasAIHost() {
t.Error("a machine with neither plugin has neither feature")
t.Error("a machine with neither plugin has neither feature")