Skip to content

Commit e3aee0c

Browse files
authored
fix: ctrl k not showing navigation items + improve ai button by making it an item in the menu (#6132)
* Fix missing navigation after migration to svelte 5 of ctrl k search .includes doesn't work anymore because the items inside the array are treated as state, and thus svelte wraps them with a Proxy thing * Change ask ai to be a menu item * Remove comment
1 parent c498c48 commit e3aee0c

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

frontend/src/lib/components/search/GlobalSearchModal.svelte

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
Route,
2626
Search,
2727
SearchCode,
28-
Unplug
28+
Unplug,
29+
WandSparkles
2930
} from 'lucide-svelte'
3031
import Portal from '$lib/components/Portal.svelte'
3132
@@ -293,8 +294,7 @@
293294
}
294295
295296
if (tab === 'default') {
296-
if (searchTerm === '')
297-
itemMap['default'] = fuzzyFilter(searchTerm, defaultMenuItems, defaultMenuItemLabels)
297+
if (searchTerm === '') itemMap['default'] = defaultMenuItems
298298
else
299299
itemMap['default'] = fuzzyFilter(
300300
searchTerm,
@@ -372,9 +372,6 @@
372372
}
373373
}
374374
}
375-
if ((itemMap[tab] ?? []).length === 0 && searchTerm.length > 0 && event.key === 'Enter') {
376-
askAiButton?.onClick()
377-
}
378375
}
379376
}
380377
@@ -653,10 +650,14 @@
653650
<div class="overflow-y-auto relative {maxModalHeight(tab)}">
654651
{#if tab === 'default' || tab === 'switch-mode'}
655652
{@const items = (itemMap[tab] ?? []).filter((e) =>
656-
defaultMenuItemsWithHidden.includes(e)
653+
defaultMenuItemsWithHidden.some((x) => e.search_id === x.search_id)
657654
)}
658655
{#if items.length > 0}
659-
<div class={tab === 'switch-mode' ? 'p-2' : 'p-2 border-b'}>
656+
<div
657+
class={tab === 'switch-mode' || itemMap[tab].length === items.length
658+
? 'p-2'
659+
: 'p-2 border-b'}
660+
>
660661
{#each items as el}
661662
<QuickMenuItem
662663
onselect={(shift) => el?.action(shift)}
@@ -674,8 +675,8 @@
674675
{/if}
675676

676677
{#if tab === 'default'}
677-
<div class="p-2">
678-
{#if (itemMap[tab] ?? []).filter((e) => (combinedItems ?? []).includes(e)).length > 0}
678+
{#if (itemMap[tab] ?? []).filter((e) => (combinedItems ?? []).includes(e)).length > 0}
679+
<div class="p-2">
679680
<div class="py-2 px-1 text-xs font-semibold text-tertiary">
680681
Flows/Scripts/Apps
681682
</div>
@@ -694,19 +695,28 @@
694695
bind:mouseMoved
695696
/>
696697
{/each}
697-
{/if}
698+
</div>
699+
{/if}
698700

699-
{#if (itemMap[tab] ?? []).length === 0}
701+
{#if (itemMap[tab] ?? []).length === 0}
702+
<div class="p-2">
703+
<QuickMenuItem
704+
onselect={() => {
705+
askAiButton?.onClick()
706+
}}
707+
id={'ai:no-results-ask-ai'}
708+
hovered={true}
709+
label={`Try asking \`${searchTerm}\` to AI`}
710+
icon={WandSparkles}
711+
bind:mouseMoved
712+
/>
700713
<div class="flex w-full justify-center items-center">
701714
<div class="text-tertiary text-center">
702-
<div class="text-2xl font-bold"
703-
>Nothing found, ask the AI to find what you need!</div
704-
>
705-
<div class="text-sm">Tip: press `esc` to quickly clear the search bar</div>
715+
<div class="pt-1 text-sm">Tip: press `esc` to quickly clear the search bar</div>
706716
</div>
707717
</div>
708-
{/if}
709-
</div>
718+
</div>
719+
{/if}
710720
{:else if tab === 'content'}
711721
<ContentSearchInner
712722
search={removePrefix(searchTerm, '#')}

0 commit comments

Comments
 (0)