Awesome Reviewers

When an action can fail or an environment can change, ensure error handling preserves user state, prevents incorrect side effects, and recovers automatically.

Apply this checklist: 1) Pre-flight validations before mutation

2) Only transition/cleanup after success is confirmed

3) Restore UI/event side effects on all exit paths

4) Implement recovery for transient failures

5) Test failure scenarios explicitly

Example pattern (state changes only after success):

async function onCommit() {
  // pre-flight checks
  if (!canCommit) return;

  const ok = await onAction({ type: "commit", message: trimmed, push });
  if (ok) setMessage(""); // only clear on success
}
async function onResume(sessionId: string) {
  // If resume fails, keep the remote/cloud session attached.
  const ok = await localRestore(sessionId);
  if (ok) detachCloudSession();
}