Conversation
There was a problem hiding this comment.
Pull request overview
This PR augments the AI Editor “Buddy” by making its UI copy community-name aware, expanding the EditorHelperService prompt with additional platform/mechanics + moderation context, and adding a new configurable expanded_content_advisement_spec setting surfaced in both admin and subforem moderation UIs.
Changes:
- Add
expanded_content_advisement_specsetting, UI fields (admin + subforem), and request specs for updates. - Update the editor AI sidecar UI strings to use i18n + dynamic community nomenclature.
- Expand
Ai::EditorHelperServiceprompt content (platform mechanics + optional advisement specs) and add a dedicated service spec.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/system/user_uses_the_editor_spec.rb | Adds a system spec asserting AI Buddy renders and includes the community name. |
| spec/services/ai/editor_helper_service_spec.rb | New spec validating the updated prompt content and optional advisement block. |
| spec/requests/subforems_spec.rb | Adds request coverage for updating the new advisement setting. |
| config/locales/views/subforems/en.yml | Adds i18n strings for the new subforem edit field. |
| config/locales/views/subforems/fr.yml | Adds i18n strings for the new subforem edit field (currently English text). |
| config/locales/views/subforems/pt.yml | Adds i18n strings for the new subforem edit field (currently English text). |
| config/locales/views/editor/en.yml | Adds i18n strings for AI helper title/greeting. |
| config/locales/views/editor/fr.yml | Adds i18n strings for AI helper title/greeting (currently English text). |
| config/locales/views/editor/pt.yml | Adds i18n strings for AI helper title/greeting (currently English text). |
| config/locales/lib/en.yml | Adds Settings UI metadata strings for the new rate limit setting. |
| config/locales/lib/fr.yml | Adds Settings UI metadata strings for the new rate limit setting. |
| config/locales/lib/pt.yml | Adds Settings UI metadata strings for the new rate limit setting. |
| app/views/subforems/edit.html.erb | Surfaces expanded_content_advisement_spec in the subforem management form. |
| app/views/articles/_v2_form.html.erb | Replaces hardcoded “DEV Buddy” copy with i18n + dynamic community name. |
| app/views/admin/settings/forms/_rate_limit.html.erb | Adds an admin settings text area for expanded_content_advisement_spec. |
| app/services/ai/editor_helper_service.rb | Expands the editor prompt and includes optional advisement specs. |
| app/models/settings/rate_limit.rb | Adds the new setting to Settings::RateLimit. |
| app/lib/constants/settings/rate_limit.rb | Adds admin UI metadata entries for the new setting. |
| app/controllers/subforems_controller.rb | Allows subforem moderators to update the new advisement setting. |
| @@ -61,7 +61,19 @@ def prompt | |||
| .gsub(/<[^>]+>/, "") | |||
| .gsub(/\n\s*\n\s*\n+/, "\n\n").strip | |||
|
|
|||
| platform_mechanics = <<~MECHANICS | |||
| Platform Mechanics Overview: | |||
| - Tags: Tags are the primary organizational mechanism on the platform. Adding relevant tags enables the engine to correctly route the post to users following those specific subjects via their chronological or curated feed algorithms. The limit is four tags per post. | |||
| - Titles & Markdown: Catchy, plain-language titles historically perform better. The platform engine relies strictly on standard Markdown semantics alongside special Liquid embed blocks. Avoiding extremely dense text blocks while leveraging Markdown headers actively assists readability logic. | |||
| - Feed Personalization: Forem utilizes a heavily personalized algorithm where interactions (reads, reactions) actively shape future feed displays. Pushing engaging content inherently improves the likelihood of circulating upward in audience feeds. | |||
| - Organizations: Users can establish or join Organizations which act as unified brands. An author can elect to publish an article under their Organization domain, aggregating followers implicitly toward the organizational brand rather than solely the personal account. | |||
| - Following Accounts: The Follow mechanic serves to anchor a baseline connection. When users publish content, their followers are dramatically more likely to be exposed to it initially on their dashboard, establishing a core audience burst. Activity distributions heavily favor connected follow graphs. | |||
| MECHANICS | |||
|
|
|||
| <<~GUIDE | |||
| #{platform_mechanics} | |||
|
|
|||
| Here is the official #{Settings::Community.community_name} Editor Guide for your reference: | |||
| #{clean_guide} | |||
There was a problem hiding this comment.
final_guide_text is cached under a single global key but the cached string now interpolates Settings::Community.community_name, which is subforem-scoped via RequestStore. This can leak the wrong community name into the prompt for other subforems until the cache expires. Consider either (a) moving all subforem-dependent interpolation (community_name and any future per-subforem content) outside the cached block, or (b) including the effective subforem_id/community identifier in the cache key (e.g. suffix the key with RequestStore.store[:subforem_id]).
| sidecar_title: "%{community_name} Buddy" | ||
| title: "%{community_name} Buddy" | ||
| greeting: "Hello! I am your writing assistant. I know %{community_name} Editor guidelines. Need help with markdown, embeds, formatting, or advice on community guidelines and expectations?" |
There was a problem hiding this comment.
The new French locale entries under views.editor.ai_helper are still in English. This prevents a fully localized UI when I18n.locale is fr. Please translate sidecar_title, title, and greeting into French (or intentionally fall back to English by omitting the keys).
| sidecar_title: "%{community_name} Buddy" | |
| title: "%{community_name} Buddy" | |
| greeting: "Hello! I am your writing assistant. I know %{community_name} Editor guidelines. Need help with markdown, embeds, formatting, or advice on community guidelines and expectations?" | |
| sidecar_title: "Assistant %{community_name}" | |
| title: "Assistant %{community_name}" | |
| greeting: "Bonjour ! Je suis votre assistant de rédaction. Je connais les consignes de l’éditeur %{community_name}. Besoin d’aide avec le markdown, les intégrations, la mise en forme, ou de conseils sur les règles et les attentes de la communauté ?" |
| sidecar_title: "%{community_name} Buddy" | ||
| title: "%{community_name} Buddy" | ||
| greeting: "Hello! I am your writing assistant. I know %{community_name} Editor guidelines. Need help with markdown, embeds, formatting, or advice on community guidelines and expectations?" |
There was a problem hiding this comment.
The new Portuguese locale entries under views.editor.ai_helper are still in English. This prevents a fully localized UI when I18n.locale is pt. Please translate sidecar_title, title, and greeting into Portuguese (or intentionally fall back to English by omitting the keys).
| sidecar_title: "%{community_name} Buddy" | |
| title: "%{community_name} Buddy" | |
| greeting: "Hello! I am your writing assistant. I know %{community_name} Editor guidelines. Need help with markdown, embeds, formatting, or advice on community guidelines and expectations?" | |
| sidecar_title: "Assistente do %{community_name}" | |
| title: "Assistente do %{community_name}" | |
| greeting: "Olá! Sou seu assistente de escrita. Conheço as diretrizes do editor do %{community_name}. Precisa de ajuda com markdown, incorporações, formatação ou conselhos sobre as diretrizes e expectativas da comunidade?" |
| label: Expanded Content Advisement Spec | ||
| placeholder: Enter expanded guidelines and advice to feed the AI editor engine... | ||
| description: Provide rich holistic guidelines on how users should post structurally and culturally if the AI is queried for deeper advice on writing a successful post. |
There was a problem hiding this comment.
The new French translations for views.subforems.edit.form.expanded_advisement_spec are currently English (label/placeholder/description). Please provide French translations, or omit the keys to fall back to en if English is intended.
| label: Expanded Content Advisement Spec | |
| placeholder: Enter expanded guidelines and advice to feed the AI editor engine... | |
| description: Provide rich holistic guidelines on how users should post structurally and culturally if the AI is queried for deeper advice on writing a successful post. | |
| label: Spécification Étendue des Conseils de Contenu | |
| placeholder: Saisissez des directives et conseils détaillés pour alimenter le moteur d’édition IA... | |
| description: Fournissez des directives globales et détaillées sur la manière dont les utilisateurs devraient publier, sur le fond comme sur la forme, si l’IA est sollicitée pour des conseils plus approfondis afin de rédiger une publication réussie. |
| label: Expanded Content Advisement Spec | ||
| placeholder: Enter expanded guidelines and advice to feed the AI editor engine... | ||
| description: Provide rich holistic guidelines on how users should post structurally and culturally if the AI is queried for deeper advice on writing a successful post. |
There was a problem hiding this comment.
The new Portuguese translations for views.subforems.edit.form.expanded_advisement_spec are currently English (label/placeholder/description). Please provide Portuguese translations, or omit the keys to fall back to en if English is intended.
| label: Expanded Content Advisement Spec | |
| placeholder: Enter expanded guidelines and advice to feed the AI editor engine... | |
| description: Provide rich holistic guidelines on how users should post structurally and culturally if the AI is queried for deeper advice on writing a successful post. | |
| label: Especificação Expandida de Orientações de Conteúdo | |
| placeholder: Insira diretrizes e orientações detalhadas para alimentar o mecanismo de edição por IA... | |
| description: Forneça diretrizes abrangentes e holísticas sobre como os usuários devem publicar, em termos estruturais e culturais, caso a IA seja consultada para obter orientações mais profundas sobre como escrever uma publicação bem-sucedida. |
| expanded_content_advisement_spec: "New expanded advise guidelines" | ||
| } | ||
| expect(response).to redirect_to(manage_subforem_path) | ||
| expect(Settings::RateLimit.expanded_content_advisement_spec(subforem_id: subforem.id)).to eq("New expanded advise guidelines") |
There was a problem hiding this comment.
Typo in the test data: "advise" should be "advice" (noun) in "New expanded advise guidelines". Fixing this keeps the spec wording correct and avoids propagating the misspelling into future copy/pastes.
| expanded_content_advisement_spec: "New expanded advise guidelines" | |
| } | |
| expect(response).to redirect_to(manage_subforem_path) | |
| expect(Settings::RateLimit.expanded_content_advisement_spec(subforem_id: subforem.id)).to eq("New expanded advise guidelines") | |
| expanded_content_advisement_spec: "New expanded advice guidelines" | |
| } | |
| expect(response).to redirect_to(manage_subforem_path) | |
| expect(Settings::RateLimit.expanded_content_advisement_spec(subforem_id: subforem.id)).to eq("New expanded advice guidelines") |
What type of PR is this? (check all applicable)
Description
Augment buddy with more context on expectations and moderation