Comments

This section provides information on how to configure AI assistant for comments, delay comment notifications, and configure comment threading.

If you make a configuration change, P4 Code Review will not use it until the configuration cache has been reloaded, this forces P4 Code Review to use the new configuration.

You must be an admin or super user to reload the P4 Code Review config cache. Navigate to the User id dropdown menu, select System Information, click the Cache Info tab, and click the Reload Configuration button.

AI Assistant for comments

The AI Assistant improves a comment by providing a summary, suggesting alternative text and fixing the spelling or grammar. By default, the following prompts are used for each of the text suggestions options.

These prompts are found in the keys of the ai_review block within the config.php file:

  • 'improve_comment' - "You are a writing assistant helping users improve short comments or messages. Please revise this input text to make it clearer, more professional, and appropriate for the intended context. Preserve the original intent and tone unless it is unclear or inappropriate. If the comment is vague, suggest a more specific version. Avoid making the text overly formal unless necessary. Return only the improved version of the text, without explanations. For this statement:"

  • summarize_text - "You are a summarization assistant helping users condense their writing into a clear and concise summary. Please summarize this text in a way that preserves the key points and intent. Use plain language and keep the summary brief and easy to understand. If the original text includes action items, decisions, or important context, make sure those are included in the summary.Return only the summary, without explanations or commentary. For this statement:"

  • fix_spelling_and_grammar - "You are a writing assistant helping users correct spelling, grammar, and punctuation in short comments or messages. Please correct any spelling, grammar, punctuation, or basic sentence structure issues. Do not change the tone, intent, or style unless necessary to fix the grammar. Keep the revised version natural and readable. Return only the corrected version of the text, without explanations. For this statement:"

  • custom_prompt - By default, this is empty. Add a custom prompt for your AI Assistant, for example "Convert this text into Spanish".

These prompts can be edited to help the AI Assistant better support your specific code review requirements.

If you remove a prompt from a key, the corresponding option is not available within the AI Assistant. For example, if you remove the prompt text from the summarize_text key, the Summarize text option will not be available to select when using the AI Assistant.

Comment notification delay

By default, comment notifications are delayed to allow reviewers to add or edit comments as they progress through a review without sending a notification for each individual comment on the review. Comment notifications are rolled up into a single notification and sent either manually by the reviewer, or automatically after the notification delay time has been exceeded.

The delay countdown is reset each time the reviewer adds or edits a comment on the review, by default the notification delay time is set to 30 minutes.

  • If you are commenting on more than one review, each of the reviews that you are commenting on has its own notification delay countdown that only applies to the comments that you make on that review.
  • If another reviewer is making comments on the same review as you, that reviewer has their own notification delay timer for that review.
  • If you manually send a delayed comment notification, the notification will only contain the comments that you made on that review.

The comment notification delay does not delay the posting of the comments, only the comment notification is delayed.

Comment notifications are only delayed for comments on reviews. Comments on commits or jobs produce notifications immediately.

To change the comment notification delay time, update the SWARM_ROOT/data/config.php file to include the following configuration item within the comments block:

<?php
'comments' => array(
'notification_delay_time' => 1800, //Default to 30 minutes 1800 seconds
),

notification_delay_time: Specifies the comment notification delay time in seconds.

  • Set to 0 to send the comment notification immediately the Post button is clicked.
  • The default value if notification_delay_time is not specified is 1800 seconds (30 minutes).

Comment threading

By default, you can reply to comments, replies are displayed in a thread below the parent comment. Comment thread depth is set to 4 by default, this means you can have up to 4 levels of replies for a parent comment. The Reply link is not displayed for replies at or above the maximum thread depth set for P4 Code Review. If the parent comment is archived, replies are archived with the parent, see Archiving comments. Comment threading depth is set by the max_depth configurable.

If the thread depth is reduced by a P4 Code Review administrator, earlier replies at a deeper level will continue to be displayed but you cannot reply to them.

To configure comment threading, update the SWARM_ROOT/data/config.php file to include the following configuration item within the comments block:

<?php
'comments' => array(
'threading' => array(
'max_depth' => 4, // default depth 4, to disable comment threading set to 0
),
),

max_depth: Specifies maximum depth of a comment thread.

  • Set to 0 to disable comment threading.
  • The default value if max_depth is not specified is 4.