Feature: return web-console remarks from the Go MCP host tools

list_hosts and get_host_detail now include the remark an admin set in the
web console, and the name/query filters match it like the Win32 server
(name: hostname + remark; query: hostname + remark + IP). The text-only
host table gains a remark column, and the MCP instructions stop claiming
the Go server keeps no remarks.

The remark table is injected through a small Note() interface so the mcp
package still does not import web. An optional Notes() snapshot
capability is borrowed once per call, so a listing neither takes a read
lock per device nor mixes labels across a concurrent save. The design
docs are updated to match the new fields and table column.

Verified: go build ./..., go vet, gofmt and the full go test ./... pass;
new tests cover remark projection, both filters and the snapshot path.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-27 14:51:15 +01:00
1 parent 95d2bbc1b6
commit 5f764b2425
8 files changed
+136 -28

No files matched your search

+14
View File
@@ -73,6 +73,20 @@ func TestDeviceNotesSetPersistClear(t *testing.T) {
if got := notes.Note("dev-2"); got != "" {
t.Fatalf("Note after Remove = %q, want empty", got)
}
// Notes() is the bulk snapshot callers take per listing; it must be a
// copy, not a live view of the table.
if err := notes.Set("dev-3", "Bulk", "admin"); err != nil {
t.Fatalf("Set dev-3: %v", err)
}
snap := notes.Notes()
if snap["dev-3"] != "Bulk" {
t.Fatalf("Notes()[dev-3] = %q, want %q", snap["dev-3"], "Bulk")
}
snap["dev-3"] = "mutated"
if got := notes.Note("dev-3"); got != "Bulk" {
t.Fatalf("mutating the snapshot changed the store: %q", got)
}
}
// TestSetDeviceRemarkHandler exercises the WebSocket path: the superadmin