Skip to content

Conversation

sdemagny
Copy link
Contributor

@sdemagny sdemagny commented Oct 16, 2025

Capture d’écran 2025-10-17 à 01 59 18

Summary by CodeRabbit

  • New Features

    • Users can insert template variables as dynamic placeholders into email templates, enabling reusable and data-driven compositions.
  • Style

    • Improved visual styling for template variable elements in the composer for better visibility and selection feedback; removed outdated signature-related styles to avoid visual conflicts.

Copy link

coderabbitai bot commented Oct 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Added template-variable placeholder support to the template composer: extended BlockNote inlineContentSpecs, fetched placeholders via usePlaceholdersRetrieve (refetch on mount and focus), rendered TemplateVariableSelector in the toolbar, and moved/added stylesheet rules for inline template-variable presentation.

Changes

Cohort / File(s) Summary
Template Composer Feature Integration
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx
Imported InlineTemplateVariable, TemplateVariableSelector, and usePlaceholdersRetrieve; extended TEMPLATE_BLOCKNOTE_SCHEMA.inlineContentSpecs with 'template-variable': InlineTemplateVariable; hooked usePlaceholdersRetrieve (refetch on mount/window focus); wired placeholders & loading into TemplateComposer and rendered TemplateVariableSelector in the toolbar.
Template Variable Styling
src/frontend/src/features/blocknote/inline-template-variable/_index.scss
Added styles for span[data-inline-content-type="template-variable"] (padding, border radius, bg color, color, font-size, monospace font, non-selectable) and selected-node state .node-template-variable.ProseMirror-selectednode span[...] with distinct background.
Signature Composer Styling Cleanup
src/frontend/src/features/layouts/components/admin/modal-compose-signature/_index.scss
Removed the .signature-composer block that previously included template-variable inline styling and selected-node styles (cleaned duplicate/relocated styles).

Sequence Diagram(s)

sequenceDiagram
    participant Mount as TemplateComposer Mount
    participant Hook as usePlaceholdersRetrieve
    participant API as Placeholders API
    participant Composer as TemplateComposer
    participant Selector as TemplateVariableSelector

    Mount->>Hook: initialize (on mount)
    Hook->>API: fetch placeholders
    API-->>Hook: placeholders data
    Hook-->>Composer: update placeholders & loading
    Composer->>Composer: extend BlockNote schema with 'template-variable'
    Composer->>Selector: render with placeholders & loading
    Note over Selector: user chooses placeholder → inserted as inline content

    rect rgb(240,248,255)
      Note over Mount,Hook: refetch on window focus
      Mount-->>Hook: trigger refetch
      Hook->>API: re-fetch placeholders
      API-->>Hook: updated data
      Hook-->>Composer: update placeholders
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰✨
I nibble code and stitch a thread so clever,
Placeholders fetched on mount and focus ever,
A tiny selector hops into the toolbar light,
Inline variables glowing calm and bright,
Templates now sing through day and night.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "✨(template) allow to insert variable in message template" is directly related to the main change in the changeset. The modifications across all three files are focused on enabling users to insert template variables into message templates—adding the necessary component (TemplateVariableSelector), schema extensions (template-variable inline content), and associated styling. The title accurately captures this primary objective and uses clear, specific language that would allow reviewers scanning the commit history to quickly understand the core functionality being introduced.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc7a55 and bf77b07.

📒 Files selected for processing (3)
  • src/frontend/src/features/blocknote/inline-template-variable/_index.scss (1 hunks)
  • src/frontend/src/features/layouts/components/admin/modal-compose-signature/_index.scss (0 hunks)
  • src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (5 hunks)

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/_index.scss (1)

20-22: Use theme variable instead of hardcoded color.

The selected node styling uses a hardcoded color #94badc, which breaks consistency with the theme-based approach used elsewhere in the file (e.g., lines 12-13, 15).

Consider using a theme variable for consistency:

