Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix[channels]: Jump to Latest behavior (#1414)

Peter Chinmana34d955e2d14
diff --git a/js/app/packages/block-channel/component/MessageList/MessageList.tsx b/js/app/packages/block-channel/component/MessageList/MessageList.tsx
index 81da86dc04..107044ff1a 100644
--- a/js/app/packages/block-channel/component/MessageList/MessageList.tsx
+++ b/js/app/packages/block-channel/component/MessageList/MessageList.tsx
@@ -374,6 +374,11 @@ function MessageListImpl(props: MessageListProps) {
const [isNearBottom, setIsNearBottom] = createSignal(true);
const [initialScrollComplete, setInitialScrollComplete] = createSignal(false);
+ const [isScrolledBackSignificantly, setIsScrolledBackSignificantly] =
+ createSignal(false);
+ const [isScrollingDown, setIsScrollingDown] = createSignal(false);
+ let prevScrollOffset: number | undefined;
+ let downwardScrollAccumulator = 0;
// Navigation methods for keyboard navigation
const navigateToMessage = (messageId: string): boolean => {
@@ -709,6 +714,36 @@ function MessageListImpl(props: MessageListProps) {
return distanceFromBottom <= THRESHOLD;
};
+ const checkIfScrolledBackSignificantly = () => {
+ const handle = virtualHandle();
+ if (!handle) return false;
+ const THRESHOLD = 2000;
+ return handle.scrollOffset > THRESHOLD;
+ };
+
+ // Track scroll direction.
+ // Requires 100px of cumulative downward scrolling before triggering.
+ // Any upward scroll resets the accumulator immediately.
+ const updateScrollDirection = () => {
+ const handle = virtualHandle();
+ if (handle && prevScrollOffset !== undefined) {
+ const currentOffset = handle.scrollOffset;
+ const delta = prevScrollOffset - currentOffset; // positive = scrolling down
+ if (delta > 0) {
+ downwardScrollAccumulator += delta;
+ if (downwardScrollAccumulator >= 100) {
+ setIsScrollingDown(true);
+ }
+ } else if (delta < 0) {
+ downwardScrollAccumulator = 0;
+ setIsScrollingDown(false);
+ }
+ }
+ if (handle) {
+ prevScrollOffset = handle.scrollOffset;
+ }
+ };
+
const lastMessageReaction = createMemo(() => {
const list = props.orderedMessages();
const lastMessageId = list[list.length - 1]?.id;
@@ -807,6 +842,9 @@ function MessageListImpl(props: MessageListProps) {
const nearBottom = checkIfNearBottom();
setIsNearBottom(nearBottom);
+ setIsScrolledBackSignificantly(checkIfScrolledBackSignificantly());
+ updateScrollDirection();
+
if (!nearBottom && dismissJumpToLatest()) {
setDismissJumpToLatest(false);
}
@@ -1021,7 +1059,8 @@ function MessageListImpl(props: MessageListProps) {
initialScrollComplete() &&
!dismissJumpToLatest() &&
!showJumpToUnviewedMessages() &&
- !isNearBottom()
+ isScrolledBackSignificantly() &&
+ isScrollingDown()
}
>
<DeprecatedTextButton