The dashboard FileViewer was displaying file paths correctly but not rendering the actual code content below them. Users could see which files were read, but the syntax-highlighted code viewer area remained blank.
The backend wraps event data in a nested structure when emitting hook events:
# Backend structure (hooks.py line 420-430)
{
"type": "hook",
"subtype": "post_tool",
"data": {
"tool_name": "Read",
"tool_parameters": {"file_path": "/path/to/file"},
"output": "<ACTUAL FILE CONTENT>" # Content is here!
}
}The frontend was looking for eventData.output (direct access), but the actual content was at eventData.data.output (nested inside the data field).
Updated the content extraction logic in files.svelte.ts to check multiple possible locations for the content, prioritizing the correct nested structure:
// Extract innerData first
const innerData = eventData.data && typeof eventData.data === 'object'
? eventData.data as Record<string, unknown>
: null;
// Check locations in priority order
const content = (
// 1. Check innerData.output (backend format: data.data.output)
typeof (innerData as any)?.output === 'string' ? (innerData as any).output :
// 2. Check eventData.output (direct format - fallback)
typeof eventData.output === 'string' ? eventData.output :
// 3. Check eventData.result (alternative format)
typeof eventData.result === 'string' ? eventData.result :
// 4. Other fallback locations...
undefined
);src/claude_mpm/dashboard-svelte/src/lib/stores/files.svelte.ts(lines 155-197)- Added extraction of
innerDatafromeventData.data - Updated content extraction to prioritize
innerData.output - Enhanced debug logging to show the nested data structure
- Added comprehensive fallback chain for content location
- Added extraction of
After the fix:
- Dashboard build completed successfully
- Content extraction now checks the correct nested location first
- Enhanced logging will help diagnose any future data structure issues
- Start the dashboard:
mpm start - Open dashboard in browser:
http://localhost:5050 - Navigate to the "Files" tab
- Click on any file that was read
- Verify that:
- File path is displayed in the header
- Code content appears below with syntax highlighting
- Console logs show
hasContent: trueand correct content length
The enhanced logging now shows:
[FILES] Read operation for /path/to/file: {
hasContent: true,
contentLength: 1234,
contentPreview: "...",
innerData: {
hasOutput: true,
outputType: "string",
outputIsString: true,
keys: ["output", "tool_name", "tool_parameters"]
},
// ... more debug info
}cd /Users/masa/Projects/claude-mpm/src/claude_mpm/dashboard-svelte
npm run build
rm -rf ../dashboard/static/svelte-build
cp -r .svelte-kit/output/client ../dashboard/static/svelte-build- User Experience: File content now displays correctly in the FileViewer
- Performance: No performance impact (same number of checks, just different order)
- Compatibility: Maintains backward compatibility with direct format via fallback chain
- Debugging: Enhanced logging helps diagnose future data structure issues
- Added: 15 lines (nested data extraction + enhanced logging)
- Removed: 3 lines (old simple extraction)
- Net Change: +12 lines
- Backend:
src/claude_mpm/services/monitor/handlers/hooks.py(emits the nested structure) - Frontend Store:
src/claude_mpm/dashboard-svelte/src/lib/stores/files.svelte.ts(content extraction) - Frontend Component:
src/claude_mpm/dashboard-svelte/src/lib/components/FileViewer.svelte(rendering)