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.

chg(new-channels): thread reply mounts (#2319)

teo35ff875506df
diff --git a/js/app/packages/channel/Thread/ChannelThread.tsx b/js/app/packages/channel/Thread/ChannelThread.tsx
index cd594463af..29dc261361 100644
--- a/js/app/packages/channel/Thread/ChannelThread.tsx
+++ b/js/app/packages/channel/Thread/ChannelThread.tsx
@@ -27,7 +27,11 @@ export function ChannelThread(props: ThreadProps) {
const [displayName] = useDisplayName(macroId());
const thread = () => props.data().thread;
const hasReplies = () => thread().reply_count > 0;
- const fetchRepliesEnabled = deferredGate(hasReplies, 300);
+ const debouncedFetchRepliesEnabled = deferredGate(hasReplies, 300);
+ // Targeted reply navigation needs the full reply list immediately so the
+ // thread can resolve the reply index and complete the scroll.
+ const fetchRepliesEnabled = () =>
+ !!props.targetReplyId || debouncedFetchRepliesEnabled();
const isSelected = () => props.selectedMessageId?.() === props.data().id;
@@ -121,10 +125,18 @@ export function ChannelThread(props: ThreadProps) {
() => props.targetReplyId,
canScrollToTargetReply,
loadedReplies,
+ displayReplies,
props.isExpanded,
replyListHandle,
],
- ([targetReplyId, canScroll, replies, isExpanded, handle]) => {
+ ([
+ targetReplyId,
+ canScroll,
+ replies,
+ renderedReplies,
+ isExpanded,
+ handle,
+ ]) => {
if (!targetReplyId) return;
if (!canScroll) return;
@@ -133,8 +145,17 @@ export function ChannelThread(props: ThreadProps) {
);
if (targetReplyIndex === -1) return;
- if (!isExpanded && targetReplyIndex >= DEFAULT_VISIBLE_REPLY_COUNT) {
- props.setIsExpanded(true);
+ if (!isExpanded) {
+ const renderedTargetReplyIndex = renderedReplies.findIndex(
+ (reply) => reply.id === targetReplyId
+ );
+ if (renderedTargetReplyIndex === -1) {
+ props.setIsExpanded(true);
+ return;
+ }
+
+ if (!handle?.scrollToIndex(renderedTargetReplyIndex)) return;
+ props.onTargetReplyScrolled?.(targetReplyId);
return;
}