From c764a000c0b70ef330653c3015255cdaf8404a03 Mon Sep 17 00:00:00 2001 From: Youzini-afk <13153778771cx@gmail.com> Date: Wed, 15 Apr 2026 22:04:54 +0800 Subject: [PATCH] fix: keep luker host profile before chat selection --- host/runtime-host-adapter.js | 7 +------ tests/luker-host-adapter.mjs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/host/runtime-host-adapter.js b/host/runtime-host-adapter.js index c6a6fb5..31ce187 100644 --- a/host/runtime-host-adapter.js +++ b/host/runtime-host-adapter.js @@ -182,17 +182,12 @@ function isAndroidWebViewLike() { export function isLukerHostContext(context = getHostRuntimeContext()) { const activeContext = context && typeof context === "object" ? context : getHostRuntimeContext(); - const hasImplicitCurrentChat = - Boolean(resolveChatFileName(activeContext)) || - normalizeString(activeContext.groupId) !== "" || - normalizeString(activeContext.characterId) !== ""; return ( !!globalThis.Luker && typeof globalThis.Luker?.getContext === "function" && typeof activeContext.getChatState === "function" && typeof activeContext.updateChatState === "function" && - typeof activeContext.getChatStateBatch === "function" && - hasImplicitCurrentChat + typeof activeContext.getChatStateBatch === "function" ); } diff --git a/tests/luker-host-adapter.mjs b/tests/luker-host-adapter.mjs index ae6f3ca..6b90d90 100644 --- a/tests/luker-host-adapter.mjs +++ b/tests/luker-host-adapter.mjs @@ -46,6 +46,26 @@ try { assert.equal(resolveChatStateTargetChatId(target), "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 = { chatId: "chat-char-1", characterId: "char-1",