From 793be29331c0a777faabb35609a5af93ab0229ff Mon Sep 17 00:00:00 2001 From: kicer Date: Fri, 13 Nov 2026 14:52:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E8=A1=8C=E6=94=B9=E6=88=90=E6=8A=98=E5=8F=A0?= =?UTF-8?q?=E5=8D=A1=E7=89=87=EF=BC=8C=E6=91=98=E8=A6=81=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=90=8C=E4=B8=80=E5=A5=97=E8=A7=86=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 画像快照、渠道说明、开场记忆这些「只发给模型看」的注入内容,之前要么完全 不可见(画像快照存在 sessions 表里,不在 messages),要么假装成用户发言—— channel_note / memory_note 会被 userMsgHtml 渲染成一条用户气泡,打开微信 会话时那两段 # [CTX] 大文本就挂在你名下。 现在统一成可折叠卡片:画像快照是每轮请求拼在最前的上下文,历史又是懒加载 的,所以等翻到最早(has_more=false)再补到流顶,不会插在首屏那几条前面被 后续分页顶到中间;渠道/记忆按 type 直接渲染成卡片。内容都走 markdown,和 摘要卡片一致。 压缩摘要卡片与它们共用一套:淡蓝底、蓝边蓝字、三角箭头、虚线分隔,折叠与 展开同底色,去掉渐变/阴影/数据库图标,默认全部收起(流式收尾也不再自动 展开),标题旁的「后续对话以此为起点」一并去掉。摘要卡片补 width:100%, 否则在 align-items:flex-start 的 .msg 里折叠后只剩标题那点宽。 顺带:errAck(工具参数非法被整轮移除)在气泡上方标一行,原来只显示模型 当时的内容,看不出这一轮其实没进上下文。 --- app/server/public/css/style.css | 30 ++++++++++++++++++++++ app/server/public/index.html | 16 +++++------- app/server/public/js/chat.js | 45 +++++++++++++++++++++++---------- app/server/public/js/stream.js | 3 +-- 4 files changed, 70 insertions(+), 24 deletions(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index b843957..31da965 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -225,6 +225,36 @@ main { flex: 1; min-height: 0; display: flex; flex-direction: column; } /* 流式阶段给一点视觉提示:边色稍亮,收尾(assistant_message)后去除 */ .msg-think.streaming { border-color: #d8e0f5; } +/* 上下文卡片:只发给模型看的注入行(画像快照 / 渠道说明 / 开场记忆)折叠展示, + 视觉与压缩摘要卡片一致:淡蓝底、蓝边蓝字、三角箭头、虚线分隔,不用渐变/阴影 */ +.msg-ctx { + margin: 0 0 12px; border: 1px solid #dbe4fb; border-radius: 12px; overflow: hidden; + background: #f7f9ff; +} +.msg-ctx > summary { + list-style: none; cursor: pointer; user-select: none; + display: flex; align-items: center; gap: 7px; + padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--active); +} +.msg-ctx > summary::-webkit-details-marker { display: none; } +.msg-ctx > summary::before { + content: ''; flex: none; width: 0; height: 0; margin-left: 1px; + border-left: 5px solid var(--active); border-top: 4px solid transparent; border-bottom: 4px solid transparent; + transition: transform .15s ease; +} +.msg-ctx[open] > summary::before { transform: rotate(90deg); } +.msg-ctx-body { + /* 比标题区(#f7f9ff)再淡一档,分隔开又不跳色 */ + border-top: 1px dashed #dbe4fb; background: #fbfcff; + padding: 10px 13px 12px; +} +.msg-ctx-body .bubble-ai { margin: 0; background: transparent; font-size: 14px; line-height: 1.7; } +/* errAck:这一轮工具参数非法、已从上下文移除,气泡上方标一行 */ +.msg-note { + margin: 0 0 6px; padding: 3px 9px; border-radius: 6px; + background: #fff8c5; color: #9a6700; font-size: 12px; +} + /* 用户气泡:右侧,浅色背景,圆角矩形 */ .bubble-user { background: var(--active-soft); color: var(--ink); diff --git a/app/server/public/index.html b/app/server/public/index.html index c31c4de..d1c5a4f 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -17,13 +17,12 @@