From aa50a89f30ae9f6e25e3380d3536d031940c82db Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Fri, 13 Nov 2026 03:30:45 -0600 Subject: [PATCH 1/2] ci/vercel-build-log: Keep big changed-page lists a Slack table A table over Slack's 10,000 characters fell back to text rows, which Slack split into several replies and unfurled the preview links under. Now the table keeps the pages that fit and counts the rest in a last row, with the pages past the PR comment's own limit. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d43a-2ab9-77c4-9ac4-aeea3b840866 Co-authored-by: Amp --- AGENTS.md | 4 ++-- dev/vercel-build-log.mjs | 41 ++++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 69bab4810..b98002e52 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -191,8 +191,8 @@ GH_TOKEN=$(gh auth token) GITHUB_REPOSITORY=sourcegraph/docs \ A build that passed also copies the table of changed pages from the `preview-links.yml` comment into the Slack reply: each page before, after, and its diff for an open PR; each page in production and its diff for a - merged one. It is a Slack table block, or a line of text per row when the - table is over Slack's 10,000 characters. + merged one. It is a Slack table block, and the pages past Slack's 10,000 + characters for a table are counted in its last row. - It reads Vercel with the `VERCEL_TOKEN` repo secret, a token scoped to the `sourcegraph-docs` project that expires 2026-12-10; mint a new one with `POST /v3/user/tokens?teamId=` and `projectId` in the body. diff --git a/dev/vercel-build-log.mjs b/dev/vercel-build-log.mjs index 11089061f..0576a3748 100644 --- a/dev/vercel-build-log.mjs +++ b/dev/vercel-build-log.mjs @@ -30,8 +30,9 @@ * when the build passed, the table of docs pages the PR changed, copied * from the preview-links workflow's PR comment: each page before, after, * and its diff for an open PR; each page in production and its diff for a - * merged one. It is a Slack table block, or a line of text per row when - * the pages are not one table Slack takes. The + * merged one. It is a Slack table block, ending in a count of the pages + * past its 10,000 characters, or a line of text per row when the pages + * are not one table Slack takes. The * post is looked for a week back (so a re-run by hand still finds it) and * for up to 30 minutes (the app can post minutes after this runs). Skipped * when SLACK_BOT_TOKEN or SLACK_CHANNEL_ID is unset; a Slack error is a @@ -478,8 +479,11 @@ function slackTableCell(markdown) { // The rows as a Slack table block, or nothing when they are not one table // Slack takes: a message holds one table (two PRs at one commit have one -// each), its rows have the same number of cells (the list from before the -// table has no header), and its cells hold SLACK_TABLE_CHARACTERS in all. +// each), and its rows have the same number of cells (the list from before +// the table has no header). +// +// Its cells hold SLACK_TABLE_CHARACTERS in all, so the pages past that are +// counted in a last row, with the pages past the PR comment's own limit. // The Markdown is counted, which is longer than the text and URLs in it function slackTable(rows) { const oneTable = @@ -487,10 +491,35 @@ function slackTable(rows) { rows.filter(isHeader).length === 1 && isHeader(rows[0]) && rows.every(cells => cells.length === rows[0].length); - if (!oneTable || rows.flat().join('').length > SLACK_TABLE_CHARACTERS) { + if (!oneTable) { return undefined; } - return {type: 'table', rows: rows.map(cells => cells.map(slackTableCell))}; + const [header, ...pages] = rows; + let more = Number(pages.at(-1)?.[0].match(/^…and (\d+) more$/)?.[1] ?? 0); + if (more > 0) { + pages.pop(); + } + const shown = () => [ + header, + ...pages, + ...(more > 0 + ? [ + header.map((_, column) => + column === 0 + ? `…and ${more} more in the PR comment` + : '' + ) + ] + : []) + ]; + while (shown().flat().join('').length > SLACK_TABLE_CHARACTERS) { + pages.pop(); + more++; + } + return { + type: 'table', + rows: shown().map(cells => cells.map(slackTableCell)) + }; } // The preview-links workflow is started by the same deployment event as this From ae3ab3c28c3a6f23de91d7cf181c1af0e59a4c60 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:59:23 -0600 Subject: [PATCH 2/2] ci/vercel-build-log: Keep text rows to one Slack message Slack splits text over 4,000 characters into several messages, each carrying the log file again. The text rows for two PRs at one commit now stop short of that and count the rest in a last line. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d43a-2ab9-77c4-9ac4-aeea3b840866 Co-authored-by: Amp --- dev/vercel-build-log.mjs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/dev/vercel-build-log.mjs b/dev/vercel-build-log.mjs index 0576a3748..7e4c447dc 100644 --- a/dev/vercel-build-log.mjs +++ b/dev/vercel-build-log.mjs @@ -64,6 +64,8 @@ const PREVIEW_LINKS_WAIT_MINUTES = 1; const PREVIEW_LINKS_POLL_SECONDS = 10; // What the cells of a Slack table block can hold in all const SLACK_TABLE_CHARACTERS = 10_000; +// What Slack posts as one message: it splits longer text at line breaks +const SLACK_TEXT_CHARACTERS = 4_000; const API_URL = process.env.GITHUB_API_URL ?? 'https://api.github.com'; const REPOSITORY = process.env.GITHUB_REPOSITORY; @@ -565,7 +567,9 @@ async function changedPageRowsOf(pulls) { } // The message a file is shared with: the PR link, and the changed pages as -// a table block, or as lines of text when they are not one table Slack takes +// a table block, or as lines of text when they are not one table Slack takes. +// Slack splits text over SLACK_TEXT_CHARACTERS into messages that each carry +// the file again, so the lines past that are counted in a last line function fileMessage(pulls, error, changedPages) { const text = [ error && `> ${error}`, @@ -575,11 +579,20 @@ function fileMessage(pulls, error, changedPages) { .join('\n'); const table = slackTable(changedPages); if (!table) { - return { - initial_comment: [text, ...changedPages.map(slackTextRow)].join( - '\n' - ) - }; + const lines = changedPages.map(slackTextRow); + let shown = lines.length; + const comment = () => + [ + text, + ...lines.slice(0, shown), + ...(shown < lines.length + ? [`…and ${lines.length - shown} more in the PR comments`] + : []) + ].join('\n'); + while (comment().length > SLACK_TEXT_CHARACTERS) { + shown--; + } + return {initial_comment: comment()}; } return { blocks: JSON.stringify([