Repository navigation
fix(design): make Design home search addressable so find-designs lands on the filtered list #9542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
7f53329
ecef321
5836dcc
8c768b2
3e8897d
097742b
363fd72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ const designLeftPanelSchema = z.enum([ | |
|
|
||
| export default defineAction({ | ||
| description: | ||
| "Navigate the UI to a specific view or path. Views: list, templates, editor, present, settings. Use --templateId with templates, --designId with editor/present views. For designs, use editorView=overview to show the infinite screens canvas, or editorView=single with fileId/filename/screen to focus a screen. Use leftPanel=file|agent|assets|tools|tokens|threads to focus the left rail (file is the panel labeled Layers, with screens and the layer tree; threads is the review comment threads panel). The inspector has no tabs, so inspectorTab is accepted and ignored; the legacy value extensions still opens Tools. Use tool to activate a design editor tool. In Interact mode, use interactDevice to pick the preview device and interactTheme=light|dark|system to pick the preview color scheme.", | ||
| "Navigate the UI to a specific view or path. Views: list, templates, editor, present, settings. Use --templateId with templates, --designId with editor/present views. Use view=list with --search to land on Design home filtered by that text (for example to show the designs matching a name), from any screen including an open editor. For designs, use editorView=overview to show the infinite screens canvas, or editorView=single with fileId/filename/screen to focus a screen. Use leftPanel=file|agent|assets|tools|tokens|threads to focus the left rail (file is the panel labeled Layers, with screens and the layer tree; threads is the review comment threads panel). The inspector has no tabs, so inspectorTab is accepted and ignored; the legacy value extensions still opens Tools. Use tool to activate a design editor tool. In Interact mode, use interactDevice to pick the preview device and interactTheme=light|dark|system to pick the preview color scheme.", | ||
| schema: z | ||
| .object({ | ||
| view: z | ||
|
|
@@ -116,6 +116,14 @@ export default defineAction({ | |
| .optional() | ||
| .describe("Saved or built-in template ID for templates view"), | ||
| path: z.string().optional().describe("URL path to navigate to"), | ||
| search: z | ||
| .string() | ||
| .trim() | ||
| .max(200) | ||
| .optional() | ||
| .describe( | ||
| "With view=list: filter Design home by this text (case-insensitive match on design titles)", | ||
| ), | ||
| intent: navigationIntentSchema, | ||
| }) | ||
| .superRefine((args, ctx) => { | ||
|
|
@@ -172,6 +180,7 @@ export default defineAction({ | |
| if (args.interactTheme) nav.interactTheme = args.interactTheme; | ||
| if (args.templateId) nav.templateId = args.templateId; | ||
| if (args.path) nav.path = args.path; | ||
| if (args.search) nav.search = args.search; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Allow identical search navigation commands to run againThis action writes the same
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deferred as non-critical after round 2; tracked in follow-up list (design search follow-ups: typed-search scope parity, route-state dedup of identical navigate commands, search arg with non-list views). |
||
| await writeAppStateForCurrentTab("navigate", nav); | ||
| return `Navigating to ${args.view || args.path}${ | ||
| args.designId ? ` (design: ${args.designId})` : "" | ||
|
|
@@ -181,7 +190,7 @@ export default defineAction({ | |
| args.fileId || args.screenId || args.filename || args.screen | ||
| ? ` (screen: ${args.fileId ?? args.screenId ?? args.filename ?? args.screen})` | ||
| : "" | ||
| }${args.tool ? ` (${args.tool} tool)` : ""}${ | ||
| }${args.search ? ` (search: ${JSON.stringify(args.search)})` : ""}${args.tool ? ` (${args.tool} tool)` : ""}${ | ||
| args.interactDevice ? ` (device: ${args.interactDevice})` : "" | ||
| }${args.interactTheme ? ` (theme: ${args.interactTheme})` : ""}`; | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,10 +179,13 @@ | |
| const isSaveTemplateGettingStarted = | ||
| searchParams.get("gettingStarted") === "save-template"; | ||
| const queryClient = useQueryClient(); | ||
| const [search, setSearch] = useState(""); | ||
| const [designFilter, setDesignFilter] = useState<DesignFilter>( | ||
| () => readStoredDesignFilter() ?? "mine", | ||
| ); | ||
| const urlSearch = searchParams.get("search") ?? ""; | ||
| const lastUrlSearchRef = useRef(urlSearch); | ||
| const [search, setSearch] = useState(urlSearch); | ||
| const [designFilter, setDesignFilter] = useState<DesignFilter>(() => { | ||
| const stored = readStoredDesignFilter() ?? "mine"; | ||
| return urlSearch.trim() && stored === "mine" ? "all" : stored; | ||
| }); | ||
| const [page, setPage] = useState(1); | ||
| const [deleteId, setDeleteId] = useState<string | null>(null); | ||
| const [bulkDeleteOpen, setBulkDeleteOpen] = useState(false); | ||
|
|
@@ -345,7 +348,7 @@ | |
| if (!hasAccessibleDesigns) { | ||
| if (isSaveTemplateGettingStarted || hasSearchResultsSection) return; | ||
| homeLibraryTabWasSelectedRef.current = false; | ||
| setHomeSection("templates"); | ||
| return; | ||
| } | ||
| if (homeLibraryTabWasSelectedRef.current) return; | ||
|
|
@@ -359,7 +362,7 @@ | |
| isSaveTemplateGettingStarted, | ||
| ]); | ||
| useEffect(() => { | ||
| if (hasSearchResultsSection) setHomeSection("recent"); | ||
| }, [hasSearchResultsSection]); | ||
| const { | ||
| data: templatesData, | ||
|
|
@@ -468,7 +471,7 @@ | |
| }, | ||
| ); | ||
| useEffect(() => { | ||
| const handleFirstRunCompleted = () => void homeSuggestionsProfile.refetch(); | ||
| window.addEventListener( | ||
| "agent-native:first-run-completed", | ||
| handleFirstRunCompleted, | ||
|
|
@@ -540,7 +543,7 @@ | |
| homeSuggestionRole, | ||
| createHomeSuggestionRandom(homeSuggestionSeed), | ||
| ), | ||
| [homeSuggestionsIdentityScope, homeSuggestionRole, homeSuggestionSeed], | ||
| ); | ||
| const homeSuggestions = selectedHomeSuggestionKeys.map( | ||
| ({ id, label, prompt }) => { | ||
|
|
@@ -586,7 +589,7 @@ | |
|
|
||
| useEffect(() => { | ||
| if (!designsData || page <= totalPages) return; | ||
| setPage(totalPages); | ||
| setSelectedDesignIds(new Set()); | ||
| }, [designsData, page, totalPages]); | ||
|
|
||
|
|
@@ -618,7 +621,7 @@ | |
| // Submitting navigates away, and unmounting discards every Figma | ||
| // attachment the context still holds; accepting hands the sent ones over. | ||
| const acceptHomeContext = useRef(homeContext.submissionAccepted); | ||
| acceptHomeContext.current = homeContext.submissionAccepted; | ||
|
|
||
| const toggleDesignSelection = useCallback((id: string) => { | ||
| setSelectedDesignIds((current) => { | ||
|
|
@@ -650,14 +653,38 @@ | |
| }); | ||
| }, [designs]); | ||
|
|
||
| const handleSearchChange = useCallback((query: string) => { | ||
| setSearch(query); | ||
| if (query.trim()) setHomeSection("recent"); | ||
| const handleSearchChange = useCallback( | ||
| (query: string) => { | ||
| setSearch(query); | ||
| if (query.trim()) setHomeSection("recent"); | ||
| setPage(1); | ||
| setSelectedDesignIds((current) => | ||
| current.size === 0 ? current : new Set(), | ||
| ); | ||
| lastUrlSearchRef.current = query; | ||
| const next = new URLSearchParams(searchParams); | ||
| if (query) next.set("search", query); | ||
| else next.delete("search"); | ||
| if (next.toString() !== searchParams.toString()) { | ||
| setSearchParams(next, { replace: true }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Keep typed search scope consistent with URL-restored searchesTyping a nonempty query writes the same
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deferred as non-critical after round 2; tracked in follow-up list (design search follow-ups: typed-search scope parity, route-state dedup of identical navigate commands, search arg with non-list views). |
||
| } | ||
| }, | ||
| [searchParams, setSearchParams], | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (lastUrlSearchRef.current === urlSearch) return; | ||
| lastUrlSearchRef.current = urlSearch; | ||
| setSearch(urlSearch); | ||
| if (urlSearch.trim()) { | ||
| setDesignFilter((current) => (current === "mine" ? "all" : current)); | ||
| } | ||
| if (urlSearch.trim()) setHomeSection("recent"); | ||
| setPage(1); | ||
| setSelectedDesignIds((current) => | ||
| current.size === 0 ? current : new Set(), | ||
| ); | ||
| }, []); | ||
| }, [urlSearch]); | ||
|
|
||
| const handleDesignFilterChange = useCallback( | ||
| (next: "all" | "mine" | "shared") => { | ||
|
|
@@ -1404,7 +1431,7 @@ | |
| <ClientOnly> | ||
| <DesignHomeLibrary | ||
| value={ | ||
| hasAccessibleDesigns && !homeLibraryTabWasSelectedRef.current | ||
|
Check warning on line 1434 in templates/design/app/pages/Index.tsx
|
||
| ? "recent" | ||
| : homeSection | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.