From 2b6e589ab3f604e40b4d870586bc52cc021326ac Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 22 Nov 2026 15:22:33 -0800 Subject: [PATCH] fix(anilist): treat the anchor as season 1 in the air-order continuation check pickByAirOrder skipped the named-season guard for an anchor whose titles name no season, so a "Season 2" entry with a "Part 2" synonym was dropped as a back half and season 2 could not be picked. --- .../services/anilist/season-resolver.test.ts | 19 +++++++++++++++++++ src/core/services/anilist/season-resolver.ts | 8 +++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/core/services/anilist/season-resolver.test.ts b/src/core/services/anilist/season-resolver.test.ts index 36d0dcb3..d8061a97 100644 --- a/src/core/services/anilist/season-resolver.test.ts +++ b/src/core/services/anilist/season-resolver.test.ts @@ -623,6 +623,25 @@ test('a sequel naming its own season is not a back half, even with a part synony assert.equal(unnamed.result?.id, 2); }); +test('air order keeps a sequel naming its own season despite a part synonym', () => { + const anchor: AnilistSeasonMedia = { + id: 1, + episodes: 12, + format: 'TV', + seasonYear: 2020, + title: { english: 'Air Order Show' }, + }; + const sequel: AnilistSeasonMedia = { + id: 2, + episodes: 12, + format: 'TV', + seasonYear: 2022, + title: { english: 'Air Order Show Season 2' }, + synonyms: ['Air Order Show Part 2'], + }; + assert.equal(pickByAirOrder(anchor, 2, [anchor, sequel])?.id, 2); +}); + test('a season 1 episode past its length does not move to a longer later season', async () => { const { result } = await resolveInChain( [ diff --git a/src/core/services/anilist/season-resolver.ts b/src/core/services/anilist/season-resolver.ts index 2aeb92ba..425173b6 100644 --- a/src/core/services/anilist/season-resolver.ts +++ b/src/core/services/anilist/season-resolver.ts @@ -620,7 +620,13 @@ export function pickByAirOrder( // spells it " Part 1" is kept. const seasons = franchise.filter((entry) => { if (entry.id === anchor.id) return true; - return !franchise.some((other) => other.id !== entry.id && isSeasonContinuation(other, entry)); + // The anchor is season 1 here, which lets the continuation check reject an entry + // naming another season even when the anchor's own titles name none. + return !franchise.some( + (other) => + other.id !== entry.id && + isSeasonContinuation(other, entry, other.id === anchor.id ? 1 : null), + ); }); if (seasons.length < season) return null;