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(channels): add touch jump-to-latest button above the composer (#8773)
teo58284b42197c
diff --git a/apps/web/src/features/block-agent/component/Transcript.test.tsx b/apps/web/src/features/block-agent/component/Transcript.test.tsxindex 01fb65f0a5..90e8b11d95 100644--- a/apps/web/src/features/block-agent/component/Transcript.test.tsx+++ b/apps/web/src/features/block-agent/component/Transcript.test.tsx@@ -517,4 +517,18 @@ describe('Transcript with the shared TanStack ThreadList', () => {await settle();expect(view.scroller.scrollTop).toBe(view.scroller.scrollHeight - viewport);});++ it('keeps the touch jump button visible while scrolling up and jumps to latest on tap', async () => {+ session.touch = true;+ const view = mount(Array.from({ length: 50 }, (_, i) => message(i)));+ await settle();+ expect(view.queryByLabelText('Jump to latest')).toBeNull();+ view.scroller.dispatchEvent(new WheelEvent('wheel', { deltaY: -600 }));+ view.scroller.scrollTo({ top: 500 });+ await settle();+ view.getByLabelText('Jump to latest').click();+ await settle();+ expect(view.scroller.scrollTop).toBe(view.scroller.scrollHeight - viewport);+ expect(view.queryByLabelText('Jump to latest')).toBeNull();+ });});diff --git a/apps/web/src/features/block-agent/component/Transcript.tsx b/apps/web/src/features/block-agent/component/Transcript.tsxindex df63971295..b084259698 100644--- a/apps/web/src/features/block-agent/component/Transcript.tsx+++ b/apps/web/src/features/block-agent/component/Transcript.tsx@@ -202,11 +202,10 @@ export function Transcript(props: { searchTarget?: AgentMessageTarget }) {</ThreadList><ScrollToBottomOverlayscrollState={scrollState}- onScrollToBottom={() => {+ onScrollToBottom={(behavior) => {setHighlightedId(undefined);- navigation()?.scrollToLatest();+ navigation()?.scrollToLatest(behavior);}}- class="touch:top-[calc(var(--mobile-content-inset-top,0)+1rem)]"/><ReplyToSelection container={transcriptEl()} onReply={quoteSelection} /></div>diff --git a/apps/web/src/features/channel/Channel/Channel.tsx b/apps/web/src/features/channel/Channel/Channel.tsxindex 1fe582cf3e..5326b6bb63 100644--- a/apps/web/src/features/channel/Channel/Channel.tsx+++ b/apps/web/src/features/channel/Channel/Channel.tsx@@ -172,7 +172,7 @@ export type MessageTimelineStateSnapshot = {export type ChannelHandle = {goToMessage: TargetMessageController['goToMessage'];- goToLatest: () => void;+ goToLatest: (behavior?: ScrollBehavior) => void;getMessagesStateSnapshot: () => MessageTimelineStateSnapshot | undefined;};@@ -581,7 +581,9 @@ export function Channel(props: ChannelProps) {// A latest request waits for both the query and the rendered list. Keeping// its identity prevents a late response from overriding newer navigation.- let pendingLatest: { phase: 'loading' | 'waiting-for-layout' } | undefined;+ let pendingLatest:+ | { phase: 'loading' | 'waiting-for-layout'; behavior?: ScrollBehavior }+ | undefined;const cancelLatestNavigation = () => {pendingLatest = undefined;};@@ -600,13 +602,16 @@ export function Channel(props: ChannelProps) {if (latestEntry !== undefined &&messageIndex.entryKeys.at(-1) === timelineEntryKey(latestEntry) &&- threadListNavigation()?.scrollToLatest()+ threadListNavigation()?.scrollToLatest(pendingLatest.behavior))cancelLatestNavigation();};- const goToLatest: ChannelHandle['goToLatest'] = async () => {- const request: NonNullable<typeof pendingLatest> = { phase: 'loading' };+ const goToLatest: ChannelHandle['goToLatest'] = async (behavior) => {+ const request: NonNullable<typeof pendingLatest> = {+ phase: 'loading',+ behavior,+ };pendingLatest = request;try {const needsLatestPage =@@ -993,7 +998,6 @@ export function Channel(props: ChannelProps) {<ScrollToBottomOverlayscrollState={threadListScrollState}onScrollToBottom={goToLatest}- class="touch:top-[calc(var(--mobile-content-inset-top,0)+1rem)]"/></Show></Show>diff --git a/apps/web/src/features/channel/Channel/ScrollToBottomOverlay.tsx b/apps/web/src/features/channel/Channel/ScrollToBottomOverlay.tsxindex 13e63fa1a6..bde68c7255 100644--- a/apps/web/src/features/channel/Channel/ScrollToBottomOverlay.tsx+++ b/apps/web/src/features/channel/Channel/ScrollToBottomOverlay.tsx@@ -1,41 +1,63 @@-import { cn, Layer } from '@ui';+import { FloatRegions } from '@components/app/mobile/float-regions/float-region-state';+import { MobileDockButton } from '@components/app/mobile/MobileDockButton';+import { MobileDockIsland } from '@components/app/mobile/MobileDockIsland';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import ArrowDown from '@phosphor-icons/core/regular/arrow-down.svg?component-solid';+import { Layer } from '@ui';import { type Accessor, Show } from 'solid-js';import type { ThreadListScrollState } from './ThreadList';export function shouldShowScrollToBottomButton(- state: ThreadListScrollState | undefined+ state: ThreadListScrollState | undefined,+ touch: boolean): boolean {- if (!state) return false;+ if (!state?.didInitialScroll || state.isNearBottom) return false;return (- state.didInitialScroll &&- !state.isNearBottom &&- state.isScrollingDown &&- state.distanceFromBottom > state.viewportSize+ touch ||+ (state.isScrollingDown && state.distanceFromBottom > state.viewportSize));}type ScrollToBottomOverlayProps = {scrollState: Accessor<ThreadListScrollState | undefined>;- onScrollToBottom: () => void;- class?: string;+ onScrollToBottom: (behavior?: ScrollBehavior) => void;};export function ScrollToBottomOverlay(props: ScrollToBottomOverlayProps) {return (- <Show when={shouldShowScrollToBottomButton(props.scrollState())}>+ <Show+ when={shouldShowScrollToBottomButton(+ props.scrollState(),+ isTouchDevice()+ )}+ ><Layer depth={3}>- <button- type="button"- class={cn(- 'absolute top-4 left-1/2 -translate-x-1/2 z-10 rounded-full px-3 py-1.5 text-xs bg-surface border border-edge-muted shadow-lg not-touch:hover:overlay-hover not-touch:active:overlay-active',- props.class- )}- onClick={() => {- props.onScrollToBottom();- }}+ <Show+ when={isTouchDevice()}+ fallback={+ <button+ type="button"+ class="absolute top-4 left-1/2 -translate-x-1/2 z-10 rounded-full px-3 py-1.5 text-xs bg-surface border border-edge-muted shadow-lg not-touch:hover:overlay-hover not-touch:active:overlay-active"+ onClick={() => {+ props.onScrollToBottom();+ }}+ >+ Scroll to bottom+ </button>+ }>- Scroll to bottom- </button>+ <MobileDockIsland+ class="absolute z-10 right-[calc(var(--safe-right,0px)+var(--mobile-chrome-gutter))]"+ style={{ bottom: `${FloatRegions.hostHeight() + 12}px` }}+ >+ <MobileDockButton+ icon={ArrowDown}+ ariaLabel="Jump to latest"+ data-keep-keyboard+ onClick={() => props.onScrollToBottom('smooth')}+ />+ </MobileDockIsland>+ </Show></Layer></Show>);diff --git a/apps/web/src/features/channel/Channel/ThreadList.tsx b/apps/web/src/features/channel/Channel/ThreadList.tsxindex 81b6ae7e44..69c948f826 100644--- a/apps/web/src/features/channel/Channel/ThreadList.tsx+++ b/apps/web/src/features/channel/Channel/ThreadList.tsx@@ -43,7 +43,7 @@ export type ThreadListInitialPosition =export type ThreadListNavigation = {/** Publish geometry after registered destinations finish mounting/unmounting. */requestLayoutUpdate: () => void;- scrollToLatest: () => boolean;+ scrollToLatest: (behavior?: ScrollBehavior) => boolean;scrollToMessage: (id: string,options?: { align?: ScrollAlignment; userIntent?: ScrollDirection }@@ -410,11 +410,11 @@ export function ThreadList(props: ThreadListProps) {const navigation: ThreadListNavigation = {requestLayoutUpdate: scheduleScrollState,- scrollToLatest: () => {+ scrollToLatest: (behavior) => {if (!canNavigate() || !props.keys().length) return false;lifecycle.send('navigate');scrollCompensation?.finish();- virtualizer.scrollToEnd();+ virtualizer.scrollToEnd({ behavior });scheduleScrollState();return true;},@@ -454,7 +454,12 @@ export function ThreadList(props: ThreadListProps) {// This microtask runs after synchronous row measurements, before paint.lifecycle.send('layout');const distanceFromTop = logicalScrollOffset(el.scrollTop);- const distanceFromBottom = virtualizer.getDistanceFromEnd();+ // The virtualizer's cached offset can trail scrollTop: this publish may run+ // in the microtask before its own scroll listener records the new position.+ const distanceFromBottom = Math.max(+ el.scrollHeight - el.clientHeight - distanceFromTop,+ 0+ );// WebKit cannot move the native top boundary during a fling without a// scroll write. Fill a bounded history buffer ahead of the next gesture,// including after initial positioning or navigation into older messages.diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.mdindex 0ac84b9834..f513521c79 100644--- a/docs/agent-guide/ai-chat.md+++ b/docs/agent-guide/ai-chat.md@@ -1683,7 +1683,9 @@ message highlight; incoming output does not repeat the search jump.- New messages and growing streamed replies follow while within 50px of the end.Scroll up to read history without being pulled back by subsequent output.- Far above the end, scroll downward to reveal **Scroll to bottom**. Clicking it- returns to latest and resumes following. The right-edge custom scrollbar is also+ returns to latest and resumes following. On touch devices the round **Jump to+ latest** button above the composer replaces it and shows whenever the transcript+ is away from the end. The right-edge custom scrollbar is alsodrag-seekable, like channels.- Select mounted transcript text to use **Reply to selection**. Streaming updatesretain message-row identity; scrolling a row outside the virtual window candiff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.mdindex 2bcef1f456..c87dee5218 100644--- a/docs/agent-guide/channels.md+++ b/docs/agent-guide/channels.md@@ -601,6 +601,9 @@ Returning through split navigation restores the saved message position and expanthreads. Switching channel tabs and returning restores the Messages position,expanded threads, and pending reply from when the tab was left. The `Scroll to bottom` control appears when scrolling down through history;it returns to the latest page even after opening a link into old history.+On touch devices a round **Jump to latest** button sits bottom-right above the+composer whenever the list is away from the bottom, in either scroll direction;+tapping it smooth-scrolls to latest and keeps the keyboard open.The jump waits for that page to reach the rendered list.A newer message navigation cancels a pending jump to latest. Scrolling manuallyor choosing another destination also cancels the initial target's delayed fallback.