@copilotz/chat-ui 0.9.9 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2707,25 +2707,32 @@ var Sidebar2 = ({
2707
2707
  inputRef.current.select();
2708
2708
  }
2709
2709
  }, [editingThreadId]);
2710
+ const normalizedSearchQuery = searchQuery.trim().toLowerCase();
2711
+ const threadMatchesTitle = (thread) => !normalizedSearchQuery || (thread.title ?? "").toString().toLowerCase().includes(
2712
+ normalizedSearchQuery
2713
+ );
2714
+ const tagMatchesSearch = (tag) => !normalizedSearchQuery || tag.name.toLowerCase().includes(normalizedSearchQuery) || tag.id.toLowerCase().includes(normalizedSearchQuery);
2715
+ const threadMatchesSearch = (thread) => threadMatchesTitle(thread) || (thread.tags ?? []).some(tagMatchesSearch);
2710
2716
  const filteredThreads = threads.filter((thread) => {
2711
- const title = (thread.title ?? "").toString();
2712
- const matchesSearch = title.toLowerCase().includes(searchQuery.toLowerCase());
2713
2717
  const matchesArchiveFilter = showArchived || !thread.isArchived;
2714
- return matchesSearch && matchesArchiveFilter;
2718
+ return threadMatchesSearch(thread) && matchesArchiveFilter;
2715
2719
  });
2716
2720
  const allTags = (0, import_react4.useMemo)(() => collectThreadTags(threads), [threads]);
2717
2721
  const threadGroups = (0, import_react4.useMemo)(() => {
2718
2722
  if (tagsEnabled && groupBy === "tag") {
2719
- const groups2 = allTags.map((tag) => ({
2720
- key: tag.id,
2721
- label: tag.name,
2722
- tag,
2723
- threads: filteredThreads.filter(
2724
- (thread) => (thread.tags ?? []).some((threadTag) => threadTag.id === tag.id)
2725
- )
2726
- })).filter((group) => group.threads.length > 0);
2723
+ const groups2 = allTags.map((tag) => {
2724
+ const tagMatches = tagMatchesSearch(tag);
2725
+ return {
2726
+ key: tag.id,
2727
+ label: tag.name,
2728
+ tag,
2729
+ threads: filteredThreads.filter(
2730
+ (thread) => (thread.tags ?? []).some((threadTag) => threadTag.id === tag.id) && (tagMatches || threadMatchesTitle(thread))
2731
+ )
2732
+ };
2733
+ }).filter((group) => group.threads.length > 0);
2727
2734
  const untagged = filteredThreads.filter(
2728
- (thread) => (thread.tags ?? []).length === 0
2735
+ (thread) => (thread.tags ?? []).length === 0 && threadMatchesTitle(thread)
2729
2736
  );
2730
2737
  if (untagged.length > 0) {
2731
2738
  groups2.push({
@@ -2772,6 +2779,7 @@ var Sidebar2 = ({
2772
2779
  config.labels?.yesterday,
2773
2780
  filteredThreads,
2774
2781
  groupBy,
2782
+ normalizedSearchQuery,
2775
2783
  tagsEnabled
2776
2784
  ]);
2777
2785
  const tagDialogThread = tagDialogThreadId ? threads.find((thread) => thread.id === tagDialogThreadId) ?? null : null;
@@ -2822,7 +2830,7 @@ var Sidebar2 = ({
2822
2830
  setEditingThreadId(null);
2823
2831
  };
2824
2832
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Sidebar, { collapsible: "icon", ...props, children: [
2825
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SidebarHeader, { children: [
2833
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SidebarHeader, { className: "gap-3 p-3", children: [
2826
2834
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-3 px-2 py-3", children: [
2827
2835
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex items-center justify-center shrink-0", children: config.branding?.logo || /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Avatar, { className: "h-8 w-8", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AvatarFallback, { className: "bg-primary text-primary-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react8.Bot, { className: "h-4 w-4" }) }) }) }),
2828
2836
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col min-w-0 group-data-[collapsible=icon]:hidden", children: [
@@ -2830,56 +2838,78 @@ var Sidebar2 = ({
2830
2838
  config.branding?.subtitle && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-xs text-muted-foreground truncate", children: config.branding.subtitle })
2831
2839
  ] })
2832
2840
  ] }),
2833
- onCreateThread && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2834
- CreateThreadDialog,
2835
- {
2836
- config,
2837
- onCreateThread,
2838
- trigger: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SidebarMenu, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SidebarMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2839
- SidebarMenuButton,
2840
- {
2841
- size: "lg",
2842
- className: "w-full justify-start gap-2 border border-sidebar-border shadow-sm hover:bg-sidebar-accent hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:justify-center",
2843
- tooltip: config.labels?.newChat || "New Chat",
2844
- children: [
2845
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react8.Plus, { className: "size-4" }),
2846
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "group-data-[collapsible=icon]:hidden", children: config.labels?.newChat || "New Chat" })
2847
- ]
2848
- }
2849
- ) }) })
2850
- }
2851
- ),
2852
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "px-2 py-1 mt-4", children: [
2853
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative group-data-[collapsible=icon]:hidden", children: [
2841
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-3 px-1 group-data-[collapsible=icon]:hidden", children: [
2842
+ onCreateThread && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2843
+ CreateThreadDialog,
2844
+ {
2845
+ config,
2846
+ onCreateThread,
2847
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SidebarMenu, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SidebarMenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2848
+ SidebarMenuButton,
2849
+ {
2850
+ size: "lg",
2851
+ className: "h-11 w-full justify-start gap-2 rounded-xl border border-sidebar-border/80 bg-sidebar text-sidebar-foreground shadow-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:justify-center",
2852
+ tooltip: config.labels?.newChat || "New Chat",
2853
+ children: [
2854
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react8.Plus, { className: "size-4" }),
2855
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "group-data-[collapsible=icon]:hidden", children: config.labels?.newChat || "New Chat" })
2856
+ ]
2857
+ }
2858
+ ) }) })
2859
+ }
2860
+ ),
2861
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative", children: [
2854
2862
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2855
2863
  import_lucide_react8.Search,
