Add parallel search mode and index progress bar

Features:
- CCW smart_search: Add 'parallel' mode that runs hybrid + exact + ripgrep
  simultaneously with RRF (Reciprocal Rank Fusion) for result merging
- Dashboard: Add real-time progress bar for CodexLens index initialization
- MCP: Return progress metadata in init action response
- Codex-lens: Auto-detect optimal worker count for parallel indexing

Changes:
- smart-search.ts: Add parallel mode, RRF fusion, progress tracking
- codex-lens.ts: Add onProgress callback support, progress parsing
- codexlens-routes.ts: Broadcast index progress via WebSocket
- codexlens-manager.js: New index progress modal with real-time updates
- notifications.js: Add WebSocket event handler registration system
- i18n.js: Add English/Chinese translations for progress UI
- index_tree.py: Workers parameter now auto-detects CPU count (max 16)
- commands.py: CLI --workers parameter supports auto-detection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-12-17 23:17:15 +08:00
parent 44d84116c3
commit 51a61bef31
8 changed files with 569 additions and 21 deletions

View File

@@ -87,6 +87,49 @@ let autoRefreshInterval = null;
let lastDataHash = null;
const AUTO_REFRESH_INTERVAL_MS = 30000; // 30 seconds
// Custom event handlers registry for components to subscribe to specific events
const wsEventHandlers = {};
/**
* Register a custom handler for a specific WebSocket event type
* @param {string} eventType - The event type to listen for
* @param {Function} handler - The handler function
*/
function registerWsEventHandler(eventType, handler) {
if (!wsEventHandlers[eventType]) {
wsEventHandlers[eventType] = [];
}
wsEventHandlers[eventType].push(handler);
}
/**
* Unregister a custom handler for a specific WebSocket event type
* @param {string} eventType - The event type
* @param {Function} handler - The handler function to remove
*/
function unregisterWsEventHandler(eventType, handler) {
if (wsEventHandlers[eventType]) {
wsEventHandlers[eventType] = wsEventHandlers[eventType].filter(h => h !== handler);
}
}
/**
* Dispatch event to registered handlers
* @param {string} eventType - The event type
* @param {Object} data - The full event data
*/
function dispatchToEventHandlers(eventType, data) {
if (wsEventHandlers[eventType]) {
wsEventHandlers[eventType].forEach(handler => {
try {
handler(data);
} catch (e) {
console.error('[WS] Error in custom handler for', eventType, e);
}
});
}
}
// ========== WebSocket Connection ==========
function initWebSocket() {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
@@ -390,6 +433,12 @@ function handleNotification(data) {
console.log('[CodexLens] Uninstallation completed:', payload);
break;
case 'CODEXLENS_INDEX_PROGRESS':
// Handle CodexLens index progress updates
dispatchToEventHandlers('CODEXLENS_INDEX_PROGRESS', data);
console.log('[CodexLens] Index progress:', payload.stage, payload.percent + '%');
break;
default:
console.log('[WS] Unknown notification type:', type);
}