Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/cowork-gui/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,18 @@ pub fn run() {
// Store in app state
if let Some(state) = app.try_state::<AppState>() {
if let Ok(mut ws) = state.workspace_path.lock() {
*ws = Some(workspace);
*ws = Some(workspace.clone());
}
}

// Reset any "running" iterations to "paused" since there's no actual execution after reopening
reset_running_iterations();

// Emit project_loaded event to notify frontend to navigate to iterations page
if let Some(window) = app.get_webview_window("main") {
let _ = window.emit("project_loaded", ());
eprintln!("[GUI] Emitted project_loaded event for workspace: {}", workspace);
}
}
} else {
eprintln!("[GUI] Invalid workspace path: {}", workspace);
Expand Down
13 changes: 13 additions & 0 deletions crates/cowork-gui/src/hooks/useAppEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,19 @@ export function useAppEvents(userInput: string, setUserInput: (input: string) =>

// Wait for all listeners to be registered in parallel
await Promise.all(listenerPromises);

// Check if there's already an open project (e.g., when launched with --workspace)
// This handles the timing issue where backend emits project_loaded before frontend listeners are ready
try {
const hasOpenProject = await API.workspace.hasOpen();
if (hasOpenProject) {
console.log('[App] Detected open project on startup, loading project...');
await loadProject();
setActiveView('iterations');
}
} catch (error) {
console.error('[App] Failed to check for open project:', error);
}
};

setupListeners();
Expand Down
Loading