@@ -13,6 +13,21 @@ const STANDALONE_HUD_POSITION = Object.freeze({
1313 transform : 'none'
1414} ) ;
1515const AGENT_TASK_HUD_COLLAPSED_KEY = 'agent-task-hud-collapsed-v2' ;
16+ const AGENT_TASK_HUD_VISIBLE_KEY = 'neko-agent-taskhud-visible' ;
17+
18+ function isAgentTaskHudVisiblePreferenceEnabled ( ) {
19+ try {
20+ return localStorage . getItem ( AGENT_TASK_HUD_VISIBLE_KEY ) !== 'false' ;
21+ } catch ( _ ) {
22+ return true ;
23+ }
24+ }
25+
26+ function setAgentTaskHudVisiblePreferenceEnabled ( enabled ) {
27+ try {
28+ localStorage . setItem ( AGENT_TASK_HUD_VISIBLE_KEY , enabled ? 'true' : 'false' ) ;
29+ } catch ( _ ) { }
30+ }
1631
1732function appendPluginDashboardOpenerOrigin ( url ) {
1833 const target = new URL ( url , document . baseURI || window . location . href ) ;
@@ -309,57 +324,96 @@ window.AgentHUD._createAgentPopupContent = function (popup) {
309324 statusDiv . setAttribute ( 'data-i18n' , 'settings.toggles.checking' ) ;
310325 popup . appendChild ( statusDiv ) ;
311326
312- // 【状态机严格控制】所有 agent 开关默认禁用 ,title显示查询中
313- // 只有状态机检测到可用性后才逐个恢复交互
327+ // 【状态机严格控制】Agent 能力开关默认禁用 ,title显示查询中
328+ // 只有状态机检测到可用性后才逐个恢复交互;悬浮窗显示偏好不依赖后端状态。
314329 const agentToggles = [
315330 {
316331 id : 'agent-master' ,
317332 label : window . t ? window . t ( 'settings.toggles.agentMaster' ) : 'Agent总开关' ,
318333 labelKey : 'settings.toggles.agentMaster' ,
319334 initialDisabled : true ,
320- initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...'
335+ initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...' ,
336+ controlStyle : 'slider'
337+ } ,
338+ {
339+ id : 'agent-taskhud' ,
340+ label : window . t ? window . t ( 'settings.toggles.showTaskHud' ) : '显示悬浮窗' ,
341+ labelKey : 'settings.toggles.showTaskHud' ,
342+ initialDisabled : false ,
343+ controlStyle : 'slider' ,
344+ separatorAfter : true
321345 } ,
322346 {
323347 id : 'agent-keyboard' ,
324348 label : window . t ? window . t ( 'settings.toggles.keyboardControl' ) : '键鼠控制' ,
325349 labelKey : 'settings.toggles.keyboardControl' ,
326350 initialDisabled : true ,
327- initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...'
351+ initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...' ,
352+ controlStyle : 'slider'
328353 } ,
329354 {
330355 id : 'agent-browser' ,
331356 label : window . t ? window . t ( 'settings.toggles.browserUse' ) : 'Browser Control' ,
332357 labelKey : 'settings.toggles.browserUse' ,
333358 initialDisabled : true ,
334- initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...'
359+ initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...' ,
360+ controlStyle : 'slider'
335361 } ,
336362 {
337363 id : 'agent-openfang' ,
338364 label : window . t ? window . t ( 'settings.toggles.openfang' ) : '专属桌面' ,
339365 labelKey : 'settings.toggles.openfang' ,
340366 initialDisabled : true ,
341- initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...'
367+ initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...' ,
368+ controlStyle : 'slider'
342369 } ,
343370 {
344371 id : 'agent-user-plugin' ,
345372 label : window . t ? window . t ( 'settings.toggles.userPlugin' ) : '用户插件' ,
346373 labelKey : 'settings.toggles.userPlugin' ,
347374 initialDisabled : true ,
348- initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...'
375+ initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...' ,
376+ controlStyle : 'slider'
349377 } ,
350378 {
351379 id : 'agent-openclaw' ,
352380 label : window . t ? window . t ( 'settings.toggles.openclawConnect' ) : 'OpenClaw' ,
353381 labelKey : 'settings.toggles.openclawConnect' ,
354382 initialDisabled : true ,
355- initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...'
383+ initialTitle : window . t ? window . t ( 'settings.toggles.checking' ) : '查询中...' ,
384+ controlStyle : 'slider'
356385 }
357386 ] ;
358387
359388 agentToggles . forEach ( toggle => {
360389 const toggleItem = this . _createToggleItem ( toggle , popup ) ;
361390 popup . appendChild ( toggleItem ) ;
362391
392+ if ( toggle . id === 'agent-taskhud' ) {
393+ const taskHudCheckbox = toggleItem . querySelector ( `#${ avatarPrefix } -agent-taskhud` ) ;
394+ if ( taskHudCheckbox ) {
395+ taskHudCheckbox . checked = isAgentTaskHudVisiblePreferenceEnabled ( ) ;
396+ if ( typeof taskHudCheckbox . _updateStyle === 'function' ) {
397+ taskHudCheckbox . _updateStyle ( ) ;
398+ }
399+ taskHudCheckbox . addEventListener ( 'change' , ( event ) => {
400+ setAgentTaskHudVisiblePreferenceEnabled ( taskHudCheckbox . checked ) ;
401+ if ( typeof window . checkAndToggleTaskHUD === 'function' ) {
402+ window . checkAndToggleTaskHUD ( event ) ;
403+ } else if ( ! taskHudCheckbox . checked && typeof this . hideAgentTaskHUD === 'function' ) {
404+ this . hideAgentTaskHUD ( ) ;
405+ }
406+ } ) ;
407+ }
408+ }
409+
410+ if ( toggle . separatorAfter ) {
411+ const separator = document . createElement ( 'div' ) ;
412+ separator . className = `${ avatarPrefix } -settings-separator` ;
413+ separator . setAttribute ( 'aria-hidden' , 'true' ) ;
414+ popup . appendChild ( separator ) ;
415+ }
416+
363417 // 侧边快捷入口(用户插件管理面板 / OpenClaw 接入教程)
364418 if ( ( toggle . id === 'agent-user-plugin' || toggle . id === 'agent-openclaw' ) && typeof this . _createSidePanelContainer === 'function' ) {
365419 document . querySelectorAll ( `[data-neko-sidepanel-type="${ toggle . id } -actions"]` ) . forEach ( ( element ) => {
@@ -840,9 +894,10 @@ window.AgentHUD._setupCollapseFunctionality = function (emptyState, collapseButt
840894} ;
841895
842896// 显示任务 HUD
843- window . AgentHUD . showAgentTaskHUD = function ( ) {
897+ window . AgentHUD . showAgentTaskHUD = function ( options = { } ) {
898+ const ignoreVisibilityPreference = options . ignoreVisibilityPreference === true ;
844899 console . log ( '[AgentHUD][TimeoutTrace] showAgentTaskHUD called. Current timeout ID:' , this . _hideTimeout ) ;
845- if ( isAgentHudSuppressedByGoodbye ( ) ) {
900+ if ( isAgentHudSuppressedByGoodbye ( ) || ( ! ignoreVisibilityPreference && ! isAgentTaskHudVisiblePreferenceEnabled ( ) ) ) {
846901 this . hideAgentTaskHUD ( ) ;
847902 return ;
848903 }
0 commit comments