mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 14:20:35 +08:00
fix: keep luker host profile before chat selection
This commit is contained in:
@@ -182,17 +182,12 @@ function isAndroidWebViewLike() {
|
|||||||
export function isLukerHostContext(context = getHostRuntimeContext()) {
|
export function isLukerHostContext(context = getHostRuntimeContext()) {
|
||||||
const activeContext =
|
const activeContext =
|
||||||
context && typeof context === "object" ? context : getHostRuntimeContext();
|
context && typeof context === "object" ? context : getHostRuntimeContext();
|
||||||
const hasImplicitCurrentChat =
|
|
||||||
Boolean(resolveChatFileName(activeContext)) ||
|
|
||||||
normalizeString(activeContext.groupId) !== "" ||
|
|
||||||
normalizeString(activeContext.characterId) !== "";
|
|
||||||
return (
|
return (
|
||||||
!!globalThis.Luker &&
|
!!globalThis.Luker &&
|
||||||
typeof globalThis.Luker?.getContext === "function" &&
|
typeof globalThis.Luker?.getContext === "function" &&
|
||||||
typeof activeContext.getChatState === "function" &&
|
typeof activeContext.getChatState === "function" &&
|
||||||
typeof activeContext.updateChatState === "function" &&
|
typeof activeContext.updateChatState === "function" &&
|
||||||
typeof activeContext.getChatStateBatch === "function" &&
|
typeof activeContext.getChatStateBatch === "function"
|
||||||
hasImplicitCurrentChat
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,26 @@ try {
|
|||||||
assert.equal(resolveChatStateTargetChatId(target), "group-1");
|
assert.equal(resolveChatStateTargetChatId(target), "group-1");
|
||||||
assert.equal(serializeBmeChatStateTarget(target), "group:group-1");
|
assert.equal(serializeBmeChatStateTarget(target), "group:group-1");
|
||||||
|
|
||||||
|
const noChatSelectedContext = {
|
||||||
|
chatId: "",
|
||||||
|
characterId: "",
|
||||||
|
groupId: null,
|
||||||
|
getChatState() {},
|
||||||
|
updateChatState() {},
|
||||||
|
getChatStateBatch() {},
|
||||||
|
};
|
||||||
|
globalThis.Luker = {
|
||||||
|
getContext() {
|
||||||
|
return noChatSelectedContext;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
assert.equal(
|
||||||
|
resolveBmeHostProfile(noChatSelectedContext),
|
||||||
|
"luker",
|
||||||
|
"未进入聊天时,宿主档案仍应反映 Luker 环境,而不是退回 generic-st",
|
||||||
|
);
|
||||||
|
assert.equal(resolveCurrentBmeChatStateTarget(noChatSelectedContext), null);
|
||||||
|
|
||||||
const characterContext = {
|
const characterContext = {
|
||||||
chatId: "chat-char-1",
|
chatId: "chat-char-1",
|
||||||
characterId: "char-1",
|
characterId: "char-1",
|
||||||
|
|||||||
Reference in New Issue
Block a user