{"record":{"id":"29638acb26e6fe0e","repo":"sinelaw/fresh","slug":"cannot-save-remote-connection-lost","errorCode":null,"errorMessage":"Cannot save: remote connection lost ({})","messagePattern":"Cannot save: remote connection lost \\((.+?)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/fresh-editor/src/app/file_operations.rs","lineNumber":50,"sourceCode":"        .iter()\n        .filter(|(_, state)| {\n            state.buffer.is_modified()\n                && state\n                    .buffer\n                    .file_path()\n                    .map(|p| p.as_os_str().is_empty())\n                    .unwrap_or(true)\n        })\n        .map(|(id, _)| *id)\n        .collect()\n}\n\nimpl Editor {\n    /// Save the active buffer\n    pub fn save(&mut self) -> anyhow::Result<()> {\n        // Fail fast if remote connection is down\n        if !self.authority().filesystem.is_remote_connected() {\n            anyhow::bail!(\n                \"Cannot save: remote connection lost ({})\",\n                self.authority()\n                    .filesystem\n                    .remote_connection_info()\n                    .unwrap_or(\"unknown host\")\n            );\n        }\n\n        let path = self\n            .active_state()\n            .buffer\n            .file_path()\n            .map(|p| p.to_path_buf());\n\n        match self.active_state_mut().buffer.save() {\n            Ok(()) => self.finalize_save(path),\n            Err(e) => {\n                if let Some(sudo_info) = e.downcast_ref::<SudoSaveRequired>() {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/file_operations.rs#L32-L68","documentation":"save fails fast when the remote filesystem connection is down, before attempting to write the buffer, because the write would either time out or produce a confusing I/O error. The host info is included when known.","triggerScenarios":"Calling Editor::save (from handle_action, handle_prompt_confirm_input, or handle_confirm_close_buffer) while authority().filesystem.is_remote_connected() is false.","commonSituations":"Pressing Ctrl+S after an SSH drop; closing a buffer with a pending save prompt during a network outage; saving on laptop sleep/resume where the remote session died.","solutions":["Reconnect the remote session, then retry the save.","Before saving (especially on close), check is_remote_connected() and warn the user so edits aren't lost.","Offer a local fallback save (e.g. write to a temp file) when the remote is unreachable."],"exampleFix":"// before\nif editor.buffer_is_modified(id) { editor.save()?; } // may bail on disconnect\n// after\nif editor.buffer_is_modified(id) {\n    if !editor.filesystem().is_remote_connected() { editor.reconnect_remote()?; }\n    editor.save()?;\n}","handlingStrategy":"validation","validationCode":"if !editor.filesystem().is_remote_connected() { editor.reconnect_remote()?; } // then save","typeGuard":null,"tryCatchPattern":"match editor.save() { Err(e) if e.to_string().starts_with(\"Cannot save: remote connection lost\") => { backup_to_local_tmp(buffer); notify_user(); } r => r }","preventionTips":["Check connection state before save, especially on buffer close","Keep a local emergency copy of dirty remote buffers","Monitor remote health and reconnect proactively"],"tags":["remote","network","save"],"backgroundTag":"connection-refused","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}