feat: prefer direct benchmark actions when context exists
This commit is contained in:
@@ -12648,6 +12648,19 @@ document.addEventListener("click", async (event) => {
|
||||
return;
|
||||
}
|
||||
if (name === "open-similar-search") {
|
||||
const account = getSelectedAccount();
|
||||
if (account?.id) {
|
||||
await runDirectDiscoveryAction("search-similar-accounts", {
|
||||
target_account_id: account.id,
|
||||
max_candidates: 8,
|
||||
extra_requirements: ""
|
||||
}, {
|
||||
busyLabel: "正在查找相似账号...",
|
||||
errorTitle: "查相似失败",
|
||||
discoveryFocus: "relations"
|
||||
});
|
||||
return;
|
||||
}
|
||||
openSimilaritySearchAction();
|
||||
return;
|
||||
}
|
||||
@@ -12665,6 +12678,22 @@ document.addEventListener("click", async (event) => {
|
||||
return;
|
||||
}
|
||||
if (name === "open-benchmark-link") {
|
||||
const account = getSelectedAccount();
|
||||
const candidate = safeArray(appState.lastSimilaritySearch?.candidates)[0] || null;
|
||||
if (account?.id && candidate) {
|
||||
await runDirectDiscoveryAction("save-benchmark-link", {
|
||||
source_account_id: account.id,
|
||||
target_account_id: candidate.candidate_account_id || "",
|
||||
target_profile_url: candidate.candidate_account_id ? "" : (candidate.candidate_profile_url || ""),
|
||||
search_id: appState.lastSimilaritySearch?.id || "",
|
||||
note: brief(candidate.rationale_text || "由对标工作台直接加入对标库。", 120)
|
||||
}, {
|
||||
busyLabel: "正在保存对标关系...",
|
||||
errorTitle: "保存对标失败",
|
||||
discoveryFocus: "relations"
|
||||
});
|
||||
return;
|
||||
}
|
||||
openBenchmarkLinkAction();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1450,6 +1450,16 @@ test("live-first workbench flows no longer advertise stale missing-capability pl
|
||||
assert.match(APP, /暂未识别当前动作/);
|
||||
});
|
||||
|
||||
test("smart discovery entrypoints prefer direct execute before falling back to forms", () => {
|
||||
const clicks = extractBetween(APP, "document.addEventListener(\"click\", async (event) => {", "document.addEventListener(\"submit\", async (event) => {");
|
||||
assert.match(clicks, /name === "open-similar-search"[\s\S]*const account = getSelectedAccount\(\);/);
|
||||
assert.match(clicks, /name === "open-similar-search"[\s\S]*runDirectDiscoveryAction\("search-similar-accounts"/);
|
||||
assert.match(clicks, /name === "open-similar-search"[\s\S]*openSimilaritySearchAction\(\);/);
|
||||
assert.match(clicks, /name === "open-benchmark-link"[\s\S]*const candidate = safeArray\(appState\.lastSimilaritySearch\?\.candidates\)\[0\] \|\| null;/);
|
||||
assert.match(clicks, /name === "open-benchmark-link"[\s\S]*runDirectDiscoveryAction\("save-benchmark-link"/);
|
||||
assert.match(clicks, /name === "open-benchmark-link"[\s\S]*openBenchmarkLinkAction\(\);/);
|
||||
});
|
||||
|
||||
test("declared static workbench actions are wired into explicit handlers", () => {
|
||||
const declared = new Set([...APP.matchAll(/data-action="([a-zA-Z0-9_-]+)"/g)].map((match) => match[1]));
|
||||
const clickHandled = new Set([...APP.matchAll(/if \(name === "([a-zA-Z0-9_-]+)"\)/g)].map((match) => match[1]));
|
||||
|
||||
Reference in New Issue
Block a user