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): center AI input box (#1066)

Eric Hayes5fd3b2e73d38
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsx
index b3147d89ed..e2a35d53a5 100644
--- a/js/app/packages/app/component/Soup.tsx
+++ b/js/app/packages/app/component/Soup.tsx
@@ -55,6 +55,7 @@ import {
Switch,
} from 'solid-js';
import { PreviewPanel } from './PreviewPanel';
+import { SoupChatInput } from './SoupChatInput';
import { SuspenseContextComp } from './SuspenseContext';
import {
SplitHeaderLeft,
@@ -768,6 +769,7 @@ export function Soup() {
/>
</Show>
</div>
+ <SoupChatInput />
</div>
);
}
diff --git a/js/app/packages/app/component/SoupChatInput.tsx b/js/app/packages/app/component/SoupChatInput.tsx
new file mode 100644
index 0000000000..aa4a412767
--- /dev/null
+++ b/js/app/packages/app/component/SoupChatInput.tsx
@@ -0,0 +1,57 @@
+import { useChatInput } from '@core/component/AI/component/input/useChatInput';
+import { setPendingSendData } from '@core/component/AI/signal/pendingSend';
+import type {
+ Attachment,
+ CreateAndSend,
+ Model,
+ Send,
+} from '@core/component/AI/types';
+import { useBigChat } from '@core/signal/layout';
+
+export function SoupChatInput() {
+ const [, setBigChatOpen] = useBigChat();
+
+ const { ChatInput, chatMarkdownArea, attachments, model } = useChatInput();
+
+ // Store content before send since ChatInput clears it before calling onSend
+ let pendingContent = '';
+ let pendingAttachments: Attachment[] = [];
+ let pendingModel: Model;
+
+ // Track changes to capture content before it's cleared
+ const captureState = () => {
+ pendingContent = chatMarkdownArea.markdownText();
+ pendingAttachments = attachments.attached();
+ pendingModel = model();
+ };
+
+ const handleSend = (_request: Send | CreateAndSend) => {
+ // Store the captured data for the rightbar to pick up
+ if (pendingContent) {
+ setPendingSendData({
+ content: pendingContent,
+ attachments: pendingAttachments,
+ model: pendingModel,
+ });
+ }
+
+ // Open bigchat - it will pick up the pending send
+ setBigChatOpen(true);
+ };
+
+ return (
+ <div
+ class="absolute bottom-2 left-1/2 -translate-x-1/2 w-full max-w-3xl z-10 pointer-events-none"
+ onKeyDown={captureState}
+ onClick={captureState}
+ >
+ <div class="pointer-events-auto">
+ <ChatInput
+ onSend={handleSend}
+ isPersistent={true}
+ autoFocusOnMount={false}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/js/app/packages/app/component/rightbar/Rightbar.tsx b/js/app/packages/app/component/rightbar/Rightbar.tsx
index a758adf2ec..e68a68a600 100644
--- a/js/app/packages/app/component/rightbar/Rightbar.tsx
+++ b/js/app/packages/app/component/rightbar/Rightbar.tsx
@@ -2,8 +2,10 @@ import { globalSplitManager } from '@app/signal/splitLayout';
import { useIsAuthenticated } from '@core/auth';
import { AiChatEmptyState } from '@core/component/AI/component/AIChatEmptyState';
import { DragDropWrapper } from '@core/component/AI/component/DragDrop';
+import { useBuildChatSendRequest } from '@core/component/AI/component/input/buildRequest';
import { useChatInput } from '@core/component/AI/component/input/useChatInput';
import { ChatMessages } from '@core/component/AI/component/message/ChatMessages';
+import { getPendingSend } from '@core/component/AI/signal/pendingSend';
import { registerToolHandler } from '@core/component/AI/signal/tool';
import type {
Attachment,
@@ -566,6 +568,28 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {
}
};
+ const buildChatSendRequest = useBuildChatSendRequest();
+
+ // Check for pending sends from SoupChatInput when bigchat opens
+ createEffect(
+ on(bigChatOpen, async (isOpen, wasOpen) => {
+ if (isOpen && !wasOpen) {
+ const pending = getPendingSend();
+ if (pending) {
+ // Build and send the request
+ const request = await buildChatSendRequest({
+ chatId: chatId(),
+ userRequest: pending.content,
+ attachments: pending.attachments,
+ model: pending.model,
+ isPersistent: true,
+ });
+ onSend(request);
+ }
+ }
+ })
+ );
+
// load chat state
createEffect(
on(chatId, (chatId_) => {
diff --git a/js/app/packages/core/component/AI/signal/pendingSend.test.ts b/js/app/packages/core/component/AI/signal/pendingSend.test.ts
new file mode 100644
index 0000000000..2ab59e44ed
--- /dev/null
+++ b/js/app/packages/core/component/AI/signal/pendingSend.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, test } from 'vitest';
+import {
+ getPendingSend,
+ setPendingSendData,
+ type PendingSend,
+} from './pendingSend';
+
+describe('pendingSend signal', () => {
+ test('setPendingSendData stores pending send data', () => {
+ const data: PendingSend = {
+ content: 'Test message',
+ attachments: [],
+ model: 'claude-haiku-4-5' as any,
+ };
+
+ setPendingSendData(data);
+ const result = getPendingSend();
+
+ expect(result).toEqual(data);
+ });
+
+ test('getPendingSend clears data after retrieval', () => {
+ const data: PendingSend = {
+ content: 'Test message',
+ attachments: [],
+ model: 'claude-haiku-4-5' as any,
+ };
+
+ setPendingSendData(data);
+ getPendingSend();
+ const secondCall = getPendingSend();
+
+ expect(secondCall).toBeNull();
+ });
+
+ test('getPendingSend returns null when no data is set', () => {
+ const result = getPendingSend();
+ expect(result).toBeNull();
+ });
+
+ test('setPendingSendData with attachments and model', () => {
+ const data: PendingSend = {
+ content: 'Message with attachment',
+ attachments: [
+ {
+ id: 'attach-1',
+ type: 'file',
+ name: 'test.pdf',
+ size: 1024,
+ created_at: '2025-01-01T00:00:00Z',
+ } as any,
+ ],
+ model: 'claude-opus-4-5' as any,
+ };
+
+ setPendingSendData(data);
+ const result = getPendingSend();
+
+ expect(result?.content).toBe('Message with attachment');
+ expect(result?.attachments).toHaveLength(1);
+ expect(result?.model).toBe('claude-opus-4-5');
+ });
+});
diff --git a/js/app/packages/core/component/AI/signal/pendingSend.ts b/js/app/packages/core/component/AI/signal/pendingSend.ts
new file mode 100644
index 0000000000..973ef8ec9a
--- /dev/null
+++ b/js/app/packages/core/component/AI/signal/pendingSend.ts
@@ -0,0 +1,24 @@
+import type { Attachment, Model } from '@core/component/AI/types';
+import { createSignal } from 'solid-js';
+
+export type PendingSend = {
+ content: string;
+ attachments: Attachment[];
+ model: Model;
+};
+
+const [pendingSend, setPendingSend] = createSignal<PendingSend | null>(null);
+
+export function getPendingSend(): PendingSend | null {
+ const pending = pendingSend();
+ if (pending) {
+ // Clear it once retrieved
+ setPendingSend(null);
+ return pending;
+ }
+ return null;
+}
+
+export function setPendingSendData(send: PendingSend): void {
+ setPendingSend(send);
+}