mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-17 01:46:07 +00:00
fix(bots): hide redundant namespace wildcard and show raw event code
- Only surface `ns.*` wildcard when the namespace has 2+ concrete events, so single-event adapters (legacy) show just the one event - Show raw event code as a muted subtitle under each option's label Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
committed by
huanghuoguoguo
parent
8aedb57340
commit
55ed1d4595
@@ -143,12 +143,17 @@ function agentSupportsEventPattern(agent: Agent, pattern: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function eventNamespaces(events: string[]) {
|
function eventNamespaces(events: string[]) {
|
||||||
const ns = new Set<string>();
|
// Only surface a `ns.*` wildcard when the namespace actually has 2+
|
||||||
|
// concrete events — otherwise the wildcard is redundant with the single event.
|
||||||
|
const counts = new Map<string, number>();
|
||||||
events.forEach((e) => {
|
events.forEach((e) => {
|
||||||
const n = e.split('.')[0];
|
const n = e.split('.')[0];
|
||||||
if (n) ns.add(`${n}.*`);
|
if (n) counts.set(n, (counts.get(n) ?? 0) + 1);
|
||||||
});
|
});
|
||||||
return Array.from(ns).sort();
|
return Array.from(counts.entries())
|
||||||
|
.filter(([, c]) => c >= 2)
|
||||||
|
.map(([n]) => `${n}.*`)
|
||||||
|
.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Localized label for an event pattern. Concrete events look up
|
// Localized label for an event pattern. Concrete events look up
|
||||||
@@ -535,14 +540,30 @@ function BindingCardContent({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="h-8 flex-1 min-w-0 text-sm">
|
<SelectTrigger className="h-8 flex-1 min-w-0 text-sm">
|
||||||
<SelectValue placeholder={t('bots.eventPatternPlaceholder')} />
|
{binding.event_pattern ? (
|
||||||
|
<span className="truncate">
|
||||||
|
{eventLabel(binding.event_pattern, t)}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<SelectValue placeholder={t('bots.eventPatternPlaceholder')} />
|
||||||
|
)}
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{eventOptions.map((event) => (
|
{eventOptions.map((event) => {
|
||||||
<SelectItem key={event} value={event}>
|
const label = eventLabel(event, t);
|
||||||
{eventLabel(event, t)}
|
return (
|
||||||
</SelectItem>
|
<SelectItem key={event} value={event}>
|
||||||
))}
|
<span className="flex flex-col">
|
||||||
|
<span>{label}</span>
|
||||||
|
{label !== event && (
|
||||||
|
<span className="text-[11px] text-muted-foreground font-mono">
|
||||||
|
{event}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</SelectItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user