Skip to content

Fix public auth portal redirects for sign-in/up#36

Open
Huynhthuongg wants to merge 6 commits into
mainfrom
codex/fix-high-priority-bug-in-public-fallback-sfc4f4
Open

Fix public auth portal redirects for sign-in/up#36
Huynhthuongg wants to merge 6 commits into
mainfrom
codex/fix-high-priority-bug-in-public-fallback-sfc4f4

Conversation

@Huynhthuongg

@Huynhthuongg Huynhthuongg commented May 23, 2026

Copy link
Copy Markdown
Member

Summary by cubic

Fixes broken sign-in/up in public mode by routing auth to a new public portal when Clerk is disabled or missing. Adds a health page to verify env setup and a public-only router to keep users on safe pages.

  • Bug Fixes

    • Redirect '/sign-in' and '/sign-up' to '/auth' when VITE_AUTH_MODE=public or Clerk key is missing.
    • Public-only router blocks private pages and redirects '/chat*' to '/'.
    • Centralized auth/env detection in src/config/auth-mode.ts (authMode, isAuthEnabled, clerkConfig) and show a public app shell instead of an error when auth is off.
  • New Features

    • '/auth' portal linking to Clerk sign-in/up.
    • '/health-config' diagnostics with an env checklist; added docs_self_healing_process.md runbook.
    • Sandbox pages: '/mobile-dashboard', '/chat-static', '/termux-lab' (with command logs/suggestions), '/tools'.
    • Tidied tsconfig.json and fixed minor TS issues in chat components to clear CI typecheck errors.

Written for commit d88d3d7. Summary will update on new commits. Review in cubic

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

PR thiết lập hệ thống chế độ xác thực có cấu hình linh hoạt (clerk hoặc public), mở rộng định tuyến ứng dụng để hỗ trợ cả hai chế độ, bổ sung sáu trang UI mới và cập nhật type annotation cũng như tài liệu cấu hình.

Changes

Auth Mode Framework và Routing

Layer / File(s) Summary
Auth Mode Configuration Module
src/config/auth-mode.ts
Module mới định nghĩa AuthMode type (clerk | public), đọc VITE_AUTH_MODE từ env, xuất authMode, isClerkConfigured, isAuthEnabled, clerkConfig, và envChecklist để mô tả trạng thái các biến cấu hình.
App Router và Layout Integration
src/App.tsx
Import cấu hình auth, thay thế việc lấy Clerk keys từ env bằng clerkConfig, mở rộng Router() với các route /auth, /mobile-dashboard, /chat-static, /termux-lab, /tools, /health-config, thêm PublicOnlyRouter() cho chế độ public, và cập nhật logic App() để render theo trạng thái isAuthEnabled.
New Feature Pages
src/pages/auth-portal.tsx, src/pages/mobile-dashboard.tsx, src/pages/chat-static.tsx, src/pages/termux-lab.tsx, src/pages/tools-hub.tsx, src/pages/health-config.tsx
Sáu trang mới: AuthPortal (màn hình OAuth), MobileDashboard (dashboard mobile với toggle menu), ChatStaticPage (UI chat tĩnh), TermuxLab (trợ lý lệnh), ToolsHub (danh sách công cụ), HealthConfigPage (cấu hình auth runtime).
Type Annotation Refinements
src/components/chat-area.tsx, src/components/chat-sidebar.tsx
Cập nhật type annotation cho tham số callback: conv: any trong onSuccess xử lý cuộc trò chuyện và c: any trong callback lọc.
Configuration và Documentation
tsconfig.json, docs_self_healing_process.md
Triển khai cấu hình TypeScript sang dạng mảng nhiều dòng, loại bỏ phần references, thêm tài liệu mô tả quy trình tự động nhắc nhở cho cấu hình môi trường và artifact bị thiếu.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Chế độ auth linh hoạt đã đến,
Clerk hoặc public, tuỳ bạn chọn,
Sáu trang mới long lanh trổi dâu,
Health config giám sát từng bước,
Routing thông minh, type an toàn! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Tiêu đề chính xác mô tả thay đổi chính: thêm auth portal công khai và sửa chữa các luồng redirect cho sign-in/up khi chế độ public được bật hoặc Clerk không được cấu hình.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed Mô tả PR liên quan chặt chẽ đến các thay đổi trong mã nguồn - nó giải thích rõ các sửa lỗi liên quan đến auth portal, routing public-only, và các trang mới được thêm vào.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-high-priority-bug-in-public-fallback-sfc4f4
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/fix-high-priority-bug-in-public-fallback-sfc4f4
  • 🛠️ Aethon

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped Aethon/backend-api.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot

