Skip to content

Commit c8039aa

Browse files
committed
fix(frontend): suppress stale global search results
1 parent 7065c0b commit c8039aa

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

frontend/src/components/CommandPalette.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -430,45 +430,48 @@ export function CommandPalette() {
430430
{/* Global results */}
431431
{mode === "global" && (
432432
<div className="border-t border-hud-border max-h-64 overflow-y-auto">
433-
{searching && (
433+
{query.length < 2 && (
434+
<div className="px-4 py-3 font-mono text-[13px] text-hud-label">
435+
Type at least 2 characters to search across worlds
436+
</div>
437+
)}
438+
{query.length >= 2 && searching && (
434439
<div className="px-4 py-3 font-mono text-[13px] text-hud-muted animate-pulse">
435440
Searching all worlds...
436441
</div>
437442
)}
438-
{!searching && searchResults.length === 0 && query.length >= 2 && (
443+
{query.length >= 2 && !searching && globalResults.length === 0 && (
439444
<div className="px-4 py-3 font-mono text-[13px] text-hud-label">
440445
No results found across worlds
441446
</div>
442447
)}
443-
{[...searchResults].sort((a, b) => b.score - a.score).map((result: GlobalSearchResult, index) => {
448+
{query.length >= 2 && globalResults.map((result, index) => {
444449
const isActive = activeIndex === index;
445450
return (
446451
<button
447-
key={`${result.entity_type}-${result.entity_id}`}
448-
onClick={() => {
449-
window.location.href = `/${locale}/world/${result.world_id}`;
450-
}}
452+
key={result.id}
453+
onClick={result.onSelect}
451454
className={`w-full px-4 py-2 text-left flex items-center gap-3 transition-colors ${
452455
isActive ? "bg-accent/15" : "hover:bg-accent/10"
453456
}`}
454457
>
455458
<div className={`w-1.5 h-1.5 rounded-full ${
456-
result.entity_type === "wiki_page" ? "bg-success" :
457-
result.entity_type === "agent" ? "bg-accent" : "bg-herald"
459+
result.entityType === "wiki_page" ? "bg-success" :
460+
result.entityType === "agent" ? "bg-accent" : "bg-herald"
458461
}`} />
459462
<div className="flex-1 min-w-0">
460463
<div className="flex items-center gap-2">
461-
<span className="font-mono text-base text-hud-text truncate">{result.title}</span>
464+
<span className="font-mono text-base text-hud-text truncate">{result.label}</span>
462465
<span className="font-mono text-[11px] text-hud-label uppercase flex-shrink-0">
463-
{result.entity_type.replace("_", " ")}
466+
{result.badge}
464467
</span>
465468
</div>
466469
<div className="font-mono text-sm text-hud-muted truncate">
467-
{result.snippet}
470+
{result.sublabel}
468471
</div>
469472
</div>
470473
<span className="font-mono text-[11px] text-hud-label flex-shrink-0">
471-
{(result.score * 100).toFixed(0)}%
474+
{result.meta}
472475
</span>
473476
</button>
474477
);

0 commit comments

Comments
 (0)