Skip to content

Commit dd884f5

Browse files
authored
Merge pull request #18 from All-Hands-AI/feature/openhands-trajectory-support
Add support for OpenHands trajectory visualization
2 parents e9e911c + 6397e93 commit dd884f5

39 files changed

+636
-2855
lines changed

src/App.tsx

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import RepositorySelector from './components/RepositorySelector';
44
import { WorkflowRunsList } from './components/workflow-runs';
55
import RunDetails from './components/RunDetails';
66
import RunDetailsSkeleton from './components/loading/RunDetailsSkeleton';
7+
import { TrajectoryLoadingOverlay } from './components/loading/TrajectoryLoadingOverlay';
78
import { WorkflowRun } from './types';
89
import { UploadTrajectory } from './components/upload/UploadTrajectory';
910
import { EvaluationUpload } from './components/upload/EvaluationUpload';
@@ -294,8 +295,9 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => {
294295
const navigate = useNavigate();
295296
const location = useLocation();
296297
const [uploadedContent, setUploadedContent] = useState<UploadContent | null>(null);
298+
const [isLoadingTrajectory, setIsLoadingTrajectory] = useState<boolean>(false);
297299

298-
// Check if we should restore from localStorage on initial load
300+
// Check for URL parameters and localStorage on initial load
299301
useEffect(() => {
300302
// Keep track of load count to prevent cycles
301303
navigationRef.current.loadCount++;
@@ -311,6 +313,28 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => {
311313
console.log('Initial navigation check');
312314
navigationRef.current.initialNavigationDone = true;
313315

316+
// Check for data parameter in URL
317+
const searchParams = new URLSearchParams(location.search);
318+
const dataParam = searchParams.get('data');
319+
320+
if (dataParam) {
321+
try {
322+
// Decode and parse the data parameter
323+
const decodedData = atob(decodeURIComponent(dataParam));
324+
const parsedData = JSON.parse(decodedData);
325+
console.log('Found trajectory data in URL:', parsedData);
326+
327+
// Set the uploaded content
328+
setUploadedContent(parsedData);
329+
330+
// Clear the URL parameter to avoid reloading the same data
331+
navigate(location.pathname, { replace: true });
332+
return;
333+
} catch (error) {
334+
console.error('Failed to parse data parameter:', error);
335+
}
336+
}
337+
314338
// Only redirect if we're at the root path and have no owner/repo
315339
if ((!owner || !repo) && location.pathname === '/') {
316340
const savedRepo = localStorage.getItem('selected_repository');
@@ -325,7 +349,7 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => {
325349
}
326350
}
327351
}
328-
}, [owner, repo, navigate, location.pathname]);
352+
}, [owner, repo, navigate, location.pathname, location.search]);
329353

330354
// Handle repository selection
331355
const handleRepositorySelect = (newOwner: string, newRepo: string) => {
@@ -343,11 +367,20 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => {
343367

344368
// Handle trajectory upload
345369
const handleTrajectoryUpload = (content: UploadContent) => {
370+
setIsLoadingTrajectory(false);
346371
setUploadedContent(content);
347372
};
348373

374+
// Handle trajectory upload start
375+
const handleTrajectoryUploadStart = () => {
376+
setIsLoadingTrajectory(true);
377+
};
378+
349379
return (
350380
<div className="h-screen max-h-screen flex flex-col overflow-hidden bg-gray-50 dark:bg-gray-900">
381+
{/* Show loading overlay when processing trajectory */}
382+
{isLoadingTrajectory && <TrajectoryLoadingOverlay />}
383+
351384
{/* Header */}
352385
<header className={`${isDark ? 'bg-gray-800 border-gray-700' : 'bg-white border-gray-200'} border-b`}>
353386
<div className="max-w-[1920px] mx-auto px-4 sm:px-6 lg:px-8">
@@ -407,7 +440,10 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => {
407440
<h2 className={`text-lg font-medium mb-4 ${isDark ? 'text-white' : 'text-gray-900'}`}>
408441
Upload OpenHands Trajectory
409442
</h2>
410-
<UploadTrajectory onUpload={handleTrajectoryUpload} />
443+
<UploadTrajectory
444+
onUpload={handleTrajectoryUpload}
445+
onUploadStart={handleTrajectoryUploadStart}
446+
/>
411447
</div>
412448

413449
<div>
@@ -449,7 +485,10 @@ const App: React.FC<{ router?: boolean }> = ({ router = true }) => {
449485
<h2 className={`text-lg font-medium mb-4 ${isDark ? 'text-white' : 'text-gray-900'}`}>
450486
Or Upload OpenHands Trajectory
451487
</h2>
452-
<UploadTrajectory onUpload={handleTrajectoryUpload} />
488+
<UploadTrajectory
489+
onUpload={handleTrajectoryUpload}
490+
onUploadStart={handleTrajectoryUploadStart}
491+
/>
453492
</div>
454493

455494
<div>

0 commit comments

Comments
 (0)