Skip to content

Add Recent Drafts section and Drafts library tab#1219

Open
SajalChaplot wants to merge 3 commits into
mainfrom
ai_main_e7ce0f2d56ed4d349867
Open

Add Recent Drafts section and Drafts library tab#1219
SajalChaplot wants to merge 3 commits into
mainfrom
ai_main_e7ce0f2d56ed4d349867

Conversation

@SajalChaplot

@SajalChaplot SajalChaplot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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-assets server action queries candidate-role assets across accessible libraries. A RecentDraftsSection component 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 a drafts tab type that filters assets by role === "generated" && status === "candidate", and the tab is pre-selected when navigating via the ?tab=drafts URL 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 optional libraryId filter and configurable limit.
  • 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 a drafts tab type and isDraftAsset helper; updates assetMatchesTab so the generated tab excludes drafts; reads the ?tab= URL param on mount and syncs it to state; passes includeCandidates: true when the drafts tab is active; adds the "Drafts" TabsTrigger to the UI; adds status field to the Asset type.

Edit in Builder  Preview


To clone this PR locally use the Github CLI with command gh pr checkout 1219

You can tag me at @BuilderIO for anything you want me to fix or change

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@builder-io-integration builder-io-integration Bot changed the title Update from the Builder.io agent Add Recent Drafts section and Drafts library tab Jun 16, 2026
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Here's a visual recap of what changed:

Open the full interactive recap

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

builder-io-integration[bot]

This comment was marked as outdated.

@SajalChaplot

Copy link
Copy Markdown
Contributor Author

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

@builder-io-integration

Copy link
Copy Markdown
Contributor

There was a problem with your request, please try again later. Error id: 13e28aa54d104e79ab012671e19434a6

@SajalChaplot

Copy link
Copy Markdown
Contributor Author

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

@builder-io-integration

Copy link
Copy Markdown
Contributor

Reviewed the two bot comments — agreed with both, fixed both in the Drafts tab query (library.tsx):

  1. Video drafts excludedmediaType is now omitted when viewing Drafts, so image and video drafts show.
  2. Only latest run showncandidateRunIds is now omitted on the Drafts tab, so all unsaved drafts appear, not just the most recent batch.

Typecheck passes.

@builder-io-integration

Copy link
Copy Markdown
Contributor

Both PR review comments were valid, and I fixed both in the Drafts tab query (templates/assets/app/routes/library.tsx):

  1. Video drafts excluded — the query applied a default mediaType: "image" even on the Drafts tab, hiding video drafts that RecentDraftsSection would show. Now mediaType is omitted (undefined) when viewing Drafts, so both image and video drafts appear.

  2. Only the latest run showncandidateRunIds was passed regardless of tab, narrowing Drafts to the most recent generation batch. Now it's omitted on the Drafts tab, so all unsaved drafts appear.

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.



🟡 Both PR comments addressed and replied to; fixes are committed locally and need a push to update the PR.

@SajalChaplot

Copy link
Copy Markdown
Contributor Author

@builderio-bot ci/link and format check is failing. fix that

@builder-io-integration

Copy link
Copy Markdown
Contributor

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 (list-draft-assets.ts and library.tsx).

I ran Prettier --write on them and verified they now pass prettier --check. The reformatted files are staged and will update the PR on the next push.



🟢 Fixed the Prettier formatting failures in list-draft-assets.ts and library.tsx; both now pass the format check.

@builder-io-integration builder-io-integration 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.

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 mediaType constraint)
  • ✅ Drafts tab now shows all unsaved drafts, not just the latest batch (removed candidateRunIds filter)

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)

Comment on lines 810 to +822
() => ({
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,

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.

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

Fix in Builder

Comment on lines +685 to +687
useEffect(() => {
if (urlAssetTab) setAssetTab(urlAssetTab);
}, [urlAssetTab]);

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.

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

Fix in Builder

@SajalChaplot

Copy link
Copy Markdown
Contributor Author

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

@steve8708

Copy link
Copy Markdown
Contributor

@SajalChaplot can you post in #product-agent-native-feedback this issue, we can tag Milos in there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants