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
style(command): retsyle command menu, general dialogs, launcher, add tag selector command menu (#4974)
Seamus88be4705e2e3
diff --git a/apps/web/src/components/ui/components/CommandMenuPrimitives.tsx b/apps/web/src/components/ui/components/CommandMenuPrimitives.tsxnew file mode 100644index 0000000000..eb00d32c71--- /dev/null+++ b/apps/web/src/components/ui/components/CommandMenuPrimitives.tsx@@ -0,0 +1,248 @@+import {+ type Accessor,+ children,+ createEffect,+ createSelector,+ createSignal,+ type JSX,+ type ParentProps,+ type Setter,+ Show,+ splitProps,+} from 'solid-js';+import { Dynamic } from 'solid-js/web';+import { cn } from '../utils/classname';+import { Panel } from './Panel';+import type { SurfaceProps } from './Surface';++type SelectedIndexSetter = Setter<number>;++export type CommandListController<T> = {+ selectedIndex: Accessor<number>;+ setSelectedIndex: (+ next: number | ((previous: number) => number),+ options?: { scrollIntoView?: boolean }+ ) => void;+ setSelectedIndexFromPointer: (index: number) => void;+ isSelected: (index: number) => boolean;+ selectedItem: Accessor<T | undefined>;+ selectSelected: () => boolean;+ selectNext: () => boolean;+ selectPrevious: () => boolean;+ shouldScrollSelectedIntoView: Accessor<boolean>;+};++export function createCommandListController<T>(options: {+ items: Accessor<readonly T[]>;+ selectedIndex?: Accessor<number>;+ setSelectedIndex?: SelectedIndexSetter;+ onSelect?: (item: T, index: number) => void;+}): CommandListController<T> {+ const [internalSelectedIndex, setInternalSelectedIndex] = createSignal(0);+ const [shouldScrollSelectedIntoView, setShouldScrollSelectedIntoView] =+ createSignal(false);++ const selectedIndex = options.selectedIndex ?? internalSelectedIndex;+ const setRawSelectedIndex =+ options.setSelectedIndex ?? setInternalSelectedIndex;++ const setSelectedIndex = (+ next: number | ((previous: number) => number),+ options?: { scrollIntoView?: boolean }+ ) => {+ setShouldScrollSelectedIntoView(Boolean(options?.scrollIntoView));+ setRawSelectedIndex(next);+ };++ createEffect(() => {+ const items = options.items();+ const current = selectedIndex();++ if (items.length === 0) {+ if (current !== 0) setSelectedIndex(0);+ return;+ }++ if (current >= items.length) {+ setSelectedIndex(items.length - 1);+ }+ });++ const selectedItem = () => options.items()[selectedIndex()];+ const isSelected = createSelector(selectedIndex);++ const selectNext = () => {+ const items = options.items();+ if (items.length === 0) return false;++ setSelectedIndex((previous) => (previous + 1) % items.length, {+ scrollIntoView: true,+ });+ return true;+ };++ const selectPrevious = () => {+ const items = options.items();+ if (items.length === 0) return false;++ setSelectedIndex(+ (previous) => (previous - 1 + items.length) % items.length,+ { scrollIntoView: true }+ );+ return true;+ };++ const selectSelected = () => {+ const index = selectedIndex();+ const item = options.items()[index];+ if (!item) return false;++ options.onSelect?.(item, index);+ return true;+ };++ return {+ selectedIndex,+ setSelectedIndex,+ setSelectedIndexFromPointer: (index) => setSelectedIndex(index),+ isSelected,+ selectedItem,+ selectSelected,+ selectNext,+ selectPrevious,+ shouldScrollSelectedIntoView,+ };+}++function CommandMenuShellRoot(props: SurfaceProps) {+ const [local, rest] = splitProps(props, ['children', 'class']);++ return (+ <Panel class={cn('max-h-[75vh] rounded-xl', local.class)} {...rest}>+ {local.children}+ </Panel>+ );+}++function CommandMenuHeader(props: ParentProps<{ class?: string }>) {+ return (+ <Panel.Header class={cn('gap-2 px-2 my-1 bg-surface', props.class)}>+ {props.children}+ </Panel.Header>+ );+}++function CommandMenuToolbar(props: ParentProps<{ class?: string }>) {+ return (+ <Panel.Toolbar class={cn('bg-surface', props.class)}>+ {props.children}+ </Panel.Toolbar>+ );+}++function CommandMenuBody(+ props: ParentProps<{ class?: string; scroll?: boolean }>+) {+ return (+ <Panel.Body class={props.class} scroll={props.scroll}>+ {props.children}+ </Panel.Body>+ );+}++function CommandMenuFooter(props: ParentProps<{ class?: string }>) {+ return (+ <Panel.Footer+ class={cn(+ 'gap-4 px-4 bg-surface text-xs text-ink-extra-muted/80',+ props.class+ )}+ >+ {props.children}+ </Panel.Footer>+ );+}++export const CommandMenuShell = Object.assign(CommandMenuShellRoot, {+ Header: CommandMenuHeader,+ Toolbar: CommandMenuToolbar,+ Body: CommandMenuBody,+ Footer: CommandMenuFooter,+});++export function CommandMenuSearchInput(+ props: JSX.InputHTMLAttributes<HTMLInputElement>+) {+ const [local, rest] = splitProps(props, ['class']);++ return (+ <input+ class={cn(+ 'flex-1 bg-transparent border-0 outline-none focus:outline-none ring-0 focus:ring-0 text-ink-muted placeholder:text-ink-placeholder',+ local.class+ )}+ {...rest}+ />+ );+}++export function CommandMenuListItem(+ props: ParentProps<{+ id?: string;+ as?: 'button' | 'div';+ class?: string;+ selected?: boolean;+ disabled?: boolean;+ onClick?: JSX.EventHandlerUnion<HTMLElement, MouseEvent>;+ onMouseMove?: JSX.EventHandlerUnion<HTMLElement, MouseEvent>;+ }>+) {+ return (+ <Dynamic+ component={props.as ?? 'button'}+ type={props.as === 'div' ? undefined : 'button'}+ id={props.id}+ disabled={props.disabled}+ class={cn(+ 'rounded-md group w-full flex items-center h-10 px-2 gap-2 text-sm font-semibold relative scroll-m-1 text-left disabled:opacity-50 disabled:pointer-events-none',+ props.selected && 'bg-active',+ props.class+ )}+ onClick={props.onClick}+ onMouseMove={props.onMouseMove}+ >+ {props.children}+ </Dynamic>+ );+}++export function CommandMenuEmptyState(+ props: ParentProps<{ class?: string; children: JSX.Element }>+) {+ const resolved = children(() => props.children);++ return (+ <Show when={resolved()}>+ <div class={cn('p-4 text-center text-ink-muted text-sm', props.class)}>+ {resolved()}+ </div>+ </Show>+ );+}++export function CommandMenuHotkeyHint(+ props: ParentProps<{+ class?: string;+ hotkey: JSX.Element;+ label: JSX.Element;+ }>+) {+ return (+ <span class={cn('flex items-center gap-1', props.class)}>+ <div class="flex border border-edge-muted text-xxs rounded-md items-center px-1.5 py-px font-normal">+ {props.hotkey}+ </div>+ {props.label}+ </span>+ );+}diff --git a/apps/web/src/components/ui/components/Dialog.tsx b/apps/web/src/components/ui/components/Dialog.tsxindex 33cb9a795a..5583a0d6bd 100644--- a/apps/web/src/components/ui/components/Dialog.tsx+++ b/apps/web/src/components/ui/components/Dialog.tsx@@ -1,7 +1,13 @@import { Dialog as KobalteDialog } from '@kobalte/core/dialog';import type { JSX, Ref } from 'solid-js';+import { createEffect, createSignal, onCleanup } from 'solid-js';import { cn } from '../utils/classname';+const DIALOG_HANDOFF_WINDOW_MS = 180;++let openDialogCount = 0;+let lastAllDialogsClosedAt = Number.NEGATIVE_INFINITY;+export type DialogProps = {onEscapeKeyDown?: (event: KeyboardEvent) => void /* Forwarded to Kobalte */;onCloseAutoFocus?: (event: Event) => void /* Forwarded to Kobalte */;@@ -14,13 +20,58 @@ export type DialogProps = {children: JSX.Element /* Content children */;class?: string /* classes for content */;open: boolean /* if dialog is open */;+ visibleScrim?: boolean /* if the scrim is visible */;};export function Dialog(props: DialogProps) {+ const [animateOnOpen, setAnimateOnOpen] = createSignal(false);+ let countedOpen = false;++ createEffect(() => {+ if (props.open) {+ if (!countedOpen) {+ const isDialogHandoff =+ openDialogCount > 0 ||+ performance.now() - lastAllDialogsClosedAt < DIALOG_HANDOFF_WINDOW_MS;++ setAnimateOnOpen(!isDialogHandoff);+ openDialogCount += 1;+ countedOpen = true;+ }+ return;+ }++ if (countedOpen) {+ openDialogCount = Math.max(0, openDialogCount - 1);+ countedOpen = false;+ setAnimateOnOpen(false);++ if (openDialogCount === 0) {+ lastAllDialogsClosedAt = performance.now();+ }+ }+ });++ onCleanup(() => {+ if (!countedOpen) return;++ openDialogCount = Math.max(0, openDialogCount - 1);++ if (openDialogCount === 0) {+ lastAllDialogsClosedAt = performance.now();+ }+ });+return (<KobalteDialog onOpenChange={props.onOpenChange} open={props.open} modal><KobalteDialog.Portal>- <KobalteDialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay pattern-edge-muted pattern-diagonal-4" />+ <KobalteDialog.Overlay+ class={cn(+ 'hidden fixed inset-0 z-modal bg-modal-overlay',+ animateOnOpen() && 'dialog-overlay-open-animation',+ Boolean(props.visibleScrim) && 'visible'+ )}+ /><divclass={cn('fixed top-0 bottom-(--virtual-keyboard-height,0) inset-x-0 z-modal flex',@@ -37,13 +88,21 @@ export function Dialog(props: DialogProps) {<KobalteDialog.Contentref={props.contentRef}class={cn(- 'overflow-hidden portal-scope isolate',+ 'portal-scope isolate rounded-xl',props.fullscreen ? 'size-full' : 'w-200 max-w-[calc(100vw-16px)]',+ animateOnOpen() &&+ (props.fullscreen+ ? 'dialog-fullscreen-open-animation'+ : 'dialog-content-open-animation'),props.class)}onCloseAutoFocus={props.onCloseAutoFocus}onEscapeKeyDown={props.onEscapeKeyDown}onOpenAutoFocus={props.onOpenAutoFocus}+ style={{+ 'box-shadow':+ '0 5px 40px rgba(0, 0, 0, 0.1), 0 5px 50px rgba(0,0,0,0.03)',+ }}>{props.children}</KobalteDialog.Content>diff --git a/apps/web/src/components/ui/index.ts b/apps/web/src/components/ui/index.tsindex 05c6d66247..9d29081871 100644--- a/apps/web/src/components/ui/index.ts+++ b/apps/web/src/components/ui/index.ts@@ -20,6 +20,15 @@ export {} from './components/Checkbox';export type { CollapsedInputProps } from './components/CollapsedInput';export { CollapsedInput } from './components/CollapsedInput';+export {+ type CommandListController,+ CommandMenuEmptyState,+ CommandMenuHotkeyHint,+ CommandMenuListItem,+ CommandMenuSearchInput,+ CommandMenuShell,+ createCommandListController,+} from './components/CommandMenuPrimitives';export type { DialogProps } from './components/Dialog';export { Dialog } from './components/Dialog';export { Dropdown } from './components/Dropdown';diff --git a/apps/web/src/features/command/CommandItem.tsx b/apps/web/src/features/command/CommandItem.tsxindex a4e7c46774..7067926296 100644--- a/apps/web/src/features/command/CommandItem.tsx+++ b/apps/web/src/features/command/CommandItem.tsx@@ -10,7 +10,7 @@ import {enqueueDocumentWakeup,isWakeableDocument,} from '@queries/preview';-import { cn, Hotkey } from '@ui';+import { CommandMenuListItem, Hotkey } from '@ui';import { createEffect, For, Match, Show, Switch } from 'solid-js';import { Dynamic } from 'solid-js/web';import type { DisplayHotkeyStep } from './types';@@ -31,7 +31,7 @@ interface CommandItemProps {index: number;selected: boolean;onSelect: (item: CommandMenuItem, openInNewSplit: boolean) => void;- onHover?: (index: number) => void;+ onMouseMove?: (index: number) => void;}function CommandItemHotkey(props: { item: CommandMenuItem }) {@@ -221,15 +221,10 @@ function ItemDisplay(props: { item: CommandMenuItem }) {export function CommandItem(props: CommandItemProps) {return (- <div- class={cn(- 'rounded-md group flex items-center h-10 px-2 text-sm font-semibold relative',- {- 'bg-active': props.selected,- 'hover:bg-hover/50': !props.selected,- }- )}- onMouseMove={() => props.onHover?.(props.index)}+ <CommandMenuListItem+ as="div"+ selected={props.selected}+ onMouseMove={() => props.onMouseMove?.(props.index)}onClick={(e) => {e.preventDefault();e.stopPropagation();@@ -240,6 +235,6 @@ export function CommandItem(props: CommandItemProps) {<div class="ml-auto"><CommandItemHotkey item={props.item} /></div>- </div>+ </CommandMenuListItem>);}diff --git a/apps/web/src/features/command/CommandMenu.tsx b/apps/web/src/features/command/CommandMenu.tsxindex 728e626324..7b4cfd748e 100644--- a/apps/web/src/features/command/CommandMenu.tsx+++ b/apps/web/src/features/command/CommandMenu.tsx@@ -22,7 +22,16 @@ import { openExternalUrl } from '@core/util/url';import { type EntityData, InlineEntity, isGithubPrEntity } from '@entity';import Macro from '@icon/macro-logo.svg';import ArrowLeft from '@phosphor/arrow-left.svg';-import { cn, Dialog, Hotkey, Panel } from '@ui';+import {+ CommandMenuEmptyState,+ CommandMenuHotkeyHint,+ CommandMenuSearchInput,+ CommandMenuShell,+ cn,+ createCommandListController,+ Dialog,+ Hotkey,+} from '@ui';import {createEffect,createMemo,@@ -140,15 +149,17 @@ export function CommandMenuInner(props: {? undefined: useCommandItems(query, CommandState.categoryFilter);const filteredItems = props.items ?? defaultFilteredItems!;- const [shouldScrollSelectedIntoView, setShouldScrollSelectedIntoView] =- createSignal(false);+ const listController = createCommandListController({+ items: filteredItems,+ selectedIndex: CommandState.selectedIndex,+ setSelectedIndex: CommandState.setSelectedIndex,+ });createEffect(() => {const items = filteredItems();const current = CommandState.selectedIndex();if (current >= items.length && items.length > 0) {- setShouldScrollSelectedIntoView(false);- CommandState.setSelectedIndex(items.length - 1);+ listController.setSelectedIndex(items.length - 1);}});@@ -160,8 +171,7 @@ export function CommandMenuInner(props: {// no results the rows below are fallbacks (ask AI), and the search row// should stay the default.const secondIsResult = items[1] && !isAskAiItem(items[1]);- setShouldScrollSelectedIntoView(false);- CommandState.setSelectedIndex(firstIsSearch && secondIsResult ? 1 : 0);+ listController.setSelectedIndex(firstIsSearch && secondIsResult ? 1 : 0);}));@@ -367,9 +377,7 @@ export function CommandMenuInner(props: {keyDownHandler: () => {const items = filteredItems();if (items.length === 0) return false;- setShouldScrollSelectedIntoView(true);- CommandState.setSelectedIndex((prev) => (prev + 1) % items.length);- return true;+ return listController.selectNext();},runWithInputFocused: true,hide: true,@@ -382,11 +390,7 @@ export function CommandMenuInner(props: {keyDownHandler: () => {const items = filteredItems();if (items.length === 0) return false;- setShouldScrollSelectedIntoView(true);- CommandState.setSelectedIndex(- (prev) => (prev - 1 + items.length) % items.length- );- return true;+ return listController.selectPrevious();},runWithInputFocused: true,hide: true,@@ -506,28 +510,6 @@ export function CommandMenuInner(props: {}});- const [isKeyboardActive, setIsKeyboardActive] = createSignal(false);-- function handleMouseEnter(index: number) {- if (isKeyboardActive()) return;- setShouldScrollSelectedIntoView(false);- CommandState.setSelectedIndex(index);- }-- // Track keyboard activity to prevent mouse hover from interfering- createEffect(() => {- const handleKeyDown = () => setIsKeyboardActive(true);- const handleMouseMove = () => setIsKeyboardActive(false);-- document.addEventListener('keydown', handleKeyDown);- document.addEventListener('mousemove', handleMouseMove);-- return () => {- document.removeEventListener('keydown', handleKeyDown);- document.removeEventListener('mousemove', handleMouseMove);- };- });-const isInCommandScope = createMemo(() => CommandState.commandScopeCommands().length > 0);@@ -563,12 +545,12 @@ export function CommandMenuInner(props: {}));return (- <Panel+ <CommandMenuShellclass={cn('max-h-[75vh] rounded-xl', props.class)}ref={setCommandMenuRef}depth={props.depth}>- <Panel.Header class="gap-2 px-2 bg-surface">+ <CommandMenuShell.Header><Showwhen={isInCommandScope()}fallback={@@ -585,9 +567,8 @@ export function CommandMenuInner(props: {<ArrowLeft class="size-3" /></button></Show>- <input+ <CommandMenuSearchInputtype="text"- class="flex-1 bg-transparent border-0 outline-none focus:outline-none ring-0 focus:ring-0 text-ink-muted placeholder:text-ink-placeholder"placeholder={CommandState.commandScopePlaceholder() ??(isEntityActionMode() ? 'Search actions...' : 'Search...')@@ -596,12 +577,12 @@ export function CommandMenuInner(props: {onInput={(e) => CommandState.setQuery(e.currentTarget.value)}autofocus/>- </Panel.Header>+ </CommandMenuShell.Header><Show when={isEntityActionMode() || !isInCommandScope()}>- <Panel.Toolbar+ <CommandMenuShell.Toolbarclass={cn(- 'bg-surface pl-2.5 pr-1.5 pt-2 border-0',+ 'pl-2.5 pr-1.5 pt-2 border-0',isEntityActionMode() && 'gap-1.5')}>@@ -624,18 +605,18 @@ export function CommandMenuInner(props: {entities={CommandState.entityActionEntities()}/></Show>- </Panel.Toolbar>+ </CommandMenuShell.Toolbar></Show>- <Panel.Body>+ <CommandMenuShell.Body><div- class="bg-surface overflow-hidden transition-[height] duration-60 ease-out"+ class="bg-surface overflow-hidden transition-[height] duration-60 ease-out p-2"style={{ height: `${resultsHeight()}px` }}><Showwhen={filteredItems().length > 0}fallback={- <div class="p-4 text-center text-ink-muted">No results found</div>+ <CommandMenuEmptyState>No results found</CommandMenuEmptyState>}><VirtualizedCommandList@@ -644,14 +625,14 @@ export function CommandMenuInner(props: {onSelect={(item, openInNewSplit) =>handleItemAction(item, openInNewSplit)}- onMouseEnter={handleMouseEnter}- scrollSelectedIntoView={shouldScrollSelectedIntoView()}+ onItemMouseMove={listController.setSelectedIndexFromPointer}+ scrollSelectedIntoView={listController.shouldScrollSelectedIntoView()}/></Show></div>- </Panel.Body>+ </CommandMenuShell.Body>- <Panel.Footer class="gap-4 px-4 bg-surface text-xs text-ink-extra-muted/80">+ <CommandMenuShell.Footer><span class="flex items-center gap-1"><div class="flex gap-1"><div class="flex border border-edge-muted text-xxs rounded-md items-center px-1.5 py-px font-normal">@@ -704,8 +685,8 @@ export function CommandMenuInner(props: {><HotkeyHint command={escapeHotkey} label="Back" /></Show>- </Panel.Footer>- </Panel>+ </CommandMenuShell.Footer>+ </CommandMenuShell>);}@@ -746,7 +727,7 @@ function VirtualizedCommandList(props: {items: CommandMenuItem[];selectedIndex: number;onSelect: (item: CommandMenuItem, openInNewSplit: boolean) => void;- onMouseEnter: (index: number) => void;+ onItemMouseMove: (index: number) => void;scrollSelectedIntoView: boolean;}) {let virtualizerHandle: VirtualizerHandle | undefined;@@ -783,7 +764,7 @@ function VirtualizedCommandList(props: {}}data={props.items}style={{ height: '100%' }}- class="scrollbar-hidden p-2"+ class="scrollbar-hidden">{(item, index) => (<CommandItem@@ -791,7 +772,7 @@ function VirtualizedCommandList(props: {index={index()}selected={selector(index())}onSelect={props.onSelect}- onHover={props.onMouseEnter}+ onMouseMove={props.onItemMouseMove}/>)}</VList>@@ -800,11 +781,9 @@ function VirtualizedCommandList(props: {function HotkeyHint(props: { command: RegisterHotkeyReturn; label: string }) {return (- <span class="flex items-center gap-1">- <div class="flex border border-edge-muted text-xxs rounded-md items-center px-1.5 py-px font-normal">- <Hotkey shortcut={props.command.hotkey()} class="space-x-1" />- </div>- {props.label}- </span>+ <CommandMenuHotkeyHint+ hotkey={<Hotkey shortcut={props.command.hotkey()} class="space-x-1" />}+ label={props.label}+ />);}diff --git a/apps/web/src/features/command/Launcher.tsx b/apps/web/src/features/command/Launcher.tsxindex efb7e32607..d6e927f9ad 100644--- a/apps/web/src/features/command/Launcher.tsx+++ b/apps/web/src/features/command/Launcher.tsx@@ -52,7 +52,7 @@ import { Dialog } from '@kobalte/core/dialog';import { getMarkdownGoldenBytes } from '@macro-inc/lexical-core/markdown-golden';import ArrowRight from '@phosphor/arrow-right.svg';import { createProject } from '@queries/storage/projects';-import { cn, Hotkey, Layer } from '@ui';+import { CommandMenuShell, cn, Hotkey, Layer } from '@ui';import { getNormalizedKeyString } from '@ui/components/Hotkey';import {createEffect,@@ -747,8 +747,11 @@ export const LauncherInner = (props: LauncherInnerProps) => {onCleanup(hkGroup.dispose);return (- <div class="bg-surface ring ring-edge-muted rounded-xl max-w-[calc(100vw-2rem)]">- <div class="flex items-center justify-between p-2 px-4 sm:px-6 border-b border-edge-muted">+ <CommandMenuShell+ depth={2}+ class="h-auto w-fit max-w-[calc(100vw-2rem)] shadow-menu menu-open-animation"+ >+ <CommandMenuShell.Header class="my-0 justify-between p-2 px-4 sm:px-6 bg-surface"><h1 class="font-bold text-ink-muted">Create New</h1><p class="gap-2 text-ink-extra-muted text-xs items-center hidden touch:hidden md:flex"><style>{`@@ -779,23 +782,25 @@ export const LauncherInner = (props: LauncherInnerProps) => {</span>to launch in new split</p>- </div>- <div- class="relative grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 justify-items-center gap-3 p-4 sm:p-6 isolate brackets-never"- ref={ref}- >- <For each={blocks()}>- {(item, index) => (- <LauncherMenuItem- creatableBlock={item}- onMouseEnter={() => setFocusedIndex(index())}- onFocus={() => setFocusedIndex(index())}- focused={focusedIndex() === index()}- />- )}- </For>- </div>- </div>+ </CommandMenuShell.Header>+ <CommandMenuShell.Body>+ <div+ class="relative grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 justify-items-center gap-3 p-4 sm:p-6 isolate brackets-never"+ ref={ref}+ >+ <For each={blocks()}>+ {(item, index) => (+ <LauncherMenuItem+ creatableBlock={item}+ onMouseEnter={() => setFocusedIndex(index())}+ onFocus={() => setFocusedIndex(index())}+ focused={focusedIndex() === index()}+ />+ )}+ </For>+ </div>+ </CommandMenuShell.Body>+ </CommandMenuShell>);};@@ -808,24 +813,25 @@ export const Launcher = (props: LauncherProps) => {return (<Dialog open={props.open} onOpenChange={props.onOpenChange} modal={true}><Dialog.Portal>- <Dialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay pattern-diagonal-4 pattern-edge-muted"></Dialog.Overlay>+ <Dialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay"></Dialog.Overlay><Dialog.Content>- <Layer depth={3}>- <div- class="fixed inset-0 z-modal w-screen h-screen flex items-center justify-center"- onClick={(e) => {- if (e.target === e.currentTarget) {- props.onOpenChange(false);- }- }}- >- <LauncherInner- onClose={(shouldReturnFocus) =>- props.onOpenChange(false, shouldReturnFocus)- }- />- </div>- </Layer>+ <div+ class={cn(+ 'fixed top-0 bottom-(--virtual-keyboard-height,0) inset-x-0 z-modal w-screen flex justify-center px-2',+ isMobile() ? 'items-center' : 'items-start pt-[10vh]'+ )}+ onClick={(e) => {+ if (e.target === e.currentTarget) {+ props.onOpenChange(false);+ }+ }}+ >+ <LauncherInner+ onClose={(shouldReturnFocus) =>+ props.onOpenChange(false, shouldReturnFocus)+ }+ />+ </div></Dialog.Content></Dialog.Portal></Dialog>diff --git a/apps/web/src/features/next-soup/actions/use-block-entity-commands.ts b/apps/web/src/features/next-soup/actions/use-block-entity-commands.tsindex 81c04b8050..cc3b8206e2 100644--- a/apps/web/src/features/next-soup/actions/use-block-entity-commands.ts+++ b/apps/web/src/features/next-soup/actions/use-block-entity-commands.ts@@ -15,6 +15,7 @@ import { blockHotkeyScopeSignal } from '@core/signal/blockElement';import { type EntityData, isTaskEntity } from '@entity';import { SYSTEM_PROPERTY_IDS } from '@property/constants';import type { Property, PropertyDefinitionDomain } from '@property/types';+import { macroEntityToPropertyEntityType } from '@property/utils';import { createEffect, onCleanup } from 'solid-js';import {makeCopyAction,@@ -81,6 +82,14 @@ export const useBlockEntityCommands = () => {openPropertyEditor([entity], mode, property);}};+ const canAssignTags = (entity: EntityData) => {+ try {+ macroEntityToPropertyEntityType(entity);+ return true;+ } catch {+ return false;+ }+ };// The 'e' hotkey from inside a block is reserved for entities opened full// screen from the inbox/mail lists, mirroring the j/k gating in@@ -341,6 +350,26 @@ export const useBlockEntityCommands = () => {tags: [HotkeyTags.SelectionModification],}).withGroup(group);+ // Assign tags - 't'+ registerHotkey({+ hotkey: ['t'],+ hotkeyToken: TOKENS.entity.action.tags,+ scopeId,+ description: 'Tag item',+ keyDownHandler: () => {+ const entity = getEntity();+ if (!entity) return false;+ openPropertyEditor([entity], 'tag');+ return true;+ },+ condition: () => {+ const entity = getEntity();+ return entity !== undefined && canAssignTags(entity);+ },+ displayPriority: 10,+ tags: [HotkeyTags.SelectionModification],+ }).withGroup(group);+// Set priority - 'shift+cmd+p'registerHotkey({hotkey: ['shift+cmd+p'],diff --git a/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts b/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.tsindex 99cd0bd002..2b3240d0d0 100644--- a/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts+++ b/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts@@ -13,6 +13,7 @@ import { TOKENS } from '@core/hotkey/tokens';import { type EntityData, isTaskEntity } from '@entity';import { SYSTEM_PROPERTY_IDS } from '@property/constants';import type { Property, PropertyDefinitionDomain } from '@property/types';+import { macroEntityToPropertyEntityType } from '@property/utils';import { onCleanup } from 'solid-js';import type { SoupState } from '../create-soup-state';import {@@ -128,6 +129,14 @@ export const useEntityActionHotkeys = (openPropertyEditor(entities, mode, property);}};+ const canAssignTags = (entity: EntityData) => {+ try {+ macroEntityToPropertyEntityType(entity);+ return true;+ } catch {+ return false;+ }+ };// Mark Done - 'e', not included in Hotkey Group so that we can use it from inside of blocksregisterHotkey({@@ -407,6 +416,30 @@ export const useEntityActionHotkeys = (scopeId,}).withGroup(group);+ // Assign tags - t+ registerHotkey({+ hotkey: ['t'],+ hotkeyToken: TOKENS.entity.action.tags,+ tags: [HotkeyTags.SelectionModification],+ displayPriority: 10,+ description: () => {+ const count = getEntitiesForAction().length;+ return count > 1 ? 'Tag items' : 'Tag item';+ },+ keyDownHandler: () => {+ const entities = getEntitiesForAction();+ if (entities.length === 0) return false;+ openPropertyEditor(entities, 'tag');+ return true;+ },+ condition: () => {+ if (condition && !condition()) return false;+ const entities = getEntitiesForAction();+ return entities.length > 0 && entities.every(canAssignTags);+ },+ scopeId,+ }).withGroup(group);+// Set priority - shift+cmd+pregisterHotkey({hotkey: ['shift+cmd+p'],diff --git a/apps/web/src/features/property/editor/PropertyEditorModal.tsx b/apps/web/src/features/property/editor/PropertyEditorModal.tsxindex 5788dfe9f7..7e2e145044 100644--- a/apps/web/src/features/property/editor/PropertyEditorModal.tsx+++ b/apps/web/src/features/property/editor/PropertyEditorModal.tsx@@ -4,17 +4,20 @@ import type { IUser } from '@core/user';import { idToDisplayName, idToEmail } from '@core/user/util';import { useDateSearch } from '@core/util/dateSearch/useDateSearch';import { fuzzyFilter } from '@core/util/fuzzy';-import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';import {type ListNavActions,useListKeyBindings,} from '@core/util/useListKeyBindings';import { type EntityData, InlineEntity } from '@entity';+import PropertiesIcon from '@phosphor/sliders-horizontal.svg';+import TagIcon from '@phosphor/tag-simple.svg';import { type CombinedEntity, getEntityName, getEntityType } from '@property';import { PropertyValueIcon } from '@property/component/propertyValue';import { SYSTEM_PROPERTY_IDS } from '@property/constants';+import { OptionCheckBox } from '@property/editors/selectors/OptionCheckBox';import { usePropertySelection } from '@property/hooks';import { usePropertyEntityDisplay } from '@property/hooks/usePropertyEntityDisplay';+import { TagDot } from '@property/tags/TagDot';import type {Property,PropertyApiValues,@@ -25,11 +28,27 @@ import {PropertyDataTypeIcon,toPropertyApiValue,} from '@property/utils';-import { useEntityPropertiesQuery } from '@queries/properties/entity';+import {+ useAddEntityPropertyOptionMutation,+ useEntityPropertiesQuery,+ useRemoveEntityPropertyOptionMutation,+} from '@queries/properties/entity';+import { useTagsQuery } from '@queries/properties/tags';import { useCurrentTeamQuery } from '@queries/team/teams';import type { EntityReference } from '@service-properties/generated/schemas/entityReference';+import type { PropertyDefinitionDetailResponse } from '@service-properties/generated/schemas/propertyDefinitionDetailResponse';+import type { PropertyOptionResponse } from '@service-properties/generated/schemas/propertyOptionResponse';+import type { TagScope } from '@service-properties/generated/schemas/tagScope';import { mergeRefs } from '@solid-primitives/refs';-import { cn, Dialog, Hotkey, Surface } from '@ui';+import {+ CommandMenuEmptyState,+ CommandMenuListItem,+ CommandMenuSearchInput,+ CommandMenuShell,+ cn,+ Dialog,+ Hotkey,+} from '@ui';import {type Accessor,createEffect,@@ -63,30 +82,100 @@ function ListItem(props: {id: string;isSelected: boolean;disabled?: boolean;- onClick: () => void;+ onClick: (event: MouseEvent) => void;onMouseEnter: () => void;children: JSX.Element;+ class?: string;}) {return (- <button- type="button"+ <CommandMenuListItemid={props.id}+ selected={props.isSelected}disabled={props.disabled}- class={cn(- 'rounded-md group w-full flex items-center h-10 px-2 gap-2 text-sm font-semibold relative scroll-m-1',- {- 'bg-active': props.isSelected,- 'hover:bg-hover/50': !props.isSelected,- }- )}onClick={props.onClick}- onMouseEnter={props.onMouseEnter}+ onMouseMove={props.onMouseEnter}+ class={props.class}>{props.children}- </button>+ </CommandMenuListItem>);}+type TagOptionItem = {+ scope: TagScope;+ definition: PropertyDefinitionDetailResponse;+ option: PropertyOptionResponse;+};++type EntityTagIdsByDefinition = Map<string, Map<string, string[]>>;++function tagOptionLabel(option: PropertyOptionResponse): string {+ return option.value.type === 'string' ? option.value.value : '';+}++function tagDefinitionDomain(+ definition: PropertyDefinitionDetailResponse+): PropertyDefinitionDomain {+ return {+ id: definition.id,+ displayName: definition.displayName,+ valueType: 'TAG',+ isMultiSelect: true,+ isMetadata: definition.isMetadata,+ isSystem: definition.isSystem,+ owner: definition,+ createdAt: definition.createdAt ?? new Date().toISOString(),+ updatedAt: definition.updatedAt ?? new Date().toISOString(),+ };+}++function entityTagIdsByDefinition(+ entities: EntityData[],+ fetchedProperties?: { entityId: string; properties: Property[] }+): EntityTagIdsByDefinition {+ const byEntity = new Map<string, Map<string, string[]>>();++ for (const entity of entities) {+ const byDefinition = new Map<string, string[]>();++ if (fetchedProperties?.entityId === entity.id) {+ for (const property of fetchedProperties.properties) {+ if (property.valueType === 'SELECT_STRING' && property.value) {+ byDefinition.set(property.propertyDefinitionId, property.value);+ }+ }+ } else {+ const properties = 'properties' in entity ? entity.properties : undefined;+ for (const property of properties ?? []) {+ if (property.value?.type === 'SelectOption') {+ byDefinition.set(property.definition.id, property.value.value);+ }+ }+ }++ byEntity.set(entity.id, byDefinition);+ }++ return byEntity;+}++function getTagIds(+ byEntity: EntityTagIdsByDefinition,+ entityId: string,+ definitionId: string+) {+ return byEntity.get(entityId)?.get(definitionId) ?? [];+}++function canAssignTags(entity: EntityData): boolean {+ try {+ macroEntityToPropertyEntityType(entity);+ return true;+ } catch {+ return false;+ }+}+export function PropertyEditorModal() {const [dialogRef, setDialogRef] = createSignal<HTMLElement | undefined>();const [attach, hotkeyScope] = useHotkeyDOMScope('property-editor');@@ -135,9 +224,7 @@ export function PropertyEditorModal() {}));- const { isKeypressActive } = useIsKeyPressActive();const setSelectedIndexFromMouse = (index: number) => {- if (isKeypressActive()) return;setSelectedIndex(index);};@@ -149,55 +236,66 @@ export function PropertyEditorModal() {onOpenChange={togglePropertyEditor}contentRef={mergeRefs(attach, setDialogRef)}>- <Surface depth={2} class="rounded-xl">- <div class="*:max-h-[75vh]">- <div class="flex flex-col max-h-108 overflow-hidden text-sm">- <div class="flex items-center gap-2 bg-surface px-2 h-10 border-b border-edge-muted shrink-0">- <span class="pl-2 pointer-events-none">❯</span>- <SearchInput- placeHolder={placeholder() || defaultPlaceholder}- value={searchValue}- setValue={setSearchValue}- focusedIndex={selectedIndex}- setFocusedIndex={setSelectedIndex}- inputType={inputType()}+ <CommandMenuShell depth={2} class="rounded-xl max-h-108 text-sm">+ <CommandMenuShell.Header>+ <span class="pl-2 text-ink-extra-muted/55 pointer-events-none">+ <PropertiesIcon class="size-3" />+ </span>+ <SearchInput+ placeHolder={placeholder() || defaultPlaceholder}+ value={searchValue}+ setValue={setSearchValue}+ focusedIndex={selectedIndex}+ setFocusedIndex={setSelectedIndex}+ inputType={inputType()}+ />+ </CommandMenuShell.Header>+ <CommandMenuShell.Toolbar class="p-3 py-2 border-b-0">+ <EditingEntityPreview+ entities={propertyEditorState.selectedEntities}+ />+ </CommandMenuShell.Toolbar>+ <CommandMenuShell.Body>+ <Switch>+ <Match when={propertyEditorState.mode === 'selector'}>+ <div class="overflow-scroll scrollbar-hidden">+ <PropertyList+ searchTerm={searchValue()}+ focusedIndex={selectedIndex}+ setFocusedIndex={setSelectedIndex}+ setFocusedIndexFromMouse={setSelectedIndexFromMouse}+ setKeybindings={keybindings}+ />+ </div>+ </Match>+ <Match when={propertyEditorState.mode === 'direct'}>+ <PropertyValueEditor+ property={propertyEditorState.targetProperty}+ searchValue={searchValue}+ setSearchValue={setSearchValue}+ selectedIndex={selectedIndex}+ setSelectedIndex={setSelectedIndex}+ setSelectedIndexFromMouse={setSelectedIndexFromMouse}+ setKeybindings={keybindings}+ setPlaceholder={setPlaceholder}+ setInputType={setInputType}+ onSave={handlePropertySave}/>- </div>- <div class="p-2 border-b border-edge-muted">- <EditingEntityPreview+ </Match>+ <Match when={propertyEditorState.mode === 'tag'}>+ <TagAssignmentEditorentities={propertyEditorState.selectedEntities}+ searchValue={searchValue}+ selectedIndex={selectedIndex}+ setSelectedIndex={setSelectedIndex}+ setSelectedIndexFromMouse={setSelectedIndexFromMouse}+ setKeybindings={keybindings}+ setPlaceholder={setPlaceholder}/>- </div>- <Switch>- <Match when={propertyEditorState.mode === 'selector'}>- <div class="overflow-scroll scrollbar-hidden">- <PropertyList- searchTerm={searchValue()}- focusedIndex={selectedIndex}- setFocusedIndex={setSelectedIndex}- setFocusedIndexFromMouse={setSelectedIndexFromMouse}- setKeybindings={keybindings}- />- </div>- </Match>- <Match when={propertyEditorState.mode === 'direct'}>- <PropertyValueEditor- property={propertyEditorState.targetProperty}- searchValue={searchValue}- setSearchValue={setSearchValue}- selectedIndex={selectedIndex}- setSelectedIndex={setSelectedIndex}- setSelectedIndexFromMouse={setSelectedIndexFromMouse}- setKeybindings={keybindings}- setPlaceholder={setPlaceholder}- setInputType={setInputType}- onSave={handlePropertySave}- />- </Match>- </Switch>- </div>- </div>- </Surface>+ </Match>+ </Switch>+ </CommandMenuShell.Body>+ </CommandMenuShell></Dialog>);}@@ -218,10 +316,10 @@ function SearchInput(props: {});return (- <input+ <CommandMenuSearchInputref={inputRef}type={props.inputType ?? 'text'}- class="flex-1 text-base border-0 outline-none! focus:outline-none ring-0! focus:ring-0"+ class="text-base"placeholder={props.placeHolder}value={props.value()}onInput={(e) => props.setValue(e.target.value)}@@ -251,6 +349,17 @@ function PropertyList(props: {() => props.searchTerm);+ const showTagAssignmentOption = createMemo(() => {+ const query = props.searchTerm.toLowerCase().trim();+ return (+ propertyEditorState.selectedEntities.every(canAssignTags) &&+ (!query || 'tags'.includes(query) || 'label'.includes(query))+ );+ });++ const rowCount = () =>+ filteredProperties().length + (showTagAssignmentOption() ? 1 : 0);+createEffect(() => {props.searchTerm;props.setFocusedIndex(0);@@ -258,15 +367,25 @@ function PropertyList(props: {props.setKeybindings({next: () => {- const len = filteredProperties().length;+ const len = rowCount();+ if (len === 0) return;props.setFocusedIndex((prev) => (prev + 1) % len);},previous: () => {- const len = filteredProperties().length;+ const len = rowCount();+ if (len === 0) return;props.setFocusedIndex((prev) => (prev - 1 + len) % len);},select: () => {- const focusedProperty = filteredProperties()[props.focusedIndex()];+ if (showTagAssignmentOption() && props.focusedIndex() === 0) {+ setPropertyEditorMode('tag');+ return;+ }++ const focusedProperty =+ filteredProperties()[+ props.focusedIndex() - (showTagAssignmentOption() ? 1 : 0)+ ];if (focusedProperty) {setProperty(focusedProperty);}@@ -275,7 +394,11 @@ function PropertyList(props: {createEffect(() => {const index = props.focusedIndex();- const elem = document.getElementById(`property-editor-option-${index}`);+ const elem = document.getElementById(+ showTagAssignmentOption() && index === 0+ ? 'property-editor-option-tags'+ : `property-editor-option-${index}`+ );if (elem) {elem.scrollIntoView({ block: 'nearest' });}@@ -290,24 +413,45 @@ function PropertyList(props: {return (<Show- when={filteredProperties().length > 0}+ when={rowCount() > 0}fallback={- <div class="text-center py-4 text-ink-muted text-sm">+ <CommandMenuEmptyState>No matching properties found- </div>+ </CommandMenuEmptyState>}><divref={containerRef}- class="max-h-52 overflow-y-auto overflow-x-hidden scrollbar-hidden p-1"+ class="max-h-54 overflow-y-auto overflow-x-hidden scrollbar-hidden p-2">+ <Show when={showTagAssignmentOption()}>+ <ListItem+ id="property-editor-option-tags"+ isSelected={selector(0)}+ onClick={() => setPropertyEditorMode('tag')}+ onMouseEnter={() => props.setFocusedIndexFromMouse(0)}+ class="scroll-m-2"+ >+ <TagIcon class="size-4 text-ink-muted opacity-50" />+ <div class="flex-1 text-left flex">+ <p class="text-sm font-medium">Tags</p>+ </div>+ </ListItem>+ </Show><For each={filteredProperties()}>{(property, index) => (<ListItem- id={`property-editor-option-${index()}`}- isSelected={selector(index())}+ id={`property-editor-option-${index() + (showTagAssignmentOption() ? 1 : 0)}`}+ isSelected={selector(+ index() + (showTagAssignmentOption() ? 1 : 0)+ )}onClick={() => setProperty(property)}- onMouseEnter={() => props.setFocusedIndexFromMouse(index())}+ onMouseEnter={() =>+ props.setFocusedIndexFromMouse(+ index() + (showTagAssignmentOption() ? 1 : 0)+ )+ }+ class="scroll-m-2"><PropertyDataTypeIcon property={property} class="opacity-50" /><div class="flex-1 text-left flex">@@ -351,6 +495,275 @@ function EditingEntityPreview(props: { entities: EntityData[] }) {);}+function TagAssignmentEditor(props: {+ entities: EntityData[];+ searchValue: Accessor<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ setSelectedIndexFromMouse: (index: number) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+}) {+ const tagsQuery = useTagsQuery();+ const currentTeamQuery = useCurrentTeamQuery();+ const addOption = useAddEntityPropertyOptionMutation();+ const removeOption = useRemoveEntityPropertyOptionMutation();+ const singleEntity = () =>+ props.entities.length === 1 ? props.entities[0] : undefined;+ const entityPropertiesQuery = useEntityPropertiesQuery(+ () => {+ const entity = singleEntity();+ return entity ? macroEntityToPropertyEntityType(entity) : 'DOCUMENT';+ },+ () => singleEntity()?.id ?? '',+ false+ );+ const currentEntityTagIds = () =>+ entityTagIdsByDefinition(+ props.entities,+ singleEntity() && entityPropertiesQuery.data+ ? {+ entityId: singleEntity()!.id,+ properties: entityPropertiesQuery.data,+ }+ : undefined+ );+ const initialEntityTagIds = currentEntityTagIds();+ const [orderedTagIds, setOrderedTagIds] =+ createSignal<EntityTagIdsByDefinition>(initialEntityTagIds);+ const [localTagIds, setLocalTagIds] =+ createSignal<EntityTagIdsByDefinition>(initialEntityTagIds);+ const [hasEditedTags, setHasEditedTags] = createSignal(false);+ let syncedEntityIds = props.entities.map((entity) => entity.id).join('\0');++ createEffect(() => {+ props.setPlaceholder('Change or add tags...');+ });++ createEffect(+ on(+ () => ({+ entityIds: props.entities.map((entity) => entity.id).join('\0'),+ properties: entityPropertiesQuery.data,+ }),+ ({ entityIds }) => {+ const entityIdsChanged = entityIds !== syncedEntityIds;+ if (entityIdsChanged) {+ syncedEntityIds = entityIds;+ setHasEditedTags(false);+ }+ if (hasEditedTags() && !entityIdsChanged) return;++ const nextTagIds = currentEntityTagIds();+ setOrderedTagIds(nextTagIds);+ setLocalTagIds(nextTagIds);+ }+ )+ );++ const teamName = () => currentTeamQuery.data?.team.name?.trim() || 'Team';++ const tagItems = createMemo<TagOptionItem[]>(() => {+ const items: TagOptionItem[] = [];+ for (const set of tagsQuery.data ?? []) {+ if (!set.definition) continue;+ const sortedOptions = [...set.options].sort(+ (a, b) => a.displayOrder - b.displayOrder+ );+ for (const option of sortedOptions) {+ items.push({ scope: set.scope, definition: set.definition, option });+ }+ }+ return items;+ });++ const isFullyApplied = (item: TagOptionItem) => {+ if (props.entities.length === 0) return false;+ return props.entities.every((entity) =>+ getTagIds(localTagIds(), entity.id, item.definition.id).includes(+ item.option.id+ )+ );+ };++ const wasFullyAppliedWhenOpened = (item: TagOptionItem) => {+ if (props.entities.length === 0) return false;+ return props.entities.every((entity) =>+ getTagIds(orderedTagIds(), entity.id, item.definition.id).includes(+ item.option.id+ )+ );+ };++ const filteredItems = createMemo(() => {+ const query = props.searchValue().trim().toLowerCase();+ const matchesQuery = (item: TagOptionItem) =>+ !query || tagOptionLabel(item.option).toLowerCase().includes(query);++ const matchingItems = tagItems().filter(matchesQuery);+ const applied = matchingItems.filter(wasFullyAppliedWhenOpened);+ const remaining = matchingItems.filter(+ (item) => !wasFullyAppliedWhenOpened(item)+ );++ return [...applied, ...remaining];+ });+ const selectedGroupSize = createMemo(+ () => filteredItems().filter(wasFullyAppliedWhenOpened).length+ );++ createEffect(() => {+ props.searchValue();+ props.setSelectedIndex(0);+ });++ createEffect(() => {+ const index = props.selectedIndex();+ const elem = document.getElementById(`tag-assignment-option-${index}`);+ elem?.scrollIntoView({ block: 'nearest' });+ });++ const updateLocalOption = (item: TagOptionItem, remove: boolean) => {+ setLocalTagIds((prev) => {+ const next = new Map(prev);+ for (const entity of props.entities) {+ const byDefinition = new Map(next.get(entity.id) ?? []);+ const current = byDefinition.get(item.definition.id) ?? [];+ byDefinition.set(+ item.definition.id,+ remove+ ? current.filter((id) => id !== item.option.id)+ : current.includes(item.option.id)+ ? current+ : [...current, item.option.id]+ );+ next.set(entity.id, byDefinition);+ }+ return next;+ });+ };++ const toggleTag = async (+ item: TagOptionItem,+ event?: KeyboardEvent | MouseEvent+ ) => {+ const remove = isFullyApplied(item);+ const shouldClose = !event?.shiftKey;+ const previousTagIds = localTagIds();+ setHasEditedTags(true);+ updateLocalOption(item, remove);++ try {+ const update = Promise.all(+ props.entities.map(async (entity) => {+ const entityType = macroEntityToPropertyEntityType(entity);+ const current = getTagIds(+ previousTagIds,+ entity.id,+ item.definition.id+ );+ const hasOption = current.includes(item.option.id);++ if (remove && !hasOption) return;+ if (!remove && hasOption) return;++ const optimisticOptionIds = remove+ ? current.filter((id) => id !== item.option.id)+ : [...current, item.option.id];+ const mutation = remove ? removeOption : addOption;++ await mutation.mutateAsync({+ entityId: entity.id,+ entityType,+ property: tagDefinitionDomain(item.definition),+ optionId: item.option.id,+ optimisticOptionIds,+ });+ })+ );++ if (shouldClose) closePropertyEditor();+ await update;+ } catch (error) {+ if (!shouldClose) {+ setLocalTagIds(previousTagIds);+ }+ console.error('Failed to update tags', error);+ }+ };++ props.setKeybindings({+ next: () => {+ const len = filteredItems().length;+ if (len === 0) return;+ props.setSelectedIndex((prev) => (prev + 1) % len);+ },+ previous: () => {+ const len = filteredItems().length;+ if (len === 0) return;+ props.setSelectedIndex((prev) => (prev - 1 + len) % len);+ },+ select: (event) => {+ const item = filteredItems()[props.selectedIndex()];+ if (item) void toggleTag(item, event);+ },+ });++ const selector = createSelector(props.selectedIndex);++ return (+ <Show+ when={!tagsQuery.isLoading}+ fallback={<CommandMenuEmptyState>Loading tags...</CommandMenuEmptyState>}+ >+ <Show+ when={filteredItems().length > 0}+ fallback={+ <CommandMenuEmptyState>+ {(tagsQuery.data ?? []).length === 0+ ? 'No tags available'+ : 'No tags match your search'}+ </CommandMenuEmptyState>+ }+ >+ <div class="max-h-54 overflow-y-auto overflow-x-hidden scrollbar-hidden p-2">+ <For each={filteredItems()}>+ {(item, index) => (+ <>+ <Show+ when={+ index() === selectedGroupSize() && selectedGroupSize() > 0+ }+ >+ <div class="mx-2 my-1 h-px bg-edge-muted/50" />+ </Show>+ <ListItem+ id={`tag-assignment-option-${index()}`}+ isSelected={selector(index())}+ onClick={(event) => void toggleTag(item, event)}+ onMouseEnter={() => props.setSelectedIndexFromMouse(index())}+ class="scroll-m-2"+ >+ <OptionCheckBox checked={isFullyApplied(item)} multiselect />+ <TagDot color={item.option.color ?? undefined} />+ <span class="min-w-0 flex-1 truncate">+ {tagOptionLabel(item.option)}+ </span>+ <Show when={item.scope === 'team'}>+ <span class="max-w-30 shrink-0 truncate rounded-full border border-ink/5 px-1.5 py-0.5 text-[10px] leading-none text-ink-extra-muted">+ {teamName()}+ </span>+ </Show>+ </ListItem>+ </>+ )}+ </For>+ </div>+ </Show>+ </Show>+ );+}+function PropertyValueEditor(props: {property?: Property | PropertyDefinitionDomain;searchValue: Accessor<string>;@@ -486,13 +899,13 @@ function SelectPropertyEditor(props: {const selector = createSelector(props.selectedIndex);return (- <div class="p-1 max-h-52 overflow-y-auto overflow-x-hidden scrollbar-hidden">+ <div class="max-h-54 overflow-y-auto overflow-x-hidden scrollbar-hidden p-2"><Showwhen={filteredOptions().length > 0}fallback={- <div class="text-center py-4 text-ink-muted text-sm">+ <CommandMenuEmptyState>No matching options found- </div>+ </CommandMenuEmptyState>}><For each={filteredOptions()}>@@ -502,6 +915,7 @@ function SelectPropertyEditor(props: {isSelected={selector(index())}onClick={() => props.onSubmit(option.id)}onMouseEnter={() => props.setSelectedIndexFromMouse(index())}+ class="scroll-m-2"><PropertyValueIcon optionId={option.id} /><div class="flex-1 text-left">@@ -600,15 +1014,15 @@ function EntityPropertyEditor(props: {const selector = createSelector(props.selectedIndex);return (- <div class="p-1 max-h-50 overflow-y-auto overflow-x-hidden scrollbar-hidden">+ <div class="max-h-54 overflow-y-auto overflow-x-hidden scrollbar-hidden p-2"><Showwhen={entities().length > 0}fallback={- <div class="text-center py-4 text-ink-muted text-sm">+ <CommandMenuEmptyState>{props.searchValue().trim()? 'No matching entities found': 'No entities available'}- </div>+ </CommandMenuEmptyState>}><For each={entities()}>@@ -616,6 +1030,7 @@ function EntityPropertyEditor(props: {<ListItemid={`entity-option-${index()}`}isSelected={selector(index())}+ class="scroll-m-2"onClick={() => {const entityRef: EntityReference = {entity_id: entity.id,@@ -790,7 +1205,7 @@ function DirectEditPropertyEditor(props: {};return (- <div class="max-h-50 overflow-y-auto overflow-x-hidden scrollbar-hidden p-1">+ <div class="max-h-50 overflow-y-auto overflow-x-hidden scrollbar-hidden p-2"><ListItemid="property-value-option-0"isSelected={true}@@ -864,21 +1279,21 @@ function DatePropertyEditor(props: {return (<>- <div class="p-1 max-h-50 overflow-y-auto overflow-x-hidden scrollbar-hidden">+ <div class="p-2 max-h-54 overflow-y-auto overflow-x-hidden scrollbar-hidden"><Showwhen={dateOptions().length > 0}fallback={<Showwhen={props.searchValue().trim()}fallback={- <div class="text-center py-4 text-ink-muted text-sm">+ <CommandMenuEmptyState>Enter a date or duration- </div>+ </CommandMenuEmptyState>}>- <div class="text-center py-4 text-ink-muted text-sm">+ <CommandMenuEmptyState>No dates match "{props.searchValue()}"- </div>+ </CommandMenuEmptyState></Show>}>@@ -889,6 +1304,7 @@ function DatePropertyEditor(props: {isSelected={selector(index())}onClick={() => props.onSubmit(option.date)}onMouseEnter={() => props.setSelectedIndexFromMouse(index())}+ class="scroll-m-2"><div class="flex-1 text-left"><p class="text-sm font-medium">{option.displayText}</p>@@ -902,7 +1318,7 @@ function DatePropertyEditor(props: {</Show></div>- <div class="px-2 py-1.5 border-t border-edge-muted">+ <div class="p-4 border-t border-edge-muted"><div class="text-xs text-ink-muted"><span>Use queries like </span><code class="bg-active px-1">3d</code>,{' '}diff --git a/apps/web/src/features/property/editor/state/propertyEditor.ts b/apps/web/src/features/property/editor/state/propertyEditor.tsindex a0adde51d6..1f6d360cdc 100644--- a/apps/web/src/features/property/editor/state/propertyEditor.ts+++ b/apps/web/src/features/property/editor/state/propertyEditor.ts@@ -3,7 +3,7 @@ import type { EntityData } from '@entity';import type { Property, PropertyDefinitionDomain } from '@property/types';import { createStore, reconcile } from 'solid-js/store';-type PropertyEditorMode = 'selector' | 'direct';+type PropertyEditorMode = 'selector' | 'direct' | 'tag';export const [propertyEditorOpen, setPropertyEditorOpen] =createControlledOpenSignal(false, { id: 'property-edit' });diff --git a/apps/web/src/features/property/tags/TagPicker.tsx b/apps/web/src/features/property/tags/TagPicker.tsxindex 967afb3e85..ec31205134 100644--- a/apps/web/src/features/property/tags/TagPicker.tsx+++ b/apps/web/src/features/property/tags/TagPicker.tsx@@ -516,7 +516,7 @@ function TagPickerBody(props: {<><DropdownSearchInputvalue={search()}- placeholder="Change or Add tags"+ placeholder="Change or add tags"onInput={(value) => {setSearch(value);dropdown.setSearchQuery(value);diff --git a/apps/web/src/features/property/tags/useDocTags.ts b/apps/web/src/features/property/tags/useDocTags.tsindex 3ad364b215..6d177f5c1f 100644--- a/apps/web/src/features/property/tags/useDocTags.ts+++ b/apps/web/src/features/property/tags/useDocTags.ts@@ -47,7 +47,7 @@ function definitionDomain(return {id: definition.id,displayName: definition.displayName,- valueType: 'SELECT_STRING',+ valueType: 'TAG',isMultiSelect: true,isMetadata: definition.isMetadata,isSystem: definition.isSystem,diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex 3e9172bf4a..d785ee6bc1 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -125,7 +125,7 @@--color-surface: var(--b0);--color-drop-shadow: oklch(0.15 0 0 / 0.04);- --color-overlay: oklch(var(--b1l) var(--b1c) var(--b1h) / 0.8);+ --color-overlay: oklch(0 0 0 / 0.05);--color-edge-muted: var(--b3);--color-edge: var(--b4);@@ -212,6 +212,9 @@/* Animations */--animate-slide-in: slideIn 150ms cubic-bezier(0.16, 1, 0.3, 1);--animate-menu-open: menu-open 120ms cubic-bezier(0.16, 1, 0.3, 1);+ --animate-dialog-overlay-open: dialog-overlay-open 120ms ease-out;+ --animate-dialog-content-open: dialog-content-open 160ms cubic-bezier(0.16, 1, 0.3, 1);+ --animate-dialog-fullscreen-open: dialog-fullscreen-open 160ms cubic-bezier(0.16, 1, 0.3, 1);--animate-typing-dot: typing-dot 1s infinite;--animate-swipe-out: swipeOut 100ms ease-out;--animate-indeterminate-bar: indeterminate-bar 1.1s ease-in-out infinite;@@ -354,6 +357,33 @@}}+@keyframes dialog-overlay-open {+ from { opacity: 0; }+ to { opacity: 1; }+}++@keyframes dialog-content-open {+ from {+ opacity: 0;+ transform: translateY(4px) scale(0.98);+ }+ to {+ opacity: 1;+ transform: translateY(0) scale(1);+ }+}++@keyframes dialog-fullscreen-open {+ from {+ opacity: 0;+ transform: translateY(6px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+}+@keyframes typing-dot {0% { transform: scale(1) translateY(0 ); }50% { transform: scale(1.5) translateY(-2px); }@@ -545,6 +575,31 @@ a {}}+@utility dialog-overlay-open-animation {+ animation: var(--animate-dialog-overlay-open);++ @media (prefers-reduced-motion: reduce) {+ animation: none;+ }+}++@utility dialog-content-open-animation {+ transform-origin: center;+ animation: var(--animate-dialog-content-open);++ @media (prefers-reduced-motion: reduce) {+ animation: none;+ }+}++@utility dialog-fullscreen-open-animation {+ animation: var(--animate-dialog-fullscreen-open);++ @media (prefers-reduced-motion: reduce) {+ animation: none;+ }+}+@utility macro-message-width {max-width: 100%;width: 100%;diff --git a/apps/web/src/lib/core/hotkey/tokens.ts b/apps/web/src/lib/core/hotkey/tokens.tsindex 76707ab82d..f42b55ff72 100644--- a/apps/web/src/lib/core/hotkey/tokens.ts+++ b/apps/web/src/lib/core/hotkey/tokens.ts@@ -56,6 +56,7 @@ export const TOKENS = {copyEntityId: 'entity.action.copyEntityId',favorite: 'entity.action.favorite',properties: 'entity.action.properties',+ tags: 'entity.action.tags',priority: 'entity.action.priority',status: 'entity.action.status',assignee: 'entity.action.assignee',diff --git a/apps/web/src/lib/core/util/useListKeyBindings.ts b/apps/web/src/lib/core/util/useListKeyBindings.tsindex 407b34e455..de11199a9c 100644--- a/apps/web/src/lib/core/util/useListKeyBindings.ts+++ b/apps/web/src/lib/core/util/useListKeyBindings.ts@@ -3,7 +3,7 @@ import { type Accessor, createEffect, on, onCleanup } from 'solid-js';export type ListNavActions = {next: VoidFunction;previous: VoidFunction;- select: VoidFunction;+ select: (event?: KeyboardEvent) => void;};export function useListKeyBindings(elem: Accessor<HTMLElement | undefined>) {@@ -19,7 +19,7 @@ export function useListKeyBindings(elem: Accessor<HTMLElement | undefined>) {actions?.previous();} else if (e.key === 'Enter') {e.preventDefault();- actions?.select();+ actions?.select(e);}};diff --git a/apps/web/src/lib/queries/properties/entity.ts b/apps/web/src/lib/queries/properties/entity.tsindex d7d27e867e..bbe1c5fbc5 100644--- a/apps/web/src/lib/queries/properties/entity.ts+++ b/apps/web/src/lib/queries/properties/entity.ts@@ -41,7 +41,7 @@ import { buildOptimisticSetEntityProperty } from './graphql-optimistic';import { propertiesKeys } from './keys';function toPropertyTargetEntityType(- entityType: EntityType+ entityType: EntityType | PropertyTargetEntityType): PropertyTargetEntityType {return entityType === 'TASK' ? 'DOCUMENT' : entityType;}@@ -92,7 +92,7 @@ export function useEntityPropertiesQuery(}function invalidatePropertiesForEntity(- entityType: EntityType,+ entityType: EntityType | PropertyTargetEntityType,entityId: string) {queryClient.invalidateQueries({@@ -278,7 +278,7 @@ export function useDeleteEntityPropertyMutation(type AddEntityPropertyParams = {entityId: string;- entityType: EntityType;+ entityType: EntityType | PropertyTargetEntityType;propertyDefinitionId: string;};@@ -317,7 +317,7 @@ export function useAddEntityPropertyMutation(type EntityPropertyOptionParams = {entityId: string;- entityType: EntityType;+ entityType: EntityType | PropertyTargetEntityType;property: Property | PropertyDefinitionDomain;optionId: string;/**@@ -690,7 +690,7 @@ function trackTaskPropertySave(type BulkSaveEntityPropertiesParams = {properties: Array<{entityId: string;- entityType: EntityType;+ entityType: EntityType | PropertyTargetEntityType;property: Property | PropertyDefinitionDomain;apiValues: PropertyApiValues;}>;