feat(web): 播报板搜索支持按节点 id 筛选

搜索框在内容/来源之外,新增节点 id 匹配:纯数字或 UI 展示的「#41」形式
都会精确命中该节点。服务端 NodesPage 在 payload/origin ILIKE 的 OR 组里
追加 id 精确匹配;mock 同步;补 NodesPage id 搜索测试。
This commit is contained in:
Autumn-27 committed 2026-09-17 11:31:27 -04:00
1 parent c6c5329a18
commit e2ada7e494
4 files changed
+65 -3

No files matched your search

+48
View File
@@ -246,3 +246,51 @@ func TestIntentPauseResumeAndCancelCleanup(t *testing.T) {
assertCount(`SELECT COUNT(*) FROM exploration_anchors WHERE node_id=$1`, 0, directFact)
assertCount(`SELECT COUNT(*) FROM assets WHERE id=$1`, 1, assetID)
}
// TestNodesPageQueryMatchesID verifies the 播报板 search filters on node id (both
// the bare number and the「#id」form the UI shows) in addition to payload/origin.
func TestNodesPageQueryMatchesID(t *testing.T) {
d, err := Open(testDSN(t))
if err != nil {
t.Skipf("postgres unavailable (%v) — skipping", err)
}
defer d.Close()
expID, err := d.CreateExploration("test", "id 搜索")
if err != nil {
t.Fatal(err)
}
defer d.Exec(`DELETE FROM explorations WHERE id=$1`, expID)
es := d.Exploration(expID)
target, err := es.AddNode("fact", map[string]any{"summary": "needle-alpha"}, 0, "confirmed", "worker-a", nil)
if err != nil {
t.Fatal(err)
}
other, err := es.AddNode("fact", map[string]any{"summary": "unrelated-beta"}, 0, "confirmed", "worker-b", nil)
if err != nil {
t.Fatal(err)
}
onlyTarget := func(label, q string) {
t.Helper()
nodes, total, err := es.NodesPage(NodeFilter{Query: q}, 1, 50)
if err != nil {
t.Fatalf("%s: %v", label, err)
}
if total != 1 || len(nodes) != 1 || nodes[0].ID != target {
t.Fatalf("%s: q=%q total=%d nodes=%+v, want single node %d", label, q, total, nodes, target)
}
}
onlyTarget("bare id", fmt.Sprint(target))
onlyTarget("hash id", "#"+fmt.Sprint(target))
onlyTarget("payload still works", "needle-alpha")
// A non-matching numeric id returns nothing (and does not accidentally match other).
if nodes, total, err := es.NodesPage(NodeFilter{Query: fmt.Sprint(target + other + 1000)}, 1, 50); err != nil {
t.Fatal(err)
} else if total != 0 || len(nodes) != 0 {
t.Fatalf("non-existent id: total=%d nodes=%+v, want empty", total, nodes)
}
}