From 4a34dc69f544460e7893b04dbfd002f1c67125ae Mon Sep 17 00:00:00 2001 From: Guilhem Date: Tue, 27 Oct 2026 00:43:44 +0100 Subject: [PATCH] feat: show the draft badge on Home's favorite and recent cards (#12018) * feat: show the draft badge on Home's favorite and recent cards Co-Authored-By: Claude Opus 5.5 (1M context) * fix: show the draft badge on Home's agent cards Co-Authored-By: Claude Opus 5.5 (1M context) --------- Co-authored-by: Claude Opus 5.5 (1M context) --- .../components/home/HomeQuickAccess.svelte | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/home/HomeQuickAccess.svelte b/frontend/src/lib/components/home/HomeQuickAccess.svelte index b81f848838..7b181eb4d3 100644 --- a/frontend/src/lib/components/home/HomeQuickAccess.svelte +++ b/frontend/src/lib/components/home/HomeQuickAccess.svelte @@ -18,11 +18,13 @@ import { Button } from '$lib/components/common' import DropdownV2 from '$lib/components/DropdownV2.svelte' import { useEditRights } from '$lib/operatorWriteRights' - import { roleCapabilities } from '$lib/stores' + import { roleCapabilities, userStore } from '$lib/stores' import { AppService } from '$lib/gen' import { copyToClipboard, type Item } from '$lib/utils' import RowIcon from '$lib/components/common/table/RowIcon.svelte' + import DraftBadge from '$lib/components/DraftBadge.svelte' import Star from '$lib/components/Star.svelte' + import { useWorkspaceDrafts, type DraftItem } from '$lib/workspaceDrafts.svelte' import TimeAgo from '$lib/components/TimeAgo.svelte' import { favoriteManager, @@ -213,6 +215,27 @@ via: r.via })) }) + // The cards know only kind and path, so their drafts come from the workspace's draft list, + // keyed the way favorites are: a raw app's card can be an `app` one, its draft is `raw_app`. + // An agent is a resource and drafts as one; no other resource can sit at its path. + // The list holds the user's own drafts and legacy ones, so an item only another user drafted + // shows its badge in the list below but not on its card. + const drafts = useWorkspaceDrafts(() => workspace) + function cardKind(kind: DraftItem['kind']): FavoriteKind | undefined { + if (kind === 'script' || kind === 'flow' || kind === 'app' || kind === 'raw_app') { + return asStarKind(kind) + } + return kind === 'resource' ? 'agent' : undefined + } + let draftByItem = $derived( + new Map( + drafts.items.flatMap((d) => { + const kind = cardKind(d.kind) + return kind ? [[`${kind}/${d.path}`, d]] : [] + }) + ) + ) + // Grows by a page from the "Load next" card; back to one page on the next visit. let recentLimit = $state(RECENT_COUNT) let recentMore = $derived(Math.max(0, recentAll.length - recentLimit)) @@ -334,6 +357,7 @@ {#snippet card(item: Entry, favorite: boolean)} + {@const draft = draftByItem.get(`${item.starKind}/${item.path}`)}
@@ -363,6 +387,21 @@ tabindex="-1" aria-hidden="true" > + + {#if draft} + + + + {/if} {#if !favorite && item.at}