Improve document tooltip display with track ID and better formatting

• Add track ID to tooltip display
• Remove JSON braces from metadata
• Reorder tooltip content layout
• Clean up metadata indentation
• Show track ID before metadata
This commit is contained in:
yangdx 2025-10-05 10:13:11 +08:00
parent b5f8376756
commit 0c1cb7b731

View file

@ -77,7 +77,13 @@ const formatMetadata = (metadata: Record<string, any>): string => {
} }
} }
return JSON.stringify(formattedMetadata, null, 2); // Format JSON and remove outer braces and indentation
const jsonStr = JSON.stringify(formattedMetadata, null, 2);
const lines = jsonStr.split('\n');
// Remove first line ({) and last line (}), and remove leading indentation (2 spaces)
return lines.slice(1, -1)
.map(line => line.replace(/^ {2}/, ''))
.join('\n');
}; };
const pulseStyle = ` const pulseStyle = `
@ -1422,14 +1428,17 @@ export default function DocumentManager() {
)} )}
{/* Tooltip rendering logic */} {/* Tooltip rendering logic */}
{(doc.error_msg || (doc.metadata && Object.keys(doc.metadata).length > 0)) && ( {(doc.error_msg || (doc.metadata && Object.keys(doc.metadata).length > 0) || doc.track_id) && (
<div className="invisible group-hover:visible tooltip"> <div className="invisible group-hover:visible tooltip">
{doc.error_msg && ( {doc.track_id && (
<pre>{doc.error_msg}</pre> <div className="mt-1">Track ID: {doc.track_id}</div>
)} )}
{doc.metadata && Object.keys(doc.metadata).length > 0 && ( {doc.metadata && Object.keys(doc.metadata).length > 0 && (
<pre>{formatMetadata(doc.metadata)}</pre> <pre>{formatMetadata(doc.metadata)}</pre>
)} )}
{doc.error_msg && (
<pre>{doc.error_msg}</pre>
)}
</div> </div>
)} )}
</div> </div>