mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Fix cognition owner label collisions in UI
This commit is contained in:
55
style.css
55
style.css
@@ -5275,6 +5275,13 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bme-cog-owner-card__name-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.bme-cog-owner-card__name {
|
.bme-cog-owner-card__name {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@@ -5282,6 +5289,22 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bme-cog-owner-card__badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.4;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: var(--bme-on-surface-dim);
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bme-cog-owner-card__stats {
|
.bme-cog-owner-card__stats {
|
||||||
@@ -5309,10 +5332,25 @@
|
|||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bme-cog-detail-title-wrap {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 3px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.bme-cog-detail-name {
|
.bme-cog-detail-name {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--bme-on-surface);
|
color: var(--bme-on-surface);
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bme-cog-detail-meta {
|
||||||
|
font-size: 10px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--bme-on-surface-dim);
|
||||||
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bme-cog-detail-badge {
|
.bme-cog-detail-badge {
|
||||||
@@ -5805,3 +5843,20 @@
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 520px) {
|
||||||
|
.bme-cognition-line {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bme-cognition-line strong {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bme-cog-detail-header {
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -114,6 +114,18 @@ applyCognitionUpdates(
|
|||||||
],
|
],
|
||||||
{ changedNodeIds: [bellEvent.id] },
|
{ changedNodeIds: [bellEvent.id] },
|
||||||
);
|
);
|
||||||
|
applyCognitionUpdates(
|
||||||
|
graph,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
ownerType: "user",
|
||||||
|
ownerName: "露西亚",
|
||||||
|
knownRefs: [bellEvent.id],
|
||||||
|
visibility: [{ ref: bellEvent.id, score: 0.8 }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{ changedNodeIds: [bellEvent.id] },
|
||||||
|
);
|
||||||
applyManualKnowledgeOverride(graph, {
|
applyManualKnowledgeOverride(graph, {
|
||||||
ownerKey: ownerA.ownerKey,
|
ownerKey: ownerA.ownerKey,
|
||||||
nodeId: bellEvent.id,
|
nodeId: bellEvent.id,
|
||||||
@@ -149,5 +161,11 @@ assert.ok(
|
|||||||
(entry) => entry.ownerName === "露西亚" && entry.knownCount >= 1,
|
(entry) => entry.ownerName === "露西亚" && entry.knownCount >= 1,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
const sameNameOwners = ownerList.filter((entry) => entry.ownerName === "露西亚");
|
||||||
|
assert.equal(sameNameOwners.length, 2);
|
||||||
|
assert.deepEqual(
|
||||||
|
sameNameOwners.map((entry) => entry.ownerType).sort(),
|
||||||
|
["character", "user"],
|
||||||
|
);
|
||||||
|
|
||||||
console.log("knowledge-state tests passed");
|
console.log("knowledge-state tests passed");
|
||||||
|
|||||||
181
ui/panel.js
181
ui/panel.js
@@ -984,6 +984,98 @@ function _ownerAvatarHsl(name) {
|
|||||||
return `hsl(${hue}, 55%, 42%)`;
|
return `hsl(${hue}, 55%, 42%)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _normalizeOwnerUiType(ownerType = "") {
|
||||||
|
const normalized = String(ownerType || "").trim();
|
||||||
|
if (normalized === "user") return "user";
|
||||||
|
if (normalized === "character") return "character";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function _inferOwnerTypeFromKey(ownerKey = "") {
|
||||||
|
const normalizedOwnerKey = String(ownerKey || "").trim().toLowerCase();
|
||||||
|
if (normalizedOwnerKey.startsWith("user:")) return "user";
|
||||||
|
if (normalizedOwnerKey.startsWith("character:")) return "character";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getOwnerTypeDisplayLabel(ownerType = "") {
|
||||||
|
const normalizedType = _normalizeOwnerUiType(ownerType);
|
||||||
|
if (normalizedType === "user") return "用户";
|
||||||
|
if (normalizedType === "character") return "角色";
|
||||||
|
return "Owner";
|
||||||
|
}
|
||||||
|
|
||||||
|
function _buildOwnerCollisionIndex(owners = []) {
|
||||||
|
const collisionIndex = new Map();
|
||||||
|
for (const owner of Array.isArray(owners) ? owners : []) {
|
||||||
|
const baseName =
|
||||||
|
String(owner?.ownerName || owner?.ownerKey || "未命名角色").trim() ||
|
||||||
|
"未命名角色";
|
||||||
|
const nameKey = baseName.toLocaleLowerCase("zh-Hans-CN");
|
||||||
|
const ownerType = _normalizeOwnerUiType(owner?.ownerType) || "unknown";
|
||||||
|
const entry = collisionIndex.get(nameKey) || {
|
||||||
|
count: 0,
|
||||||
|
typeCounts: new Map(),
|
||||||
|
};
|
||||||
|
entry.count += 1;
|
||||||
|
entry.typeCounts.set(ownerType, (entry.typeCounts.get(ownerType) || 0) + 1);
|
||||||
|
collisionIndex.set(nameKey, entry);
|
||||||
|
}
|
||||||
|
return collisionIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _shortOwnerNodeId(owner = {}) {
|
||||||
|
const nodeId = String(owner?.nodeId || "").trim();
|
||||||
|
if (!nodeId) return "";
|
||||||
|
return nodeId.length > 6 ? nodeId.slice(0, 6) : nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getOwnerDisplayInfo(owner = {}, collisionIndex = null) {
|
||||||
|
const baseName =
|
||||||
|
String(owner?.ownerName || owner?.ownerKey || "未命名角色").trim() ||
|
||||||
|
"未命名角色";
|
||||||
|
const ownerKey = String(owner?.ownerKey || "").trim();
|
||||||
|
const ownerType =
|
||||||
|
_normalizeOwnerUiType(owner?.ownerType) || _inferOwnerTypeFromKey(ownerKey);
|
||||||
|
const typeLabel = _getOwnerTypeDisplayLabel(ownerType);
|
||||||
|
const collisionInfo =
|
||||||
|
collisionIndex instanceof Map
|
||||||
|
? collisionIndex.get(baseName.toLocaleLowerCase("zh-Hans-CN")) || null
|
||||||
|
: null;
|
||||||
|
const typeCounts =
|
||||||
|
collisionInfo?.typeCounts instanceof Map ? collisionInfo.typeCounts : new Map();
|
||||||
|
const totalCount = Number(collisionInfo?.count || 0);
|
||||||
|
const sameTypeCount = Number(typeCounts.get(ownerType || "unknown") || 0);
|
||||||
|
const hasCrossTypeCollision = totalCount > 1 && typeCounts.size > 1;
|
||||||
|
const shortNodeId = ownerType === "character" ? _shortOwnerNodeId(owner) : "";
|
||||||
|
|
||||||
|
let title = baseName;
|
||||||
|
if (hasCrossTypeCollision) {
|
||||||
|
title = `${baseName}(${typeLabel})`;
|
||||||
|
} else if (sameTypeCount > 1) {
|
||||||
|
title =
|
||||||
|
ownerType === "character" && shortNodeId
|
||||||
|
? `${baseName}(${typeLabel} ${shortNodeId})`
|
||||||
|
: `${baseName}(${typeLabel})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const subtitleParts = [typeLabel];
|
||||||
|
if (ownerType === "character" && shortNodeId) {
|
||||||
|
subtitleParts.push(`#${shortNodeId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
typeLabel,
|
||||||
|
subtitle: subtitleParts.join(" · "),
|
||||||
|
avatarText: baseName.charAt(0) || "?",
|
||||||
|
avatarSeed: ownerKey || `${ownerType}:${baseName}`,
|
||||||
|
tooltip: [title, ownerKey && ownerKey !== title ? ownerKey : ""]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" · "),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 认知视图工作区 ====================
|
// ==================== 认知视图工作区 ====================
|
||||||
|
|
||||||
function _refreshCognitionWorkspace() {
|
function _refreshCognitionWorkspace() {
|
||||||
@@ -1016,6 +1108,7 @@ function _renderCogStatusStrip(graph, loadInfo, canRender) {
|
|||||||
const timelineState = graph?.timelineState || {};
|
const timelineState = graph?.timelineState || {};
|
||||||
const { owners, activeOwnerKey, activeOwner, activeOwnerLabels } =
|
const { owners, activeOwnerKey, activeOwner, activeOwnerLabels } =
|
||||||
_getCurrentCognitionOwnerSummary(graph);
|
_getCurrentCognitionOwnerSummary(graph);
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(owners);
|
||||||
const activeRegion = String(
|
const activeRegion = String(
|
||||||
historyState.activeRegion || historyState.lastExtractedRegion || regionState.manualActiveRegion || "",
|
historyState.activeRegion || historyState.lastExtractedRegion || regionState.manualActiveRegion || "",
|
||||||
).trim();
|
).trim();
|
||||||
@@ -1046,7 +1139,9 @@ function _renderCogStatusStrip(graph, loadInfo, canRender) {
|
|||||||
<div class="bme-cog-status-card__value">${_escHtml(
|
<div class="bme-cog-status-card__value">${_escHtml(
|
||||||
activeOwnerLabels.length > 0
|
activeOwnerLabels.length > 0
|
||||||
? activeOwnerLabels.join(" / ")
|
? activeOwnerLabels.join(" / ")
|
||||||
: activeOwner?.ownerName || activeOwnerKey || "—",
|
: activeOwner
|
||||||
|
? _getOwnerDisplayInfo(activeOwner, collisionIndex).title
|
||||||
|
: activeOwnerKey || "—",
|
||||||
)}</div>
|
)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bme-cog-status-card">
|
<div class="bme-cog-status-card">
|
||||||
@@ -1083,6 +1178,7 @@ function _renderCogOwnerList(graph, canRender) {
|
|||||||
|
|
||||||
const { owners, activeOwnerKey, activeOwnerKeys } =
|
const { owners, activeOwnerKey, activeOwnerKeys } =
|
||||||
_getCurrentCognitionOwnerSummary(graph);
|
_getCurrentCognitionOwnerSummary(graph);
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(owners);
|
||||||
|
|
||||||
if (!owners.length) {
|
if (!owners.length) {
|
||||||
el.innerHTML = `<div class="bme-cog-monitor-empty">暂无认知角色</div>`;
|
el.innerHTML = `<div class="bme-cog-monitor-empty">暂无认知角色</div>`;
|
||||||
@@ -1091,8 +1187,8 @@ function _renderCogOwnerList(graph, canRender) {
|
|||||||
|
|
||||||
el.innerHTML = owners
|
el.innerHTML = owners
|
||||||
.map((owner) => {
|
.map((owner) => {
|
||||||
const firstName = String(owner.ownerName || owner.ownerKey || "?").charAt(0);
|
const displayInfo = _getOwnerDisplayInfo(owner, collisionIndex);
|
||||||
const bgColor = _ownerAvatarHsl(owner.ownerName || owner.ownerKey);
|
const bgColor = _ownerAvatarHsl(displayInfo.avatarSeed);
|
||||||
const selected = owner.ownerKey === currentCognitionOwnerKey ? "is-selected" : "";
|
const selected = owner.ownerKey === currentCognitionOwnerKey ? "is-selected" : "";
|
||||||
const anchor =
|
const anchor =
|
||||||
owner.ownerKey === activeOwnerKey ||
|
owner.ownerKey === activeOwnerKey ||
|
||||||
@@ -1102,10 +1198,14 @@ function _renderCogOwnerList(graph, canRender) {
|
|||||||
return `
|
return `
|
||||||
<div class="bme-cog-owner-card ${selected} ${anchor}"
|
<div class="bme-cog-owner-card ${selected} ${anchor}"
|
||||||
data-owner-key="${_escHtml(String(owner.ownerKey || ""))}"
|
data-owner-key="${_escHtml(String(owner.ownerKey || ""))}"
|
||||||
role="button" tabindex="0">
|
role="button" tabindex="0"
|
||||||
<div class="bme-cog-avatar" style="background:${bgColor}">${_escHtml(firstName)}</div>
|
title="${_escHtml(displayInfo.tooltip)}">
|
||||||
|
<div class="bme-cog-avatar" style="background:${bgColor}">${_escHtml(displayInfo.avatarText)}</div>
|
||||||
<div class="bme-cog-owner-card__info">
|
<div class="bme-cog-owner-card__info">
|
||||||
<div class="bme-cog-owner-card__name">${_escHtml(String(owner.ownerName || owner.ownerKey || "未命名"))}</div>
|
<div class="bme-cog-owner-card__name-row">
|
||||||
|
<div class="bme-cog-owner-card__name">${_escHtml(displayInfo.title)}</div>
|
||||||
|
<span class="bme-cog-owner-card__badge">${_escHtml(displayInfo.typeLabel)}</span>
|
||||||
|
</div>
|
||||||
<div class="bme-cog-owner-card__stats">已知 ${Number(owner.knownCount || 0)} · 误解 ${Number(owner.mistakenCount || 0)} · 隐藏 ${Number(owner.manualHiddenCount || 0)}</div>
|
<div class="bme-cog-owner-card__stats">已知 ${Number(owner.knownCount || 0)} · 误解 ${Number(owner.mistakenCount || 0)} · 隐藏 ${Number(owner.manualHiddenCount || 0)}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
@@ -1124,6 +1224,9 @@ function _renderCogOwnerDetail(graph, loadInfo, canRender) {
|
|||||||
|
|
||||||
const { selectedOwner, activeOwnerKey, activeOwnerKeys } =
|
const { selectedOwner, activeOwnerKey, activeOwnerKeys } =
|
||||||
_getCurrentCognitionOwnerSummary(graph);
|
_getCurrentCognitionOwnerSummary(graph);
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(
|
||||||
|
_getCognitionOwnerCollection(graph),
|
||||||
|
);
|
||||||
|
|
||||||
if (!selectedOwner) {
|
if (!selectedOwner) {
|
||||||
el.innerHTML = `<div class="bme-cog-monitor-empty">选择上方角色查看详情,或等待提取产生认知数据。</div>`;
|
el.innerHTML = `<div class="bme-cog-monitor-empty">选择上方角色查看详情,或等待提取产生认知数据。</div>`;
|
||||||
@@ -1169,6 +1272,7 @@ function _renderCogOwnerDetail(graph, loadInfo, canRender) {
|
|||||||
const writeBlocked = _isGraphWriteBlocked(loadInfo);
|
const writeBlocked = _isGraphWriteBlocked(loadInfo);
|
||||||
const suppressedCount = new Set([...(ownerState.manualHiddenNodeIds || []), ...(ownerState.mistakenNodeIds || [])]).size;
|
const suppressedCount = new Set([...(ownerState.manualHiddenNodeIds || []), ...(ownerState.mistakenNodeIds || [])]).size;
|
||||||
const disabledAttr = !selectedNode || writeBlocked ? "disabled" : "";
|
const disabledAttr = !selectedNode || writeBlocked ? "disabled" : "";
|
||||||
|
const displayInfo = _getOwnerDisplayInfo(selectedOwner, collisionIndex);
|
||||||
|
|
||||||
const visChips = strongVisibleNames.length
|
const visChips = strongVisibleNames.length
|
||||||
? strongVisibleNames.map((n) => `<span class="bme-cog-chip is-visible">${_escHtml(n)}</span>`).join("")
|
? strongVisibleNames.map((n) => `<span class="bme-cog-chip is-visible">${_escHtml(n)}</span>`).join("")
|
||||||
@@ -1179,7 +1283,12 @@ function _renderCogOwnerDetail(graph, loadInfo, canRender) {
|
|||||||
|
|
||||||
el.innerHTML = `
|
el.innerHTML = `
|
||||||
<div class="bme-cog-detail-header">
|
<div class="bme-cog-detail-header">
|
||||||
<div class="bme-cog-detail-name">${_escHtml(String(selectedOwner.ownerName || selectedOwner.ownerKey || "未命名"))}</div>
|
<div class="bme-cog-detail-title-wrap">
|
||||||
|
<div class="bme-cog-detail-name" title="${_escHtml(displayInfo.tooltip)}">${_escHtml(displayInfo.title)}</div>
|
||||||
|
<div class="bme-cog-detail-meta">${_escHtml(
|
||||||
|
[displayInfo.subtitle, selectedOwner.ownerKey || ""].filter(Boolean).join(" · "),
|
||||||
|
)}</div>
|
||||||
|
</div>
|
||||||
${
|
${
|
||||||
selectedOwner.ownerKey === activeOwnerKey ||
|
selectedOwner.ownerKey === activeOwnerKey ||
|
||||||
activeOwnerKeys.includes(selectedOwner.ownerKey)
|
activeOwnerKeys.includes(selectedOwner.ownerKey)
|
||||||
@@ -1426,6 +1535,7 @@ function _refreshMobileCognition() {
|
|||||||
|
|
||||||
const { owners, activeOwnerKey, activeOwner, activeOwnerKeys, activeOwnerLabels } =
|
const { owners, activeOwnerKey, activeOwner, activeOwnerKeys, activeOwnerLabels } =
|
||||||
_getCurrentCognitionOwnerSummary(graph);
|
_getCurrentCognitionOwnerSummary(graph);
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(owners);
|
||||||
const historyState = graph?.historyState || {};
|
const historyState = graph?.historyState || {};
|
||||||
const regionState = graph?.regionState || {};
|
const regionState = graph?.regionState || {};
|
||||||
const activeRegion = String(historyState.activeRegion || historyState.lastExtractedRegion || regionState.manualActiveRegion || "").trim();
|
const activeRegion = String(historyState.activeRegion || historyState.lastExtractedRegion || regionState.manualActiveRegion || "").trim();
|
||||||
@@ -1433,17 +1543,20 @@ function _refreshMobileCognition() {
|
|||||||
? regionState.adjacencyMap[activeRegion].adjacent : [];
|
? regionState.adjacencyMap[activeRegion].adjacent : [];
|
||||||
|
|
||||||
const ownerCards = owners.map((owner) => {
|
const ownerCards = owners.map((owner) => {
|
||||||
const firstName = String(owner.ownerName || owner.ownerKey || "?").charAt(0);
|
const displayInfo = _getOwnerDisplayInfo(owner, collisionIndex);
|
||||||
const bgColor = _ownerAvatarHsl(owner.ownerName || owner.ownerKey);
|
const bgColor = _ownerAvatarHsl(displayInfo.avatarSeed);
|
||||||
const anchor =
|
const anchor =
|
||||||
owner.ownerKey === activeOwnerKey || activeOwnerKeys.includes(owner.ownerKey)
|
owner.ownerKey === activeOwnerKey || activeOwnerKeys.includes(owner.ownerKey)
|
||||||
? "is-active-anchor"
|
? "is-active-anchor"
|
||||||
: "";
|
: "";
|
||||||
return `
|
return `
|
||||||
<div class="bme-cog-owner-card ${anchor}" style="min-width:unset;max-width:unset">
|
<div class="bme-cog-owner-card ${anchor}" style="min-width:unset;max-width:unset" title="${_escHtml(displayInfo.tooltip)}">
|
||||||
<div class="bme-cog-avatar" style="background:${bgColor}">${_escHtml(firstName)}</div>
|
<div class="bme-cog-avatar" style="background:${bgColor}">${_escHtml(displayInfo.avatarText)}</div>
|
||||||
<div class="bme-cog-owner-card__info">
|
<div class="bme-cog-owner-card__info">
|
||||||
<div class="bme-cog-owner-card__name">${_escHtml(String(owner.ownerName || owner.ownerKey || "未命名"))}</div>
|
<div class="bme-cog-owner-card__name-row">
|
||||||
|
<div class="bme-cog-owner-card__name">${_escHtml(displayInfo.title)}</div>
|
||||||
|
<span class="bme-cog-owner-card__badge">${_escHtml(displayInfo.typeLabel)}</span>
|
||||||
|
</div>
|
||||||
<div class="bme-cog-owner-card__stats">已知 ${Number(owner.knownCount || 0)} · 误解 ${Number(owner.mistakenCount || 0)}</div>
|
<div class="bme-cog-owner-card__stats">已知 ${Number(owner.knownCount || 0)} · 误解 ${Number(owner.mistakenCount || 0)}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
@@ -1456,7 +1569,9 @@ function _refreshMobileCognition() {
|
|||||||
<div class="bme-cog-status-card__value">${_escHtml(
|
<div class="bme-cog-status-card__value">${_escHtml(
|
||||||
activeOwnerLabels.length > 0
|
activeOwnerLabels.length > 0
|
||||||
? activeOwnerLabels.join(" / ")
|
? activeOwnerLabels.join(" / ")
|
||||||
: activeOwner?.ownerName || "—",
|
: activeOwner
|
||||||
|
? _getOwnerDisplayInfo(activeOwner, collisionIndex).title
|
||||||
|
: "—",
|
||||||
)}</div>
|
)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bme-cog-status-card">
|
<div class="bme-cog-status-card">
|
||||||
@@ -1774,6 +1889,7 @@ function _getLatestRecallOwnerInfo(graph) {
|
|||||||
runtimeDebug?.runtimeDebug?.injections?.recall || {};
|
runtimeDebug?.runtimeDebug?.injections?.recall || {};
|
||||||
const retrievalMeta = recallInjection?.retrievalMeta || {};
|
const retrievalMeta = recallInjection?.retrievalMeta || {};
|
||||||
const owners = _getCognitionOwnerCollection(graph);
|
const owners = _getCognitionOwnerCollection(graph);
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(owners);
|
||||||
const ownerCandidates = Array.isArray(retrievalMeta.sceneOwnerCandidates)
|
const ownerCandidates = Array.isArray(retrievalMeta.sceneOwnerCandidates)
|
||||||
? retrievalMeta.sceneOwnerCandidates
|
? retrievalMeta.sceneOwnerCandidates
|
||||||
: [];
|
: [];
|
||||||
@@ -1787,12 +1903,24 @@ function _getLatestRecallOwnerInfo(graph) {
|
|||||||
? [fallbackOwnerKey]
|
? [fallbackOwnerKey]
|
||||||
: [];
|
: [];
|
||||||
const ownerLabels = normalizedOwnerKeys.map((ownerKey) => {
|
const ownerLabels = normalizedOwnerKeys.map((ownerKey) => {
|
||||||
|
const ownerEntry = owners.find((entry) => entry.ownerKey === ownerKey);
|
||||||
|
if (ownerEntry) {
|
||||||
|
return _getOwnerDisplayInfo(ownerEntry, collisionIndex).title;
|
||||||
|
}
|
||||||
const candidateMatch = ownerCandidates.find(
|
const candidateMatch = ownerCandidates.find(
|
||||||
(candidate) => String(candidate?.ownerKey || "").trim() === ownerKey,
|
(candidate) => String(candidate?.ownerKey || "").trim() === ownerKey,
|
||||||
);
|
);
|
||||||
if (candidateMatch?.ownerName) return String(candidateMatch.ownerName);
|
if (candidateMatch?.ownerName) {
|
||||||
const ownerEntry = owners.find((entry) => entry.ownerKey === ownerKey);
|
return _getOwnerDisplayInfo(
|
||||||
return String(ownerEntry?.ownerName || ownerKey || "—");
|
{
|
||||||
|
ownerKey,
|
||||||
|
ownerName: candidateMatch.ownerName,
|
||||||
|
ownerType: _inferOwnerTypeFromKey(ownerKey),
|
||||||
|
},
|
||||||
|
collisionIndex,
|
||||||
|
).title;
|
||||||
|
}
|
||||||
|
return _getOwnerDisplayInfo({ ownerKey }, collisionIndex).title;
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -1851,6 +1979,7 @@ function _renderCognitionOwnerList(
|
|||||||
const listEl = document.getElementById("bme-cognition-owner-list");
|
const listEl = document.getElementById("bme-cognition-owner-list");
|
||||||
if (!listEl) return;
|
if (!listEl) return;
|
||||||
listEl.innerHTML = "";
|
listEl.innerHTML = "";
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(owners);
|
||||||
|
|
||||||
if (!owners.length) {
|
if (!owners.length) {
|
||||||
const li = document.createElement("li");
|
const li = document.createElement("li");
|
||||||
@@ -1862,6 +1991,7 @@ function _renderCognitionOwnerList(
|
|||||||
|
|
||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
for (const owner of owners) {
|
for (const owner of owners) {
|
||||||
|
const displayInfo = _getOwnerDisplayInfo(owner, collisionIndex);
|
||||||
const li = document.createElement("li");
|
const li = document.createElement("li");
|
||||||
li.className = "bme-cognition-owner-row";
|
li.className = "bme-cognition-owner-row";
|
||||||
|
|
||||||
@@ -1875,14 +2005,16 @@ function _renderCognitionOwnerList(
|
|||||||
button.classList.add("is-active-anchor");
|
button.classList.add("is-active-anchor");
|
||||||
}
|
}
|
||||||
button.dataset.ownerKey = String(owner.ownerKey || "");
|
button.dataset.ownerKey = String(owner.ownerKey || "");
|
||||||
|
button.title = displayInfo.tooltip;
|
||||||
|
|
||||||
const title = document.createElement("div");
|
const title = document.createElement("div");
|
||||||
title.className = "bme-cognition-owner-btn__title";
|
title.className = "bme-cognition-owner-btn__title";
|
||||||
title.textContent = String(owner.ownerName || owner.ownerKey || "未命名角色");
|
title.textContent = displayInfo.title;
|
||||||
|
|
||||||
const meta = document.createElement("div");
|
const meta = document.createElement("div");
|
||||||
meta.className = "bme-cognition-owner-btn__meta";
|
meta.className = "bme-cognition-owner-btn__meta";
|
||||||
meta.textContent = [
|
meta.textContent = [
|
||||||
|
displayInfo.subtitle,
|
||||||
`已知 ${Number(owner.knownCount || 0)}`,
|
`已知 ${Number(owner.knownCount || 0)}`,
|
||||||
`误解 ${Number(owner.mistakenCount || 0)}`,
|
`误解 ${Number(owner.mistakenCount || 0)}`,
|
||||||
`隐藏 ${Number(owner.manualHiddenCount || 0)}`,
|
`隐藏 ${Number(owner.manualHiddenCount || 0)}`,
|
||||||
@@ -1962,16 +2094,22 @@ function _renderCognitionDetail(
|
|||||||
: "未选中节点";
|
: "未选中节点";
|
||||||
const writeBlocked = _isGraphWriteBlocked(loadInfo);
|
const writeBlocked = _isGraphWriteBlocked(loadInfo);
|
||||||
const aliases = Array.isArray(ownerState.aliases) ? ownerState.aliases : [];
|
const aliases = Array.isArray(ownerState.aliases) ? ownerState.aliases : [];
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(_getCognitionOwnerCollection(graph));
|
||||||
|
const displayInfo = _getOwnerDisplayInfo(selectedOwner, collisionIndex);
|
||||||
|
|
||||||
detailEl.innerHTML = `
|
detailEl.innerHTML = `
|
||||||
<div class="bme-cognition-detail-card">
|
<div class="bme-cognition-detail-card">
|
||||||
<div class="bme-config-card-head">
|
<div class="bme-config-card-head">
|
||||||
<div>
|
<div>
|
||||||
<div class="bme-config-card-title">${_escHtml(
|
<div class="bme-config-card-title">${_escHtml(
|
||||||
String(selectedOwner.ownerName || selectedOwner.ownerKey || "未命名角色"),
|
displayInfo.title,
|
||||||
)}</div>
|
)}</div>
|
||||||
<div class="bme-config-card-subtitle">
|
<div class="bme-config-card-subtitle">
|
||||||
${_escHtml(String(selectedOwner.ownerKey || ""))}
|
${_escHtml(
|
||||||
|
[displayInfo.subtitle, String(selectedOwner.ownerKey || "")]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" · "),
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${
|
${
|
||||||
@@ -2145,6 +2283,7 @@ function _refreshCognitionDashboard(
|
|||||||
selectedOwner,
|
selectedOwner,
|
||||||
activeOwner,
|
activeOwner,
|
||||||
} = _getCurrentCognitionOwnerSummary(graph);
|
} = _getCurrentCognitionOwnerSummary(graph);
|
||||||
|
const collisionIndex = _buildOwnerCollisionIndex(owners);
|
||||||
const activeRegion = String(
|
const activeRegion = String(
|
||||||
historyState.activeRegion ||
|
historyState.activeRegion ||
|
||||||
historyState.lastExtractedRegion ||
|
historyState.lastExtractedRegion ||
|
||||||
@@ -2164,7 +2303,9 @@ function _refreshCognitionDashboard(
|
|||||||
"bme-cognition-active-owner",
|
"bme-cognition-active-owner",
|
||||||
activeOwnerLabels.length > 0
|
activeOwnerLabels.length > 0
|
||||||
? activeOwnerLabels.join(" / ")
|
? activeOwnerLabels.join(" / ")
|
||||||
: activeOwner?.ownerName || activeOwnerKey || "—",
|
: activeOwner
|
||||||
|
? _getOwnerDisplayInfo(activeOwner, collisionIndex).title
|
||||||
|
: activeOwnerKey || "—",
|
||||||
);
|
);
|
||||||
_setText("bme-cognition-active-region", activeRegionLabel || "—");
|
_setText("bme-cognition-active-region", activeRegionLabel || "—");
|
||||||
_setText(
|
_setText(
|
||||||
|
|||||||
Reference in New Issue
Block a user