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 (ai): engooden chat controls (#82)
Eric Hayes53b74b5be5a8
diff --git a/js/app/packages/core/component/AI/component/input/ActiveTabAttachment.tsx b/js/app/packages/core/component/AI/component/input/ActiveTabAttachment.tsxindex 48b8f23488..9c53755721 100644--- a/js/app/packages/core/component/AI/component/input/ActiveTabAttachment.tsx+++ b/js/app/packages/core/component/AI/component/input/ActiveTabAttachment.tsx@@ -290,7 +290,7 @@ export function ActiveTabAttachment(props: ActiveTabAttachmentProps) {return (<Show when={hasUnattachedTabs()}>- <div class="flex items-center p-1 space-x-2 hover:bg-hover hover-transition-bg cursor-pointer text-sm border border-dashed border-ink-muted">+ <div class="py-[1.5] px-2 hover:bg-hover hover-transition-bg text-xs border border-edge border-dashed"><DropdownMenuopen={showDropdown()}onOpenChange={setShowDropdown}@@ -298,13 +298,12 @@ export function ActiveTabAttachment(props: ActiveTabAttachmentProps) {><DropdownMenu.Trigger><div- class="flex items-center gap-1 cursor-pointer"+ class="flex items-center gap-1 text-ink"onClick={() => setShowDropdown(!showDropdown())}>- <span class="text-ink">{'Tabs'}</span>+ Tabs</div></DropdownMenu.Trigger>-<DropdownMenu.Portal><AddContextDropdownactiveTabs={validActiveTabs()}diff --git a/js/app/packages/core/component/AI/component/input/Attachment.tsx b/js/app/packages/core/component/AI/component/input/Attachment.tsxindex 0f18a24d78..36f00e7e6c 100644--- a/js/app/packages/core/component/AI/component/input/Attachment.tsx+++ b/js/app/packages/core/component/AI/component/input/Attachment.tsx@@ -30,7 +30,7 @@ type AttachmentListProps = {export function AttachmentList(props: AttachmentListProps) {return (- <div class="flex flex-row w-full space-x-2 items-center flex-wrap overflow-x-hidden">+ <div class="flex flex-row w-full space-x-2 items-end flex-wrap overflow-x-hidden pb-1"><For each={props.attached()}>{(attachment) => (<ChatAttachment@@ -148,7 +148,7 @@ function ChatAttachment(props: {<Match when={true}><divclass={`- flex items-center p-1 space-x-2 rounded-lg+ flex items-center p-1 space-x-2hover:bg-hover hover-transition-bg cursor-defaulttext-sm`}diff --git a/js/app/packages/core/component/AI/component/input/Sources.tsx b/js/app/packages/core/component/AI/component/input/Sources.tsxdeleted file mode 100644index 7a0a7d9ddc..0000000000--- a/js/app/packages/core/component/AI/component/input/Sources.tsx+++ /dev/null@@ -1,32 +0,0 @@-import { For, type Signal } from 'solid-js';--export type Source = 'chat' | 'channel' | 'document' | 'email' | 'everything';--const SOURCE_LABELS: Record<Source, string> = {- everything: 'Everything',- chat: 'Chat',- channel: 'Channel',- document: 'Document',- email: 'Email',-};--export function SourceSelector(props: { sources: Signal<Source> }) {- const [source, setSource] = props.sources;-- return (- <div>- <div class="relative flex gap-1 text-xs p-1">- <For each={Object.entries(SOURCE_LABELS)}>- {([src, label]) => (- <button- onClick={() => setSource(src as any)}- class={`px-2 py-0.5 border-1 border-accent text-s border-0.5 ${source() === (src as any) ? 'bg-accent text-page' : 'hover:text-page text-ink-muted hover:bg-accent hover:border-accent border-ink-muted'}`}- >- {label}- </button>- )}- </For>- </div>- </div>- );-}diff --git a/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsx b/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsxindex ca47492615..3a334e957e 100644--- a/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsx+++ b/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsx@@ -1,42 +1,82 @@-import { MenuItem } from '@core/component/Menu';-import { TextButton } from '@core/component/TextButton';-import { DropdownMenu } from '@kobalte/core/dropdown-menu';+import DropdownMenu from '@core/component/FormControls/DropdownMenu';+import { SegmentedControl } from '@core/component/FormControls/SegmentControls';import type { ToolSet } from '@service-cognition/generated/schemas';-import { For, type Signal } from 'solid-js';+import { type ParentProps, Show, type Signal } from 'solid-js';type ToolSetName = ToolSet['type'];-const DROPDOWN_OPTIONS: Record<ToolSetName, string> = {- all: 'Agent',- none: 'Ask',-};-export function ToolsetSelector(props: { toolset: Signal<ToolSet> }) {+const TOOLSET_TO_DISPLAY = {+ none: 'ASK',+ all: 'AGENT',+} as const satisfies Record<ToolSetName, string>;++const TOOLSET_FROM_DISPLAY = {+ ASK: 'none',+ AGENT: 'all',+} as const satisfies Record<string, ToolSetName>;++export type Source = 'chat' | 'channel' | 'document' | 'email' | 'everything';++const SOURCE_TO_DISPLAY = {+ everything: 'ALL',+ chat: 'CHATS',+ channel: 'CHANNELS',+ document: 'DOCUMENTS',+ email: 'EMAILS',+} as const satisfies Record<Source, string>;++const SOURCE_FROM_DISPLAY = {+ ALL: 'everything',+ CHATS: 'chat',+ CHANNELS: 'channel',+ DOCUMENTS: 'document',+ EMAILS: 'email',+} as const satisfies Record<string, Source>;++export function ToolsetSelector(props: {+ toolset: Signal<ToolSet>;+ sources: Signal<Source>;+}) {const [toolset, setToolset] = props.toolset;+ const [source, setSource] = props.sources;+ const StyledTriggerLabel = (props: ParentProps) => {+ return <span class="text-[.85rem] font-medium flex">{props.children}</span>;+ };return (- <DropdownMenu>- <DropdownMenu.Trigger>- <TextButton- theme="clear"- onClick={() => {}}- text={DROPDOWN_OPTIONS[toolset().type]}- showChevron- />- </DropdownMenu.Trigger>- <DropdownMenu.Portal>- {/*there's probabably a real way to do this, but if I don't z index then big chat dropdown broke*/}- <DropdownMenu.Content class="z-100000">- <For each={Object.entries(DROPDOWN_OPTIONS)}>- {([k, v]) => (- <MenuItem- class="bg-panel"- text={v}- onClick={() => setToolset({ type: k as ToolSetName })}- />- )}- </For>- </DropdownMenu.Content>- </DropdownMenu.Portal>- </DropdownMenu>+ <div class="flex items-center gap-x-1">+ <SegmentedControl+ defaultValue={TOOLSET_TO_DISPLAY[toolset().type]}+ onChange={(s) => {+ setToolset({+ type: TOOLSET_FROM_DISPLAY[s as keyof typeof TOOLSET_FROM_DISPLAY],+ });+ }}+ list={Object.keys(TOOLSET_FROM_DISPLAY)}+ />++ <Show when={toolset().type === 'all'}>+ <div class="flex">+ <DropdownMenu+ theme="secondary"+ triggerLabel={<StyledTriggerLabel>Filter</StyledTriggerLabel>}+ >+ <SegmentedControl+ defaultValue={SOURCE_TO_DISPLAY[source()]}+ onChange={(s) => {+ setSource(+ SOURCE_FROM_DISPLAY[s as keyof typeof SOURCE_FROM_DISPLAY]+ );+ }}+ list={Object.keys(SOURCE_FROM_DISPLAY)}+ />+ </DropdownMenu>++ <span class="bg-accent text-panel font-mono text-xs font-medium p-1">+ {SOURCE_TO_DISPLAY[source()]}+ </span>+ </div>+ </Show>+ </div>);}diff --git a/js/app/packages/core/component/AI/component/input/buildRequest.ts b/js/app/packages/core/component/AI/component/input/buildRequest.tsindex 87b20f9e5c..d75f75be8b 100644--- a/js/app/packages/core/component/AI/component/input/buildRequest.ts+++ b/js/app/packages/core/component/AI/component/input/buildRequest.ts@@ -15,7 +15,7 @@ import {cognitionApiServiceClient,cognitionWebsocketServiceClient,} from '@service-cognition/client';-import type { Source } from './Sources';+import type { Source } from './ToolsetSelector';function sourceToPrompt(source?: Source): string {if (!source) return '';diff --git a/js/app/packages/core/component/AI/component/input/useChatInput.tsx b/js/app/packages/core/component/AI/component/input/useChatInput.tsxindex 434b5dbd81..ac7642720a 100644--- a/js/app/packages/core/component/AI/component/input/useChatInput.tsx+++ b/js/app/packages/core/component/AI/component/input/useChatInput.tsx@@ -28,8 +28,7 @@ import { ActiveTabAttachment } from './ActiveTabAttachment';import { AttachmentList } from './Attachment';import { ChatAttachMenu } from './ChatAttachMenu';import { SendMessageButton, StopButton } from './SendMessageButton';-import { type Source, SourceSelector } from './Sources';-import { ToolsetSelector } from './ToolsetSelector';+import { type Source, ToolsetSelector } from './ToolsetSelector';import {type UseChatMarkdown,useChatMarkdownArea,@@ -225,7 +224,7 @@ function ChatInput(props: ChatInputInternalProps) {}/></div>- <div class="flex justify-between w-full px-2 pb-2">+ <div class="flex justify-between w-full px-2"><Show when={showAttachMenu()}><ChatAttachMenuanchorRef={attachMenuAnchorRef()!}@@ -239,21 +238,14 @@ function ChatInput(props: ChatInputInternalProps) {uploadQueue={props.uploadQueue}/></Show>- <div class="flex items-center space-x-2">+ <div class="flex items-center"><IconButtonicon={showAttachMenu() ? XIcon : PlusIcon}theme="base"+ size="sm"ref={setAttachMenuAnchorRef}onClick={() => setShowAttachMenu((prev) => !prev)}/>-- {/*- Removed (for now) - we're moving to gemini 2.5 to use GCP credits. This will probably come back soon- <ModelSelector- selectedModel={props.model()}- onSelect={(model) => props.setModel(model)}- />*/}- <ToolsetSelector toolset={toolsetSignal} /><Show when={props.showActiveTabs}><ActiveTabAttachmentonAddAttachment={(attachment) => {@@ -270,9 +262,10 @@ function ChatInput(props: ChatInputInternalProps) {attachAllOnMount={!props.chatId()}/></Show>- <Show when={toolsetSignal[0]().type === 'all'}>- <SourceSelector sources={[source, setSource]} />- </Show>+ <ToolsetSelector+ toolset={toolsetSignal}+ sources={[source, setSource]}+ /></div><Switch><Match when={props.uploadQueue.uploading().length !== 0}>