% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addins.R
\name{addin_fix_console_error}
\alias{addin_fix_console_error}
\title{Fix the last console error automatically}
\usage{
addin_fix_console_error()
}
\value{
Invisible \code{NULL} (called for side-effects).
}
\description{
After running code that produces an error in the R console, trigger this
addin (recommended shortcut: \code{Ctrl+Shift+F} / \code{Cmd+Shift+F}).
}
\details{
The addin attempts to recover the most recent error message using several
strategies, in order of priority:

\enumerate{
\item The \code{rlang} last-error store (\code{rlang::last_error()}), which captures
errors thrown by \pkg{rlang}-aware packages and the tidyverse.
\item Base R's \code{.Last.error} binding (set whenever an unhandled condition
reaches the top level).
\item The \code{.Last.error.trace} character vector written by some versions of
\pkg{rlang}.
}

The complete source file currently open in the editor is also sent to the LLM
as context.  The LLM returns the entire corrected file, with changed lines
annotated as \verb{# FIX: <reason>}.  A diff-style preview dialog lets you review
and edit the fix before applying it.

\strong{Workflow}
\enumerate{
\item Run code — error appears in console.
\item Trigger this addin.
\item Review the fix in the preview dialog → click \strong{Apply Fix}.
}

If no recent error is detected, a dialog explains the possible reasons and
suggests using \code{\link[=addin_fix_selected_error]{addin_fix_selected_error()}} instead.
}
\seealso{
\code{\link[=addin_fix_selected_error]{addin_fix_selected_error()}}, \code{\link[=llmcoder_setup]{llmcoder_setup()}}
}
