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
fix chat controls (#148)
Eric Hayes42fde90b0b28
diff --git a/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsx b/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsxindex 5e963e27e6..1c1178ae59 100644--- a/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsx+++ b/js/app/packages/core/component/AI/component/input/ToolsetSelector.tsx@@ -6,33 +6,44 @@ import { type ParentProps, Show, type Signal } from 'solid-js';type ToolSetName = ToolSet['type'];-const TOOLSET_TO_DISPLAY = {- none: 'ASK',- all: 'AGENT',-} as const satisfies Record<ToolSetName, string>;+const TOOLSETS = [+ {+ value: 'none' as const,+ label: 'ASK',+ tooltip: 'Simple answers to simple questions',+ },+ {+ value: 'all' as const,+ label: 'AGENT',+ tooltip: 'Dynamically search Macro for useful context',+ },+] as const;-const TOOLSET_FROM_DISPLAY = {- ASK: 'none',- AGENT: 'all',-} as const satisfies Record<string, ToolSetName>;+const TOOLSET_TO_DISPLAY = Object.fromEntries(+ TOOLSETS.map((t) => [t.value, t.label])+) as Record<ToolSetName, string>;++const TOOLSET_FROM_DISPLAY = Object.fromEntries(+ TOOLSETS.map((t) => [t.label, { value: t.value, tooltip: t.tooltip }])+) as Record<string, { value: ToolSetName; tooltip: string }>;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 SOURCES = [+ { value: 'everything' as const, label: 'ALL' },+ { value: 'chat' as const, label: 'CHATS' },+ { value: 'channel' as const, label: 'CHANNELS' },+ { value: 'document' as const, label: 'DOCUMENTS' },+ { value: 'email' as const, label: 'EMAILS' },+] as const;++const SOURCE_TO_DISPLAY = Object.fromEntries(+ SOURCES.map((s) => [s.value, s.label])+) as Record<Source, string>;-const SOURCE_FROM_DISPLAY = {- ALL: 'everything',- CHATS: 'chat',- CHANNELS: 'channel',- DOCUMENTS: 'document',- EMAILS: 'email',-} as const satisfies Record<string, Source>;+const SOURCE_FROM_DISPLAY = Object.fromEntries(+ SOURCES.map((s) => [s.label, s.value])+) as Record<string, Source>;export function ToolsetSelector(props: {toolset: Signal<ToolSet>;@@ -43,32 +54,37 @@ export function ToolsetSelector(props: {const StyledTriggerLabel = (props: ParentProps) => {return (- <span class="text-[.85rem] font-medium font-mono">- <Tooltip- tooltip={"Tell the agent which sources to consider in it's search"}- >- {props.children}- </Tooltip>- </span>+ <Tooltip+ tooltip={'Tell the agent which sources to consider in its search'}+ >+ {props.children}+ </Tooltip>);};return (<div class="flex items-center gap-x-1"><SegmentedControl+ size="SM"defaultValue={TOOLSET_TO_DISPLAY[toolset().type]}onChange={(s) => {setToolset({- type: TOOLSET_FROM_DISPLAY[s as keyof typeof TOOLSET_FROM_DISPLAY],+ type: TOOLSET_FROM_DISPLAY[s as keyof typeof TOOLSET_FROM_DISPLAY]+ .value,});}}- list={Object.keys(TOOLSET_FROM_DISPLAY)}+ list={TOOLSETS.map((t) => ({+ value: t.label,+ label: t.label,+ tooltip: t.tooltip,+ }))}/><Show when={toolset().type === 'all'}><div class="flex"><DropdownMenu+ size="SM"theme="secondary"- triggerLabel={<StyledTriggerLabel>Source</StyledTriggerLabel>}+ triggerLabel={<span>SOURCE</span>}><SegmentedControldefaultValue={SOURCE_TO_DISPLAY[source()]}@@ -77,11 +93,10 @@ export function ToolsetSelector(props: {SOURCE_FROM_DISPLAY[s as keyof typeof SOURCE_FROM_DISPLAY]);}}- list={Object.keys(SOURCE_FROM_DISPLAY)}+ list={SOURCES.map((s) => s.label)}/></DropdownMenu>-- <span class="bg-accent text-panel font-mono text-xs font-medium p-1">+ <span class="bg-accent text-panel font-mono text-xs font-medium px-1 flex items-center">{SOURCE_TO_DISPLAY[source()]}</span></div>diff --git a/js/app/packages/core/component/AI/component/input/useChatInput.tsx b/js/app/packages/core/component/AI/component/input/useChatInput.tsxindex 0adb8ed3a8..a75737f8c9 100644--- a/js/app/packages/core/component/AI/component/input/useChatInput.tsx+++ b/js/app/packages/core/component/AI/component/input/useChatInput.tsx@@ -128,7 +128,6 @@ export function useChatInput(}function ChatInput(props: ChatInputInternalProps) {- console.log('CHAT INPUT', props);let containerRef!: HTMLDivElement;const generating = props.isGenerating ?? (() => false);const toolsetSignal = createSignal<ToolSet>({ type: 'all' });diff --git a/js/app/packages/core/component/FormControls/Button.tsx b/js/app/packages/core/component/FormControls/Button.tsxindex bddd8bfd43..8ed5014e62 100644--- a/js/app/packages/core/component/FormControls/Button.tsx+++ b/js/app/packages/core/component/FormControls/Button.tsx@@ -10,6 +10,7 @@ import { Hotkey } from '../Hotkey';type Size = 'SM' | 'Base' | 'XS';type Theme = 'primary' | 'secondary' | 'primary' | 'secondary';+const sizeClass: Record<Size, string> = {XS: 'text-[10px] p-1',SM: 'text-xs p-1',diff --git a/js/app/packages/core/component/FormControls/DropdownMenu.tsx b/js/app/packages/core/component/FormControls/DropdownMenu.tsxindex 330618268e..820bb281eb 100644--- a/js/app/packages/core/component/FormControls/DropdownMenu.tsx+++ b/js/app/packages/core/component/FormControls/DropdownMenu.tsx@@ -85,6 +85,7 @@ const DropdownMenu: ParentComponent<start();observe(_popoverPortalEl);});+return (<Popovermodal@@ -100,7 +101,9 @@ const DropdownMenu: ParentComponent<<Popover.Triggersize={props.size}active={open()}- classList={{ '!block': true }}+ classList={{+ '!block': true,+ }}as={Button}theme="primary"ref={triggerEl}diff --git a/js/app/packages/core/component/FormControls/SegmentControls.tsx b/js/app/packages/core/component/FormControls/SegmentControls.tsxindex f871a16d18..8bbe32569c 100644--- a/js/app/packages/core/component/FormControls/SegmentControls.tsx+++ b/js/app/packages/core/component/FormControls/SegmentControls.tsx@@ -1,3 +1,4 @@+import { Tooltip } from '@core/component/Tooltip';import {SegmentedControl as KSegmentedControl,type SegmentedControlRootProps,@@ -6,8 +7,10 @@ import {createEffect,createSignal,For,+ Match,type ParentComponent,Show,+ Switch,} from 'solid-js';import { ToggleButton } from './ToggleButton';@@ -19,7 +22,7 @@ const sizeClass: Record<Size, string> = {export const SegmentedControl: ParentComponent<{- list: string[] | { value: string; label: string }[];+ list: string[] | { value: string; label: string; tooltip?: string }[];value?: string;label?: string;labelClass?: string;@@ -48,7 +51,7 @@ export const SegmentedControl: ParentComponent<return (<KSegmentedControl- class="flex gap-3"+ class="flex gap-3 text-sm"classList={{[`justify-between`]: !!props.label,'flex-row-reverse': props.labelPlacement === 'right',@@ -79,6 +82,8 @@ export const SegmentedControl: ParentComponent<typeof item === 'object' ? item.value : item;const itemLabel = () =>typeof item === 'object' ? item.label : item;+ const tooltip = (): undefined | string =>+ typeof item === 'object' ? item.tooltip : undefined;return (<KSegmentedControl.Itemvalue={itemValue()}@@ -102,16 +107,34 @@ export const SegmentedControl: ParentComponent<>{item}</div> */}- <ToggleButton- size={props.size}- pressed={value() === itemValue()}- animateFlickerOnDeactivate={false}- tabIndex={-1}- as="div"- disabled={props.disabled}- >- {itemLabel()}- </ToggleButton>+ <Switch>+ <Match when={tooltip()}>+ <Tooltip tooltip={tooltip()}>+ <ToggleButton+ size={props.size}+ pressed={value() === itemValue()}+ animateFlickerOnDeactivate={false}+ tabIndex={-1}+ as="div"+ disabled={props.disabled}+ >+ {itemLabel()}+ </ToggleButton>+ </Tooltip>+ </Match>+ <Match when={!tooltip()}>+ <ToggleButton+ size={props.size}+ pressed={value() === itemValue()}+ animateFlickerOnDeactivate={false}+ tabIndex={-1}+ as="div"+ disabled={props.disabled}+ >+ {itemLabel()}+ </ToggleButton>+ </Match>+ </Switch></KSegmentedControl.ItemLabel></KSegmentedControl.Item>);