Skip to content

Commit 033b849

Browse files
committed
fix: 修复 URL 解析 code 后授权状态改变时 hello 消息不更新的问题
1 parent 328e1d8 commit 033b849

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

app/components/chat.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,19 +3463,27 @@ function ChatComponent() {
34633463
}
34643464

34653465
const context: RenderMessage[] = useMemo(() => {
3466-
return session.mask.hideContext ? [] : session.mask.context.slice();
3467-
}, [session.mask.context, session.mask.hideContext]);
3468-
3469-
if (
3470-
context.length === 0 &&
3471-
session.messages.at(0)?.content !== BOT_HELLO.content
3472-
) {
3473-
const copiedHello = Object.assign({}, BOT_HELLO);
3474-
if (!accessStore.isAuthorized()) {
3475-
copiedHello.content = Locale.Error.Unauthorized;
3466+
const ctx = session.mask.hideContext ? [] : session.mask.context.slice();
3467+
3468+
if (
3469+
ctx.length === 0 &&
3470+
session.messages.at(0)?.content !== BOT_HELLO.content
3471+
) {
3472+
const copiedHello = Object.assign({}, BOT_HELLO);
3473+
if (!accessStore.isAuthorized()) {
3474+
copiedHello.content = Locale.Error.Unauthorized;
3475+
}
3476+
ctx.push(copiedHello);
34763477
}
3477-
context.push(copiedHello);
3478-
}
3478+
3479+
return ctx;
3480+
}, [
3481+
session.mask.context,
3482+
session.mask.hideContext,
3483+
session.messages,
3484+
accessStore.customHello,
3485+
accessStore.accessCode,
3486+
]);
34793487

34803488
function InputPreviewBubble(props: {
34813489
text: string;
@@ -3875,7 +3883,6 @@ function ChatComponent() {
38753883

38763884
// 在目标节点中查找实际的文本位置
38773885
const targetNodeText = targetNode.textContent || "";
3878-
const cleanTargetText = cleanText(targetNodeText);
38793886

38803887
// 计算在原始文本中的偏移量
38813888
let actualOffset = 0;
@@ -5160,7 +5167,7 @@ function ChatComponent() {
51605167
atBottomStateChange={setHitBottom}
51615168
atBottomThreshold={64}
51625169
increaseViewportBy={{ top: 400, bottom: 800 }}
5163-
computeItemKey={(index, m) => m.id}
5170+
computeItemKey={(_index, m) => m.id}
51645171
rangeChanged={(range) => setVisibleRange(range)}
51655172
itemContent={(index, message) => {
51665173
const i = index;

0 commit comments

Comments
 (0)