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[mobile]: swipe in animation, and other improvements (#3533)
Peter Chinman7983914d5208
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsxindex e408c4720f..7d4f008e39 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx@@ -27,6 +27,7 @@ export const SoupEntityContextMenu: FlowComponent<data-soup-entityref={(el) =>longPressHighlight(el, () => ({+ className: 'touch-highlight',onLongPress: () => drawerManager?.open(props.entity, soup),}))}diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-navigation-touch-highlight.ts b/js/app/packages/app/component/next-soup/soup-view/soup-navigation-touch-highlight.tsnew file mode 100644index 0000000000..cc24de898b--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/soup-navigation-touch-highlight.ts@@ -0,0 +1,32 @@+import { isTouchDevice } from '@core/mobile/isTouchDevice';++const NAVIGATION_TOUCH_HIGHLIGHT_CLASS = 'navigation-touch-highlight';+const NAVIGATION_TOUCH_HIGHLIGHT_TIMEOUT_MS = 500;+const navigationTouchHighlightTimers = new WeakMap<HTMLElement, number>();++export function persistSoupNavigationTouchHighlight(+ event: MouseEvent | PointerEvent+) {+ if (!isTouchDevice()) return false;++ const target = event.currentTarget ?? event.target;+ if (!(target instanceof Element)) return false;++ const trigger = target.closest('[data-soup-entity]');+ if (!(trigger instanceof HTMLElement)) return false;++ trigger.classList.add(NAVIGATION_TOUCH_HIGHLIGHT_CLASS);++ const existingTimer = navigationTouchHighlightTimers.get(trigger);+ if (existingTimer !== undefined) {+ window.clearTimeout(existingTimer);+ }++ const timer = window.setTimeout(() => {+ trigger.classList.remove(NAVIGATION_TOUCH_HIGHLIGHT_CLASS);+ navigationTouchHighlightTimers.delete(trigger);+ }, NAVIGATION_TOUCH_HIGHLIGHT_TIMEOUT_MS);++ navigationTouchHighlightTimers.set(trigger, timer);+ return true;+}diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex ee686a85e0..f4ba417d90 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -23,6 +23,7 @@ import { useFilterRefinements } from '@app/component/next-soup/soup-view/filtersimport { MaybeSoupEntityActionDrawerManager } from '@app/component/next-soup/soup-view/SoupEntityActionDrawerManager';import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';import { SoupEntityContextMenu } from '@app/component/next-soup/soup-view/soup-entity-context-menu';+import { persistSoupNavigationTouchHighlight } from '@app/component/next-soup/soup-view/soup-navigation-touch-highlight';import { activeSoupViewCounts } from '@app/component/next-soup/soup-view/soup-view-cache-key';import {SoupViewContextProvider,@@ -763,6 +764,8 @@ export const SoupViewList = (props: SoupViewListProps) => {return;}+ persistSoupNavigationTouchHighlight(event);+await openEntityInSplitFromUnifiedList(entity, {openInNewSplit: event.shiftKey,location,diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListEntity.tsx b/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListEntity.tsxindex b664811561..ac4aab0158 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListEntity.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListEntity.tsx@@ -2,6 +2,7 @@ import '@entity/composed/ListEntity.css';import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { isMobile } from '@core/mobile/isMobile';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import {createEntityDraggable,Entity,@@ -129,10 +130,12 @@ export function TaskListEntity(props: TaskListEntityProps) {{'min-h-10 mx-1': !isMobile(),'bg-accent/8': props.checked,- 'ring ring-accent/16 ring-inset': props.checked && props.highlighted,+ 'ring ring-accent/16 ring-inset':+ props.checked && props.highlighted && !isTouchDevice(),'ring ring-edge bg-active/60 ring-inset':- props.highlighted && !props.checked,- 'hover:bg-active/30': !props.highlighted && !props.checked,+ props.highlighted && !props.checked && !isTouchDevice(),+ 'hover:bg-active/30':+ !props.highlighted && !props.checked && !isTouchDevice(),})}onMouseMove={props.onMouseMove}diff --git a/js/app/packages/app/component/settings/Settings.tsx b/js/app/packages/app/component/settings/Settings.tsxindex 911f8febca..3b9426820a 100644--- a/js/app/packages/app/component/settings/Settings.tsx+++ b/js/app/packages/app/component/settings/Settings.tsx@@ -1,4 +1,4 @@-import { createEffect, onMount, Show, Suspense } from 'solid-js';+import { onMount, Show, Suspense } from 'solid-js';import { type SettingsTab, useSettingsState } from '@core/constant/SettingsState';import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { isMobile } from '@core/mobile/isMobile';@@ -14,7 +14,10 @@ import { Shortcuts } from './Shortcuts';import { Team } from './Team';import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';import type { ValidHotkey } from '@core/hotkey/types';-import { SplitHeaderLeft, SplitHeaderRight } from '../split-layout/components/SplitHeader';+import {+ SplitHeaderLeft,+ SplitHeaderRight,+} from '../split-layout/components/SplitHeader';import { CollapsibleHeaderItem } from '../split-layout/components/CollapsibleHeaderItem';import { SettingsButton } from './SettingsButton';import { isTouchDevice } from '@core/mobile/isTouchDevice';@@ -37,24 +40,13 @@ type SettingsPanelProps = {};function SettingsPanel(props: SettingsPanelProps) {- const { settingsOpen, closeSettings, activeTabId, setActiveTabId } = useSettingsState();+ const { closeSettings, activeTabId, setActiveTabId } = useSettingsState();const teamsFlag = useFeatureFlag('enable-teams-settings', { enabledOverride: ENABLE_TEAMS_OVERRIDE });// Set up hotkey scope for settings panelconst [attachHotkeys, settingsHotkeyScope] = useHotkeyDOMScope('settings');let settingsContainerRef: HTMLDivElement | undefined;- function focusSettingsOnOpen() {- if (settingsOpen()){- setTimeout(() => {- // Focus the settings container to activate the hotkey scope- settingsContainerRef?.focus();- }, 10);- }- }-- createEffect(focusSettingsOnOpen);-function settingsTabs() {const tabs: { value: string; label: string }[] = [{ value: 'Appearance', label: 'Appearance' },@@ -175,6 +167,7 @@ function SettingsPanel(props: SettingsPanelProps) {class="size-full flex flex-col outline-none"classList={{ invisible: props.hide }}tabIndex={0}+ data-settings-panelref={settingsContainerRef}><SplitHeaderLeft>@@ -239,4 +232,3 @@ function SettingsPanel(props: SettingsPanelProps) {</div>);}-diff --git a/js/app/packages/app/component/split-layout/mobile/MobileSwipeBackContainer.tsx b/js/app/packages/app/component/split-layout/mobile/MobileSwipeBackContainer.tsxindex 507c82cfa1..2b87bb6153 100644--- a/js/app/packages/app/component/split-layout/mobile/MobileSwipeBackContainer.tsx+++ b/js/app/packages/app/component/split-layout/mobile/MobileSwipeBackContainer.tsx@@ -1,14 +1,4 @@-import { cn } from '@ui';-import {- type Accessor,- batch,- createMemo,- createSignal,- onCleanup,- onMount,- Show,- Suspense,-} from 'solid-js';+import { type Accessor, createMemo, Show, Suspense } from 'solid-js';import { SplitPanel } from '../components/SplitPanel';import type {SplitHandle,@@ -16,15 +6,10 @@ import type {SplitManager,SplitState,} from '../layoutManager';+import { createMobileSplitMotion } from './createMobileSplitMotion';import type { MobileSwipeLayout } from './createMobileSwipeLayout';-const SWIPE_EDGE_THRESHOLD = 28; // px from left edge to initiate gesture-const SWIPE_VELOCITY_THRESHOLD = 0.3; // px/ms — fast flick completes swipe-const SWIPE_DISTANCE_THRESHOLD = 0.5; // fraction of screen width-const SWIPE_ANIMATION_MS = 88;-const BG_PEEK_OFFSET = 110; // px the BG panel is offset left at rest; closes to 0 as FG slides away--type MobileSwipeBackContainerProps = {+export type MobileSwipeBackContainerProps = {splitManager: SplitManager;mobileSwipeLayout: MobileSwipeLayout;splits: Accessor<ReadonlyArray<SplitState>>;@@ -34,172 +19,66 @@ type MobileSwipeBackContainerProps = {export function MobileSwipeBackContainer(props: MobileSwipeBackContainerProps) {const { splitManager, mobileSwipeLayout } = props;- const [dragOffset, setDragOffset] = createSignal(0);- const [isDragging, setIsDragging] = createSignal(false);- const [isAnimatingOut, setIsAnimatingOut] = createSignal(false);-- let startX = 0;- let startTime = 0;- let animationTimer: ReturnType<typeof setTimeout> | undefined;- onCleanup(() => clearTimeout(animationTimer));-- function animateComplete(onDone: () => void) {- setIsAnimatingOut(true);- setDragOffset(window.innerWidth);- animationTimer = setTimeout(() => {- batch(() => {- setIsAnimatingOut(false);- setDragOffset(0);- onDone();- });- }, SWIPE_ANIMATION_MS);- }-- function animateSnapBack() {- setIsAnimatingOut(true);- setDragOffset(0);- animationTimer = setTimeout(- () => setIsAnimatingOut(false),- SWIPE_ANIMATION_MS- );- }-- function triggerAnimatedSwipeBack() {- if (!mobileSwipeLayout.canGoBack()) return;- animateComplete(() => mobileSwipeLayout.completeSwipeBack());- }-- // Register the animated trigger so the back button can invoke it.- onMount(() => mobileSwipeLayout.setAnimatedTrigger(triggerAnimatedSwipeBack));- onCleanup(() => mobileSwipeLayout.setAnimatedTrigger(undefined));-- function handleTouchStart(e: TouchEvent) {- if (!mobileSwipeLayout.canGoBack()) return;- const touch = e.touches[0];- if (!touch || touch.clientX > SWIPE_EDGE_THRESHOLD) return;- // Buttons can sit inside the swipe-edge zone. If we start the gesture, the preventDefault() in touchmove suppresses the synthesized click on iOS.- if (- e.target instanceof Element &&- e.target.closest('button, a, [role="button"]')- ) {- return;- }- startX = touch.clientX;- startTime = Date.now();- setIsDragging(true);- }-- function handleTouchMove(e: TouchEvent) {- if (!isDragging()) return;- e.preventDefault();- const touch = e.touches[0];- if (!touch) return;- const dx = Math.max(0, touch.clientX - startX);- setDragOffset(dx);- }-- function handleTouchEnd() {- if (!isDragging()) return;- setIsDragging(false);- const dx = dragOffset();- const elapsed = Date.now() - startTime;- const velocity = elapsed > 0 ? dx / elapsed : 0;- const threshold = window.innerWidth * SWIPE_DISTANCE_THRESHOLD;- if (dx > threshold || velocity > SWIPE_VELOCITY_THRESHOLD) {- animateComplete(() => mobileSwipeLayout.completeSwipeBack());- } else {- animateSnapBack();- }- }-- const slotAData = createMemo(() => {- const id = mobileSwipeLayout.slotASplitId();- if (!id) return undefined;- const split = props.splits().find((s) => s.id === id);- const rawHandle = splitManager.getSplit(id);- if (!split || !rawHandle) return undefined;- const handle: SplitHandle = {- ...rawHandle,- goBack: () => mobileSwipeLayout.swipeBack(),- canGoBack: () => mobileSwipeLayout.canGoBack(),- };- return { split, handle };- });-- const slotBData = createMemo(() => {- const id = mobileSwipeLayout.slotBSplitId();- if (!id) return undefined;- const split = props.splits().find((s) => s.id === id);- const rawHandle = splitManager.getSplit(id);- if (!split || !rawHandle) return undefined;- const handle: SplitHandle = {- ...rawHandle,- goBack: () => mobileSwipeLayout.swipeBack(),- canGoBack: () => mobileSwipeLayout.canGoBack(),- };- return { split, handle };+ const motion = createMobileSplitMotion({+ mobileSwipeLayout,+ panelRefs: props.panelRefs,});- function getFgTransition(): string {- if (isDragging()) return 'none';- if (isAnimatingOut()) return `transform ${SWIPE_ANIMATION_MS}ms ease-out`;- return 'none';- }-- // FG translation style — applied only to the currently-active FG slot div.- const fgStyle = () => ({- transform: `translateX(${dragOffset()}px)`,- transition: getFgTransition(),- 'will-change': 'transform',- });-- // BG parallax style — BG starts BG_PEEK_OFFSET px to the left and closes to 0 as FG slides away.- const bgStyle = () => ({- transform: `translateX(${-BG_PEEK_OFFSET + (dragOffset() / window.innerWidth) * BG_PEEK_OFFSET}px)`,- transition: getFgTransition(),- 'will-change': 'transform',- });+ const slotDataFor = (slotSplitId: Accessor<SplitId | undefined>) =>+ createMemo(() => {+ const id = slotSplitId();+ if (!id) return undefined;+ const split = props.splits().find((s) => s.id === id);+ const rawHandle = splitManager.getSplit(id);+ if (!split || !rawHandle) return undefined;+ const handle: SplitHandle = {+ ...rawHandle,+ goBack: () => mobileSwipeLayout.swipeBack(),+ canGoBack: () => mobileSwipeLayout.canGoBack(),+ };+ return { split, handle };+ });++ const slotAData = slotDataFor(mobileSwipeLayout.slotASplitId);+ const slotBData = slotDataFor(mobileSwipeLayout.slotBSplitId);++ const renderKeyForSplit = (split: SplitState) =>+ `${split.id}:${split.content.type}:${split.content.id}`;return (<divclass="relative size-full overflow-hidden"- on:touchstart={handleTouchStart}- on:touchmove={handleTouchMove}- on:touchend={handleTouchEnd}- on:touchcancel={() => {- if (!isDragging()) return;- setIsDragging(false);- animateSnapBack();- }}+ on:touchstart={motion.handleTouchStart}+ on:touchmove={motion.handleTouchMove}+ on:touchend={motion.handleTouchEnd}+ on:touchcancel={motion.handleTouchCancel}><Show when={slotAData()}>{(a) => (<div- class={cn(- 'absolute inset-0',- {- 'z-10 shadow-xl': mobileSwipeLayout.fgIsSlotA(),- 'z-0 pointer-events-none': !mobileSwipeLayout.fgIsSlotA(),- },- !mobileSwipeLayout.fgIsSlotA() &&- !isDragging() &&- !isAnimatingOut() &&- 'hidden'- )}- style={mobileSwipeLayout.fgIsSlotA() ? fgStyle() : bgStyle()}+ class={motion.classForSlot(mobileSwipeLayout.fgIsSlotA())}+ style={motion.styleForSlot(mobileSwipeLayout.fgIsSlotA())}+ onTransitionEnd={(e) =>+ motion.handleTransitionEnd(e, mobileSwipeLayout.fgIsSlotA())+ }>{/*- * Key by content id so that SplitPanel (and its soup state) remounts when the slot's content changes, needed for dock / soup-view navigation.+ * Key by split and content so SplitPanel remounts when a slot+ * receives a new split, even if it has the same content id.*/}- <Show when={a().split.content.id} keyed>- {(_contentId) => (+ <Show when={renderKeyForSplit(a().split)} keyed>+ {(_renderKey) => (<Suspense><SplitPanelsplit={a().split}handle={a().handle}active={mobileSwipeLayout.fgIsSlotA()}setPanelRef={(ref) =>- props.panelRefs.set(a().split.id, ref)+ motion.handlePanelRef(+ a().split.id,+ ref,+ mobileSwipeLayout.fgIsSlotA()+ )}index={0}/>@@ -213,28 +92,25 @@ export function MobileSwipeBackContainer(props: MobileSwipeBackContainerProps) {<Show when={slotBData()}>{(b) => (<div- class={cn(- 'absolute inset-0',- {- 'z-user-highlight shadow-xl': !mobileSwipeLayout.fgIsSlotA(),- '-z-1 pointer-events-none': mobileSwipeLayout.fgIsSlotA(),- },- mobileSwipeLayout.fgIsSlotA() &&- !isDragging() &&- !isAnimatingOut() &&- 'hidden'- )}- style={!mobileSwipeLayout.fgIsSlotA() ? fgStyle() : bgStyle()}+ class={motion.classForSlot(!mobileSwipeLayout.fgIsSlotA())}+ style={motion.styleForSlot(!mobileSwipeLayout.fgIsSlotA())}+ onTransitionEnd={(e) =>+ motion.handleTransitionEnd(e, !mobileSwipeLayout.fgIsSlotA())+ }>- <Show when={b().split.content.id} keyed>- {(_contentId) => (+ <Show when={renderKeyForSplit(b().split)} keyed>+ {(_renderKey) => (<Suspense><SplitPanelsplit={b().split}handle={b().handle}active={!mobileSwipeLayout.fgIsSlotA()}setPanelRef={(ref) =>- props.panelRefs.set(b().split.id, ref)+ motion.handlePanelRef(+ b().split.id,+ ref,+ !mobileSwipeLayout.fgIsSlotA()+ )}index={1}/>diff --git a/js/app/packages/app/component/split-layout/mobile/createMobileForwardAnimation.ts b/js/app/packages/app/component/split-layout/mobile/createMobileForwardAnimation.tsnew file mode 100644index 0000000000..3bf3024eed--- /dev/null+++ b/js/app/packages/app/component/split-layout/mobile/createMobileForwardAnimation.ts@@ -0,0 +1,142 @@+import { batch, createSignal, onCleanup } from 'solid-js';+import type { SplitId } from '../layoutManager';+import type { MobileSwipeLayout } from './createMobileSwipeLayout';++type ForwardAnimationPhase = 'idle' | 'preparing' | 'animating';++type SplitTransformStyle = {+ transform: string;+ transition: string;+ 'will-change': string;+};++type MobileForwardAnimationOptions = {+ animationMs: number;+ bgPeekOffset: number;+ mobileSwipeLayout: MobileSwipeLayout;+ panelRefs: Map<SplitId, HTMLDivElement>;+};++export function createMobileForwardAnimation(+ options: MobileForwardAnimationOptions+) {+ const [phase, setPhase] = createSignal<ForwardAnimationPhase>('idle');++ let forwardStartFrame: ReturnType<typeof requestAnimationFrame> | undefined;+ let forwardSettleFrame: ReturnType<typeof requestAnimationFrame> | undefined;++ const cancelFrame = (+ frame: ReturnType<typeof requestAnimationFrame> | undefined+ ) => {+ if (frame !== undefined) {+ cancelAnimationFrame(frame);+ }+ return undefined;+ };++ function clearScheduledAnimation() {+ forwardStartFrame = cancelFrame(forwardStartFrame);+ forwardSettleFrame = cancelFrame(forwardSettleFrame);+ }++ onCleanup(clearScheduledAnimation);++ function incomingSplitId() {+ return options.mobileSwipeLayout.fgIsSlotA()+ ? options.mobileSwipeLayout.slotBSplitId()+ : options.mobileSwipeLayout.slotASplitId();+ }++ function incomingPanelIsMounted() {+ const splitId = incomingSplitId();+ if (!splitId) return false;+ return options.panelRefs.get(splitId)?.isConnected === true;+ }++ function scheduleAnimationStartIfReady() {+ if (phase() !== 'preparing') return;+ if (!incomingPanelIsMounted()) return;+ scheduleAnimationStart();+ }++ function scheduleAnimationStart() {+ if (forwardStartFrame !== undefined) return;+ forwardStartFrame = requestAnimationFrame(() => {+ forwardStartFrame = undefined;+ forwardSettleFrame = requestAnimationFrame(() => {+ forwardSettleFrame = undefined;+ if (phase() === 'preparing') {+ setPhase('animating');+ }+ });+ });+ }++ function trigger() {+ if (phase() !== 'idle') return;++ clearScheduledAnimation();+ setPhase('preparing');+ scheduleAnimationStartIfReady();+ }++ function handleTransitionEnd(e: TransitionEvent, isForeground: boolean) {+ if (e.target !== e.currentTarget) return;+ if (isForeground) return;+ if (e.propertyName !== 'transform') return;+ if (phase() !== 'animating') return;++ batch(() => {+ setPhase('idle');+ options.mobileSwipeLayout.completeNavigateForward();+ });+ }++ function handlePanelRef(+ splitId: SplitId,+ ref: HTMLDivElement,+ isForeground: boolean+ ) {+ options.panelRefs.set(splitId, ref);+ if (!isForeground && splitId === incomingSplitId()) {+ scheduleAnimationStartIfReady();+ }+ }++ function incomingStyle(): SplitTransformStyle {+ return {+ transform: phase() === 'animating' ? 'translateX(0)' : 'translateX(100%)',+ transition:+ phase() === 'animating'+ ? `transform ${options.animationMs}ms ease-out`+ : 'none',+ 'will-change': 'transform',+ };+ }++ function outgoingStyle(): SplitTransformStyle {+ return {+ transform:+ phase() === 'animating'+ ? `translateX(${-options.bgPeekOffset}px)`+ : 'translateX(0)',+ transition:+ phase() === 'animating'+ ? `transform ${options.animationMs}ms ease-out`+ : 'none',+ 'will-change': 'transform',+ };+ }++ function styleForSlot(isForeground: boolean) {+ return isForeground ? outgoingStyle() : incomingStyle();+ }++ return {+ phase,+ trigger,+ handleTransitionEnd,+ handlePanelRef,+ styleForSlot,+ };+}diff --git a/js/app/packages/app/component/split-layout/mobile/createMobileSplitMotion.ts b/js/app/packages/app/component/split-layout/mobile/createMobileSplitMotion.tsnew file mode 100644index 0000000000..69c9d3dab4--- /dev/null+++ b/js/app/packages/app/component/split-layout/mobile/createMobileSplitMotion.ts@@ -0,0 +1,88 @@+import { cn } from '@ui';+import { onCleanup, onMount } from 'solid-js';+import type { SplitId } from '../layoutManager';+import { createMobileForwardAnimation } from './createMobileForwardAnimation';+import { createMobileSwipeBackGesture } from './createMobileSwipeBackGesture';+import type { MobileSwipeLayout } from './createMobileSwipeLayout';++const SWIPE_EDGE_THRESHOLD = 40; // px from left edge to initiate gesture+const SWIPE_VELOCITY_THRESHOLD = 0.3; // px/ms - fast flick completes swipe+const SWIPE_DISTANCE_THRESHOLD = 0.5; // fraction of screen width+const SWIPE_ANIMATION_MS = 88;+const BG_PEEK_OFFSET = 110; // px the BG panel is offset left at rest; closes to 0 as FG slides away++type MobileSplitMotionOptions = {+ mobileSwipeLayout: MobileSwipeLayout;+ panelRefs: Map<SplitId, HTMLDivElement>;+};++export function createMobileSplitMotion(options: MobileSplitMotionOptions) {+ const { mobileSwipeLayout } = options;++ const forwardAnimation = createMobileForwardAnimation({+ animationMs: SWIPE_ANIMATION_MS,+ bgPeekOffset: BG_PEEK_OFFSET,+ mobileSwipeLayout,+ panelRefs: options.panelRefs,+ });+ const swipeBackGesture = createMobileSwipeBackGesture({+ animationMs: SWIPE_ANIMATION_MS,+ bgPeekOffset: BG_PEEK_OFFSET,+ edgeThreshold: SWIPE_EDGE_THRESHOLD,+ velocityThreshold: SWIPE_VELOCITY_THRESHOLD,+ distanceThreshold: SWIPE_DISTANCE_THRESHOLD,+ mobileSwipeLayout,+ canStart: () => forwardAnimation.phase() === 'idle',+ });++ onMount(() => {+ mobileSwipeLayout.setAnimatedTrigger(swipeBackGesture.trigger);+ mobileSwipeLayout.setForwardNavigationTrigger(() => {+ swipeBackGesture.reset();+ forwardAnimation.trigger();+ });+ });+ onCleanup(() => {+ mobileSwipeLayout.setAnimatedTrigger(undefined);+ mobileSwipeLayout.setForwardNavigationTrigger(undefined);+ });++ const forwardIsActive = () => forwardAnimation.phase() !== 'idle';++ function styleForSlot(isForeground: boolean) {+ if (forwardIsActive()) {+ return forwardAnimation.styleForSlot(isForeground);+ }+ return swipeBackGesture.styleForSlot(isForeground);+ }++ function classForSlot(isForeground: boolean) {+ return cn(+ 'absolute inset-0',+ {+ 'z-10': isForeground && !forwardIsActive(),+ 'z-0 pointer-events-none':+ (!isForeground && !forwardIsActive()) ||+ (isForeground && forwardIsActive()),+ 'z-user-highlight pointer-events-none':+ !isForeground && forwardIsActive(),+ },+ !isForeground &&+ !swipeBackGesture.isDragging() &&+ !swipeBackGesture.isAnimatingOut() &&+ !forwardIsActive() &&+ 'hidden'+ );+ }++ return {+ classForSlot,+ styleForSlot,+ handlePanelRef: forwardAnimation.handlePanelRef,+ handleTransitionEnd: forwardAnimation.handleTransitionEnd,+ handleTouchStart: swipeBackGesture.handleTouchStart,+ handleTouchMove: swipeBackGesture.handleTouchMove,+ handleTouchEnd: swipeBackGesture.handleTouchEnd,+ handleTouchCancel: swipeBackGesture.handleTouchCancel,+ };+}diff --git a/js/app/packages/app/component/split-layout/mobile/createMobileSwipeBackGesture.ts b/js/app/packages/app/component/split-layout/mobile/createMobileSwipeBackGesture.tsnew file mode 100644index 0000000000..33168e9061--- /dev/null+++ b/js/app/packages/app/component/split-layout/mobile/createMobileSwipeBackGesture.ts@@ -0,0 +1,160 @@+import { batch, createSignal, onCleanup } from 'solid-js';+import type { MobileSwipeLayout } from './createMobileSwipeLayout';++type SplitTransformStyle = {+ transform: string;+ transition: string;+ 'will-change': string;+};++type MobileSwipeBackGestureOptions = {+ animationMs: number;+ bgPeekOffset: number;+ edgeThreshold: number;+ velocityThreshold: number;+ distanceThreshold: number;+ mobileSwipeLayout: MobileSwipeLayout;+ canStart: () => boolean;+};++export function createMobileSwipeBackGesture(+ options: MobileSwipeBackGestureOptions+) {+ const [dragOffset, setDragOffset] = createSignal(0);+ const [isDragging, setIsDragging] = createSignal(false);+ const [isAnimatingOut, setIsAnimatingOut] = createSignal(false);++ let startX = 0;+ let startTime = 0;+ let animationTimer: ReturnType<typeof setTimeout> | undefined;++ function clearScheduledAnimation() {+ clearTimeout(animationTimer);+ }++ onCleanup(clearScheduledAnimation);++ function reset() {+ clearScheduledAnimation();+ batch(() => {+ setIsDragging(false);+ setIsAnimatingOut(false);+ setDragOffset(0);+ });+ }++ function animateComplete(onDone: () => void) {+ clearScheduledAnimation();+ setIsAnimatingOut(true);+ setDragOffset(window.innerWidth);+ animationTimer = setTimeout(() => {+ batch(() => {+ setIsAnimatingOut(false);+ setDragOffset(0);+ onDone();+ });+ }, options.animationMs);+ }++ function animateSnapBack() {+ clearScheduledAnimation();+ setIsAnimatingOut(true);+ setDragOffset(0);+ animationTimer = setTimeout(+ () => setIsAnimatingOut(false),+ options.animationMs+ );+ }++ function trigger() {+ if (!options.canStart() || isAnimatingOut()) return;+ if (!options.mobileSwipeLayout.canGoBack()) return;+ animateComplete(() => options.mobileSwipeLayout.completeSwipeBack());+ }++ function handleTouchStart(e: TouchEvent) {+ if (!options.canStart() || isAnimatingOut()) return;+ if (!options.mobileSwipeLayout.canGoBack()) return;+ const touch = e.touches[0];+ if (!touch || touch.clientX > options.edgeThreshold) return;+ // Buttons can sit inside the swipe-edge zone. If we start the gesture, the preventDefault() in touchmove suppresses the synthesized click on iOS.+ if (+ e.target instanceof Element &&+ e.target.closest('button, a, [role="button"]')+ ) {+ return;+ }+ startX = touch.clientX;+ startTime = Date.now();+ setIsDragging(true);+ }++ function handleTouchMove(e: TouchEvent) {+ if (!isDragging()) return;+ e.preventDefault();+ const touch = e.touches[0];+ if (!touch) return;+ const dx = Math.max(0, touch.clientX - startX);+ setDragOffset(dx);+ }++ function handleTouchEnd() {+ if (!isDragging()) return;+ setIsDragging(false);+ const dx = dragOffset();+ const elapsed = Date.now() - startTime;+ const velocity = elapsed > 0 ? dx / elapsed : 0;+ const threshold = window.innerWidth * options.distanceThreshold;+ if (dx > threshold || velocity > options.velocityThreshold) {+ trigger();+ } else {+ animateSnapBack();+ }+ }++ function handleTouchCancel() {+ if (!isDragging()) return;+ setIsDragging(false);+ animateSnapBack();+ }++ function getTransition(): string {+ if (isDragging()) return 'none';+ if (isAnimatingOut()) {+ return `transform ${options.animationMs}ms ease-out`;+ }+ return 'none';+ }++ function foregroundStyle(): SplitTransformStyle {+ return {+ transform: `translateX(${dragOffset()}px)`,+ transition: getTransition(),+ 'will-change': 'transform',+ };+ }++ function backgroundStyle(): SplitTransformStyle {+ return {+ transform: `translateX(${-options.bgPeekOffset + (dragOffset() / window.innerWidth) * options.bgPeekOffset}px)`,+ transition: getTransition(),+ 'will-change': 'transform',+ };+ }++ function styleForSlot(isForeground: boolean) {+ return isForeground ? foregroundStyle() : backgroundStyle();+ }++ return {+ isDragging,+ isAnimatingOut,+ reset,+ trigger,+ handleTouchStart,+ handleTouchMove,+ handleTouchEnd,+ handleTouchCancel,+ styleForSlot,+ };+}diff --git a/js/app/packages/app/component/split-layout/mobile/createMobileSwipeLayout.ts b/js/app/packages/app/component/split-layout/mobile/createMobileSwipeLayout.tsindex 34bbb5f80a..81d79441fe 100644--- a/js/app/packages/app/component/split-layout/mobile/createMobileSwipeLayout.ts+++ b/js/app/packages/app/component/split-layout/mobile/createMobileSwipeLayout.ts@@ -23,11 +23,18 @@ export type MobileSwipeLayout = {* Called by MobileSwipeBackContainer after its animation finishes.*/completeSwipeBack: () => void;+ /** Completes a prepared forward navigation after the swipe-in animation. */+ completeNavigateForward: () => void;/*** Register an animated trigger provided by MobileSwipeBackContainer.* When set, swipeBack() will animate before completing.*/setAnimatedTrigger: (trigger: (() => void) | undefined) => void;+ /**+ * Register an animated forward-navigation trigger. The next split is already+ * prepared in the background slot when this trigger runs.+ */+ setForwardNavigationTrigger: (trigger: (() => void) | undefined) => void;/*** Initiate a swipe-back — animated if container has registered a trigger,* otherwise completes immediately. Called by the split header back button.@@ -52,9 +59,12 @@ export function createMobileSwipeLayout(const toggleFgSlot = () => setFgIsSlotA((prev) => !prev);let animatedTrigger: (() => void) | undefined;+ let forwardNavigationTrigger: (() => void) | undefined;const fgSplitId = () => (fgIsSlotA() ? slotASplitId() : slotBSplitId());const bgSplitId = () => (fgIsSlotA() ? slotBSplitId() : slotASplitId());+ const sameContent = (a: SplitContent, b: SplitContent) =>+ a.type === b.type && a.id === b.id;// The BG split is always exactly bgSplitId() — derive exclusion directly from// the slot signals rather than maintaining a separate set.@@ -88,6 +98,20 @@ export function createMobileSwipeLayout(const fgHandle = currentFgId? splitManager.getSplit(currentFgId): undefined;+ const bgHandle = currentBgId+ ? splitManager.getSplit(currentBgId)+ : undefined;++ // If the target is already mounted in BG, promote it instead of recreating it.+ if (bgHandle && sameContent(bgHandle.content(), content)) {+ if (forwardNavigationTrigger) {+ forwardNavigationTrigger();+ } else {+ completeNavigateForward();+ }+ return;+ }+const newFgInitialHistory = fgHandle?.history() ?? [];// Batch to ensure reactive dependencies never see intermediate state.@@ -99,11 +123,26 @@ export function createMobileSwipeLayout(const newFgHandle = splitManager.createNewSplit({content,initialHistory: newFgInitialHistory,- activate: true,+ activate: false,referredFrom,});setNewFgSlotId(newFgHandle.id);+ });++ if (forwardNavigationTrigger) {+ forwardNavigationTrigger();+ } else {+ completeNavigateForward();+ }+ }++ function completeNavigateForward() {+ const preparedFgId = bgSplitId();+ if (!preparedFgId) return;++ batch(() => {+ splitManager.activateSplit(preparedFgId);toggleFgSlot();});}@@ -150,6 +189,10 @@ export function createMobileSwipeLayout(animatedTrigger = trigger;}+ function setForwardNavigationTrigger(trigger: (() => void) | undefined) {+ forwardNavigationTrigger = trigger;+ }+function swipeBack() {if (!canGoBack()) return;if (animatedTrigger) {@@ -165,7 +208,9 @@ export function createMobileSwipeLayout(fgIsSlotA,canGoBack,completeSwipeBack,+ completeNavigateForward,setAnimatedTrigger,+ setForwardNavigationTrigger,swipeBack,};}diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex c8e46dba97..2db5a297fe 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -421,17 +421,28 @@ html:not([data-touch-device="true"]) [data-message]:hover{@apply bg-ink/3 rounded-sm ring ring-edge ring-inset;}-/* Long-press animation */-.long-press-animation [data-swipe-content],-[data-message].long-press-animation{+/* Channel message long-press animation */+.channel-message-long-press-highlight [data-swipe-content],+[data-message].channel-message-long-press-highlight{animation: long-press-message-highlight 400ms ease-in both;}-[data-message].long-press-animation > .message-accent-bar,-.long-press-animation [data-accent-bar] {+[data-message].channel-message-long-press-highlight > .message-accent-bar,+.channel-message-long-press-highlight [data-accent-bar] {animation: long-press-accent-bar 400ms ease-in both;}+/* Immediate touch feedback for mobile soup entity rows */+[data-soup-entity].touch-highlight [data-swipe-content],+[data-soup-entity].touch-highlight .soup-list-entity,+[data-soup-entity].navigation-touch-highlight [data-swipe-content],+[data-soup-entity].navigation-touch-highlight .soup-list-entity,+.soup-list-entity.navigation-touch-highlight,+.soup-list-entity.navigation-touch-highlight [data-swipe-content] {+ background-color: var(--color-hover);+ transition: none;+}+:focus-visible {outline: none;}diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsxindex 0dba484fa4..d3c129ce0e 100644--- a/js/app/packages/block-email/component/Email.tsx+++ b/js/app/packages/block-email/component/Email.tsx@@ -1,3 +1,4 @@+import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { EmailCompose } from '@block-email/component/compose/Compose';import {EmailProvider,@@ -10,6 +11,7 @@ import { useUserContext } from '@core/context/user';import { TOKENS } from '@core/hotkey/tokens';import { registerScopeSignalHotkey } from '@core/hotkey/utils';import { isMobile } from '@core/mobile/isMobile';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import {blockElementSignal,blockHotkeyScopeSignal,@@ -61,6 +63,7 @@ function EmailContent(props: EmailViewProps) {const blockElement = blockElementSignal.get;const context = useEmailContext();+ const splitPanel = useSplitPanel();const { isLoading: isUserLoading } = useUserContext();const [isScrolled, setIsScrolled] = createSignal(false);@@ -193,12 +196,19 @@ function EmailContent(props: EmailViewProps) {)?.db_id;});+ const canRunInitialEmailScroll = () =>+ !isTouchDevice() || splitPanel?.isPanelActive() !== false;+// ============================================// PHASE 2: HANDLE TARGET MESSAGE SCROLLING// ============================================// This effect handles scrolling to a specific message (if provided via URL) or scrolling to the last message by default// This effect should only run once.context.onInitialDataLoad(() => {+ // Initial scroll positioning visibly shifts the email panel if it runs+ // while the split is swiping in on touch devices.+ if (!canRunInitialEmailScroll()) return false;+// Check for target messageconst targetMessageId_ = context.messages.targetMessageID();@@ -352,8 +362,9 @@ function EmailContent(props: EmailViewProps) {createEffect(() => {if (hasRun) return;// Focus the email block on mount+ if (isTouchDevice()) return;if (!blockElement()) return;- blockElement()?.focus();+ blockElement()?.focus({ preventScroll: true });hasRun = true;});diff --git a/js/app/packages/channel/Message/ChannelMessage.tsx b/js/app/packages/channel/Message/ChannelMessage.tsxindex 1d1c0d5c22..3dcdf42061 100644--- a/js/app/packages/channel/Message/ChannelMessage.tsx+++ b/js/app/packages/channel/Message/ChannelMessage.tsx@@ -189,6 +189,7 @@ export function ChannelMessage(props: ChannelMessageProps) {onClick={props.onClick}ref={(el) =>longPressHighlight(el, () => ({+ className: 'channel-message-long-press-highlight',onLongPress: () => drawerManager?.open(props.message, props.actions),}))}diff --git a/js/app/packages/core/constant/SettingsState.tsx b/js/app/packages/core/constant/SettingsState.tsxindex 90c30474e5..62d9635ced 100644--- a/js/app/packages/core/constant/SettingsState.tsx+++ b/js/app/packages/core/constant/SettingsState.tsx@@ -1,5 +1,6 @@import { useSplitLayout } from '@app/component/split-layout/layout';import { globalSplitManager } from '@app/signal/splitLayout';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { createMemo, createSignal } from 'solid-js';export type SettingsTab =@@ -37,9 +38,22 @@ export const useSettingsState = () => {return getSettingsSplit() !== undefined;});+ const focusSettingsPanel = () => {+ if (isTouchDevice()) return;+ setTimeout(() => {+ const settingsSplit = getSettingsSplit();+ if (!settingsSplit) return;+ const settingsPanel = document.querySelector<HTMLElement>(+ `[data-split-id="${settingsSplit.id}"] [data-settings-panel]`+ );+ settingsPanel?.focus({ preventScroll: true });+ }, 10);+ };+const openSettings = (activeTabId?: SettingsTab) => {if (activeTabId) setActiveTabId(activeTabId);openWithSplit({ type: 'component', id: 'settings' }, { activate: true });+ focusSettingsPanel();};const closeSettings = () => {diff --git a/js/app/packages/core/directive/longPressHighlight.ts b/js/app/packages/core/directive/longPressHighlight.tsindex 057366c460..0005839470 100644--- a/js/app/packages/core/directive/longPressHighlight.ts+++ b/js/app/packages/core/directive/longPressHighlight.ts@@ -1,12 +1,13 @@import { type Accessor, onCleanup } from 'solid-js';import { touchHandler } from './touchHandler';+const LONG_PRESS_ENTER_DELAY_MS = 100;+const LONG_PRESS_EXIT_DELAY_MS = 50;+interface LongPressHighlightOptions {onLongPress?: () => void;- /** Delay (ms) before adding the `long-press-animation` class on touch start. If touch ends before this delay, no exit animation plays. Default: 100 */- enterDelay?: number;- /** Delay (ms) before removing the `long-press-animation` class after a long press. Default: 50 */- exitDelay?: number;+ /** CSS class added while the touch highlight is active. */+ className: string;}declare module 'solid-js' {@@ -18,18 +19,37 @@ declare module 'solid-js' {}/**- * Wraps touchHandler to manage the `long-press-animation` CSS class lifecycle on an element.- * Pair with the corresponding CSS animation on `.long-press-animation`.+ * Wraps touchHandler to manage a touch highlight CSS class lifecycle on an element.+ * Pair with a corresponding CSS animation for the configured className.*/export function longPressHighlight(element: HTMLElement,options: Accessor<LongPressHighlightOptions>) {let enterTimer: number | undefined;+ let exitTimer: number | undefined;+ let activeClassName: string | undefined;++ const highlightClassName = () => options().className;++ const cancelExit = () => {+ if (exitTimer !== undefined) {+ clearTimeout(exitTimer);+ exitTimer = undefined;+ }+ };const startAnimation = () => {enterTimer = undefined;- element.classList.add('long-press-animation');+ cancelExit();++ const className = highlightClassName();+ if (activeClassName && activeClassName !== className) {+ element.classList.remove(activeClassName);+ }++ activeClassName = className;+ element.classList.add(className);};const cancelEnter = () => {@@ -40,15 +60,23 @@ export function longPressHighlight(};const endAnimation = () => {- element.classList.remove('long-press-animation');+ cancelExit();+ if (activeClassName) {+ element.classList.remove(activeClassName);+ activeClassName = undefined;+ return;+ }+ element.classList.remove(highlightClassName());+ };++ const scheduleEndAnimation = (delay: number) => {+ cancelExit();+ exitTimer = window.setTimeout(endAnimation, delay);};touchHandler(element, () => ({onTouchStart: () => {- enterTimer = window.setTimeout(- startAnimation,- options().enterDelay ?? 100- );+ enterTimer = window.setTimeout(startAnimation, LONG_PRESS_ENTER_DELAY_MS);},onLongPress: () => {options().onLongPress?.();@@ -62,10 +90,13 @@ export function longPressHighlight(if (!longpress) {endAnimation();} else {- setTimeout(endAnimation, options().exitDelay ?? 50);+ scheduleEndAnimation(LONG_PRESS_EXIT_DELAY_MS);}},}));- onCleanup(cancelEnter);+ onCleanup(() => {+ cancelEnter();+ endAnimation();+ });}diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsxindex c75d6dba1b..8543132e88 100644--- a/js/app/packages/entity/src/composed/ListEntity.tsx+++ b/js/app/packages/entity/src/composed/ListEntity.tsx@@ -3,6 +3,7 @@ import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { isMobile } from '@core/mobile/isMobile';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { stackNotifications } from '@notifications';import {BULK_DOCUMENT_WAKEUP_FEATURE_FLAG,@@ -202,8 +203,9 @@ export function ListEntity(props: ListEntityProps) {'bg-accent/8': props.checked,'ring ring-accent/16 ring-inset': props.checked && props.highlighted,'ring ring-edge bg-active/60 ring-inset':- props.highlighted && !props.checked,- 'hover:bg-active/30': !props.highlighted && !props.checked,+ props.highlighted && !props.checked && !isTouchDevice(),+ 'hover:bg-active/30':+ !props.highlighted && !props.checked && !isTouchDevice(),})}onMouseMove={props.onMouseMove}