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(search): find routines in Cmd+K and Search (#9399)
Eric Hayes50c1ec88ea0e
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex b6604e5801..76cbab0604 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -456,6 +456,7 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to- Keep mobile Search history lightweight: save query/category/mode, account-scoped item anchors, and at most 200 ordering IDs per mode; never save row objects or virtualizer caches. Restore from current sources with at most three additional pages, fall back when an anchor disappears, and stop restoration on user interaction or scope changes. Dock navigation starts a fresh search session; cached rows belong to the source, not history.- Release per-history-entry state when its router entry is replaced, pruned, or closed; retain only the latest per-view session snapshot and the latest split event outside reachable Back/Forward history.- Keep Quick Access cache availability reactive to the GraphQL rollout flag; it can arrive after the provider mounts, and email has no legacy source fallback.+- Cmd+K, mobile name search, and the desktop Search page find routines by name from the Quick Access `routine` bucket (the scheduled-action list); keep them out of `entityPool`, which Home, Drive, and Tasks searches share, and use `routinePool` for workspace Search only.- Cmd+K and mobile name search take task projects from the Quick Access `initiative` bucket (typed All queries and the Projects category), searched from the GraphQL cache like other entities. Don't give them a per-query server search: its rows drop out while each new query loads, so projects flash as you type.- Merge the complete channel list into Quick Access even with the GraphQL cache enabled; preserve newer viewed timestamps and apply the channel boost before the extra DM boost in shared command/mobile name ranking.- Include all channel metadata in Quick Access item versions; record complete, cached-recent, and merged channel counts plus the last index-build duration on cache-search traces.diff --git a/apps/web/src/features/command/open-command-result.ts b/apps/web/src/features/command/open-command-result.tsindex 90332f5c4d..669f696395 100644--- a/apps/web/src/features/command/open-command-result.ts+++ b/apps/web/src/features/command/open-command-result.ts@@ -17,6 +17,7 @@ import { openExternalUrl } from '@core/util/url';import { isGithubPrEntity } from '@entity';import { useGetOrCreateDirectMessageMutation } from '@queries/channel/get-or-create-dm';import { projectRouteId } from '../projects/core/route';+import { routineContent } from '../routines/routine-navigation';import { getCategorySearchFilters } from './category-search-filters';import {type CommandMenuItem,@@ -130,6 +131,15 @@ export function createCommandResultOpener(return true;}+ if (isEntityItem(item) && item.bucket === 'routine') {+ openWithSplit(routineContent(item.id), {+ referredFrom,+ preferNewSplit: openInNewSplit,+ search: {},+ });+ return true;+ }+if (isEntityItem(item)) return openEntity(item, openInNewSplit);if (isUserItem(item)) {diff --git a/apps/web/src/features/command/queries/entity-search.ts b/apps/web/src/features/command/queries/entity-search.tsindex 735020c068..96cbfb7ac7 100644--- a/apps/web/src/features/command/queries/entity-search.ts+++ b/apps/web/src/features/command/queries/entity-search.ts@@ -18,7 +18,7 @@ export type EntitySearchCategory =const QUICK_ACCESS_BUCKETS_BY_CATEGORY: Partial<Record<EntitySearchCategory, Bucket[]>> = {- all: exclude('person', 'initiative', 'crm_contact'),+ all: exclude('person', 'initiative', 'crm_contact', 'routine'),email: ['email'],channels: ['channel'],dms: ['dm'],@@ -66,10 +66,11 @@ export function useEntitySearch(if ((category === 'all' || category === 'dms') && hasQuery()) {buckets = [...buckets, 'person'];}- // Like people, projects join All only for typed searches; the empty- // recency list leaves them to the Projects category.+ // Like people, projects and routines join All only for typed searches;+ // the empty recency list leaves projects to the Projects category, and+ // routines have no view history to rank them among recent items.if (category === 'all' && hasQuery()) {- buckets = [...buckets, 'initiative'];+ buckets = [...buckets, 'initiative', 'routine'];}return quickAccess.useList({buckets: options.excludeEmailsdiff --git a/apps/web/src/features/home/queries/use-home-query.test.ts b/apps/web/src/features/home/queries/use-home-query.test.tsindex cd2f6fabc6..d4e500e3f7 100644--- a/apps/web/src/features/home/queries/use-home-query.test.ts+++ b/apps/web/src/features/home/queries/use-home-query.test.ts@@ -15,7 +15,7 @@ vi.mock('@app/features/soup', async () => ({...(await import('@app/features/soup/filters')),...(await import('@app/features/soup/collection/rows')),...(await import('@app/features/soup/collection/row-store')),- useSearchContext: () => ({ entityPool: () => [] }),+ useSearchContext: () => ({ entityPool: () => [], routinePool: () => [] }),createSearchState: () => ({isSearching: () => false,usesServiceSearch: () => false,diff --git a/apps/web/src/features/home/queries/use-home-unread.test.ts b/apps/web/src/features/home/queries/use-home-unread.test.tsindex 96ce99237f..bcf6bdf066 100644--- a/apps/web/src/features/home/queries/use-home-unread.test.ts+++ b/apps/web/src/features/home/queries/use-home-unread.test.ts@@ -26,7 +26,7 @@ vi.mock('@app/features/soup', async () => ({...(await import('@app/features/soup/filters')),...(await import('@app/features/soup/collection/rows')),...(await import('@app/features/soup/collection/row-store')),- useSearchContext: () => ({ entityPool: () => [] }),+ useSearchContext: () => ({ entityPool: () => [], routinePool: () => [] }),createSearchState: vi.fn(),}));// Keep data-only query tests independent of unrelated UI barrel dependencies.diff --git a/apps/web/src/features/next-soup/soup-view/create-search-state.ts b/apps/web/src/features/next-soup/soup-view/create-search-state.tsindex 6c0286b6d6..e2a1fe4bbc 100644--- a/apps/web/src/features/next-soup/soup-view/create-search-state.ts+++ b/apps/web/src/features/next-soup/soup-view/create-search-state.ts@@ -46,9 +46,12 @@ export const createSearchState = ({assignees: assignees(),});- const { entityPool } = useSearchContext();+ const { entityPool, routinePool } = useSearchContext();const localPool = createMemo(() => {- const pool = entityPool();+ const pool =+ surface() === 'search'+ ? [...entityPool(), ...routinePool()]+ : entityPool();const activeIds = soup.predicates.activeIds().filter((id) => id !== 'explicit-noise');diff --git a/apps/web/src/features/next-soup/soup-view/soup-view-context.mount.test.tsx b/apps/web/src/features/next-soup/soup-view/soup-view-context.mount.test.tsxindex 0ba14b4bf1..fd5605bd73 100644--- a/apps/web/src/features/next-soup/soup-view/soup-view-context.mount.test.tsx+++ b/apps/web/src/features/next-soup/soup-view/soup-view-context.mount.test.tsx@@ -86,8 +86,11 @@ vi.mock('@queries/soup/search', () => ({}));vi.mock('@app/features/soup/search', async (importOriginal) => ({...(await importOriginal<object>()),- useSearchContext: () => ({ entityPool: () => [] }),- useOptionalSearchContext: () => ({ entityPool: () => [] }),+ useSearchContext: () => ({ entityPool: () => [], routinePool: () => [] }),+ useOptionalSearchContext: () => ({+ entityPool: () => [],+ routinePool: () => [],+ }),}));vi.mock('@queries/properties/tags', () => ({useTagsQuery: () => ({ data: [], isSuccess: true }),diff --git a/apps/web/src/features/soup/search/context.tsx b/apps/web/src/features/soup/search/context.tsxindex c4484b79c9..cecb0b8fb0 100644--- a/apps/web/src/features/soup/search/context.tsx+++ b/apps/web/src/features/soup/search/context.tsx@@ -1,3 +1,4 @@+import { useQuickAccess } from '@core/context/quickAccess';import type { EntityData } from '@entity';import { type EntityTypeItemMap, useQuickAccessEntities } from '@property';import { EntityType } from '@service-properties/generated/schemas/entityType';@@ -27,6 +28,11 @@ export type SoupSearchPoolEntry = {interface SearchContextValue {entityPool: Accessor<SoupSearchPoolEntry[]>;+ /**+ * Routines, kept out of `entityPool`: that pool also feeds the Home, Drive,+ * and Tasks searches, which never list routines. Workspace Search adds them.+ */+ routinePool: Accessor<SoupSearchPoolEntry[]>;}const SearchContext = createContext<SearchContextValue>();@@ -43,9 +49,12 @@ export const useOptionalSearchContext = () => useContext(SearchContext);export const SearchProvider: FlowComponent = (props) => {const { items } = useQuickAccessEntities(() => [...SEARCH_ENTITY_TYPES]);+ const routines = useQuickAccess().useList('routine').items;return (- <SearchContext.Provider value={{ entityPool: items }}>+ <SearchContext.Provider+ value={{ entityPool: items, routinePool: routines }}+ >{props.children}</SearchContext.Provider>);diff --git a/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts b/apps/web/src/features/tasks-view/queries/use-tasks-query.test.tsindex f96e994bc4..606dbe7d69 100644--- a/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts+++ b/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts@@ -20,7 +20,7 @@ vi.mock('@app/features/soup', async () => ({...(await import('@app/features/soup/collection/rows')),...(await import('@app/features/soup/collection/row-store')),...(await import('@app/features/soup/collection/transforms')),- useSearchContext: () => ({ entityPool: () => [] }),+ useSearchContext: () => ({ entityPool: () => [], routinePool: () => [] }),createSearchState: () => {fixture.searchState();return {diff --git a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.ts b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.tsindex e3258973fc..4534ee8cd6 100644--- a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.ts+++ b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.ts@@ -17,6 +17,7 @@ import { INITIAL_CACHE_REVISION } from '@graphql-cache/index';import type { HydrationSearchChanges } from '@graphql-cache/protocol';import type { CachedGraphqlChannel } from '@queries/channel/graphql';import type { HistoryItem } from '@queries/history/types';+import type { ScheduledAction } from '@service-scheduled-action/generated/schemas';import type { ApiChannelWithLatest } from '@service-storage/channel-list-types';import type { ListedDatabase } from '@service-storage/generated/schemas/listedDatabase';import { render } from '@solidjs/testing-library';@@ -71,6 +72,7 @@ const mocks = vi.hoisted(() => ({crmContacts: [] as CrmContactEntity[],initiatives: [] as InitiativeEntity[],databases: [] as ListedDatabase[],+ schedules: [] as ScheduledAction[],crmEnabled: (): boolean => true,projectsEnabled: (): boolean => true,graphqlEnabled: (): boolean => true,@@ -204,6 +206,9 @@ vi.mock('@queries/storage/databases', () => ({vi.mock('@queries/storage/forms', () => ({useFormsQuery: () => ({ data: [], isSuccess: true }),}));+vi.mock('@app/features/routines/queries/schedules', () => ({+ useSchedulesQuery: () => ({ data: mocks.schedules, isSuccess: true }),+}));vi.mock('@service-storage/util/filename', () => ({formatDocumentName: (name: string) => name,}));@@ -260,6 +265,7 @@ beforeEach(() => {mocks.crmContacts = [];mocks.initiatives = [];mocks.databases = [];+ mocks.schedules = [];mocks.crmEnabled = () => true;mocks.projectsEnabled = () => true;mocks.graphqlEnabled = () => true;@@ -1680,6 +1686,32 @@ describe('database command discovery', () => {});});+describe('routine command discovery', () => {+ it('finds a routine by name without any Soup history or cache hits', async () => {+ mocks.schedules = [+ {+ id: 'weekly-digest',+ name: 'Weekly digest',+ owner: 'me',+ enabled: true,+ created_at: '2026-09-01T00:00:00Z',+ updated_at: '2026-09-02T00:00:00Z',+ } as ScheduledAction,+ ];+ const list = setup((source) =>+ source.useList({+ buckets: ['routine'],+ searchTerm: () => 'digest',+ })+ );+ await vi.waitFor(() => expect(list.items()).toHaveLength(1));+ expect(list.items()[0]).toMatchObject({+ bucket: 'routine',+ data: { type: 'routine', name: 'Weekly digest' },+ });+ });+});+it('finds an unqueued first-use draft by title without a cached thread and retires it after sync', async () => {const [copies, setCopies] = createSignal<LocalDraft[]>([{diff --git a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsxindex bdf3fab2c1..227acf7661 100644--- a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx+++ b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx@@ -6,6 +6,8 @@ import {materializeCachedGraphqlCrmContacts,useQuickAccessCrmContactsQuery,} from '@app/features/crm/record-adapter';+import { scheduleToEntity } from '@app/features/routines/queries/entities';+import { useSchedulesQuery } from '@app/features/routines/queries/schedules';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { itemToSafeName } from '@core/constant/allBlocks';import {@@ -379,6 +381,8 @@ const RECORD_TYPE_BY_BUCKET: Record<Bucket, string> = {database: 'Database',// Forms come from their REST list too.form: 'Form',+ // Routines come from the scheduled-action list.+ routine: 'Routine',initiative: 'GraphqlSoupInitiative',};@@ -452,6 +456,7 @@ export function createQuickAccessValue(): QuickAccessContextValue {const databasesFlag = useFeatureFlag(enableDatabases);const formsQuery = useFormsQuery();const formsFlag = useFeatureFlag(enableForms);+ const schedulesQuery = useSchedulesQuery(() => true);const { query: initiativesQuery, initiatives: initiativesAccessor } =useQuickAccessInitiativesQuery();@@ -955,6 +960,39 @@ export function createQuickAccessValue(): QuickAccessContextValue {return sortIndexEntries(entries);});+ // Routines have no view history; their last change is the closest signal.+ const routineEntries = createLazyMemo(() => {+ const entries: IndexEntry[] = [];+ const schedules = schedulesQuery.isSuccess ? schedulesQuery.data : [];+ for (const schedule of schedules) {+ const routine = scheduleToEntity(schedule);+ if (!routine) continue;+ const sortTimestamp =+ toTimestamp(routine.updatedAt) || toTimestamp(routine.createdAt);+ const version = JSON.stringify(routine);+ const cached = itemCache.get(routine.id);+ if (!cached || cached.version !== version) {+ itemCache.set(routine.id, {+ version,+ item: {+ kind: 'entity',+ id: routine.id,+ bucket: 'routine',+ searchText: routine.name,+ sortTimestamp,+ timestamps: {+ updatedAt: routine.updatedAt,+ createdAt: routine.createdAt,+ },+ data: routine,+ },+ });+ }+ entries.push({ id: routine.id, bucket: 'routine', sortTimestamp });+ }+ return sortIndexEntries(entries);+ });+const initiativeEntries = createLazyMemo(() => {const viewedAtMap = soupViewedAtMap();const entries: IndexEntry[] = [];@@ -987,6 +1025,7 @@ export function createQuickAccessValue(): QuickAccessContextValue {agentSessionEntries(),databaseEntries(),formEntries(),+ routineEntries(),initiativeEntries(),]);const seenIds = new Set(allEntries.map((entry) => entry.id));@@ -1399,6 +1438,7 @@ export function createQuickAccessValue(): QuickAccessContextValue {fireAndForget(databasesQuery.refetch(), 'quick-access');if (formsFlag().enabled)fireAndForget(formsQuery.refetch(), 'quick-access');+ fireAndForget(schedulesQuery.refetch(), 'quick-access');fireAndForget(initiativesQuery.refetch(), 'quick-access');};diff --git a/apps/web/src/lib/core/context/quickAccess/types.ts b/apps/web/src/lib/core/context/quickAccess/types.tsindex 61c660d0b3..ca59abff86 100644--- a/apps/web/src/lib/core/context/quickAccess/types.ts+++ b/apps/web/src/lib/core/context/quickAccess/types.ts@@ -13,6 +13,7 @@ import type {FormEntity,InitiativeEntity,ProjectEntity,+ RoutineEntity,SkillEntity,SnippetEntity,TaskEntity,@@ -41,7 +42,8 @@ export type Bucket =| 'agent_session'| 'initiative'| 'database'- | 'form';+ | 'form'+ | 'routine';export type EntityBucket = Exclude<Bucket, 'person'>;@@ -62,6 +64,7 @@ const ALL_BUCKETS: Bucket[] = ['agent_session','database','form',+ 'routine','initiative',];@@ -154,6 +157,7 @@ export type BucketItemMap = {agent_session: EntityItem<AgentSessionEntity>;database: EntityItem<DatabaseEntity>;form: EntityItem<FormEntity>;+ routine: EntityItem<RoutineEntity>;initiative: EntityItem<InitiativeEntity>;person: UserItem;};diff --git a/docs/agent-guide/search.md b/docs/agent-guide/search.mdindex b4a7407d2a..0d74100ce6 100644--- a/docs/agent-guide/search.md+++ b/docs/agent-guide/search.md@@ -6,6 +6,12 @@ Sidebar `Search` button → `/app/search` with a focused query box. Results(including a `Featured Results` group) filter live as you type; no Enter needed. `Ctrl+K` isusually faster for jump-to-entity; `/` opens workspace search when no editor is focused.+Routines are found by name in a typed `Ctrl+K` **All** query, in touch Search's+**All** name results, and in the desktop Search page's `Featured Results`. They+come from the routines list (Quick Access `routine` bucket), not the search+service, and open the routine in the Agents workspace. They stay out of the+empty recency list and out of Home, Drive and Tasks searches.+Desktop filter chips use one compact control size for values, match mode, andclear actions. Labels and controls stay vertically centered inside a frame thatgrows to fit them, rather than clipping taller segments.