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
chore: update fe history type (#1349)
gbirmandcd6b2a5ece9
diff --git a/js/app/packages/block-email/component/AttachMenu.tsx b/js/app/packages/block-email/component/AttachMenu.tsxindex d6a1054b62..2aacd7125d 100644--- a/js/app/packages/block-email/component/AttachMenu.tsx+++ b/js/app/packages/block-email/component/AttachMenu.tsx@@ -10,7 +10,7 @@ import SearchIcon from '@icon/regular/magnifying-glass.svg';import { DropdownMenu } from '@kobalte/core/dropdown-menu';import type { DocumentMentionInfo } from '@lexical-core';import type { Item } from '@service-storage/generated/schemas/item';-import { useHistoryQuery } from '@queries/history/history';+import { useHistoryQuery, type HistoryItem } from '@queries/history/history';import fuzzy from 'fuzzy';import {createMemo,@@ -29,7 +29,7 @@ type AttachMenuProps = {open?: boolean;onClose?: () => void;trigger: JSX.Element;- onAttach: (items: Item[]) => void;+ onAttach: (items: HistoryItem[]) => void;onAttachDocuments?: (items: DocumentMentionInfo[]) => void;attachedItems?: () => Item[];setIsPending?: Setter<boolean>;diff --git a/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx b/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsxindex d6e9db272b..df3d34e5ee 100644--- a/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx+++ b/js/app/packages/core/component/AI/component/input/ChatAttachMenu.tsx@@ -23,7 +23,7 @@ import {import DeviceMobileIcon from '@icon/regular/device-mobile-speaker.svg';import LaptopIcon from '@icon/regular/laptop.svg';import SearchIcon from '@icon/regular/magnifying-glass.svg';-import type { Item } from '@service-storage/generated/schemas/item';+import type { HistoryItem } from '@queries/history/history';import {createEffect,createMemo,@@ -183,7 +183,7 @@ export function ChatAttachMenu(props: ChatAttachMenuProps) {}};- const selectItem = (item: Item) => {+ const selectItem = (item: HistoryItem) => {// TODO: add other supported attachment types, e.g. channelif (item.type !== 'document') {console.error('ChatAttachMenu only supports document items');diff --git a/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx b/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsxindex a16c0ac662..4e852c52d3 100644--- a/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx+++ b/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx@@ -51,7 +51,7 @@ import { isMobile } from '@core/mobile/isMobile';import type { IOrganizationUser } from '@core/user';import { handleFileFolderDrop } from '@core/util/upload';import { $isDocumentMentionNode } from '@lexical-core';-import type { Item } from '@service-storage/generated/schemas/item';+import type { HistoryItem } from '@queries/history/history';import { onElementConnect } from '@solid-primitives/lifecycle';import { activeElement } from 'app/signal/focus';import { filePastePlugin } from 'core/component/LexicalMarkdown/plugins/file-paste/filePastePlugin';@@ -221,7 +221,7 @@ export type ConsumableChatMarkdownAreaProps = {initialValue?: string;placeholder?: string;users?: Accessor<IOrganizationUser[]>;- history?: Accessor<Item[]>;+ history?: Accessor<HistoryItem[]>;onPasteFile?: (files: File[]) => void;dontFocusOnMount?: boolean;portalScope?: PortalScope;diff --git a/js/app/packages/core/component/AI/signal/tabAttachments.ts b/js/app/packages/core/component/AI/signal/tabAttachments.tsindex e1732c85f3..646146604b 100644--- a/js/app/packages/core/component/AI/signal/tabAttachments.ts+++ b/js/app/packages/core/component/AI/signal/tabAttachments.ts@@ -17,7 +17,6 @@ import type { SplitContent } from 'app/component/split-layout/layoutManager';import { globalSplitManager } from 'app/signal/splitLayout';import type { Accessor } from 'solid-js';import { createMemo } from 'solid-js';-import type { HistoryItem } from '@queries/history/history';type Item = HistoryItem | null;diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsxindex 82d18fae1a..f444cd7768 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx@@ -36,7 +36,6 @@ import {} from '@macro-entity';import { useHistoryQuery } from '@queries/history/history';import type { SearchArgs } from '@service-search/client';-import type { Item } from '@service-storage/generated/schemas/item';import { debounce } from '@solid-primitives/scheduled';import { globalSplitManager } from 'app/signal/splitLayout';import type { LexicalEditor } from 'lexical';@@ -80,6 +79,7 @@ import {handleUserMention,type UserMentionRecord,} from '../../utils/mentionsUtils';+import type { HistoryItem as Item } from '@queries/history/history';false && clickOutside;false && floatWithSelection;diff --git a/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.tsindex c788be8b07..f804d0c1bd 100644--- a/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts+++ b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts@@ -1,9 +1,9 @@import type { ChannelWithParticipants, IUser } from '@core/user';import type { EmailEntity } from '@macro-entity';import type { EntityType } from '@service-properties/generated/schemas/entityType';-import type { Item } from '@service-storage/generated/schemas/item';import type { Accessor } from 'solid-js';import type { FreshSortConfig, TimestampedItem } from '@core/util/freshSort';+import type { HistoryItem as Item } from '@queries/history/history';/** Combined entity type for unified handling across entity selectors */export type CombinedEntity =diff --git a/js/app/packages/core/util/getItemBlockName.ts b/js/app/packages/core/util/getItemBlockName.tsindex 659108648f..1e2dc2dfdf 100644--- a/js/app/packages/core/util/getItemBlockName.ts+++ b/js/app/packages/core/util/getItemBlockName.ts@@ -1,7 +1,16 @@import { fileTypeToBlockName } from '@core/constant/allBlocks';import type { Item } from '@service-storage/generated/schemas/item';-export function getItemBlockName(item: Item, icon?: boolean) {+type NonDocumentItem = Pick<Exclude<Item, { type: 'document' }>, 'type'>;++type DocumentItem = Pick<+ Extract<Item, { type: 'document' }>,+ 'type' | 'fileType' | 'subType'+>;++type ItemBlockNameInfo = NonDocumentItem | DocumentItem;++export function getItemBlockName(item: ItemBlockNameInfo, icon?: boolean) {if (item.type === 'document')return fileTypeToBlockName((item.subType?.type as string | undefined) ?? item.fileType,diff --git a/js/app/packages/queries/history/transforms.ts b/js/app/packages/queries/history/transforms.tsindex 8e63ec6402..384caa1599 100644--- a/js/app/packages/queries/history/transforms.ts+++ b/js/app/packages/queries/history/transforms.ts@@ -1,32 +1,73 @@import { itemToSafeName } from '@core/constant/allBlocks';import type { Item } from '@service-storage/generated/schemas/item';-type ItemWithViewedAt = Item & { viewedAt?: number };--export type HistoryItem = Item & {- name: string;+type BaseHistoryItem = Pick<+ Item,+ 'id' | 'name' | 'createdAt' | 'updatedAt' | 'deletedAt'+> & {viewedAt?: number;};+export type DocumentHistoryItem = BaseHistoryItem &+ Pick<Extract<Item, { type: 'document' }>, 'type' | 'fileType' | 'subType'>;++export type ChatHistoryItem = BaseHistoryItem &+ Pick<Extract<Item, { type: 'chat' }>, 'type' | 'isPersistent'>;++export type ProjectHistoryItem = BaseHistoryItem &+ Pick<Extract<Item, { type: 'project' }>, 'type'>;++/** Minimal history item types containing only the properties actually used */+export type HistoryItem =+ | DocumentHistoryItem+ | ChatHistoryItem+ | ProjectHistoryItem;+export type HistoryQueryResponse = {- data: Item[];+ data: HistoryItem[];};export function transformHistoryItem(- item: Item,+ item: HistoryItem,rawName?: boolean): HistoryItem {- return {- ...item,+ const base = {+ id: item.id,name: rawName ? item.name : itemToSafeName(item),- viewedAt: (item as ItemWithViewedAt).viewedAt,+ createdAt: item.createdAt,+ updatedAt: item.updatedAt,+ deletedAt: item.deletedAt,+ viewedAt: item.viewedAt,};++ switch (item.type) {+ case 'document':+ return {+ ...base,+ type: 'document',+ fileType: item.fileType,+ subType: item.subType,+ };++ case 'chat':+ return {+ ...base,+ type: 'chat',+ isPersistent: item.isPersistent,+ };++ case 'project':+ return {+ ...base,+ type: 'project',+ };+ }}export function filterInstructionsMd(- items: Item[],+ items: HistoryItem[],instructionsId: string | null | undefined-): Item[] {+): HistoryItem[] {if (!instructionsId) return items;return items.filter((item) => item.id !== instructionsId);}@@ -46,17 +87,17 @@ export function transformHistoryResponse(* Returns a new array without mutating the input.*/export function updateViewedAtAndMoveItemToFront(- items: ItemWithViewedAt[],+ items: HistoryItem[],itemId: string,timestamp: number-): ItemWithViewedAt[] {+): HistoryItem[] {const itemIndex = items.findIndex((item) => item.id === itemId);// Item not found, return original arrayif (itemIndex === -1) return items;const item = items[itemIndex];- const updatedItem: ItemWithViewedAt = { ...item, viewedAt: timestamp };+ const updatedItem: HistoryItem = { ...item, viewedAt: timestamp };// Return new array with updated item at frontreturn [