diff --git a/static/src/app/methods/ui.ts b/static/src/app/methods/ui.ts index 1cf5d14..95319d5 100644 --- a/static/src/app/methods/ui.ts +++ b/static/src/app/methods/ui.ts @@ -118,14 +118,17 @@ export const uiMethods = { }, openMobileOverlay(target) { + console.log('[UI_DEBUG] openMobileOverlay called, target:', target, 'isMobileViewport:', this.isMobileViewport, 'activeMobileOverlay:', this.activeMobileOverlay); if (!this.isMobileViewport) { + console.log('[UI_DEBUG] openMobileOverlay: blocked - not mobile viewport'); return; } if (target === 'approval') { this.fetchPendingToolApprovals(); } if (this.activeMobileOverlay === target) { - this.closeMobileOverlay(); + console.log('[UI_DEBUG] openMobileOverlay: target already active, closing'); + this.closeMobileOverlay('same-target-click'); return; } if (this.activeMobileOverlay === 'conversation') { @@ -134,6 +137,7 @@ export const uiMethods = { if (target === 'conversation') { this.uiSetSidebarCollapsed(false); } + console.log('[UI_DEBUG] openMobileOverlay: opening target:', target); this.uiSetActiveMobileOverlay(target); this.uiSetMobileOverlayMenuOpen(false); }, @@ -150,7 +154,8 @@ export const uiMethods = { this.refreshCurrentPage(); }, - closeMobileOverlay() { + closeMobileOverlay(source = 'unknown') { + console.log('[UI_DEBUG] closeMobileOverlay called from:', source, 'activeMobileOverlay:', this.activeMobileOverlay); if (!this.activeMobileOverlay) { this.uiCloseMobileOverlay(); return; @@ -691,9 +696,6 @@ export const uiMethods = { async fetchPendingToolApprovals() { if (!this.currentConversationId) { this.pendingToolApprovals = []; - if (this.isMobileViewport && this.activeMobileOverlay === 'approval') { - this.closeMobileOverlay(); - } return; } try { @@ -706,16 +708,12 @@ export const uiMethods = { } const items = Array.isArray(payload.items) ? payload.items : []; this.pendingToolApprovals = items; - if (items.length > 0) { + // 电脑端:有审批时自动展开面板 + if (items.length > 0 && !this.isMobileViewport) { this.rightCollapsed = false; if (this.rightWidth < this.minPanelWidth) { this.rightWidth = this.minPanelWidth; } - if (this.isMobileViewport && this.activeMobileOverlay !== 'approval') { - this.openMobileOverlay('approval'); - } - } else if (this.isMobileViewport && this.activeMobileOverlay === 'approval') { - this.closeMobileOverlay(); } } catch (_error) { // ignore @@ -809,28 +807,38 @@ export const uiMethods = { }, handleApprovalPanelToggleClick() { + console.log('[UI_DEBUG] handleApprovalPanelToggleClick called, isMobileViewport:', this.isMobileViewport, 'currentConversationId:', this.currentConversationId, 'activeMobileOverlay:', this.activeMobileOverlay); if (!this.currentConversationId) { + console.log('[UI_DEBUG] handleApprovalPanelToggleClick: blocked - no conversation'); return; } if (this.isMobileViewport) { + console.log('[UI_DEBUG] handleApprovalPanelToggleClick: mobile path, toggling overlay'); + // 手机端:获取审批列表(不自动关闭),然后切换遮罩 this.fetchPendingToolApprovals(); this.openMobileOverlay('approval'); return; } + console.log('[UI_DEBUG] handleApprovalPanelToggleClick: desktop path, toggling panel'); this.toggleApprovalPanel(); }, - handleTokenPanelToggleClick() { + handleTokenPanelToggleClick(fromSettingsMenu = false) { + console.log('[UI_DEBUG] handleTokenPanelToggleClick called, fromSettingsMenu:', fromSettingsMenu, 'isMobileViewport:', this.isMobileViewport, 'tokenPanelCollapsed:', this.tokenPanelCollapsed, 'currentConversationId:', this.currentConversationId); if (!this.currentConversationId) { + console.log('[UI_DEBUG] handleTokenPanelToggleClick: blocked - no conversation'); return; } if (this.isPolicyBlocked('block_token_panel', '用量统计已被管理员禁用')) { + console.log('[UI_DEBUG] handleTokenPanelToggleClick: blocked - policy'); return; } // 移动端禁用“点击展开顶部用量面板”,仅允许在已展开时点击收起 - if (this.isMobileViewport && this.tokenPanelCollapsed) { + if (this.isMobileViewport && this.tokenPanelCollapsed && !fromSettingsMenu) { + console.log('[UI_DEBUG] handleTokenPanelToggleClick: blocked - mobile viewport restriction'); return; } + console.log('[UI_DEBUG] handleTokenPanelToggleClick: calling toggleTokenPanel'); this.toggleTokenPanel(); }, @@ -1095,6 +1103,7 @@ export const uiMethods = { }, toggleApprovalPanel() { + console.log('[UI_DEBUG] toggleApprovalPanel called, current rightCollapsed:', this.rightCollapsed, 'new state:', !this.rightCollapsed); this.rightCollapsed = !this.rightCollapsed; if (!this.rightCollapsed && this.rightWidth < this.minPanelWidth) { this.rightWidth = this.minPanelWidth; diff --git a/static/src/components/input/InputComposer.vue b/static/src/components/input/InputComposer.vue index 587b657..ca7a632 100644 --- a/static/src/components/input/InputComposer.vue +++ b/static/src/components/input/InputComposer.vue @@ -129,7 +129,7 @@ @update-tool-category="(id, enabled) => $emit('update-tool-category', id, enabled)" @realtime-terminal="$emit('realtime-terminal')" @toggle-focus-panel="$emit('toggle-focus-panel')" - @toggle-token-panel="$emit('toggle-token-panel')" + @toggle-token-panel="(val) => $emit('toggle-token-panel', val)" @compress-conversation="$emit('compress-conversation')" @toggle-approval-panel="$emit('toggle-approval-panel')" @open-review="$emit('open-review')" diff --git a/static/src/components/input/QuickMenu.vue b/static/src/components/input/QuickMenu.vue index ee6b4d2..7efc176 100644 --- a/static/src/components/input/QuickMenu.vue +++ b/static/src/components/input/QuickMenu.vue @@ -108,7 +108,7 @@ type="button" class="menu-entry submenu-entry" data-tutorial="settings-token-panel" - @click="$emit('toggle-token-panel')" + @click="console.log('[UI_DEBUG] QuickMenu 用量统计按钮 clicked, emitting toggle-token-panel with true'); $emit('toggle-token-panel', true)" :disabled="!currentConversationId" > 用量统计 @@ -182,7 +182,7 @@ defineEmits<{ (event: 'toggle-settings'): void; (event: 'update-tool-category', id: string, enabled: boolean): void; (event: 'realtime-terminal'): void; - (event: 'toggle-token-panel'): void; + (event: 'toggle-token-panel', fromSettingsMenu?: boolean): void; (event: 'compress-conversation'): void; (event: 'toggle-approval-panel'): void; (event: 'toggle-mode-menu'): void; diff --git a/static/src/stores/resource.ts b/static/src/stores/resource.ts index 121d290..6c3618f 100644 --- a/static/src/stores/resource.ts +++ b/static/src/stores/resource.ts @@ -101,6 +101,7 @@ export const useResourceStore = defineStore('resource', { this.currentContextTokens = value || 0; }, toggleTokenPanel() { + console.log('[UI_DEBUG] toggleTokenPanel called, current state:', this.tokenPanelCollapsed, 'new state:', !this.tokenPanelCollapsed); this.tokenPanelCollapsed = !this.tokenPanelCollapsed; }, async updateCurrentContextTokens(conversationId: string | null) {