-  .node-template-variable.ProseMirror-selectednode span[data-inline-content-type="template-variable"] {
+  .node-template-variable.ProseMirror-selectednode span[data-inline-type="template-variable"] {
-    background: #94badc;
+    background: var(--c--theme--colors--primary-200);

Note: Also corrected the attribute selector to match the fix in the previous comment.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56f3b4c and 67d4660.

📒 Files selected for processing (2)
  • src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/_index.scss (1 hunks)
  • src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (2)
src/frontend/src/features/blocknote/inline-template-variable/index.tsx (2)
  • InlineTemplateVariable (63-83)
  • TemplateVariableSelector (14-60)
src/frontend/src/features/api/gen/placeholders/placeholders.ts (1)
  • usePlaceholdersRetrieve (168-196)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: docker-publish-mta-in / docker-build-push
  • GitHub Check: docker-publish-socks-proxy / docker-build-push
  • GitHub Check: test-back
  • GitHub Check: lint-back
  • GitHub Check: check-api-state
  • GitHub Check: build-front
🔇 Additional comments (2)
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (2)

179-182: Verify serialization of template variables.

The template variable feature is being integrated, but there's a TODO comment in the InlineTemplateVariable component (see src/frontend/src/features/blocknote/inline-template-variable/index.tsx, line 73-74) indicating that serialization/deserialization during export and parsing may not be fully implemented. This could affect saving and loading templates with variables.

Please confirm that template variables correctly serialize when saving templates and deserialize when loading them. Test the following workflow:

  1. Insert a template variable into a template
  2. Save the template
  3. Reload/reopen the template
  4. Verify the variable displays correctly and can be edited

If serialization is incomplete, the variables may not persist correctly across saves.


3-3: Good integration of template variable feature.

The integration of InlineTemplateVariable and TemplateVariableSelector follows the established pattern in the codebase. The schema extension, placeholder fetching, and toolbar integration are implemented correctly.

Also applies to: 23-23, 179-182

@sdemagny sdemagny force-pushed the sdem/insert_variable_into_msg_template branch from 67d4660 to 7fc7a55 Compare October 20, 2025 15:31
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (1)

46-51: Error handling for placeholders API is already flagged.

This concern about missing error state handling (isError, error) was raised in previous review comments. The current implementation will silently fail with an empty object if the API call fails.

🧹 Nitpick comments (1)
src/frontend/src/features/blocknote/inline-template-variable/_index.scss (1)

14-16: Consider using a CSS custom property for the selected background.

The selected-node background uses a hardcoded color #94badc while other colors use CSS custom properties. For consistency and maintainability, consider defining this in the theme variables.

-.node-template-variable.ProseMirror-selectednode span[data-inline-content-type="template-variable"] {
-    background: #94badc;
+.node-template-variable.ProseMirror-selectednode span[data-inline-type="template-variable"] {
+    background: var(--c--theme--colors--primary-200);
 }

Note: Also update the selector to match the fix in the previous comment.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67d4660 and 7fc7a55.

📒 Files selected for processing (3)
  • src/frontend/src/features/blocknote/inline-template-variable/_index.scss (1 hunks)
  • src/frontend/src/features/layouts/components/admin/modal-compose-signature/_index.scss (0 hunks)
  • src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (5 hunks)
💤 Files with no reviewable changes (1)
  • src/frontend/src/features/layouts/components/admin/modal-compose-signature/_index.scss
🧰 Additional context used
🧬 Code graph analysis (1)
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (2)
src/frontend/src/features/blocknote/inline-template-variable/index.tsx (2)
  • InlineTemplateVariable (63-83)
  • TemplateVariableSelector (14-60)
src/frontend/src/features/api/gen/placeholders/placeholders.ts (1)
  • usePlaceholdersRetrieve (168-196)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: docker-publish-socks-proxy / docker-build-push
  • GitHub Check: check-api-state
  • GitHub Check: build-front
  • GitHub Check: test-back
  • GitHub Check: lint-back
🔇 Additional comments (1)
src/frontend/src/features/layouts/components/mailbox-settings/modal-compose-template/template-composer.tsx (1)

3-3: LGTM! Template variable integration looks solid.

The integration properly:

  • Imports the necessary components
  • Extends the BlockNote schema with the new inline content type
  • Renders the selector in the toolbar with correct props

The implementation follows the same pattern as the existing SignatureTemplateSelector.

Also applies to: 23-23, 179-182

@sdemagny sdemagny force-pushed the sdem/insert_variable_into_msg_template branch from 7fc7a55 to bf77b07 Compare October 20, 2025 15:58
@sdemagny sdemagny merged commit bf77b07 into main Oct 20, 2025
10 of 11 checks passed
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.

1 participant