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): opus + hotkeys (#887)
Eric Hayes2905df5af814
diff --git a/js/app/packages/app/component/rightbar/Rightbar.tsx b/js/app/packages/app/component/rightbar/Rightbar.tsxindex b81cb9c478..1d23c4fb4d 100644--- a/js/app/packages/app/component/rightbar/Rightbar.tsx+++ b/js/app/packages/app/component/rightbar/Rightbar.tsx@@ -239,6 +239,7 @@ export function Rightbar(props: {chatName: string | undefined;stream: Accessor<MessageStream | undefined>;onSend: (args: CreateAndSend | Send) => void;+ stopGenerating: () => void;onUnmount?: () => void;messages: Accessor<ChatMessageWithAttachments[]>;initialState?: {@@ -281,14 +282,7 @@ export function Rightbar(props: {registerToolHandler(props.stream);- const stopGenerating = () => {- const stream_ = props.stream();- if (!stream_) return;- cognitionWebsocketServiceClient.stopChatMessage({- stream_id: stream_.request.stream_id,- });- stream_.close();- };+ const stopGenerating = props.stopGenerating;// NOTE: due to mount race condition in the markdown area, we need to set the initial value hereconst {@@ -432,7 +426,7 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {| undefined>();- const [attachHotkeys, scopeId] = useHotkeyDOMScope('ai-right-panel');+ const [attachHotkeys, scopeId] = useHotkeyDOMScope('ai-chat');const clearChatState = () => {const attached = attachments();@@ -620,6 +614,23 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {},});+ const stopGenerating = () => {+ const stream_ = stream();+ if (!stream_) return false;+ cognitionWebsocketServiceClient.stopChatMessage({+ stream_id: stream_.request.stream_id,+ });+ stream_.close();+ return true;+ };++ registerHotkey({+ scopeId,+ hotkey: 'ctrl+c',+ description: 'Stop stream',+ keyDownHandler: stopGenerating,+ runWithInputFocused: true,+ });return (<Show when={isAuthenticated()}><Resize.Panel@@ -651,6 +662,7 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {initialState={initialChatState()}onSend={onSend}stream={stream}+ stopGenerating={stopGenerating}setState={{setChatId,setModel,diff --git a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsxindex 375b9bb997..c474584abd 100644--- a/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx+++ b/js/app/packages/core/component/AI/component/AIChatEmptyState.tsx@@ -1,3 +1,4 @@+import { modifierMap } from '@core/component/Hotkey';import { BrightJoins } from '@ui/components/BrightJoins';import { useOpenInstructionsMd } from '../util/instructions';@@ -10,6 +11,22 @@ export function AiChatEmptyState() {<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>+ <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>+ <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><div>Change the<spandiff --git a/js/app/packages/core/component/AI/component/input/useChatInput.tsx b/js/app/packages/core/component/AI/component/input/useChatInput.tsxindex e148118ae7..b6d428bd77 100644--- a/js/app/packages/core/component/AI/component/input/useChatInput.tsx+++ b/js/app/packages/core/component/AI/component/input/useChatInput.tsx@@ -1,6 +1,6 @@import { withAnalytics } from '@coparse/analytics';import { useBuildChatSendRequest } from '@core/component/AI/component/input/buildRequest';-import { DEFAULT_MODEL } from '@core/component/AI/constant';+import { DEFAULT_MODEL, SMART_MODE_MODEL } from '@core/component/AI/constant';import {useAttachments,useChatAttachableHistory,@@ -15,8 +15,10 @@ import type {UploadQueue,} from '@core/component/AI/types';import { useUploadAttachment } from '@core/component/AI/util/uploadToChat';-import { CircleSpinner } from '@core/component/CircleSpinner';import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';+import { Hotkey, modifierMap } from '@core/component/Hotkey';+import { Tooltip } from '@core/component/Tooltip';+import { pressedKeys } from '@core/hotkey/state';import { isMobileWidth } from '@core/mobile/mobileWidth';import PlusIcon from '@icon/regular/plus.svg';import XIcon from '@icon/regular/x.svg';@@ -24,11 +26,10 @@ import { createCallback } from '@solid-primitives/rootless';import { BrightJoins } from '@ui/components/BrightJoins';import type { LexicalEditor } from 'lexical';import type { Accessor, Component, Setter } from 'solid-js';-import { createEffect, createSignal, Match, on, Show, Switch } from 'solid-js';+import { createEffect, createSignal, on, Show } from 'solid-js';import { useTabAttachments } from '../../signal/tabAttachments';import { AttachmentList } from './Attachment';import { ChatAttachMenu } from './ChatAttachMenu';-import { SendMessageButton, StopButton } from './SendMessageButton';import type { Source } from './ToolsetSelector';import {type UseChatMarkdown,@@ -170,7 +171,7 @@ function ChatInput(props: ChatInputInternalProps) {!isEmptyInput() && !generating() && !hasUploadingAttachments();const buildChatSendRequest = useBuildChatSendRequest();- const sendMessage = createCallback(async () => {+ const sendMessage = createCallback(async (modelOverride?: Model) => {if (!canSendMessage()) return;const request = await buildChatSendRequest({@@ -178,7 +179,7 @@ function ChatInput(props: ChatInputInternalProps) {userRequest: props.markdown.markdownText(),isPersistent: props.isPersistent,attachments: props.attachments.attached(),- model: props.model(),+ model: modelOverride ?? props.model(),toolset: toolsetSignal[0](),source: source(),});@@ -188,14 +189,15 @@ function ChatInput(props: ChatInputInternalProps) {function handleEnter(e: KeyboardEvent): boolean {if (e.key === 'Enter' && !e.shiftKey) {- // Always prevent default for Enter (unless Shift is held)e.preventDefault();- // Only send if we can send, otherwise no-opif (canSendMessage()) {- sendMessage();+ if (e.metaKey) {+ sendMessage(SMART_MODE_MODEL);+ } else {+ sendMessage();+ }}-return true;} else {return false;@@ -265,28 +267,50 @@ function ChatInput(props: ChatInputInternalProps) {onClick={() => setShowAttachMenu((prev) => !prev)}/></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 class="flex flex-col items-end text-xs leading-tight text-ink-disabled">+ <div class="text-xs flex flex-col gap-1 opacity-70 items-end absolute bottom-1">+ <Show when={generating()}>+ <Tooltip tooltip="ctrl+c to stop" placement="top">+ <div+ class="flex items-center gap-1.5"+ classList={{+ 'text-accent': pressedKeys().has('ctrl'),+ }}+ >+ <span class="">Stop</span>+ <div class="flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25 font-normal">+ <Hotkey shortcut="ctrl+c" />+ </div>+ </div>+ </Tooltip>+ </Show>+ <Tooltip tooltip="Enter to send with Haiku" placement="top">+ <div class="flex items-center gap-1.5">+ <span class="">Haiku</span>+ <div class="flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25 font-normal">+ <Hotkey shortcut="Enter" />+ </div>+ </div>+ </Tooltip>+ <Tooltip+ tooltip={`${modifierMap.cmd} + Enter to send with Opus`}+ placement="top"+ >+ <div+ class="flex items-center gap-1.5"+ classList={{+ 'text-accent': pressedKeys().has('cmd'),+ }}+ >+ <span>Opus</span>+ <div class="flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25 font-normal">+ <Hotkey shortcut={'meta+Enter'} />+ </div>+ </div>+ </Tooltip>+ </div>+ </div></div></div></div>diff --git a/js/app/packages/core/component/AI/constant/model.ts b/js/app/packages/core/component/AI/constant/model.tsindex 7e2cb5d36e..993905a6df 100644--- a/js/app/packages/core/component/AI/constant/model.ts+++ b/js/app/packages/core/component/AI/constant/model.ts@@ -16,13 +16,15 @@ type ExhaustiveMap = {// } as const;export const MODEL_PRETTYNAME: ExhaustiveMap = {- 'claude-sonnet-4-5': 'Claude Sonnet 4.5',+ 'claude-opus-4-5': 'Claude Opus 4.5','claude-haiku-4-5': 'Claude Haiku 4.5',} as const;export const MODEL_PROVIDER_ICON: ExhaustiveMap = {'claude-haiku-4-5': AnthropicIcon,- 'claude-sonnet-4-5': AnthropicIcon,+ 'claude-opus-4-5': AnthropicIcon,};+export const SMART_MODE_MODEL: Model = 'claude-opus-4-5';+export const DEFAULT_MODEL: Model = 'claude-haiku-4-5';diff --git a/js/app/packages/core/component/Hotkey.tsx b/js/app/packages/core/component/Hotkey.tsxindex 8af52885f7..ffa40e907b 100644--- a/js/app/packages/core/component/Hotkey.tsx+++ b/js/app/packages/core/component/Hotkey.tsx@@ -4,7 +4,7 @@ import { getPrettyHotkeyStringByToken } from '@core/hotkey/utils';import { createMemo, For, type JSX, Show, splitProps } from 'solid-js';import type { Theme } from './Themes';-const modifierMap = {+export const modifierMap = {cmd: IS_MAC ? '⌘' : 'Ctrl',opt: IS_MAC ? '⌥' : 'Alt',shift: IS_MAC ? '⇧' : 'Shift',diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/model.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/model.tsindex ee95db3ddf..89cb97fb56 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/model.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/model.ts@@ -8,12 +8,12 @@ export type Model = typeof Model[keyof typeof Model];export const Model = {"claude-haiku-4-5": "claude-haiku-4-5",- "claude-sonnet-4-5": "claude-sonnet-4-5",+ "claude-opus-4-5": "claude-opus-4-5",} as const;export const AllModels: Model[] = ["claude-haiku-4-5",- "claude-sonnet-4-5"+ "claude-opus-4-5"] as const;const values: [Model, ...Model[]] = [Object.values(Model)[0],