mirror of
https://github.com/bal-spec/sillytavern-character-memory.git
synced 2026-04-28 03:39:44 +00:00
fix: Data Bank browser always empty in group chats
getCharacterName() returns null in group chats because ST leaves context.characterId undefined when multiple characters are active. The guard `!charName || !target` was short-circuiting on that null and showing "No character selected" even though getMemoryTargets() had valid members. Switch the gate to `!targets.length` — the only thing that actually matters — in both the initial HTML build and rebuildDataBankList. Also use target.name as fallback for the 1:1 subtitle in case charName is ever unexpectedly null. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9f154199a4
commit
cdb92a332e
1 changed files with 4 additions and 4 deletions
8
index.js
8
index.js
|
|
@ -5526,7 +5526,7 @@ async function showTroubleshooter(initialSection = 'health') {
|
|||
|
||||
let dataBankHtml = '';
|
||||
let dataBankSubtitle = 'No character selected';
|
||||
if (!charName || !target) {
|
||||
if (!targets.length) {
|
||||
dataBankHtml = '<div class="charMemory_diagEmpty">No character selected.</div>';
|
||||
} else if (targets.length > 1) {
|
||||
// Group chat: labeled section per member
|
||||
|
|
@ -5539,8 +5539,9 @@ async function showTroubleshooter(initialSection = 'health') {
|
|||
</div>`;
|
||||
}
|
||||
} else {
|
||||
const displayName = charName || target.name;
|
||||
const avatarImg = `<img class="charMemory_groupAvatar" src="/thumbnail?type=avatar&file=${encodeURIComponent(target.avatar)}" alt="" onerror="this.style.display='none'" style="vertical-align:middle;" />`;
|
||||
dataBankSubtitle = `${avatarImg} ${escapeHtml(charName)}'s Data Bank files`;
|
||||
dataBankSubtitle = `${avatarImg} ${escapeHtml(displayName)}'s Data Bank files`;
|
||||
dataBankHtml = buildMemberFileList(target);
|
||||
}
|
||||
|
||||
|
|
@ -5992,9 +5993,8 @@ async function showTroubleshooter(initialSection = 'health') {
|
|||
const rebuildDataBankList = () => {
|
||||
if (!$modal.find('.charMemory_modalSection[data-section="databank"]').hasClass('active')) return;
|
||||
const currentTargets = getMemoryTargets();
|
||||
const currentCharName = getCharacterName();
|
||||
let newHtml = '';
|
||||
if (!currentCharName || !currentTargets.length) {
|
||||
if (!currentTargets.length) {
|
||||
newHtml = '<div class="charMemory_diagEmpty">No character selected.</div>';
|
||||
} else if (currentTargets.length > 1) {
|
||||
for (const t of currentTargets) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue