style(chat): integrate the context toolbar into the composer

This commit is contained in:
Sycun committed 2026-11-20 15:44:50 +08:00
1 parent df585f207a
commit 7af146701e
9 files changed
+137 -131

No files matched your search

+49 -60
View File
@@ -45320,9 +45320,7 @@ html[data-theme="dark"] .project-conversation-row:hover .project-conversation-it
}
}
/* ============================================================================
Layered chat composer: Codex-style hierarchy with CyberStrikeAI controls
============================================================================ */
/* Chat composer and context toolbar */
.chat-input-container {
position: relative;
@@ -45348,17 +45346,14 @@ html[data-theme="dark"] .project-conversation-row:hover .project-conversation-it
.chat-composer-context {
position: relative;
z-index: 1;
z-index: 3;
display: flex;
align-items: center;
min-height: 52px;
margin: 0 30px -9px;
padding: 0 15px 9px;
border: 1px solid rgba(15, 23, 42, 0.08);
border-bottom: 0;
border-radius: 22px 22px 0 0;
background: #f5f6f7;
box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.035);
min-height: 42px;
padding: 5px 10px;
border-bottom: 1px solid var(--border-color);
border-radius: 21px 21px 0 0;
background: color-mix(in srgb, var(--accent-color) 6%, var(--bg-primary));
box-sizing: border-box;
}
@@ -45374,37 +45369,35 @@ html[data-theme="dark"] .project-conversation-row:hover .project-conversation-it
}
.chat-composer-context .chat-input-leading > *:not(:last-child) {
margin-right: 4px;
padding-right: 5px;
margin-inline-end: 5px;
padding-inline-end: 5px;
}
.chat-composer-context .chat-input-leading > *:not(:last-child)::after {
content: '';
position: absolute;
top: 11px;
right: 0;
bottom: 11px;
inset-block: 7px;
inset-inline-end: 0;
width: 1px;
background: rgba(15, 23, 42, 0.09);
background: var(--border-color);
}
.chat-composer-context .role-selector-btn {
height: 40px;
padding: 0 12px;
gap: 8px;
height: 30px;
max-width: 100%;
padding: 0 8px;
gap: 6px;
border: 0;
border-radius: 12px;
border-radius: 8px;
background: transparent;
box-shadow: none;
color: #20242a;
font-size: 14px;
font-weight: 560;
color: var(--text-primary);
}
.chat-composer-context .role-selector-btn:hover,
.chat-composer-context .role-selector-btn.active {
border: 0;
background: rgba(15, 23, 42, 0.055);
background: color-mix(in srgb, var(--accent-color) 10%, transparent);
box-shadow: none;
}
@@ -45414,20 +45407,24 @@ html[data-theme="dark"] .project-conversation-row:hover .project-conversation-it
}
.chat-composer-context .role-selector-icon {
width: 20px;
min-width: 20px;
height: 20px;
font-size: 18px;
width: 16px;
min-width: 16px;
height: 16px;
font-size: 16px;
color: var(--accent-color);
}
.chat-composer-context .role-selector-icon svg {
display: block;
width: 100%;
height: 100%;
}
.chat-composer-context .role-selector-text {
color: #20242a;
font-size: 14px;
font-weight: 560;
min-width: 0;
color: var(--text-primary);
font-size: 13px;
font-weight: 500;
}
.chat-composer-context .role-selector-arrow {
@@ -45910,12 +45907,6 @@ html[data-theme="dark"] .chat-input-container {
background: transparent !important;
}
html[data-theme="dark"] .chat-composer-context {
border-color: #263244;
background: #172033;
box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.15);
}
html[data-theme="dark"] .chat-composer-context .role-selector-btn {
border: 0 !important;
background: transparent !important;
@@ -45932,7 +45923,6 @@ html[data-theme="dark"] .chat-composer-context .role-selector-text {
color: var(--text-primary);
}
html[data-theme="dark"] .chat-composer-context .chat-input-leading > *:not(:last-child)::after,
html[data-theme="dark"] .chat-composer-meta-divider {
background: rgba(148, 163, 184, 0.18);
}
@@ -45997,16 +45987,11 @@ html[data-theme="dark"] .chat-system-model-retry:hover {
}
.chat-composer-context {
min-height: 54px;
margin-right: 16px;
margin-left: 16px;
padding-right: 8px;
padding-left: 8px;
padding-inline: 7px;
}
.chat-composer-context .role-selector-btn {
padding-right: 9px;
padding-left: 9px;
height: 34px;
}
.chat-composer-context .project-selector-wrapper .role-selector-text {
@@ -46022,8 +46007,8 @@ html[data-theme="dark"] .chat-system-model-retry:hover {
@media (max-width: 620px) {
.chat-composer-context .chat-input-leading > *:not(:last-child) {
margin-right: 1px;
padding-right: 2px;
margin-inline-end: 1px;
padding-inline-end: 2px;
}
.chat-composer-context .role-selector-btn {
@@ -46061,17 +46046,16 @@ html[data-theme="dark"] .chat-system-model-retry:hover {
}
@container chat-composer (max-width: 520px) {
.chat-composer-context {
margin-right: 8px;
margin-left: 8px;
padding-right: 7px;
padding-left: 7px;
}
.chat-composer-context .chat-input-leading {
width: 100%;
}
.chat-composer-context .chat-input-leading > *,
.chat-composer-context .agent-mode-inner {
flex-shrink: 1;
min-width: 0;
}
.chat-composer-context .role-selector-btn {
gap: 5px;
padding-right: 7px;
@@ -46079,7 +46063,9 @@ html[data-theme="dark"] .chat-system-model-retry:hover {
}
.chat-composer-context #agent-mode-text {
display: none;
max-width: 82px;
overflow: hidden;
text-overflow: ellipsis;
}
.chat-composer-footer {
@@ -46106,12 +46092,16 @@ html[data-theme="dark"] .chat-system-model-retry:hover {
@container chat-composer (max-width: 350px) {
.chat-composer-context .project-selector-wrapper .role-selector-text,
.chat-composer-context #role-selector-text {
max-width: 62px;
.chat-composer-context #agent-mode-text {
max-width: 78px;
overflow: hidden;
text-overflow: ellipsis;
}
.chat-composer-context #role-selector-text {
display: none;
}
.chat-hitl-shortcut {
max-width: 118px;
}
@@ -46844,7 +46834,6 @@ html[data-theme="dark"] .chat-composer-surface > .chat-session-settings-popover
display: none !important;
}
.chat-input-container.has-hitl-approval .chat-composer-context,
.chat-input-container.has-hitl-approval .chat-composer-surface {
display: none;
}
+2
View File
@@ -756,6 +756,8 @@
"generatedFromFact": "مُولّدة من حقيقة المشروع {{factKey}}"
},
"chat": {
"defaultWorkspace": "مساحة العمل الافتراضية",
"boundProject": "مشروع مرتبط",
"toolExecBlocked": "تم حظر الأداة {{name}}",
"newChat": "محادثة جديدة",
"newTask": "مهمّة جديدة",
+2
View File
@@ -756,6 +756,8 @@
"generatedFromFact": "Generated from project fact {{factKey}}"
},
"chat": {
"defaultWorkspace": "Default workspace",
"boundProject": "Linked project",
"toolExecBlocked": "Tool {{name}} blocked",
"newChat": "New chat",
"newTask": "New task",
+2
View File
@@ -768,6 +768,8 @@
"generatedFromFact": "Создано из факта проекта {{factKey}}"
},
"chat": {
"defaultWorkspace": "Рабочая область по умолчанию",
"boundProject": "Связанный проект",
"toolExecBlocked": "Инструмент {{name}} заблокирован",
"newChat": "Новый диалог",
"newTask": "Новая задача",
+2
View File
@@ -744,6 +744,8 @@
"generatedFromFact": "由项目事实 {{factKey}} 生成"
},
"chat": {
"defaultWorkspace": "默认工作区",
"boundProject": "已绑定项目",
"toolExecBlocked": "工具 {{name}} 已拦截",
"newChat": "新对话",
"newTask": "新任务",
+10
View File
@@ -6,6 +6,7 @@ const chat = fs.readFileSync('web/static/js/chat.js', 'utf8');
const monitor = fs.readFileSync('web/static/js/monitor.js', 'utf8');
const projects = fs.readFileSync('web/static/js/projects.js', 'utf8');
const styles = fs.readFileSync('web/static/css/style.css', 'utf8');
const template = fs.readFileSync('web/templates/index.html', 'utf8');
const zh = JSON.parse(fs.readFileSync('web/static/i18n/zh-CN.json', 'utf8'));
const en = JSON.parse(fs.readFileSync('web/static/i18n/en-US.json', 'utf8'));
@@ -43,6 +44,15 @@ test('欢迎语随项目和无项目状态更新', () => {
assert.equal(typeof en.chat.projectWelcomeMessage, 'string');
});
test('输入框顶部在同一张卡片内依次显示模式和项目', () => {
const composer = template.slice(template.indexOf('id="chat-input-container"'), template.indexOf('id="chat-input"'));
assert.match(composer, /class="chat-input-primary-row chat-composer-surface">\s*<div class="chat-composer-context"/);
assert.match(composer, /id="agent-mode-btn"[\s\S]*id="chat-project-btn"[\s\S]*class="chat-input-with-files"/);
assert.match(composer, /id="chat-project-text"[^>]*data-i18n="chat.defaultWorkspace"/);
assert.match(chat, /dataset\.projectName\?\.trim\(\)/);
assert.equal(zh.chat.defaultWorkspace, '默认工作区');
});
test('会话设置打开时提升整个输入区层级并遮住轮次导航', () => {
assert.match(chat, /function syncChatSessionSettingsLayerState\(\)/);
assert.match(chat, /inputBar\.classList\.toggle\('is-session-settings-open', open\)/);
+4 -9
View File
@@ -336,8 +336,7 @@ function syncChatReasoningBarHeight() {
const reasoning = document.getElementById('chat-reasoning-wrapper');
const inputBar = document.getElementById('chat-input-container');
if (!reasoning || !inputBar) return;
// The composer is now a two-layer surface and is intentionally taller than
// the sidebar trigger. Do not mirror its height into the settings card.
// The composer height positions the timeline controls independently of the settings card.
reasoning.style.removeProperty('--chat-input-bar-height');
const chatContainer = inputBar.closest('.chat-container');
const height = Math.ceil(inputBar.getBoundingClientRect().height || 0);
@@ -3412,15 +3411,12 @@ window.formatProjectNameForDisplay = formatProjectNameForDisplay;
window.applyProjectNameDisplay = applyProjectNameDisplay;
function getChatWelcomeProjectName() {
const projectElement = document.getElementById('chat-project-text');
const projectText = (projectElement?.dataset?.fullName || projectElement?.textContent || '').trim();
return projectText || (typeof window.t === 'function' ? window.t('projects.noProject') : '无项目');
return document.getElementById('chat-project-text')?.dataset.projectName?.trim() || '';
}
function getChatWelcomeText() {
const project = getChatWelcomeProjectName();
const noProject = typeof window.t === 'function' ? window.t('projects.noProject') : '无项目';
if (!project || project === noProject) {
if (!project) {
return typeof window.t === 'function'
? window.t('chat.noProjectWelcomeMessage')
: '当前无项目,请输入您的测试需求,系统将自动执行相应的安全测试。';
@@ -3433,10 +3429,9 @@ function getChatWelcomeText() {
function updateChatWelcomeTitle(title) {
if (!title) return;
const project = getChatWelcomeProjectName();
const noProject = typeof window.t === 'function' ? window.t('projects.noProject') : '无项目';
const subtitle = title.parentElement?.querySelector('.chat-welcome-empty-state-subtitle');
if (project === noProject) {
if (!project) {
title.textContent = typeof window.t === 'function'
? window.t('chat.noProjectWelcomeTitle')
: '要测试什么?';
+5 -1
View File
@@ -3918,9 +3918,13 @@ function updateChatProjectButtonLabel() {
const textEl = document.getElementById('chat-project-text');
if (!textEl) return;
const id = resolveChatProjectSelection();
const name = id ? projectNameById[id] || '' : '';
textEl.dataset.projectName = name;
if (id) delete textEl.dataset.i18n;
else textEl.dataset.i18n = 'chat.defaultWorkspace';
window.applyProjectNameDisplay(
textEl,
id && projectNameById[id] ? projectNameById[id] : tp('projects.noProject')
name || tp(id ? 'chat.boundProject' : 'chat.defaultWorkspace')
);
if (typeof window.refreshChatWelcomeEmptyState === 'function') {
window.refreshChatWelcomeEmptyState();
+61 -61
View File
@@ -39,7 +39,7 @@
}
})();
</script>
<link rel="stylesheet" href="/static/css/style.css?v=20261113-vulnerability-domain-browser">
<link rel="stylesheet" href="/static/css/style.css?v=20261120-composer-toolbar">
<link rel="stylesheet" href="/static/css/vulnerability-download.css?v=20261030-2">
<link rel="stylesheet" href="/static/css/tool-guard.css?v=20260907-7">
<link rel="stylesheet" href="/static/css/chat-plan-progress.css?v=20260813-4">
@@ -1150,64 +1150,10 @@
</button>
<div id="agent-plan-progress" class="agent-plan-progress" hidden aria-live="polite"></div>
<div id="chat-input-container" class="chat-input-container">
<section id="chat-hitl-approval-dock" class="chat-hitl-approval-dock" aria-label="待审批操作" aria-live="polite" hidden></section>
<div class="chat-input-primary-row chat-composer-surface">
<div class="chat-composer-context" aria-label="当前会话上下文">
<div class="chat-input-leading">
<div class="role-selector-wrapper project-selector-wrapper">
<button type="button" id="chat-project-btn" class="role-selector-btn" onclick="toggleChatProjectPanel()" aria-label="选择项目" aria-haspopup="listbox" aria-expanded="false" title="绑定项目后共享事实黑板(跨对话)" data-i18n="projects.chatSelectorButton" data-i18n-attr="aria-label,title">
<span class="role-selector-icon" aria-hidden="true">
<svg width="19" height="19" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.5 6.5A2.5 2.5 0 0 1 6 4h4l2 2h6A2.5 2.5 0 0 1 20.5 8.5v8A2.5 2.5 0 0 1 18 19H6a2.5 2.5 0 0 1-2.5-2.5v-10z" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"/>
</svg>
</span>
<span id="chat-project-text" class="role-selector-text" data-i18n="projects.noProject">无项目</span>
<svg class="role-selector-arrow" width="10" height="10" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<div id="chat-project-panel" class="role-selection-panel chat-project-panel" style="display: none;" role="listbox" aria-labelledby="chat-project-panel-title">
<div class="role-selection-panel-header">
<h3 id="chat-project-panel-title" class="role-selection-panel-title" data-i18n="projects.selectProject">选择项目</h3>
<button type="button" class="role-selection-panel-close" onclick="closeChatProjectPanel()" title="关闭" aria-label="关闭">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6l12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
<div class="chat-project-panel-body">
<div class="chat-project-panel-search">
<input type="search" id="chat-project-search" class="chat-project-panel-search-input" autocomplete="off" data-i18n="projects.searchProjectsPlaceholder" data-i18n-attr="placeholder" placeholder="搜索项目…">
</div>
<div id="chat-project-list" class="role-selection-list-main"></div>
<div class="chat-project-panel-footer">
<button type="button" class="role-selection-item-main chat-project-panel-create-btn" data-require-permission="project:write" onclick="showNewProjectModalFromChat()">
<span class="chat-project-panel-create-icon" aria-hidden="true">+</span>
<span class="chat-project-panel-create-label" data-i18n="projects.newProject">新建项目</span>
</button>
</div>
</div>
</div>
</div>
<div id="role-selector-wrapper" class="role-selector-wrapper">
<button type="button" id="role-selector-btn" class="role-selector-btn" onclick="toggleRoleSelectionPanel()" data-i18n="chat.selectRole" data-i18n-attr="title" title="选择角色">
<span id="role-selector-icon" class="role-selector-icon">🔵</span>
<span id="role-selector-text" class="role-selector-text" data-i18n="chat.defaultRole">默认</span>
<svg class="role-selector-arrow" width="10" height="10" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<!-- 角色选择下拉面板 -->
<div id="role-selection-panel" class="role-selection-panel" style="display: none;">
<div class="role-selection-panel-header">
<h3 class="role-selection-panel-title" data-i18n="chat.rolePanelTitle">选择角色</h3>
<button class="role-selection-panel-close" onclick="closeRoleSelectionPanel()" data-i18n="common.close" data-i18n-attr="title" title="关闭">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6l12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
<div id="role-selection-list" class="role-selection-list-main"></div>
</div>
</div>
<div id="agent-mode-wrapper" class="agent-mode-wrapper" style="display: none;">
<div class="agent-mode-inner">
<button type="button" id="agent-mode-btn" class="role-selector-btn agent-mode-btn" onclick="toggleAgentModePanel()" data-i18n="chat.agentModeSelectAria" data-i18n-attr="aria-label,title" data-i18n-skip-text="true" aria-label="选择对话执行模式" aria-haspopup="listbox" aria-expanded="false" title="选择对话执行模式">
@@ -1264,10 +1210,64 @@
</div>
<input type="hidden" id="agent-mode-select" value="single" autocomplete="off">
</div>
<div class="role-selector-wrapper project-selector-wrapper">
<button type="button" id="chat-project-btn" class="role-selector-btn" onclick="toggleChatProjectPanel()" aria-label="选择项目" aria-haspopup="listbox" aria-expanded="false" title="绑定项目后共享事实黑板(跨对话)" data-i18n="projects.chatSelectorButton" data-i18n-attr="aria-label,title">
<span class="role-selector-icon" aria-hidden="true">
<svg width="19" height="19" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.5 6.5A2.5 2.5 0 0 1 6 4h4l2 2h6A2.5 2.5 0 0 1 20.5 8.5v8A2.5 2.5 0 0 1 18 19H6a2.5 2.5 0 0 1-2.5-2.5v-10z" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"/>
</svg>
</span>
<span id="chat-project-text" class="role-selector-text" data-i18n="chat.defaultWorkspace">默认工作区</span>
<svg class="role-selector-arrow" width="10" height="10" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<div id="chat-project-panel" class="role-selection-panel chat-project-panel" style="display: none;" role="listbox" aria-labelledby="chat-project-panel-title">
<div class="role-selection-panel-header">
<h3 id="chat-project-panel-title" class="role-selection-panel-title" data-i18n="projects.selectProject">选择项目</h3>
<button type="button" class="role-selection-panel-close" onclick="closeChatProjectPanel()" title="关闭" aria-label="关闭">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6l12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
<div class="chat-project-panel-body">
<div class="chat-project-panel-search">
<input type="search" id="chat-project-search" class="chat-project-panel-search-input" autocomplete="off" data-i18n="projects.searchProjectsPlaceholder" data-i18n-attr="placeholder" placeholder="搜索项目…">
</div>
<div id="chat-project-list" class="role-selection-list-main"></div>
<div class="chat-project-panel-footer">
<button type="button" class="role-selection-item-main chat-project-panel-create-btn" data-require-permission="project:write" onclick="showNewProjectModalFromChat()">
<span class="chat-project-panel-create-icon" aria-hidden="true">+</span>
<span class="chat-project-panel-create-label" data-i18n="projects.newProject">新建项目</span>
</button>
</div>
</div>
</div>
</div>
<div id="role-selector-wrapper" class="role-selector-wrapper">
<button type="button" id="role-selector-btn" class="role-selector-btn" onclick="toggleRoleSelectionPanel()" data-i18n="chat.selectRole" data-i18n-attr="title,aria-label" title="选择角色" aria-label="选择角色">
<span id="role-selector-icon" class="role-selector-icon">🔵</span>
<span id="role-selector-text" class="role-selector-text" data-i18n="chat.defaultRole">默认</span>
<svg class="role-selector-arrow" width="10" height="10" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<!-- 角色选择下拉面板 -->
<div id="role-selection-panel" class="role-selection-panel" style="display: none;">
<div class="role-selection-panel-header">
<h3 class="role-selection-panel-title" data-i18n="chat.rolePanelTitle">选择角色</h3>
<button class="role-selection-panel-close" onclick="closeRoleSelectionPanel()" data-i18n="common.close" data-i18n-attr="title" title="关闭">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6l12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
<div id="role-selection-list" class="role-selection-list-main"></div>
</div>
</div>
</div>
</div>
<section id="chat-hitl-approval-dock" class="chat-hitl-approval-dock" aria-label="待审批操作" aria-live="polite" hidden></section>
<div class="chat-input-primary-row chat-composer-surface">
<div class="chat-input-with-files">
<div id="chat-file-list" class="chat-file-list" aria-label="已选文件列表"></div>
<div id="chat-attachment-progress" class="chat-upload-progress-row" hidden role="status" aria-live="polite">
@@ -7090,7 +7090,7 @@
<script src="/static/js/chat-scroll.js?v=20260815-1-20261113-chat-scroll"></script>
<script src="/static/js/monitor.js?v=20261011-token-usage-pagination-20261027-20261113-chat-scroll"></script>
<script src="/static/js/attack-chain-context.js?v=20261012-summary-2"></script>
<script src="/static/js/chat.js?v=20261118-pi-usage-summary"></script>
<script src="/static/js/chat.js?v=20261120-composer-toolbar"></script>
<script src="/static/js/chat-plan-progress.js?v=20260815-1"></script>
<script src="/static/js/hitl.js?v=20260819-1-pagination-20261027"></script>
<script src="/static/js/tool-guard.js?v=20261010-conflict"></script>
@@ -7106,7 +7106,7 @@
<script src="/static/js/knowledge.js"></script>
<script src="/static/js/skills.js?v=20261115-ui-drawers"></script>
<script src="/static/js/fact-graph.js"></script>
<script src="/static/js/projects.js?v=20260819-1-pagination-20261027"></script>
<script src="/static/js/projects.js?v=20260819-1-pagination-20261027-composer-workspace"></script>
<script src="/static/js/vulnerability.js?v=20261116-record-pagination"></script>
<script src="/static/js/vulnerability-workspace.js?v=20261115-timestamps"></script>
<script src="/static/js/vulnerability-download.js?v=20261030-2"></script>