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
fix(soup): Entity being highlighted twice when in multiple groups (#3481)
dev-rbc620ef925cbf
diff --git a/js/app/packages/app/component/next-soup/create-soup-state.ts b/js/app/packages/app/component/next-soup/create-soup-state.tsindex 12d1b5a967..8f16aae2e7 100644--- a/js/app/packages/app/component/next-soup/create-soup-state.ts+++ b/js/app/packages/app/component/next-soup/create-soup-state.ts@@ -85,7 +85,10 @@ export const createSoupState = <TId extends string = FilterID>(const sort = createSortState(SORT_CONFIGS, ['updated_at']);- const [focusedId, setFocusedId] = createSignal<string | undefined>();+ // Tracked by index (not id) so a row id duplicated across groups highlights+ // only one occurrence. lastFocusedRowId follows that row across setRows.+ const [focusedIndex, setFocusedIndex] = createSignal(-1);+ let lastFocusedRowId: string | undefined;const [activeGroupId, setActiveGroupId] = createSignal<string | undefined>();@@ -130,7 +133,7 @@ export const createSoupState = <TId extends string = FilterID>(group,getIsGrouped: () => isGrouped,getIsLoadMore: () => isLoadMore,- isFocused: () => focusedId() === id,+ isFocused: () => focusedIndex() === index,isSelected: () =>!isGrouped && !isLoadMore && selection.isSelected(original.id),};@@ -143,6 +146,10 @@ export const createSoupState = <TId extends string = FilterID>(const setRows = (newRows: SoupRow[]) => {setRowsInternal(newRows);+ if (!lastFocusedRowId) return;+ const nextIndex = newRows.findIndex((r) => r.id === lastFocusedRowId);+ setFocusedIndex(nextIndex);+ if (nextIndex < 0) lastFocusedRowId = undefined;};const [previewEntity, setPreviewEntity] = createSignal<string | undefined>();@@ -153,22 +160,15 @@ export const createSoupState = <TId extends string = FilterID>(const indexOf = (id: string): number => rows().findIndex((r) => r.id === id);- const focusedIndex = createMemo(() => {- const id = focusedId();- if (!id) return -1;- return indexOf(id);- });-const focusedRow = createMemo(() => {const index = focusedIndex();if (index === -1) return undefined;return rows()[index];});- const focusedItem = createMemo(() => {- const row = focusedRow();- return row?.original;- });+ const focusedId = createMemo(() => focusedRow()?.id);++ const focusedItem = createMemo(() => focusedRow()?.original);const getRow = (id: string): SoupRow | undefined =>rows().find((r) => r.id === id);@@ -198,7 +198,8 @@ export const createSoupState = <TId extends string = FilterID>(const result = calculateFocusRow(index);if (result) {- setFocusedId(result.row.id);+ setFocusedIndex(result.index);+ lastFocusedRowId = result.row.id;}return result;@@ -269,7 +270,8 @@ export const createSoupState = <TId extends string = FilterID>(};const clearFocus = () => {- setFocusedId(undefined);+ setFocusedIndex(-1);+ lastFocusedRowId = undefined;};return {@@ -295,7 +297,22 @@ export const createSoupState = <TId extends string = FilterID>(id: focusedId,index: focusedIndex,clear: clearFocus,- set: (id: string | undefined) => setFocusedId(id),+ set: (id: string | undefined) => {+ if (id === undefined) {+ clearFocus();+ return;+ }+ const idx = indexOf(id);+ if (idx < 0) return;+ setFocusedIndex(idx);+ lastFocusedRowId = id;+ },+ setIndex: (index: number) => {+ const row = rows()[index];+ if (!row) return;+ setFocusedIndex(index);+ lastFocusedRowId = row.id;+ },},navigate: {diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex 460ac4ef47..328c094ff6 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -766,6 +766,7 @@ export const SoupViewList = (props: SoupViewListProps) => {projectEntity?: ProjectEntity;event: MouseEvent | PointerEvent;location?: SearchLocation;+ rowIndex?: number;};const onEntityClick = async (args: EntityClickArgs) => {@@ -782,7 +783,8 @@ export const SoupViewList = (props: SoupViewListProps) => {}if (soup.previewEntity() && type === 'entity') {- soup.focus.set(entity.id);+ if (args.rowIndex !== undefined) soup.focus.setIndex(args.rowIndex);+ else soup.focus.set(entity.id);return;}@@ -1287,7 +1289,7 @@ export const SoupViewList = (props: SoupViewListProps) => {onMouseMove={() => {if (isKeypressActive()) return;if (soup.previewEntity()) return;- soup.focus.set(row.id);+ soup.focus.setIndex(row.index);}}showUnrollNotifications={soup.predicates.isActive('inbox') &&@@ -1311,6 +1313,7 @@ export const SoupViewList = (props: SoupViewListProps) => {entity: row.original,event,location: undefined,+ rowIndex: row.index,});}}onProjectClick={(@@ -1323,6 +1326,7 @@ export const SoupViewList = (props: SoupViewListProps) => {entity: row.original,event,location: undefined,+ rowIndex: row.index,});}}onContentHitClick={(@@ -1334,6 +1338,7 @@ export const SoupViewList = (props: SoupViewListProps) => {entity: row.original,event: e,location,+ rowIndex: row.index,});}}entityRowConfig={{