fix(webui): capture all-channel chat history and correct input source

- handleChat now injects with source=webui so the LLM no longer sees
  cli as the input channel
- subscribe to EventRawInput/EventAgentOutput to persist every
  conversation turn from all channels (cli/qq/webui), replacing the
  manual webui-only addChatMsg to avoid duplicates
- ChatMsg gains a source field; GUI shows a channel badge for
  non-webui messages
This commit is contained in:
root
2026-08-01 14:06:18 +08:00
parent dbbd73b930
commit 94312d714a
3 changed files with 41 additions and 3 deletions

View File

@ -371,6 +371,9 @@ function renderChat() {
});
}
var body = rc + tcs + '<div class="text">' + c + '</div>';
if (m.source && m.source !== 'webui') {
body = '<div class="msg-source">' + escHtml(__('通道','Channel')) + ': ' + escHtml(m.source) + '</div>' + body;
}
if (role === 'system') {
html += '<div class="msg msg-system"><div class="msg-bubble">' + body + '</div></div>';
} else {

View File

@ -176,6 +176,7 @@ code { font-family:monospace; font-size:12px; color:var(--pre-color) }
.msg-system .msg-avatar { background:var(--msg-system-bg); color:var(--msg-system-color) }
.msg-content { min-width:0 }
.msg-bubble { padding:8px 12px; border-radius:10px; font-size:13px; line-height:1.5; word-break:break-word; position:relative }
.msg-source { font-size:11px; opacity:.55; margin-bottom:4px; color:inherit }
.msg-user .msg-bubble { background:var(--msg-user-bg); color:var(--msg-user-color); border-bottom-right-radius:4px }
.msg-assistant .msg-bubble { background:var(--msg-assistant-bg); color:var(--msg-assistant-color); border-bottom-left-radius:4px }
.msg-system .msg-bubble { background:var(--msg-system-bg); color:var(--msg-system-color); text-align:center; font-size:12px }