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: edit with ai button (#5290)

Peter Chinmand624070be4d9
diff --git a/apps/web/src/features/block-md/component/DocumentAiEditBar.tsx b/apps/web/src/features/block-md/component/DocumentAiEditBar.tsx
index a3c19fc756..825dbcf868 100644
--- a/apps/web/src/features/block-md/component/DocumentAiEditBar.tsx
+++ b/apps/web/src/features/block-md/component/DocumentAiEditBar.tsx
@@ -24,10 +24,11 @@ export function DocumentAiEditBar(props: { documentId: string }) {
const [focused, setFocused] = createSignal(false);
const [prompt, setPrompt] = createSignal('');
- const editor = buildChatEditor();
+ let editor = buildChatEditor();
const collapse = () => {
setExpanded(false);
+ setPrompt('');
md.editor?.focus();
};
@@ -49,16 +50,25 @@ export function DocumentAiEditBar(props: { documentId: string }) {
.finally(() => setEditing(false));
};
- editor
- .onEnter(() => {
- submit();
- return true;
- })
- .onEscape(() => {
- collapse();
- return true;
- })
- .onChange((markdown) => setPrompt(markdown));
+ const configureEditor = () =>
+ buildChatEditor()
+ .onEnter(() => {
+ submit();
+ return true;
+ })
+ .onEscape(() => {
+ collapse();
+ return true;
+ })
+ .onChange((markdown) => setPrompt(markdown));
+
+ editor = configureEditor();
+
+ const expand = () => {
+ editor = configureEditor();
+ setExpanded(true);
+ requestAnimationFrame(() => editor.controls.focus());
+ };
return (
<div class="flex justify-end">
@@ -77,9 +87,10 @@ export function DocumentAiEditBar(props: { documentId: string }) {
when={expanded()}
fallback={
<Button
- onClick={() => {
+ onClick={(event) => {
+ event.stopPropagation();
if (editing()) cancelAiEdit(props.documentId);
- else setExpanded(true);
+ else expand();
}}
onMouseEnter={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
@@ -121,7 +132,7 @@ export function DocumentAiEditBar(props: { documentId: string }) {
>
<div class="flex flex-col gap-2 p-3" use:clickOutside={collapse}>
<div class="flex items-start gap-2">
- <span class="mt-0.5 flex size-4 shrink-0 items-center justify-center text-accent">
+ <span class="flex h-8 w-4 shrink-0 items-center justify-center text-accent">
<AnimatedStarIcon triggerAnimation={focused()} />
</span>
<div class="min-w-0 grow text-sm text-ink">
diff --git a/apps/web/src/features/channel/Message/tests/reactions.test.tsx b/apps/web/src/features/channel/Message/tests/reactions.test.tsx
index aec02fba88..4d76a38392 100644
--- a/apps/web/src/features/channel/Message/tests/reactions.test.tsx
+++ b/apps/web/src/features/channel/Message/tests/reactions.test.tsx
@@ -49,7 +49,7 @@ describe('Reactions', () => {
});
it('calls onReact with chip emoji when a reaction chip is clicked', async () => {
- const user = userEvent.setup();
+ const user = userEvent.setup({ skipHover: true });
const onReact = vi.fn();
render(() => (