Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): link the release notes instead of pasting the changeset (#4042)

Andrew Mikofalvy75446377d724
diff --git a/.github/scripts/write-back-gate.mjs b/.github/scripts/write-back-gate.mjs
index 3eea1b01b..155dd41ac 100644
--- a/.github/scripts/write-back-gate.mjs
+++ b/.github/scripts/write-back-gate.mjs
@@ -9,7 +9,6 @@ const LINEAR_UPLOAD_RE = /^https?:\/\/uploads\.linear\.app\//i;
const RELEASE_VERSION_RE = /^v?(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/;
const RELEASES_URL = 'https://github.com/inkeep/open-knowledge/releases';
-const MAX_PROSE_CHARS = 1200;
export function classifyAttachment(rawUrl) {
const url = String(rawUrl ?? '').trim();
@@ -100,11 +99,6 @@ export function markerSuffixFor(originUrl) {
return `?notified=${encodeURIComponent(String(originUrl ?? ''))}`;
}
-export function originAlreadyNotified(attachmentUrls, originUrl) {
- const suffix = markerSuffixFor(originUrl);
- return (attachmentUrls ?? []).some((u) => String(u ?? '').endsWith(suffix));
-}
-
export function compareVersions(a, b) {
const ka = releaseVersionKey(a);
const kb = releaseVersionKey(b);
@@ -213,7 +207,6 @@ export function composeReply({
originChannel,
coverage = [],
channel = 'stable',
- quote = true,
}) {
const normalizedVersion = String(version ?? '')
.trim()
@@ -232,31 +225,28 @@ export function composeReply({
const lines = [openingLine(channel, normalizedVersion)];
- if (quote) {
- const trimmedProse =
- prose.length > MAX_PROSE_CHARS ? `${prose.slice(0, MAX_PROSE_CHARS).trimEnd()}...` : prose;
- lines.push('', trimmedProse);
- }
-
if (coverage.length > 0) {
lines.push('', `Covers ${[...coverage].sort().join(', ')}.`);
}
- lines.push('', updateInstruction(originChannel, channel, normalizedVersion));
+ lines.push('', updateInstruction(originChannel, channel));
return lines.join('\n');
}
-function updateInstruction(originChannel, channel = 'stable', version = '') {
- const action =
+function updateInstruction(originChannel, channel = 'stable') {
+ const lead =
+ channel === 'beta'
+ ? 'Read the notes and download the beta on'
+ : 'To pick it up, update to the latest desktop app. The notes are on';
+ const tail =
channel === 'beta'
- ? `To try it ahead of that, download the v${version} beta from`
- : 'To pick it up, update to the latest desktop app from';
- const tail = channel === 'beta' ? ' once its installers have finished uploading' : '';
+ ? " once the beta's installers have finished uploading."
+ : ' once the release finishes publishing.';
if (originChannel === 'discord-thread') {
- return `${action} <${RELEASES_URL}>${tail}.`;
+ return `${lead} <${RELEASES_URL}>${tail}`;
}
- return `${action} [the releases page](${RELEASES_URL})${tail}.`;
+ return `${lead} [the releases page](${RELEASES_URL})${tail}`;
}
function openingLine(channel, version) {
diff --git a/.github/scripts/write-back-gate.test.mjs b/.github/scripts/write-back-gate.test.mjs
index 6f318b354..92d5882bb 100644
--- a/.github/scripts/write-back-gate.test.mjs
+++ b/.github/scripts/write-back-gate.test.mjs
@@ -6,8 +6,6 @@ import {
evaluateFanIn,
isOriginRepliableFrom,
highestVersion,
- markerSuffixFor,
- originAlreadyNotified,
partitionAttachments,
} from './write-back-gate.mjs';
@@ -255,10 +253,10 @@ describe('fan-in gate', () => {
});
describe('reply composition', () => {
- const CHANGESET = {
- title: 'Honor backslash escapes in the markdown promoters',
- body: 'Typing `\\==not a highlight\\==` now stays literal instead of turning into a highlight.',
- };
+ const CHANGESET_BODY =
+ 'Honor backslash escapes in the markdown promoters.\n\nTyping `\\==not a highlight\\==` now stays literal instead of turning into a highlight.';
+ const changesetFrom = (body) => ({ title: body.split('\n')[0].trim(), body });
+ const CHANGESET = changesetFrom(CHANGESET_BODY);
const compose = (overrides = {}) =>
composeReply({ changeset: CHANGESET, version: 'v0.36.0', originChannel: 'github-issue', ...overrides });
@@ -267,30 +265,26 @@ describe('reply composition', () => {
expect(compose()).toContain('v0.36.0');
});
- test('the reply carries the changeset prose', () => {
- expect(compose()).toContain('stays literal instead of turning into a highlight');
+ test('the changeset prose is never quoted into the reply', () => {
+ const text = compose();
+ expect(text).not.toContain('stays literal instead of turning into a highlight');
+ expect(text).not.toContain(CHANGESET.title);
});
- test('a multi-paragraph changeset that fits the bound is quoted in full', () => {
+ test('a multi-paragraph changeset reaches the reader as a link, not as paragraphs', () => {
const text = compose({
- changeset: {
- title: 'Message actions',
- body: 'Messages you send now carry their own actions:\n\n- Resend to a different agent.\n- Copy and edit.',
- },
+ changeset: changesetFrom(
+ 'Messages you send now carry their own actions:\n\n- Resend to a different agent.\n- Copy and edit.'
+ ),
});
- expect(text).toContain('Messages you send now carry their own actions:');
- expect(text).toContain('Resend to a different agent.');
+ expect(text).not.toContain('Messages you send now carry their own actions:');
+ expect(text).not.toContain('Resend to a different agent.');
+ expect(text).toContain('[the releases page](https://github.com/inkeep/open-knowledge/releases)');
});
- test('quote: false omits the changeset prose but keeps the rest of the reply', () => {
- const text = compose({ quote: false });
- expect(text).not.toContain('stays literal instead of turning into a highlight');
- expect(text).toContain('v0.36.0');
- expect(text).toContain('update to the latest desktop app');
- });
-
- test('quote: false still refuses to compose from an empty changeset', () => {
- expect(compose({ quote: false, changeset: { title: '', body: '' } })).toBeNull();
+ test('the reply links the releases index, never a tag page still in draft when it posts', () => {
+ expect(compose()).not.toContain('/releases/tag/');
+ expect(compose({ channel: 'beta', version: 'v0.36.0-beta.1' })).not.toContain('/releases/tag/');
});
test('the reply lists every contributing ticket in sorted order', () => {
@@ -302,6 +296,13 @@ describe('reply composition', () => {
expect(compose({ coverage: ['PRD-7539'] })).toContain('Covers PRD-7539.');
});
+ test('the stable instruction hedges on the draft window the reply posts inside', () => {
+ expect(compose()).toContain('once the release finishes publishing');
+ expect(compose({ channel: 'beta', version: 'v0.36.0-beta.1' })).toContain(
+ "once the beta's installers have finished uploading"
+ );
+ });
+
test('the update instruction is channel-appropriate', () => {
const gh = compose({ originChannel: 'github-issue' });
const discord = compose({ originChannel: 'discord-thread' });
@@ -317,9 +318,10 @@ describe('reply composition', () => {
}
});
- test('an empty changeset body falls back to the changeset title', () => {
- const text = compose({ changeset: { title: 'Fix the thing', body: ' ' } });
- expect(text).toContain('Fix the thing');
+ test('a one-line changeset still composes, since a changeset is what gates the reply', () => {
+ const text = compose({ changeset: changesetFrom('Fix the thing') });
+ expect(text).not.toBeNull();
+ expect(text).not.toContain('Fix the thing');
});
test('an empty body and title refuses to compose rather than emitting a blank reply', () => {
@@ -332,31 +334,10 @@ describe('reply composition', () => {
expect(() => compose({ version: 'latest' })).toThrow(/derived version/);
});
- test('pathological changeset prose is bounded so the reply fits a Discord message', () => {
- const text = compose({ changeset: { title: 't', body: 'x'.repeat(5000) }, coverage: ['PRD-1'] });
+ test('a pathological changeset body cannot inflate the reply past a Discord message', () => {
+ const text = compose({ changeset: changesetFrom('x'.repeat(5000)), coverage: ['PRD-1'] });
expect(text.length).toBeLessThan(2000);
- expect(text).toContain('...');
- });
-
- test('a body exactly at the bound is quoted whole, not truncated', () => {
- const body = 'x'.repeat(1200);
- const text = compose({ changeset: { title: 't', body }, coverage: ['PRD-1'] });
- expect(text).toContain(body);
- expect(text).not.toContain('...');
- });
-
- test('one character past the bound is truncated', () => {
- const body = 'x'.repeat(1201);
- const text = compose({ changeset: { title: 't', body }, coverage: ['PRD-1'] });
- expect(text).toContain(`${'x'.repeat(1200)}...`);
- expect(text).not.toContain(body);
- });
-
- test('a realistic multi-word body is cut mid-word with the trailing space trimmed', () => {
- const body = `${'word '.repeat(240)}tail`;
- const text = compose({ changeset: { title: 't', body }, coverage: ['PRD-1'] });
- expect(text).toContain('word...');
- expect(text).not.toContain('word ...');
+ expect(text).not.toContain('xxx');
});
test('no internal ticket detail reaches the composed reply', () => {
@@ -432,34 +413,6 @@ describe('origin remit', () => {
});
});
-describe('repeat-reply detection', () => {
- const ORIGIN = 'https://github.com/inkeep/open-knowledge/issues/1414';
- const marker = (version, originUrl = ORIGIN) =>
- `https://github.com/inkeep/open-knowledge/releases/tag/v${version}${markerSuffixFor(originUrl)}`;
-
- test('no marker for this origin at all means no earlier reply', () => {
- expect(originAlreadyNotified([], ORIGIN)).toBe(false);
- expect(originAlreadyNotified([marker('0.59.0')], 'https://github.com/other/repo/issues/1')).toBe(
- false,
- );
- });
-
- test('a marker for a DIFFERENT version on this origin means an earlier reply already quoted it', () => {
- expect(originAlreadyNotified([marker('0.59.0-beta.2')], ORIGIN)).toBe(true);
- });
-
- test('an origin carrying its own query string still gets an unambiguous suffix', () => {
- const trickyOrigin = 'https://github.com/inkeep/open-knowledge/issues/1?notified=x';
- expect(originAlreadyNotified([marker('0.59.0')], trickyOrigin)).toBe(false);
- expect(originAlreadyNotified([marker('0.59.0', trickyOrigin)], trickyOrigin)).toBe(true);
- expect(originAlreadyNotified([marker('0.59.0', trickyOrigin)], ORIGIN)).toBe(false);
- });
-
- test('the suffix must be at the tail, not merely present', () => {
- expect(originAlreadyNotified([`${marker('0.59.0')}&ref=slack`], ORIGIN)).toBe(false);
- });
-});
-
describe('prerelease ordering', () => {
test('a beta ranks below the stable that supersedes it', () => {
expect(compareVersions('0.59.0-beta.9', '0.59.0')).toBeLessThan(0);
@@ -499,7 +452,7 @@ describe('the two channels say different things', () => {
expect(text).toContain('going out now on the Open Knowledge beta channel');
expect(text).toContain('follow up here');
expect(text).not.toContain('update to the latest');
- expect(text).toContain('download the v0.59.0-beta.2 beta');
+ expect(text).toContain('download the beta');
expect(text).not.toMatch(/available now|download it now/i);
expect(text).toContain('installers have finished uploading');
});
diff --git a/.github/scripts/write-back.mjs b/.github/scripts/write-back.mjs
index 40cedeefd..9209bcb8b 100644
--- a/.github/scripts/write-back.mjs
+++ b/.github/scripts/write-back.mjs
@@ -17,7 +17,6 @@ import {
evaluateFanIn,
isOriginRepliableFrom,
markerSuffixFor,
- originAlreadyNotified,
partitionAttachments,
} from './write-back-gate.mjs';
@@ -357,14 +356,6 @@ export async function runWriteBack({
skip(candidate.identifier, 'already-notified');
continue;
}
- const quotedBefore = originAlreadyNotified(attachmentUrls, origin.url);
- if (quotedBefore) {
- log(
- `::debug::write-back: ${origin.url} already carries a marker for an earlier version ` +
- `(${candidate.identifier}); any reply for this origin will omit the changeset quote.`,
- );
- }
-
const changeset = await readChangesetProse(candidate, { fixReferences });
const text =
changeset === null
@@ -375,13 +366,12 @@ export async function runWriteBack({
originChannel: origin.channel,
coverage: gate.coverage,
channel,
- quote: !quotedBefore,
});
if (!text) {
log(
`::warning::write-back: ${candidate.identifier} shipped in v${gate.version} but has no changeset prose ` +
- 'to quote; posting nothing rather than a bare version.',
+ 'behind it; posting nothing rather than a bare version.',
);
skip(candidate.identifier, 'no-prose');
continue;
@@ -390,14 +380,13 @@ export async function runWriteBack({
if (!live) {
log(
`::notice::write-back: [dry run] would reply to ${origin.url} for ${candidate.identifier} ` +
- `(v${gate.version}, covers ${gate.coverage.join(', ')}, quoted=${!quotedBefore}).`,
+ `(v${gate.version}, covers ${gate.coverage.join(', ')}).`,
);
posted.push({
identifier: candidate.identifier,
origin: origin.url,
version: gate.version,
dryRun: true,
- quoted: !quotedBefore,
});
continue;
}
@@ -415,20 +404,18 @@ export async function runWriteBack({
} catch (err) {
throw new NeedsHumanError(
`marker for ${origin.url} was written but the reply did NOT send (${err.message}). ` +
- 'No future run will retry it; post the reply by hand — and since this marker now makes a ' +
- 'later automated reply on this same origin assume its quote already landed, include it.',
+ 'No future run will retry it; post the reply by hand.',
);
}
log(
`::notice::write-back: replied to ${origin.url} for ${candidate.identifier} ` +
- `(v${gate.version}, quoted=${!quotedBefore}).`,
+ `(v${gate.version}).`,
);
posted.push({
identifier: candidate.identifier,
origin: origin.url,
version: gate.version,
dryRun: false,
- quoted: !quotedBefore,
});
}
};
diff --git a/.github/scripts/write-back.test.mjs b/.github/scripts/write-back.test.mjs
index 5df19cd18..977c1f1e8 100644
--- a/.github/scripts/write-back.test.mjs
+++ b/.github/scripts/write-back.test.mjs
@@ -26,13 +26,16 @@ import {
runWriteBack,
selectGhToken,
} from './write-back.mjs';
+import { composeReply } from './write-back-gate.mjs';
const GH_ISSUE = 'https://github.com/inkeep/open-knowledge/issues/769';
const GH_PULL = 'https://github.com/inkeep/agents-private/pull/2844';
const SLACK_ARCHIVE = 'https://inkeep.slack.com/archives/C016VCYCL74/p1727122965001469';
const LINEAR_UPLOAD = 'https://uploads.linear.app/abc/def/diagnostics.zip';
const DISCORD_THREAD = 'https://discord.com/channels/1514363990740828223/1528881792063508610';
-const CHANGESET = { title: 'Honor backslash escapes', body: 'Honor backslash escapes in the markdown promoters.' };
+const CHANGESET_BODY =
+ 'Honor backslash escapes in the markdown promoters.\n\nTyping the escape now stays literal.';
+const CHANGESET = { title: CHANGESET_BODY.split('\n')[0], body: CHANGESET_BODY };
const PRIVATE_SHA = 'da71f0c698ccaac11da915169ca6c7d585d5eb97';
const MIRRORED_SHA = 'eb52a625cd86859a8ec43ddc8f96e9b418d092a7';
@@ -434,7 +437,8 @@ describe('write-back run', () => {
const mark = h.writes.find((w) => w.kind === 'mark');
expect(post.origin).toBe(GH_ISSUE);
expect(post.text).toContain('v0.36.0');
- expect(post.text).toContain(CHANGESET.body);
+ expect(post.text).not.toContain(CHANGESET.body);
+ expect(post.text).toContain('https://github.com/inkeep/open-knowledge/releases');
expect(mark.url).toBe(notificationMarkerUrl({ version: '0.36.0', originUrl: GH_ISSUE }));
});
@@ -574,6 +578,27 @@ describe('changeset parsing', () => {
expect(parseChangeset(['---', "'x': patch", '---', ''].join('\n'))).toBeNull();
expect(parseChangeset('')).toBeNull();
});
+
+ test('no real changeset shape leaks into the reply, whatever its prose looks like', () => {
+ const shapes = [
+ 'Fixed an error thrown inside every CodeMirror-backed editor when selecting with the mouse. Double-clicking to select a word and triple-clicking to select a line both threw, and so did the handler that starts a drag from a widget.',
+ 'Messages you send in an agent chat now carry their own actions:\n\n- Send the same prompt to a different agent.\n- Copy and edit a sent message.',
+ 'The sync indicator recovers after a sleep, a Wi-Fi change, or a VPN flap.',
+ ];
+ for (const prose of shapes) {
+ const changeset = parseChangeset(['---', "'x': patch", '---', '', prose].join('\n'));
+ const text = composeReply({
+ changeset,
+ version: 'v0.36.0',
+ originChannel: 'github-issue',
+ coverage: ['PRD-7539'],
+ });
+ expect(text).not.toBeNull();
+ expect(text).not.toContain(changeset.title);
+ expect(text).not.toContain(changeset.body);
+ expect(text).toContain('[the releases page](https://github.com/inkeep/open-knowledge/releases)');
+ }
+ });
});
describe('locating the changeset a fix shipped with', () => {
@@ -592,7 +617,7 @@ describe('locating the changeset a fix shipped with', () => {
expect(findChangesetPath(['.changeset/some-fix.md'], { repo: 'open-knowledge' })).toBe('.changeset/some-fix.md');
});
- test("another product's changeset is never quoted to an Open Knowledge reporter", () => {
+ test("another product's changeset is never picked for an Open Knowledge reporter", () => {
const foreign = ['public/agents/.changeset/some-agents-fix.md', '.changeset/a-stray-root-changeset.md'];
expect(findChangesetPath(foreign, { repo: 'agents-private' })).toBeNull();
});
@@ -1385,7 +1410,8 @@ describe('the beta leg', () => {
expect(post.text).toContain('going out now on the Open Knowledge beta channel');
expect(post.text).toContain('follow up here');
expect(post.text).not.toContain('This shipped in');
- expect(post.text).toContain(CHANGESET.body);
+ expect(post.text).not.toContain(CHANGESET.body);
+ expect(post.text).toContain('https://github.com/inkeep/open-knowledge/releases');
});
test('the beta marker is not the stable one, so each channel is told at most once', async () => {
@@ -1428,36 +1454,21 @@ describe('the beta leg', () => {
expect(post.text).not.toContain('beta');
});
- test('the stable leg omits the changeset prose when a beta reply already quoted it on this origin', async () => {
- const betaMarker = notificationMarkerUrl({ version: '0.37.0-beta.0', originUrl: GH_ISSUE });
- const h = harness({
- live: true,
- listCandidates: async () => [candidate({ attachmentUrls: [GH_PULL, GH_ISSUE, betaMarker] })],
- });
+ test('the stable leg links the notes instead of quoting the changeset', async () => {
+ const h = harness({ live: true });
const result = await h.run();
const post = h.writes.find((w) => w.kind === 'post');
expect(post.text).toContain('This shipped in Open Knowledge v0.36.0');
expect(post.text).not.toContain(CHANGESET.body);
+ expect(post.text).toContain('https://github.com/inkeep/open-knowledge/releases');
expect(result.posted.map((p) => p.identifier)).toEqual(['PRD-7539']);
- expect(result.posted[0].quoted).toBe(false);
- });
-
- test('a dry run reports the same quote decision the live run would make', async () => {
- const betaMarker = notificationMarkerUrl({ version: '0.37.0-beta.0', originUrl: GH_ISSUE });
- const h = harness({
- listCandidates: async () => [candidate({ attachmentUrls: [GH_PULL, GH_ISSUE, betaMarker] })],
- });
- const result = await h.run();
- expect(result.posted[0].quoted).toBe(false);
- expect(h.logs.some((m) => m.includes('[dry run]') && m.includes('quoted=false'))).toBe(true);
});
- test('the quote decision is made per origin, not once for the whole candidate', async () => {
- const betaMarker = notificationMarkerUrl({ version: '0.35.0', originUrl: GH_ISSUE });
+ test('no origin gets the changeset prose, whichever channel it came in on', async () => {
const h = harness({
live: true,
listCandidates: async () => [
- candidate({ attachmentUrls: [GH_PULL, GH_ISSUE, DISCORD_THREAD, betaMarker] }),
+ candidate({ attachmentUrls: [GH_PULL, GH_ISSUE, DISCORD_THREAD] }),
],
});
await h.run();
@@ -1465,6 +1476,8 @@ describe('the beta leg', () => {
const forIssue = posts.find((p) => p.origin === GH_ISSUE);
const forDiscord = posts.find((p) => p.origin === DISCORD_THREAD);
expect(forIssue.text).not.toContain(CHANGESET.body);
- expect(forDiscord.text).toContain(CHANGESET.body);
+ expect(forIssue.text).toContain('[the releases page](https://github.com/inkeep/open-knowledge/releases)');
+ expect(forDiscord.text).not.toContain(CHANGESET.body);
+ expect(forDiscord.text).toContain('<https://github.com/inkeep/open-knowledge/releases>');
});
});