Skip to content

refactor: deal with misc todo comments in frontend - #178

Merged
didinele merged 3 commits into
mainfrom
refactor/misc-frontend
Jul 17, 2026
Merged

refactor: deal with misc todo comments in frontend#178
didinele merged 3 commits into
mainfrom
refactor/misc-frontend

Conversation

@didinele

@didinele didinele commented Jul 17, 2026

Copy link
Copy Markdown
Member

Closes #133

Summary by CodeRabbit

  • New Features
    • Added a global, dismissible error banner stack for background failures with 8-second auto-dismiss.
    • Added in-page error messaging for end/repost actions in AMA details.
  • Bug Fixes
    • Improved API error handling to preserve validation details and surface field-specific messages on form errors (AMA creation, grant submission).
    • Reduced banner noise for session-expired cases and refined when background refetch banners appear.
    • Enhanced first-load error UI with clearer messaging.
  • UI / Chores
    • Replaced dashboard placeholders (AMA tile icon, removed a TODO artifact).

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
chatsift-website Ready Ready Preview, Comment Jul 17, 2026 4:01pm

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f20eebe8-8dbb-4394-8de4-a85f9ac06e5b

📥 Commits

Reviewing files that changed from the base of the PR and between 03286a9 and 3324b8b.

📒 Files selected for processing (2)
  • apps/website/src/api/error.ts
  • apps/website/src/api/fetch.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/website/src/api/error.ts
  • apps/website/src/api/fetch.ts

📝 Walkthrough

Walkthrough

The website now preserves nested API validation errors, maps them to form fields, displays background failures through a global dismissible banner, improves action and initial-load error UI, and replaces dashboard placeholders with the AMA icon.

Changes

Error handling and dashboard updates

Layer / File(s) Summary
Validation error contracts and consumers
apps/website/src/api/error.ts, apps/website/src/api/fetch.ts, apps/website/src/app/dashboard/.../CreateAMAForm.tsx, apps/website/src/app/dashboard/.../AddGrantCard.tsx
APIError stores nested Zod field errors and resolves messages by path. API parsing forwards those errors, and dashboard forms use them for field-specific validation messages.
Shared Jotai store integration
apps/website/src/api/store.ts, apps/website/src/api/fetch.ts, apps/website/src/api/routes/auth.ts, apps/website/src/components/common/NavGate.tsx, apps/website/src/components/common/Providers.tsx
Client token reads, logout timestamps, redirect checks, and React state access now use one shared Jotai store instance.
Background error banner flow
apps/website/src/api/errorBanner.ts, apps/website/src/api/queryClient.ts, apps/website/src/components/common/ErrorBanner.tsx, apps/website/src/components/common/Providers.tsx
Background refetch failures with cached data are queued as banners, while 401 errors are excluded. Banners render globally, support manual dismissal, and expire after eight seconds.
Action and first-load error displays
apps/website/src/app/dashboard/.../AMADetails.tsx, apps/website/src/components/user/UserErrorHandler.tsx
AMA action failures now render messages, and first-load user errors display styled fallback or API messages while preserving the login response for 401 errors.
Dashboard placeholder replacement
apps/website/src/app/dashboard/[id]/ama/page.tsx, apps/website/src/app/dashboard/[id]/page.tsx
The AMA navigation tile now renders SvgAMA, and a leftover TODO is removed from the general settings card.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QueryCache
  participant errorBannerMessagesAtom
  participant ErrorBanner
  QueryCache->>errorBannerMessagesAtom: pushErrorBanner(message)
  errorBannerMessagesAtom-->>ErrorBanner: Provide queued messages
  ErrorBanner->>errorBannerMessagesAtom: dismissErrorBanner(id)
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also adds unrelated error handling, banner, store, query client, and form changes beyond the TODO cleanup. Split the unrelated frontend refactors into separate PRs or explain how each change supports #133.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related but too vague to identify the main change. Rename it to mention the dashboard TODO cleanup, e.g. "refactor: resolve dashboard TODO comments".
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The four files named in #133 were updated, matching the requested dashboard TODO cleanup scope.
✨ 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 refactor/misc-frontend

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

@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: 6

🤖 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 `@apps/website/src/api/error.ts`:
- Around line 5-7: Preserve the complete Zod treeified-error payload: in
apps/website/src/api/error.ts at lines 5-7 and 45-54, retain the root node’s
errors, properties, and items, and update fieldError(...) to traverse both
properties and items; in apps/website/src/api/fetch.ts at lines 34-41, forward
the complete error tree instead of passing only properties.

