Dev#47
Conversation
📝 WalkthroughWalkthroughAdds centralized public environment validation and wires it into startup, Supabase, account deletion, privacy/profile UI, and build config. It also removes the AI chat local fallback path, updates login/auth/legal text, and adds preview/release documentation. ChangesEnvironment validation and configuration wiring
Estimated code review effort: 3 (Moderate) | ~30 minutes AI chat, login, auth errors, and legal values
Estimated code review effort: 2 (Simple) | ~15 minutes Preview readiness documentation
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/ai-chat/ai-chat-screen.tsx (1)
281-281: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winAdd a persisted assistant fallback on remote failures
The catch path only shows a transient dialog; the user message is already stored, so if that dialog is missed the transcript later shows an unanswered prompt with no explanation. Add a lightweight assistant reply or retry prompt so the history reflects the failure.🤖 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 `@components/ai-chat/ai-chat-screen.tsx` at line 281, The remote-failure catch path in ai-chat-screen.tsx only shows a transient dialog after addMessage(userMessage), so the conversation history can end up with an unanswered user prompt. Update the failure handling in the ai chat flow to also persist a lightweight assistant fallback message or retry prompt through the same message-adding path used by the chat transcript, so the failure is reflected even if the dialog is missed.
🤖 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 @.env.preview.example:
- Around line 2-9: The `.env.preview.example` template currently contains real
preview secrets and project identifiers instead of placeholders. Replace the
live values for EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY, EXPO_PUBLIC_SUPABASE_URL, and
EXPO_PUBLIC_SUPABASE_ANON_KEY with dummy/example placeholders, and keep
EXPO_PUBLIC_ACCOUNT_DELETION_URL empty or illustrative; use the tracked example
file only as a schema, with real Preview values supplied through EAS/environment
configuration rather than committed here.
In @.gitignore:
- Around line 37-38: The .gitignore entries for .env.preview.example and
.env.production.example are using ignore rules instead of negation, so these
template files remain untrackable. Update the .gitignore rules alongside
.env.example to negate these specific template filenames, ensuring they are
allowed through the broader .env.* ignore pattern and can be committed going
forward.
In `@app.json`:
- Around line 40-42: The splash screen image sizing in the app config is likely
incorrect because the Splash logo uses imageWidth set to 1, which makes it
effectively invisible. Update the splash configuration for the image entry in
app.json by changing the imageWidth value to an appropriate visible pixel size,
and verify the splash image still uses the intended image, imageWidth, and
resizeMode settings.
In `@app/`(auth)/login.tsx:
- Line 21: A commented-out prop is left in the login screen and should be
removed entirely. Delete the dead `showTemporaryOnboardingBackButton` line from
the `login` component in `login.tsx` rather than keeping it as a comment, since
the prop is optional and already defaults to false.
In `@components/ai-chat/ai-chat-screen.tsx`:
- Around line 325-336: The catch block in ai-chat-screen’s AI chat request
handler is swallowing the thrown error, which removes dev-time diagnostics and
makes RemoteJournalAssistantError cases impossible to distinguish. Update the
catch path to accept the error object and add __DEV__-only logging similar to
generateRemoteJournalResponse, preserving the existing requestIdRef.current
guard before showing the dialog. Make sure the log includes the actual error or
its code/message so empty_response, invalid_response, and remote_unavailable can
be diagnosed from the AiChatScreen flow.
In `@components/errors/configuration-error-screen.tsx`:
- Around line 19-21: The title text in ConfigurationErrorScreen is using a
nonstandard line-height class, while the component’s other text already follows
the convention. Update the Text element in configuration-error-screen.tsx to use
leading-6 instead of leading-8, keeping the existing styling and the component’s
title formatting consistent with the shared typography rule.
In `@docs/preview-smoke-test.md`:
- Around line 3-12: The status labels in the preview smoke test table are
overstating readiness by marking workstation-only validations as Passed. Update
the tracker in the preview smoke test document so CFG-01 through CFG-06 are
moved into a separate preflight section or relabeled as non-device checks, and
keep “Passed” reserved for the recorded device plus Preview APK scenario only.
Use the existing table entries and status column in the preview smoke test doc
to make the distinction clear.
In `@docs/preview-tester-guide.md`:
- Line 14: The tester verification step in the preview guide uses an imprecise
label; update the instruction in the preview tester guide to name the exact
Profile label testers should check, specifically using the concrete `Preview •
v1.0.0` wording. Keep the check tied to the existing app-name validation in the
guide so reviewers can clearly confirm the expected label without ambiguity.
In `@lib/environment.ts`:
- Around line 32-95: add unit tests for validatePublicEnvironment to cover every
branch that determines whether the app can boot, including missing required env
vars, invalid HTTPS URLs, the preview environment pk_live_ restriction, and the
localhost/http exception handled by isAllowedUrl; place tests so they exercise
the validatePublicEnvironment helper directly and verify both isValid=false
developerMessage cases and the valid environment return shape.
- Around line 42-51: The Clerk publishable key validation in environment.ts is
asymmetric: preview rejects pk_live_ but production does not reject pk_test_.
Update the validation logic around the rawClerkPublishableKey checks so the
Environment validation enforces the matching rule for production as well, using
the existing appEnvironment branch structure and the key helpers like
isClerkPublishableKey and the current preview restriction as the reference
point.
- Around line 1-30: Create a shared accessor in lib/environment.ts that returns
the validated public environment values or null so callers do not repeat
publicEnvironmentResult.isValid ? publicEnvironmentResult.environment.X : null.
Update the existing consumers in lib/supabase.ts,
lib/account/accountDeletionService.ts, app/legal/privacy-policy.tsx,
app/settings/privacy.tsx, and components/profile/profile-screen.tsx to use the
new helper, and keep the app/** route files free of inline
environment-derivation logic.
---
Outside diff comments:
In `@components/ai-chat/ai-chat-screen.tsx`:
- Line 281: The remote-failure catch path in ai-chat-screen.tsx only shows a
transient dialog after addMessage(userMessage), so the conversation history can
end up with an unanswered user prompt. Update the failure handling in the ai
chat flow to also persist a lightweight assistant fallback message or retry
prompt through the same message-adding path used by the chat transcript, so the
failure is reflected even if the dialog is missed.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3f27b2b2-f62a-4bd5-9fe5-7fc0c19b6cf3
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (25)
.env.example.env.preview.example.env.production.example.gitignoreapp.jsonapp/(auth)/login.tsxapp/_layout.tsxapp/legal/privacy-policy.tsxapp/settings/privacy.tsxcomponents/ai-chat/ai-chat-screen.tsxcomponents/auth/auth-utils.tscomponents/errors/configuration-error-screen.tsxcomponents/profile/profile-screen.tsxcontent/legal/legalVersions.tsdocs/environment-matrix.mddocs/preview-build-readiness.mddocs/preview-smoke-test.mddocs/preview-tester-guide.mddocs/release-configuration-audit.mdeas.jsonlib/account/accountDeletionService.tslib/environment.tslib/notifications.tslib/supabase.tspackage.json
💤 Files with no reviewable changes (1)
- components/auth/auth-utils.ts
| .env.preview.example | ||
| .env.production.example |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
New env template files are ignored instead of negated.
Lines 37-38 explicitly ignore .env.preview.example and .env.production.example, but these are template files with placeholder values (like .env.example), which is negated via !.env.example on line 41. As written, .env.* (line 39) already covers these filenames, and adding them as explicit ignores (rather than negations) means the new template files won't be trackable going forward.
🔧 Proposed fix
-.env.preview.example
-.env.production.example
.env.*
+!.env.preview.example
+!.env.production.example
!.env.example📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| .env.preview.example | |
| .env.production.example | |
| !.env.preview.example | |
| !.env.production.example |
🤖 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 @.gitignore around lines 37 - 38, The .gitignore entries for
.env.preview.example and .env.production.example are using ignore rules instead
of negation, so these template files remain untrackable. Update the .gitignore
rules alongside .env.example to negate these specific template filenames,
ensuring they are allowed through the broader .env.* ignore pattern and can be
committed going forward.
| "image": "./assets/images/splash-logo.png", | ||
| "imageWidth": 1, | ||
| "resizeMode": "contain", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
imageWidth: 1 likely a typo.
A splash image width of 1 renders as effectively invisible. This is probably meant to be a larger pixel value (e.g. 200).
🤖 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 `@app.json` around lines 40 - 42, The splash screen image sizing in the app
config is likely incorrect because the Splash logo uses imageWidth set to 1,
which makes it effectively invisible. Update the splash configuration for the
image entry in app.json by changing the imageWidth value to an appropriate
visible pixel size, and verify the splash image still uses the intended image,
imageWidth, and resizeMode settings.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/ai-chat/ai-chat-screen.tsx (1)
328-358: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRedundant duplicate failure notification (persisted bubble + modal).
On every failed request this now both (a) permanently persists a generic "I couldn't respond..." assistant bubble into the user's chat history via
addMessage, and (b) pops a destructive dialog with nearly the same message. SincechatMessagesis persisted (via the chat store's hydration/rehydrate wiring), repeated failures/retries will leave the conversation littered with duplicate boilerplate bubbles alongside the transient dialog shown for the same event.Consider keeping only one channel — e.g. drop the modal and rely on the persisted bubble (consistent with how successful responses render), or skip persisting the failure bubble and rely solely on the dialog.
♻️ Example: rely on persisted bubble only
- addMessage({ - content: "I couldn't respond just now. Please try again in a moment.", - createdAt: new Date().toISOString(), - id: createChatMessageId(), - role: "assistant", - userId, - }); - - showDialog({ - confirmText: "OK", - message: - "DearDiary AI could not respond right now. Your journal entries are still safe.", - title: "AI Chat unavailable", - variant: "destructive", - }); + addMessage({ + content: "I couldn't respond just now. Please try again in a moment.", + createdAt: new Date().toISOString(), + id: createChatMessageId(), + role: "assistant", + userId, + });🤖 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 `@components/ai-chat/ai-chat-screen.tsx` around lines 328 - 358, In ai-chat-screen.tsx, the catch block in the AI chat request flow is surfacing the same failure twice by both persisting an assistant message with addMessage and showing a destructive showDialog modal. Update the failure handling in this request path to use only one user-facing channel: either keep the persisted bubble and remove the dialog, or keep the dialog and avoid adding the fallback assistant message, so the chat history doesn’t accumulate duplicate boilerplate failures.
🤖 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.
Outside diff comments:
In `@components/ai-chat/ai-chat-screen.tsx`:
- Around line 328-358: In ai-chat-screen.tsx, the catch block in the AI chat
request flow is surfacing the same failure twice by both persisting an assistant
message with addMessage and showing a destructive showDialog modal. Update the
failure handling in this request path to use only one user-facing channel:
either keep the persisted bubble and remove the dialog, or keep the dialog and
avoid adding the fallback assistant message, so the chat history doesn’t
accumulate duplicate boilerplate failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 29bd3310-8fa1-45be-9f74-1a0b259f905d
📒 Files selected for processing (14)
.env.preview.exampleapp/(auth)/login.tsxapp/legal/privacy-policy.tsxapp/settings/privacy.tsxcomponents/ai-chat/ai-chat-screen.tsxcomponents/errors/configuration-error-screen.tsxcomponents/profile/profile-screen.tsxdocs/preview-smoke-test.mddocs/preview-tester-guide.mdlib/account/accountDeletionService.tslib/environment.tslib/supabase.tspackage.jsontests/environment.test.ts
💤 Files with no reviewable changes (1)
- app/(auth)/login.tsx
Summary by CodeRabbit