2856
2864
  {
2857
2865
  "aria-hidden": "true",
2858
- className: "pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 select-none opacity-50"
2866
+ className: "pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 select-none text-sidebar-foreground/45"
2859
2867
  }
2860
2868
  ),
2861
2869
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2862
2870
  Input,
2863
2871
  {
2864
- className: "h-8 pl-3 pr-10 bg-sidebar-accent/50 border-sidebar-border focus-visible:ring-1 focus-visible:ring-sidebar-ring",
2872
+ className: "h-9 rounded-xl border-sidebar-border/80 bg-sidebar pl-3 pr-10 text-sidebar-foreground shadow-sm placeholder:text-sidebar-foreground/50 focus-visible:ring-1 focus-visible:ring-sidebar-ring",
2865
2873
  placeholder: config.labels?.search || "Search...",
2866
2874
  value: searchQuery,
2867
2875
  onChange: (e) => setSearchQuery(e.target.value)
2868
2876
  }
2869
2877
  )
2870
2878
  ] }),
2871
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "hidden group-data-[collapsible=icon]:flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2872
- Button,
2873
- {
2874
- variant: "ghost",
2875
- size: "icon",
2876
- className: "h-7 w-7",
2877
- onClick: () => setOpen(true),
2878
- title: config.labels?.search || "Search",
2879
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react8.Search, { className: "h-4 w-4" })
2880
- }
2881
- ) })
2882
- ] })
2879
+ tagsEnabled && threadTagsConfig?.groupingEnabled !== false && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-1 rounded-xl border border-sidebar-border/60 bg-sidebar-accent/70 p-1", children: [
2880
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2881
+ Button,
2882
+ {
2883
+ variant: "ghost",
2884
+ size: "sm",
2885
+ onClick: () => setGroupBy("date"),
2886
+ className: `h-8 rounded-lg px-2 text-xs font-semibold transition-colors ${groupBy === "date" ? "border border-sidebar-border bg-sidebar text-sidebar-foreground shadow-sm hover:bg-sidebar" : "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground"}`,
2887
+ children: config.labels?.groupByDate || "Date"
2888
+ }
2889
+ ),
2890
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2891
+ Button,
2892
+ {
2893
+ variant: "ghost",
2894
+ size: "sm",
2895
+ onClick: () => setGroupBy("tag"),
2896
+ className: `h-8 rounded-lg px-2 text-xs font-semibold transition-colors ${groupBy === "tag" ? "border border-sidebar-border bg-sidebar text-sidebar-foreground shadow-sm hover:bg-sidebar" : "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground"}`,
2897
+ children: config.labels?.groupByTag || "Tag"
2898
+ }
2899
+ )
2900
+ ] })
2901
+ ] }),
2902
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "hidden group-data-[collapsible=icon]:flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2903
+ Button,
2904
+ {
2905
+ variant: "ghost",
2906
+ size: "icon",
2907
+ className: "h-8 w-8",
2908
+ onClick: () => setOpen(true),
2909
+ title: config.labels?.search || "Search",
2910
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react8.Search, { className: "h-4 w-4" })
2911
+ }
2912
+ ) })
2883
2913
  ] }),
2884
2914
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SidebarContent, { children: [
2885
2915
  threads.some((t) => t.isArchived) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-4 py-2 mt-2 group-data-[collapsible=icon]:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
@@ -2895,28 +2925,6 @@ var Sidebar2 = ({
2895
2925
  ]
2896
2926
  }
2897
2927
  ) }),
2898
- tagsEnabled && threadTagsConfig?.groupingEnabled !== false && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-2 py-2 group-data-[collapsible=icon]:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-1 rounded-lg border border-sidebar-border/70 bg-sidebar-accent/70 p-1", children: [
2899
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2900
- Button,
2901
- {
2902
- variant: "ghost",
2903
- size: "sm",
2904
- onClick: () => setGroupBy("date"),
2905
- className: `h-7 rounded-md px-2 text-xs font-semibold transition-colors ${groupBy === "date" ? "border border-sidebar-border bg-sidebar text-sidebar-foreground shadow-sm hover:bg-sidebar" : "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground"}`,
2906
- children: config.labels?.groupByDate || "Date"
2907
- }
2908
- ),
2909
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2910
- Button,
2911
- {
2912
- variant: "ghost",
2913
- size: "sm",
2914
- onClick: () => setGroupBy("tag"),
2915
- className: `h-7 rounded-md px-2 text-xs font-semibold transition-colors ${groupBy === "tag" ? "border border-sidebar-border bg-sidebar text-sidebar-foreground shadow-sm hover:bg-sidebar" : "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground"}`,
2916
- children: config.labels?.groupByTag || "Tag"
2917
- }
2918
- )
2919
- ] }) }),
2920
2928
  threadGroups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "px-4 py-8 text-center text-muted-foreground group-data-[collapsible=icon]:hidden", children: [
2921
2929
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "mx-auto h-8 w-8 mb-2 flex items-center justify-center rounded-full bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react8.Plus, { className: "h-4 w-4 opacity-50" }) }),
2922
2930
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-xs", children: searchQuery ? config.labels?.noThreadsFound || "No conversations found" : config.labels?.noThreadsYet || "No conversations yet" })