@@ -28,12 +28,13 @@ export function RunnerPage() {
2828 const [ continueContext , setContinueContext ] = useState ( null ) ;
2929 const fileInputRef = useRef ( null ) ;
3030 const outputRef = useRef ( null ) ;
31+ const continueWorkspaceRef = useRef ( location . state ?. continueFrom ?. workspacePath ?? null ) ;
3132
3233 // Get the selected app's repoPath
3334 const selectedApp = apps . find ( a => a . id === selectedAppId ) ;
3435 const workspacePath = selectedApp ?. repoPath || '' ;
3536
36- // Handle continuation context from navigation
37+ // Handle continuation context from navigation — store continueFrom and clear location state once
3738 useEffect ( ( ) => {
3839 const continueFrom = location . state ?. continueFrom ;
3940 if ( continueFrom ) {
@@ -45,17 +46,10 @@ export function RunnerPage() {
4546 if ( continueFrom . model ) {
4647 setSelectedModel ( continueFrom . model ) ;
4748 }
48- // Set workspace from previous run if available
49- if ( continueFrom . workspacePath ) {
50- const app = apps . find ( a => a . repoPath === continueFrom . workspacePath ) ;
51- if ( app ) {
52- setSelectedAppId ( app . id ) ;
53- }
54- }
5549 // Clear location state to prevent re-triggering on refresh
5650 navigate ( location . pathname , { replace : true , state : null } ) ;
5751 }
58- } , [ location . state , apps ] ) ;
52+ } , [ location . state , navigate ] ) ;
5953
6054 useEffect ( ( ) => {
6155 Promise . all ( [
@@ -66,12 +60,11 @@ export function RunnerPage() {
6660 // Filter out PortOS Autofixer (it's part of PortOS project)
6761 const filteredApps = appsData . filter ( a => a . id !== 'portos-autofixer' ) ;
6862 setApps ( filteredApps ) ;
69- // Set workspace: prefer continuation context, then PortOS, then first app
63+ // Set workspace: prefer continuation context (stored in ref) , then PortOS, then first app
7064 setSelectedAppId ( prev => {
7165 if ( prev ) return prev ;
72- const continueWorkspacePath = location . state ?. continueFrom ?. workspacePath ;
73- if ( continueWorkspacePath ) {
74- const continueApp = filteredApps . find ( a => a . repoPath === continueWorkspacePath ) ;
66+ if ( continueWorkspaceRef . current ) {
67+ const continueApp = filteredApps . find ( a => a . repoPath === continueWorkspaceRef . current ) ;
7568 if ( continueApp ) return continueApp . id ;
7669 }
7770 const portosApp = filteredApps . find ( a => a . name === 'PortOS' ) ;
0 commit comments