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: swipe gestures in Soup (#784)
Peter Chinman4679bc94c6e0
diff --git a/js/app/bun.lock b/js/app/bun.lockindex 2bd9c80500..9fc8db17f2 100644--- a/js/app/bun.lock+++ b/js/app/bun.lock@@ -57,6 +57,7 @@"@tanstack/solid-query": "^5.90.3","@tanstack/solid-query-devtools": "^5.90.3","@tanstack/solid-virtual": "^3.13.13",+ "@tauri-apps/plugin-haptics": "~2","@tauri-apps/plugin-http": "~2","@tauri-apps/plugin-notification": "~2","@tauri-apps/plugin-os": "~2",@@ -1146,6 +1147,8 @@"@tauri-apps/api": ["@tauri-apps/[email protected]", "", {}, "sha512-ga7zdhbS2GXOMTIZRT0mYjKJtR9fivsXzsyq5U3vjDL0s6DTMwYRm0UHNjzTY5dh4+LSC68Sm/7WEiimbQNYlw=="],+ "@tauri-apps/plugin-haptics": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-TqvBR5JoPodDQWPXsNymmyqp37dOpunZOdVVbx5xOAxki7rVwiCMvoEPdtJQNIrU+dQDfkQYZ2oDBVOu4hf+ig=="],+"@tauri-apps/plugin-http": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-x1mQKHSLDk4mS2S938OTeyk8L7QyLpCrKZCZcjkljGsvTvRMojCvI9SeJ1kaxc7t8xSilkC7WdId8xER9TIGLg=="],"@tauri-apps/plugin-notification": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-7gqgfANSREKhh35fY1L4j3TUjUdePmU735FYDqRGeIf8nMXWpcx6j4FhN9/4nYz+m0mv79DCTPLqIPTySggGgg=="],diff --git a/js/app/package.json b/js/app/package.jsonindex c51c49ffce..981ee0974f 100644--- a/js/app/package.json+++ b/js/app/package.json@@ -97,6 +97,7 @@"@tanstack/solid-query-devtools": "^5.90.3","@tanstack/solid-virtual": "^3.13.13","@tauri-apps/plugin-http": "~2",+ "@tauri-apps/plugin-haptics": "~2","@tauri-apps/plugin-notification": "~2","@tauri-apps/plugin-os": "~2","@tauri-apps/plugin-websocket": "~2",diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex 021a25b7e4..528ac10fea 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -3,7 +3,7 @@ import { useIsAuthenticated } from '@core/auth';import { Resize } from '@core/component/Resize';import { useABTest } from '@core/constant/ABTest';import { usePaywallState } from '@core/constant/PaywallState';-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { isMobileWidth } from '@core/mobile/mobileWidth';import {LAYOUT_CONTEXT_ID,@@ -147,7 +147,7 @@ export function Layout(props: RouteSectionProps) {<Show when={paywallOpen()}><Paywall /></Show>- <div class="p-[var(--gutter-size)] ios:p-0 grow-1">+ <div class="p-[var(--gutter-size)] touch:mobile-width:p-0 grow-1"><Resize.Zonegutter={8}direction="horizontal"@@ -167,7 +167,7 @@ export function Layout(props: RouteSectionProps) {<Showwhen={isAuthenticated() && !AUTH_URLS.includes(location.pathname)}>- <Show when={!isNativeMobilePlatform()}>+ <Show when={!isTouchDevice() || !isMobileWidth()}><Dock /></Show><Launcher open={createMenuOpen()} onOpenChange={setCreateMenuOpen} />diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsxindex dc1848afcd..025f32712c 100644--- a/js/app/packages/app/component/Soup.tsx+++ b/js/app/packages/app/component/Soup.tsx@@ -14,7 +14,8 @@ import { fileTypeToResolvedBlockName } from '@core/constant/allBlocks';import { fileFolderDrop } from '@core/directive/fileFolderDrop';import { TOKENS } from '@core/hotkey/tokens';import type { RegisterHotkeyReturn } from '@core/hotkey/types';-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { isMobileWidth } from '@core/mobile/mobileWidth';import type { BlockOrchestrator } from '@core/orchestrator';import {DEFAULT_VIEWS,@@ -468,7 +469,7 @@ export function Soup() {<Showwhen={showHelpDrawer().has(selectedView() as DefaultView) &&- !isNativeMobilePlatform()+ !(isTouchDevice() && isMobileWidth())}><HelpDrawer viewId={view().id} />diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsxindex 3233a86ca2..c1fc8ade80 100644--- a/js/app/packages/app/component/SoupContext.tsx+++ b/js/app/packages/app/component/SoupContext.tsx@@ -1,5 +1,6 @@import { globalSplitManager } from '@app/signal/splitLayout';import { useChannelsContext } from '@core/component/ChannelsProvider';+import { toast } from '@core/component/Toast/Toast';import { fileTypeToBlockName } from '@core/constant/allBlocks';import { ENABLE_PROPERTIES_METADATA } from '@core/constant/featureFlags';import { HotkeyTags } from '@core/hotkey/constants';@@ -7,6 +8,7 @@ import { activeScope, hotkeyScopeTree } from '@core/hotkey/state';import { TOKENS } from '@core/hotkey/tokens';import type { ValidHotkey } from '@core/hotkey/types';import { runCommand } from '@core/hotkey/utils';+import { isModality } from '@core/mobile/inputModality';import { DEFAULT_VIEWS, type DefaultView, type ViewId } from '@core/types/view';import { getActualTarget } from '@core/util/getActualTarget';import { isInteractiveElement } from '@core/util/isInteractiveElement';@@ -82,6 +84,8 @@ import {type NavigateListFn = (input: NavigationInput) => Promise<NavigationResult>;+type CollapseEntityFn = (entityId: string) => Promise<void>;+export type UnifiedListContext = {viewsDataStore: Store<ViewDataMap>;setViewDataStore: SetStoreFunction<Partial<ViewDataMap>>;@@ -97,6 +101,10 @@ export type UnifiedListContext = {navigateThroughList: NavigateListFn;// this is a private method that should be registered once by createNavigationEntityListShortcut_setNavigateThroughList: (fn: NavigateListFn) => void;+ /**+ * Optional hook to animate an entity row collapsing before the entity disappears from the list. This gets set by the EntityRowProvider.+ */+ collapseEntitySignal: Signal<CollapseEntityFn | undefined>;};export function createStubSoupContext(): UnifiedListContext {@@ -118,6 +126,7 @@ export function createStubSoupContext(): UnifiedListContext {entity: undefined,}),_setNavigateThroughList: () => {},+ collapseEntitySignal: createSignal<CollapseEntityFn | undefined>(undefined),};}@@ -134,6 +143,9 @@ export function createSoupContext(): UnifiedListContext {const entityListRefSignal = createSignal<HTMLDivElement>();const entitiesSignal = createSignal<EntityData[]>();const emailViewSignal = createSignal<PreviewViewStandardLabel>('inbox');+ const collapseEntitySignal = createSignal<CollapseEntityFn | undefined>(+ undefined+ );const tutorialCompleted = useTutorialCompleted();const [showHelpDrawer, setShowHelpDrawer] = createSignal<Set<DefaultView>>(!tutorialCompleted() ? new Set(DEFAULT_VIEWS) : new Set()@@ -149,6 +161,7 @@ export function createSoupContext(): UnifiedListContext {entityListRefSignal,entitiesSignal,emailViewSignal,+ collapseEntitySignal,showHelpDrawer,setShowHelpDrawer,actionRegistry: createEntityActionRegistry(),@@ -402,6 +415,24 @@ export function createNavigationEntityListShortcut({);if (handler || hasSupportedEntity) {+ // Check if current view filters out completed items. More robustly we would have the list of entitites itself trigger entity removal animation when the list changes, but this is complicated by our usage of queries and virtualized lists.+ const currentViewConfig =+ unifiedListContext.viewsDataStore[selectedView()];+ const [collapseEntity] = unifiedListContext.collapseEntitySignal;+ const shouldCollapse =+ currentViewConfig?.filters?.notificationFilter === 'notDone' &&+ collapseEntity() !== undefined;++ // If the view hides completed items, collapse the entities first+ if (shouldCollapse) {+ const collapse = collapseEntity();+ if (collapse) {+ await Promise.all(+ multiSelectEntities.map((entity) => collapse(entity.id))+ );+ }+ }+if (multiSelectEntities.length > 1) {const selectedEntityData = getSelectedEntity();const selectedEntityIncludedInMultiSelectedEntities =@@ -411,7 +442,11 @@ export function createNavigationEntityListShortcut({// update selected entity to current selected entity's neighbor, before/after neighbor is based on last navigation direction.// if selected entity is not from multi selected list, don't update selected entity- if (selectedEntityIncludedInMultiSelectedEntities) {+ // we don't want to update the selected entity when user is using touch modality because it will cause the list to scroll in unexpected ways when swiping to mark done+ if (+ selectedEntityIncludedInMultiSelectedEntities &&+ !isModality('touch')+ ) {const index = selectedEntityData?.index ?? 0;const newSelectedEntity = entities()?.at(index);@@ -422,7 +457,7 @@ export function createNavigationEntityListShortcut({mode: 'step',});}- } else {+ } else if (!isModality('touch')) {if (isEntityLastItem()) {navigateThroughList({ axis: 'start', mode: 'step' });} else {@@ -451,6 +486,8 @@ export function createNavigationEntityListShortcut({}setViewDataStore(selectedView(), 'multiSelectEntities', []);++ toast.success('Marked as done');}return { success: true };diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsxindex d2e3a959b3..0b40cb7d46 100644--- a/js/app/packages/app/component/UnifiedListView.tsx+++ b/js/app/packages/app/component/UnifiedListView.tsx@@ -37,6 +37,7 @@ import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';import { arrayEquals } from '@core/util/compareUtils';import { debouncedDependent } from '@core/util/debounce';import { fuzzyMatch } from '@core/util/fuzzy';+import CheckIcon from '@icon/bold/check-bold.svg';import SearchIcon from '@icon/regular/magnifying-glass.svg?component-solid';import LoadingSpinner from '@icon/regular/spinner.svg?component-solid';import XIcon from '@icon/regular/x.svg?component-solid';@@ -133,6 +134,7 @@ import {import { EntityActionsMenuItems } from './EntityActionsMenuItems';import { EntityModal } from './EntityModal/EntityModal';import { EntitySelectionToolbarModal } from './EntitySelectionToolbarModal';+import { EntityRow, EntityRowProvider } from './mobile/EntityRow';import { PropertyDisplayControl } from './PropertyDisplayControl';import { useUpsertSavedViewMutation } from './Soup';import {@@ -200,7 +202,6 @@ export type UnifiedListViewProps = {defaultDisplayOptions?: Partial<DisplayOptions>;hideToolbar?: true;};-export function UnifiedListView(props: UnifiedListViewProps) {const [contextAndModalState, setContextAndModalState] = createStore<{modalOpen: boolean;@@ -252,6 +253,15 @@ export function UnifiedListView(props: UnifiedListViewProps) {const view = createMemo(() => viewsData[selectedView()]);const selectedEntity = createMemo(() => view()?.selectedEntity);+ const entityById = createMemo(() => {+ const list = entities_() ?? [];+ const map = new Map<string, EntityData>();+ for (const entity of list as any[]) {+ if (entity?.id) map.set(entity.id, entity);+ }+ return map;+ });+const setSelectedEntity = (entity: EntityData | undefined) => {setViewDataStore(selectedView(),@@ -1264,6 +1274,113 @@ export function UnifiedListView(props: UnifiedListViewProps) {let lastClickedEntityId = -1;+ const toggleSingleMultiSelection = (params: {+ entity: EntityData;+ next: boolean;+ }) => {+ unifiedListContext.setViewDataStore(+ selectedView(),+ 'multiSelectEntities',+ (prev) => {+ if (!params.next) {+ return prev.filter((e) => e.id !== params.entity.id);+ }+ return prev.concat(params.entity);+ }+ );+ };++ const getSelectionAnchorIndex = (params: {+ entityList: EntityData[];+ selectedEntitySet: Set<EntityData>;+ lastClickedIndex: number;+ }) => {+ // Try to grab the last clicked item and fall back on the highest currently+ // selected index.+ let anchorIndex = params.lastClickedIndex;+ if (anchorIndex === -1) {+ for (let i = 0; i < params.entityList.length; i++) {+ if (params.selectedEntitySet.has(params.entityList[i])) {+ anchorIndex = i;+ }+ }+ }+ return anchorIndex;+ };++ const getNewEntitiesForShiftSelection = (params: {+ entityList: EntityData[];+ selectedEntitySet: Set<EntityData>;+ anchorIndex: number;+ targetIndex: number;+ }) => {+ const newEntitiesForSelection: EntityData[] = [];+ const sign = Math.sign(params.targetIndex - params.anchorIndex);+ if (params.anchorIndex === params.targetIndex)+ return newEntitiesForSelection;++ for (+ let i = params.anchorIndex;+ sign > 0 ? i <= params.targetIndex : i >= params.targetIndex;+ i += sign+ ) {+ const entity = params.entityList[i];+ if (!params.selectedEntitySet.has(entity)) {+ newEntitiesForSelection.push(entity);+ }+ }++ return newEntitiesForSelection;+ };++ const handleMultiSelectChecked = (params: {+ entity: EntityData;+ entityIndex: number;+ next: boolean;+ shiftKey: boolean;+ }) => {+ if (!params.shiftKey) {+ toggleSingleMultiSelection({ entity: params.entity, next: params.next });+ lastClickedEntityId = params.entityIndex;+ return;+ }++ const entityList = unifiedListContext.entitiesSignal[0]();+ if (!entityList) return;++ const selectedEntitySet = new Set(+ unifiedListContext.viewsDataStore[unifiedListContext.selectedView()]+ .multiSelectEntities+ );++ const anchorIndex = getSelectionAnchorIndex({+ entityList,+ selectedEntitySet,+ lastClickedIndex: lastClickedEntityId,+ });++ if (anchorIndex === -1) {+ toggleSingleMultiSelection({ entity: params.entity, next: params.next });+ lastClickedEntityId = params.entityIndex;+ return;+ }++ const newEntitiesForSelection = getNewEntitiesForShiftSelection({+ entityList,+ selectedEntitySet,+ anchorIndex,+ targetIndex: params.entityIndex,+ });++ unifiedListContext.setViewDataStore(+ selectedView(),+ 'multiSelectEntities',+ (prev) => prev.concat(newEntitiesForSelection)+ );++ lastClickedEntityId = params.entityIndex;+ };+// reset last clicked on view change.createEffect(on(view, () => {@@ -1528,188 +1645,147 @@ export function UnifiedListView(props: UnifiedListViewProps) {}}><ContextMenu.Trigger class="size-full unified-list-root">- <UnifiedListComponent- entityListRef={setLocalEntityListRef}- virtualizerHandle={setVirtualizerHandle}- viewId={view()?.id}- searchText={searchText()}- hasRefinementsFromBase={isViewConfigChanged()}- entityMinHeight={ENTITY_HEIGHT}- >- {(innerProps) => {- const displayDoneButton = () => {- if (innerProps.entity.type === 'email') {- return !innerProps.entity.done;- }-- return (innerProps.entity.notifications?.().length ?? 0) > 0;- };- const timestamp = () => {- switch (sortType()) {- case 'viewed_at':- return innerProps.entity.viewedAt;- case 'created_at':- return innerProps.entity.createdAt;- case 'updated_at':- return innerProps.entity.updatedAt;- }- };- return (- <EntityWithEverything- onContextMenu={() => {- if (isPanelActive() && !preview()) {- setSelectedEntity(innerProps.entity);- }+ <EntityRowProvider+ container={localEntityListRef}+ canSwipeLeft={(entityId) => {+ const entity = entityById().get(entityId);+ if (!entity) return false;+ return unifiedListContext.actionRegistry.isActionEnabled(+ 'mark_as_done',+ entity+ );+ }}+ onSwipeLeft={(entityId) => {+ const entity = entityById().get(entityId);+ if (!entity) return false;- setContextAndModalState((prev) => {- return {- ...prev,- contextMenuOpen: true,- selectedEntity: innerProps.entity,- };- });- }}- entity={innerProps.entity}- properties={- isTaskEntity(innerProps.entity)- ? taskPropertiesStore[innerProps.entity.id]- : undefined- }- timestamp={timestamp()}- onClick={entityClickHandler}- onClickRowAction={- unifiedListContext.actionRegistry.isActionEnabled(- 'mark_as_done',- innerProps.entity- )- ? (entity, type) => {- if (type === 'done') {- markEntityAsDone?.(entity);- }- }- : undefined+ unifiedListContext.actionRegistry.execute('mark_as_done', entity);+ }}+ setCollapseEntity={unifiedListContext.collapseEntitySignal[1]}+ >+ <UnifiedListComponent+ entityListRef={setLocalEntityListRef}+ virtualizerHandle={setVirtualizerHandle}+ viewId={view()?.id}+ searchText={searchText()}+ hasRefinementsFromBase={isViewConfigChanged()}+ entityMinHeight={ENTITY_HEIGHT}+ >+ {(innerProps) => {+ const displayDoneButton = () => {+ if (innerProps.entity.type === 'email') {+ return !innerProps.entity.done;}- onClickNotification={(notifiedEntity) => {- const notification = tryToTypedNotification(- notifiedEntity.notification- );- if (!notification) return;- if (notifiedEntity.type === 'channel')- gotoChannelNotification(notification);- }}- onMouseOver={() => {- if (preview()) return;-- setViewDataStore(- selectedView(),- 'hasUserInteractedEntity',- true- );-- setSelectedEntity(innerProps.entity);- }}- onMouseLeave={() => {}}- onFocusIn={() => {- if (preview()) return;-- setSelectedEntity(innerProps.entity);- }}- showLeftColumnIndicator={- showUnreadIndicator() || importantFilter()- }- fadeIfRead={showUnreadIndicator()}- showUnrollNotifications={showUnrollNotifications()}- importantIndicatorActive={importantFilterFn(- innerProps.entity- )}- unreadIndicatorActive={unreadFilterFn(innerProps.entity)}- showDoneButton={displayDoneButton()}- highlighted={- isPanelActive() && focusedSelector(innerProps.entity.id)- }- selected={- focusedSelector(innerProps.entity.id) ||- contextAndModalState.selectedEntity?.id ===- innerProps.entity.id+ return (innerProps.entity.notifications?.().length ?? 0) > 0;+ };+ const timestamp = () => {+ switch (sortType()) {+ case 'viewed_at':+ return innerProps.entity.viewedAt;+ case 'created_at':+ return innerProps.entity.createdAt;+ case 'updated_at':+ return innerProps.entity.updatedAt;}- checked={multiSelectSelector(innerProps.entity.id)}- onChecked={(next, shiftKey) => {- const toggleSingle = () =>- unifiedListContext.setViewDataStore(- selectedView(),- 'multiSelectEntities',- (p) => {- if (!next) {- return p.filter(- (e) => e.id !== innerProps.entity.id- );- }- return p.concat(innerProps.entity);- }- );-- if (shiftKey) {- const entityList = unifiedListContext.entitiesSignal[0]();- if (!entityList) return;-- const selectedEntitySet = new Set(- unifiedListContext.viewsDataStore[- unifiedListContext.selectedView()- ].multiSelectEntities- );- const newEnititiesForSeleciton: EntityData[] = [];-- // Try to grab the last clicked item and fall back on- // the highest currently selected index.- let anchorIndex = lastClickedEntityId;- if (anchorIndex === -1) {- for (let i = 0; i < entityList.length; i++) {- if (selectedEntitySet.has(entityList[i])) {- anchorIndex = i;- }+ };+ return (+ <EntityRow+ entityId={innerProps.entity.id}+ swipeLeftColor="bg-success"+ swipeLeftRevealedComponent={+ <CheckIcon class="size-8 text-panel" />+ }+ >+ <EntityWithEverything+ onContextMenu={() => {+ if (isPanelActive() && !preview()) {+ setSelectedEntity(innerProps.entity);}+ setContextAndModalState((prev) => {+ return {+ ...prev,+ contextMenuOpen: true,+ selectedEntity: innerProps.entity,+ };+ });+ }}+ entity={innerProps.entity}+ properties={+ isTaskEntity(innerProps.entity)+ ? taskPropertiesStore[innerProps.entity.id]+ : undefined}-- if (anchorIndex === -1) {- toggleSingle();- lastClickedEntityId = innerProps.index;- return;+ timestamp={timestamp()}+ onClick={entityClickHandler}+ onClickRowAction={+ unifiedListContext.actionRegistry.isActionEnabled(+ 'mark_as_done',+ innerProps.entity+ )+ ? (entity, type) => {+ if (type === 'done') {+ markEntityAsDone?.(entity);+ }+ }+ : undefined}-- const targetIndex = innerProps.index;- const sign = Math.sign(targetIndex - anchorIndex);- if (anchorIndex === targetIndex) {- // no_op- } else {- for (- let i = anchorIndex;- sign > 0 ? i <= targetIndex : i >= targetIndex;- i += sign- ) {- const entity = entityList[i];- if (!selectedEntitySet.has(entity)) {- newEnititiesForSeleciton.push(entity);- }- }+ onClickNotification={(notifiedEntity) => {+ const notification = tryToTypedNotification(+ notifiedEntity.notification+ );+ if (!notification) return;+ if (notifiedEntity.type === 'channel')+ gotoChannelNotification(notification);+ }}+ onMouseOver={() => {+ if (preview()) return;+ setViewDataStore(+ selectedView(),+ 'hasUserInteractedEntity',+ true+ );+ setSelectedEntity(innerProps.entity);+ }}+ onMouseLeave={() => {}}+ onFocusIn={() => {+ if (preview()) return;+ setSelectedEntity(innerProps.entity);+ }}+ showLeftColumnIndicator={+ showUnreadIndicator() || importantFilter()}- unifiedListContext.setViewDataStore(- selectedView(),- 'multiSelectEntities',- (p) => {- return p.concat(newEnititiesForSeleciton);- }- );- lastClickedEntityId = innerProps.index;- } else {- toggleSingle();- lastClickedEntityId = innerProps.index;- }- }}- />- );- }}- </UnifiedListComponent>+ fadeIfRead={showUnreadIndicator()}+ showUnrollNotifications={showUnrollNotifications()}+ importantIndicatorActive={importantFilterFn(+ innerProps.entity+ )}+ unreadIndicatorActive={unreadFilterFn(innerProps.entity)}+ showDoneButton={displayDoneButton()}+ highlighted={+ isPanelActive() && focusedSelector(innerProps.entity.id)+ }+ selected={+ focusedSelector(innerProps.entity.id) ||+ contextAndModalState.selectedEntity?.id ===+ innerProps.entity.id+ }+ checked={multiSelectSelector(innerProps.entity.id)}+ onChecked={(next, shiftKey) =>+ handleMultiSelectChecked({+ entity: innerProps.entity,+ entityIndex: innerProps.index,+ next,+ shiftKey: shiftKey ?? false,+ })+ }+ />+ </EntityRow>+ );+ }}+ </UnifiedListComponent>+ </EntityRowProvider>+<EntityModalisOpen={() =>!!(diff --git a/js/app/packages/app/component/dock/Dock.tsx b/js/app/packages/app/component/dock/Dock.tsxindex 60f6089cd4..bbd5e5fbc6 100644--- a/js/app/packages/app/component/dock/Dock.tsx+++ b/js/app/packages/app/component/dock/Dock.tsx@@ -311,7 +311,7 @@ export function Dock() {<IconAI /></Button>- <div class="ios:hidden">+ <div class="mobile-width:hidden"><Buttontooltip={<LabelAndHotKey label='Create New Split' hotkeyToken={TOKENS.global.createNewSplit} />}onClick={() => {diff --git a/js/app/packages/app/component/mobile/EntityRow.tsx b/js/app/packages/app/component/mobile/EntityRow.tsxnew file mode 100644index 0000000000..38137acc2f--- /dev/null+++ b/js/app/packages/app/component/mobile/EntityRow.tsx@@ -0,0 +1,505 @@+import { impactFeedback } from '@tauri-apps/plugin-haptics';+import {+ type Accessor,+ createContext,+ createEffect,+ createMemo,+ createSignal,+ type JSX,+ onCleanup,+ onMount,+ type ParentProps,+ type Setter,+ useContext,+} from 'solid-js';++const SWIPE_ACTIVATION_DISTANCE = 75; // Threshold, in pixels, of dx past which releasing touch will activate swipe gesture;+const DIRECTIONALITY_THRESHOLD = 5; // Threshold, in pixels, of either dx or dy, past which a gesture is considered "horizontal" or "vertical". Note: it is not obvious that these should both be the same value... we may want to experiment more.+const AUTO_ACTIVATION_PERCENTAGE = 0.75; // Percentage of container width past which the swipe gesture auto activates.++const TRANSLATE_AFTER_TRIGGERED_SPEED = 100; // ms;+const SPRING_BACK_SPEED = 250; // ms;+const COLLAPSE_SPEED = 250; // ms;++const ROW_PHASES = [+ 'idle',+ 'dragging',+ 'threshold',+ 'triggered',+ 'collapsing',+ 'complete',+] as const;++type RowPhase = (typeof ROW_PHASES)[number];++const ROW_PHASE_RANK: Record<RowPhase, number> = {+ idle: 0,+ dragging: 1,+ threshold: 2,+ triggered: 3,+ collapsing: 4,+ complete: 5,+};++const isAtLeastPhase = (phase: RowPhase, minInclusive: RowPhase) =>+ ROW_PHASE_RANK[phase] >= ROW_PHASE_RANK[minInclusive];++type SwipeDirection = 'left' | 'right' | null;++type EntityRowState = {+ direction: SwipeDirection;+ phase: RowPhase;+};++type RowElements = {+ rowEl: HTMLDivElement;+ swipeEl: HTMLDivElement;+ contentEl: HTMLDivElement;+ leftRevealEl?: Element | null;+ rightRevealEl?: Element | null;+};++type SwipeTouchState = {+ startX: number;+ startY: number;+ currentX: number;+ currentY: number;+ isSwipeGesture: boolean | null;+ entityId: string | null;+ elements: RowElements | undefined;+};++type EntityRowContextValue = {+ stateFor: (entityId: string) => EntityRowState;+ clearState: (entityId: string) => void;+ collapseEntity: (entityId: string) => Promise<void>;+};++export const EntityRowContext = createContext<EntityRowContextValue>();++export function EntityRowProvider(+ props: ParentProps<{+ container: Accessor<HTMLElement | undefined>;+ canSwipeRight?: (entityId: string) => boolean;+ canSwipeLeft?: (entityId: string) => boolean;+ onSwipeRight?: (entityId: string) => void;+ onSwipeLeft?: (entityId: string) => void;+ setCollapseEntity?: Setter<+ ((entityId: string) => Promise<void>) | undefined+ >;+ }>+) {+ const [stateById, setStateById] = createSignal<+ Record<string, EntityRowState>+ >(Object.create(null));++ const setState = (entityId: string, state: Partial<EntityRowState>) => {+ setStateById((prev) => ({+ ...prev,+ [entityId]: { ...prev[entityId], ...state },+ }));+ };+ const clearState = (entityId: string) => {+ setStateById((prev) => {+ const newState = { ...prev };+ delete newState[entityId];+ return newState;+ });+ };+ let touchState: SwipeTouchState = {+ startX: 0,+ startY: 0,+ currentX: 0,+ currentY: 0,+ isSwipeGesture: null,+ entityId: null,+ elements: undefined,+ };++ let rafId: number | null = null;++ const resetRowState = () => {+ const els = touchState.elements;+ const id = touchState.entityId;+ if (!els || !id) return;+ // if row has not been collapsed, reset its styling.+ setTimeout(() => {+ if (!isAtLeastPhase(stateById()[id]?.phase, 'collapsing')) {+ els.contentEl.style.transition = `transform ${SPRING_BACK_SPEED}ms ease-out`;+ els.contentEl.style.transform = 'translateX(0px)';+ setTimeout(() => {+ els.contentEl.style.transition = ``;+ clearState(id);+ }, SPRING_BACK_SPEED);+ }+ }, COLLAPSE_SPEED);+ };++ const resetTouchState = () => {+ touchState = {+ startX: 0,+ startY: 0,+ currentX: 0,+ currentY: 0,+ isSwipeGesture: null,+ entityId: null,+ elements: undefined,+ };+ };++ function springBack() {+ if (!touchState.elements || !touchState.entityId) return;+ const { contentEl } = touchState.elements;+ const entityId = touchState.entityId;+ contentEl.style.transition = `transform ${SPRING_BACK_SPEED}ms ease-out`;+ contentEl.style.transform = 'translateX(0px)';++ setTimeout(() => {+ contentEl.style.transition = '';+ setState(entityId, { direction: null, phase: 'idle' });+ }, SPRING_BACK_SPEED);+ }++ const collapseEntity = (entityId: string): Promise<void> => {+ return new Promise((resolve) => {+ setState(entityId, { phase: 'collapsing' });+ setTimeout(() => {+ setState(entityId, { phase: 'complete' });+ resolve();+ }, COLLAPSE_SPEED);+ });+ };++ // Register/unregister the row-collapse hook with our parent (e.g. UnifiedListView).+ onMount(() => {+ props.setCollapseEntity?.(() => collapseEntity);+ onCleanup(() => props.setCollapseEntity?.(() => undefined));+ });++ const handleSwipe = (entityId: string) => {+ const els = touchState.elements;+ if (!els) return;+ const direction = stateById()[entityId]?.direction;+ if (!direction) return;+ const onSwipe =+ direction === 'left' ? props.onSwipeLeft : props.onSwipeRight;+ if (!onSwipe) return;++ // Cancel any pending animation frame+ if (rafId) cancelAnimationFrame(rafId);++ els.contentEl.style.transition = `transform ${TRANSLATE_AFTER_TRIGGERED_SPEED}ms ease-out`;+ els.contentEl.style.transform = `translateX(${direction === 'left' ? '-100%' : '100%'})`;++ setState(entityId, { phase: 'triggered' });++ setTimeout(() => {+ onSwipe(entityId);+ }, TRANSLATE_AFTER_TRIGGERED_SPEED);++ // If row has not been removed, reset it:+ setTimeout(() => {+ els.contentEl.style.transition = ``;+ els.contentEl.style.transform = 'translateX(0px)';+ }, COLLAPSE_SPEED);++ resetRowState();+ };++ const canSwipeRight = (entityId: string) => {+ if (!props.onSwipeRight) return false;+ return props.canSwipeRight ? props.canSwipeRight(entityId) : true;+ };+ const canSwipeLeft = (entityId: string) => {+ if (!props.onSwipeLeft) return false;+ return props.canSwipeLeft ? props.canSwipeLeft(entityId) : true;+ };++ const onTouchStart = (e: TouchEvent) => {+ const target = e.target;+ if (!(target instanceof Element)) return;+ const swipeEl = target.closest('[data-swipe-surface]');+ if (!(swipeEl instanceof HTMLDivElement)) return;++ const rowEl = swipeEl.closest('[data-swipe-row]');+ if (!(rowEl instanceof HTMLDivElement)) return;++ const entityId = rowEl.dataset.swipeEntityId;+ if (!entityId) return;++ const contentEl = swipeEl.querySelector('[data-swipe-content]');+ if (!(contentEl instanceof HTMLDivElement)) return;++ const leftRevealEl = rowEl.querySelector('[data-left-reveal]');+ const rightRevealEl = rowEl.querySelector('[data-right-reveal]');++ const allowRight = canSwipeRight(entityId);+ const allowLeft = canSwipeLeft(entityId);+ if (!allowRight && !allowLeft) return;++ const phase = stateById()[entityId]?.phase ?? 'idle';+ if (phase === 'triggered' || phase === 'collapsing') return;++ const touch = e.touches[0];++ // Clear any existing transition immediately on touch start.+ contentEl.style.transition = '';++ touchState = {+ startX: touch.clientX,+ startY: touch.clientY,+ currentX: touch.clientX,+ currentY: touch.clientY,+ isSwipeGesture: null,+ entityId,+ elements: {+ rowEl,+ swipeEl,+ contentEl,+ leftRevealEl,+ rightRevealEl,+ },+ };+ };++ const onTouchMove = (e: TouchEvent) => {+ if (!touchState.elements || !touchState.entityId) return;+ if (isAtLeastPhase(stateById()[touchState.entityId]?.phase, 'triggered')) {+ return;+ }++ const touch = e.touches[0];+ const dx = touch.clientX - touchState.startX;+ const dy = touch.clientY - touchState.startY;++ // Determine direction on first significant movement+ if (+ touchState.isSwipeGesture === null &&+ (Math.abs(dx) > DIRECTIONALITY_THRESHOLD ||+ Math.abs(dy) > DIRECTIONALITY_THRESHOLD)+ ) {+ touchState.isSwipeGesture = Math.abs(dx) > Math.abs(dy);+ }++ if (touchState.isSwipeGesture) {+ e.preventDefault();++ touchState.currentX = touch.clientX;++ const allowRight = canSwipeRight(touchState.entityId);+ const allowLeft = canSwipeLeft(touchState.entityId);++ // Constrain dx based on available callbacks+ let constrainedDx = dx;+ if (dx > 0 && !allowRight) {+ constrainedDx = dx * 0.1;+ } else if (dx < 0 && !allowLeft) {+ constrainedDx = dx * 0.1;+ }++ if (rafId) cancelAnimationFrame(rafId);+ rafId = requestAnimationFrame(() => {+ if (!touchState.elements) return;+ touchState.elements.contentEl.style.transform = `translateX(${constrainedDx}px)`;+ rafId = null;+ });++ // set activation state+ const phase = stateById()[touchState.entityId]?.phase ?? 'idle';+ const thesholdCrossed =+ (allowRight && dx > SWIPE_ACTIVATION_DISTANCE) ||+ (allowLeft && dx < -SWIPE_ACTIVATION_DISTANCE);++ if (thesholdCrossed) {+ if (phase !== 'threshold') {+ impactFeedback('light');+ setState(touchState.entityId, {+ direction: dx > 0 ? 'right' : 'left',+ phase: 'threshold',+ });+ }+ } else {+ if (phase !== 'dragging') {+ if (phase === 'threshold') {+ impactFeedback('light');+ }+ setState(touchState.entityId, {+ direction: dx > 0 ? 'right' : 'left',+ phase: 'dragging',+ });+ }+ }++ // Auto-activate swipe if threshold is reached+ const containerWidth = touchState.elements.swipeEl.clientWidth;+ if (allowRight && dx > containerWidth * AUTO_ACTIVATION_PERCENTAGE) {+ handleSwipe(touchState.entityId);+ } else if (+ allowLeft &&+ dx < -containerWidth * AUTO_ACTIVATION_PERCENTAGE+ ) {+ handleSwipe(touchState.entityId);+ }+ }+ };++ const onTouchEnd = (_e: TouchEvent) => {+ if (+ !touchState.elements ||+ !touchState.entityId ||+ !touchState.isSwipeGesture+ ) {+ resetTouchState();+ return;+ }+ if (isAtLeastPhase(stateById()[touchState.entityId]?.phase, 'triggered')) {+ resetTouchState();+ return;+ }++ const deltaX = touchState.currentX - touchState.startX;++ const entityId = touchState.entityId;++ const allowRight = canSwipeRight(entityId);+ const allowLeft = canSwipeLeft(entityId);++ if (allowRight && deltaX > SWIPE_ACTIVATION_DISTANCE) {+ void handleSwipe(entityId);+ } else if (allowLeft && deltaX < -SWIPE_ACTIVATION_DISTANCE) {+ void handleSwipe(entityId);+ } else {+ springBack();+ }++ resetRowState();+ resetTouchState();+ };++ const onTouchCancel = (_e: TouchEvent) => {+ springBack();+ resetRowState();+ resetTouchState();+ };++ createEffect(() => {+ const el = props.container();+ if (!el) return;++ el.addEventListener('touchstart', onTouchStart, { passive: true });+ el.addEventListener('touchmove', onTouchMove, { passive: false });+ el.addEventListener('touchend', onTouchEnd, { passive: true });+ el.addEventListener('touchcancel', onTouchCancel, { passive: true });++ onCleanup(() => {+ el.removeEventListener('touchstart', onTouchStart);+ el.removeEventListener('touchmove', onTouchMove);+ el.removeEventListener('touchend', onTouchEnd);+ el.removeEventListener('touchcancel', onTouchCancel);+ });+ });++ const ctx: EntityRowContextValue = {+ stateFor: (entityId) =>+ stateById()[entityId] ?? { phase: 'idle', direction: null },+ clearState: (entityId) => clearState(entityId),+ collapseEntity,+ };++ return (+ <EntityRowContext.Provider value={ctx}>+ {props.children}+ </EntityRowContext.Provider>+ );+}++export function EntityRow(+ props: ParentProps<{+ entityId: string;+ swipeRightRevealedComponent?: JSX.Element;+ swipeLeftRevealedComponent?: JSX.Element;+ swipeLeftColor?: string;+ swipeRightColor?: string;+ }>+) {+ const ctx = useContext(EntityRowContext);+ if (!ctx) {+ throw new Error('EntityRow must be used within EntityRowProvider');+ }++ const rowState = createMemo(() => ctx.stateFor(props.entityId));++ onCleanup(() => {+ ctx.clearState(props.entityId);+ });++ return (+ <div+ data-swipe-row+ data-swipe-entity-id={props.entityId}+ class="w-full grid grid-cols-1 relative overflow-hidden transition-[grid-template-rows] duration-[250ms] ease-in-out"+ classList={{+ 'bg-transparent': rowState()?.phase === 'idle',+ [props.swipeLeftColor ?? 'bg-edge-muted']:+ rowState()?.direction === 'left',+ [props.swipeRightColor ?? 'bg-edge']: rowState()?.direction === 'right',+ 'grid-rows-[0fr]': isAtLeastPhase(rowState()?.phase, 'collapsing'),+ 'grid-rows-[1fr]': !isAtLeastPhase(rowState()?.phase, 'collapsing'),+ }}+ >+ {/* Swipe Right Revealed Component */}+ <div+ class="absolute top-0 left-0 h-full flex items-center justify-center z-[1]"+ style={{+ width: `${SWIPE_ACTIVATION_DISTANCE}px`,+ }}+ aria-hidden="true"+ >+ <div+ data-left-reveal+ class="transition-transform duration-300 ease-in-out"+ classList={{+ 'scale-50': !isAtLeastPhase(rowState()?.phase, 'threshold'),+ 'scale-100': isAtLeastPhase(rowState()?.phase, 'threshold'),+ }}+ >+ {props.swipeRightRevealedComponent}+ </div>+ </div>++ {/* Swipe Left Revealed Component */}+ <div+ class="absolute top-0 right-0 h-full flex items-center justify-center z-[1]"+ style={{+ width: `${SWIPE_ACTIVATION_DISTANCE}px`,+ }}+ aria-hidden="true"+ >+ <div+ data-right-reveal+ class="transition-transform duration-300 ease-in-out"+ classList={{+ 'scale-50': !isAtLeastPhase(rowState()?.phase, 'threshold'),+ 'scale-100': isAtLeastPhase(rowState()?.phase, 'threshold'),+ }}+ >+ {props.swipeLeftRevealedComponent}+ </div>+ </div>++ {/* Swipe Surface */}+ <div+ data-swipe-surface+ class="relative min-h-0 z-[2] w-full select-none [touch-action:pan-y]"+ >+ {/* Swipe Content */}+ <div+ data-swipe-content+ class="w-full min-h-0 overflow-hidden flex items-center p-0 bg-panel"+ >+ {props.children}+ </div>+ </div>+ </div>+ );+}diff --git a/js/app/packages/app/component/settings/Appearance.tsx b/js/app/packages/app/component/settings/Appearance.tsxindex 65b8ed4297..17372fab93 100644--- a/js/app/packages/app/component/settings/Appearance.tsx+++ b/js/app/packages/app/component/settings/Appearance.tsx@@ -11,37 +11,13 @@ export function Appearance() {// const [cursorEnabled, setCursorEnabled] = createSignal(customCursorEnabled());return (- <>- <style>{`- .appearance-container{- grid-template-areas: "tools" "basic" "list" "advanced";- grid-template-rows: min-content min-content 1fr 1fr;- grid-template-columns: 1fr;- }- @container(min-width: 650px){- .appearance-container{- grid-template-areas: "tools tools" "basic basic" "list advanced";- grid-template-rows: min-content min-content 1fr;- grid-template-columns: 1fr 1fr;- }- }- `}</style><div- style="- background-color: var(--color-edge-muted);- container-type: inline-size;- position: absolute;- overflow: hidden;- display: grid;- inset: 0;- gap: 1px;- "- class="appearance-container"+ class="absolute inset-0 overflow-hidden bg-edge-muted @container gap-px grid grid-cols-1 grid-rows-[min-content_min-content_1fr_1fr] @[650px]:grid-cols-2 @[650px]:grid-rows-[min-content_min-content_1fr] touch:mobile-width:flex">- <div class="ios:hidden" style="grid-area: tools;"><ThemeTools /></div>- <div class="ios:hidden" style="grid-area: basic;"><ThemeEditorBasic /></div>- <div style="grid-area: list; overflow: hidden;"><ThemeList/></div>- <div class="ios:hidden" style="grid-area: advanced; overflow: hidden;"><ThemeEditorAdvanced /></div>+ <div class="touch:mobile-width:hidden @[650px]:col-span-2"><ThemeTools /></div>+ <div class="touch:mobile-width:hidden @[650px]:col-span-2"><ThemeEditorBasic /></div>+ <div class="touch:mobile-width:flex-1 overflow-hidden"><ThemeList/></div>+ <div class="touch:mobile-width:hidden overflow-hidden"><ThemeEditorAdvanced /></div>{/*<Show when={ENABLE_CUSTOM_CURSOR}><div@@ -64,6 +40,5 @@ export function Appearance() {</div></Show>*/}</div>- </>);}diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsxindex 00b050ce28..4d41ffb486 100644--- a/js/app/packages/app/component/settings/Settings.tsx+++ b/js/app/packages/app/component/settings/Settings.tsx@@ -16,6 +16,8 @@ import { Appearance } from './Appearance';import { Tabs } from '@kobalte/core/tabs';import { Account } from './Account';import { Inbox } from './Inbox';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { isMobileWidth } from '@core/mobile/mobileWidth';const SCROLL_THRESHOLD = 10;@@ -149,7 +151,7 @@ export function SettingsPanel(props: SettingsPanelProps) {{/* Header with tabs */}<div class="relative isolate shrink-0 border-b border-edge-muted"><div class="flex items-center px-2 h-[2.5rem]">- <Show when={!isNativeMobilePlatform()}>+ <Show when={!isTouchDevice() || !isMobileWidth()}><DeprecatedIconButtonicon={CloseIcon}onClick={closeSettings}@@ -230,7 +232,7 @@ export function SettingsPanel(props: SettingsPanelProps) {<div class="flex-1" />- <Show when={!isNativeMobilePlatform()}>+ <Show when={!isTouchDevice() || !isMobileWidth()}><DeprecatedIconButtonicon={spotlight() ? ContractIcon : ExpandIcon}onClick={() => setSpotlight(!spotlight())}diff --git a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx b/js/app/packages/app/component/split-layout/components/SplitContainer.tsxindex 1f66f28311..563906208c 100644--- a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitContainer.tsx@@ -2,7 +2,8 @@ import MacroJump from '@app/component/MacroJump';import { MobileDock } from '@app/component/mobile/MobileDock';import { globalSplitManager } from '@app/signal/splitLayout';import { ClippedPanel } from '@core/component/ClippedPanel';-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { isMobileWidth } from '@core/mobile/mobileWidth';import { isRightPanelOpen, isSettingsPanelOpen } from '@core/signal/layout';import { createElementSize } from '@solid-primitives/resize-observer';import {@@ -116,7 +117,7 @@ export function SplitContainer(<Show when={panel.handle.isSpotLight()}><MacroJump tabbableParent={ref} /></Show>- <Show when={isNativeMobilePlatform()}>+ <Show when={isTouchDevice() && isMobileWidth()}><MobileDock /></Show></div>diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsxindex d275983e68..39acb4161e 100644--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx@@ -2,6 +2,8 @@ import EntityNavigationIndicator from '@app/component/EntityNavigationIndicator'import { LabelAndHotKey } from '@core/component/Tooltip';import { ENABLE_PREVIEW } from '@core/constant/featureFlags';import { TOKENS } from '@core/hotkey/tokens';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { isMobileWidth } from '@core/mobile/mobileWidth';import CollapseIcon from '@icon/regular/arrows-in.svg';import ExpandIcon from '@icon/regular/arrows-out.svg';import CaretLeft from '@icon/regular/caret-left.svg';@@ -145,7 +147,7 @@ function SplitPreviewToggle() {function SplitControlButtons() {return (<div class="flex flex-row items-center px-2 h-full shrink-0">- <div class="ios:hidden">+ <div class="touch:mobile-width:hidden"><SplitCloseButton /></div><SplitBackButton />@@ -211,20 +213,24 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {{/* space filler */}<div class="h-full grow-1" />- <div- class="min-w-4 h-full shrink-0 ios:hidden"- ref={(ref) => {- ctx.layoutRefs.headerRight = ref;- }}- />- <div class="z-2 relative flex items-center bg-panel pr-2 h-full ios:hidden">- <EntityNavigationIndicator />- <SplitPreviewToggle />- <SplitSpotlightButton />- </div>- <div class="z-2 relative items-center bg-panel pr-2 h-full hidden ios:flex">- <SplitSettingsButton />- </div>+ <Show when={!isTouchDevice() || !isMobileWidth()}>+ <div+ class="min-w-4 h-full shrink-0"+ ref={(ref) => {+ ctx.layoutRefs.headerRight = ref;+ }}+ />+ <div class="z-2 relative flex items-center bg-panel pr-2 h-full">+ <EntityNavigationIndicator />+ <SplitPreviewToggle />+ <SplitSpotlightButton />+ </div>+ </Show>+ <Show when={isTouchDevice()}>+ <div class="z-2 relative flex items-center bg-panel pr-2 h-full">+ <SplitSettingsButton />+ </div>+ </Show></div></div>);diff --git a/js/app/packages/app/component/split-layout/components/SplitTabs.tsx b/js/app/packages/app/component/split-layout/components/SplitTabs.tsxindex 3a26dd697b..245d46b8d1 100644--- a/js/app/packages/app/component/split-layout/components/SplitTabs.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitTabs.tsx@@ -106,7 +106,7 @@ export function SplitTabs(props: {});return (- <div class="relative isolate h-full shrink grow-2 @container-normal">+ <div class="touch:mobile-width:hidden relative isolate h-full shrink grow-2 @container-normal">{/* Left clip boundary indicator */}<divclass="absolute pointer-events-none left-0 top-px bottom-px w-3 z-2 pattern-diagonal-4 pattern-edge mask-r-from-0% border-l border-edge-muted transition-opacity duration-150"diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex 456ba08e4b..fab4248d82 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -249,6 +249,8 @@@custom-variant tauri (&:where(.tauri *));@custom-variant ios (&:where(.tauri-ios *));+@custom-variant touch (&:where(html[data-touch-device="true"] *));+@custom-variant mobile-width (@media (max-width: 639px));:root {--color-focus: var(--color-accent);diff --git a/js/app/packages/app/index.html b/js/app/packages/app/index.htmlindex b0afd3ab7e..bfa57e689f 100644--- a/js/app/packages/app/index.html+++ b/js/app/packages/app/index.html@@ -36,7 +36,7 @@<body><noscript>You need to enable JavaScript to run this app.</noscript>- <div id="root" class="h-full ios:h-screen"></div>+ <div id="root" class="h-full touch:h-screen"></div><div id="modal" class="z-modal"></div><!--Entrypointdiff --git a/js/app/packages/app/index.tsx b/js/app/packages/app/index.tsxindex 0356f410bd..cf72cd58f9 100644--- a/js/app/packages/app/index.tsx+++ b/js/app/packages/app/index.tsx@@ -4,6 +4,7 @@ import './index.css';import * as analytics from '@coparse/analytics';import { initializeLexical } from '@core/component/LexicalMarkdown/init';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { getPlatform } from '@core/util/platform';import * as Observability from '@observability';import { ErrorBoundary, render } from 'solid-js/web';@@ -19,14 +20,35 @@ const renderApp = () => {const root = document.getElementById('root');if (!root) return console.error('Root element not found');document.documentElement.dataset.platform = getPlatform();+ document.documentElement.dataset.touchDevice = isTouchDevice()+ ? 'true'+ : 'false';// Used for :focus-visible, which focus-bracket utility uses, to prevent input elements triggering :focus-visible on mouse click- document.addEventListener('keydown', () => {- document.documentElement.dataset.modality = 'keyboard';- });- document.addEventListener('mousedown', () => {- document.documentElement.dataset.modality = 'mouse';- });+ // Use capture phase to ensure we catch events even if they're stopped by handlers+ document.addEventListener(+ 'keydown',+ () => {+ document.documentElement.dataset.modality = 'keyboard';+ },+ { capture: true }+ );++ document.addEventListener(+ 'mousedown',+ () => {+ document.documentElement.dataset.modality = 'mouse';+ },+ { capture: true }+ );++ document.addEventListener(+ 'touchstart',+ () => {+ document.documentElement.dataset.modality = 'touch';+ },+ { capture: true, passive: true }+ );if (import.meta.env.MODE === 'development') {return render(diff --git a/js/app/packages/block-canvas/component/MediaSelector.tsx b/js/app/packages/block-canvas/component/MediaSelector.tsxindex 18bcc5e8a5..70e0ec239f 100644--- a/js/app/packages/block-canvas/component/MediaSelector.tsx+++ b/js/app/packages/block-canvas/component/MediaSelector.tsx@@ -21,7 +21,6 @@ import {import { fileDrop } from '@core/directive/fileDrop';import { fileSelector } from '@core/directive/fileSelector';import { HEIC_EXTENSIONS, HEIC_MIME_TYPES } from '@core/heic/constants';-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { DropdownMenu } from '@kobalte/core/dropdown-menu';import UploadSimple from '@phosphor-icons/core/bold/upload-simple-bold.svg?component-solid';import Image from '@phosphor-icons/core/regular/image.svg?component-solid';@@ -171,50 +170,48 @@ export function MediaSelector() {}}class="flex flex-col gap-1">- <Show when={!isNativeMobilePlatform()}>- <Show when={isDragging()}>- <FileDropOverlay valid={true}>- <div class="font-mono">- Drop any file here to add it to your canvas- </div>- </FileDropOverlay>- </Show>- <DropdownMenu.Item closeOnSelect={false}>+ <Show when={isDragging()}>+ <FileDropOverlay valid={true}>+ <div class="font-mono">+ Drop any file here to add it to your canvas+ </div>+ </FileDropOverlay>+ </Show>+ <DropdownMenu.Item closeOnSelect={false}>+ <div+ class="w-72 flex flex-row select-none items-center gap-1 "+ onmousedown={(e) => {+ e.stopPropagation();+ e.preventDefault();+ select.abort();+ }}+ ontouchstart={(e) => {+ e.stopPropagation();+ e.preventDefault();+ select.abort();+ }}+ ><div- class="w-72 flex flex-row select-none items-center gap-1 "- onmousedown={(e) => {- e.stopPropagation();- e.preventDefault();- select.abort();- }}- ontouchstart={(e) => {- e.stopPropagation();- e.preventDefault();- select.abort();+ class="w-full hidden sm:flex p-2 mb-1 bg-edge/15 hover:bg-accent/15 hover-transition-bg transition-colors items-center justify-center gap-2"+ use:fileSelector={{+ acceptedFileExtensions: acceptedFileExtensions,+ acceptedMimeTypes: acceptedMimeTypes,+ onSelect: (files: File[]) => {+ track(TrackingEvents.BLOCKCANVAS.IMAGES.STATICIMAGE, {+ method: 'click dropdown button',+ });+ handleFileDrop(files, centerVec());+ setImageSelectorOpen(false);+ },}}>- <div- class="w-full hidden sm:flex p-2 mb-1 bg-edge/15 hover:bg-accent/15 hover-transition-bg transition-colors items-center justify-center gap-2"- use:fileSelector={{- acceptedFileExtensions: acceptedFileExtensions,- acceptedMimeTypes: acceptedMimeTypes,- onSelect: (files: File[]) => {- track(TrackingEvents.BLOCKCANVAS.IMAGES.STATICIMAGE, {- method: 'click dropdown button',- });- handleFileDrop(files, centerVec());- setImageSelectorOpen(false);- },- }}- >- <UploadSimple class="w-3.5 h-3.5 shrink-0 text-accent-ink" />- <span class="text-sm font-medium text-accent-ink">- Upload File- </span>- </div>+ <UploadSimple class="w-3.5 h-3.5 shrink-0 text-accent-ink" />+ <span class="text-sm font-medium text-accent-ink">+ Upload File+ </span></div>- </DropdownMenu.Item>- </Show>+ </div>+ </DropdownMenu.Item><div class="w-full"><Showwhen={userMediaFiles().length > 0}diff --git a/js/app/packages/block-canvas/component/ToolBar.tsx b/js/app/packages/block-canvas/component/ToolBar.tsxindex 0eee55ebf9..7171d8b46e 100644--- a/js/app/packages/block-canvas/component/ToolBar.tsx+++ b/js/app/packages/block-canvas/component/ToolBar.tsx@@ -14,7 +14,7 @@ import {} from '@core/constant/featureFlags';import { IS_MAC } from '@core/constant/isMac';import { TOKENS } from '@core/hotkey/tokens';-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { blockHotkeyScopeSignal } from '@core/signal/blockElement';import { useCanEdit } from '@core/signal/permissions';import CaretDown from '@icon/bold/caret-down-bold.svg';@@ -180,7 +180,7 @@ export function ToolBar() {}}/>- <Show when={!isNativeMobilePlatform()}>+ <Show when={!isTouchDevice()}><DeprecatedIconButtontooltip={[{ label: 'Zoom', hotkeyToken: TOKENS.canvas.zoomInTool },diff --git a/js/app/packages/core/component/ClippedPanel.tsx b/js/app/packages/core/component/ClippedPanel.tsxindex 0d62f0d8b4..51ddbab037 100644--- a/js/app/packages/core/component/ClippedPanel.tsx+++ b/js/app/packages/core/component/ClippedPanel.tsx@@ -1,4 +1,5 @@-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { isMobileWidth } from '@core/mobile/mobileWidth';import { cornerClip } from '@core/util/clipPath';import { type JSXElement, type Ref, Show } from 'solid-js';import { beveledCorners } from '../../block-theme/signals/themeSignals';@@ -16,7 +17,7 @@ interface PanelProps {export function ClippedPanel(props: PanelProps) {return (<Show- when={!isNativeMobilePlatform()}+ when={!isTouchDevice() || !isMobileWidth()}fallback={<div class="size-full">{props.children}</div>}><divdiff --git a/js/app/packages/core/hotkey/hotkeys.ts b/js/app/packages/core/hotkey/hotkeys.tsindex 3cc3c9be15..dff55071f4 100644--- a/js/app/packages/core/hotkey/hotkeys.ts+++ b/js/app/packages/core/hotkey/hotkeys.ts@@ -1,7 +1,5 @@import { IS_MAC } from '@core/constant/isMac';-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { isTouchDevice } from '@core/mobile/isTouchDevice';-import { isMobileWidth } from '@core/mobile/mobileWidth';import { isEditableInput } from '@core/util/isEditableInput';import { logger } from '@observability';import { onCleanup, onMount, untrack } from 'solid-js';@@ -424,7 +422,7 @@ export function attachGlobalDOMScope(el: Element) {* @returns A function to subscribe to keypress events with full context information.*/export function useHotKeyRoot() {- if (isNativeMobilePlatform() || (isMobileWidth() && isTouchDevice())) {+ if (isTouchDevice()) {return;}diff --git a/js/app/packages/core/mobile/inputModality.ts b/js/app/packages/core/mobile/inputModality.tsnew file mode 100644index 0000000000..e598f8b6f7--- /dev/null+++ b/js/app/packages/core/mobile/inputModality.ts@@ -0,0 +1,9 @@+/**+ * Returns true if the user's most recent input modality matches the provided value.+ *+ * The modality reflects the most recent input type the user has used.+ */+export function isModality(modality: 'mouse' | 'keyboard' | 'touch'): boolean {+ if (typeof document === 'undefined') return false;+ return document.documentElement.dataset.modality === modality;+}diff --git a/js/app/packages/core/mobile/isTouchDevice.ts b/js/app/packages/core/mobile/isTouchDevice.tsindex 2b8759b149..dd95cba836 100644--- a/js/app/packages/core/mobile/isTouchDevice.ts+++ b/js/app/packages/core/mobile/isTouchDevice.ts@@ -1,8 +1,10 @@+/**+ * This function returns true if the device is PRIMARILY touch device, E.g. this should return false for touchscreen laptops. However, the user might still be using a keyboard, e.g. if they have a physical keyboard attached to their iPad. In that case, you may want to use isModality('touch') instead.+ */export function isTouchDevice(): boolean {if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')return false;- // "Primarily touch" == touch-first input (primary pointer is coarse AND primary hover is none).const hasCoarsePointer = window.matchMedia('(pointer: coarse)').matches;const hasNoHover = window.matchMedia('(hover: none)').matches;diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsxindex 308212e435..9b5db4132b 100644--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx@@ -863,7 +863,7 @@ export function EntityWithEverything(use:draggableuse:droppabledata-checked={props.checked}- class="everything-entity relative group/entity hover:bg-hover/30"+ class="everything-entity w-full relative group/entity hover:bg-hover/30"style={{'min-height': `${ENTITY_HEIGHT}px`,}}diff --git a/js/app/tauri/Cargo.lock b/js/app/tauri/Cargo.lockindex e47dc7d797..516b45f7a5 100644--- a/js/app/tauri/Cargo.lock+++ b/js/app/tauri/Cargo.lock@@ -91,6 +91,7 @@ dependencies = ["tauri","tauri-build","tauri-plugin-deep-link",+ "tauri-plugin-haptics","tauri-plugin-http","tauri-plugin-log","tauri-plugin-notification",@@ -4566,6 +4567,20 @@ dependencies = ["url",]+[[package]]+name = "tauri-plugin-haptics"+version = "2.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "01b167d598ada05c599f4460595108c8d1aa636030a97d19796c1bcda97d881d"+dependencies = [+ "log",+ "serde",+ "serde_json",+ "tauri",+ "tauri-plugin",+ "thiserror 2.0.17",+]+[[package]]name = "tauri-plugin-http"version = "2.5.2"diff --git a/js/app/tauri/src-tauri/Cargo.toml b/js/app/tauri/src-tauri/Cargo.tomlindex e771ea03b8..8a99ae7673 100644--- a/js/app/tauri/src-tauri/Cargo.toml+++ b/js/app/tauri/src-tauri/Cargo.toml@@ -56,3 +56,6 @@ tauri-plugin-os = "2"[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\"))".dependencies]tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }++[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]+tauri-plugin-haptics = "2"diff --git a/js/app/tauri/src-tauri/capabilities/mobile.json b/js/app/tauri/src-tauri/capabilities/mobile.jsonnew file mode 100644index 0000000000..defab0d9e0--- /dev/null+++ b/js/app/tauri/src-tauri/capabilities/mobile.json@@ -0,0 +1,16 @@+{+ "identifier": "mobile-capability",+ "platforms": [+ "android",+ "iOS"+ ],+ "windows": [+ "main"+ ],+ "permissions": [+ "haptics:allow-impact-feedback",+ "haptics:allow-notification-feedback",+ "haptics:allow-selection-feedback",+ "haptics:allow-vibrate"+ ]+}diff --git a/js/app/tauri/src-tauri/src/lib.rs b/js/app/tauri/src-tauri/src/lib.rsindex 7793e3d2b2..aac136d042 100644--- a/js/app/tauri/src-tauri/src/lib.rs+++ b/js/app/tauri/src-tauri/src/lib.rs@@ -57,7 +57,7 @@ pub fn run() {registry.init();- let mut builder = tauri::Builder::default();+ let mut builder = tauri::Builder::default().plugin(tauri_plugin_haptics::init());#[cfg(desktop)]{