{"record":{"id":"bb6867347af204b7","repo":"zed-industries/zed","slug":"cannot-open-repository-on-disconnected-remote-mach","errorCode":null,"errorMessage":"cannot open repository on disconnected remote machine","messagePattern":"cannot open repository on disconnected remote machine","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent_ui/src/thread_worktree_archive.rs","lineNumber":410,"sourceCode":"            .next()\n    });\n\n    if let Some((repo, project)) = live_repo {\n        return Ok((repo, project));\n    }\n\n    let app_state =\n        current_app_state(cx).context(\"no app state available for temporary project\")?;\n\n    // For remote paths, create a fresh RemoteClient through the connection\n    // pool (reusing the existing SSH transport) and build a temporary\n    // remote project. Each RemoteClient gets its own server-side headless\n    // project, so there are no RPC routing conflicts with other projects.\n    let temp_project = if let Some(connection) = remote_connection_owned {\n        let remote_client = cx\n            .update(|cx| {\n                if !remote::has_active_connection(&connection, cx) {\n                    anyhow::bail!(\"cannot open repository on disconnected remote machine\");\n                }\n                Ok(remote_connection::connect_reusing_pool(connection, cx))\n            })?\n            .await?\n            .context(\"remote connection was canceled\")?;\n\n        cx.update(|cx| {\n            Project::remote(\n                remote_client,\n                app_state.client.clone(),\n                app_state.node_runtime.clone(),\n                app_state.user_store.clone(),\n                app_state.languages.clone(),\n                app_state.fs.clone(),\n                false,\n                cx,\n            )\n        })","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent_ui/src/thread_worktree_archive.rs#L392-L428","documentation":"Raised when opening an archived agent thread whose worktree lives on a remote (SSH) machine, but the pooled connection to that machine is no longer active. The code explicitly re-checks `remote::has_active_connection` before reusing the SSH transport from the connection pool; if the SSH session dropped, it refuses to build the temporary remote project.","triggerScenarios":"Opening a thread worktree archive (resuming/restoring an old thread) that references remote paths, while the SSH connection it was created over has since closed: network change, SSH timeout, remote host reboot, or Zed restarted without reconnecting.","commonSituations":"Resuming old threads after sleep/hibernate or switching networks; SSH keepalive timeout on idle connections; remote host unreachable (rebooted, DNS changed); opening archives from another machine.","solutions":["Reconnect to the remote host first (reopen the remote project / SSH panel) and wait for it to be active, then open the archived thread.","Verify the SSH host is reachable (`ssh <host>` in a terminal) and credentials/agent forwarding still work.","If the remote is gone for good, open the thread on a local copy of the worktree instead of the remote paths.","In code driving this path, check `remote::has_active_connection` before attempting the open and surface a reconnect prompt."],"exampleFix":"// before: assume the pooled connection is still usable\ncx.update(|cx| remote_connection::connect_reusing_pool(connection, cx))?.await?;\n\n// after: verify liveness first and fail with an actionable message\nif !remote::has_active_connection(&connection, cx) {\n    prompt_user_to_reconnect(&connection);\n    return Ok(None);\n}\ncx.update(|cx| remote_connection::connect_reusing_pool(connection, cx))?.await?;","handlingStrategy":"retry","validationCode":"// Before opening a remote-path thread archive:\nlet active = cx.update(|cx| remote::has_active_connection(&connection, cx));\nif !active {\n    // prompt reconnect instead of calling open\n}","typeGuard":null,"tryCatchPattern":"match open_archived_thread(&archive, cx).await {\n    Err(err) if err.to_string().contains(\"disconnected remote machine\") => {\n        reconnect_remote(&connection).await?; // then retry once\n        open_archived_thread(&archive, cx).await\n    }\n    result => result,\n}","preventionTips":["Check `remote::has_active_connection` before any pooled-connection reuse.","Prompt the user to reconnect SSH when resuming threads that reference remote paths.","Keep local mirrors of important remote worktrees if archives must open offline."],"tags":["remote","ssh","connection-pool","thread-archive","worktree"],"backgroundTag":"remote-connection-lost","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}