Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(channel): show total match count in find bar (#3208)
gbirman03975d166777
diff --git a/js/app/packages/channel/Channel/Channel.tsx b/js/app/packages/channel/Channel/Channel.tsxindex 48b10a8627..335920dee8 100644--- a/js/app/packages/channel/Channel/Channel.tsx+++ b/js/app/packages/channel/Channel/Channel.tsx@@ -131,7 +131,8 @@ export function Channel(props: ChannelProps) {channelId: () => props.channelId,initialTargetMessageId: props.targetMessageId,initialTargetMessageReplyId: props.targetMessageReplyId,- messageKeys: () => messageIndex.keys,+ // changing the array reference is required to trigger the scroll effect+ messageKeys: () => [...messageIndex.keys],navigation: threadListNavigation,didInitialScroll: () => threadListScrollState()?.didInitialScroll ?? false,});diff --git a/js/app/packages/channel/Channel/create-channel-find-bar.ts b/js/app/packages/channel/Channel/create-channel-find-bar.tsindex 3af3fe2acb..5af285fa0a 100644--- a/js/app/packages/channel/Channel/create-channel-find-bar.ts+++ b/js/app/packages/channel/Channel/create-channel-find-bar.ts@@ -53,12 +53,19 @@ export function createChannelFindBar(if (!searchQuery.isSuccess) return [];const data = searchQuery.data;if (!data) return [];- return data.filter(+ return data.items.filter((e): e is WithSearch<ChannelMessageEntity> =>isChannelMessageEntity(e) && e.channelId === options.channelId());});+ const totalCount = createMemo<number | undefined>(() => {+ if (!submittedQuery()) return undefined;+ if (searchQuery.isPlaceholderData) return undefined;+ if (!searchQuery.isSuccess) return undefined;+ return searchQuery.data?.totalCount;+ });+// Prefetch the next page when the cursor approaches the end of the// loaded results so navigating to the boundary doesn't stall on a// network round-trip.@@ -74,6 +81,7 @@ export function createChannelFindBar(return {results,+ totalCount,isFetching: () => searchQuery.isFetching,validateText: validateSearchServiceText,navigate: (result) => {diff --git a/js/app/packages/channel/Thread/ChannelThread.tsx b/js/app/packages/channel/Thread/ChannelThread.tsxindex 9e864f3b63..f4abc6817b 100644--- a/js/app/packages/channel/Thread/ChannelThread.tsx+++ b/js/app/packages/channel/Thread/ChannelThread.tsx@@ -156,8 +156,8 @@ export function ChannelThread(props: ThreadProps) {createEffect(on(- [() => props.selectedReplyId, loadedReplies],- ([selectedReplyId, replies]) => {+ [() => props.selectedReplyId, () => props.targetReplyId, loadedReplies],+ ([selectedReplyId, _targetReplyId, replies]) => {if (!selectedReplyId) {if (replySelection.selectedId()) replySelection.clear();return;diff --git a/js/app/packages/core/component/createFindBarController.ts b/js/app/packages/core/component/createFindBarController.tsindex 12e42f953e..e6dc124a38 100644--- a/js/app/packages/core/component/createFindBarController.ts+++ b/js/app/packages/core/component/createFindBarController.ts@@ -11,6 +11,7 @@ export type FindBarSource<T> = {isFetching: Accessor<boolean>;navigate: (result: T) => void;validateText?: (text: string) => boolean;+ totalCount?: Accessor<number | undefined>;};export type FindBarController = {@@ -52,8 +53,6 @@ export function createFindBarController<T>(const source = makeSource({ isOpen, submittedQuery, activeIndex });const validateText = source.validateText ?? ((text) => text.length > 0);- createEffect(on(submittedQuery, () => setActiveIndex(0), { defer: true }));-createEffect(on(source.results, (rs) => {if (!isOpen()) return;@@ -119,7 +118,7 @@ export function createFindBarController<T>(activeIndex,hasUnsubmittedChanges: () => query().trim() !== submittedQuery(),isPending: () => !!submittedQuery() && source.isFetching(),- resultsCount: () => source.results().length,+ resultsCount: () => source.totalCount?.() ?? source.results().length,open,close,submit,diff --git a/js/app/packages/queries/soup/search.ts b/js/app/packages/queries/soup/search.tsindex f14e3afb33..cb0073ef51 100644--- a/js/app/packages/queries/soup/search.ts+++ b/js/app/packages/queries/soup/search.ts@@ -159,11 +159,14 @@ export const useSearchChannelQuery = (};},select: (data) => {- return data.pages.flatMap((page) =>+ const items = data.pages.flatMap((page) =>page.results.flatMap((item) =>mapChannelSearchResultItem(item, channels()))) as WithSearch<ChannelMessageEntity>[];+ // stable per query so first page is enough+ const totalCount = data.pages[0]?.total_count;+ return { items, totalCount };},enabled: enabled(),placeholderData: (p) => p,