Skip to content

Add per-project issue summary instructions, with project role info in issue JSON - #339

Open
chrisdaloa wants to merge 11 commits into
haru:developfrom
chrisdaloa:feature/issue-summary-role-instructions
Open

Add per-project issue summary instructions, with project role info in issue JSON#339
chrisdaloa wants to merge 11 commits into
haru:developfrom
chrisdaloa:feature/issue-summary-role-instructions

Conversation

@chrisdaloa

Copy link
Copy Markdown
Contributor

What this adds

Per-project instructions for issue summary generation
A new issue_summary_instructions setting on the project's AI Helper settings page, following the exact same pattern already used for issue_draft_instructions, subtask_instructions, health_report_instructions and assignment_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 includes roles: [...] — the user's Redmine roles in that project, via the existing User#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_instructions to 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 the roles field on author/assigned_to/journal user
  • test/unit/agents/issue_agent_test.rbissue_summary passes issue_summary_instructions from project settings into the prompt
  • test/unit/llm_test.rb — blank-response handling
  • test/functional/ai_helper_project_settings_controller_test.rb — new field persists via the settings form
  • Rebased on latest develop; full relevant test suite green (115 runs / 362 assertions, 0 failures) and RuboCop clean on all touched Ruby files

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

Copilot AI 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.

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_instructions to project settings (DB column, controller strong params, settings form, and i18n labels).
  • Extend IssueJson to include roles: [...] 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:).

Comment thread lib/redmine_ai_helper/llm.rb Outdated
chrisdaloa and others added 2 commits July 11, 2026 09:52
The blank-summary error was hardcoded in English and streamed
directly to the UI, so non-English installs saw untranslated text.
@haru haru added the enhancement New feature or request label Jul 13, 2026
# 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'.
@haru

haru commented Aug 3, 2026

Copy link
Copy Markdown
Owner

IssueJson#format_user_with_roles (issue_json.rb:61) raises NoMethodError when issue.assigned_to is a Group (possible when Setting.issue_group_assignment is enabled), since roles_for_project is defined only on User.
image

…mmary-role-instructions

# Conflicts:
#	config/locales/ja.yml
#	lib/redmine_ai_helper/agents/issue_read_agent.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants