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.

1.7 KB
Raw Blame
import { SoupChatInput } from '@app/features/chat/SoupChatInput';
import { activeElement } from '@app/signal/focus';
import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import { isEditableInput } from '@core/util/isEditableInput';
import { Show } from 'solid-js';
import { FloatRegion } from './float-regions/FloatRegion';
import { MobilePageCreateButton } from './MobilePageCreateButton';
import { useForegroundMobileView } from './use-mobile-nav';

/** The page's New action, or an AI composer on the Agents view. */
export function MobilePageActionRow() {
  // Keep the editor and its draft alive while typing elsewhere or while another
  // accessory owns the slot.
  const foregroundView = useForegroundMobileView();
  const showsComposer = () => foregroundView() === 'agents';
  let composerRef: HTMLDivElement | undefined;
  const composer = (
    <Show when={showsComposer()}>
      <div ref={composerRef} class="pointer-events-auto min-w-0 flex-1">
        <SoupChatInput />
      </div>
    </Show>
  );
  const isAvailable = () => {
    if (!showsComposer() && virtualKeyboardVisible()) return false;
    const focused = activeElement();
    return (
      !isEditableInput(focused) ||
      (showsComposer() && !!composerRef?.contains(focused))
    );
  };

  return (
    // Screen composers (0) and search (100) take precedence.
    <FloatRegion region="accessory" priority={-1} active={isAvailable}>
      <div class="group/mobile-composer flex items-end justify-end gap-(--mobile-chrome-gutter) px-(--mobile-chrome-gutter)">
        {composer}
        <div class="shrink-0 empty:hidden group-has-[[data-composer-expanded=true]]/mobile-composer:hidden">
          <MobilePageCreateButton />
        </div>
      </div>
    </FloatRegion>
  );
}