Skip to content

Resolves #364, Append macro content into the editors instead of replacing the entire content - #366

Open
vanboom wants to merge 1 commit into
abhinavxd:mainfrom
vanboom:364-append-macros
Open

Resolves #364, Append macro content into the editors instead of replacing the entire content#366
vanboom wants to merge 1 commit into
abhinavxd:mainfrom
vanboom:364-append-macros

Conversation

@vanboom

@vanboom vanboom commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Appending macros allows them to be used as composable text snippets while editing messages. This works very well in companion with the CTRL+M feature that allows quick access to the macros from the text editor.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed macro content insertion to preserve existing message content instead of replacing it. When applying a macro in conversations or replies, your current text is now appended with the macro content rather than being overwritten.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Macro content handlers in two conversation UI components now preserve existing editor content. The new conversation macro and reply macro watchers append their injected content to the current editor state instead of replacing it entirely, allowing users to combine macro text with manually entered content.

Changes

Macro Content Appending in Editors

Layer / File(s) Summary
Macro content appending in conversation and reply editors
frontend/apps/main/src/features/conversation/CreateConversation.vue, frontend/apps/main/src/features/conversation/ReplyBox.vue
Macro watchers now concatenate injected content with existing editor text. CreateConversation.vue appends message_content to form.values.content, and ReplyBox.vue appends to htmlContent, enabling users to preserve manually entered text when applying macros.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A macro's whisper,
No longer doth it steal the words,
But joins them in chorus—
Append, not replace, it learns,
Content flows free.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately and concisely describes the main change: converting macro insertion from replacing to appending content in editors.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/apps/main/src/features/conversation/CreateConversation.vue (1)

503-513: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add guard to check message_content exists before appending.

The watcher appends message_content without first verifying it exists. Since message_content is optional in the macro schema (context snippet from formSchema.js:11-34), this could append undefined to the content. This is inconsistent with ReplyBox.vue line 479, which includes a guard: if (conversationStore.getMacro('reply').message_content).

🛡️ Proposed fix to add guard and improve consistency
 watch(
   () => conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).id,
   () => {
+    const macro = conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION)
+    if (!macro.message_content) return
+    
     const currentValue = form.values?.content || ''
-    form.setFieldValue(
-      'content',
-      currentValue + conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content
-    )
+    form.setFieldValue('content', currentValue + macro.message_content)
   },
   { deep: true }
 )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/apps/main/src/features/conversation/CreateConversation.vue` around
lines 503 - 513, The watcher for
conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).id appends
message_content unguarded, which can add "undefined" because message_content is
optional; update the watcher in CreateConversation.vue to first read the macro
via conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION), check that
macro.message_content is truthy (or !== undefined) before calling
form.setFieldValue('content', ...), and only append when message_content
exists—mirroring the guard used in ReplyBox.vue.
🧹 Nitpick comments (2)
frontend/apps/main/src/features/conversation/CreateConversation.vue (1)

506-510: ⚡ Quick win

Consider adding spacing between existing content and appended macro.

When macro content is appended directly to existing editor content, text may run together without proper separation. Consider adding a space, newline, or other separator to ensure readability when composing multiple text snippets.

💡 Example with spacing
     const currentValue = form.values?.content || ''
     form.setFieldValue(
       'content',
-      currentValue + conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content
+      currentValue + ' ' + conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content
     )

Or with a line break if that better fits the use case:

     const currentValue = form.values?.content || ''
     form.setFieldValue(
       'content',
-      currentValue + conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content
+      currentValue + '<br>' + conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content
     )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/apps/main/src/features/conversation/CreateConversation.vue` around
lines 506 - 510, Append a separator when concatenating macro text to existing
editor content to avoid words running together: in the block using currentValue,
form.setFieldValue, and
conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content,
detect if currentValue is non-empty and insert a single space or newline
(depending on UX preference) between currentValue and the macro message_content
before calling form.setFieldValue so the appended macro is always separated from
existing text.
frontend/apps/main/src/features/conversation/ReplyBox.vue (1)

479-481: ⚡ Quick win

Consider adding spacing between existing content and appended macro.

Similar to CreateConversation.vue, when macro content is appended directly to existing editor content, text may run together. Consider adding a separator to improve readability when composing multiple text snippets.

💡 Example with spacing
     if (conversationStore.getMacro('reply').message_content) {
-      htmlContent.value = htmlContent.value + conversationStore.getMacro('reply').message_content
+      htmlContent.value = htmlContent.value + ' ' + conversationStore.getMacro('reply').message_content
     }

Or with a line break:

     if (conversationStore.getMacro('reply').message_content) {
-      htmlContent.value = htmlContent.value + conversationStore.getMacro('reply').message_content
+      htmlContent.value = htmlContent.value + '<br>' + conversationStore.getMacro('reply').message_content
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/apps/main/src/features/conversation/ReplyBox.vue` around lines 479 -
481, The macro append currently concatenates directly: when
conversationStore.getMacro('reply').message_content exists it does
htmlContent.value = htmlContent.value + ... which can run text together; update
the logic around htmlContent.value and
conversationStore.getMacro('reply').message_content to insert a separator (e.g.,
a space or "\n\n" / "<br/>" depending on HTML vs plain text context) only when
htmlContent.value is non-empty so appended macro content is clearly separated
from existing content.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@frontend/apps/main/src/features/conversation/CreateConversation.vue`:
- Around line 503-513: The watcher for
conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).id appends
message_content unguarded, which can add "undefined" because message_content is
optional; update the watcher in CreateConversation.vue to first read the macro
via conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION), check that
macro.message_content is truthy (or !== undefined) before calling
form.setFieldValue('content', ...), and only append when message_content
exists—mirroring the guard used in ReplyBox.vue.

---

Nitpick comments:
In `@frontend/apps/main/src/features/conversation/CreateConversation.vue`:
- Around line 506-510: Append a separator when concatenating macro text to
existing editor content to avoid words running together: in the block using
currentValue, form.setFieldValue, and
conversationStore.getMacro(MACRO_CONTEXT.NEW_CONVERSATION).message_content,
detect if currentValue is non-empty and insert a single space or newline
(depending on UX preference) between currentValue and the macro message_content
before calling form.setFieldValue so the appended macro is always separated from
existing text.

In `@frontend/apps/main/src/features/conversation/ReplyBox.vue`:
- Around line 479-481: The macro append currently concatenates directly: when
conversationStore.getMacro('reply').message_content exists it does
htmlContent.value = htmlContent.value + ... which can run text together; update
the logic around htmlContent.value and
conversationStore.getMacro('reply').message_content to insert a separator (e.g.,
a space or "\n\n" / "<br/>" depending on HTML vs plain text context) only when
htmlContent.value is non-empty so appended macro content is clearly separated
from existing content.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c2423247-2b50-42b3-9b7f-e4c529cb1c47

📥 Commits

Reviewing files that changed from the base of the PR and between 5e9d964 and 0fb169b.

📒 Files selected for processing (2)
  • frontend/apps/main/src/features/conversation/CreateConversation.vue
  • frontend/apps/main/src/features/conversation/ReplyBox.vue

@vanboom vanboom changed the title #364, Append macro content into the editors instead of replacing the entire content Resolves #364, Append macro content into the editors instead of replacing the entire content Jun 4, 2026
@abhinavxd

Copy link
Copy Markdown
Owner

We should insert macro content at the cursor position - that's even better.

The current string concat also sometimes leaves a stray

on an empty editor inserting through the editor avoids that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants