Skip to content

fix: ctrl k not showing navigation items + improve ai button by making it an item in the menu #6132

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions frontend/src/lib/components/search/GlobalSearchModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
Route,
Search,
SearchCode,
Unplug
Unplug,
WandSparkles
} from 'lucide-svelte'
import Portal from '$lib/components/Portal.svelte'

Expand Down Expand Up @@ -293,8 +294,7 @@
}

if (tab === 'default') {
if (searchTerm === '')
itemMap['default'] = fuzzyFilter(searchTerm, defaultMenuItems, defaultMenuItemLabels)
if (searchTerm === '') itemMap['default'] = defaultMenuItems
else
itemMap['default'] = fuzzyFilter(
searchTerm,
Expand Down Expand Up @@ -372,9 +372,6 @@
}
}
}
if ((itemMap[tab] ?? []).length === 0 && searchTerm.length > 0 && event.key === 'Enter') {
askAiButton?.onClick()
}
}
}

Expand Down Expand Up @@ -653,10 +650,14 @@
<div class="overflow-y-auto relative {maxModalHeight(tab)}">
{#if tab === 'default' || tab === 'switch-mode'}
{@const items = (itemMap[tab] ?? []).filter((e) =>
defaultMenuItemsWithHidden.includes(e)
defaultMenuItemsWithHidden.some((x) => e.search_id === x.search_id)
)}
{#if items.length > 0}
<div class={tab === 'switch-mode' ? 'p-2' : 'p-2 border-b'}>
<div
class={tab === 'switch-mode' || itemMap[tab].length === items.length
? 'p-2'
: 'p-2 border-b'}
>
{#each items as el}
<QuickMenuItem
onselect={(shift) => el?.action(shift)}
Expand All @@ -674,8 +675,8 @@
{/if}

{#if tab === 'default'}
<div class="p-2">
{#if (itemMap[tab] ?? []).filter((e) => (combinedItems ?? []).includes(e)).length > 0}
{#if (itemMap[tab] ?? []).filter((e) => (combinedItems ?? []).includes(e)).length > 0}
<div class="p-2">
<div class="py-2 px-1 text-xs font-semibold text-tertiary">
Flows/Scripts/Apps
</div>
Expand All @@ -694,19 +695,28 @@
bind:mouseMoved
/>
{/each}
{/if}
</div>
{/if}

{#if (itemMap[tab] ?? []).length === 0}
{#if (itemMap[tab] ?? []).length === 0}
<div class="p-2">
<QuickMenuItem
onselect={() => {
askAiButton?.onClick()
}}
id={'ai:no-results-ask-ai'}
hovered={true}
label={`Try asking \`${searchTerm}\` to AI`}
icon={WandSparkles}
bind:mouseMoved
/>
<div class="flex w-full justify-center items-center">
<div class="text-tertiary text-center">
<div class="text-2xl font-bold"
>Nothing found, ask the AI to find what you need!</div
>
<div class="text-sm">Tip: press `esc` to quickly clear the search bar</div>
<div class="pt-1 text-sm">Tip: press `esc` to quickly clear the search bar</div>
</div>
</div>
{/if}
</div>
</div>
{/if}
{:else if tab === 'content'}
<ContentSearchInner
search={removePrefix(searchTerm, '#')}
Expand Down
Loading