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: task dedup frontend fixes (#3745)
Eric Hayes0200c9cf83be
diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsxindex ebf00e5454..3fce66b6e5 100644--- a/js/app/packages/block-md/component/ComposeTask.tsx+++ b/js/app/packages/block-md/component/ComposeTask.tsx@@ -34,7 +34,6 @@ import { useUpsertToHistoryMutation } from '@queries/history/history';import { refetchSoupEntity } from '@queries/soup/cache';import { propertiesServiceClient } from '@service-properties/client';import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';-import type { TaskSimilarityResult } from '@service-storage/client';import { debounce } from '@solid-primitives/scheduled';import { useQuery } from '@tanstack/solid-query';import { Button, Hotkey, Scroll, ToggleSwitch } from '@ui';@@ -56,7 +55,7 @@ import {updateDraftTimestamp,} from '../util/taskComposerStorage';import { InlinePropertyValue } from './InlinePropertyValue';-import { SimilarTasksSection } from './TaskDuplicatesPill';+import { SimilarTasksSection } from './TaskDuplicateList';// Show these props in the composer (Linear-style left-to-right order).const COMPOSER_PROPERTIES = [@@ -224,7 +223,6 @@ export function ComposeTask(props: ComposeTaskProps) {content: draft.content,editorState: draft.editorState,propertyValues: draft.propertyValues,- similarTasks: draft.similarTasks ?? [],isDraftLoaded: true,};}@@ -234,7 +232,6 @@ export function ComposeTask(props: ComposeTaskProps) {content: props.initialContent ?? '',editorState: undefined,propertyValues: getDefaultPropertyValues(),- similarTasks: [] as TaskSimilarityResult[],isDraftLoaded: false,};};@@ -254,9 +251,6 @@ export function ComposeTask(props: ComposeTaskProps) {const [createMore, setCreateMore] = createSignal(false);const [errorMessage, setErrorMessage] = createSignal<string>('');const [isCreating, setIsCreating] = createSignal(false);- const [similarTasks, setSimilarTasks] = createSignal<TaskSimilarityResult[]>(- initialState.similarTasks- );let attachInputRef: HTMLInputElement | undefined;const handleAttachFiles = async (event: Event) => {@@ -290,7 +284,6 @@ export function ComposeTask(props: ComposeTaskProps) {// so without this the draft only saved when title/content changed.JSON.stringify(propertyValues);const currentProperties = structuredClone(unwrap(propertyValues));- const currentSimilarTasks = similarTasks();if (hasInitializedFromDraft) {hasInitializedFromDraft = false;@@ -302,7 +295,6 @@ export function ComposeTask(props: ComposeTaskProps) {content: currentContent,editorState: bodyEditor()?.getEditorState().toJSON(),propertyValues: currentProperties,- similarTasks: currentSimilarTasks,});});@@ -870,8 +862,6 @@ export function ComposeTask(props: ComposeTaskProps) {<SimilarTasksSectiontitle={title}content={content}- initialResults={initialState.similarTasks}- onResults={setSimilarTasks}onOpenTask={handleOpenSimilarTask}/></div>diff --git a/js/app/packages/block-md/component/TaskDuplicatesPill.tsx b/js/app/packages/block-md/component/TaskDuplicateList.tsxsimilarity index 77%rename from js/app/packages/block-md/component/TaskDuplicatesPill.tsxrename to js/app/packages/block-md/component/TaskDuplicateList.tsxindex ae8502bd32..82b06a9541 100644--- a/js/app/packages/block-md/component/TaskDuplicatesPill.tsx+++ b/js/app/packages/block-md/component/TaskDuplicateList.tsx@@ -21,7 +21,7 @@ import {Suspense,} from 'solid-js';-const DEBOUNCE_MS = 500;+const DEBOUNCE_MS = 150;type DebouncedInput = { title: string; markdown: string };@@ -32,43 +32,26 @@ type DebouncedInput = { title: string; markdown: string };*/function SimilarTasksInner(props: {debounced: Accessor<DebouncedInput>;- initialResults: TaskSimilarityResult[];- onResults: (results: TaskSimilarityResult[]) => void;onOpenTask: (taskId: string) => void;}) {const [expanded, setExpanded] = createSignal(true);const [listRef, setListRef] = createSignal<HTMLElement>();- // The composer's draft (and its saved results) was loaded for this input.- const initialInput = props.debounced();+ const similarity = useTaskSimilaritySearchQuery(() => ({+ title: props.debounced().title,+ markdown: props.debounced().markdown,+ // Mirror the composer's create call, which does not share with a team.+ shareWithTeam: false,+ }));- const similarity = useTaskSimilaritySearchQuery(- () => ({- title: props.debounced().title,- markdown: props.debounced().markdown,- // Mirror the composer's create call, which does not share with a team.- shareWithTeam: false,- }),- () => {- const input = props.debounced();- const isInitialInput =- input.title === initialInput.title &&- input.markdown === initialInput.markdown;- return isInitialInput && props.initialResults.length > 0- ? props.initialResults- : undefined;- }- );-- // Persist the latest results with the composer draft.- createEffect(() => {- const data = similarity.data;- if (data) props.onResults(data);- });-- // Live results once loaded, otherwise the results saved with the draft.+ // The query retains its last data while disabled, so clear the results+ // ourselves once there is nothing to search on (no title and no body).+ const hasInput = () => {+ const input = props.debounced();+ return input.title.trim().length > 0 || input.markdown.trim().length > 0;+ };const results = (): TaskSimilarityResult[] =>- similarity.data ?? props.initialResults;+ hasInput() ? (similarity.data ?? []) : [];const ids = () => results().map((result) => result.taskId);// Hydrate full soup entities (status, owner, assignees, …) for the matches so@@ -140,8 +123,6 @@ function SimilarTasksInner(props: {export function SimilarTasksSection(props: {title: Accessor<string>;content: Accessor<string>;- initialResults: TaskSimilarityResult[];- onResults: (results: TaskSimilarityResult[]) => void;onOpenTask: (taskId: string) => void;}) {const flag = useFeatureFlag(ENABLE_TASK_DUPLICATES_FLAG, {@@ -167,8 +148,6 @@ export function SimilarTasksSection(props: {<Suspense><SimilarTasksInnerdebounced={debounced}- initialResults={props.initialResults}- onResults={props.onResults}onOpenTask={props.onOpenTask}/></Suspense>diff --git a/js/app/packages/block-md/util/taskComposerStorage.ts b/js/app/packages/block-md/util/taskComposerStorage.tsindex 0b2bae4024..2aeb2c34c5 100644--- a/js/app/packages/block-md/util/taskComposerStorage.ts+++ b/js/app/packages/block-md/util/taskComposerStorage.ts@@ -1,5 +1,4 @@import type { PropertyApiValues } from '@property/types';-import type { TaskSimilarityResult } from '@service-storage/client';import type { SerializedEditorState } from 'lexical';const STORAGE_KEY = 'task-composer-draft';@@ -12,9 +11,6 @@ export interface TaskComposerDraft {/** Markdown text fallback (used by older drafts and for the createTask API) */content: string;propertyValues: Record<string, PropertyApiValues>;- /** Possible-duplicate tasks last surfaced for this draft, persisted so they- * reappear instantly when the draft is restored. */- similarTasks?: TaskSimilarityResult[];timestamp: number;}diff --git a/js/app/packages/queries/storage/task-duplicates.ts b/js/app/packages/queries/storage/task-duplicates.tsindex 3f6af4f647..f23deee3bb 100644--- a/js/app/packages/queries/storage/task-duplicates.ts+++ b/js/app/packages/queries/storage/task-duplicates.ts@@ -68,9 +68,6 @@ export function useDismissTaskDuplicatesMutation(documentId: Accessor<string>) {}));}-/** Minimum title length before the live similarity search fires. */-export const SIMILARITY_SEARCH_MIN_TITLE_LENGTH = 3;-type TaskSimilaritySearchInput = {title: string;markdown: string;@@ -95,21 +92,18 @@ async function searchSimilarTasks(* Live, ephemeral similarity search used by the task composer. Hits the* stateless `/documents/similarity_search` HTTP endpoint — nothing is* persisted, so there is no cache invalidation or dismiss flow.- *- * `initialData` lets a restored composer draft seed the results for its- * initial input so saved matches render instantly without a refetch flash.*/export function useTaskSimilaritySearchQuery(- input: Accessor<TaskSimilaritySearchInput>,- initialData?: Accessor<TaskSimilarityResult[] | undefined>+ input: Accessor<TaskSimilaritySearchInput>) {return useQuery(() => ({queryKey: taskSimilaritySearchKeys.forInput(input()).queryKey,queryFn: () => searchSimilarTasks(input()),- enabled: input().title.trim().length >= SIMILARITY_SEARCH_MIN_TITLE_LENGTH,+ // Only query when there is something to search on: a title or a body.+ enabled:+ input().title.trim().length > 0 || input().markdown.trim().length > 0,staleTime: 30 * 1000,placeholderData: (prev) => prev,- initialData: initialData?.(),}));}diff --git a/js/bun.lock b/js/bun.lockindex d8a2279d66..198ad6c4b1 100644--- a/js/bun.lock+++ b/js/bun.lock@@ -827,7 +827,7 @@"@img/sharp-win32-x64": ["@img/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw=="],- "@inkibra/tauri-plugins": ["@inkibra/tauri-plugins@github:macro-inc/tauri-plugins#26537c8", { "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" } }, "macro-inc-tauri-plugins-26537c8", "sha512-6p5xQAkS6Uw6J8Uh0vlj6MjKZXWps5E1Gu0hciBFq1E2BfPBZAgdeeafKnR3diNb4SXWK0JML49nAr+o5PhwKw=="],+ "@inkibra/tauri-plugins": ["@inkibra/tauri-plugins@github:macro-inc/tauri-plugins#26537c8", { "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" } }, "macro-inc-tauri-plugins-26537c8"],"@inquirer/external-editor": ["@inquirer/[email protected]", "", { "dependencies": { "chardet": "^2.1.1", "iconv-lite": "^0.7.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA=="],@@ -2547,7 +2547,7 @@"pathval": ["[email protected]", "", {}, "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ=="],- "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6", "sha512-HDFaPbCxLG2GHpf1smUG97nku5aPGBGaCcIbK05dGdp07TBLUlDcXsM4WcE82mO5W4RBPIBVYobX5N/6M6NFrA=="],+ "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6"],"performance-now": ["[email protected]", "", {}, "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="],