Files
LangBot/web/tests/unit/core-version.test.mjs
044d2698d4 feat(web): show release notes from langbot.app changelog in the update dialog (#3044)
* feat(web): show release notes from langbot.app changelog in the update dialog

Read the curated changelog feed at https://langbot.app/changelog.json for
update detection and release notes, and redesign the dialog as a timeline
of every release between the running and latest version, grouped by
change type. Clicking the sidebar version opens the current version's
notes. Falls back to the Space-cached GitHub releases when the feed is
unreachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

* style(web): simplify update dialog to match the existing UI

Drop the header gradient, icon tile, coloured type pills and timeline
rail; use plain DialogHeader, neutral type labels and separators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

* style(web): use langbot.app changelog type tags in the update dialog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

* fix(web): order pre-release, post and hand-edited Core versions correctly in the update prompt

The sidebar badge and the dialog used two different comparators that
both read PEP 440 suffixes like 4.11.8b1 as 4.11.8, so beta users were
never offered the matching stable release, and the two could disagree.
Unparseable versions such as "custom" were offered every release.

Use one parser (coreVersion.ts) for both: stable X.Y.Z supersedes its
own a/b/rc/dev and -beta.N builds, .postN and +local map to their base
release, and unparseable versions never get an update prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-11-16 13:31:53 +08:00

74 lines
2.4 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import ts from 'typescript';
import { fileURLToPath } from 'node:url';
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
const sourcePath = path.resolve(
currentDirectory,
'../../src/app/utils/coreVersion.ts',
);
function loadCoreVersion() {
const compiled = ts.transpileModule(fs.readFileSync(sourcePath, 'utf8'), {
compilerOptions: {
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2020,
},
}).outputText;
const loadedModule = { exports: {} };
new Function('module', 'exports', compiled)(
loadedModule,
loadedModule.exports,
);
return loadedModule.exports;
}
const { isCoreUpdate, coreReleaseOf, parseCoreVersion } = loadCoreVersion();
const FEED = ['4.11.8', '4.11.7', '4.11.5', '4.11.0'];
const pending = (current) => FEED.filter((v) => isCoreUpdate(v, current));
test('offers newer stable releases to stable installs', () => {
assert.deepEqual(pending('v4.11.5'), ['4.11.8', '4.11.7']);
assert.deepEqual(pending('v4.11.8'), []);
assert.deepEqual(pending('v4.12.0'), []);
assert.equal(isCoreUpdate('5.0.0', 'v4.11.8'), true);
});
test('a stable release supersedes its own pre-releases (PEP 440 and semver)', () => {
for (const current of [
'v4.11.8b1',
'v4.11.8rc2',
'v4.11.8a1',
'v4.11.8.dev0',
'v4.11.8-beta.1',
'v4.11.8.beta1',
]) {
assert.deepEqual(pending(current), ['4.11.8'], current);
}
assert.deepEqual(pending('v4.11.0rc1'), FEED);
});
test('pre-releases ahead of the latest stable get no prompt', () => {
assert.deepEqual(pending('v4.12.0b1'), []);
assert.deepEqual(pending('v4.12.0.dev0'), []);
assert.equal(coreReleaseOf('v4.12.0b1'), null);
});
test('post releases and local builds count as their base release', () => {
for (const current of ['v4.11.8.post1', 'v4.11.8+custom', 'v4.11.8-post2']) {
assert.deepEqual(pending(current), [], current);
assert.equal(coreReleaseOf(current), '4.11.8', current);
}
assert.deepEqual(pending('v4.11.5+mybuild'), ['4.11.8', '4.11.7']);
});
test('unparseable versions never prompt an update', () => {
for (const current of ['vcustom', 'v4.11', '', null, undefined, 'latest']) {
assert.equal(parseCoreVersion(current), null, String(current));
assert.deepEqual(pending(current), [], String(current));
}
});