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 on a message to reply in channels (#4657)
Peter Chinman65c889d539cc
diff --git a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsx b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsxindex 20fae70ce1..2d687c4b50 100644--- a/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsx+++ b/js/app/packages/app/component/auth/mobile-onboarding/OnboardingInbox.tsx@@ -1,5 +1,5 @@-import { EntityRowProvider } from '@app/component/mobile/EntityRow';import { MobileDrawer } from '@app/component/mobile/MobileDrawer';+import { SwipableRowProvider } from '@app/component/mobile/SwipableRow';import { touchHandler } from '@core/directive/touchHandler';import {type EmailEntity,@@ -130,7 +130,7 @@ export function OnboardingInbox() {</p><ListLayoutProvider ref={listRef}>- <EntityRowProvider+ <SwipableRowProvidercontainer={listRef}canSwipeLeft={() => true}onSwipeLeft={(entityId) => markDone(entityId)}@@ -168,7 +168,7 @@ export function OnboardingInbox() {)}</For></div>- </EntityRowProvider>+ </SwipableRowProvider></ListLayoutProvider>{/* Long-press action drawer (markup modeled on SoupEntityActionDrawer). */}diff --git a/js/app/packages/app/component/mobile/EntityRow.tsx b/js/app/packages/app/component/mobile/SwipableRow.tsxsimilarity index 62%rename from js/app/packages/app/component/mobile/EntityRow.tsxrename to js/app/packages/app/component/mobile/SwipableRow.tsxindex 45b8b1bf8b..572f96ffae 100644--- a/js/app/packages/app/component/mobile/EntityRow.tsx+++ b/js/app/packages/app/component/mobile/SwipableRow.tsx@@ -1,4 +1,5 @@import { hapticImpact } from '@core/mobile/haptics';+import { cn } from '@ui';import {type Accessor,createContext,@@ -46,7 +47,7 @@ const isAtLeastPhase = (phase: RowPhase, minInclusive: RowPhase) =>type SwipeDirection = 'left' | 'right' | null;-type EntityRowState = {+type SwipableRowState = {direction: SwipeDirection;phase: RowPhase;};@@ -65,49 +66,54 @@ type SwipeTouchState = {currentX: number;currentY: number;isSwipeGesture: boolean | null;- entityId: string | null;+ id: string | null;elements: RowElements | undefined;};-type EntityRowContextValue = {- stateFor: (entityId: string) => EntityRowState;- clearState: (entityId: string) => void;- collapseEntity: (entityId: string) => Promise<void>;+type SwipableRowContextValue = {+ stateFor: (id: string) => SwipableRowState;+ clearState: (id: string) => void;+ collapseRow: (id: string) => Promise<void>;registerRowHandler: (- entityId: string,+ id: string,handlers: { onSwipeLeft?: () => void; onSwipeRight?: () => void }) => void;- unregisterRowHandler: (entityId: string) => void;+ unregisterRowHandler: (id: string) => void;};-export const EntityRowContext = createContext<EntityRowContextValue>();+export const SwipableRowContext = createContext<SwipableRowContextValue>();-export function EntityRowProvider(+export function SwipableRowProvider(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- >;+ /**+ * How a row animates once its swipe triggers. 'fly-out' (default)+ * translates the row off-screen, for actions that remove the row from+ * the list (e.g. mark done). 'spring-back' returns the row to rest, for+ * actions that keep it in place (e.g. reply to a message).+ */+ triggerBehavior?: 'fly-out' | 'spring-back';+ setCollapseEntity?: Setter<((id: string) => Promise<void>) | undefined>;}>) {const [stateById, setStateById] = createSignal<- Record<string, EntityRowState>+ Record<string, SwipableRowState>>(Object.create(null));- const setState = (entityId: string, state: Partial<EntityRowState>) => {+ const setState = (id: string, state: Partial<SwipableRowState>) => {setStateById((prev) => ({...prev,- [entityId]: { ...prev[entityId], ...state },+ [id]: { ...prev[id], ...state },}));};- const clearState = (entityId: string) => {+ const clearState = (id: string) => {setStateById((prev) => {const newState = { ...prev };- delete newState[entityId];+ delete newState[id];return newState;});};@@ -122,7 +128,7 @@ export function EntityRowProvider(currentX: 0,currentY: 0,isSwipeGesture: null,- entityId: null,+ id: null,elements: undefined,};@@ -130,7 +136,7 @@ export function EntityRowProvider(const resetRowState = () => {const els = touchState.elements;- const id = touchState.entityId;+ const id = touchState.id;if (!els || !id) return;// if row has not been collapsed, reset its styling.setTimeout(() => {@@ -152,15 +158,15 @@ export function EntityRowProvider(currentX: 0,currentY: 0,isSwipeGesture: null,- entityId: null,+ id: null,elements: undefined,};};function springBack() {- if (!touchState.elements || !touchState.entityId) return;+ if (!touchState.elements || !touchState.id) return;const { contentEl } = touchState.elements;- const entityId = touchState.entityId;+ const entityId = touchState.id;contentEl.style.transition = `transform ${SPRING_BACK_SPEED}ms ease-out`;contentEl.style.transform = 'translateX(0px)';@@ -170,7 +176,7 @@ export function EntityRowProvider(}, SPRING_BACK_SPEED);}- const collapseEntity = (entityId: string): Promise<void> => {+ const collapseRow = (entityId: string): Promise<void> => {return new Promise((resolve) => {setState(entityId, { phase: 'collapsing' });setTimeout(() => {@@ -182,32 +188,47 @@ export function EntityRowProvider(// Register/unregister the row-collapse hook with our parent (e.g. UnifiedListView).onMount(() => {- props.setCollapseEntity?.(() => collapseEntity);+ props.setCollapseEntity?.(() => collapseRow);onCleanup(() => props.setCollapseEntity?.(() => undefined));});- const handleSwipe = (entityId: string) => {+ const handleSwipe = (id: string) => {const els = touchState.elements;if (!els) return;- const direction = stateById()[entityId]?.direction;+ const direction = stateById()[id]?.direction;if (!direction) return;const defaultSwipeLeft = props.onSwipeLeft;const defaultSwipeRight = props.onSwipeRight;const swipeHandler =direction === 'left'- ? (customRowSwipeHandlers.get(entityId)?.onSwipeLeft ??- (defaultSwipeLeft ? () => defaultSwipeLeft(entityId) : undefined))- : (customRowSwipeHandlers.get(entityId)?.onSwipeRight ??- (defaultSwipeRight ? () => defaultSwipeRight(entityId) : undefined));+ ? (customRowSwipeHandlers.get(id)?.onSwipeLeft ??+ (defaultSwipeLeft ? () => defaultSwipeLeft(id) : undefined))+ : (customRowSwipeHandlers.get(id)?.onSwipeRight ??+ (defaultSwipeRight ? () => defaultSwipeRight(id) : undefined));if (!swipeHandler) return;// Cancel any pending animation frameif (rafId) cancelAnimationFrame(rafId);+ if (props.triggerBehavior === 'spring-back') {+ // The row stays in the list: return the content to rest and fire the+ // handler synchronously — still inside the touch gesture, so a+ // handler that focuses an input can open the iOS keyboard.+ els.contentEl.style.transition = `transform ${SPRING_BACK_SPEED}ms ease-out`;+ els.contentEl.style.transform = 'translateX(0px)';+ setState(id, { phase: 'triggered' });+ swipeHandler();+ setTimeout(() => {+ els.contentEl.style.transition = '';+ clearState(id);+ }, SPRING_BACK_SPEED);+ return;+ }+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' });+ setState(id, { phase: 'triggered' });setTimeout(() => {swipeHandler();@@ -222,17 +243,34 @@ export function EntityRowProvider(resetRowState();};- const canSwipeRight = (entityId: string) => {- if (customRowSwipeHandlers.get(entityId)?.onSwipeRight !== undefined)- return true;+ const canSwipeRight = (id: string) => {+ if (customRowSwipeHandlers.get(id)?.onSwipeRight !== undefined) return true;if (!props.onSwipeRight) return false;- return props.canSwipeRight ? props.canSwipeRight(entityId) : true;+ return props.canSwipeRight ? props.canSwipeRight(id) : true;};- const canSwipeLeft = (entityId: string) => {- if (customRowSwipeHandlers.get(entityId)?.onSwipeLeft !== undefined)- return true;+ const canSwipeLeft = (id: string) => {+ if (customRowSwipeHandlers.get(id)?.onSwipeLeft !== undefined) return true;if (!props.onSwipeLeft) return false;- return props.canSwipeLeft ? props.canSwipeLeft(entityId) : true;+ return props.canSwipeLeft ? props.canSwipeLeft(id) : true;+ };++ // Touches that begin inside a horizontally scrollable element (a code+ // block, a wide table) must pan that element, not swipe the row.+ const startsInHorizontalScroller = (+ target: Element,+ boundary: Element+ ): boolean => {+ let el: Element | null = target;+ while (el && el !== boundary) {+ if (+ el.scrollWidth > el.clientWidth &&+ /auto|scroll/.test(getComputedStyle(el).overflowX)+ ) {+ return true;+ }+ el = el.parentElement;+ }+ return false;};const onTouchStart = (e: TouchEvent) => {@@ -241,11 +279,13 @@ export function EntityRowProvider(const swipeEl = target.closest('[data-swipe-surface]');if (!(swipeEl instanceof HTMLDivElement)) return;+ if (startsInHorizontalScroller(target, swipeEl)) return;+const rowEl = swipeEl.closest('[data-swipe-row]');if (!(rowEl instanceof HTMLDivElement)) return;- const entityId = rowEl.dataset.swipeEntityId;- if (!entityId) return;+ const id = rowEl.dataset.swipeId;+ if (!id) return;const contentEl = swipeEl.querySelector('[data-swipe-content]');if (!(contentEl instanceof HTMLDivElement)) return;@@ -253,11 +293,11 @@ export function EntityRowProvider(const leftRevealEl = rowEl.querySelector('[data-left-reveal]');const rightRevealEl = rowEl.querySelector('[data-right-reveal]');- const allowRight = canSwipeRight(entityId);- const allowLeft = canSwipeLeft(entityId);+ const allowRight = canSwipeRight(id);+ const allowLeft = canSwipeLeft(id);if (!allowRight && !allowLeft) return;- const phase = stateById()[entityId]?.phase ?? 'idle';+ const phase = stateById()[id]?.phase ?? 'idle';if (phase === 'triggered' || phase === 'collapsing') return;const touch = e.touches[0];@@ -271,7 +311,7 @@ export function EntityRowProvider(currentX: touch.clientX,currentY: touch.clientY,isSwipeGesture: null,- entityId,+ id: id,elements: {rowEl,swipeEl,@@ -283,8 +323,8 @@ export function EntityRowProvider(};const onTouchMove = (e: TouchEvent) => {- if (!touchState.elements || !touchState.entityId) return;- if (isAtLeastPhase(stateById()[touchState.entityId]?.phase, 'triggered')) {+ if (!touchState.elements || !touchState.id) return;+ if (isAtLeastPhase(stateById()[touchState.id]?.phase, 'triggered')) {return;}@@ -306,8 +346,8 @@ export function EntityRowProvider(touchState.currentX = touch.clientX;- const allowRight = canSwipeRight(touchState.entityId);- const allowLeft = canSwipeLeft(touchState.entityId);+ const allowRight = canSwipeRight(touchState.id);+ const allowLeft = canSwipeLeft(touchState.id);// Constrain dx based on available callbackslet constrainedDx = dx;@@ -325,7 +365,7 @@ export function EntityRowProvider(});// set activation state- const phase = stateById()[touchState.entityId]?.phase ?? 'idle';+ const phase = stateById()[touchState.id]?.phase ?? 'idle';const thesholdCrossed =(allowRight && dx > SWIPE_ACTIVATION_DISTANCE) ||(allowLeft && dx < -SWIPE_ACTIVATION_DISTANCE);@@ -333,7 +373,7 @@ export function EntityRowProvider(if (thesholdCrossed) {if (phase !== 'threshold') {hapticImpact('light');- setState(touchState.entityId, {+ setState(touchState.id, {direction: dx > 0 ? 'right' : 'left',phase: 'threshold',});@@ -343,7 +383,7 @@ export function EntityRowProvider(if (phase === 'threshold') {hapticImpact('light');}- setState(touchState.entityId, {+ setState(touchState.id, {direction: dx > 0 ? 'right' : 'left',phase: 'dragging',});@@ -353,33 +393,29 @@ export function EntityRowProvider(// Auto-activate swipe if threshold is reachedconst containerWidth = touchState.elements.swipeEl.clientWidth;if (allowRight && dx > containerWidth * AUTO_ACTIVATION_PERCENTAGE) {- handleSwipe(touchState.entityId);+ handleSwipe(touchState.id);} else if (allowLeft &&dx < -containerWidth * AUTO_ACTIVATION_PERCENTAGE) {- handleSwipe(touchState.entityId);+ handleSwipe(touchState.id);}}};const onTouchEnd = (_e: TouchEvent) => {- if (- !touchState.elements ||- !touchState.entityId ||- !touchState.isSwipeGesture- ) {+ if (!touchState.elements || !touchState.id || !touchState.isSwipeGesture) {resetTouchState();return;}- if (isAtLeastPhase(stateById()[touchState.entityId]?.phase, 'triggered')) {+ if (isAtLeastPhase(stateById()[touchState.id]?.phase, 'triggered')) {resetTouchState();return;}const deltaX = touchState.currentX - touchState.startX;- const entityId = touchState.entityId;+ const entityId = touchState.id;const allowRight = canSwipeRight(entityId);const allowLeft = canSwipeLeft(entityId);@@ -419,71 +455,90 @@ export function EntityRowProvider(});});- const ctx: EntityRowContextValue = {- stateFor: (entityId) =>- stateById()[entityId] ?? { phase: 'idle', direction: null },- clearState: (entityId) => clearState(entityId),- collapseEntity,- registerRowHandler: (entityId, handlers) => {- customRowSwipeHandlers.set(entityId, handlers);+ const ctx: SwipableRowContextValue = {+ stateFor: (id) => stateById()[id] ?? { phase: 'idle', direction: null },+ clearState: (id) => clearState(id),+ collapseRow: collapseRow,+ registerRowHandler: (id, handlers) => {+ customRowSwipeHandlers.set(id, handlers);},- unregisterRowHandler: (entityId) => {- customRowSwipeHandlers.delete(entityId);+ unregisterRowHandler: (id) => {+ customRowSwipeHandlers.delete(id);},};return (- <EntityRowContext.Provider value={ctx}>+ <SwipableRowContext.Provider value={ctx}>{props.children}- </EntityRowContext.Provider>+ </SwipableRowContext.Provider>);}/*** Container for swipe gesture capabilities on touch devices.*/-export function EntityRow(+export function SwipableRow(props: ParentProps<{- entityId: string;+ id: string;+ /** Applied to the root row so callers can scope styles to data-swipe-* attributes. */+ class?: string;swipeRightRevealedComponent?: JSX.Element;swipeLeftRevealedComponent?: JSX.Element;swipeLeftColor?: string;swipeRightColor?: string;+ /**+ * Background class of the sliding content. Defaults to an opaque panel+ * background so the revealed layer stays hidden at rest. Pass+ * 'bg-transparent' when the row must not paint over decorations behind+ * it (e.g. thread rails); the reveal components then have to manage+ * their own visibility, since nothing covers them at rest.+ */+ rowBgClass?: string;onSwipeLeft?: () => void;onSwipeRight?: () => void;}>) {- const ctx = useContext(EntityRowContext);+ const ctx = useContext(SwipableRowContext);if (!ctx) {- throw new Error('EntityRow must be used within EntityRowProvider');+ throw new Error('SwipableRow must be used within SwipableRowProvider');}- const rowState = createMemo(() => ctx.stateFor(props.entityId));+ const rowState = createMemo(() => ctx.stateFor(props.id));createEffect(() => {- const { onSwipeLeft, onSwipeRight, entityId } = props;+ const { onSwipeLeft, onSwipeRight, id: entityId } = props;if (!onSwipeLeft && !onSwipeRight) return;ctx.registerRowHandler(entityId, { onSwipeLeft, onSwipeRight });onCleanup(() => ctx.unregisterRowHandler(entityId));});onCleanup(() => {- ctx.clearState(props.entityId);+ ctx.clearState(props.id);});+ const swipePhase = () => rowState().phase;+ const swipeDirection = () => rowState().direction;+ const isSwipeInteracting = () => isAtLeastPhase(swipePhase(), 'dragging');+return (<divdata-swipe-row- data-swipe-entity-id={props.entityId}- class="grow w-full grid grid-cols-1 relative overflow-hidden transition-[grid-template-rows] duration-250 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'),- }}+ data-swipe-id={props.id}+ data-swipe-phase={swipePhase()}+ data-swipe-direction={swipeDirection() ?? undefined}+ data-swipe-interacting={isSwipeInteracting() ? '' : undefined}+ class={cn(+ 'grow w-full grid grid-cols-1 relative overflow-hidden transition-[grid-template-rows] duration-250 ease-in-out',+ props.class,+ {+ 'bg-transparent': swipePhase() === 'idle',+ [props.swipeLeftColor ?? 'bg-edge-muted']:+ swipeDirection() === 'left',+ [props.swipeRightColor ?? 'bg-edge']: swipeDirection() === 'right',+ 'grid-rows-[0fr]': isAtLeastPhase(swipePhase(), 'collapsing'),+ 'grid-rows-[1fr]': !isAtLeastPhase(swipePhase(), 'collapsing'),+ }+ )}>{/* Swipe Right Revealed Component */}<div@@ -495,11 +550,10 @@ export function EntityRow(><divdata-left-reveal- class="transition-transform duration-300 ease-in-out"- classList={{- 'scale-50': !isAtLeastPhase(rowState()?.phase, 'threshold'),- 'scale-100': isAtLeastPhase(rowState()?.phase, 'threshold'),- }}+ class={cn('transition-transform duration-300 ease-in-out', {+ 'scale-50': !isAtLeastPhase(swipePhase(), 'threshold'),+ 'scale-100': isAtLeastPhase(swipePhase(), 'threshold'),+ })}>{props.swipeRightRevealedComponent}</div>@@ -515,11 +569,10 @@ export function EntityRow(><divdata-right-reveal- class="transition-transform duration-300 ease-in-out"- classList={{- 'scale-50': !isAtLeastPhase(rowState()?.phase, 'threshold'),- 'scale-100': isAtLeastPhase(rowState()?.phase, 'threshold'),- }}+ class={cn('transition-transform duration-300 ease-in-out', {+ 'scale-50': !isAtLeastPhase(swipePhase(), 'threshold'),+ 'scale-100': isAtLeastPhase(swipePhase(), 'threshold'),+ })}>{props.swipeLeftRevealedComponent}</div>@@ -533,7 +586,10 @@ export function EntityRow({/* Swipe Content */}<divdata-swipe-content- class="size-full min-h-0 overflow-hidden flex items-center p-0 bg-panel"+ class={cn(+ 'size-full min-h-0 overflow-hidden flex items-center p-0',+ props.rowBgClass ?? 'bg-panel'+ )}>{props.children}</div>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 cf10c786b8..6870c456e9 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@@ -3,9 +3,9 @@ import {useGlobalBlockOrchestrator,useGlobalNotificationSource,} from '@app/component/GlobalAppState';-import { EntityRowProvider } from '@app/component/mobile/EntityRow';import { FloatRegion } from '@app/component/mobile/float-regions/FloatRegion';import { PullToRefresh } from '@app/component/mobile/PullToRefresh';+import { SwipableRowProvider } from '@app/component/mobile/SwipableRow';import {makeMarkDoneAction,useEntityActionHotkeys,@@ -1357,7 +1357,7 @@ export const SoupViewList = (props: SoupViewListProps) => {><ResponsiveCompanyListHeader class="shrink-0" /></Show>- <EntityRowProvider+ <SwipableRowProvidercontainer={localEntityListRef}canSwipeLeft={(entityId) => {const entity = entityById().get(entityId);@@ -1629,7 +1629,7 @@ export const SoupViewList = (props: SoupViewListProps) => {);}}</SoupList>- </EntityRowProvider>+ </SwipableRowProvider></ListLayoutProvider><Show when={!props.customScrollbarHidden}>diff --git a/js/app/packages/app/component/next-soup/soup-view/views/companies/CompanyListEntity.tsx b/js/app/packages/app/component/next-soup/soup-view/views/companies/CompanyListEntity.tsxindex edac328d92..ba0f96307f 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/companies/CompanyListEntity.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/companies/CompanyListEntity.tsx@@ -1,5 +1,8 @@import '@entity/composed/ListEntity.css';-import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';+import {+ SwipableRow,+ SwipableRowContext,+} from '@app/component/mobile/SwipableRow';import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { isMobile } from '@core/mobile/isMobile';import { isTouchDevice } from '@core/mobile/isTouchDevice';@@ -21,18 +24,18 @@ function MaybeEntityRow(props: {children: JSX.Element;config?: EntityRowConfig;}) {- const ctx = useContext(EntityRowContext);+ const ctx = useContext(SwipableRowContext);return (<Show when={isMobile() && ctx} fallback={props.children}>- <EntityRow- entityId={props.entityId}+ <SwipableRow+ id={props.entityId}swipeLeftColor={props.config?.swipeLeftColor}swipeLeftRevealedComponent={props.config?.swipeLeftRevealedComponent}swipeRightColor={props.config?.swipeRightColor}swipeRightRevealedComponent={props.config?.swipeRightRevealedComponent}>{props.children}- </EntityRow>+ </SwipableRow></Show>);}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 4a65b26a2e..67f9f9ca4d 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@@ -1,5 +1,8 @@import '@entity/composed/ListEntity.css';-import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';+import {+ SwipableRow,+ SwipableRowContext,+} from '@app/component/mobile/SwipableRow';import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { isMobile } from '@core/mobile/isMobile';@@ -53,18 +56,18 @@ function MaybeEntityRow(props: {children: JSX.Element;config?: EntityRowConfig;}) {- const ctx = useContext(EntityRowContext);+ const ctx = useContext(SwipableRowContext);return (<Show when={isMobile() && ctx} fallback={props.children}>- <EntityRow- entityId={props.entityId}+ <SwipableRow+ id={props.entityId}swipeLeftColor={props.config?.swipeLeftColor}swipeLeftRevealedComponent={props.config?.swipeLeftRevealedComponent}swipeRightColor={props.config?.swipeRightColor}swipeRightRevealedComponent={props.config?.swipeRightRevealedComponent}>{props.children}- </EntityRow>+ </SwipableRow></Show>);}diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex b5c58a515a..21e01f1779 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -627,27 +627,28 @@ html:not([data-touch-device="true"]) [data-message]:hover{html:not([data-touch-device="true"]) [data-message][data-targeted]:hover{@apply bg-accent/40 rounded-sm;}-/*[data-message][data-targeted] > .message-accent-bar {- opacity: 1;-}*/@keyframes long-press-message-highlight {from {- background-color: oklch(from var(--color-ink) l c h / 0%);+ background-color: oklch(from var(--color-active) l c h / 0%);border-radius: var(--radius-sm);}to {- background-color: oklch(from var(--color-ink) l c h / 10%);+ background-color: oklch(from var(--color-active) l c h);border-radius: var(--radius-sm);}}/* Channel message long-press animation */.channel-message-long-press-highlight [data-swipe-content],-[data-message].channel-message-long-press-highlight{+[data-message].channel-message-long-press-highlight {animation: long-press-message-highlight 400ms ease-in both;}+.channel-message-swipe-to-reply-row[data-swipe-interacting] [data-swipe-content] {+ animation: long-press-message-highlight 100ms 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 {diff --git a/js/app/packages/channel/Channel/Channel.tsx b/js/app/packages/channel/Channel/Channel.tsxindex 7df8c5dfe9..9a4b57e5e7 100644--- a/js/app/packages/channel/Channel/Channel.tsx+++ b/js/app/packages/channel/Channel/Channel.tsx@@ -52,6 +52,7 @@ import {import { usePostTypingUpdateMutation } from '@queries/channel/typing';import { queryClient } from '@queries/client';import { useBeforeLeave } from '@solidjs/router';+import { SwipableRowProvider } from 'app/component/mobile/SwipableRow';import {type Accessor,createEffect,@@ -164,6 +165,9 @@ export function Channel(props: ChannelProps) {createSignal<ThreadListNavigation>();const [threadListScrollState, setThreadListScrollState] =createSignal<ThreadListScrollState>();+ // Hosts the swipe-to-reply gesture listeners (mobile).+ const [threadListContainerEl, setThreadListContainerEl] =+ createSignal<HTMLElement>();// When opening without a target, clear stale data that was previously// restored from a load-around session so the query fetches from the bottom.@@ -590,81 +594,91 @@ export function Channel(props: ChannelProps) {/></Show><Show when={messages().length > 0}>- <div class="relative flex-1 min-h-0">- <ThreadList- keys={() => messageIndex.keys}- initialScrollTarget={threadListInitialScrollTarget()}- fullFrameScrollInsets={threadListScrollInsets}- shift={shift}- prepend={threadPaginator.isPrepending}- onScrollNearTop={threadPaginator.shiftPaginate}- onScrollNearBottom={threadPaginator.prependPaginate}- onNavigationReady={setThreadListNavigation}- onScrollStateChange={setThreadListScrollState}- initialScrollSnapshot={- props.targetMessageId- ? undefined- : props.initialMessagesStateSnapshot?.scroll- }- onScrollSnapshotChange={setThreadListScrollSnapshot}+ <div+ class="relative flex-1 min-h-0"+ ref={setThreadListContainerEl}+ >+ <SwipableRowProvider+ container={threadListContainerEl}+ triggerBehavior="spring-back">- {(item) => {- const message = () => messageById().get(item.id);- const state = threadManager.getOrCreateThreadState(- item.id- );- const isNewestThread = () =>- item.id === messageIndex.keys.at(-1);-- return (- <Show when={message()}>- {(m) => (- <ChannelThread- data={m}- channelId={() => props.channelId}- isNewestThread={isNewestThread()}- getMessageActions={getMessageActions}- targetThreadId={targetMessageController.activeTargetMessageId()}- targetReplyId={targetMessageController.pendingTargetReplyId()}- activeTargetReplyId={targetMessageController.activeTargetMessageReplyId()}- unifiedReplyTarget={unifiedInput.replyTarget()}- onTargetReplyScrolled={(replyId) => {- targetMessageController.completePendingReplyScroll(- m().id,- replyId- );- }}- isExpanded={state.isExpanded}- setIsExpanded={state.setIsExpanded}- isReplying={state.isReplying}- setIsReplying={state.setIsReplying}- replyInputState={state.replyInputState}- setReplyInputState={state.setReplyInputState}- setReplyInputEl={state.setReplyInputEl}- replyInputHandle={state.replyInputHandle}- setReplyInputHandle={state.setReplyInputHandle}- replyInputFocusRequest={- state.replyInputFocusRequest- }- listMeta={listMetaByMessageId()[item.id]}- messageEditor={messageEditor}- participants={participants.users}- threadActions={{- onDismissNewMessages:- activityTracker.dismissNewMessages,- }}- isNewMessage={activityTracker.isNewMessage}- selectedMessageId={selection.selectedId}- onSelectMessage={selectMessage}- onClearSelection={clearSelection}- onClearTarget={releaseSelectionAndTarget}- messageListScopeId={messageListScopeId}- />- )}- </Show>- );- }}- </ThreadList>+ <ThreadList+ keys={() => messageIndex.keys}+ initialScrollTarget={threadListInitialScrollTarget()}+ fullFrameScrollInsets={threadListScrollInsets}+ shift={shift}+ prepend={threadPaginator.isPrepending}+ onScrollNearTop={threadPaginator.shiftPaginate}+ onScrollNearBottom={threadPaginator.prependPaginate}+ onNavigationReady={setThreadListNavigation}+ onScrollStateChange={setThreadListScrollState}+ initialScrollSnapshot={+ props.targetMessageId+ ? undefined+ : props.initialMessagesStateSnapshot?.scroll+ }+ onScrollSnapshotChange={setThreadListScrollSnapshot}+ >+ {(item) => {+ const message = () => messageById().get(item.id);+ const state = threadManager.getOrCreateThreadState(+ item.id+ );+ const isNewestThread = () =>+ item.id === messageIndex.keys.at(-1);++ return (+ <Show when={message()}>+ {(m) => (+ <ChannelThread+ data={m}+ channelId={() => props.channelId}+ isNewestThread={isNewestThread()}+ getMessageActions={getMessageActions}+ targetThreadId={targetMessageController.activeTargetMessageId()}+ targetReplyId={targetMessageController.pendingTargetReplyId()}+ activeTargetReplyId={targetMessageController.activeTargetMessageReplyId()}+ unifiedReplyTarget={unifiedInput.replyTarget()}+ onTargetReplyScrolled={(replyId) => {+ targetMessageController.completePendingReplyScroll(+ m().id,+ replyId+ );+ }}+ isExpanded={state.isExpanded}+ setIsExpanded={state.setIsExpanded}+ isReplying={state.isReplying}+ setIsReplying={state.setIsReplying}+ replyInputState={state.replyInputState}+ setReplyInputState={state.setReplyInputState}+ setReplyInputEl={state.setReplyInputEl}+ replyInputHandle={state.replyInputHandle}+ setReplyInputHandle={+ state.setReplyInputHandle+ }+ replyInputFocusRequest={+ state.replyInputFocusRequest+ }+ listMeta={listMetaByMessageId()[item.id]}+ messageEditor={messageEditor}+ participants={participants.users}+ threadActions={{+ onDismissNewMessages:+ activityTracker.dismissNewMessages,+ }}+ isNewMessage={activityTracker.isNewMessage}+ selectedMessageId={selection.selectedId}+ onSelectMessage={selectMessage}+ onClearSelection={clearSelection}+ onClearTarget={releaseSelectionAndTarget}+ messageListScopeId={messageListScopeId}+ />+ )}+ </Show>+ );+ }}+ </ThreadList>+ </SwipableRowProvider><Show when={!findBar.isOpen()}><ScrollToBottomOverlayscrollState={threadListScrollState}diff --git a/js/app/packages/channel/Message/ChannelMessage.tsx b/js/app/packages/channel/Message/ChannelMessage.tsxindex 7253a0ebc6..ed9ccd47c0 100644--- a/js/app/packages/channel/Message/ChannelMessage.tsx+++ b/js/app/packages/channel/Message/ChannelMessage.tsx@@ -11,6 +11,7 @@ import { isUnifiedInputMode } from '../unified-input-mode';import { useMessage } from './context';import type { ChannelMessageListMeta } from './list-meta';import { Message } from './Message';+import { MaybeSwipeToReplyRow } from './SwipeToReplyRow';import type { MessageActions, MessageData } from './types';type ChannelMessageProps = {@@ -199,46 +200,50 @@ export function ChannelMessage(props: ChannelMessageProps) {const isGrouped = () => props.listMeta?.isGroupedWithPrevious === true;return (- <Message.Root- message={props.message}- actions={props.actions}- selected={props.selected}- targeted={- props.targeted ||- // In unified-input mode the edit happens in the floating input; the- // accent bar marks the message it is bound to.- (isUnifiedInputMode() &&- isEditingMessage(props.messageEditor, props.message.id))- }- onClick={props.onClick}- ref={(el) =>- touchHandler(el, () => ({- touchClassName: 'channel-message-long-press-highlight',- // Yield to the native image callout when long-pressing an image.- skipSelectors: ['img'],- onLongPress: () => drawerManager?.open(props.message, props.actions),- }))- }- >- <Switch>- <Match when={props.message.deleted_at != null}>- <DeletedMessageLayout />- </Match>- <Match when={isGrouped()}>- <GroupedMessageLayout- channelId={props.channelId}- messageEditor={props.messageEditor}- participants={props.participants}- />- </Match>- <Match when={true}>- <RegularMessageLayout- channelId={props.channelId}- messageEditor={props.messageEditor}- participants={props.participants}- />- </Match>- </Switch>- </Message.Root>+ <MaybeSwipeToReplyRow message={props.message} actions={props.actions}>+ <Message.Root+ class="w-full"+ message={props.message}+ actions={props.actions}+ selected={props.selected}+ targeted={+ props.targeted ||+ // In unified-input mode the edit happens in the floating input; the+ // accent bar marks the message it is bound to.+ (isUnifiedInputMode() &&+ isEditingMessage(props.messageEditor, props.message.id))+ }+ onClick={props.onClick}+ ref={(el) =>+ touchHandler(el, () => ({+ touchClassName: 'channel-message-long-press-highlight',+ // Yield to the native image callout when long-pressing an image.+ skipSelectors: ['img'],+ onLongPress: () =>+ drawerManager?.open(props.message, props.actions),+ }))+ }+ >+ <Switch>+ <Match when={props.message.deleted_at != null}>+ <DeletedMessageLayout />+ </Match>+ <Match when={isGrouped()}>+ <GroupedMessageLayout+ channelId={props.channelId}+ messageEditor={props.messageEditor}+ participants={props.participants}+ />+ </Match>+ <Match when={true}>+ <RegularMessageLayout+ channelId={props.channelId}+ messageEditor={props.messageEditor}+ participants={props.participants}+ />+ </Match>+ </Switch>+ </Message.Root>+ </MaybeSwipeToReplyRow>);}diff --git a/js/app/packages/channel/Message/SwipeToReplyRow.tsx b/js/app/packages/channel/Message/SwipeToReplyRow.tsxnew file mode 100644index 0000000000..140e2f1f96--- /dev/null+++ b/js/app/packages/channel/Message/SwipeToReplyRow.tsx@@ -0,0 +1,80 @@+import { triggerFocusInput } from '@core/directive/focusInput';+import { isMobile } from '@core/mobile/isMobile';+import ReplyIcon from '@phosphor/arrow-bend-up-left.svg';+import {+ SwipableRow,+ SwipableRowContext,+} from 'app/component/mobile/SwipableRow';+import { type ParentProps, Show, useContext } from 'solid-js';+import type { MessageActions, MessageData } from './types';++/**+ * The affordance revealed behind a message while it is being swiped. The+ * swipe content is transparent (so thread rails stay visible at rest), so+ * the badge manages its own visibility: hidden until the swipe crosses the+ * activation threshold, fading back out once the swipe triggers.+ */+function SwipeReplyBadge(props: { messageId: string }) {+ const ctx = useContext(SwipableRowContext);+ const revealed = () => ctx?.stateFor(props.messageId)?.phase === 'threshold';++ return (+ <div+ class="size-9 rounded-full bg-accent text-panel flex items-center justify-center transition-opacity duration-150"+ classList={{ 'opacity-0': !revealed() }}+ >+ <ReplyIcon class="size-5" aria-hidden="true" />+ </div>+ );+}++/**+ * On mobile, wraps a channel message so swiping it left reveals a reply+ * affordance and opens the reply input for its thread. Renders children+ * as-is when there is no surrounding `EntityRowProvider` (desktop,+ * standalone threads) or the message cannot be replied to.+ */+export function MaybeSwipeToReplyRow(+ props: ParentProps<{ message: MessageData; actions?: MessageActions }>+) {+ const ctx = useContext(SwipableRowContext);++ const reply = () => {+ const onReply = props.actions?.onReply;+ if (!onReply) return;+ // Reply inputs are keyed by the thread root, not the swiped message.+ const threadId = props.message.thread_id ?? props.message.id;+ // Called synchronously inside the touch gesture so iOS opens the+ // keyboard once the reply input mounts.+ triggerFocusInput(() =>+ document.querySelector<HTMLElement>(+ `[data-input-id="thread-reply-input-${threadId}"] [contenteditable]`+ )+ );+ void onReply({ message: props.message });+ };++ return (+ <Show+ when={isMobile() && ctx && props.actions?.onReply}+ fallback={props.children}+ >+ <SwipableRow+ id={props.message.id}+ class="channel-message-swipe-to-reply-row"+ onSwipeLeft={reply}+ // Transparent throughout: decorations behind the row (thread rails)+ // must stay visible, and the rubber-banded right direction must not+ // tint the row. The badge alone signals the pending action.+ swipeLeftColor="bg-transparent"+ swipeRightColor="bg-transparent"+ rowBgClass="bg-transparent"+ swipeLeftRevealedComponent={+ <SwipeReplyBadge messageId={props.message.id} />+ }+ >+ {props.children}+ </SwipableRow>+ </Show>+ );+}diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsxindex f828dfbe4f..f1244d17c2 100644--- a/js/app/packages/entity/src/composed/ListEntity.tsx+++ b/js/app/packages/entity/src/composed/ListEntity.tsx@@ -1,5 +1,4 @@import './ListEntity.css';-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';@@ -16,6 +15,10 @@ import {} from '@service-connection/stream-events';import { mergeRefs } from '@solid-primitives/refs';import { cn } from '@ui';+import {+ SwipableRow,+ SwipableRowContext,+} from 'app/component/mobile/SwipableRow';import {createEffect,createMemo,@@ -65,18 +68,18 @@ export function MaybeEntityRow(props: {children: JSX.Element;config?: EntityRowConfig;}) {- const ctx = useContext(EntityRowContext);+ const ctx = useContext(SwipableRowContext);return (<Show when={isMobile() && ctx} fallback={props.children}>- <EntityRow- entityId={props.entityId}+ <SwipableRow+ id={props.entityId}swipeLeftColor={props.config?.swipeLeftColor}swipeLeftRevealedComponent={props.config?.swipeLeftRevealedComponent}swipeRightColor={props.config?.swipeRightColor}swipeRightRevealedComponent={props.config?.swipeRightRevealedComponent}>{props.children}- </EntityRow>+ </SwipableRow></Show>);}diff --git a/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsx b/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsxindex fa5aaa77ff..6f9827ecb0 100644--- a/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsx+++ b/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsx@@ -1,5 +1,4 @@import { useGlobalNotificationSource } from '@app/component/GlobalAppState';-import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';import { globalSplitManager } from '@app/signal/splitLayout';import {getMostRecentNotification,@@ -7,6 +6,10 @@ import {openNotification,} from '@notifications';import { cn } from '@ui';+import {+ SwipableRow,+ SwipableRowContext,+} from 'app/component/mobile/SwipableRow';import { createEffect, type JSX, useContext } from 'solid-js';import { createStore, reconcile } from 'solid-js/store';import { CollapsibleList } from '../components/CollapsibleList';@@ -91,7 +94,7 @@ function MobileStackRow(props: {entity: WithNotification<EntityData>;entityRowConfig?: EntityRowConfig;}) {- const ctx = useContext(EntityRowContext);+ const ctx = useContext(SwipableRowContext);const notificationSource = useGlobalNotificationSource();const { markStackAsDone } = useNotificationStackActions({stack: props.stack,@@ -101,7 +104,7 @@ function MobileStackRow(props: {const unread = () => isNotificationUnread(props.stack);const handleSwipeLeft = async () => {- await ctx?.collapseEntity(stackEntityId());+ await ctx?.collapseRow(stackEntityId());markStackAsDone();};@@ -136,8 +139,8 @@ function MobileStackRow(props: {}return (- <EntityRow- entityId={stackEntityId()}+ <SwipableRow+ id={stackEntityId()}onSwipeLeft={handleSwipeLeft}swipeLeftColor={props.entityRowConfig?.swipeLeftColor}swipeLeftRevealedComponent={@@ -154,7 +157,7 @@ function MobileStackRow(props: {unread={unread()}onClick={handleClick}/>- </EntityRow>+ </SwipableRow>);}