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: kill rightbar + cmd-j focus (#1623)

Eric Hayese5626af8730e
diff --git a/js/app/packages/app/component/SoupChatInput.tsx b/js/app/packages/app/component/SoupChatInput.tsx
index 234d71bcfa..8d69e50589 100644
--- a/js/app/packages/app/component/SoupChatInput.tsx
+++ b/js/app/packages/app/component/SoupChatInput.tsx
@@ -1,16 +1,17 @@
+import { useSoup } from '@app/component/next-soup/soup-context';
+import type { ChatSendInput } from '@core/component/AI/component/input/buildRequest';
+import { useChatMarkdownArea } from '@core/component/AI/component/input/useChatMarkdownArea';
import {
ChatInputProvider,
useChatInputContext,
} from '@core/component/AI/context';
-import type { ChatSendInput } from '@core/component/AI/component/input/buildRequest';
-import { useChatMarkdownArea } from '@core/component/AI/component/input/useChatMarkdownArea';
import { setPendingSendData } from '@core/component/AI/signal/pendingSend';
+import { TOKENS } from '@core/hotkey/tokens';
import { isErr } from '@core/util/maybeResult';
import { cognitionApiServiceClient } from '@service-cognition/client';
import { ChatInput } from 'core/component/AI/component/input/ChatInput';
-import { useHotkeyDOMScope } from 'core/hotkey/hotkeys';
+import { registerHotkey, useHotkeyDOMScope } from 'core/hotkey/hotkeys';
import { onMount, Show } from 'solid-js';
-import { useSoup } from '@app/component/next-soup/soup-context';
import { useSplitPanelOrThrow } from './split-layout/layoutUtils';
function SoupChatInputInner() {
@@ -29,6 +30,18 @@ function SoupChatInputInner() {
attachHotkeys(containerRef);
});
+ // cmd+j - Focus the soup chat input
+ registerHotkey({
+ hotkey: 'cmd+j',
+ scopeId: splitPanelContext.splitHotkeyScope,
+ hotkeyToken: TOKENS.chat.input.focus,
+ description: 'Focus chat input',
+ keyDownHandler: () => {
+ chatMarkdownArea.focus();
+ return true;
+ },
+ });
+
const handleSend = async (request: ChatSendInput) => {
// Create a new persistent chat
const response = await cognitionApiServiceClient.createChat({
@@ -67,6 +80,10 @@ function SoupChatInputInner() {
<ChatInput
markdown={chatMarkdownArea}
onSend={handleSend}
+ onEscape={() => {
+ splitPanelContext.panelRef()?.focus();
+ return true;
+ }}
isPersistent={true}
autoFocusOnMount={false}
/>
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index c91046df86..0e725c692d 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -1,4 +1,6 @@
import { useGlobalBlockOrchestrator } from '@app/component/GlobalAppState';
+import { createSoupState } from '@app/component/next-soup/create-soup-state';
+import { SoupContextProvider } from '@app/component/next-soup/soup-context';
import { activeElement } from '@app/signal/focus';
import { Resize } from '@core/component/Resize';
import { tabTitleSignal } from '@core/signal/tabTitle';
@@ -35,8 +37,6 @@ import {
} from './layoutManager';
import { decodePairs } from './layoutUtils';
import { registerSplitHotkeys } from './registerSplitHotkeys';
-import { SoupContextProvider } from '@app/component/next-soup/soup-context';
-import { createSoupState } from '@app/component/next-soup/create-soup-state';
type SplitLayoutContainerProps = {
pairs: string[];
@@ -45,8 +45,7 @@ type SplitLayoutContainerProps = {
function getParentSplitId(element: Element | null) {
if (!element || !element.isConnected) return null;
- // Checking the parent element here so that we don't get the split container itself.
- const splitParent = element.parentElement?.closest('[data-split-container]');
+ const splitParent = element.closest('[data-split-container]');
if (!splitParent) return null;
const splitId = splitParent.getAttribute('data-split-id');
if (!splitId) return null;
@@ -273,7 +272,7 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
const [, setTabTitle] = tabTitleSignal;
// Store a ref to each panel by id
- let panelRefs = new Map<SplitId, HTMLDivElement>();
+ const panelRefs = new Map<SplitId, HTMLDivElement>();
createEffect(
on(splitManager.events, (event) => {
if (event.type === SplitEvent.Remove) {
diff --git a/js/app/packages/block-chat/component/Chat.tsx b/js/app/packages/block-chat/component/Chat.tsx
index eda975601e..c92a51aa74 100644
--- a/js/app/packages/block-chat/component/Chat.tsx
+++ b/js/app/packages/block-chat/component/Chat.tsx
@@ -248,7 +248,7 @@ function ChatInner(props: {
chatId={chat.chatId()}
onSend={onSend}
captureEditor={setChatEditor}
- autoFocusOnMount={!navigatedFromJK()}
+ autoFocusOnMount={true}
/>
</div>
</div>
diff --git a/js/app/packages/core/component/AI/component/input/ChatInput.tsx b/js/app/packages/core/component/AI/component/input/ChatInput.tsx
index b7f6dd6e41..d85d800ae9 100644
--- a/js/app/packages/core/component/AI/component/input/ChatInput.tsx
+++ b/js/app/packages/core/component/AI/component/input/ChatInput.tsx
@@ -29,6 +29,7 @@ const { track, TrackingEvents } = withAnalytics();
export type ChatInputProps = {
onSend: (args: ChatSendInput) => void;
onStop?: () => void;
+ onEscape?: (e: KeyboardEvent) => boolean;
isPersistent?: boolean;
showActiveTabs?: boolean;
captureEditor?: (editor: LexicalEditor) => void;
@@ -249,6 +250,7 @@ export function ChatInput(props: ChatInputComponentProps) {
>
<props.markdown.MarkdownArea
onEnter={handleEnter}
+ onEscape={props.onEscape}
placeholder="Ask AI, @mention anything"
history={availableAttachments}
dontFocusOnMount={
diff --git a/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx b/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx
index e64c071cd9..236f8c65ee 100644
--- a/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx
+++ b/js/app/packages/core/component/AI/component/input/useChatMarkdownArea.tsx
@@ -59,9 +59,11 @@ import { createAccessoryStore } from 'core/component/LexicalMarkdown/plugins/nod
import { textPastePlugin } from 'core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin';
import {
$getRoot,
+ COMMAND_PRIORITY_CRITICAL,
COMMAND_PRIORITY_HIGH,
FORMAT_TEXT_COMMAND,
KEY_ENTER_COMMAND,
+ KEY_ESCAPE_COMMAND,
type LexicalEditor,
type TextFormatType,
} from 'lexical';
@@ -217,6 +219,7 @@ type MarkdownAreaProps = {
export type ConsumableChatMarkdownAreaProps = {
onChange?: (value: string) => void;
onEnter?: (e: KeyboardEvent) => boolean;
+ onEscape?: (e: KeyboardEvent) => boolean;
onBlur?: () => void;
initialValue?: string;
placeholder?: string;
@@ -376,6 +379,16 @@ function MarkdownArea(
);
}
+ if (props.onEscape !== undefined) {
+ autoRegister(
+ editor.registerCommand(
+ KEY_ESCAPE_COMMAND,
+ (e) => (props.onEscape ? props.onEscape(e) : false),
+ COMMAND_PRIORITY_CRITICAL
+ )
+ );
+ }
+
onCleanup(() => {
cleanup();
});