In
`@apps/website/src/app/dashboard/`[id]/ama/amas/[amaId]/_components/AMADetails.tsx:
- Around line 58-77: Prevent duplicate submissions in handleRepostPrompt and the
AMA-ending handler by guarding against in-flight mutations before invoking
mutateAsync. Disable the corresponding repost and end-confirmation controls
while their mutations are pending, and restore the controls after completion or
failure.
- Around line 80-86: Add role="alert" to the actionError paragraph in AMADetails
so failed actions are announced to screen readers while focus remains on the
triggering button; preserve the existing styling and conditional rendering.

In `@apps/website/src/app/dashboard/`[id]/settings/_components/AddGrantCard.tsx:
- Around line 32-41: Update the APIError handling in AddGrantCard so statuses
other than 404, 422, and 400 also call setError with a generic fallback or the
API-provided message before returning. Preserve the existing status-specific
messages and fieldError handling.

In `@apps/website/src/components/common/ErrorBanner.tsx`:
- Around line 17-19: Update the ErrorBanner container div to include a
live-region semantic such as role="status", ensuring newly rendered error
messages are announced to assistive technology while preserving the existing
styling and message content.

In `@apps/website/src/components/common/Providers.tsx`:
- Around line 16-18: Use one shared Jotai store for ErrorBanner state: update
apps/website/src/api/errorBanner.ts lines 16-22 to expose or reuse the store
instance, and pass that same instance to JotaiProvider in
apps/website/src/components/common/Providers.tsx lines 16-18. Ensure
pushErrorBanner and dismissErrorBanner continue writing to the store consumed by
ErrorBanner.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 59d5a5d0-d1a2-45dd-bab6-9684b6f09660

📥 Commits

Reviewing files that changed from the base of the PR and between fb4bc7c and b50f00b.

📒 Files selected for processing (12)
  • apps/website/src/api/error.ts
  • apps/website/src/api/errorBanner.ts
  • apps/website/src/api/fetch.ts
  • apps/website/src/api/queryClient.ts
  • apps/website/src/app/dashboard/[id]/ama/amas/[amaId]/_components/AMADetails.tsx
  • apps/website/src/app/dashboard/[id]/ama/amas/new/_components/CreateAMAForm.tsx
  • apps/website/src/app/dashboard/[id]/ama/page.tsx
  • apps/website/src/app/dashboard/[id]/page.tsx
  • apps/website/src/app/dashboard/[id]/settings/_components/AddGrantCard.tsx
  • apps/website/src/components/common/ErrorBanner.tsx
  • apps/website/src/components/common/Providers.tsx
  • apps/website/src/components/user/UserErrorHandler.tsx
💤 Files with no reviewable changes (1)
  • apps/website/src/app/dashboard/[id]/page.tsx

Comment thread apps/website/src/api/error.ts Outdated
Comment thread apps/website/src/components/common/ErrorBanner.tsx
Comment thread apps/website/src/components/common/Providers.tsx Outdated

@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: 1

🤖 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 `@apps/website/src/api/error.ts`:
- Around line 6-9: Update the ZodErrorTree interface in error.ts so properties
and items are optional and items accepts null entries, matching treeifyError()
and JSON payloads. Apply the same shape to the matching payload type in
fetch.ts, and widen fieldError()’s local node type to allow null values.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e57e4f26-7a2c-4a5c-8530-819c3ddfe9f6

📥 Commits

Reviewing files that changed from the base of the PR and between b50f00b and 03286a9.

📒 Files selected for processing (10)
  • apps/website/src/api/error.ts
  • apps/website/src/api/errorBanner.ts
  • apps/website/src/api/fetch.ts
  • apps/website/src/api/routes/auth.ts
  • apps/website/src/api/store.ts
  • apps/website/src/app/dashboard/[id]/ama/amas/[amaId]/_components/AMADetails.tsx
  • apps/website/src/app/dashboard/[id]/settings/_components/AddGrantCard.tsx
  • apps/website/src/components/common/ErrorBanner.tsx
  • apps/website/src/components/common/NavGate.tsx
  • apps/website/src/components/common/Providers.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/website/src/components/common/Providers.tsx
  • apps/website/src/api/errorBanner.ts
  • apps/website/src/components/common/ErrorBanner.tsx
  • apps/website/src/app/dashboard/[id]/ama/amas/[amaId]/_components/AMADetails.tsx
  • apps/website/src/app/dashboard/[id]/settings/_components/AddGrantCard.tsx
  • apps/website/src/api/fetch.ts

Comment thread apps/website/src/api/error.ts Outdated
@didinele
didinele merged commit 0afdf47 into main Jul 17, 2026
6 checks passed
@didinele
didinele deleted the refactor/misc-frontend branch July 17, 2026 16:02
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.

Resolve outstanding dashboard TODOs

1 participant