claude-mpm 3.4.10__py3-none-any.whl → 3.4.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. claude_mpm/cli/commands/run.py +10 -10
  2. claude_mpm/dashboard/index.html +13 -0
  3. claude_mpm/dashboard/static/css/dashboard.css +2722 -0
  4. claude_mpm/dashboard/static/js/components/agent-inference.js +619 -0
  5. claude_mpm/dashboard/static/js/components/event-processor.js +641 -0
  6. claude_mpm/dashboard/static/js/components/event-viewer.js +914 -0
  7. claude_mpm/dashboard/static/js/components/export-manager.js +362 -0
  8. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +611 -0
  9. claude_mpm/dashboard/static/js/components/hud-library-loader.js +211 -0
  10. claude_mpm/dashboard/static/js/components/hud-manager.js +671 -0
  11. claude_mpm/dashboard/static/js/components/hud-visualizer.js +1718 -0
  12. claude_mpm/dashboard/static/js/components/module-viewer.js +2701 -0
  13. claude_mpm/dashboard/static/js/components/session-manager.js +520 -0
  14. claude_mpm/dashboard/static/js/components/socket-manager.js +343 -0
  15. claude_mpm/dashboard/static/js/components/ui-state-manager.js +427 -0
  16. claude_mpm/dashboard/static/js/components/working-directory.js +866 -0
  17. claude_mpm/dashboard/static/js/dashboard-original.js +4134 -0
  18. claude_mpm/dashboard/static/js/dashboard.js +1978 -0
  19. claude_mpm/dashboard/static/js/socket-client.js +537 -0
  20. claude_mpm/dashboard/templates/index.html +346 -0
  21. claude_mpm/dashboard/test_dashboard.html +372 -0
  22. claude_mpm/scripts/socketio_daemon.py +51 -6
  23. claude_mpm/services/socketio_server.py +41 -5
  24. {claude_mpm-3.4.10.dist-info → claude_mpm-3.4.14.dist-info}/METADATA +2 -1
  25. {claude_mpm-3.4.10.dist-info → claude_mpm-3.4.14.dist-info}/RECORD +29 -9
  26. {claude_mpm-3.4.10.dist-info → claude_mpm-3.4.14.dist-info}/WHEEL +0 -0
  27. {claude_mpm-3.4.10.dist-info → claude_mpm-3.4.14.dist-info}/entry_points.txt +0 -0
  28. {claude_mpm-3.4.10.dist-info → claude_mpm-3.4.14.dist-info}/licenses/LICENSE +0 -0
  29. {claude_mpm-3.4.10.dist-info → claude_mpm-3.4.14.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,641 @@
1
+ /**
2
+ * Event Processor Module
3
+ *
4
+ * Handles event processing, filtering, and rendering for different tabs in the dashboard.
5
+ * Provides centralized event filtering and rendering logic for agents, tools, and files tabs.
6
+ *
7
+ * WHY: Extracted from main dashboard to isolate complex event processing logic
8
+ * that involves filtering, transforming, and rendering events across different views.
9
+ * This improves maintainability and makes the event processing logic testable.
10
+ *
11
+ * DESIGN DECISION: Maintains its own filtered event collections while relying on
12
+ * eventViewer for source data. Provides separate filtering logic for each tab type
13
+ * while sharing common filtering patterns and utilities.
14
+ */
15
+ class EventProcessor {
16
+ constructor(eventViewer, agentInference) {
17
+ this.eventViewer = eventViewer;
18
+ this.agentInference = agentInference;
19
+
20
+ // Processed event collections for different tabs
21
+ this.agentEvents = [];
22
+ this.filteredAgentEvents = [];
23
+ this.filteredToolEvents = [];
24
+ this.filteredFileEvents = [];
25
+
26
+ // Session filtering
27
+ this.selectedSessionId = null;
28
+
29
+ // Git tracking status cache
30
+ this.fileTrackingCache = new Map(); // file_path -> {is_tracked: boolean, timestamp: number}
31
+ this.trackingCheckTimeout = 30000; // Cache for 30 seconds
32
+
33
+ console.log('Event processor initialized');
34
+ }
35
+
36
+ /**
37
+ * Get filtered events for a specific tab
38
+ * @param {string} tabName - Tab name ('agents', 'tools', 'files', 'events')
39
+ * @returns {Array} - Filtered events
40
+ */
41
+ getFilteredEventsForTab(tabName) {
42
+ const events = this.eventViewer.events;
43
+ console.log(`getFilteredEventsForTab(${tabName}) - using RAW events: ${events.length} total`);
44
+
45
+ // Use session manager to filter events by session if needed
46
+ const sessionManager = window.sessionManager;
47
+ if (sessionManager && sessionManager.selectedSessionId) {
48
+ const sessionEvents = sessionManager.getEventsForSession(sessionManager.selectedSessionId);
49
+ console.log(`Filtering by session ${sessionManager.selectedSessionId}: ${sessionEvents.length} events`);
50
+ return sessionEvents;
51
+ }
52
+
53
+ return events;
54
+ }
55
+
56
+ /**
57
+ * Apply agents tab filtering for unique instances
58
+ * @param {Array} uniqueInstances - Unique agent instances to filter
59
+ * @returns {Array} - Filtered unique instances
60
+ */
61
+ applyAgentsFilters(uniqueInstances) {
62
+ const searchInput = document.getElementById('agents-search-input');
63
+ const typeFilter = document.getElementById('agents-type-filter');
64
+
65
+ const searchText = searchInput ? searchInput.value.toLowerCase() : '';
66
+ const typeValue = typeFilter ? typeFilter.value : '';
67
+
68
+ return uniqueInstances.filter(instance => {
69
+ // Search filter
70
+ if (searchText) {
71
+ const searchableText = [
72
+ instance.agentName || '',
73
+ instance.type || '',
74
+ instance.isImplied ? 'implied' : 'explicit'
75
+ ].join(' ').toLowerCase();
76
+
77
+ if (!searchableText.includes(searchText)) {
78
+ return false;
79
+ }
80
+ }
81
+
82
+ // Type filter
83
+ if (typeValue) {
84
+ const agentName = instance.agentName || 'unknown';
85
+ if (!agentName.toLowerCase().includes(typeValue.toLowerCase())) {
86
+ return false;
87
+ }
88
+ }
89
+
90
+ return true;
91
+ });
92
+ }
93
+
94
+ /**
95
+ * Apply tools tab filtering
96
+ * @param {Array} events - Events to filter
97
+ * @returns {Array} - Filtered events
98
+ */
99
+ applyToolsFilters(events) {
100
+ const searchInput = document.getElementById('tools-search-input');
101
+ const typeFilter = document.getElementById('tools-type-filter');
102
+
103
+ const searchText = searchInput ? searchInput.value.toLowerCase() : '';
104
+ const typeValue = typeFilter ? typeFilter.value : '';
105
+
106
+ return events.filter(event => {
107
+ // Search filter
108
+ if (searchText) {
109
+ const searchableText = [
110
+ event.tool_name || '',
111
+ event.agent_type || '',
112
+ event.type || '',
113
+ event.subtype || ''
114
+ ].join(' ').toLowerCase();
115
+
116
+ if (!searchableText.includes(searchText)) {
117
+ return false;
118
+ }
119
+ }
120
+
121
+ // Type filter
122
+ if (typeValue) {
123
+ const toolName = event.tool_name || '';
124
+ if (toolName !== typeValue) {
125
+ return false;
126
+ }
127
+ }
128
+
129
+ return true;
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Apply tools tab filtering for tool calls
135
+ * @param {Array} toolCallsArray - Tool calls array to filter
136
+ * @returns {Array} - Filtered tool calls
137
+ */
138
+ applyToolCallFilters(toolCallsArray) {
139
+ const searchInput = document.getElementById('tools-search-input');
140
+ const typeFilter = document.getElementById('tools-type-filter');
141
+
142
+ const searchText = searchInput ? searchInput.value.toLowerCase() : '';
143
+ const typeValue = typeFilter ? typeFilter.value : '';
144
+
145
+ return toolCallsArray.filter(([key, toolCall]) => {
146
+ // Search filter
147
+ if (searchText) {
148
+ const searchableText = [
149
+ toolCall.tool_name || '',
150
+ toolCall.agent_type || '',
151
+ 'tool_call'
152
+ ].join(' ').toLowerCase();
153
+
154
+ if (!searchableText.includes(searchText)) {
155
+ return false;
156
+ }
157
+ }
158
+
159
+ // Type filter
160
+ if (typeValue) {
161
+ const toolName = toolCall.tool_name || '';
162
+ if (toolName !== typeValue) {
163
+ return false;
164
+ }
165
+ }
166
+
167
+ return true;
168
+ });
169
+ }
170
+
171
+ /**
172
+ * Apply files tab filtering
173
+ * @param {Array} fileOperations - File operations to filter
174
+ * @returns {Array} - Filtered file operations
175
+ */
176
+ applyFilesFilters(fileOperations) {
177
+ const searchInput = document.getElementById('files-search-input');
178
+ const typeFilter = document.getElementById('files-type-filter');
179
+
180
+ const searchText = searchInput ? searchInput.value.toLowerCase() : '';
181
+ const typeValue = typeFilter ? typeFilter.value : '';
182
+
183
+ return fileOperations.filter(([filePath, fileData]) => {
184
+ // Session filter - filter operations within each file
185
+ if (this.selectedSessionId) {
186
+ // Filter operations for this file by session
187
+ const sessionOperations = fileData.operations.filter(op =>
188
+ op.sessionId === this.selectedSessionId
189
+ );
190
+
191
+ // If no operations from this session, exclude the file
192
+ if (sessionOperations.length === 0) {
193
+ return false;
194
+ }
195
+
196
+ // Update the fileData to only include session-specific operations
197
+ // (Note: This creates a filtered view without modifying the original)
198
+ fileData = {
199
+ ...fileData,
200
+ operations: sessionOperations,
201
+ lastOperation: sessionOperations[sessionOperations.length - 1]?.timestamp || fileData.lastOperation
202
+ };
203
+ }
204
+
205
+ // Search filter
206
+ if (searchText) {
207
+ const searchableText = [
208
+ filePath,
209
+ ...fileData.operations.map(op => op.operation),
210
+ ...fileData.operations.map(op => op.agent)
211
+ ].join(' ').toLowerCase();
212
+
213
+ if (!searchableText.includes(searchText)) {
214
+ return false;
215
+ }
216
+ }
217
+
218
+ // Type filter
219
+ if (typeValue) {
220
+ const operations = fileData.operations.map(op => op.operation);
221
+ if (!operations.includes(typeValue)) {
222
+ return false;
223
+ }
224
+ }
225
+
226
+ return true;
227
+ });
228
+ }
229
+
230
+ /**
231
+ * Extract operation type from event type
232
+ * @param {string} eventType - Event type string
233
+ * @returns {string} - Operation type
234
+ */
235
+ extractOperation(eventType) {
236
+ if (!eventType) return 'unknown';
237
+
238
+ const type = eventType.toLowerCase();
239
+ if (type.includes('read')) return 'read';
240
+ if (type.includes('write')) return 'write';
241
+ if (type.includes('edit')) return 'edit';
242
+ if (type.includes('create')) return 'create';
243
+ if (type.includes('delete')) return 'delete';
244
+ if (type.includes('move') || type.includes('rename')) return 'move';
245
+
246
+ return 'other';
247
+ }
248
+
249
+ /**
250
+ * Extract tool name from hook event type
251
+ * @param {string} eventType - Hook event type
252
+ * @returns {string} - Tool name
253
+ */
254
+ extractToolFromHook(eventType) {
255
+ if (!eventType) return '';
256
+
257
+ // Pattern: Pre{ToolName}Use or Post{ToolName}Use
258
+ const match = eventType.match(/^(?:Pre|Post)(.+)Use$/);
259
+ return match ? match[1] : '';
260
+ }
261
+
262
+ /**
263
+ * Extract tool name from subtype
264
+ * @param {string} subtype - Event subtype
265
+ * @returns {string} - Tool name
266
+ */
267
+ extractToolFromSubtype(subtype) {
268
+ if (!subtype) return '';
269
+
270
+ // Handle various subtype patterns
271
+ if (subtype.includes('_')) {
272
+ const parts = subtype.split('_');
273
+ return parts[0] || '';
274
+ }
275
+
276
+ return subtype;
277
+ }
278
+
279
+ /**
280
+ * Extract target information from tool parameters
281
+ * @param {string} toolName - Tool name
282
+ * @param {Object} params - Tool parameters
283
+ * @param {Object} toolParameters - Alternative tool parameters
284
+ * @returns {string} - Target information
285
+ */
286
+ extractToolTarget(toolName, params, toolParameters) {
287
+ const parameters = params || toolParameters || {};
288
+
289
+ switch (toolName?.toLowerCase()) {
290
+ case 'read':
291
+ case 'write':
292
+ case 'edit':
293
+ return parameters.file_path || parameters.path || '';
294
+ case 'bash':
295
+ return parameters.command || '';
296
+ case 'grep':
297
+ return parameters.pattern || '';
298
+ case 'task':
299
+ return parameters.subagent_type || parameters.agent_type || '';
300
+ default:
301
+ // Try to find a meaningful parameter
302
+ const keys = Object.keys(parameters);
303
+ const meaningfulKeys = ['path', 'file_path', 'command', 'pattern', 'query', 'target'];
304
+ for (const key of meaningfulKeys) {
305
+ if (parameters[key]) {
306
+ return parameters[key];
307
+ }
308
+ }
309
+ return keys.length > 0 ? `${keys[0]}: ${parameters[keys[0]]}` : '';
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Generate HTML for unique agent instances (one row per PM delegation)
315
+ * @param {Array} events - Agent events to render (not used, kept for compatibility)
316
+ * @returns {string} - HTML string
317
+ */
318
+ generateAgentHTML(events) {
319
+ // Get unique agent instances from agent inference
320
+ const uniqueInstances = this.agentInference.getUniqueAgentInstances();
321
+
322
+ // Apply filtering
323
+ const filteredInstances = this.applyAgentsFilters(uniqueInstances);
324
+
325
+ return filteredInstances.map((instance, index) => {
326
+ const agentName = instance.agentName;
327
+ const timestamp = this.formatTimestamp(instance.timestamp);
328
+ const delegationType = instance.isImplied ? 'implied' : 'explicit';
329
+ const eventCount = instance.eventCount || 0;
330
+
331
+ const onclickString = `dashboard.selectCard('agents', ${index}, 'agent_instance', '${instance.id}'); dashboard.showAgentInstanceDetails('${instance.id}');`;
332
+
333
+ // Format: "[Agent Name] (delegationType, eventCount events)" with separate timestamp
334
+ const agentMainContent = `${agentName} (${delegationType}, ${eventCount} events)`;
335
+
336
+ return `
337
+ <div class="event-item single-row event-agent" onclick="${onclickString}">
338
+ <span class="event-single-row-content">
339
+ <span class="event-content-main">${agentMainContent}</span>
340
+ <span class="event-timestamp">${timestamp}</span>
341
+ </span>
342
+ </div>
343
+ `;
344
+ }).join('');
345
+ }
346
+
347
+ /**
348
+ * Generate HTML for tool events
349
+ * @param {Array} toolCalls - Tool calls to render
350
+ * @returns {string} - HTML string
351
+ */
352
+ generateToolHTML(toolCalls) {
353
+ const filteredToolCalls = this.applyToolCallFilters(toolCalls);
354
+
355
+ return filteredToolCalls.map(([key, toolCall], index) => {
356
+ const toolName = toolCall.tool_name || 'Unknown';
357
+ const rawAgent = toolCall.agent_type || 'Unknown';
358
+ const timestamp = this.formatTimestamp(toolCall.timestamp);
359
+ const status = toolCall.post_event ? 'completed' : 'pending';
360
+ const statusClass = status === 'completed' ? 'status-success' : 'status-pending';
361
+
362
+ // Convert agent name: show "pm" for PM agent, otherwise show actual agent name
363
+ const agentName = rawAgent.toLowerCase() === 'pm' ? 'pm' : rawAgent;
364
+
365
+ // Format: "Tool Name (Agent Name)" - removed duration from main display
366
+ const toolMainContent = `${toolName} (${agentName})`;
367
+
368
+ return `
369
+ <div class="event-item single-row event-tool ${statusClass}" onclick="dashboard.selectCard('tools', ${index}, 'toolCall', '${key}'); dashboard.showToolCallDetails('${key}')">
370
+ <span class="event-single-row-content">
371
+ <span class="event-content-main">${toolMainContent}</span>
372
+ <span class="event-timestamp">${timestamp}</span>
373
+ </span>
374
+ </div>
375
+ `;
376
+ }).join('');
377
+ }
378
+
379
+ /**
380
+ * Generate HTML for file operations
381
+ * @param {Array} fileOperations - File operations to render
382
+ * @returns {string} - HTML string
383
+ */
384
+ generateFileHTML(fileOperations) {
385
+ const filteredFiles = this.applyFilesFilters(fileOperations);
386
+
387
+ return filteredFiles.map(([filePath, fileData], index) => {
388
+ const operations = fileData.operations.map(op => op.operation);
389
+ const timestamp = this.formatTimestamp(fileData.lastOperation);
390
+
391
+ // Count operations by type for display: "read(2), write(1)"
392
+ const operationCounts = {};
393
+ operations.forEach(op => {
394
+ operationCounts[op] = (operationCounts[op] || 0) + 1;
395
+ });
396
+
397
+ const operationSummary = Object.entries(operationCounts)
398
+ .map(([op, count]) => `${op}(${count})`)
399
+ .join(', ');
400
+
401
+ // Get unique agents that worked on this file
402
+ const uniqueAgents = [...new Set(fileData.operations.map(op => op.agent))];
403
+ const agentSummary = uniqueAgents.length > 1 ? `by ${uniqueAgents.length} agents` : `by ${uniqueAgents[0] || 'unknown'}`;
404
+
405
+ // Format: "[file path] read(2), write(1) by agent" with separate timestamp
406
+ const fileName = this.getRelativeFilePath(filePath);
407
+ const fileMainContent = `${fileName} ${operationSummary} ${agentSummary}`;
408
+
409
+ return `
410
+ <div class="event-item single-row file-item" onclick="dashboard.selectCard('files', ${index}, 'file', '${filePath}'); dashboard.showFileDetails('${filePath}')">
411
+ <span class="event-single-row-content">
412
+ <span class="event-content-main">${fileMainContent}</span>
413
+ <span class="event-timestamp">${timestamp}</span>
414
+ </span>
415
+ </div>
416
+ `;
417
+ }).join('');
418
+ }
419
+
420
+ /**
421
+ * Get icon for file operations
422
+ * @param {Array} operations - Array of operations
423
+ * @returns {string} - Icon representation
424
+ */
425
+ getFileOperationIcon(operations) {
426
+ if (operations.includes('write') || operations.includes('create')) return '📝';
427
+ if (operations.includes('edit')) return '✏️';
428
+ if (operations.includes('read')) return '👁️';
429
+ if (operations.includes('delete')) return '🗑️';
430
+ if (operations.includes('move')) return '📦';
431
+ return '📄';
432
+ }
433
+
434
+ /**
435
+ * Get relative file path
436
+ * @param {string} filePath - Full file path
437
+ * @returns {string} - Relative path
438
+ */
439
+ getRelativeFilePath(filePath) {
440
+ if (!filePath) return '';
441
+
442
+ // Simple relative path logic - can be enhanced
443
+ const parts = filePath.split('/');
444
+ if (parts.length > 3) {
445
+ return '.../' + parts.slice(-2).join('/');
446
+ }
447
+ return filePath;
448
+ }
449
+
450
+ /**
451
+ * Format timestamp for display
452
+ * @param {string|number} timestamp - Timestamp to format
453
+ * @returns {string} - Formatted timestamp
454
+ */
455
+ formatTimestamp(timestamp) {
456
+ if (!timestamp) return '';
457
+
458
+ const date = new Date(timestamp);
459
+ return date.toLocaleTimeString();
460
+ }
461
+
462
+ /**
463
+ * Set selected session ID for filtering
464
+ * @param {string} sessionId - Session ID to filter by
465
+ */
466
+ setSelectedSessionId(sessionId) {
467
+ this.selectedSessionId = sessionId;
468
+ }
469
+
470
+ /**
471
+ * Get selected session ID
472
+ * @returns {string|null} - Current session ID
473
+ */
474
+ getSelectedSessionId() {
475
+ return this.selectedSessionId;
476
+ }
477
+
478
+ /**
479
+ * Get unique tool instances (one row per unique tool call)
480
+ * This deduplicates tool calls to show unique instances only
481
+ * @param {Array} toolCallsArray - Tool calls array
482
+ * @returns {Array} - Unique tool instances
483
+ */
484
+ getUniqueToolInstances(toolCallsArray) {
485
+ // The toolCallsArray already represents unique tool calls
486
+ // since it's generated from paired pre/post events in FileToolTracker
487
+ // Just apply filtering and return
488
+ return this.applyToolCallFilters(toolCallsArray);
489
+ }
490
+
491
+ /**
492
+ * Get unique file instances (one row per unique file)
493
+ * This aggregates all operations on each file
494
+ * @param {Array} fileOperations - File operations array
495
+ * @returns {Array} - Unique file instances (same as input since already unique per file)
496
+ */
497
+ getUniqueFileInstances(fileOperations) {
498
+ // The fileOperations array already represents unique files
499
+ // since it's keyed by file path in FileToolTracker
500
+ // Just apply filtering and return
501
+ return this.applyFilesFilters(fileOperations);
502
+ }
503
+
504
+ /**
505
+ * Check if a file is tracked by git (with caching)
506
+ * @param {string} filePath - Path to the file
507
+ * @param {string} workingDir - Working directory
508
+ * @returns {Promise<boolean>} - Promise resolving to tracking status
509
+ */
510
+ async isFileTracked(filePath, workingDir) {
511
+ const cacheKey = `${workingDir}:${filePath}`;
512
+ const now = Date.now();
513
+
514
+ // Check cache first
515
+ const cached = this.fileTrackingCache.get(cacheKey);
516
+ if (cached && (now - cached.timestamp) < this.trackingCheckTimeout) {
517
+ return cached.is_tracked;
518
+ }
519
+
520
+ try {
521
+ // Use the socketio connection to check tracking status
522
+ const socket = window.socket;
523
+ if (!socket) {
524
+ console.warn('No socket connection available for git tracking check');
525
+ return false;
526
+ }
527
+
528
+ return new Promise((resolve) => {
529
+ // Set up one-time listener for response
530
+ const responseHandler = (data) => {
531
+ if (data.file_path === filePath) {
532
+ const isTracked = data.success && data.is_tracked;
533
+
534
+ // Cache the result
535
+ this.fileTrackingCache.set(cacheKey, {
536
+ is_tracked: isTracked,
537
+ timestamp: now
538
+ });
539
+
540
+ socket.off('file_tracked_response', responseHandler);
541
+ resolve(isTracked);
542
+ }
543
+ };
544
+
545
+ socket.on('file_tracked_response', responseHandler);
546
+
547
+ // Send request
548
+ socket.emit('check_file_tracked', {
549
+ file_path: filePath,
550
+ working_dir: workingDir
551
+ });
552
+
553
+ // Timeout after 5 seconds
554
+ setTimeout(() => {
555
+ socket.off('file_tracked_response', responseHandler);
556
+ resolve(false); // Default to not tracked on timeout
557
+ }, 5000);
558
+ });
559
+
560
+ } catch (error) {
561
+ console.error('Error checking file tracking status:', error);
562
+ return false;
563
+ }
564
+ }
565
+
566
+ /**
567
+ * Generate git diff icon with tracking status
568
+ * @param {string} filePath - Path to the file
569
+ * @param {string} timestamp - Operation timestamp
570
+ * @param {string} workingDir - Working directory
571
+ * @returns {string} - HTML for git diff icon
572
+ */
573
+ generateGitDiffIcon(filePath, timestamp, workingDir) {
574
+ const iconId = `git-icon-${filePath.replace(/[^a-zA-Z0-9]/g, '-')}-${timestamp}`;
575
+
576
+ // Initially show default icon
577
+ const iconHtml = `
578
+ <span id="${iconId}" class="git-diff-icon"
579
+ onclick="event.stopPropagation(); showGitDiffModal('${filePath}', '${timestamp}')"
580
+ title="View git diff for this file operation"
581
+ style="margin-left: 8px; cursor: pointer; font-size: 16px;">
582
+ 📋
583
+ </span>
584
+ `;
585
+
586
+ // Asynchronously check tracking status and update icon
587
+ this.isFileTracked(filePath, workingDir).then(isTracked => {
588
+ const iconElement = document.getElementById(iconId);
589
+ if (iconElement) {
590
+ if (!isTracked) {
591
+ // File is not tracked - show crossed out icon
592
+ iconElement.innerHTML = '📋❌';
593
+ iconElement.title = 'File not tracked by git - click to see details';
594
+ iconElement.classList.add('untracked-file');
595
+ } else {
596
+ // File is tracked - keep normal icon
597
+ iconElement.innerHTML = '📋';
598
+ iconElement.title = 'View git diff for this file operation';
599
+ iconElement.classList.add('tracked-file');
600
+ }
601
+ }
602
+ }).catch(error => {
603
+ console.error('Error updating git diff icon:', error);
604
+ });
605
+
606
+ return iconHtml;
607
+ }
608
+
609
+ /**
610
+ * Show agent instance details for unique instance view
611
+ * @param {string} instanceId - Agent instance ID
612
+ */
613
+ showAgentInstanceDetails(instanceId) {
614
+ const pmDelegations = this.agentInference.getPMDelegations();
615
+ const instance = pmDelegations.get(instanceId);
616
+
617
+ if (!instance) {
618
+ console.error('Agent instance not found:', instanceId);
619
+ return;
620
+ }
621
+
622
+ // Show details about this PM delegation and its events
623
+ console.log('Showing agent instance details for:', instanceId, instance);
624
+
625
+ // This would integrate with the existing detail view system
626
+ // For now, just log the details - can be expanded to show in a modal/sidebar
627
+ const detailsHtml = `
628
+ <div class="agent-instance-details">
629
+ <h3>Agent Instance: ${instance.agentName}</h3>
630
+ <p><strong>Type:</strong> ${instance.isImplied ? 'Implied PM Delegation' : 'Explicit PM Delegation'}</p>
631
+ <p><strong>Start Time:</strong> ${this.formatTimestamp(instance.timestamp)}</p>
632
+ <p><strong>Event Count:</strong> ${instance.agentEvents.length}</p>
633
+ <p><strong>Session:</strong> ${instance.sessionId}</p>
634
+ ${instance.pmCall ? `<p><strong>PM Call:</strong> Task delegation to ${instance.agentName}</p>` : '<p><strong>Note:</strong> Implied delegation (no explicit PM call found)</p>'}
635
+ </div>
636
+ `;
637
+
638
+ // You would integrate this with your existing detail display system
639
+ console.log('Agent instance details HTML:', detailsHtml);
640
+ }
641
+ }