fix(reconciliation): 平台抽屉补 WeKnora 跳转链接
build / build (push) Failing after 26s

- 为什么:白盒复检 P1——平台侧文件详情抽屉 503 只有文案,需求 §8 要求跳转链接;/monitor/tasks 行没有 URL。
- 做什么:抽出 KnowledgeBaseConsoleURL,finding 与 /monitor/tasks 共用同一拼接;handler 用当前生效测试端点填 weknora_url,前端抽屉透传给 WeKnoraProgress;openapi/需求 §7 同步。
- 补证据:stage=weknora 真库合并用例;对账扫描改为真实 HTTP 桩断言零写;progress 投影断言上游密钥字段不外泄。
- 验证:make verify 17 项 success;go test ./... exit 0;web 648 测试 + build;monitor_tasks 真库集成用例 PASS。
This commit is contained in:
Zhero & Rin
2026-12-01 15:00:25 +08:00
committed by 姚章浩
parent 7d21251605
commit 095aa3ed68
16 changed files with 344 additions and 28 deletions
+20
View File
@@ -0,0 +1,20 @@
package weknora
import (
"net/url"
"strings"
)
// KnowledgeBaseConsoleURL builds the console link for one knowledge base.
// Reconciliation findings and the platform task drawer both use this rule: if
// they drift, the same knowledge base opens at two different addresses, and the
// 503 fallback link in one drawer points somewhere else than the other.
// An empty origin or base id yields an empty link, which both callers treat as
// "no link configured" rather than inventing a host.
func KnowledgeBaseConsoleURL(origin, knowledgeBaseID string) string {
origin, knowledgeBaseID = strings.TrimSpace(origin), strings.TrimSpace(knowledgeBaseID)
if origin == "" || knowledgeBaseID == "" {
return ""
}
return strings.TrimSuffix(origin, "/") + "/platform/knowledge-bases/" + url.PathEscape(knowledgeBaseID)
}
@@ -0,0 +1,19 @@
package weknora
import "testing"
func TestKnowledgeBaseConsoleURLCannotInventAHost(t *testing.T) {
cases := []struct{ origin, kb, want string }{
{"", "kb-1", ""},
{"https://weknora.test", "", ""},
{" ", "kb-1", ""},
{"https://weknora.test/", "kb-1", "https://weknora.test/platform/knowledge-bases/kb-1"},
{" https://weknora.test/ ", " kb-1 ", "https://weknora.test/platform/knowledge-bases/kb-1"},
{"https://weknora.test/base", "kb 1", "https://weknora.test/base/platform/knowledge-bases/kb%201"},
}
for _, c := range cases {
if got := KnowledgeBaseConsoleURL(c.origin, c.kb); got != c.want {
t.Fatalf("KnowledgeBaseConsoleURL(%q,%q) = %q, want %q", c.origin, c.kb, got, c.want)
}
}
}