Add Recent Drafts section and Drafts library tab#1219
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Here's a visual recap of what changed: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@builderio-bot look at latest PR feedback and fix anything you agree with. Be skeptical. Reply to every comment if you fixed it or not and why. |
|
There was a problem with your request, please try again later. Error id: |
|
@builderio-bot look at latest PR feedback and fix anything you agree with. Be skeptical. Reply to every comment if you fixed it or not and why. |
|
Reviewed the two bot comments — agreed with both, fixed both in the Drafts tab query (
Typecheck passes. |
|
Both PR review comments were valid, and I fixed both in the Drafts tab query (
I replied to each review comment explaining the fix, posted a PR summary, and typecheck passes. The changes haven't been pushed yet — they'll go up on the next push. ⠀ |
|
@builderio-bot ci/link and format check is failing. fix that |
|
Only the Lint & format check was failing — there's no separate "link" check (the user meant "lint"). The failure was Prettier formatting on my two changed files ( I ran Prettier ⠀ |
There was a problem hiding this comment.
Builder reviewed your changes and found 2 potential issues 🟡
Review Details
Incremental Code Review — PR #1219
Good News: The two critical issues from the previous review have been fixed:
- ✅ Drafts tab now includes both image and video drafts (removed
mediaTypeconstraint) - ✅ Drafts tab now shows all unsaved drafts, not just the latest batch (removed
candidateRunIdsfilter)
New Issues Found: 3 items identified in the updated implementation.
Issues in Updated Code
🟡 MEDIUM — Drafts tab fetches entire library instead of filtering server-side (line 810-823)
The Drafts branch removes mediaType and candidateRunIds filters, but never adds server-side status/role filters. The list-assets action still queries every asset in the library, then client-side assetMatchesTab() filters to drafts. This causes performance degradation on large libraries (unnecessary DB/serialization load).
🟡 MEDIUM — Asset tab state stays on Drafts after URL param removed (line 685-687)
The urlAssetTab sync effect only updates when the param is truthy. Navigating from /library?tab=drafts to /library leaves assetTab stuck on "drafts" because the effect doesn't handle the null case. Breaks back/forward navigation and deep-linking.
🔵 LOW — View all drafts links to single-library view despite cross-library home query (RecentDraftsSection line 33)
Home page Recent Drafts fetches across all accessible libraries, but "View all drafts" navigates to /library?tab=drafts which scopes to a single selectedLibraryId. Users can see a draft on home page but not find it in the Library view if it belongs to a different library.
Strengths
✅ Good comments added explaining intent (lines 812, 818)
✅ Dependency arrays properly updated with viewingDrafts
✅ URL parameter parsing logic sound
✅ Database queries and access controls still correct
🧪 Browser testing: Completed in previous review — 12/13 test cases passed (first run scope, full testing)
| () => ({ | ||
| libraryId: selectedLibraryId, | ||
| mediaType, | ||
| // Drafts can be images or videos, so don't constrain by media type there. | ||
| mediaType: viewingDrafts ? undefined : mediaType, | ||
| query: query.trim() || undefined, | ||
| includeCandidates: | ||
| mediaType === "image" && visibleCandidateRunIds.length > 0, | ||
| viewingDrafts || | ||
| (mediaType === "image" && visibleCandidateRunIds.length > 0), | ||
| // The Drafts tab shows every unsaved draft, not just the latest run batch. | ||
| candidateRunIds: | ||
| visibleCandidateRunIds.length > 0 ? visibleCandidateRunIds : undefined, | ||
| !viewingDrafts && visibleCandidateRunIds.length > 0 | ||
| ? visibleCandidateRunIds | ||
| : undefined, |
There was a problem hiding this comment.
🟡 Drafts tab fetches entire library instead of filtering server-side
When viewingDrafts is true, the request omits mediaType and candidateRunIds, but never adds server-side draft filters (status: "candidate", role: "generated"). This causes list-assets to query every asset in the library, then filters drafts on the client. For large libraries, this is a performance regression. Consider sending draft filters server-side or using list-draft-assets action instead.
| useEffect(() => { | ||
| if (urlAssetTab) setAssetTab(urlAssetTab); | ||
| }, [urlAssetTab]); |
There was a problem hiding this comment.
🟡 Asset tab state stays on Drafts after URL param removed
The effect only updates state when urlAssetTab is truthy, so navigating from /library?tab=drafts to /library leaves assetTab stuck on "drafts" (because React Router keeps the component mounted on search param changes). This breaks back/forward navigation. Fix: use setAssetTab(urlAssetTab ?? "all") to reset when the param is absent.
|
@steve8708 can you share how do I generate a deployed preview. I am trying to connect Builder account in fusion preview, but it is throwing error, so I am unable to test this change. I need to generate image/asset for this one. |
|
@SajalChaplot can you post in #product-agent-native-feedback this issue, we can tag Milos in there |
Summary
Adds a "Recent Drafts" section below the home prompt box showing the 5 most recently AI-generated candidate assets, and introduces a new "Drafts" tab in the Library view to house all unsaved draft generations.
Problem
There was no quick way for users to revisit AI-generated assets that hadn't been saved yet. Unsaved draft generations were mixed in with other assets in the library with no dedicated view, making them hard to find.
Solution
A new
list-draft-assetsserver action queries candidate-role assets across accessible libraries. ARecentDraftsSectioncomponent renders the 5 most recent drafts below the home prompt box with a "View all drafts" link pointing to the library's new Drafts tab. The library route gains adraftstab type that filters assets byrole === "generated" && status === "candidate", and the tab is pre-selected when navigating via the?tab=draftsURL parameter.Key Changes
actions/list-draft-assets.ts– New server action that fetches unsaved draft assets (role = "generated",status = "candidate") across accessible libraries, ordered newest first, with an optionallibraryIdfilter and configurablelimit.RecentDraftsSection.tsx– New React component that displays up to 5 recent drafts as a thumbnail grid with skeleton loading states, image/video thumbnail support, and a "View all drafts" button linking to/library?tab=drafts._index.tsx– Renders<RecentDraftsSection />below the prompt box on the home page.library.tsx– Adds adraftstab type andisDraftAssethelper; updatesassetMatchesTabso thegeneratedtab excludes drafts; reads the?tab=URL param on mount and syncs it to state; passesincludeCandidates: truewhen the drafts tab is active; adds the "Drafts"TabsTriggerto the UI; addsstatusfield to theAssettype.To clone this PR locally use the Github CLI with command
gh pr checkout 1219You can tag me at @BuilderIO for anything you want me to fix or change