diff --git a/src/App.tsx b/src/App.tsx index 4739a69..7221007 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -295,21 +295,20 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => { // Check if it's an array (OpenHands trajectory format) if (Array.isArray(data)) { // Check if it has OpenHands specific fields - if (data.length > 0 && - (('action' in data[0] && 'source' in data[0]) || + if (data.length > 0 && + (('action' in data[0] && 'source' in data[0]) || ('observation' in data[0] && 'source' in data[0]))) { - console.log('Detected OpenHands trajectory format'); - - // Convert to JSONL format for the JsonlViewer - const jsonlContent = JSON.stringify({ history: data }); + console.log('Detected OpenHands trajectory format - using trajectory viewer'); + + // Return as trajectory data for the trajectory viewer return { content: { - jsonlContent, - fileType: 'jsonl' + trajectoryData: data, + fileType: 'trajectory' } }; } - + // For other array formats return { content: { @@ -334,14 +333,13 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => { // Check if it has history array (trajectory-visualizer format) if (data.history && Array.isArray(data.history)) { - console.log('Detected history array format'); - - // Already in the right format, just convert to JSONL - const jsonlContent = JSON.stringify(data); + console.log('Detected history array format - using trajectory viewer'); + + // Return the history array for the trajectory viewer return { content: { - jsonlContent, - fileType: 'jsonl' + trajectoryData: data.history, + fileType: 'trajectory' } }; } diff --git a/src/components/RunDetails.tsx b/src/components/RunDetails.tsx index bf41d51..f221f26 100644 --- a/src/components/RunDetails.tsx +++ b/src/components/RunDetails.tsx @@ -5,6 +5,7 @@ import RunDetailsSkeleton from './loading/RunDetailsSkeleton'; import ArtifactDetails from './artifacts/ArtifactDetails'; import RunHeader from './header/RunHeader'; import JsonlViewer from '../components/jsonl-viewer/JsonlViewer'; +import TrajectoryList from './share/trajectory-list'; interface RunDetailsProps { owner: string; @@ -107,6 +108,17 @@ const RunDetails: React.FC = ({ owner, repo, run, initialConten ); } + // Check if we're dealing with trajectory data + if (artifactContent?.content?.fileType === 'trajectory' && artifactContent?.content?.trajectoryData) { + console.log('Rendering Trajectory viewer with', artifactContent.content.trajectoryData.length, 'items'); + + return ( +
+ +
+ ); + } + return (
{/* Main Content */} diff --git a/src/components/share/trajectory-list-items/agent-state-change.tsx b/src/components/share/trajectory-list-items/agent-state-change.tsx index 29e7375..adf60db 100644 --- a/src/components/share/trajectory-list-items/agent-state-change.tsx +++ b/src/components/share/trajectory-list-items/agent-state-change.tsx @@ -11,11 +11,11 @@ export const AgentStateChangeComponent: React.FC = ({ sta let stateText = ''; let thought = ''; - if ('args' in state) { - stateText = state.args.agent_state; - thought = state.args.thought; - } else if ('extras' in state) { - stateText = state.extras.agent_state; + if ('args' in state && state.args) { + stateText = state.args.agent_state || ''; + thought = state.args.thought || ''; + } else if ('extras' in state && state.extras) { + stateText = state.extras.agent_state || ''; } return ( diff --git a/src/components/share/trajectory-list.tsx b/src/components/share/trajectory-list.tsx index bf7127f..1333576 100644 --- a/src/components/share/trajectory-list.tsx +++ b/src/components/share/trajectory-list.tsx @@ -59,7 +59,7 @@ export const TrajectoryList: React.FC = ({ trajectory }) => return (
{/* Trajectory Items List */} -
+

Trajectory Items ({filteredTrajectory.length} items) diff --git a/src/components/upload/UploadTrajectory.tsx b/src/components/upload/UploadTrajectory.tsx index 2306c77..8870980 100644 --- a/src/components/upload/UploadTrajectory.tsx +++ b/src/components/upload/UploadTrajectory.tsx @@ -18,17 +18,13 @@ export const UploadTrajectory: React.FC = ({ // Check if it's an array (OpenHands trajectory format) if (Array.isArray(content)) { // Check if it has OpenHands specific fields - if (content.length > 0 && - (('action' in content[0] && 'source' in content[0]) || + if (content.length > 0 && + (('action' in content[0] && 'source' in content[0]) || ('observation' in content[0] && 'source' in content[0]))) { - console.log('Detected OpenHands trajectory format'); - - // Convert to JSONL format for the JsonlViewer - const jsonlContent = JSON.stringify({ history: content }); - return { - jsonlContent, - fileType: 'jsonl' - }; + console.log('Detected OpenHands trajectory format - using trajectory viewer'); + + // Return the content directly for the trajectory viewer + return content; } return content; } @@ -43,14 +39,10 @@ export const UploadTrajectory: React.FC = ({ // Check if it has history array (trajectory-visualizer format) if (content.history && Array.isArray(content.history)) { - console.log('Detected history array format'); - - // Already in the right format, just convert to JSONL - const jsonlContent = JSON.stringify(content); - return { - jsonlContent, - fileType: 'jsonl' - }; + console.log('Detected history array format - using trajectory viewer'); + + // Return the history array for the trajectory viewer + return content.history; } // If it's not in a recognized format, return as is and let the converter handle it