Add per-project issue summary instructions, with project role info in issue JSON - #339
Open
chrisdaloa wants to merge 11 commits into
Open
Add per-project issue summary instructions, with project role info in issue JSON#339chrisdaloa wants to merge 11 commits into
chrisdaloa wants to merge 11 commits into
Conversation
…sue JSON Lets project admins customize the ticket-summary prompt from the UI, and enriches the issue JSON (author, assigned_to, journal users) with each user's project role(s) so instructions can reference them, e.g. to distinguish client vs. consultant comments without the plugin needing to know any specific role-naming convention.
The plugins: key needs RuboCop ~1.72+ (lint_roller-based), but the pinned rubocop gem is ~> 1.68.0, which only understands the legacy require: syntax for loading cop-extension gems.
The UI was hanging indefinitely when the LLM returned an empty summary (e.g. after running out of tokens while reasoning). Raise explicitly so the existing rescue/stream_proc path surfaces it.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new per-project setting to control issue-summary prompt instructions, enriches the issue JSON sent to the LLM with per-project user role names, and hardens issue-summary handling when the LLM returns a blank response.
Changes:
- Add
issue_summary_instructionsto project settings (DB column, controller strong params, settings form, and i18n labels). - Extend
IssueJsonto includeroles: [...]for author/assignee/journal users, and update prompt templates + agent to pass the new instructions into the summary prompt. - Treat blank issue-summary responses as errors to avoid UI hangs, with test coverage.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/redmine_ai_helper/agents/issue_agent.rb |
Passes issue_summary_instructions from project settings into the issue summary prompt formatting. |
lib/redmine_ai_helper/util/issue_json.rb |
Adds roles to user objects (author/assigned_to/journal user) in the JSON used for summarization prompts. |
assets/prompt_templates/issue_agent/summary.yml |
Adds issue_summary_instructions input and guidance about using role info in the JSON. |
assets/prompt_templates/issue_agent/summary_ja.yml |
Japanese counterpart of the summary prompt changes. |
lib/redmine_ai_helper/llm.rb |
Raises an explicit error when the issue-summary agent returns a blank string, so the error can be streamed/displayed. |
app/controllers/ai_helper_project_settings_controller.rb |
Permits issue_summary_instructions in project settings update params. |
app/views/ai_helper_project_settings/_show.html.erb |
Adds a textarea to edit issue_summary_instructions in the project settings UI. |
db/migrate/20260709220748_add_issue_summary_instructions_to_project_settings.rb |
Adds the issue_summary_instructions column to ai_helper_project_settings. |
config/locales/en.yml |
Adds label for the new project setting field. |
config/locales/ja.yml |
Adds label for the new project setting field (JA). |
config/locales/fr.yml |
Adds label for the new project setting field (FR). |
config/locales/it.yml |
Adds label for the new project setting field (IT). |
config/locales/pt-BR.yml |
Adds label for the new project setting field (pt-BR). |
config/locales/zh.yml |
Adds label for the new project setting field (ZH). |
test/unit/agents/issue_agent_test.rb |
Verifies issue_summary_instructions is passed into prompt formatting for issue_summary. |
test/unit/util/issue_json_test.rb |
Adds coverage ensuring user role names are included for author/assignee/journal users. |
test/unit/llm_test.rb |
Adds coverage for blank-summary handling and streaming behavior. |
test/functional/ai_helper_project_settings_controller_test.rb |
Ensures issue_summary_instructions persists through the settings form update. |
.rubocop.yml |
Updates RuboCop plugin loading key (require:). |
The blank-summary error was hardcoded in English and streamed directly to the UI, so non-English installs saw untranslated text.
# Conflicts: # lib/redmine_ai_helper/util/issue_json.rb
…oller RuboCop's Rails/StrongParametersExpect cop (now enabled via the rubocop-rails version bump on develop) flagged the strong-params line touched by this branch.
params.expect is unavailable on the older Rails versions bundled with Redmine 6.0/6.1-stable, which this plugin must still support. The previous switch to params.expect broke functional tests on those CI targets with NoMethodError: undefined method `expect'.
Owner
…mmary-role-instructions # Conflicts: # config/locales/ja.yml # lib/redmine_ai_helper/agents/issue_read_agent.rb
… path after merge from upstream/develop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this adds
Per-project instructions for issue summary generation
A new
issue_summary_instructionssetting on the project's AI Helper settings page, following the exact same pattern already used forissue_draft_instructions,subtask_instructions,health_report_instructionsandassignment_suggestion_instructions. Project admins can now customize the prompt used when generating an issue's AI summary, without touching plugin code.Project role info in the issue JSON
The JSON built for the summary prompt (
issue_json.rb) previously included each user (issue author, assignee, journal authors) as just{id, name}. That made it impossible to write instructions like "distinguish comments from clients vs. from consultants," since the LLM had no way to know who's who. Each of those user objects now also includesroles: [...]— the user's Redmine roles in that project, via the existingUser#roles_for_project. The plugin intentionally does not hardcode any interpretation of role names (e.g. what counts as "client") — that logic belongs in the per-project instructions field above, since role naming varies by installation.Example use case: a project admin sets
issue_summary_instructionsto something like "Comments from users with the 'Client' role are from the customer; treat other comments as internal," and the summary/TODO section can now reflect that distinction.Bugfix bundled in
llm.rb: an issue summary request that got back a blank response from the LLM (e.g. ran out of tokens while reasoning) used to hang the UI indefinitely instead of surfacing an error. Now raises explicitly so the existing rescue/stream_proc path reports it.Testing
test/unit/util/issue_json_test.rb— new coverage for therolesfield on author/assigned_to/journal usertest/unit/agents/issue_agent_test.rb—issue_summarypassesissue_summary_instructionsfrom project settings into the prompttest/unit/llm_test.rb— blank-response handlingtest/functional/ai_helper_project_settings_controller_test.rb— new field persists via the settings formdevelop; full relevant test suite green (115 runs / 362 assertions, 0 failures) and RuboCop clean on all touched Ruby files