{"record":{"id":"12cca57a4d0ff80e","repo":"warpdotdev/warp","slug":"failed-to-revert-changes-to-file-name","errorCode":null,"errorMessage":"Failed to revert changes to {file_name}","messagePattern":"Failed to revert changes to (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/blocklist/inline_action/code_diff_view.rs","lineNumber":1056,"sourceCode":"            );\n            return;\n        }\n\n        let window_id = ctx.window_id();\n        for diff in &self.pending_diffs {\n            if let Err(err) = diff\n                .diff_view\n                .update(ctx, |v, ctx| v.restore_diff_base(ctx))\n            {\n                report_error!(anyhow::anyhow!(\"{err}\").context(\"Failed to restore diff base\"));\n                let file_name = diff\n                    .diff_view\n                    .as_ref(ctx)\n                    .file_name()\n                    .unwrap_or_else(|| \"file\".to_string());\n                ToastStack::handle(ctx).update(ctx, |toast_stack, ctx| {\n                    toast_stack.add_ephemeral_toast(\n                        DismissibleToast::error(format!(\"Failed to revert changes to {file_name}\")),\n                        window_id,\n                        ctx,\n                    );\n                });\n            }\n        }\n\n        self.state = CodeDiffState::Reverted;\n        self.mark_action_as_reverted(ctx);\n        ctx.notify();\n    }\n\n    fn mark_action_as_reverted(&self, ctx: &mut ViewContext<Self>) {\n        if let Some(conversation_id) = self.identifiers.client_conversation_id {\n            let action_id = self.action_id.clone();\n            BlocklistAIHistoryModel::handle(ctx).update(ctx, |history_model, ctx| {\n                if let Some(conversation) = history_model.conversation_mut(&conversation_id) {\n                    conversation.mark_action_as_reverted(action_id, ctx);","sourceCodeStart":1038,"sourceCodeEnd":1074,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/blocklist/inline_action/code_diff_view.rs#L1038-L1074","documentation":"During revert of a file's agent edit, `diff.diff_view.update(ctx, |v, ctx| v.restore_diff_base(ctx))` fails. The underlying error is reported to Sentry with context 'Failed to restore diff base', and a toast 'Failed to revert changes to {file_name}' is shown (file_name falls back to \"file\" when unavailable). The code then still sets CodeDiffState::Reverted and marks the action reverted, so UI state and disk state can diverge.","triggerScenarios":"`restore_diff_base` returns Err because the target file changed or disappeared on disk since the diff base was captured, the write is blocked by permissions or a read-only filesystem, or the stored diff base snapshot is invalid/missing.","commonSituations":"File edited outside Warp (editor, CLI, formatter) between the agent edit and the revert; file deleted or moved; branch switch or checkout invalidating paths; long-lived diff sessions over stale bases.","solutions":["Check whether the file still exists and is writable; reload it in the editor and retry the revert","Re-run the diff to capture a fresh base, then revert again","If the tooling cannot restore, revert manually (git checkout/restore the file) and mark the action reverted","Read the wrapped {err} in Sentry ('Failed to restore diff base' context) for the filesystem-level cause"],"exampleFix":"// before: revert blindly\nif let Err(err) = diff.diff_view.update(ctx, |v, ctx| v.restore_diff_base(ctx)) { /* toast */ }\n\n// after: verify the file is present first\nlet path = diff.diff_view.as_ref(ctx).file_path();\nif !path.as_ref().map(|p| p.is_file()).unwrap_or(false) {\n    toast(\"File missing on disk; revert manually\");\n} else if let Err(err) = diff.diff_view.update(ctx, |v, ctx| v.restore_diff_base(ctx)) {\n    toast(format!(\"Failed to revert changes to {file_name}\"));\n}","handlingStrategy":"try-catch","validationCode":"// Before reverting, confirm the file still exists and is writable.\nlet revert_ok = path\n    .as_ref()\n    .map(|p| p.is_file() && !p.metadata().map(|m| m.permissions().readonly()).unwrap_or(true))\n    .unwrap_or(false);\nanyhow::ensure!(revert_ok, \"File missing or read-only; cannot revert\");","typeGuard":null,"tryCatchPattern":"if let Err(err) = diff.diff_view.update(ctx, |v, ctx| v.restore_diff_base(ctx)) {\n    report_error!(anyhow::anyhow!(\"{err}\").context(\"Failed to restore diff base\"));\n    ToastStack::handle(ctx).update(ctx, |toast_stack, ctx| {\n        toast_stack.add_ephemeral_toast(\n            DismissibleToast::error(format!(\"Failed to revert changes to {file_name}\")),\n            window_id,\n            ctx,\n        );\n    });\n}","preventionTips":["Re-diff files that changed on disk before offering revert","Keep diff base snapshots immutable and versioned per action","Watch for external file changes and invalidate stale revert affordances"],"tags":["ui","diff","filesystem","revert"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}