feat(onboarding): show "What to Expect" first in summary view (#44922)

When using the "summary view", in the case we hit platform limits, in
Onboarding PRs or Reconfigure PR comments, we should prioritise the
"What to Expect" as it provides a more actionable "executive summary" of
what's needed in the repository.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
This commit is contained in:
Jamie Tanna
2026-08-21 11:53:08 +00:00
committed by GitHub
parent 4593b9b5a6
commit d1b6830ddf
4 changed files with 121 additions and 31 deletions
@@ -155,6 +155,10 @@ describe('workers/repository/onboarding/pr/index', () => {
// the summary groups them under a manager heading instead
expect(prBody).not.toContain('`package.json` (npm)');
expect(prBody).toContain('#### npm\n\n * `package.json`');
// in the summary view, "What to Expect" should render before "Detected Package Files"
expect(prBody.indexOf('### What to Expect')).toBeLessThan(
prBody.indexOf('### Detected Package Files'),
);
});
it('does not attempt to replace package files when none were detected', async () => {
+57 -11
View File
@@ -86,10 +86,35 @@ async function ensureOnboardingAutoCloseAge(existingPr: Pr): Promise<boolean> {
return false;
}
/**
* Full onboarding PRs list package files before the PR list.
*/
const FULL_SECTION_ORDER = [
'PACKAGE FILES',
'CONFIG',
'BASEBRANCH',
'PRLIST',
'WARNINGS',
'ERRORS',
] as const;
/**
* "Summarised" onboarding PRs list PRs before other sections.
*/
const SUMMARY_SECTION_ORDER = [
'PRLIST',
'CONFIG',
'BASEBRANCH',
'PACKAGE FILES',
'WARNINGS',
'ERRORS',
] as const;
function buildOnboardingPrTemplate(
config: RenovateConfig,
configFile: string,
rebaseCheckBox: string,
sectionOrder: readonly string[],
): string {
let prTemplate = `Welcome to [Renovate](${
GlobalConfig.get('productLinks').homepage
@@ -121,12 +146,7 @@ function buildOnboardingPrTemplate(
`
---
{{PACKAGE FILES}}
{{CONFIG}}
{{BASEBRANCH}}
{{PRLIST}}
{{WARNINGS}}
{{ERRORS}}
${sectionOrder.map((section) => `{{${section}}}`).join('\n')}
---
@@ -249,7 +269,12 @@ export async function ensureOnboardingPr(
let prBody = finalizeOnboardingPrBody(
fillOnboardingPrBody(
buildOnboardingPrTemplate(config, configFile, rebaseCheckBox),
buildOnboardingPrTemplate(
config,
configFile,
rebaseCheckBox,
FULL_SECTION_ORDER,
),
{
packageFiles: packageFilesDesc,
config: configDesc,
@@ -267,12 +292,33 @@ export async function ensureOnboardingPr(
logger.debug(
'Onboarding PR body exceeds platform limit, switching to summary PR list and package files',
);
prBody = prBody.replace(prList, getExpectedPrListSummary(config, branches));
const prListSummary = getExpectedPrListSummary(config, branches);
if (packageFilesDesc) {
prBody = prBody.replace(
packageFilesDesc,
`### Detected Package Files\n\n${getPackageFilesSummary(packageFiles)}`,
const packageFilesSummary = `### Detected Package Files\n\n${getPackageFilesSummary(packageFiles)}`;
// "What to Expect" should render before "Detected Package Files" in the summary view,
// so rebuild from a template with that section order rather than reordering the rendered body.
prBody = finalizeOnboardingPrBody(
fillOnboardingPrBody(
buildOnboardingPrTemplate(
config,
configFile,
rebaseCheckBox,
SUMMARY_SECTION_ORDER,
),
{
packageFiles: packageFilesSummary,
config: configDesc,
baseBranch: baseBranchDesc,
prList: prListSummary,
warnings,
errors,
},
),
config,
onboardingConfigHashComment,
);
} else {
prBody = prBody.replace(prList, prListSummary);
}
}
@@ -114,6 +114,10 @@ describe('workers/repository/reconfigure/comment', () => {
// the summary groups them under a manager heading instead
expect(prBody).not.toContain('`package.json` (npm)');
expect(prBody).toContain('#### npm\n\n * `package.json`');
// in the summary view, "What to Expect" should render before "Detected Package Files"
expect(prBody.indexOf('### What to Expect')).toBeLessThan(
prBody.indexOf('### Detected Package Files'),
);
});
it('does not attempt to replace package files when none were detected', async () => {
+56 -20
View File
@@ -24,16 +24,37 @@ import {
} from '../onboarding/pr/pr-list.ts';
import type { ReconfigurePrCommentSections } from '../onboarding/pr/types.ts';
// TODO #22198
const RECONFIGURE_PR_COMMENT_TEMPLATE = `This is a reconfigure PR comment to help you understand and re-configure your renovate bot settings. If this Reconfigure PR were to be merged, we'd expect to see the following outcome:\n\n
// Full reconfigure PR comments list package files before the PR list.
const SECTION_ORDER = [
'PACKAGE FILES',
'CONFIG',
'BASEBRANCH',
'PRLIST',
'WARNINGS',
'ERRORS',
] as const;
// Once the body is summarised, "What to Expect" should render before "Detected Package Files".
const SUMMARY_SECTION_ORDER = [
'PRLIST',
'CONFIG',
'BASEBRANCH',
'PACKAGE FILES',
'WARNINGS',
'ERRORS',
] as const;
function buildReconfigurePrCommentTemplate(
sectionOrder: readonly string[],
): string {
let prCommentTemplate = `This is a reconfigure PR comment to help you understand and re-configure your renovate bot settings. If this Reconfigure PR were to be merged, we'd expect to see the following outcome:\n\n`;
// TODO #22198
prCommentTemplate += `
---
{{PACKAGE FILES}}
{{CONFIG}}
{{BASEBRANCH}}
{{PRLIST}}
{{WARNINGS}}
{{ERRORS}}
${sectionOrder.map((section) => `{{${section}}}`).join('\n')}
`;
return prCommentTemplate;
}
function fillReconfigurePrCommentBody(
prCommentTemplate: string,
@@ -76,25 +97,40 @@ export async function ensureReconfigurePrComment(
const baseBranchDesc = getBaseBranchDesc(config);
const prList = getExpectedPrList(config, branches);
let prBody = fillReconfigurePrCommentBody(RECONFIGURE_PR_COMMENT_TEMPLATE, {
packageFiles: packageFilesDesc,
config: configDesc,
baseBranch: baseBranchDesc,
prList,
warnings,
errors,
});
let prBody = fillReconfigurePrCommentBody(
buildReconfigurePrCommentTemplate(SECTION_ORDER),
{
packageFiles: packageFilesDesc,
config: configDesc,
baseBranch: baseBranchDesc,
prList,
warnings,
errors,
},
);
if (prBody.length > platform.maxBodyLength()) {
logger.debug(
'Reconfigure PR body exceeds platform limit, switching to summary PR list and package files',
);
prBody = prBody.replace(prList, getExpectedPrListSummary(config, branches));
const prListSummary = getExpectedPrListSummary(config, branches);
if (packageFilesDesc) {
prBody = prBody.replace(
packageFilesDesc,
`### Detected Package Files\n\n${getPackageFilesSummary(packageFiles)}`,
const packageFilesSummary = `### Detected Package Files\n\n${getPackageFilesSummary(packageFiles)}`;
// "What to Expect" should render before "Detected Package Files" in the summary view,
// so rebuild from a template with that section order rather than reordering the rendered body.
prBody = fillReconfigurePrCommentBody(
buildReconfigurePrCommentTemplate(SUMMARY_SECTION_ORDER),
{
packageFiles: packageFilesSummary,
config: configDesc,
baseBranch: baseBranchDesc,
prList: prListSummary,
warnings,
errors,
},
);
} else {
prBody = prBody.replace(prList, prListSummary);
}
}