Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Groupmodules/groupchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ async function getVcpGlobalSettings() {
vcpApiKey: settings.vcpApiKey,
userName: settings.userName || '用户',
topicSummaryModel: settings.topicSummaryModel,
enableAgentBubbleTheme: settings.enableAgentBubbleTheme === true,
// 添加净化器相关配置
enableContextSanitizer: settings.enableContextSanitizer === true,
contextSanitizerDepth: settings.contextSanitizerDepth,
Expand All @@ -229,6 +230,7 @@ async function getVcpGlobalSettings() {
vcpApiKey: null,
userName: '用户',
topicSummaryModel: null,
enableAgentBubbleTheme: false,
// 添加净化器默认值
enableContextSanitizer: false,
contextSanitizerDepth: 2,
Expand Down Expand Up @@ -785,6 +787,22 @@ ${canvasData.errors || 'No errors'}

console.log(`[GroupChat Context Sanitizer] Messages processed successfully`);
}
// --- Agent Bubble Theme Injection ---
if (globalVcpSettings.enableAgentBubbleTheme) {
let systemMsgIndex = messagesForAI.findIndex(m => m.role === 'system');
if (systemMsgIndex === -1) {
messagesForAI.unshift({ role: 'system', content: '' });
systemMsgIndex = 0;
}

const injection = '为你在群聊中构建独特的个性气泡,输出规范要求:{{VarDivRender}}';
if (!messagesForAI[systemMsgIndex].content.includes(injection)) {
messagesForAI[systemMsgIndex].content += `\n\n${injection}`;
messagesForAI[systemMsgIndex].content = messagesForAI[systemMsgIndex].content.trim();
}
}
// --- End of Injection ---

const modelResolution = resolveEffectiveModel(groupConfig, agentConfig);
if (!globalVcpSettings.vcpUrl) {
const errorMsg = `Agent ${agentName} (${agentId}) 无法响应:VCP URL 未配置。`;
Expand Down Expand Up @@ -1341,6 +1359,22 @@ ${canvasData.errors || 'No errors'}

console.log(`[GroupChat Context Sanitizer] Messages processed successfully`);
}
// --- Agent Bubble Theme Injection ---
if (globalVcpSettings.enableAgentBubbleTheme) {
let systemMsgIndex = messagesForAI.findIndex(m => m.role === 'system');
if (systemMsgIndex === -1) {
messagesForAI.unshift({ role: 'system', content: '' });
systemMsgIndex = 0;
}

const injection = '为你在群聊中构建独特的个性气泡,输出规范要求:{{VarDivRender}}';
if (!messagesForAI[systemMsgIndex].content.includes(injection)) {
messagesForAI[systemMsgIndex].content += `\n\n${injection}`;
messagesForAI[systemMsgIndex].content = messagesForAI[systemMsgIndex].content.trim();
}
}
// --- End of Injection ---

const modelResolution = resolveEffectiveModel(groupConfig, agentConfig);
if (!globalVcpSettings.vcpUrl) {
const errorMsg = `Agent ${agentName} (${invitedAgentId}) 无法响应(邀请):VCP URL 未配置。`;
Expand Down
9 changes: 9 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,15 @@ <h3 class="settings-section-title">界面与外观</h3>
<div class="settings-subsection-title">聊天字体与气泡</div>
<p class="settings-subsection-description">调整聊天正文、代码、场景字体和 Agent 气泡外观。</p>
</div>
<div class="form-group-inline"
style="justify-content: space-between; align-items: center; margin-bottom: 15px;">
<label for="enableAgentBubbleTheme">开启Agent自定义气泡主题</label>
<label class="switch">
<input type="checkbox" id="enableAgentBubbleTheme" name="enableAgentBubbleTheme"
checked>
<span class="slider round"></span>
</label>
</div>
<div class="settings-form-group" id="chatFontSettingsGroup" style="margin-top: 18px;">
<label for="chatFontPreset">聊天字体</label>
<select id="chatFontPreset" name="chatFontPreset">
Expand Down
1 change: 1 addition & 0 deletions modules/global-settings-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ async function saveGlobalSettings(deps, settingsForm) {
networkNotesPaths: networkNotesPaths,
sidebarWidth: refs.globalSettings.get().sidebarWidth,
notificationsSidebarWidth: refs.globalSettings.get().notificationsSidebarWidth,
enableAgentBubbleTheme: document.getElementById('enableAgentBubbleTheme')?.checked === true,
enableSmoothStreaming: document.getElementById('enableSmoothStreaming').checked,
showHomeVisualBrand: document.getElementById('showHomeVisualBrand')?.checked !== false,
showHomeVisualTagline: document.getElementById('showHomeVisualTagline')?.checked !== false,
Expand Down
21 changes: 21 additions & 0 deletions modules/ipc/chatHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,27 @@ function initialize(mainWindow, context) {
}
}

// --- Agent Bubble Theme Injection ---
try {
// Settings already loaded, just check the flag
if (settings.enableAgentBubbleTheme) {
let systemMsgIndex = messages.findIndex(m => m.role === 'system');
if (systemMsgIndex === -1) {
messages.unshift({ role: 'system', content: '' });
systemMsgIndex = 0;
}

const injection = '输出规范要求:{{VarDivRender}}';
if (!messages[systemMsgIndex].content.includes(injection)) {
messages[systemMsgIndex].content += `\n\n${injection}`;
messages[systemMsgIndex].content = messages[systemMsgIndex].content.trim();
}
}
} catch (e) {
console.error('[Agent Bubble Theme] Failed to inject bubble theme info:', e);
}
// --- End of Injection ---

// --- VCP Thought Chain Stripping ---
try {
// 默认不注入元思考链,除非明确开启
Expand Down
2 changes: 1 addition & 1 deletion modules/messageRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3299,7 +3299,7 @@ async function renderPostProcessedHtml(contentDiv, rawHtml, options = {}) {
if (!isStillValid()) return;
// stable block 会在终态被规范整树替换;提前执行脚本会把 rAF、timer 和事件
// 绑定到即将销毁的局部 DOM。CSS 动画不依赖此处理器,可继续即时播放。
if (processScripts) {
if (processScripts && settings.enableAgentBubbleTheme === true) {
processAnimationsInContent(contentDiv, visibilityOptimizer);
if (!isStillValid()) {
cleanupAnimationsInContent(contentDiv);
Expand Down
1 change: 1 addition & 0 deletions modules/renderer/mainChatSettingsPresentationOwner.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ export function createMainChatSettingsPresentationOwner({
}
}

safeCheck('enableAgentBubbleTheme', globalSettings.enableAgentBubbleTheme !== false);
safeCheck('enableSmoothStreaming', globalSettings.enableSmoothStreaming === true);
safeCheck('showHomeVisualBrand', globalSettings.showHomeVisualBrand !== false);
safeCheck('showHomeVisualTagline', globalSettings.showHomeVisualTagline !== false);
Expand Down
2 changes: 1 addition & 1 deletion modules/renderer/streamManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ async function projectStreamTerminalInternal(messageId, finishReason, context, f
}, 0);

// Step 3: Process animations, scripts, and 3D scenes
if (refs.processAnimationsInContent) {
if (refs.processAnimationsInContent && refs.globalSettingsRef?.get?.().enableAgentBubbleTheme === true) {
refs.processAnimationsInContent(contentDiv);
}
}
Expand Down
1 change: 1 addition & 0 deletions modules/utils/appSettingsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class SettingsManager extends EventEmitter {
filterRules: [],
toolAutoApprovalEnabled: false,
toolAutoApprovalRules: [],
enableAgentBubbleTheme: false,
enableSmoothStreaming: false,
uiMode: 'next',
showHomeVisualBrand: true,
Expand Down