{"record":{"id":"16c43fb5f6e19824","repo":"jlcodes99/cockpit-tools","slug":"message-16c43f","errorCode":null,"errorMessage":"message","messagePattern":"message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pages/useCodexAccountsLocalAccessController.tsx","lineNumber":927,"sourceCode":"            text: t(\"codex.localAccess.accountPoolHealth.recoverSuccess\", {\n              count: accountIds.length,\n              defaultValue: \"已提交 {{count}} 个账号的恢复操作\",\n            }),\n          });\n        } catch (error) {\n          console.error(\"Failed to recover local access accounts:\", error);\n          const message = String(error).replace(/^Error:\\s*/, \"\");\n          setMessage({\n            text: t(\"messages.actionFailed\", {\n              action: t(\n                \"codex.localAccess.accountPoolHealth.recover\",\n                \"恢复账号状态\",\n              ),\n              error: message,\n            }),\n            tone: \"error\",\n          });\n          throw new Error(message);\n        } finally {\n          setLocalAccessHealthActionBusy(false);\n        }\n      },\n      [localAccessHealthActionBusy, setMessage, t],\n    );\n  \n    const confirmHideLocalAccessEntry = useCallback(async () => {\n      if (localAccessHideSubmitting) return;\n      setLocalAccessHideSubmitting(true);\n      try {\n        if (localAccessCollection?.enabled) {\n          const nextState =\n            await codexLocalAccessService.setCodexLocalAccessEnabled(false);\n          setLocalAccessState(nextState);\n        }\n        await invoke(\"set_codex_local_access_entry_visible\", { enabled: false });\n        setLocalAccessEntryVisible(false);","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/pages/useCodexAccountsLocalAccessController.tsx#L909-L945","documentation":"A local-access health action in the Codex accounts controller (e.g. restoring account state) failed, and the resulting user-facing failure message is re-thrown as a generic Error via `throw new Error(message)`. The thrown value carries no error code; the message text is the localized status message that was also pushed to the toast/dialog. It signals that the requested local-access operation did not complete and callers (usually the `localAccessController` wrapper) must handle the rejection.","triggerScenarios":"Calling a local-access health action (like \"恢复账号状态\" / restore account state) through the `localAccessController` callback while `localAccessHealthActionBusy` is false but the underlying action rejects or returns a failure message; the catch path sets an error toast with the message and then re-throws it.","commonSituations":"A Codex account is in an inconsistent state that the restore action cannot fix; the Tauri backend command returns an error string; the user double-triggers an action and a stale busy/health state causes the operation to abort with a message.","solutions":["Read the `message` shown in the error toast next to \"恢复账号状态\" — it contains the backend's actual failure reason.","Re-run the local-access health check and retry the restore action once the previous operation has fully settled (busy flag reset).","Re-import a healthy Codex account for the current environment if the account state cannot be restored.","If it persists, inspect backend logs for the local-access command invocation that returned the failure."],"exampleFix":"// before\ncatch (err) {\n  setMessage({ text: err.message, tone: \"error\" });\n  throw err;\n}\n// after\ncatch (err) {\n  setMessage({ text: t(\"codex.localAccess.restoreFailed\", \"恢复账号状态失败\"), tone: \"error\" });\n  console.warn(\"local access restore failed\", err);\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"if (localAccessHealthActionBusy) return; // never start while a previous action is in flight","typeGuard":"function isLocalAccessError(err: unknown): err is Error & { message: string } {\n  return err instanceof Error && typeof err.message === \"string\" && err.message.length > 0;\n}","tryCatchPattern":"try {\n  await localAccessController(\"restore\");\n} catch (err) {\n  if (err instanceof Error) {\n    setMessage({ text: err.message, tone: \"error\" });\n  } else {\n    setMessage({ text: t(\"codex.localAccess.unknownError\"), tone: \"error\" });\n  }\n}","preventionTips":["Gate health actions behind the busy flag so overlapping invocations cannot race.","Always show the message from the caught Error to preserve the backend failure reason.","Run a health check before state-mutating actions."],"tags":["react","codex","local-access","account-state"],"backgroundTag":"local-access-action-failed","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}