Skip to content

Augment Buddy with more context#23139

Merged
benhalpern merged 3 commits intomainfrom
ben/smarter-assistant
Apr 14, 2026
Merged

Augment Buddy with more context#23139
benhalpern merged 3 commits intomainfrom
ben/smarter-assistant

Conversation

@benhalpern
Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Augment buddy with more context on expectations and moderation

Copilot AI review requested due to automatic review settings April 14, 2026 14:37
@benhalpern benhalpern requested review from a team as code owners April 14, 2026 14:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_spec setting, UI fields (admin + subforem), and request specs for updates.
  • Update the editor AI sidecar UI strings to use i18n + dynamic community nomenclature.
  • Expand Ai::EditorHelperService prompt 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.

Comment on lines 24 to 77
@@ -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}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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]).

Copilot uses AI. Check for mistakes.
Comment thread config/locales/views/editor/fr.yml Outdated
Comment on lines +24 to +26
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?"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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é ?"

Copilot uses AI. Check for mistakes.
Comment thread config/locales/views/editor/pt.yml Outdated
Comment on lines +24 to +26
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?"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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?"

Copilot uses AI. Check for mistakes.
Comment thread config/locales/views/subforems/fr.yml Outdated
Comment on lines +71 to +73
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.
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Comment thread config/locales/views/subforems/pt.yml Outdated
Comment on lines +71 to +73
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.
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Comment thread spec/requests/subforems_spec.rb Outdated
Comment on lines +285 to +288
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")
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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")

Copilot uses AI. Check for mistakes.
@benhalpern benhalpern merged commit 0367035 into main Apr 14, 2026
19 of 20 checks passed
@benhalpern benhalpern deleted the ben/smarter-assistant branch April 14, 2026 15:29
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