mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-16 17:36:07 +00:00
fix(web): place each adapter in a single category bucket
groupByCategory pushed multi-category adapters (lark, wecom, discord, slack) into every matching bucket, so the adapter Select rendered duplicate SelectItem values — triggering React duplicate-key warnings and corrupting Radix item tracking. Assign each item to its highest -priority matching category only. Also de-dupes the wizard card grid. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
committed by
huanghuoguoguo
parent
4aa0ac401b
commit
8eb5ca1dd1
@@ -30,9 +30,13 @@ export function getOrderedCategories(): AdapterCategoryId[] {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Groups items that have a `categories` string array into ordered category
|
* Groups items that have a `categories` string array into ordered category
|
||||||
* buckets. An item can appear in multiple groups if it belongs to multiple
|
* buckets. Each item is placed into exactly one bucket — its highest-priority
|
||||||
* categories. Items without any recognised category are collected into a
|
* matching category in display order (e.g. an adapter tagged both `popular`
|
||||||
* trailing "uncategorized" group (null key).
|
* and `china` lands in `popular`). This keeps item values unique, which is
|
||||||
|
* required when the result feeds a Select (duplicate values break Radix's
|
||||||
|
* item tracking and trigger React duplicate-key warnings). Items without any
|
||||||
|
* recognised category are collected into a trailing "uncategorized" group
|
||||||
|
* (null key).
|
||||||
*/
|
*/
|
||||||
export function groupByCategory<T extends { categories?: string[] }>(
|
export function groupByCategory<T extends { categories?: string[] }>(
|
||||||
items: T[],
|
items: T[],
|
||||||
@@ -54,10 +58,13 @@ export function groupByCategory<T extends { categories?: string[] }>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let placed = false;
|
let placed = false;
|
||||||
for (const cat of cats) {
|
// Assign to the highest-priority matching category (display order) only,
|
||||||
if (ordered.includes(cat as AdapterCategoryId)) {
|
// so each item appears in exactly one bucket.
|
||||||
buckets.get(cat as AdapterCategoryId)!.push(item);
|
for (const cat of ordered) {
|
||||||
|
if (cats.includes(cat)) {
|
||||||
|
buckets.get(cat)!.push(item);
|
||||||
placed = true;
|
placed = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!placed) {
|
if (!placed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user