kilo-code-bot Bot commented May 23, 2026

Copy link
Copy Markdown

Kilo Code Review could not run — your account is out of credits.

Add credits or switch to a free model to enable reviews on this change.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
artifacts/sandbox-ai/src/components/chat-area.tsx (1)

285-289: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Bỏ any khỏi callback onSuccess để giữ an toàn kiểu cho conv.id (chat-area.tsx:285-289)

Ép conv: any làm mất kiểu trả về của mutation; khi dùng conv.id thì lỗi shape chỉ lộ ở runtime. Thay bằng kiểu suy luận/kiểu trả về tương ứng từ useCreateOpenaiConversation.

Đề xuất sửa nhanh
-        onSuccess: (conv: any) => {
+        onSuccess: (conv) => {
           queryClient.invalidateQueries({ queryKey: getListOpenaiConversationsQueryKey() });
           pendingRef.current = { message: content, forConvId: conv.id };
           navigate(`/chat/${conv.id}`);
         },

Ngoài ra, onSuccess: (conv: any) cũng xuất hiện ở artifacts/sandbox-ai/src/components/chat-sidebar.tsx (và có filter((c: any) => ...)).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@artifacts/sandbox-ai/src/components/chat-area.tsx` around lines 285 - 289,
The onSuccess callback currently types its parameter as conv: any which loses
compile-time guarantees for conv.id; update the handler to use the actual
mutation return type from useCreateOpenaiConversation (or infer it via
ReturnType/typeof from that hook) instead of any, e.g. change onSuccess: (conv:
any) => ... to onSuccess: (conv: CreateOpenaiConversationResult) => ... (or the
inferred type) so conv.id is statically typed, and apply the same replacement
for other occurrences (e.g., the onSuccess in chat-sidebar.tsx and any
filter((c: any) => ...) there) to remove all uses of any and preserve type
safety for IDs and shapes referenced inside the callbacks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@artifacts/sandbox-ai/src/components/chat-sidebar.tsx`:
- Around line 106-109: Remove the use of `any` in the `onSuccess` callback and
the `.filter((c: any) => ...)` predicate so TypeScript can infer the real
conversation type: update `onSuccess: (conv: any)` to `onSuccess: (conv)` (or to
the explicit Conversation type if available) and change `.filter((c: any) =>
...)` to `.filter((c) => ...)` (or `.filter((c: Conversation) => ...)`),
ensuring usages like `conv.id`, `c.title`, and `c.mode` are type-checked; keep
existing logic that calls
`queryClient.invalidateQueries(getListOpenaiConversationsQueryKey())`,
`setLocation(`/chat/${conv.id}`)`, and `onClose?.()`.

In `@artifacts/sandbox-ai/src/config/auth-mode.ts`:
- Around line 25-29: Status của mục VITE_CLERK_PUBLISHABLE_KEY hiện sử dụng
isClerkConfigured trực tiếp nên khi authMode === "public" vẫn có thể hiển thị
"missing"; update logic của trường status (tham chiếu
VITE_CLERK_PUBLISHABLE_KEY, required, status, isClerkConfigured, authMode) để
khi required === true thì trả về isClerkConfigured ? "ok" : "missing", còn khi
required === false thì trả về "ok" (hoặc một trạng thái không áp dụng) để tránh
báo đỏ sai ngữ cảnh.

In `@artifacts/sandbox-ai/src/pages/auth-portal.tsx`:
- Around line 12-13: The two CTA Link components that currently point to
"/sign-in" and "/sign-up" should respect the authentication feature flag: check
the isAuthEnabled boolean in the auth-portal component and, if false, either (A)
change the href targets to a safe page (e.g., "/auth" or "#") and add a disabled
style/aria-disabled attribute, or (B) keep the links but prevent navigation and
show a toast/modal informing the user that auth is disabled; update the Link
elements that render the "Tiếp tục với Google / GitHub" and "Tạo tài khoản mới"
buttons to branch on isAuthEnabled and implement the chosen behavior (disable +
message or conditional href) so clicks no longer loop back to /auth when auth is
off.

In `@artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx`:
- Line 18: Thẻ <nav> (the element with className "p-4 space-y-2 border-b
border-white/10") cần có thuộc tính id tương ứng với giá trị của aria-controls
để liên kết truy cập; xác định giá trị aria-controls đang dùng (ví dụ
"mobile-nav" hoặc giá trị trong component điều khiển) và thêm id="that-value"
vào thẻ nav trong component mobile-dashboard.tsx (tìm phần render chứa <nav
className="p-4 space-y-2 border-b border-white/10"> và thêm id trùng khớp).
- Line 10: The icon-only toggle button lacks an accessible name; update the
button (the element with onClick={() => setOpen((v) => !v)} and className="p-2
rounded-lg border border-white/20") to include an explicit accessible name by
adding an aria-label (e.g., "Open menu" / "Close menu") and connect its expanded
state by adding aria-expanded={open} (or equivalent state variable) so screen
readers know the control purpose and current state.

In `@artifacts/sandbox-ai/src/pages/termux-lab.tsx`:
- Line 13: The input for command editing (value bound to cmd and onChange
calling setCmd) lacks an accessible label; add either a visible <label> tied via
id/htmlFor to this input or an aria-label (for example "Command input" or
similar), ensuring the input element gets an id and the label or aria-label is
present so screen readers and assistive tech can identify the field.

In `@docs_self_healing_process.md`:
- Around line 3-27: Several headings in the document ("Goal", "1) Detect", "2)
Classify", "3) Notify owner", "4) Auto-remediation checklist", "5) Prevent
regressions") are missing a blank line after the heading which triggers
markdownlint MD022; fix by inserting a single empty line immediately after each
of those heading lines so each heading is followed by a blank line before the
next content line or list, ensuring the headings comply with MD022.

---

Outside diff comments:
In `@artifacts/sandbox-ai/src/components/chat-area.tsx`:
- Around line 285-289: The onSuccess callback currently types its parameter as
conv: any which loses compile-time guarantees for conv.id; update the handler to
use the actual mutation return type from useCreateOpenaiConversation (or infer
it via ReturnType/typeof from that hook) instead of any, e.g. change onSuccess:
(conv: any) => ... to onSuccess: (conv: CreateOpenaiConversationResult) => ...
(or the inferred type) so conv.id is statically typed, and apply the same
replacement for other occurrences (e.g., the onSuccess in chat-sidebar.tsx and
any filter((c: any) => ...) there) to remove all uses of any and preserve type
safety for IDs and shapes referenced inside the callbacks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2319ca05-ff1c-47d3-aaca-01d682545978

📥 Commits

Reviewing files that changed from the base of the PR and between 8a58d37 and 5a03294.

📒 Files selected for processing (12)
  • artifacts/sandbox-ai/src/App.tsx
  • artifacts/sandbox-ai/src/components/chat-area.tsx
  • artifacts/sandbox-ai/src/components/chat-sidebar.tsx
  • artifacts/sandbox-ai/src/config/auth-mode.ts
  • artifacts/sandbox-ai/src/pages/auth-portal.tsx
  • artifacts/sandbox-ai/src/pages/chat-static.tsx
  • artifacts/sandbox-ai/src/pages/health-config.tsx
  • artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx
  • artifacts/sandbox-ai/src/pages/termux-lab.tsx
  • artifacts/sandbox-ai/src/pages/tools-hub.tsx
  • artifacts/sandbox-ai/tsconfig.json
  • docs_self_healing_process.md

Comment thread artifacts/sandbox-ai/src/components/chat-sidebar.tsx
Comment thread artifacts/sandbox-ai/src/config/auth-mode.ts
Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx
Comment thread artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx
Comment thread artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx
Comment thread artifacts/sandbox-ai/src/pages/termux-lab.tsx Outdated
Comment thread docs_self_healing_process.md

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12 issues found across 12 files

Confidence score: 3/5

  • There is concrete user-impact risk: in artifacts/sandbox-ai/src/pages/auth-portal.tsx, public-mode CTA links to /sign-in and /sign-up can redirect back to /auth, creating a loop where users cannot proceed.
  • The highest-severity issue is accessibility in artifacts/sandbox-ai/src/pages/termux-lab.tsx (missing accessible name on an interactive input), which can block assistive-technology users and should be fixed before relying on this UI.
  • Additional medium-risk regressions are present, including public-mode routing in artifacts/sandbox-ai/src/App.tsx (/chat and /chat/:id redirecting to / and breaking CTA flow), plus broad i18n and test-coverage gaps across new UI surfaces.
  • Pay close attention to artifacts/sandbox-ai/src/pages/auth-portal.tsx, artifacts/sandbox-ai/src/pages/termux-lab.tsx, and artifacts/sandbox-ai/src/App.tsx - routing behavior and accessibility have the most direct end-user impact.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread artifacts/sandbox-ai/src/pages/termux-lab.tsx Outdated
Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx
Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx
Comment thread artifacts/sandbox-ai/src/pages/health-config.tsx
Comment thread artifacts/sandbox-ai/src/pages/termux-lab.tsx
Comment thread artifacts/sandbox-ai/src/App.tsx
Comment thread artifacts/sandbox-ai/src/App.tsx
Comment thread artifacts/sandbox-ai/src/pages/health-config.tsx
Comment thread artifacts/sandbox-ai/src/config/auth-mode.ts
Comment thread artifacts/sandbox-ai/src/App.tsx
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@vercel

vercel Bot commented May 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sanbox Ready Ready Preview, Comment May 23, 2026 7:06am

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 12 files

Confidence score: 3/5

  • There is meaningful merge risk because two high-severity findings are in user-critical areas: accessibility gaps in artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx and untested core auth/navigation flows in artifacts/sandbox-ai/src/App.tsx.
  • The missing aria-label and aria-expanded on the icon-only menu toggle in artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx can directly impact screen-reader usability and WCAG compliance.
  • artifacts/sandbox-ai/src/pages/auth-portal.tsx has multiple hardcoded user-facing strings (heading, description, button), which raises localization/regression risk but appears less merge-blocking than the accessibility and test-coverage concerns.
  • Pay close attention to artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx, artifacts/sandbox-ai/src/App.tsx, and artifacts/sandbox-ai/src/pages/auth-portal.tsx - fix accessibility attributes, add auth/navigation path tests, and replace hardcoded UI text with translation calls.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx">

<violation number="1" location="artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx:10">
P1: Custom agent: **Enforce Accessibility Standards (WCAG...)**

Icon-only menu toggle is missing `aria-label` and `aria-expanded` attributes required for screen-reader accessibility.</violation>
</file>

<file name="artifacts/sandbox-ai/src/App.tsx">

<violation number="1" location="artifacts/sandbox-ai/src/App.tsx:275">
P1: Custom agent: **Enforce Pragmatic Test Coverage**

Core auth/navigation logic added without test coverage for main success/failure paths</violation>
</file>

<file name="artifacts/sandbox-ai/src/pages/auth-portal.tsx">

<violation number="1" location="artifacts/sandbox-ai/src/pages/auth-portal.tsx:7">
P2: Custom agent: **Enforce i18n for User-Facing Strings**

User-facing heading text is hardcoded instead of using a translation function (t(), useTranslation, etc.).</violation>

<violation number="2" location="artifacts/sandbox-ai/src/pages/auth-portal.tsx:9">
P2: Custom agent: **Enforce i18n for User-Facing Strings**

User-facing description text is hardcoded instead of using a translation function.</violation>

<violation number="3" location="artifacts/sandbox-ai/src/pages/auth-portal.tsx:13">
P2: Custom agent: **Enforce i18n for User-Facing Strings**

User-facing button label is hardcoded instead of using a translation function.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx
Comment thread artifacts/sandbox-ai/src/App.tsx
Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx
Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx
Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 12 files

Confidence score: 2/5

  • High risk for merge right now: artifacts/sandbox-ai/src/pages/auth-portal.tsx has a concrete, high-confidence redirect loop in public mode where /sign-in and /sign-up route back to /auth, blocking users from reaching auth screens.
  • artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx includes hardcoded user-facing text instead of i18n keys, which is a user-visible quality/compliance gap and may create localization regressions.
  • artifacts/sandbox-ai/src/App.tsx duplicates routing logic between PublicOnlyRouter and Router, which is low-severity today but increases drift and regression risk as routes evolve.
  • Pay close attention to artifacts/sandbox-ai/src/pages/auth-portal.tsx, artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx, and artifacts/sandbox-ai/src/App.tsx - resolve the auth redirect loop first, then address localization and router drift.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread artifacts/sandbox-ai/src/pages/auth-portal.tsx
Comment thread artifacts/sandbox-ai/src/pages/mobile-dashboard.tsx
Comment thread artifacts/sandbox-ai/src/App.tsx

@Huynhthuongg Huynhthuongg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant