diff --git a/src/panels/ICHelperPanel.ts b/src/panels/ICHelperPanel.ts index 31a751c..69e18f3 100644 --- a/src/panels/ICHelperPanel.ts +++ b/src/panels/ICHelperPanel.ts @@ -13,12 +13,12 @@ import { VCDViewerPanel } from "./VCDViewerPanel"; /** * 创建并显示 IC 助手面板 */ -export function showICHelperPanel(context: vscode.ExtensionContext) { +export function showICHelperPanel(context: vscode.ExtensionContext, viewColumn?: vscode.ViewColumn) { // 创建WebView面板 const panel = vscode.window.createWebviewPanel( "icCoder", // 面板ID "IC Coder", // 面板标题 - vscode.ViewColumn.Beside, // 显示在旁边 + viewColumn || vscode.ViewColumn.Beside, // 默认显示在旁边,但可以指定 { enableScripts: true, retainContextWhenHidden: true, @@ -74,6 +74,20 @@ export function showICHelperPanel(context: vscode.ExtensionContext) { getVCDFileInfo(panel, message.vcdFilePath, message.containerId); } break; + case "createNewConversation": + // 创建新会话 - 在当前编辑器组中打开新标签页 + showICHelperPanel(context, panel.viewColumn); + break; + case "loadConversationHistory": + // 加载会话历史(暂未实现) + panel.webview.postMessage({ + command: 'conversationHistory', + history: [] + }); + break; + case "selectConversation": + // 选择会话(暂未实现) + break; } }, undefined, diff --git a/src/views/conversationHistoryBar.ts b/src/views/conversationHistoryBar.ts new file mode 100644 index 0000000..c4d82b3 --- /dev/null +++ b/src/views/conversationHistoryBar.ts @@ -0,0 +1,308 @@ +/** + * 获取会话历史栏的 HTML 内容 + */ +export function getConversationHistoryBarContent(): string { + return ` +
+ `; +} + +/** + * 获取会话历史栏的 CSS 样式 + */ +export function getConversationHistoryBarStyles(): string { + return ` + .conversation-history-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 8px 16px; + background: var(--vscode-tab-activeBackground); + border-bottom: 1px solid var(--vscode-panel-border); + flex-shrink: 0; + min-height: 35px; + } + + .history-dropdown-container { + position: relative; + flex: 1; + } + + .history-dropdown-button { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 8px 12px; + background: transparent; + color: var(--vscode-input-foreground); + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 14px; + transition: all 0.2s ease; + } + + .history-dropdown-button:hover { + opacity: 0.8; + } + + .dropdown-label { + white-space: nowrap; + } + + .dropdown-icon { + width: 12px; + height: 12px; + transition: transform 0.2s ease; + flex-shrink: 0; + } + + .history-dropdown-button.active .dropdown-icon { + transform: rotate(180deg); + } + + .history-dropdown-menu { + position: absolute; + top: calc(100% + 4px); + left: 0; + min-width: 300px; + max-height: 400px; + background: var(--vscode-dropdown-background); + border: 1px solid var(--vscode-dropdown-border); + border-radius: 4px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + max-height: 400px; + overflow-y: auto; + z-index: 1000; + display: none; + } + + .history-dropdown-menu.active { + display: block; + } + + .history-list { + padding: 4px 0; + } + + .history-item { + padding: 10px 16px; + cursor: pointer; + transition: background 0.2s ease; + border-bottom: 1px solid var(--vscode-panel-border); + } + + .history-item:last-child { + border-bottom: none; + } + + .history-item:hover { + background: var(--vscode-list-hoverBackground); + } + + .history-item-title { + font-size: 14px; + font-weight: 500; + margin-bottom: 4px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + .history-item-time { + font-size: 12px; + opacity: 0.7; + } + + .history-empty { + padding: 20px; + text-align: center; + color: var(--vscode-descriptionForeground); + font-size: 14px; + } + + .new-conversation-button { + width: 36px; + height: 36px; + padding: 0; + background: transparent; + color: var(--vscode-foreground); + border: none; + border-radius: 4px; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + transition: all 0.2s ease; + flex-shrink: 0; + } + + .new-conversation-button:hover { + opacity: 0.7; + } + + .new-conversation-button:active { + opacity: 0.5; + } + + .new-conversation-button svg { + width: 20px; + height: 20px; + } + + /* 滚动条样式 */ + .history-dropdown-menu::-webkit-scrollbar { + width: 8px; + } + + .history-dropdown-menu::-webkit-scrollbar-track { + background: transparent; + } + + .history-dropdown-menu::-webkit-scrollbar-thumb { + background: rgba(128, 128, 128, 0.5); + border-radius: 4px; + } + + .history-dropdown-menu::-webkit-scrollbar-thumb:hover { + background: rgba(128, 128, 128, 0.7); + } + `; +} + +/** + * 获取会话历史栏的 JavaScript 脚本 + */ +export function getConversationHistoryBarScript(): string { + return ` + // 会话历史相关变量 + let conversationHistory = []; + let currentConversationId = null; + + // 切换历史记录下拉菜单 + function toggleHistoryDropdown() { + const menu = document.getElementById('historyDropdownMenu'); + const button = document.querySelector('.history-dropdown-button'); + + if (menu.classList.contains('active')) { + menu.classList.remove('active'); + button.classList.remove('active'); + } else { + menu.classList.add('active'); + button.classList.add('active'); + // 加载会话历史 + loadConversationHistory(); + } + } + + // 加载会话历史 + function loadConversationHistory() { + vscode.postMessage({ command: 'loadConversationHistory' }); + } + + // 渲染会话历史列表 + function renderConversationHistory(history) { + conversationHistory = history; + const historyList = document.getElementById('historyList'); + + if (!history || history.length === 0) { + historyList.innerHTML = '