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.

feat: improve email message scroll (#544)

gbirmanea4ed476893f
diff --git a/js/app/packages/block-channel/constants.ts b/js/app/packages/block-channel/constants.ts
index 9184611033..3052aad99a 100644
--- a/js/app/packages/block-channel/constants.ts
+++ b/js/app/packages/block-channel/constants.ts
@@ -1,5 +1,3 @@
-import { DEFAULT_ACTIVE_TARGET_TIME } from '@core/signal/activeTarget';
-
export const URL_PARAMS = {
thread: 'channel_thread_id',
message: 'channel_message_id',
@@ -9,4 +7,4 @@ export const URL_PARAMS = {
export const COLLAPSED_THREAD_INDEX_CUTOFF = 2;
// The time in milliseconds that a target message will be active before it is considered stale.
-export const TARGET_MESSAGE_ACTIVE_TIME = DEFAULT_ACTIVE_TARGET_TIME;
+export const TARGET_MESSAGE_ACTIVE_TIME = 800;
diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsx
index 9bb39d03d1..7d939044b9 100644
--- a/js/app/packages/block-email/component/Email.tsx
+++ b/js/app/packages/block-email/component/Email.tsx
@@ -4,7 +4,6 @@ import { toast } from '@core/component/Toast/Toast';
import { TOKENS } from '@core/hotkey/tokens';
import { registerScopeSignalHotkey } from '@core/hotkey/utils';
import { createMethodRegistration } from '@core/orchestrator';
-import { createActiveTarget } from '@core/signal/activeTarget';
import {
blockElementSignal,
blockHotkeyScopeSignal,
@@ -217,8 +216,12 @@ export function Email(props: EmailProps) {
const [focusedMessageId, setFocusedMessageId] = createSignal<string>();
const [isContainerFilled, setIsContainerFilled] = createSignal(false);
const [hasHandledTarget, setHasHandledTarget] = createSignal(false);
+ const [targetMessageActive, setTargetMessageActive] = createSignal(false);
- const activeTargetMessageId = createActiveTarget(targetMessageId);
+ const activeTargetMessageId = createMemo(() => {
+ if (!targetMessageActive()) return undefined;
+ return untrack(targetMessageId);
+ });
const blockHandle = blockHandleSignal.get;
createMethodRegistration(blockHandle, {
@@ -304,6 +307,11 @@ export function Email(props: EmailProps) {
if (success) {
setFocusedMessageId(messageId);
+ // Flash the message after scroll completes
+ setTargetMessageActive(true);
+ setTimeout(() => {
+ setTargetMessageActive(false);
+ }, 800);
// Clear scrolling flag after animation
setTimeout(() => setIsScrollingToMessage(false), 1000);
} else {
@@ -445,7 +453,7 @@ export function Email(props: EmailProps) {
// Load one more batch for scroll context
await loadContextBatch();
// Scroll to the message after DOM updates
- setTimeout(() => performScrollToMessage(messageId, 'smooth'));
+ setTimeout(() => performScrollToMessage(messageId, 'instant'));
} else {
// Message not found, fallback to last message
setTimeout(() => scrollToLastMessageAndFocus('instant'));
@@ -458,11 +466,11 @@ export function Email(props: EmailProps) {
// Case 2: Message is first in current batch - load more for context
else if (targetIndex === 0) {
await loadContextBatch();
- setTimeout(() => performScrollToMessage(messageId, 'smooth'));
+ setTimeout(() => performScrollToMessage(messageId, 'instant'));
}
// Case 3: Message is in current batch with sufficient context
else {
- setTimeout(() => performScrollToMessage(messageId, 'smooth'));
+ setTimeout(() => performScrollToMessage(messageId, 'instant'));
}
}
diff --git a/js/app/packages/core/signal/activeTarget.ts b/js/app/packages/core/signal/activeTarget.ts
deleted file mode 100644
index 40bf8376df..0000000000
--- a/js/app/packages/core/signal/activeTarget.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import {
- type Accessor,
- createEffect,
- createSignal,
- on,
- onCleanup,
-} from 'solid-js';
-
-export const DEFAULT_ACTIVE_TARGET_TIME = 800;
-
-/**
- * Creates a signal that mirrors a source signal but automatically clears
- * after a duration. Used for temporary UI states like message highlighting.
- *
- * @param source - The source signal to track
- * @param duration - Duration in milliseconds before the active state clears (default: 800ms)
- * @returns An accessor for the active target value
- *
- * @example
- * const activeId = createActiveTarget(targetId);
- * // activeId() mirrors targetId() for 800ms, then becomes undefined
- */
-export function createActiveTarget<T>(
- source: Accessor<T | undefined>,
- duration = DEFAULT_ACTIVE_TARGET_TIME
-): Accessor<T | undefined> {
- const [active, setActive] = createSignal<T | undefined>();
- let timeoutId: ReturnType<typeof setTimeout> | undefined;
-
- createEffect(
- on(source, (target) => {
- if (timeoutId !== undefined) {
- clearTimeout(timeoutId);
- timeoutId = undefined;
- }
-
- if (target !== undefined) {
- setActive(() => target);
- timeoutId = setTimeout(() => {
- setActive(undefined);
- timeoutId = undefined;
- }, duration);
- } else {
- setActive(undefined);
- }
- })
- );
-
- onCleanup(() => {
- if (timeoutId !== undefined) {
- clearTimeout(timeoutId);
- }
- });
-
- return active;
-}