fix(multi-cli): populate multiCliPlan sessions in liteTaskDataStore

Fix task click handlers not working in multi-CLI planning detail page.

Root cause: liteTaskDataStore was not being populated with multiCliPlan
sessions during initialization, so task click handlers couldn't access
session data using currentSessionDetailKey.

Changes:
- navigation.js: Add code to populate multiCliPlan sessions in liteTaskDataStore
- notifications.js: Add code to populate multiCliPlan sessions when data refreshes

Now when task detail page loads, liteTaskDataStore contains the correct key
'multi-cli-${sessionId}' matching currentSessionDetailKey, allowing task
click handlers to find session data and open detail drawer.

Verified: Task clicks now properly open detail panel for all 7 tasks.
This commit is contained in:
catlog22
2026-01-22 15:41:01 +08:00
parent f0954b3247
commit ea04663035
22 changed files with 921 additions and 83 deletions

View File

@@ -37,6 +37,38 @@ import { TaskStorageManager, type TaskCreateRequest, type TaskUpdateRequest, typ
import { executeCliTool } from '../../tools/cli-executor.js';
import { loadClaudeCliTools } from '../../tools/claude-cli-tools.js';
/**
* Module-level cache for CLI tools configuration
* Loaded once at server startup to avoid repeated file I/O
*/
let cachedEnabledTools: string[] | null = null;
/**
* Initialize CLI tools cache at server startup
* Should be called once when the server starts
*/
export function initializeCliToolsCache(): void {
try {
const cliToolsConfig = loadClaudeCliTools(os.homedir());
const enabledTools = Object.entries(cliToolsConfig.tools || {})
.filter(([_, config]) => config.enabled === true)
.map(([name]) => name);
cachedEnabledTools = ['bash', ...enabledTools];
console.log('[Loop V2] CLI tools cache initialized:', cachedEnabledTools);
} catch (err) {
console.error('[Loop V2] Failed to initialize CLI tools cache:', err);
// Fallback to basic tools if config loading fails
cachedEnabledTools = ['bash', 'gemini', 'qwen', 'codex', 'claude'];
}
}
/**
* Clear CLI tools cache (for testing or config reload)
*/
export function clearCliToolsCache(): void {
cachedEnabledTools = null;
}
/**
* V2 Loop Create Request
*/
@@ -1314,14 +1346,19 @@ function isValidId(id: string): boolean {
}
/**
* Get enabled tools list
* Get enabled tools list from cache
* If cache is not initialized, it will load from config (fallback for lazy initialization)
*/
function getEnabledToolsList(): string[] {
const cliToolsConfig = loadClaudeCliTools(os.homedir());
const enabledTools = Object.entries(cliToolsConfig.tools || {})
.filter(([_, config]) => config.enabled === true)
.map(([name]) => name);
return ['bash', ...enabledTools];
// Return cached value if available
if (cachedEnabledTools) {
return cachedEnabledTools;
}
// Fallback: lazy initialization if cache not initialized (shouldn't happen in normal operation)
console.warn('[Loop V2] CLI tools cache not initialized, performing lazy load');
initializeCliToolsCache();
return cachedEnabledTools || ['bash', 'gemini', 'qwen', 'codex', 'claude'];
}
/**