Skip to content

Dev#47

Merged
aryansoni-dev merged 3 commits into
mainfrom
dev
Jul 3, 2026
Merged

Dev#47
aryansoni-dev merged 3 commits into
mainfrom
dev

Conversation

@aryansoni-dev

@aryansoni-dev aryansoni-dev commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added fail-closed environment validation for development/preview/production with a clear configuration error screen.
    • Preview builds now display a small “Preview • vX” label on the profile screen.
  • Bug Fixes
    • AI chat no longer falls back locally; it shows an “unavailable” message when responses can’t be generated.
    • Android notification setup order improved for reliability.
    • Privacy/account-deletion pages now use the configured public environment value.
  • Documentation
    • Added environment matrix, preview readiness, smoke-test, and tester guidance, plus a release configuration audit.
  • Tests
    • Added automated environment-configuration validation tests.
  • Chores
    • Updated environment example files and Expo/Android app configuration (slug, splash, and backup/permission handling).

    [+] Prepared DearDiary for preview build and release.
    [+] Added new environment files for preview and production.
    [+] Added documentation for preview build readiness, smoke testing, and tester guide.
    [+] Added documentation for release configuration audit.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Environment validation and configuration wiring

Layer / File(s) Summary
Public environment validation module
lib/environment.ts
Defines public environment types, validation helpers, the module-level validation result, and the validated environment accessor.
Startup gating and error screen
app/_layout.tsx, components/errors/configuration-error-screen.tsx
Root layout now renders a configuration error screen or initializes Clerk from the validated public environment.
Consumers of validated environment
lib/supabase.ts, lib/account/accountDeletionService.ts, app/legal/privacy-policy.tsx, app/settings/privacy.tsx, components/profile/profile-screen.tsx
Supabase, account deletion, privacy screens, and profile UI now read configuration from the validated public environment.
Env templates and app/build config
.env.example, .env.preview.example, .env.production.example, .gitignore, app.json, eas.json, package.json, lib/notifications.ts
Updates environment templates, ignores preview/production examples, and reshapes app, EAS, package, and notification configuration for preview and production builds.

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

AI chat, login, auth errors, and legal values

Layer / File(s) Summary
AI chat remote-only handling
components/ai-chat/ai-chat-screen.tsx, components/auth/auth-utils.ts
AI chat no longer uses the local journal fallback path, and non-Clerk errors always use the generic Clerk fallback message.
Login toggle and legal values
app/(auth)/login.tsx, content/legal/legalVersions.ts
The temporary onboarding back button is no longer enabled in login, and legal placeholder strings are replaced with concrete values.

Estimated code review effort: 2 (Simple) | ~15 minutes

Preview readiness documentation

Layer / File(s) Summary
Preview environment and release docs
docs/environment-matrix.md, docs/preview-build-readiness.md, docs/preview-smoke-test.md, docs/preview-tester-guide.md, docs/release-configuration-audit.md
Adds markdown documentation covering the environment matrix, preview build readiness, smoke testing, tester guidance, and the release configuration audit.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too generic and does not describe the actual changes in the pull request. Use a concise title that names the main change, such as environment validation and preview/production configuration updates.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 dev

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.

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

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between 103fd87 and 2611b35.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (25)
  • .env.example
  • .env.preview.example
  • .env.production.example
  • .gitignore
  • app.json
  • app/(auth)/login.tsx
  • app/_layout.tsx
  • app/legal/privacy-policy.tsx
  • app/settings/privacy.tsx
  • components/ai-chat/ai-chat-screen.tsx
  • components/auth/auth-utils.ts
  • components/errors/configuration-error-screen.tsx
  • components/profile/profile-screen.tsx
  • content/legal/legalVersions.ts
  • docs/environment-matrix.md
  • docs/preview-build-readiness.md
  • docs/preview-smoke-test.md
  • docs/preview-tester-guide.md
  • docs/release-configuration-audit.md
  • eas.json
  • lib/account/accountDeletionService.ts
  • lib/environment.ts
  • lib/notifications.ts
  • lib/supabase.ts
  • package.json
💤 Files with no reviewable changes (1)
  • components/auth/auth-utils.ts

Comment thread .env.preview.example
Comment thread .gitignore
Comment on lines +37 to +38
.env.preview.example
.env.production.example

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.

Suggested change
.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.

Comment thread app.json
Comment on lines +40 to 42
"image": "./assets/images/splash-logo.png",
"imageWidth": 1,
"resizeMode": "contain",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.

Comment thread app/(auth)/login.tsx Outdated
Comment thread components/ai-chat/ai-chat-screen.tsx Outdated
Comment thread docs/preview-smoke-test.md Outdated
Comment thread docs/preview-tester-guide.md Outdated
Comment thread lib/environment.ts Outdated
Comment thread lib/environment.ts Outdated
Comment thread lib/environment.ts

@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.

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 win

Redundant 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. Since chatMessages is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2611b35 and e8a4c46.

📒 Files selected for processing (14)
  • .env.preview.example
  • app/(auth)/login.tsx
  • app/legal/privacy-policy.tsx
  • app/settings/privacy.tsx
  • components/ai-chat/ai-chat-screen.tsx
  • components/errors/configuration-error-screen.tsx
  • components/profile/profile-screen.tsx
  • docs/preview-smoke-test.md
  • docs/preview-tester-guide.md
  • lib/account/accountDeletionService.ts
  • lib/environment.ts
  • lib/supabase.ts
  • package.json
  • tests/environment.test.ts
💤 Files with no reviewable changes (1)
  • app/(auth)/login.tsx

@aryansoni-dev aryansoni-dev merged commit 10d4520 into main Jul 3, 2026
1 check passed
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