From 7c84c3b40c1091cf37a5a1ec55a467bab64c5abf Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Fri, 22 May 2026 15:41:45 +0000 Subject: [PATCH 1/5] Initial plan From f1a37dfc417caa122fc79c40aeee81349d397001 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Fri, 22 May 2026 15:54:29 +0000 Subject: [PATCH 2/5] Initial plan From 5f97e8ef370e483fc7ed1b6763bdec483b85f36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=E1=BB=B3nh=20Th=C6=B0=C6=A1ng?= Date: Sat, 23 May 2026 00:48:38 +0700 Subject: [PATCH 3/5] fix(sandbox-ai): graceful fallback when Clerk publishable key is missing --- artifacts/sandbox-ai/src/App.tsx | 46 +++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/artifacts/sandbox-ai/src/App.tsx b/artifacts/sandbox-ai/src/App.tsx index 3feaa26..7281a08 100644 --- a/artifacts/sandbox-ai/src/App.tsx +++ b/artifacts/sandbox-ai/src/App.tsx @@ -258,14 +258,54 @@ function ClerkProviderWithRoutes() { ); } + +function PublicOnlyRouter() { + return ( + + + + + + + + + + + + + + + + + + + + + ); +} + +function PublicAppWithoutAuth() { + return ( + + +
+ Auth is temporarily unavailable because VITE_CLERK_PUBLISHABLE_KEY is not configured. + Public pages are still available. +
+ + +
+
+ ); +} function App() { const [showSplash, setShowSplash] = useState(true); if (!clerkPubKey) { return ( -
- Missing VITE_CLERK_PUBLISHABLE_KEY — please check environment variables. -
+ + + ); } From 071a51c2f3ac80b55e6e086c66494341b251dea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=E1=BB=B3nh=20Th=C6=B0=C6=A1ng?= Date: Sat, 23 May 2026 00:55:32 +0700 Subject: [PATCH 4/5] feat(sandbox-ai): add auth mode switch and health-config diagnostics --- artifacts/sandbox-ai/src/App.tsx | 62 ++++++++++++++++++++++++++++++-- docs_self_healing_process.md | 27 ++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 docs_self_healing_process.md diff --git a/artifacts/sandbox-ai/src/App.tsx b/artifacts/sandbox-ai/src/App.tsx index 7281a08..dd2dc8c 100644 --- a/artifacts/sandbox-ai/src/App.tsx +++ b/artifacts/sandbox-ai/src/App.tsx @@ -28,6 +28,34 @@ const queryClient = new QueryClient(); const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY; const clerkProxyUrl = import.meta.env.VITE_CLERK_PROXY_URL; const basePath = import.meta.env.BASE_URL.replace(/\/$/, ""); +const requestedAuthMode = (import.meta.env.VITE_AUTH_MODE ?? "clerk").toLowerCase(); +const authMode = requestedAuthMode === "public" ? "public" : "clerk"; +const isClerkConfigured = Boolean(clerkPubKey); +const isAuthEnabled = authMode === "clerk" && isClerkConfigured; + +const envChecklist = [ + { + key: "VITE_AUTH_MODE", + value: import.meta.env.VITE_AUTH_MODE, + required: false, + status: "info" as const, + hint: "Optional. Use 'clerk' (default) or 'public'.", + }, + { + key: "VITE_CLERK_PUBLISHABLE_KEY", + value: clerkPubKey, + required: authMode === "clerk", + status: isClerkConfigured ? ("ok" as const) : ("missing" as const), + hint: "Required when VITE_AUTH_MODE=clerk.", + }, + { + key: "VITE_CLERK_PROXY_URL", + value: clerkProxyUrl, + required: false, + status: "info" as const, + hint: "Optional proxy URL for Clerk.", + }, +]; function stripBase(path: string): string { return basePath && path.startsWith(basePath) @@ -198,6 +226,33 @@ function ClerkAuthTokenSetter() { return null; } + +function HealthConfigPage() { + return ( +
+

Health Config

+

+ Runtime auth mode: {authMode}. Auth enabled: {String(isAuthEnabled)}. +

+
+ {envChecklist.map((item) => ( +
+
+ {item.key} + + {item.status === "ok" ? "✅ configured" : item.status === "missing" ? "❌ missing" : "ℹ️ optional"} + +
+
required: {String(item.required)}
+
value: {item.value ? "set" : "empty"}
+
{item.hint}
+
+ ))} +
+
+ ); +} + function Router() { return ( @@ -207,6 +262,7 @@ function Router() { + @@ -267,6 +323,7 @@ function PublicOnlyRouter() { + @@ -289,8 +346,7 @@ function PublicAppWithoutAuth() {
- Auth is temporarily unavailable because VITE_CLERK_PUBLISHABLE_KEY is not configured. - Public pages are still available. + Auth is running in public mode. Open /health-config to inspect environment readiness.
@@ -301,7 +357,7 @@ function PublicAppWithoutAuth() { function App() { const [showSplash, setShowSplash] = useState(true); - if (!clerkPubKey) { + if (!isAuthEnabled) { return ( diff --git a/docs_self_healing_process.md b/docs_self_healing_process.md new file mode 100644 index 0000000..0403d9f --- /dev/null +++ b/docs_self_healing_process.md @@ -0,0 +1,27 @@ +# Self-healing reminder workflow (OpenClaw/Eios style) + +## Goal +Automatically remind maintainers when deployment-critical configuration or code artifacts are missing. + +## 1) Detect +- On every deploy, open `/health-config` and validate required env keys. +- On CI, run `pnpm --filter @workspace/sandbox-ai run build` and fail on errors. + +## 2) Classify +- **Config missing** (e.g. `VITE_CLERK_PUBLISHABLE_KEY` when `VITE_AUTH_MODE=clerk`). +- **Artifact missing** (route/page/module referenced but not found). +- **Type/build breakage** (TypeScript/build errors). + +## 3) Notify owner +- Config missing -> notify DevOps/release owner. +- Artifact missing -> notify feature owner/repo maintainer. +- Build/type breakage -> notify author of latest PR and reviewer. + +## 4) Auto-remediation checklist +- If auth env missing in non-production: set `VITE_AUTH_MODE=public` as temporary fallback. +- If auth env missing in production: block release and require secret injection. +- If artifact missing: create placeholder file + TODO with owner and deadline. + +## 5) Prevent regressions +- Add a PR checklist item: “Did you verify `/health-config` and auth mode behavior?” +- Keep a short runbook for required variables per environment. From eb7024eda2943461a7600f26c2ed45ffc71f0085 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Sat, 23 May 2026 06:49:08 +0000 Subject: [PATCH 5/5] Initial plan