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.

fix(ai): auto attach on create new chat (#679)

Eric Hayes5e912db03e5b
diff --git a/js/app/packages/app/component/rightbar/Rightbar.tsx b/js/app/packages/app/component/rightbar/Rightbar.tsx
index 12d7928708..713b4ec293 100644
--- a/js/app/packages/app/component/rightbar/Rightbar.tsx
+++ b/js/app/packages/app/component/rightbar/Rightbar.tsx
@@ -193,7 +193,7 @@ function TopBar(props: {
<IconButton
size="sm"
icon={PlusIcon}
- tooltip={{ label: 'Start new thread' }}
+ tooltip={{ label: 'Create New Chat' }}
theme="current"
onClick={() => {
createNewRightbarChat();
@@ -322,29 +322,6 @@ export function Rightbar(props: {
props.setState.setModel(model_);
});
- // gone for now may want in future - ehayes 11/17/2025
- // const timeString = () => {
- // const now = new Date().getHours();
- // if (now < 12) {
- // return 'morning';
- // } else if (now < 18) {
- // return 'afternoon';
- // } else {
- // return 'evening';
- // }
- // };
- // const userId = useUserId();
- // const [name] = useDisplayName(userId());
-
- // let greeting = () => {
- // const firstName = name().split(' ').at(0);
- // if (!firstName || firstName.length === 0 || firstName.includes('@')) {
- // return ``;
- // } else {
- // return `Good ${timeString()} ${firstName}, what can I assist you with?`;
- // }
- // };
-
const [editor, setEditor] = createSignal<LexicalEditor>();
let borrowedFocus: Element | null = null;
const returnFocus = () => {
@@ -458,14 +435,15 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {
const [attachHotkeys, scopeId] = useHotkeyDOMScope('ai-right-panel');
const clearChatState = () => {
+ const attached = attachments();
setStream(undefined);
setModel(undefined);
- setAttachments([]);
+ setAttachments(attached);
setText(undefined);
setMessages([]);
setInitialChatState({
model: undefined,
- attachments: [],
+ attachments: attached,
text: undefined,
});
};
diff --git a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
index 3d83d3139a..4045435f98 100644
--- a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
+++ b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx
@@ -9,16 +9,6 @@ export function AiChatEmptyState() {
<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>
- <span class="p-1 bg-accent text-panel mr-2 text-center">Agent</span>
- <span>
- <span>
- Let AI think and search through your files, emails, and channels
- </span>
- </span>
- <span class="p-1 bg-accent text-panel mr-2 text-center">Ask</span>
- <span>
- Quick answers to quick quesions with access to any files @ mentioned
- </span>
</div>
<div>
Change the
diff --git a/js/app/packages/core/component/AI/component/input/SendMessageButton.tsx b/js/app/packages/core/component/AI/component/input/SendMessageButton.tsx
index 2779f76ece..c0b25b9cfa 100644
--- a/js/app/packages/core/component/AI/component/input/SendMessageButton.tsx
+++ b/js/app/packages/core/component/AI/component/input/SendMessageButton.tsx
@@ -1,5 +1,5 @@
+import ArrowUp from '@icon/bold/arrow-up-bold.svg';
import StopIcon from '@phosphor-icons/core/bold/stop-bold.svg?component-solid';
-import ArrowFatLineUp from '@phosphor-icons/core/fill/arrow-fat-line-up-fill.svg?component-solid';
import type { Accessor } from 'solid-js';
export function SendMessageButton(props: {
@@ -15,12 +15,8 @@ export function SendMessageButton(props: {
}}
class="text-ink-muted bg-transparent rounded-full hover:scale-110! transition ease-in-out delay-150 flex flex-col justify-center items-center"
>
- <div class="bg-transparent rounded-full size-8 flex flex-row justify-center items-center">
- <ArrowFatLineUp
- width={20}
- height={20}
- class="!text-accent-ink !fill-accent"
- />
+ <div class="group hover:bg-accent transition ease-in-out size-6 border border-accent rounded-full flex items-center justify-center">
+ <ArrowUp class="group-hover:!text-input group-hover:!fill-input !text-accent-ink !fill-accent size-4 transition ease-in-out" />
</div>
</button>
);
diff --git a/js/app/packages/core/component/AI/component/input/useChatInput.tsx b/js/app/packages/core/component/AI/component/input/useChatInput.tsx
index d20e577018..3ba8fac3c8 100644
--- a/js/app/packages/core/component/AI/component/input/useChatInput.tsx
+++ b/js/app/packages/core/component/AI/component/input/useChatInput.tsx
@@ -29,7 +29,7 @@ import { useTabAttachments } from '../../signal/tabAttachments';
import { AttachmentList } from './Attachment';
import { ChatAttachMenu } from './ChatAttachMenu';
import { SendMessageButton, StopButton } from './SendMessageButton';
-import { type Source, ToolsetSelector } from './ToolsetSelector';
+import type { Source } from './ToolsetSelector';
import {
type UseChatMarkdown,
useChatMarkdownArea,
@@ -148,7 +148,7 @@ function ChatInput(props: ChatInputInternalProps) {
const generating = props.isGenerating ?? (() => false);
const toolsetSignal = createSignal<ToolSet>({ type: 'all' });
- const [source, setSource] = createSignal<Source>('everything');
+ const [source] = createSignal<Source>('everything');
const [showAttachMenu, setShowAttachMenu] = createSignal(false);
const [attachMenuAnchorRef, setAttachMenuAnchorRef] =
createSignal<HTMLDivElement>();
@@ -205,98 +205,90 @@ function ChatInput(props: ChatInputInternalProps) {
const availableAttachments = useChatAttachableHistory();
return (
- <>
- <div class="flex flex-row items-center gap-2 pb-2">
- <ToolsetSelector
- toolset={toolsetSignal}
- sources={[source, setSource]}
- />
+ <div
+ id="chat-input"
+ ref={containerRef}
+ class="relative flex flex-col flex-1 items-center justify-between bg-input border-t border-x border-edge-muted rounded-t-[5px] -mb-[7px]"
+ >
+ <BrightJoins dots={[false, false, true, true]} />
+ <div class="relative w-full z-0 px-3 pt-2 sm:pb-4 flex-1 overflow-hidden placeholder:text-ink-placeholder placeholder:opacity-50">
+ <div
+ id="chat-input-text-area"
+ class="rounded-md w-full h-full text-base sm:text-sm text-ink"
+ >
+ <props.markdown.MarkdownArea
+ onEnter={handleEnter}
+ placeholder="Ask AI - @mention anything"
+ history={availableAttachments}
+ dontFocusOnMount={
+ isMobileWidth() || props.autoFocusOnMount === false
+ }
+ onPasteFile={props.uploadQueue.upload}
+ captureEditor={props.captureEditor}
+ />
+ </div>
</div>
- <div
- id="chat-input"
- ref={containerRef}
- class="relative flex flex-col flex-1 items-center justify-between bg-input border-t border-x border-edge-muted rounded-t-[5px] -mb-[7px]"
- >
- <BrightJoins dots={[false, false, true, true]} />
- <div class="relative w-full z-0 px-3 pt-2 sm:pb-4 flex-1 overflow-hidden placeholder:text-ink-placeholder placeholder:opacity-50">
- <div
- id="chat-input-text-area"
- class="rounded-md w-full h-full text-base sm:text-sm text-ink"
- >
- <props.markdown.MarkdownArea
- onEnter={handleEnter}
- placeholder="Ask AI - @mention anything"
- history={availableAttachments}
- dontFocusOnMount={
- isMobileWidth() || props.autoFocusOnMount === false
- }
- onPasteFile={props.uploadQueue.upload}
- captureEditor={props.captureEditor}
- />
- </div>
+ <div class="w-full">
+ <div class="px-2 w-full min-h-0">
+ <AttachmentList
+ attached={props.attachments.attached}
+ removeAttachment={(id) => {
+ track(TrackingEvents.CHAT.ATTACHMENT.REMOVE);
+ props.attachments.removeAttachment(id);
+ }}
+ uploading={() =>
+ props.uploadQueue
+ .uploading()
+ .map((uploading) => uploading.preview)
+ }
+ />
</div>
- <div class="w-full">
- <div class="px-2 w-full min-h-0">
- <AttachmentList
- attached={props.attachments.attached}
- removeAttachment={(id) => {
- track(TrackingEvents.CHAT.ATTACHMENT.REMOVE);
- props.attachments.removeAttachment(id);
+ <div class="flex flex-row w-full h-8 justify-between items-center p-2 mb-2 space-x-2 allow-css-brackets">
+ <Show when={showAttachMenu()}>
+ <ChatAttachMenu
+ anchorRef={attachMenuAnchorRef()!}
+ close={() => setShowAttachMenu(false)}
+ containerRef={containerRef}
+ open={showAttachMenu()}
+ onAttach={(attachment) => {
+ track(TrackingEvents.CHAT.ATTACHMENT.ADD);
+ props.attachments.addAttachment(attachment);
}}
- uploading={() =>
- props.uploadQueue
- .uploading()
- .map((uploading) => uploading.preview)
- }
+ uploadQueue={props.uploadQueue}
+ />
+ </Show>
+ <div class="flex flex-row items-center gap-2">
+ <IconButton
+ icon={showAttachMenu() ? XIcon : PlusIcon}
+ theme="base"
+ ref={setAttachMenuAnchorRef}
+ onClick={() => setShowAttachMenu((prev) => !prev)}
/>
</div>
- <div class="flex flex-row w-full h-8 justify-between items-center p-2 mb-2 space-x-2 allow-css-brackets">
- <Show when={showAttachMenu()}>
- <ChatAttachMenu
- anchorRef={attachMenuAnchorRef()!}
- close={() => setShowAttachMenu(false)}
- containerRef={containerRef}
- open={showAttachMenu()}
- onAttach={(attachment) => {
- track(TrackingEvents.CHAT.ATTACHMENT.ADD);
- props.attachments.addAttachment(attachment);
+ <Switch>
+ <Match when={props.uploadQueue.uploading().length !== 0}>
+ <CircleSpinner />
+ </Match>
+ <Match when={!generating()}>
+ <SendMessageButton
+ isDisabled={() => !canSendMessage()}
+ onClick={() => {
+ track(TrackingEvents.CHAT.MESSAGE.SEND);
+ sendMessage();
}}
- uploadQueue={props.uploadQueue}
/>
- </Show>
- <div class="flex flex-row items-center gap-2">
- <IconButton
- icon={showAttachMenu() ? XIcon : PlusIcon}
- theme="base"
- ref={setAttachMenuAnchorRef}
- onClick={() => setShowAttachMenu((prev) => !prev)}
+ </Match>
+ <Match when={generating()}>
+ <StopButton
+ onClick={() => {
+ track(TrackingEvents.CHAT.MESSAGE.STOP);
+ props.onStop?.();
+ }}
/>
- </div>
- <Switch>
- <Match when={props.uploadQueue.uploading().length !== 0}>
- <CircleSpinner />
- </Match>
- <Match when={!generating()}>
- <SendMessageButton
- isDisabled={() => !canSendMessage()}
- onClick={() => {
- track(TrackingEvents.CHAT.MESSAGE.SEND);
- sendMessage();
- }}
- />
- </Match>
- <Match when={generating()}>
- <StopButton
- onClick={() => {
- track(TrackingEvents.CHAT.MESSAGE.STOP);
- props.onStop?.();
- }}
- />
- </Match>
- </Switch>
- </div>
+ </Match>
+ </Switch>
</div>
</div>
- </>
+ </div>
);
}