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[new-channels]: various mobile improvements (#2363)
Peter Chinmana41e6b31b5d8
diff --git a/js/app/packages/app/component/useAppSquishHandlers.ts b/js/app/packages/app/component/useAppSquishHandlers.tsindex 7b86aa5fe3..6e77785573 100644--- a/js/app/packages/app/component/useAppSquishHandlers.ts+++ b/js/app/packages/app/component/useAppSquishHandlers.ts@@ -91,6 +91,11 @@ export function useAppSquishHandlers() {};onMount(() => {+ document.documentElement.style.setProperty(+ '--virtual-keyboard-height',+ '0px'+ );+ document.documentElement.style.setProperty('--dvh', '1dvh');if (window.visualViewport) {window.visualViewport.addEventListener('resize', handleResize);handleResize();diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex 2019e70bee..1fd37dae73 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -722,16 +722,48 @@ html[data-modality="keyboard"] .suppress-css-brackets .allow-css-brackets *:focu}/* Channel message highlight: hover only in mouse nav, keyboard selection only in keyboard nav */-[data-channel-nav="mouse"] [data-message]:hover,-[data-channel-nav="keyboard"] [data-message][data-highlighted] {+/* Suppressed on touch devices */+html:not([data-touch-device="true"]) [data-channel-nav="mouse"] [data-message]:hover,+html:not([data-touch-device="true"]) [data-channel-nav="keyboard"] [data-message][data-highlighted] {@apply bg-accent/5 outline-1 outline-accent/20 outline-offset-[-1px];}-[data-channel-nav="mouse"] [data-message]:hover > .message-accent-bar,-[data-channel-nav="keyboard"] [data-message][data-highlighted] > .message-accent-bar {+html:not([data-touch-device="true"]) [data-channel-nav="mouse"] [data-message]:hover > .message-accent-bar,+html:not([data-touch-device="true"]) [data-channel-nav="keyboard"] [data-message][data-highlighted] > .message-accent-bar {@apply opacity-100;}+/* Long-press animation */+[data-message].long-press-animation {+ animation: long-press-message-highlight 400ms ease-in both;+}++[data-message].long-press-animation > .message-accent-bar {+ animation: long-press-accent-bar 400ms ease-in both;+}++@keyframes long-press-message-highlight {+ from {+ background-color: oklch(from var(--color-accent) l c h / 0%);+ outline-width: 1px;+ outline-style: solid;+ outline-color: transparent;+ outline-offset: -1px;+ }+ to {+ background-color: oklch(from var(--color-accent) l c h / 5%);+ outline-width: 1px;+ outline-style: solid;+ outline-color: oklch(from var(--color-accent) l c h / 20%);+ outline-offset: -1px;+ }+}++@keyframes long-press-accent-bar {+ from { opacity: 0; }+ to { opacity: 1; }+}+html[data-modality="keyboard"] input:focus-visible::after,html[data-modality="keyboard"] textarea:focus-visible::after,html[data-modality="keyboard"] [contenteditable="true"]:focus-visible::after {diff --git a/js/app/packages/channel/Channel/Channel.tsx b/js/app/packages/channel/Channel/Channel.tsxindex bf398c46d7..07d41a2d1f 100644--- a/js/app/packages/channel/Channel/Channel.tsx+++ b/js/app/packages/channel/Channel/Channel.tsx@@ -8,7 +8,6 @@ import {createMemo,createSignal,on,- onCleanup,onMount,Show,type Accessor,@@ -58,6 +57,7 @@ import { createStickyScrollEffect } from './sticky-scroll';import { createMessageEditor } from './create-message-editor';import { createMessageSelection } from './create-message-selection';import { createChannelHotkeys } from './create-channel-hotkeys';+import { createInlineInputKeyboardHandler } from './create-inline-input-keyboard-handler';import type { ChannelInputProps } from '@channel/Input/ChannelInput';import {createTargetMessageController,@@ -68,16 +68,11 @@ import {useRemoveReactionMutation,} from '@queries/channel/reaction';import { resetKeyboardModality } from './util';-import { focusAndOpenKeyboard } from '@core/mobile/focus-and-open-keyboard';-import { isMobile } from '@core/mobile/isMobile';import { DebugSuspense } from '@channel/DebugSuspense';import { MaybeMessageActionDrawerManager } from '@channel/Mobile/MessageActionDrawerManager';import { useChannelParticipants } from '@channel/use-channel-participants';import { usePostTypingUpdateMutation } from '@queries/channel/typing';-import {- scrollReplyInputAboveKeyboard,- scrollReplyInputIntoView,-} from '../scroll-utils';+import { scrollReplyInputIntoView } from '../scroll-utils';export type ChannelProps = {channelId: string;@@ -105,7 +100,8 @@ export function Channel(props: ChannelProps) {createSignal<ThreadListNavigation>();const [threadListScrollState, setThreadListScrollState] =createSignal<ThreadListScrollState>();- let messageListElement: HTMLDivElement | undefined;+ const [messageListElement, setMessageListElement] =+ createSignal<HTMLDivElement>();const targetMessageController = createTargetMessageController({channelId: () => props.channelId,@@ -197,13 +193,6 @@ export function Channel(props: ChannelProps) {removeReaction: removeReactionMutation.mutate,onReply: (ctx) => {const state = threadManager.getOrCreateThreadState(ctx.message.id);- focusAndOpenKeyboard(- () =>- document.querySelector(- `[data-input-id="thread-reply-input-${ctx.message.id}"] [contenteditable]`- ) as HTMLElement | null,- ctx.event?.target as HTMLElement | undefined- );state.setIsReplying(true);requestAnimationFrame(() => scrollReplyInputIntoView(ctx.message.id));},@@ -235,6 +224,9 @@ export function Channel(props: ChannelProps) {scrollToBottom: () => threadListNavigation()?.scrollToBottom(),});+ // On Mobile when a thread reply input is focused, we want to hide the main Channel input+ createInlineInputKeyboardHandler(messageListElement, setIsChannelInputHidden);+const onSend: ChannelInputProps['onSend'] = (snapshot) => {const senderId = userId();if (!senderId) return;@@ -259,9 +251,8 @@ export function Channel(props: ChannelProps) {};const goToMessage: ChannelHandle['goToMessage'] = (messageId, replyId) => {- if (messageListElement) {- resetKeyboardModality(messageListElement);- }+ const el = messageListElement();+ if (el) resetKeyboardModality(el);targetMessageController.goToMessage(messageId, replyId);};@@ -283,7 +274,7 @@ export function Channel(props: ChannelProps) {<divclass="ph-no-capture relative flex-1 min-h-0 suppress-css-brackets suppress-css-bracket outline-none"ref={(element) => {- messageListElement = element;+ setMessageListElement(element);attachMessageListRef(element);}}tabIndex={-1}@@ -312,76 +303,6 @@ export function Channel(props: ChannelProps) {const isNewestThread = () =>item.id === messageIndex.keys().at(-1);- if (isMobile()) {- createEffect(() => {- const el = state.replyInputEl?.();- if (!el) return;-- let keyboardWillShowHandler:- | ((e: Event) => void)- | undefined;-- const handleFocusIn = () => {- setIsChannelInputHidden(true);- const currentKeyboardHeight = parseFloat(- getComputedStyle(- document.documentElement- ).getPropertyValue('--virtual-keyboard-height')- );- if (currentKeyboardHeight > 0) {- scrollReplyInputAboveKeyboard(- item.id,- currentKeyboardHeight- );- } else {- keyboardWillShowHandler = (event: Event) => {- const height =- (event as CustomEvent<{ height: number }>)- .detail?.height ?? 0;- scrollReplyInputAboveKeyboard(item.id, height);- keyboardWillShowHandler = undefined;- };- window.addEventListener(- 'keyboardWillShow',- keyboardWillShowHandler,- { once: true }- );- }- };-- const handleFocusOut = (e: FocusEvent) => {- if (!el.contains(e.relatedTarget as Node)) {- setIsChannelInputHidden(false);- if (keyboardWillShowHandler) {- window.removeEventListener(- 'keyboardWillShow',- keyboardWillShowHandler- );- keyboardWillShowHandler = undefined;- }- }- };-- el.addEventListener('focusin', handleFocusIn);- el.addEventListener(- 'focusout',- handleFocusOut as EventListener- );- onCleanup(() => {- el.removeEventListener('focusin', handleFocusIn);- el.removeEventListener(- 'focusout',- handleFocusOut as EventListener- );- if (keyboardWillShowHandler) {- window.removeEventListener(- 'keyboardWillShow',- keyboardWillShowHandler- );- }- });- });- }return (<Show when={message()}>{(m) => (diff --git a/js/app/packages/channel/Channel/InlineMessageEditor.tsx b/js/app/packages/channel/Channel/InlineMessageEditor.tsxindex 16c3fbb443..fc2b14a11d 100644--- a/js/app/packages/channel/Channel/InlineMessageEditor.tsx+++ b/js/app/packages/channel/Channel/InlineMessageEditor.tsx@@ -33,7 +33,11 @@ export function MessageEditorContent(props: MessageEditorContentProps) {});return (- <div ref={attachHotkeys} class={cn('w-full min-w-0', props.class)}>+ <div+ ref={attachHotkeys}+ class={cn('w-full min-w-0', props.class)}+ data-inline-input-container-id={message().id}+ ><ChannelInputinput={{mode: 'channel',diff --git a/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.ts b/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.tsnew file mode 100644index 0000000000..e58ada0cae--- /dev/null+++ b/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.ts@@ -0,0 +1,127 @@+import {+ createEffect,+ on,+ onCleanup,+ type Accessor,+ type Setter,+} from 'solid-js';+import { isMobile } from '@core/mobile/isMobile';+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';+import { scrollElementAboveKeyboard } from '../scroll-utils';++const INPUT_CONTAINER_SELECTOR = '[data-inline-input-container-id]';++export function createInlineInputKeyboardHandler(+ containerEl: Accessor<HTMLElement | undefined>,+ setIsChannelInputHidden: Setter<boolean>+): void {+ let getActiveInputContainer: (() => HTMLElement | undefined) | undefined;++ createEffect(() => {+ if (!isMobile()) return;+ const el = containerEl();+ if (!el) return;+ const result = attachInlineInputKeyboardHandler(+ el,+ setIsChannelInputHidden+ );+ getActiveInputContainer = result.getActiveInputContainer;+ onCleanup(() => {+ result.cleanup();+ getActiveInputContainer = undefined;+ });+ });++ // Mobile web fallback: watch for virtualKeyboardVisible signal, and scroll active input listner into view.+ createEffect(+ on(virtualKeyboardVisible, () => {+ if (!isMobile() || isNativeMobilePlatform()) return;+ if (!virtualKeyboardVisible()) return;+ const container = getActiveInputContainer?.();+ if (container) {+ setTimeout(() => {+ container.scrollIntoView({ block: 'center', behavior: 'smooth' });+ }, 0);+ }+ }),+ { defer: true }+ );+}++function attachInlineInputKeyboardHandler(+ containerEl: HTMLElement,+ setIsChannelInputHidden: Setter<boolean>+): {+ getActiveInputContainer: () => HTMLElement | undefined;+ cleanup: () => void;+} {+ let keyboardWillShowHandler: ((e: Event) => void) | undefined;+ let activeInputContainer: HTMLElement | undefined;++ const handleFocusIn = (e: FocusEvent) => {+ const inputContainer = (e.target as HTMLElement).closest<HTMLElement>(+ INPUT_CONTAINER_SELECTOR+ );+ if (!inputContainer) return;+ activeInputContainer = inputContainer;++ setIsChannelInputHidden(true);+ const currentKeyboardHeight = parseFloat(+ getComputedStyle(document.documentElement).getPropertyValue(+ '--virtual-keyboard-height'+ )+ );+ if (currentKeyboardHeight > 0) {+ scrollElementAboveKeyboard(activeInputContainer, currentKeyboardHeight);+ } else {+ if (keyboardWillShowHandler)+ window.removeEventListener('keyboardWillShow', keyboardWillShowHandler);+ keyboardWillShowHandler = (event: Event) => {+ const height =+ (event as CustomEvent<{ height: number }>).detail?.height ?? 0;+ if (activeInputContainer)+ scrollElementAboveKeyboard(activeInputContainer, height);+ keyboardWillShowHandler = undefined;+ };+ window.addEventListener('keyboardWillShow', keyboardWillShowHandler, {+ once: true,+ });+ }+ };++ const handleFocusOut = (e: FocusEvent) => {+ const inputContainer = (e.target as HTMLElement).closest<HTMLElement>(+ INPUT_CONTAINER_SELECTOR+ );+ if (!inputContainer) return;+ const nextInputContainer = (e.relatedTarget as HTMLElement | null)?.closest(+ INPUT_CONTAINER_SELECTOR+ );+ if (!nextInputContainer) {+ setIsChannelInputHidden(false);+ activeInputContainer = undefined;+ if (keyboardWillShowHandler) {+ window.removeEventListener('keyboardWillShow', keyboardWillShowHandler);+ keyboardWillShowHandler = undefined;+ }+ }+ };++ containerEl.addEventListener('focusin', handleFocusIn);+ containerEl.addEventListener('focusout', handleFocusOut as EventListener);++ return {+ getActiveInputContainer: () => activeInputContainer,+ cleanup: () => {+ containerEl.removeEventListener('focusin', handleFocusIn);+ containerEl.removeEventListener(+ 'focusout',+ handleFocusOut as EventListener+ );+ if (keyboardWillShowHandler) {+ window.removeEventListener('keyboardWillShow', keyboardWillShowHandler);+ }+ },+ };+}diff --git a/js/app/packages/channel/Channel/mobile-channel-input-visibility.tsx b/js/app/packages/channel/Channel/mobile-channel-input-visibility.tsxnew file mode 100644index 0000000000..b76d16a3d1--- /dev/null+++ b/js/app/packages/channel/Channel/mobile-channel-input-visibility.tsx@@ -0,0 +1,45 @@+import {+ createContext,+ createSignal,+ useContext,+ type Accessor,+ type JSX,+} from 'solid-js';+import { isMobile } from '@core/mobile/isMobile';++type MobileChannelInputVisibilityState = {+ isHidden: Accessor<boolean>;+ hide: () => void;+ show: () => void;+};++const MobileChannelInputVisibilityContext =+ createContext<MobileChannelInputVisibilityState>();++/**+ * On mobile: creates reactive hide/show state and provides it via context.+ * On desktop: renders children as-is with no context or signals.+ */+export function MaybeMobileChannelInputVisibilityProvider(props: {+ children: JSX.Element;+}) {+ if (!isMobile()) return props.children;+ const [isHidden, setIsHidden] = createSignal(false);+ return (+ <MobileChannelInputVisibilityContext.Provider+ value={{+ isHidden,+ hide: () => setIsHidden(true),+ show: () => setIsHidden(false),+ }}+ >+ {props.children}+ </MobileChannelInputVisibilityContext.Provider>+ );+}++export function useMobileChannelInputVisibility():+ | MobileChannelInputVisibilityState+ | undefined {+ return useContext(MobileChannelInputVisibilityContext);+}diff --git a/js/app/packages/channel/Input/ActionButton.tsx b/js/app/packages/channel/Input/ActionButton.tsxindex 47b86cbf91..7af63610b8 100644--- a/js/app/packages/channel/Input/ActionButton.tsx+++ b/js/app/packages/channel/Input/ActionButton.tsx@@ -13,6 +13,7 @@ export function InputActionButton(props: {title={props.label}aria-label={props.label}tooltip={<LabelAndHotKey label={props.label} />}+ onPointerDown={(event: PointerEvent) => event.preventDefault()}onClick={(event) => props.onClick?.(event)}classList={{ 'bg-active': props.active }}size="icon-sm"diff --git a/js/app/packages/channel/Input/Attachments.tsx b/js/app/packages/channel/Input/Attachments.tsxindex 292bcf550c..bd6934577c 100644--- a/js/app/packages/channel/Input/Attachments.tsx+++ b/js/app/packages/channel/Input/Attachments.tsx@@ -21,6 +21,11 @@ type AttachmentsProps = JSX.HTMLAttributes<HTMLDivElement> & {kind?: InputAttachmentKind | 'media';};+function truncateFilename(name: string, maxLength = 24): string {+ if (name.length <= maxLength) return name;+ return `${name.slice(0, maxLength)}…`;+}+function RemoveButton(props: {attachment: InputAttachmentData;onRemove: (attachment: InputAttachmentData) => void;@@ -30,7 +35,7 @@ function RemoveButton(props: {<buttontype="button"class={cn(- 'hover:bg-hover hover-transition-bg rounded-md p-1 items-center flex',+ 'hover:bg-hover hover-transition-bg rounded-md p-1 [@media(hover:none)]:p-2 items-center flex',props.class)}onClick={(event) => {@@ -39,7 +44,7 @@ function RemoveButton(props: {}}aria-label={`Remove ${props.attachment.name}`}>- <XIcon class="text-ink-muted group-hover:text-failure size-3" />+ <XIcon class="text-ink-muted group-hover:text-failure size-3 [@media(hover:none)]:size-4" /></button>);}@@ -71,12 +76,12 @@ function MediaAttachmentItem(props: {class="size-full object-cover"/><MediaVideo.PlayOverlay />- <RemoveButton- attachment={props.attachment}- onRemove={props.onRemove}- class="absolute -top-2 -right-2 z-[10] rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100"- /></MediaVideo.Root>+ <RemoveButton+ attachment={props.attachment}+ onRemove={props.onRemove}+ class="absolute -top-2 -right-2 z-[10] rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"+ /></Show>}>@@ -92,7 +97,7 @@ function MediaAttachmentItem(props: {<RemoveButtonattachment={props.attachment}onRemove={props.onRemove}- class="absolute -top-2 -right-2 z-[10] rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100"+ class="absolute -top-2 -right-2 z-[10] rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"/></MediaImage.Root></Show>@@ -115,7 +120,10 @@ function DocumentAttachmentItem(props: {size="xs"/></Show>- <span class="truncate max-w-[16rem]">{props.attachment.name}</span>+ <span>+ {/* Note: using javascript truncation here rather than CSS because `truncate` was causing a complex bug that made it impossible to horizontally scroll documents on mobile. */}+ {truncateFilename(props.attachment.name)}+ </span><RemoveButton attachment={props.attachment} onRemove={props.onRemove} /></div>);@@ -147,7 +155,9 @@ export function Attachments(props: AttachmentsProps) {<Show when={visibleAttachments().length > 0}><divclass={cn(- 'flex flex-row w-full px-2 py-1 gap-2 flex-wrap',+ 'flex flex-row w-full px-2 py-2 gap-2 flex-wrap',+ // On mobile, attachments scroll horizontally+ 'mobile:flex-nowrap mobile:[&>*]:shrink-0 mobile:overflow-x-auto mobile:scrollbar-hidden',local.class)}data-input-attachments={local.kind ?? 'all'}diff --git a/js/app/packages/channel/Input/ChannelInput.tsx b/js/app/packages/channel/Input/ChannelInput.tsxindex 1334e8e7c2..96c29e85b8 100644--- a/js/app/packages/channel/Input/ChannelInput.tsx+++ b/js/app/packages/channel/Input/ChannelInput.tsx@@ -21,7 +21,14 @@ import type {InputPersistenceKey,} from './types';import { applyInlineFormat, applyNodeFormat } from './utils/formatting';-import { Match, Show, Switch, type Accessor, type JSX } from 'solid-js';+import {+ Match,+ Show,+ Switch,+ createSignal,+ type Accessor,+ type JSX,+} from 'solid-js';import { isReplyInput } from './types';import type { IUser } from '@core/user/types';@@ -53,6 +60,7 @@ function DefaultActions(props: { input: InputData }) {}export function ChannelInput(props: ChannelInputProps) {+ const [scrollContainer, setScrollContainer] = createSignal<HTMLElement>();const mentionsTracker = createMentionsTracker();const attachmentTracker =props.attachmentTracker ??@@ -103,6 +111,7 @@ export function ChannelInput(props: ChannelInputProps) {namespace: props.markdownNamespace ?? 'channel-input-markdown',enableMentions: true,users: props.participants,+ scrollContainer,onMentionCreate: (mention) => {mentionsTracker.onMentionCreate(mention);},@@ -153,9 +162,12 @@ export function ChannelInput(props: ChannelInputProps) {/></Input.FormatRibbon><Input.EditorShell+ ref={setScrollContainer}onClick={(event) => {- event.stopPropagation();- markdownEditor.controls.focus();+ if (!isMobile()) {+ event.stopPropagation();+ markdownEditor.controls.focus();+ }}}><Input.Editor>@@ -164,7 +176,7 @@ export function ChannelInput(props: ChannelInputProps) {placeholder={inputState.view().placeholder}initialValue={inputState.view().value}autofocus={!isMobile()}- class="text-sm mobile:text-base"+ class="text-sm"/></Input.Editor></Input.EditorShell>diff --git a/js/app/packages/channel/Input/ChannelInputContainer.tsx b/js/app/packages/channel/Input/ChannelInputContainer.tsxindex 34ec07c6fc..caf13d44b9 100644--- a/js/app/packages/channel/Input/ChannelInputContainer.tsx+++ b/js/app/packages/channel/Input/ChannelInputContainer.tsx@@ -8,7 +8,10 @@ export function ChannelInputContainer(props: {}) {return (<div- class={cn('pb-2 w-full flex justify-center', props.isHidden && 'hidden')}+ class={cn(+ 'pb-2 mobile:pb-0 w-full flex justify-center [&_[data-input-editor-shell]]:max-h-[calc(60*var(--dvh,1dvh))] mobile:[&_[data-input-editor-shell]]:max-h-[calc(32*var(--dvh,1dvh))]',+ props.isHidden && 'hidden'+ )}ref={props.ref}>{props.children}diff --git a/js/app/packages/channel/Input/EditorShell.tsx b/js/app/packages/channel/Input/EditorShell.tsxindex 463c742e80..df49c7ece6 100644--- a/js/app/packages/channel/Input/EditorShell.tsx+++ b/js/app/packages/channel/Input/EditorShell.tsx@@ -7,7 +7,7 @@ export function EditorShell(props: JSX.HTMLAttributes<HTMLDivElement>) {return (<divclass={cn(- 'transition-all duration-150 px-3 pt-2 pb-2 @min-[40rem]:pb-4 overflow-y-auto placeholder:text-ink-placeholder text-ink w-full text-sm mobile:text-base',+ 'transition-all duration-150 px-3 pt-2 pb-2 @min-[40rem]:pb-4 overflow-y-auto placeholder:text-ink-placeholder text-ink w-full text-sm',local.class)}data-input-editor-shelldiff --git a/js/app/packages/channel/Input/RibbonButton.tsx b/js/app/packages/channel/Input/RibbonButton.tsxindex f1cb031545..dd1b61bb99 100644--- a/js/app/packages/channel/Input/RibbonButton.tsx+++ b/js/app/packages/channel/Input/RibbonButton.tsx@@ -20,8 +20,10 @@ export function RibbonButton(props: RibbonButtonProps) {'bg-active': props.active,})}- onClick={(event) => {+ onPointerDown={(event) => {event.preventDefault();+ }}+ onClick={() => {props.onClick();}}>diff --git a/js/app/packages/channel/Input/Root.tsx b/js/app/packages/channel/Input/Root.tsxindex 1393c4f687..d9a8460bdb 100644--- a/js/app/packages/channel/Input/Root.tsx+++ b/js/app/packages/channel/Input/Root.tsx@@ -2,6 +2,7 @@ import { splitProps, type JSX } from 'solid-js';import { cn } from '@ui/utils/classname';import { InputProvider } from './context';import { isReplyInput, type InputCommands, type InputData } from './types';+import { isMobile } from '@core/mobile/isMobile';const NoopInputCommands: InputCommands = {send: async () => false,@@ -27,11 +28,12 @@ export function Root(props: RootProps) {return (<divclass={cn(- 'relative macro-message-width flex flex-col flex-1 items-center justify-between bg-input border border-edge-muted rounded-[5px]',- local.class,- {- 'rounded-b-[5px] border-b mb-4': isReplyInput(local.input),- }+ 'relative max-w-full macro-message-width flex flex-col flex-1 items-center justify-between bg-input border border-edge-muted rounded-[5px]',+ isMobile() &&+ !isReplyInput(local.input) &&+ 'border-b-0 border-l-0 border-r-0 rounded-b-none',+ isReplyInput(local.input) && 'rounded-b-[5px] mb-4',+ local.class)}data-inputdata-input-id={local.input.id}diff --git a/js/app/packages/channel/Input/configured-markdown-editor.ts b/js/app/packages/channel/Input/configured-markdown-editor.tsindex de3a9d818e..e7d0f5b404 100644--- a/js/app/packages/channel/Input/configured-markdown-editor.ts+++ b/js/app/packages/channel/Input/configured-markdown-editor.ts@@ -4,9 +4,13 @@ import {type ItemMention,keyboardShortcutsPlugin,} from '@core/component/LexicalMarkdown/plugins';+import { iosCursorScrollPlugin } from '@core/component/LexicalMarkdown/plugins/ios-cursor-scroll';import { tableCellResizerPlugin } from '@core/component/LexicalMarkdown/plugins/tables/tableCellResizerPlugin';import { tablePlugin } from '@core/component/LexicalMarkdown/plugins/tables/tablePlugin';+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import type { IUser } from '@core/user/types';+import { isIOS } from '@solid-primitives/platform';+import type { Accessor } from 'solid-js';type CreateConfiguredChannelMarkdownEditorOptions = {namespace: string;@@ -20,6 +24,7 @@ type CreateConfiguredChannelMarkdownEditorOptions = {files: FileSystemFileEntry[],directories: FileSystemDirectoryEntry[]) => void;+ scrollContainer?: Accessor<HTMLElement | undefined>;};export function createConfiguredChannelMarkdownEditor(@@ -42,7 +47,7 @@ export function createConfiguredChannelMarkdownEditor(});}- return editor+ editor.withEmojis().withLinks({ floatingMenu: true }).withHistory({ timeGap: 400 })@@ -65,4 +70,12 @@ export function createConfiguredChannelMarkdownEditor().onChange(options.onChange).onEnter(options.onEnter);++ if ((isIOS || isNativeMobilePlatform()) && options.scrollContainer) {+ editor.use(+ iosCursorScrollPlugin({ scrollContainer: options.scrollContainer })+ );+ }++ return editor;}diff --git a/js/app/packages/channel/Message/ActionDrawer.tsx b/js/app/packages/channel/Message/ActionDrawer.tsxnew file mode 100644index 0000000000..7f73eab523--- /dev/null+++ b/js/app/packages/channel/Message/ActionDrawer.tsx@@ -0,0 +1,244 @@+import { MobileDrawer } from '@app/component/mobile/MobileDrawer';+import { EmojiSelector } from '@core/component/Emoji/EmojiSelector';+import ReplyIcon from '@icon/regular/arrow-bend-up-left.svg';+import LinkIcon from '@icon/regular/link.svg';+import PencilIcon from '@icon/regular/pencil.svg';+import PlusIcon from '@icon/regular/plus.svg';+import TrashIcon from '@icon/regular/trash.svg';+import {+ createSignal,+ For,+ onMount,+ Show,+ type Component,+ type JSX,+} from 'solid-js';+import { useMessageActionDrawer } from './context';+import { renderIcon } from './render-icon';+import type {+ MessageActionEvent,+ MessageActionHandler,+ MessageActions,+} from './types';++const QUICK_REACTION_EMOJIS = ['❤️', '👍', '👎', '😂', '😡'] as const;++type ActionId = 'reply' | 'copy-link' | 'edit' | 'delete';++type ActionItem = {+ id: ActionId;+ label: string;+ icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>> | string;+ onClick?: MessageActionHandler;+ destructive?: boolean;+};++function buildActionItems(actions: MessageActions | undefined): ActionItem[] {+ return [+ { id: 'reply', label: 'Reply', icon: ReplyIcon, onClick: actions?.onReply },+ {+ id: 'copy-link',+ label: 'Copy Link',+ icon: LinkIcon,+ onClick: actions?.onCopyLink,+ },+ { id: 'edit', label: 'Edit', icon: PencilIcon, onClick: actions?.onEdit },+ {+ id: 'delete',+ label: 'Delete',+ icon: TrashIcon,+ onClick: actions?.onDelete,+ destructive: true,+ },+ ];+}++function EmojiSearchView(props: {+ onSelect: (emoji: string) => void;+ onBack: () => void;+}) {+ let inputRef: HTMLInputElement | undefined;+ const [query, setQuery] = createSignal('');++ onMount(() => {+ setTimeout(() => {+ inputRef?.focus();+ }, 0);+ });++ return (+ <div class="flex flex-col flex-1 min-h-0 pb-2">+ {/* Search input */}+ <div class="flex items-center gap-2 px-3 pb-2 shrink-0">+ <div class="flex flex-1 items-center bg-input border border-edge-muted rounded-sm px-2 py-1.5 text-sm gap-1">+ <input+ ref={inputRef}+ value={query()}+ onInput={(e) => setQuery(e.currentTarget.value)}+ placeholder="Search emojis"+ aria-label="Search emojis"+ class="flex-1 bg-transparent outline-none placeholder:text-ink-placeholder"+ />+ </div>+ </div>++ {/* Emoji grid — onPointerDown preventDefault prevents the input from+ blurring before the click fires on an emoji button */}+ <div+ class="overflow-y-auto flex-1 px-1"+ onPointerDown={(e) => e.preventDefault()}+ >+ <EmojiSelector+ nameFilter={query()}+ onEmojiClick={(emoji) => props.onSelect(emoji.emoji)}+ columns={7}+ />+ </div>+ </div>+ );+}++export function ActionDrawer() {+ const drawerState = useMessageActionDrawer();+ const [showEmojiSearch, setShowEmojiSearch] = createSignal(false);++ if (!drawerState) {+ console.warn('No drawer state.');+ return null;+ }++ const message = () => drawerState.message();+ const actions = () => drawerState.actions();++ const handleReaction = (emoji: string, event?: MessageActionEvent) => {+ const msg = message();+ if (!msg) return;+ void actions()?.onReact?.({ message: msg, event, emoji });+ drawerState.close();+ setShowEmojiSearch(false);+ };++ const handleAction = (+ handler: MessageActionHandler | undefined,+ event: MouseEvent+ ) => {+ const msg = message();+ if (!msg) return;+ void handler?.({ message: msg, event });+ drawerState.close();+ };++ const actionItems = () => buildActionItems(actions());+ const nonDestructiveActions = () =>+ actionItems().filter((item) => item.onClick && !item.destructive);+ const destructiveActions = () =>+ actionItems().filter((item) => item.onClick && item.destructive);+ const hasReactAction = () => actions()?.onReact !== undefined;++ return (+ <MobileDrawer+ side="bottom"+ open={drawerState.isOpen()}+ closeOnOutsidePointerStrategy="pointerdown"+ onOpenChange={(v) => {+ if (!v) {+ drawerState.close();+ setShowEmojiSearch(false);+ }+ }}+ preventScroll={false}+ preventScrollbarShift={false}+ restoreFocus={false}+ >+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" />+ <MobileDrawer.Content aria-label="Message actions">+ {/* Drag handle */}+ <div class="flex justify-center pt-3 pb-2 shrink-0">+ <div class="w-10 h-1 rounded-full bg-edge-muted" />+ </div>++ <Show+ when={!showEmojiSearch()}+ fallback={+ <EmojiSearchView+ onSelect={(emoji) => handleReaction(emoji)}+ onBack={() => setShowEmojiSearch(false)}+ />+ }+ >+ {/* Emoji reaction row */}+ <Show when={hasReactAction()}>+ <div class="flex flex-row items-center justify-between px-3 pb-4 gap-1 shrink-0">+ <For each={QUICK_REACTION_EMOJIS}>+ {(emoji) => (+ <button+ type="button"+ title={`React ${emoji}`}+ aria-label={`React ${emoji}`}+ class="size-12 flex items-center justify-center bg-edge/30 rounded-full text-[28px]"+ onClick={(event) => handleReaction(emoji, event)}+ >+ {emoji}+ </button>+ )}+ </For>+ <button+ type="button"+ title="More reactions"+ aria-label="More reactions"+ class="size-12 bg-edge/30 rounded-full flex items-center justify-center text-ink-muted"+ onClick={() => setShowEmojiSearch(true)}+ >+ {renderIcon(PlusIcon, 'size-[28px]')}+ </button>+ </div>+ </Show>++ {/* Non-destructive actions */}+ <Show when={nonDestructiveActions().length > 0}>+ <MobileDrawer.Section class="flex flex-col shrink-0">+ <For each={nonDestructiveActions()}>+ {(action) => (+ <button+ type="button"+ data-message-action={action.id}+ class="flex items-center gap-3 px-4 py-3 text-sm text-ink hover:bg-hover hover-transition-bg text-left not-last:border-b border-page"+ onClick={(event) => handleAction(action.onClick, event)}+ >+ <span class="size-5 flex items-center justify-center shrink-0">+ {renderIcon(action.icon)}+ </span>+ {action.label}+ </button>+ )}+ </For>+ </MobileDrawer.Section>+ </Show>++ {/* Destructive actions */}+ <Show when={destructiveActions().length > 0}>+ <MobileDrawer.Section class="flex flex-col shrink-0 mt-3">+ <For each={destructiveActions()}>+ {(action) => (+ <button+ type="button"+ data-message-action={action.id}+ class="flex items-center gap-3 px-4 py-3 text-sm text-failure-ink hover:bg-hover hover-transition-bg text-left not-last:border-b border-panel"+ onClick={(event) => handleAction(action.onClick, event)}+ >+ <span class="size-5 flex items-center justify-center shrink-0">+ {renderIcon(action.icon)}+ </span>+ {action.label}+ </button>+ )}+ </For>+ </MobileDrawer.Section>+ </Show>+ </Show>+ </MobileDrawer.Content>+ </MobileDrawer.Portal>+ </MobileDrawer>+ );+}diff --git a/js/app/packages/channel/Message/ChannelMessage.tsx b/js/app/packages/channel/Message/ChannelMessage.tsxindex 5f498d43e4..945b876ac7 100644--- a/js/app/packages/channel/Message/ChannelMessage.tsx+++ b/js/app/packages/channel/Message/ChannelMessage.tsx@@ -8,7 +8,7 @@ import type { MessageSelectionState } from './context';import { useMessageActionDrawer } from '@channel/Mobile/message-action-drawer-context';import type { MessageEditor } from '../Channel/create-message-editor';import { MessageEditorContent } from '../Channel/InlineMessageEditor';-import { touchHandler } from '@core/directive/touchHandler';+import { longPressHighlight } from '@core/directive/longPressHighlight';type ChannelMessageProps = {channelId: string;@@ -170,7 +170,7 @@ export function ChannelMessage(props: ChannelMessageProps) {actions={props.actions}highlighted={props.highlighted}ref={(el) =>- touchHandler(el, () => ({+ longPressHighlight(el, () => ({onLongPress: () => drawerManager?.open(props.message, props.actions),}))}diff --git a/js/app/packages/channel/Message/ReactionChip.tsx b/js/app/packages/channel/Message/ReactionChip.tsxindex 720f9f3698..1d2caa83d6 100644--- a/js/app/packages/channel/Message/ReactionChip.tsx+++ b/js/app/packages/channel/Message/ReactionChip.tsx@@ -1,7 +1,9 @@import { Tooltip } from '@core/component/Tooltip';+import { touchHandler } from '@core/directive/touchHandler';import { idToDisplayName } from '@core/user';import { cn } from '@ui/utils/classname';-import { type JSX, Show } from 'solid-js';+import { Popover } from '@kobalte/core/popover';+import { createSignal, type JSX, Show } from 'solid-js';type ReactionChipProps = {emoji: string;@@ -55,40 +57,69 @@ function ReactionTooltipContent(props: {}export function ReactionChip(props: ReactionChipProps) {+ const [showReactors, setShowReactors] = createSignal(false);+return (- <Tooltip- tooltip={- <ReactionTooltipContent- users={props.users}- currentUserId={props.currentUserId}- emoji={props.emoji}- />- }+ <Popover+ open={showReactors()}+ onOpenChange={setShowReactors}placement="top">- <button- type="button"- data-message-reaction-chip- data-emoji={props.emoji}- class={cn(- 'flex flex-row items-center gap-2 py-1 px-2 bg-menu border h-8',- {- 'text-accent-ink border-accent': props.selected,- 'border-edge-muted hover:bg-hover hover:scale-105 transition-none hover:transition':- !props.selected && props.interactive,- 'border-edge-muted': !props.selected && !props.interactive,- 'cursor-default': !props.interactive,- 'pointer-events-auto': !props.interactive,+ <Popover.Anchor>+ <Tooltip+ tooltip={+ <ReactionTooltipContent+ users={props.users}+ currentUserId={props.currentUserId}+ emoji={props.emoji}+ />}- )}- disabled={!props.interactive}- onClick={(event) => props.onClick?.(event)}- >- <span class="text-md">{props.emoji}</span>- <Show when={props.count > 1}>- <span class="text-xs">{props.count}</span>- </Show>- </button>- </Tooltip>+ placement="top"+ >+ <button+ type="button"+ data-message-reaction-chip+ data-emoji={props.emoji}+ ref={(el) =>+ touchHandler(el, () => ({+ onLongPress: () => {+ setShowReactors(true);+ },+ stopTouchStartPropagation: true,+ }))+ }+ class={cn(+ 'flex flex-row items-center gap-2 py-1 px-2 bg-menu border h-8',+ {+ 'text-accent-ink border-accent': props.selected,+ 'border-edge-muted hover:bg-hover hover:scale-105 transition-none hover:transition':+ !props.selected && props.interactive,+ 'border-edge-muted': !props.selected && !props.interactive,+ 'cursor-default': !props.interactive,+ 'pointer-events-auto': !props.interactive,+ }+ )}+ disabled={!props.interactive}+ onClick={(event) => {+ props.onClick?.(event);+ }}+ >+ <span class="text-md">{props.emoji}</span>+ <Show when={props.count > 1}>+ <span class="text-xs">{props.count}</span>+ </Show>+ </button>+ </Tooltip>+ </Popover.Anchor>+ <Popover.Portal>+ <Popover.Content class="z-modal bg-panel p-1.5 text-ink-muted text-xs rounded-sm border border-edge-muted">+ <ReactionTooltipContent+ users={props.users}+ currentUserId={props.currentUserId}+ emoji={props.emoji}+ />+ </Popover.Content>+ </Popover.Portal>+ </Popover>);}diff --git a/js/app/packages/channel/Message/Reactions.tsx b/js/app/packages/channel/Message/Reactions.tsxindex 079c3daf88..6f6e804483 100644--- a/js/app/packages/channel/Message/Reactions.tsx+++ b/js/app/packages/channel/Message/Reactions.tsx@@ -6,6 +6,7 @@ import { EmojiReactionPopover } from './EmojiReactionPopover';import { useMessage, useMessageActions } from './context';import { ReactionChip } from './ReactionChip';import { renderIcon } from './render-icon';+import { isTouchDevice } from '@core/mobile/isTouchDevice';type ReactionsProps = {class?: string;@@ -53,7 +54,7 @@ export function Reactions(props: ReactionsProps) {}}</For>- <Show when={canReact()}>+ <Show when={canReact() && !isTouchDevice()}><EmojiReactionPopoverplacement="top"open={emojiMenuOpen()}diff --git a/js/app/packages/channel/Message/context.ts b/js/app/packages/channel/Message/context.tsindex 82e6e81be1..2b0f99e209 100644--- a/js/app/packages/channel/Message/context.ts+++ b/js/app/packages/channel/Message/context.ts@@ -17,6 +17,22 @@ export function useMessageActions(): MessageActions | undefined {return useContext(MessageActionsContext);}+export type MessageActionDrawerState = {+ isOpen: Accessor<boolean>;+ message: Accessor<MessageData | undefined>;+ actions: Accessor<MessageActions | undefined>;+ open: (message: MessageData, actions: MessageActions | undefined) => void;+ close: () => void;+};++const MessageActionDrawerContext = createContext<MessageActionDrawerState>();+export const MessageActionDrawerContextProvider =+ MessageActionDrawerContext.Provider;++export function useMessageActionDrawer(): MessageActionDrawerState | undefined {+ return useContext(MessageActionDrawerContext);+}+export type MessageSelectionState = {isSelected: boolean;};diff --git a/js/app/packages/channel/Mobile/ActionDrawer.tsx b/js/app/packages/channel/Mobile/ActionDrawer.tsxindex 144c4baf83..16a1d79a91 100644--- a/js/app/packages/channel/Mobile/ActionDrawer.tsx+++ b/js/app/packages/channel/Mobile/ActionDrawer.tsx@@ -5,6 +5,7 @@ import LinkIcon from '@icon/regular/link.svg';import PencilIcon from '@icon/regular/pencil.svg';import PlusIcon from '@icon/regular/plus.svg';import TrashIcon from '@icon/regular/trash.svg';+import { focusInput } from '@core/directive/focusInput';import {createSignal,For,@@ -31,18 +32,44 @@ type ActionItem = {icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>> | string;onClick?: MessageActionHandler;destructive?: boolean;+ getFocusTarget?: () => HTMLElement | null | undefined;};-function buildActionItems(actions: MessageActions | undefined): ActionItem[] {+function buildActionItems(+ actions: MessageActions | undefined,+ messageId: string | undefined+): ActionItem[] {return [- { id: 'reply', label: 'Reply', icon: ReplyIcon, onClick: actions?.onReply },+ {+ id: 'reply',+ label: 'Reply',+ icon: ReplyIcon,+ onClick: actions?.onReply,+ getFocusTarget: messageId+ ? () =>+ document.querySelector<HTMLElement>(+ `[data-input-id="thread-reply-input-${messageId}"] [contenteditable]`+ )+ : undefined,+ },{id: 'copy-link',label: 'Copy Link',icon: LinkIcon,onClick: actions?.onCopyLink,},- { id: 'edit', label: 'Edit', icon: PencilIcon, onClick: actions?.onEdit },+ {+ id: 'edit',+ label: 'Edit',+ icon: PencilIcon,+ onClick: actions?.onEdit,+ getFocusTarget: messageId+ ? () =>+ document.querySelector<HTMLElement>(+ `[data-input-id="edit-message-input-${messageId}"] [contenteditable]`+ )+ : undefined,+ },{id: 'delete',label: 'Delete',@@ -128,7 +155,7 @@ export function ActionDrawer() {drawerState.close();};- const actionItems = () => buildActionItems(actions());+ const actionItems = () => buildActionItems(actions(), message()?.id);const nonDestructiveActions = () =>actionItems().filter((item) => item.onClick && !item.destructive);const destructiveActions = () =>@@ -204,6 +231,10 @@ export function ActionDrawer() {type="button"data-message-action={action.id}class="flex items-center gap-3 px-4 py-3 text-sm text-ink hover:bg-hover hover-transition-bg text-left not-last:border-b border-page"+ ref={(el) => {+ const getTarget = action.getFocusTarget;+ if (getTarget) focusInput(el, () => ({ getTarget }));+ }}onClick={(event) => handleAction(action.onClick, event)}><span class="size-5 flex items-center justify-center shrink-0">@@ -225,6 +256,10 @@ export function ActionDrawer() {type="button"data-message-action={action.id}class="flex items-center gap-3 px-4 py-3 text-sm text-failure-ink hover:bg-hover hover-transition-bg text-left not-last:border-b border-panel"+ ref={(el) => {+ const getTarget = action.getFocusTarget;+ if (getTarget) focusInput(el, () => ({ getTarget }));+ }}onClick={(event) => handleAction(action.onClick, event)}><span class="size-5 flex items-center justify-center shrink-0">diff --git a/js/app/packages/channel/Thread/ChannelThread.tsx b/js/app/packages/channel/Thread/ChannelThread.tsxindex a7a5c64794..3b5377daa4 100644--- a/js/app/packages/channel/Thread/ChannelThread.tsx+++ b/js/app/packages/channel/Thread/ChannelThread.tsx@@ -5,7 +5,6 @@ import { MarkMessaageNotifications } from '@notifications/components/MarkMessageimport { useUserId } from '@core/context/user';import { deferredGate } from '@core/util/debounce';import { tryMacroId, useDisplayName } from '@core/user';-import { focusAndOpenKeyboard } from '@core/mobile/focus-and-open-keyboard';import { Thread } from './Thread';import type { ThreadProps } from './types';import type { ApiThreadReply } from '@service-comms/client';@@ -263,16 +262,12 @@ export function ChannelThread(props: ThreadProps) {</Show><Show when={shouldShowReplyButton()}><Thread.ReplyButton- onClick={(e) => {- focusAndOpenKeyboard(- () =>- (replyInputContainerRef?.querySelector(- '[contenteditable]'- ) as HTMLElement | null) ?? null,- e.currentTarget as HTMLElement- );- props.setIsReplying(true);- }}+ getFocusTarget={() =>+ replyInputContainerRef?.querySelector<HTMLElement>(+ '[contenteditable]'+ ) ?? null+ }+ onClick={() => props.setIsReplying(true)}aria-label="Reply"/></Show>diff --git a/js/app/packages/channel/Thread/ThreadReplyAuthor.tsx b/js/app/packages/channel/Thread/ThreadReplyAuthor.tsxindex 0b9b90f904..7425a86728 100644--- a/js/app/packages/channel/Thread/ThreadReplyAuthor.tsx+++ b/js/app/packages/channel/Thread/ThreadReplyAuthor.tsx@@ -7,7 +7,7 @@ type ThreadReplyAuthorProps = {export function ThreadReplyAuthor(props: ThreadReplyAuthorProps) {return (- <div class="flex items-start gap-2 p-2">+ <div class="flex items-start gap-2 pt-2 pl-2 pr-2"><div class="flex-shrink-0 size-[var(--user-icon-width)]"><UserIcon id={props.userId} size="fill" /></div>diff --git a/js/app/packages/channel/Thread/ThreadReplyButton.tsx b/js/app/packages/channel/Thread/ThreadReplyButton.tsxindex c683c6a1fa..e528c303af 100644--- a/js/app/packages/channel/Thread/ThreadReplyButton.tsx+++ b/js/app/packages/channel/Thread/ThreadReplyButton.tsx@@ -1,11 +1,14 @@+import { focusInput } from '@core/directive/focusInput';import IconPlus from '@icon/regular/plus.svg';import { cn } from '@ui/utils/classname';import { splitProps, type JSX } from 'solid-js';-type ThreadReplyButtonProps = JSX.ButtonHTMLAttributes<HTMLButtonElement>;+type ThreadReplyButtonProps = JSX.ButtonHTMLAttributes<HTMLButtonElement> & {+ getFocusTarget?: () => HTMLElement | null | undefined;+};export function ThreadReplyButton(props: ThreadReplyButtonProps) {- const [local, rest] = splitProps(props, ['class']);+ const [local, rest] = splitProps(props, ['class', 'getFocusTarget']);return (<button@@ -14,6 +17,10 @@ export function ThreadReplyButton(props: ThreadReplyButtonProps) {'w-min icon-plus allow-css-brackets mb-2 border border-edge-muted bg-menu hover:bg-hover hover-transition-bg flex flex-row justify-center items-center size-[var(--user-icon-width)] touch:min-h-[var(--user-icon-width)] touch:min-w-[var(--user-icon-width)] text-ink-muted',local.class)}+ ref={(el) => {+ const getTarget = local.getFocusTarget;+ if (getTarget) focusInput(el, () => ({ getTarget }));+ }}{...rest}><IconPlus class="size-1/2" />diff --git a/js/app/packages/channel/Thread/ThreadReplyInput.tsx b/js/app/packages/channel/Thread/ThreadReplyInput.tsxindex b686fb0026..7db30c805f 100644--- a/js/app/packages/channel/Thread/ThreadReplyInput.tsx+++ b/js/app/packages/channel/Thread/ThreadReplyInput.tsx@@ -51,7 +51,7 @@ export function ThreadReplyInput(props: ThreadReplyInputProps) {style={{ 'margin-left': replyInputOffsetX }}ref={(el) => props.setReplyInputEl?.(el)}data-reply-input- data-reply-input-id={props.messageId}+ data-inline-input-container-id={props.messageId}><ThreadReplyInputConnector />{(() => {diff --git a/js/app/packages/channel/scroll-utils.ts b/js/app/packages/channel/scroll-utils.tsindex 035e4dcd1a..873136184b 100644--- a/js/app/packages/channel/scroll-utils.ts+++ b/js/app/packages/channel/scroll-utils.ts@@ -6,7 +6,7 @@ function getMessageElement(messageId: string) {function getReplyInputElement(messageId: string) {return document.querySelector<HTMLElement>(- `[data-reply-input-id="${messageId}"]`+ `[data-inline-input-container-id="${messageId}"]`);}@@ -19,7 +19,7 @@ function isElementInView(element: HTMLElement) {return rect.top >= 0 && rect.bottom <= window.innerHeight;}-function scrollIntoViewIfNeeded(element: HTMLElement) {+export function scrollIntoViewIfNeeded(element: HTMLElement) {if (isElementInView(element)) return false;element.scrollIntoView({ block: 'nearest' });return true;@@ -48,25 +48,20 @@ export function scrollReplyInputIntoView(messageId: string) {}/**- * Scrolls the channel's scroll container so the reply input is not hidden+ * Scrolls the channel's scroll container so the given element is not hidden* behind the virtual keyboard. Call this after the keyboard has appeared and- * its height is known. If the input's bottom edge falls within `keyboardHeight`- * pixels of the windows bottom edge, the container is scrolled up- * by the overlap.+ * its height is known.*/-export function scrollReplyInputAboveKeyboard(- messageId: string,+export function scrollElementAboveKeyboard(+ el: HTMLElement,keyboardHeight: number): boolean {if (keyboardHeight <= 0) return false;- const inputEl = getReplyInputElement(messageId);- if (!inputEl) return false;-- const scrollContainer = getChannelScrollElement(inputEl);+ const scrollContainer = getChannelScrollElement(el);if (!scrollContainer) return false;- const inputRect = inputEl.getBoundingClientRect();+ const inputRect = el.getBoundingClientRect();const containerRect = scrollContainer.getBoundingClientRect();// The keyboard rises from the bottom of the screen, so the visible bottom of// the scroll container is capped at (screen bottom - keyboard height).diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsxindex 451e145b4d..12865425c2 100644--- a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx@@ -37,6 +37,7 @@ import { EmojiMenu } from '../component/menu/EmojiMenu';import { FloatingLinkMenu } from '../component/menu/FloatingLinkMenu';import { MentionsMenu } from '../component/menu/MentionsMenu';import { ActionMenu } from '../component/menu/ActionsMenu';+import { isMobile } from '@core/mobile/isMobile';import type { EditorBuilder, EditorComponentProps } from './types';export const MarkdownShell: Component<@@ -178,7 +179,7 @@ export const MarkdownShell: Component<on:keydown={(e) => e.stopPropagation()}on:click={(e) => {e.stopPropagation();- editor.focus();+ if (!isMobile()) editor.focus();}}on:mousedown={(e) => e.stopPropagation()}on:mouseup={(e) => e.stopPropagation()}diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/ios-cursor-scroll/iosCursorScrollPlugin.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/ios-cursor-scroll/iosCursorScrollPlugin.tsindex 4d2dbb81e5..a370dd97fe 100644--- a/js/app/packages/core/component/LexicalMarkdown/plugins/ios-cursor-scroll/iosCursorScrollPlugin.ts+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/ios-cursor-scroll/iosCursorScrollPlugin.ts@@ -3,7 +3,10 @@* When the keyboard appears or the cursor moves into the safe zone near the* keyboard, this scrolls the cursor into view.*/-import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';+import {+ virtualKeyboardHeight,+ virtualKeyboardVisible,+} from '@core/mobile/virtualKeyboard';import type { Accessor } from 'solid-js';import type { LexicalEditor } from 'lexical';import { createEffect, createRoot, on } from 'solid-js';@@ -28,7 +31,15 @@ export function iosCursorScrollPlugin(options: IosCursorScrollPluginOptions) {if (!caretRect) return;const scrollRect = scrollEl.getBoundingClientRect();- const safeZoneBottom = scrollRect.bottom - CURSOR_PADDING;+ // Cap the safe zone at the visual viewport bottom minus any native keyboard+ // height. On iOS web, visualViewport.height already reflects the reduced+ // viewport. On native mobile, virtualKeyboardHeight() holds the keyboard+ // height that isn't reflected in the visual viewport.+ const viewportBottom =+ (window.visualViewport?.height ?? window.innerHeight) -+ virtualKeyboardHeight();+ const safeZoneBottom =+ Math.min(scrollRect.bottom, viewportBottom) - CURSOR_PADDING;if (caretRect.bottom > safeZoneBottom) {const scrollAmount = caretRect.bottom - safeZoneBottom;diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex b5461445a6..73548a7f83 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -270,12 +270,19 @@ export const ENABLE_EMAIL_SCHEDULED_SEND = resolveFeatureFlag(true);+export const ENABLE_AI_AUTO_TAB_ATTACHMENTS = resolveFeatureFlag(+ 'ENABLE_AI_AUTO_TAB_ATTACHMENTS',+ true+);+export const ENABLE_FEATURED_SEARCH_RESULTS = resolveFeatureFlag('ENABLE_FEATURED_SEARCH_RESULTS',true);-const ENABLE_NEW_CHANNELS_OVERRIDE = true;+const ENABLE_NEW_CHANNELS_OVERRIDE = getFeatureFlagOverride(+ 'ENABLE_NEW_CHANNELS'+);export function ENABLE_NEW_CHANNELS(): boolean {if (ENABLE_NEW_CHANNELS_OVERRIDE !== undefined) {diff --git a/js/app/packages/core/directive/focusInput.ts b/js/app/packages/core/directive/focusInput.tsnew file mode 100644index 0000000000..94d6ecedca--- /dev/null+++ b/js/app/packages/core/directive/focusInput.ts@@ -0,0 +1,96 @@+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { isPlatform } from '@core/util/platform';+import { isIOS } from '@solid-primitives/platform';+import { type Accessor, onCleanup } from 'solid-js';++export type FocusInputOptions = {+ getTarget: () => HTMLElement | null | undefined;+ positionNear?: HTMLElement;+};++declare module 'solid-js' {+ namespace JSX {+ interface Directives {+ focusInput: FocusInputOptions;+ }+ }+}++/**+ * Focuses a target input when the host element is clicked.+ *+ * Pass a callback to the target element — it need not exist in the DOM at click+ * time. If the element is already visible, it is focused immediately. Otherwise+ * a MutationObserver waits for it to appear and focuses it once visible.+ *+ * The reason for this function to exist is that on iOS we have to perform a+ * disgusting workaround to accomplish this behavior. The virtual keyboard is+ * only allowed to appear synchronously, in response to user interaction. So,+ * if the target input does not currently exist, we have to create a temporary+ * input to focus immediately, then transfer focus to the real target once it+ * appears in the DOM.+ */+export function focusInput(+ el: HTMLElement,+ options: Accessor<FocusInputOptions>+) {+ const { getTarget, positionNear } = options();+ const anchor = positionNear ?? el;++ const handleClick = () => {+ const target = getTarget();+ if (target && isVisible(target)) {+ target.focus();+ return;+ }++ let observer: MutationObserver | undefined;+ let timeoutId: ReturnType<typeof setTimeout> | undefined;+ let tempEl: HTMLInputElement | undefined;++ function cleanup() {+ if (timeoutId !== undefined) clearTimeout(timeoutId);+ if (tempEl && document.body.contains(tempEl))+ document.body.removeChild(tempEl);+ observer?.disconnect();+ window.removeEventListener('beforeunload', cleanup);+ }++ function focusTargetAndCleanup() {+ getTarget()?.focus();+ cleanup();+ }++ if ((isTouchDevice() && isIOS) || isPlatform('ios')) {+ // iOS only: focus a hidden temporary input synchronously within the+ // click gesture so the virtual keyboard opens, then transfer focus to+ // the real target once it appears in the DOM.+ tempEl = document.createElement('input');+ tempEl.style.position = 'absolute';+ tempEl.style.top = `${(anchor.offsetTop ?? 0) + 7}px`;+ tempEl.style.left = `${anchor.offsetLeft ?? 0}px`;+ tempEl.style.height = '0';+ tempEl.style.opacity = '0';+ tempEl.style.fontSize = '16px';+ document.body.appendChild(tempEl);+ tempEl.focus();+ }++ observer = new MutationObserver(() => {+ const current = getTarget();+ if (current && isVisible(current)) focusTargetAndCleanup();+ });+ observer.observe(document.body, { childList: true, subtree: true });++ timeoutId = setTimeout(cleanup, 5000);+ window.addEventListener('beforeunload', cleanup, { once: true });+ };++ el.addEventListener('click', handleClick);+ onCleanup(() => el.removeEventListener('click', handleClick));+}++// Naively checks if element is visible. E.g. will not catch elements with `position: fixed`. We can make this more complex when needed.+function isVisible(el: HTMLElement): boolean {+ return el.offsetParent !== null;+}diff --git a/js/app/packages/core/directive/longPressHighlight.ts b/js/app/packages/core/directive/longPressHighlight.tsnew file mode 100644index 0000000000..47f10b170b--- /dev/null+++ b/js/app/packages/core/directive/longPressHighlight.ts@@ -0,0 +1,71 @@+import { type Accessor, onCleanup } from 'solid-js';+import { touchHandler } from './touchHandler';++export interface LongPressHighlightOptions {+ onLongPress?: () => void;+ /** Delay (ms) before adding the `long-press-animation` class on touch start. If touch ends before this delay, no exit animation plays. Default: 100 */+ enterDelay?: number;+ /** Delay (ms) before removing the `long-press-animation` class after a long press. Default: 50 */+ exitDelay?: number;+}++declare module 'solid-js' {+ namespace JSX {+ interface Directives {+ longPressHighlight: LongPressHighlightOptions;+ }+ }+}++/**+ * Wraps touchHandler to manage the `long-press-animation` CSS class lifecycle on an element.+ * Pair with the corresponding CSS animation on `.long-press-animation`.+ */+export function longPressHighlight(+ element: HTMLElement,+ options: Accessor<LongPressHighlightOptions>+) {+ let enterTimer: number | undefined;++ const startAnimation = () => {+ enterTimer = undefined;+ element.classList.add('long-press-animation');+ };++ const cancelEnter = () => {+ if (enterTimer !== undefined) {+ clearTimeout(enterTimer);+ enterTimer = undefined;+ }+ };++ const endAnimation = () => {+ element.classList.remove('long-press-animation');+ };++ touchHandler(element, () => ({+ onTouchStart: () => {+ enterTimer = window.setTimeout(+ startAnimation,+ options().enterDelay ?? 100+ );+ },+ onLongPress: () => {+ options().onLongPress?.();+ },+ onCancel: () => {+ cancelEnter();+ endAnimation();+ },+ onTouchEnd: (_e, longpress) => {+ cancelEnter();+ if (!longpress) {+ endAnimation();+ } else {+ setTimeout(endAnimation, options().exitDelay ?? 50);+ }+ },+ }));++ onCleanup(cancelEnter);+}diff --git a/js/app/packages/core/directive/touchHandler.ts b/js/app/packages/core/directive/touchHandler.tsindex 1dab5df81b..6584b50782 100644--- a/js/app/packages/core/directive/touchHandler.ts+++ b/js/app/packages/core/directive/touchHandler.ts@@ -1,12 +1,15 @@-import { type Accessor, createSignal, type JSX, onCleanup } from 'solid-js';+import { type Accessor, createSignal, onCleanup } from 'solid-js';import { hapticImpact } from '@core/mobile/haptics';export interface TouchHandlerOptions {- onLongPress?: JSX.EventHandler<HTMLElement, TouchEvent>;- onShortTouch?: JSX.EventHandler<HTMLElement, TouchEvent>;+ onLongPress?: (e: TouchEvent) => void;+ onTouchStart?: (e: TouchEvent) => void;+ onShortTouch?: (e: TouchEvent) => void;onCancel?: () => void;+ onTouchEnd?: (e: TouchEvent, longPressTriggered: boolean) => void;delay?: number;moveThreshold?: number;+ stopTouchStartPropagation?: boolean;}declare module 'solid-js' {@@ -18,7 +21,7 @@ declare module 'solid-js' {}/**- * This signal is used to check if a long press is currently active.+ * This global signal can be used to check if a long press is currently active.* For example, it is used to prevent the clickOutside directive from triggering when a long press is active.*/export const [longPressActivated, setLongPressActivated] = createSignal(false);@@ -30,9 +33,9 @@ export const [longPressActivated, setLongPressActivated] = createSignal(false);*/export function touchHandler(element: HTMLElement,- props: Accessor<TouchHandlerOptions>+ options: Accessor<TouchHandlerOptions>) {- if (!props().onLongPress && !props().onShortTouch) {+ if (!options().onLongPress && !options().onShortTouch) {return;}@@ -48,31 +51,48 @@ export function touchHandler(return Math.sqrt(deltaX * deltaX + deltaY * deltaY);}- function cancel() {+ function clearState() {if (timer) {clearTimeout(timer);timer = 0;}startPosition = undefined;+ longPressTriggered = false;setLongPressActivated(false);- props().onCancel?.();}- function handleTouchStart(e: TouchEvent) {- if (e.touches.length > 1) return;+ function initStateForNewTouch() {+ clearState();setValidShortTouch(true);+ }++ function handleTouchCancel() {+ clearState();+ options().onCancel?.();+ }++ function handleTouchStart(e: TouchEvent) {+ if (e.touches.length > 1) {+ clearState();+ setValidShortTouch(false);+ return;+ }+ initStateForNewTouch();const touch = e.touches[0];startPosition = { x: touch.clientX, y: touch.clientY };+ if (options().stopTouchStartPropagation) {+ e.stopPropagation();+ }++ options().onTouchStart?.(e);timer = window.setTimeout(() => {longPressTriggered = true;setLongPressActivated(true);hapticImpact('medium');- props().onLongPress?.(- e as TouchEvent & { currentTarget: HTMLElement; target: Element }- );- }, props().delay ?? 500);+ options().onLongPress?.(e);+ }, options().delay ?? 500);}function handleTouchMove(e: TouchEvent) {@@ -81,13 +101,15 @@ export function touchHandler(const touch = e.touches[0];const distance = getDistance(touch.clientX, touch.clientY);- if (distance > (props().moveThreshold ?? 10)) {+ if (distance > (options().moveThreshold ?? 10)) {setValidShortTouch(false);- cancel();+ handleTouchCancel();}}function handleTouchEnd(e: TouchEvent) {+ options().onTouchEnd?.(e, longPressTriggered);+const isAnchorElement = (e.target as Element)?.closest('a');const isButtonElement = (e.target as Element)?.closest('button');const isDocumentMention = (e.target as Element)?.closest(@@ -95,38 +117,27 @@ export function touchHandler();const isInternalLink = (e.target as Element)?.closest('[internal-link]');+ const touchedSomethingSharp =+ isAnchorElement || isButtonElement || isDocumentMention || isInternalLink;+if (longPressTriggered) {e.stopPropagation();- longPressTriggered = false;- } else if (validShortTouch() && !longPressTriggered) {- if (- !isAnchorElement &&- !isButtonElement &&- !isDocumentMention &&- !isInternalLink- ) {- props().onShortTouch?.(- e as TouchEvent & { currentTarget: HTMLElement; target: Element }- );- }- setValidShortTouch(false);- cancel();- } else {- cancel();+ e.preventDefault();+ } else if (validShortTouch() && !touchedSomethingSharp) {+ options().onShortTouch?.(e);}- setLongPressActivated(false);+ clearState();}element.addEventListener('touchstart', handleTouchStart, { passive: true });element.addEventListener('touchmove', handleTouchMove, { passive: true });- element.addEventListener('touchend', handleTouchEnd, { passive: true });- element.addEventListener('touchcancel', handleTouchEnd, { passive: true });+ element.addEventListener('touchend', handleTouchEnd);+ element.addEventListener('touchcancel', handleTouchCancel, { passive: true });onCleanup(() => {element.removeEventListener('touchstart', handleTouchStart);element.removeEventListener('touchmove', handleTouchMove);element.removeEventListener('touchend', handleTouchEnd);- element.removeEventListener('touchcancel', handleTouchEnd);- cancel();+ element.removeEventListener('touchcancel', handleTouchCancel);});}diff --git a/js/app/packages/core/mobile/focus-and-open-keyboard.ts b/js/app/packages/core/mobile/focus-and-open-keyboard.tsdeleted file mode 100644index 18a7460374..0000000000--- a/js/app/packages/core/mobile/focus-and-open-keyboard.ts+++ /dev/null@@ -1,66 +0,0 @@-// Source - adapted from https://stackoverflow.com/a/76838650--import { isMobile } from '@core/mobile/isMobile';--/**- * iOS only: focuses a temporary input element to open the keyboard within the- * user gesture, then transfers focus to the real target once it appears in the- * DOM. Pass a lazy getter for the target element — it need not exist at call- * time. `positionNear` positions the temp input to prevent cursor jumping.- *- * No-op on non-mobile platforms.- */-export function focusAndOpenKeyboard(- getEl: () => HTMLElement | null | undefined,- positionNear?: HTMLElement | null-) {- if (!isMobile()) return;-- const tempEl = document.createElement('input');- let observer: MutationObserver | undefined;- let timeoutId: ReturnType<typeof setTimeout> | undefined;-- function cleanup() {- if (timeoutId !== undefined) clearTimeout(timeoutId);- if (document.body.contains(tempEl)) document.body.removeChild(tempEl);- observer?.disconnect();- window.removeEventListener('beforeunload', cleanup);- }-- function focusOnElementAndCleanup() {- getEl()?.focus();- cleanup();- }-- function focusOnDummyElementToOpenIOSKeyboard() {- tempEl.style.position = 'absolute';- tempEl.style.top = `${(positionNear?.offsetTop ?? 0) + 7}px`;- tempEl.style.left = `${positionNear?.offsetLeft ?? 0}px`;- tempEl.style.height = '0';- tempEl.style.opacity = '0';- tempEl.style.fontSize = '16px';- document.body.appendChild(tempEl);- tempEl.focus();- }-- const el = getEl();- if (el && isVisible(el)) {- el.focus();- return;- }-- focusOnDummyElementToOpenIOSKeyboard();-- observer = new MutationObserver(() => {- const current = getEl();- if (current && isVisible(current)) focusOnElementAndCleanup();- });- observer.observe(document.body, { childList: true, subtree: true });-- timeoutId = setTimeout(cleanup, 5000);- window.addEventListener('beforeunload', cleanup, { once: true });-}--function isVisible(el: HTMLElement): boolean {- return el.offsetParent !== null;-}