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(ai): mcp empty state (#2344)

Eric Hayes6e3f428d9bab
diff --git a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
index fecd2345aa..b07c4bacf8 100644
--- a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
+++ b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
@@ -1,43 +1,137 @@
-import { modifierMap } from '@core/component/Hotkey';
-import { Show } from 'solid-js';
-import { useOpenInstructionsMd } from '../util/instructions';
-import { isMobile } from '@core/mobile/isMobile';
+import CheckIcon from '@phosphor-icons/core/bold/check-bold.svg?component-solid';
+import ClipboardIcon from '@phosphor-icons/core/bold/clipboard-bold.svg?component-solid';
+import { Button } from '@ui/components/Button';
+import { createSignal, For } from 'solid-js';
+
+const MACRO_MCP_CONFIG = JSON.stringify(
+ {
+ mcpServers: {
+ macro: {
+ type: 'http',
+ url: 'https://mcp-server.macro.com/mcp',
+ },
+ },
+ },
+ null,
+ 2
+);
+
+const CLAUDE_CODE_COMMAND =
+ 'claude mcp add --transport http macro https://mcp-server.macro.com/mcp';
+
+const CODEX_CLI_COMMAND =
+ 'codex mcp add macro --url https://mcp-server.macro.com/mcp';
+
+const CLI_COMMANDS = [
+ {
+ key: 'claude-cli',
+ label: 'Claude Code',
+ command: CLAUDE_CODE_COMMAND,
+ },
+ {
+ key: 'codex-cli',
+ label: 'Codex CLI',
+ command: CODEX_CLI_COMMAND,
+ },
+] as const;
export function AiChatEmptyState() {
- const openInstructions = useOpenInstructionsMd();
+ const [copiedKey, setCopiedKey] = createSignal<string | null>(null);
+
+ const handleCopy = async (key: string, text: string) => {
+ try {
+ await navigator.clipboard.writeText(text);
+ setCopiedKey(key);
+ setTimeout(
+ () => setCopiedKey((current) => (current === key ? null : current)),
+ 2000
+ );
+ } catch (err) {
+ console.error('Failed to copy MCP setup instructions', err);
+ }
+ };
+
return (
- <div class="relative p-2 border border-edge-muted bg-dialog text-sm flex flex-col gap-2 text-ink macro-message-margin">
- <Show when={!isMobile()}>
- <div class="grid justify-start grid-cols-[max-content_auto] gap-y-1 grid-template items-center">
- <span class="p-1 bg-accent text-panel mr-2 text-center">@</span>
- <span>To attach, files, emails, and channel</span>
- </div>
- <div class="grid justify-start grid-cols-[max-content_auto] gap-y-1 grid-template items-center">
- <span class="p-1 bg-accent text-panel mr-2 text-center">Enter</span>
- <span>To chat with Haiku</span>
+ <div class="macro-message-margin w-full max-w-[760px] rounded-md border border-edge-muted bg-dialog/95 p-4 text-ink shadow-lg shadow-[#000]/5 backdrop-blur-sm md:p-5">
+ <div class="flex flex-col gap-4">
+ <div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
+ <div class="min-w-0">
+ <div class="mb-2 inline-flex items-center rounded-xs border border-accent/20 bg-accent/10 px-2 py-1 text-xs text-accent">
+ Macro MCP
+ </div>
+ <h2 class="text-xl leading-tight">Connect AI to Macro</h2>
+ <p class="mt-2 max-w-[56ch] text-sm leading-6 text-ink-muted">
+ Use macro with your favorite AI chat client or code editor
+ </p>
+ </div>
</div>
- <div class="grid justify-start grid-cols-[max-content_auto] gap-y-1 grid-template items-center">
- <span class="p-1 bg-accent text-panel mr-2 text-center">
- {modifierMap.cmd} + Enter
- </span>
- <span>To chat with Opus</span>
+
+ <div class="grid gap-3">
+ <For each={CLI_COMMANDS}>
+ {(item) => (
+ <div class="overflow-hidden rounded-md border border-edge-muted bg-input/70">
+ <div class="flex items-center justify-between gap-3 border-b border-edge-muted px-4 py-2">
+ <span class="text-sm text-ink-muted">{item.label}</span>
+ <Button
+ variant={copiedKey() === item.key ? 'secondary' : 'ghost'}
+ size="sm"
+ class="shrink-0"
+ onClick={() => handleCopy(item.key, item.command)}
+ >
+ {copiedKey() === item.key ? (
+ <>
+ <CheckIcon class="size-3.5" />
+ Copied
+ </>
+ ) : (
+ <>
+ <ClipboardIcon class="size-3.5" />
+ Copy
+ </>
+ )}
+ </Button>
+ </div>
+ <pre class="overflow-x-auto px-4 py-3 text-[12px] leading-5 text-ink select-text cursor-text whitespace-pre-wrap break-all">
+ <code>{item.command}</code>
+ </pre>
+ </div>
+ )}
+ </For>
</div>
- <div class="grid justify-start grid-cols-[max-content_auto] gap-y-1 grid-template items-center">
- <span class="p-1 bg-accent text-panel mr-2 text-center">
- {modifierMap.ctrl} + C
- </span>
- <span>To Stop generating</span>
+
+ <div class="overflow-hidden rounded-md border border-edge-muted bg-input/70">
+ <div class="flex items-center justify-between gap-3 border-b border-edge-muted px-4 py-2">
+ <span class="text-sm text-ink-muted">
+ Or configure in your favorite IDE
+ </span>
+ <div class="flex items-center gap-3">
+ <span class="text-xs text-ink-muted">
+ Paste under `mcpServers`
+ </span>
+ <Button
+ variant={copiedKey() === 'json' ? 'secondary' : 'ghost'}
+ size="sm"
+ class="shrink-0"
+ onClick={() => handleCopy('json', MACRO_MCP_CONFIG)}
+ >
+ {copiedKey() === 'json' ? (
+ <>
+ <CheckIcon class="size-3.5" />
+ Copied
+ </>
+ ) : (
+ <>
+ <ClipboardIcon class="size-3.5" />
+ Copy
+ </>
+ )}
+ </Button>
+ </div>
+ </div>
+ <pre class="overflow-x-auto px-4 py-4 text-[12px] leading-5 text-ink select-text cursor-text">
+ <code>{MACRO_MCP_CONFIG}</code>
+ </pre>
</div>
- </Show>
- <div>
- Change the
- <span
- class="font-medium text-accent underline mx-1"
- onClick={openInstructions}
- >
- Instructions
- </span>
- to feed AI some basic context on what you do, who you work with, etc
</div>
</div>
);
diff --git a/js/app/packages/core/component/AI/component/message/ChatMessages.tsx b/js/app/packages/core/component/AI/component/message/ChatMessages.tsx
index fe879b286c..45947f6ea7 100644
--- a/js/app/packages/core/component/AI/component/message/ChatMessages.tsx
+++ b/js/app/packages/core/component/AI/component/message/ChatMessages.tsx
@@ -3,6 +3,8 @@ import type { ChatMessageWithAttachments } from '@core/component/AI/types';
import { asChatMessage } from '@core/component/AI/util/message';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { aiChatTheme } from '@core/component/LexicalMarkdown/theme';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { isMobileWidth } from '@core/mobile/mobileWidth';
import { PulsingStar } from '@entity/components/PulsingStar';
import { createElementSize } from '@solid-primitives/resize-observer';
import type { Accessor, JSXElement } from 'solid-js';
@@ -20,6 +22,7 @@ import {
import { createStore } from 'solid-js/store';
import { idStream, timeStream } from '../../util/stream/extendedStream';
import { AssistantMessage } from './AssistantMessage';
+import { EmptyChatState } from './EmptyChatState';
import { UserMessage } from './UserMessage';
export type MessageActions = {};
@@ -191,87 +194,103 @@ export function ChatMessages(props: ChatMessagesProps) {
};
const activeIdSelector = createSelector(activeTargetMessageId);
+ const isEmptyChat = () =>
+ messages().length === 0 &&
+ !isMobileWidth() &&
+ !isTouchDevice() &&
+ !isStream() &&
+ !chat.isWaiting() &&
+ !generatingMessage();
return (
<StaticMarkdownContext theme={aiChatTheme}>
<div class="relative flex flex-col w-full px-2 gap-y-2" ref={messagesRef}>
- <For each={allButLastMessagePair()}>
- {(msg) => (
- <div
- id={'chat-' + msg.id}
- class="w-full transition-colors duration-300"
- classList={{
- 'bg-accent': activeIdSelector(msg.id),
- }}
- >
- <Switch>
- <Match when={msg.role === 'user'}>
- <UserMessage message={msg} />
- </Match>
- <Match when={msg.role === 'assistant'}>
- <AssistantMessage
- message={msg}
- ttft={messageTimingMap[msg.id]}
- />
- </Match>
- </Switch>
- </div>
- )}
- </For>
+ <Show
+ when={isEmptyChat()}
+ fallback={
+ <>
+ <For each={allButLastMessagePair()}>
+ {(msg) => (
+ <div
+ id={'chat-' + msg.id}
+ class="w-full transition-colors duration-300"
+ classList={{
+ 'bg-accent': activeIdSelector(msg.id),
+ }}
+ >
+ <Switch>
+ <Match when={msg.role === 'user'}>
+ <UserMessage message={msg} />
+ </Match>
+ <Match when={msg.role === 'assistant'}>
+ <AssistantMessage
+ message={msg}
+ ttft={messageTimingMap[msg.id]}
+ />
+ </Match>
+ </Switch>
+ </div>
+ )}
+ </For>
- <Show when={isStream() || chat.isWaiting() || lastPair()}>
- <div
- class="shrink-0"
- style={{
- 'min-height': `${parentHeight()}px`,
- }}
- >
- <Show when={lastPair()}>
- {(pair) => (
- <For each={pair()}>
- {(msg) => (
- <div
- id={'chat-' + msg.id}
- class="w-full transition-colors duration-300"
- classList={{
- 'bg-accent': activeIdSelector(msg.id),
- }}
+ <Show when={isStream() || chat.isWaiting() || lastPair()}>
+ <div
+ class="shrink-0"
+ style={{
+ 'min-height': `${parentHeight()}px`,
+ }}
+ >
+ <Show when={lastPair()}>
+ {(pair) => (
+ <For each={pair()}>
+ {(msg) => (
+ <div
+ id={'chat-' + msg.id}
+ class="w-full transition-colors duration-300"
+ classList={{
+ 'bg-accent': activeIdSelector(msg.id),
+ }}
+ >
+ <Switch>
+ <Match when={msg.role === 'user'}>
+ <UserMessage message={msg} />
+ </Match>
+ <Match when={msg.role === 'assistant'}>
+ <AssistantMessage
+ message={msg}
+ ttft={messageTimingMap[msg.id]}
+ />
+ </Match>
+ </Switch>
+ </div>
+ )}
+ </For>
+ )}
+ </Show>
+ <Show when={generatingMessage()}>
+ {(msg) => {
+ return (
+ <div id={'chat-' + msg().id}>
+ <AssistantMessage message={msg()} isStreaming />
+ </div>
+ );
+ }}
+ </Show>
+ <Show when={isStream() || chat.isWaiting()}>
+ <OnMount
+ onShow={() =>
+ scrollToBottom(isNearBottom() ? 'instant' : 'smooth')
+ }
>
- <Switch>
- <Match when={msg.role === 'user'}>
- <UserMessage message={msg} />
- </Match>
- <Match when={msg.role === 'assistant'}>
- <AssistantMessage
- message={msg}
- ttft={messageTimingMap[msg.id]}
- />
- </Match>
- </Switch>
- </div>
- )}
- </For>
- )}
- </Show>
- <Show when={generatingMessage()}>
- {(msg) => {
- return (
- <div id={'chat-' + msg().id}>
- <AssistantMessage message={msg()} isStreaming />
- </div>
- );
- }}
- </Show>
- <Show when={isStream() || chat.isWaiting()}>
- <OnMount
- onShow={() =>
- scrollToBottom(isNearBottom() ? 'instant' : 'smooth')
- }
- >
- <PulsingStar kind="streamIndicator" animate />
- </OnMount>
- </Show>
- </div>
+ <PulsingStar kind="streamIndicator" animate />
+ </OnMount>
+ </Show>
+ </div>
+ </Show>
+ </>
+ }
+ >
+ <EmptyChatState minHeight={Math.max(parentHeight(), 420)} />
</Show>
</div>
</StaticMarkdownContext>
diff --git a/js/app/packages/core/component/AI/component/message/EmptyChatState.tsx b/js/app/packages/core/component/AI/component/message/EmptyChatState.tsx
new file mode 100644
index 0000000000..10d578b328
--- /dev/null
+++ b/js/app/packages/core/component/AI/component/message/EmptyChatState.tsx
@@ -0,0 +1,14 @@
+import { AiChatEmptyState } from '../AIChatEmptyState';
+
+export function EmptyChatState(props: { minHeight: number }) {
+ return (
+ <div
+ class="flex w-full items-center justify-center py-6"
+ style={{
+ 'min-height': `${props.minHeight}px`,
+ }}
+ >
+ <AiChatEmptyState />
+ </div>
+ );
+}