Skip to content

fix(blabsy): recover composer when a Blab fails to send#1037

Open
Bekiboo wants to merge 2 commits into
mainfrom
fix/blabsy-blab-send-error-handling
Open

fix(blabsy): recover composer when a Blab fails to send#1037
Bekiboo wants to merge 2 commits into
mainfrom
fix/blabsy-blab-send-error-handling

Conversation

@Bekiboo

@Bekiboo Bekiboo commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Description of change

sendTweet in the Blab composer set loading = true and only cleared it on the success path, with no error handling. When an image upload rejected (e.g. Firebase Storage quota exceeded, or a flaky mobile network), the promise rejected, the loading state was never reset, and the composer froze with no feedback — matching the reported "Blab stuck with 2+ images" behaviour (more images → higher chance one upload fails).

This wraps the send flow in try/catch: on failure it resets the loading state and shows an error toast, so the composer always recovers and the user can retry.

Note: this fixes the code defect (silent freeze / no feedback). It does not change the fact that uploads themselves fail when the w3ds-staging Storage bucket quota is exhausted — that's an infra issue (plan/quota) tracked separately.

Issue Number

closes #1025

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

Tested locally against the Firebase emulators (auth/firestore/storage), to work around the exhausted staging quota:

  • Happy path — posting a Blab with 2 images succeeds and both images appear in the feed (no multi-image-specific defect: each image gets a unique id → unique storage path, uploaded in parallel).
  • Failure path — temporarily denied Storage create in the rules to simulate the quota failure; confirmed the composer now shows an error toast ("Failed to send your Blab. Please try again.") and becomes usable again, instead of freezing silently.
  • pnpm exec tsc --noEmit passes.

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

Bug Fixes

  • Improved error handling for message sending operations, now providing explicit success confirmations with action links and clear failure notifications, replacing previous silent failures with transparent user feedback.

@Bekiboo Bekiboo self-assigned this Jun 15, 2026
@Bekiboo Bekiboo requested a review from coodos as a code owner June 15, 2026 05:47
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The sendTweet function in input.tsx now wraps tweet creation, Firestore addDoc/counter updates, and the success toast inside a try block. A new catch handler logs the error, resets loading to false, and displays a "Failed to send your Blab" toast error message.

Changes

sendTweet Error Handling

Layer / File(s) Summary
sendTweet try/catch and error toast
platforms/blabsy/client/src/components/input/input.tsx
Tweet construction, Firestore writes, and success toast are moved into a try block. A new catch handler logs the error, calls setLoading(false), and shows a failure toast instead of leaving failures unhandled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 A little rabbit tried to blab,
But Firestore gave a sudden jab.
Now catch swoops in with toast in paw,
"Failed to send!" — no silent flaw.
Errors logged, the state is clear,
Hoppy error handling is here! 🎉

🚥 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 The title directly addresses the main change: adding error recovery to the composer when Blab sending fails, which matches the core fix in the changeset.
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 The pull request description comprehensively covers all required sections: issue number, type of change, testing approach, and completed checklist items.

✏️ 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 fix/blabsy-blab-send-error-handling

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
platforms/blabsy/client/src/components/input/input.tsx (1)

106-107: ⚡ Quick win

Avoid the extra read: use tweetRef.id directly.

At Line 106, getDoc(tweetRef) is unnecessary for obtaining the ID. addDoc(...) already returns a ref with id, so this adds avoidable network latency.

Suggested change
-            const { id: tweetId } = await getDoc(tweetRef);
+            const tweetId = tweetRef.id;
🤖 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 `@platforms/blabsy/client/src/components/input/input.tsx` around lines 106 -
107, Remove the unnecessary getDoc() call at line 106 where the tweetId is
extracted. Since addDoc() already returns a DocumentReference with an id
property, directly access tweetRef.id instead of awaiting getDoc(tweetRef) and
destructuring the id from the result. Replace the destructuring assignment with
a simple const tweetId = tweetRef.id statement to eliminate the extra network
read and reduce latency.
🤖 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 `@platforms/blabsy/client/src/components/input/input.tsx`:
- Around line 99-104: The Promise.all at lines 99-104 treats addDoc and counter
updates (manageTotalTweets, manageTotalPhotos, manageReply) as equally critical.
When addDoc succeeds but a counter update fails, the entire operation fails in
the catch block at line 129, incorrectly telling the user the Blab failed to
send (causing duplicates on retry). Instead, separate the logic into two phases:
first, await only the addDoc call to confirm the Blab is saved (treat this
success as the canonical send success); then, separately fire off the
manageTotalTweets, manageTotalPhotos, and manageReply updates as best-effort
operations with their own error handling and logging, so their failures don't
block the user-visible send success.

---

Nitpick comments:
In `@platforms/blabsy/client/src/components/input/input.tsx`:
- Around line 106-107: Remove the unnecessary getDoc() call at line 106 where
the tweetId is extracted. Since addDoc() already returns a DocumentReference
with an id property, directly access tweetRef.id instead of awaiting
getDoc(tweetRef) and destructuring the id from the result. Replace the
destructuring assignment with a simple const tweetId = tweetRef.id statement to
eliminate the extra network read and reduce latency.
🪄 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

Run ID: ff2aedea-5547-4273-93f6-3f7962f5fe96

📥 Commits

Reviewing files that changed from the base of the PR and between 5f08b54 and 8d402b7.

📒 Files selected for processing (1)
  • platforms/blabsy/client/src/components/input/input.tsx

Comment thread platforms/blabsy/client/src/components/input/input.tsx Outdated
Addresses review feedback: addDoc and the counter updates ran together in
Promise.all, so if addDoc succeeded but manageTotalTweets/manageTotalPhotos
rejected, the catch reported "Failed to send" even though the Blab was
created — prompting a retry and duplicate Blabs while metrics drift.

Await addDoc on its own as the canonical send, then run the counter/reply
updates best-effort (logged, non-fatal). Also use tweetRef.id directly
instead of an extra getDoc round-trip, removing another post-send failure
point (and a read).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Blabsy: Blab with 2 attached images gets stuck and does not post from homepage

1 participant