{"record":{"id":"384aeb49ee4dd0b7","repo":"sinelaw/fresh","slug":"no-running-fresh-editor-for-session","errorCode":null,"errorMessage":"no running Fresh editor for session '{}'","messagePattern":"no running Fresh editor for session '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/main.rs","lineNumber":3564,"sourceCode":"            Ok(s) if !s.trim().is_empty() => s,\n            _ => anyhow::bail!(\n                \"not inside a Fresh session; set --session <id> (or run inside a \\\n                 Fresh workspace so $FRESH_SESSION is set)\"\n            ),\n        },\n    };\n\n    let socket_paths = resolve_session(Some(&session))?;\n    socket_paths.cleanup_if_stale();\n    match socket_paths.probe_server() {\n        ServerLiveness::Alive => Ok(socket_paths),\n        // Denied rather than absent. Say so, and say what to do: a caller that\n        // can re-run outside its sandbox (an agent with an escalation path)\n        // can act on this, whereas \"no running editor\" sends it hunting for a\n        // stale session that is in fact alive and well.\n        ServerLiveness::Unreachable => Err(socket_denied_error(&session, &socket_paths)),\n        ServerLiveness::Dead => {\n            anyhow::bail!(\"no running Fresh editor for session '{}'\", session)\n        }\n    }\n}\n\n/// How long a command-channel client waits for the editor to answer before\n/// giving up.\n///\n/// The default suits a command that answers within a frame — a query, a split,\n/// a dispatch. A command that *does* something slow before it can answer (a\n/// workspace create runs `git worktree add` and waits for the agent process to\n/// come up) passes its own, longer bound. Either way an explicit\n/// `FRESH_CMD_TIMEOUT_MS` wins, so a caller can always widen the wait without\n/// the CLI having to guess.\nfn cmd_reply_timeout_or(default: std::time::Duration) -> std::time::Duration {\n    std::env::var(\"FRESH_CMD_TIMEOUT_MS\")\n        .ok()\n        .and_then(|v| v.trim().parse::<u64>().ok())\n        .filter(|ms| *ms > 0)","sourceCodeStart":3546,"sourceCodeEnd":3582,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/main.rs#L3546-L3582","documentation":"resolve_cmd_socket probes the session's control socket; when liveness is Dead (socket exists but no live editor answers / editor has exited), it bails that no running Fresh editor exists for the session id. This distinguishes an exited editor from an unreachable (permission-blocked) socket.","triggerScenarios":"`fresh --session <id> --cmd ...` (or script run) where the editor that owned the session has terminated but the session id/socket is still referenced.","commonSituations":"Editor crashed or was closed between commands; stale scripts/aliases referencing an old session id; re-running a command from a saved history after the editor session ended; wrong session id that matches nothing running.","solutions":["Start (or restart) the Fresh editor for that session, then retry the command.","Verify the session id: `echo $FRESH_SESSION` inside the workspace shell, or list running fresh processes.","Remove stale socket state for the dead session if it blocks a new launch.","If you intended a live session but got this, check whether the sandbox is masking the socket (that case yields the socket-denied message instead)."],"exampleFix":"// before (editor already closed)\nfresh --session old-session --cmd quit\n// after\nfresh --session old-session main.rs   # restart editor first, then send commands","handlingStrategy":"retry","validationCode":"// probe liveness before sending commands\nconst { execSync } = require('child_process');\ntry { execSync(`pgrep -f 'fresh.*${session}'`, { stdio: 'ignore' }); }\ncatch { console.error(`No running editor for session ${session}; start it first`); process.exit(1); }","typeGuard":null,"tryCatchPattern":"// bash\nif ! fresh --session \"$S\" --cmd ping 2>/dev/null; then\n  echo \"editor for $S is down; restarting...\"\n  fresh --session \"$S\" . || exit 1\nfi","preventionTips":["Confirm the editor is alive before scripted command bursts.","Generate session ids once and store them alongside the editor process lifecycle.","Clean up dead-session sockets to avoid stale references.","Prefer reading $FRESH_SESSION from the live workspace shell over hardcoded ids."],"tags":["cli","session","ipc","stale-socket"],"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"}