Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .claude/skills/supabase-migration/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ kasane ships its Supabase **publishable** key in the client bundle (`src/api/sup

## The two data classes

| Class | Tables | Rule |
| ------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **Catalog** (public, read-only) | `series`, `arc_mappings`, `movies`, `search_aliases`, `genre_filters` | `for select using (true)`; `grant select ... to anon, authenticated`. No client writes, ever. |
| **User data** (owner-scoped) | `user_progress`, `user_preferences` | `for all using (auth.uid() = user_id) with check (auth.uid() = user_id)`; `grant select, insert, update, delete ... to authenticated` only. |
| Class | Tables | Rule |
| ------------------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Catalog** (public, read-only) | `series`, `arc_mappings`, `movies`, `search_aliases`, `genre_filters`, `mangadex_series` | `for select using (true)`; `grant select ... to anon, authenticated`. No client writes, ever. `mangadex_series` is filled by `scripts/refresh-mangadex.ts` with the service role. |
| **User data** (owner-scoped) | `user_progress`, `user_preferences` | `for all using (auth.uid() = user_id) with check (auth.uid() = user_id)`; `grant select, insert, update, delete ... to authenticated` only. |

A new table joins one of these classes. If it fits neither, that is the design question to resolve before writing SQL.

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ concurrency:
# whatever bun the machine has, so this is the only place CI's version is fixed.
env:
BUN_VERSION: 1.4.2
# Netlify builds with the same major (`netlify.toml`).
NODE_VERSION: 24

jobs:
# The `system-check` script minus `build:web`, which `build` owns so that the
Expand Down Expand Up @@ -74,6 +76,13 @@ jobs:
with:
bun-version: ${{ env.BUN_VERSION }}

# `expo export` runs under Node and loads `metro.config.js`, which needs
# the type stripping of Node 24, the version Netlify builds with.
- name: 🟢 Set up Node
uses: actions/setup-node@v5
with:
node-version: ${{ env.NODE_VERSION }}

- name: 📦 Install dependencies
run: bun install --frozen-lockfile

Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ src-tauri/Cargo.lock
.claude/*.lock
.claude/settings.local.json


# Supabase CLI local state (secrets, snapshots)
supabase/.temp/
supabase/.branches/
supabase/.snapshots/

# Netlify CLI state, and the edge bundler's lock of its own bootstrap modules.
.netlify/
deno.lock
2 changes: 1 addition & 1 deletion app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { StatusBar } from "expo-status-bar";
import * as SplashScreen from "expo-splash-screen";
import { CATALOG_QUERY_KEY, useCatalogQuery } from "@/queries/catalog";
import { COVERS_QUERY_KEY } from "@/queries/covers";
import { MINUTE_MS, WEEK_MS } from "@/queries/shared";
import { MINUTE_MS, WEEK_MS } from "@/data/time";
import {
useFonts,
SpaceGrotesk_400Regular,
Expand Down
71 changes: 38 additions & 33 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from "react-native";
import { pairResults } from "@/data/pairing";
import { useCatalog, useGenreFilters } from "@/queries/catalog";
import { useLatestAnime, useSearch } from "@/queries/search";
import { useSearch } from "@/queries/search";
import { splitHiddenForAniList } from "@/data/genreFilters";
import { Footer } from "@/components/Footer";
import { SeriesCard } from "@/components/SeriesCard";
import { GenreFilters } from "@/components/GenreFilters";
import { HomeToolbar } from "@/components/HomeToolbar";
import { LatestReleases } from "@/components/LatestReleases";
import { MappedOnlyToggle } from "@/components/MappedOnlyToggle";
import { useDebouncedValue } from "@/components/useDebouncedValue";
import { useHomeChrome } from "@/state/homeChrome";
import { usePreferences } from "@/state/preferences";
import { COLOR, FONT, SPACE } from "@/theme";

Expand All @@ -26,6 +26,7 @@ export default function HomeScreen() {
const hiddenGenres = usePreferences((s) => s.hiddenGenres);
const genreFilters = useGenreFilters();
const [mappedOnly, setMappedOnly] = useState(true);
const [filtersOpen, setFiltersOpen] = useState(false);
const { findMapping } = useCatalog();

// Chips update `hiddenGenres` immediately so they stay responsive, but the
Expand All @@ -44,10 +45,8 @@ export default function HomeScreen() {
error,
} = useSearch({ query: debouncedQuery, filters, enabled: isSearching });

const { data: latestAnime, isFetching: latestFetching } = useLatestAnime({
filters,
enabled: !isSearching,
});
// Scrolling the latest grid hands the screen over to the covers.
const immersive = useHomeChrome((s) => s.immersive);

const pairedResults = useMemo(
() => pairResults(searchResults ?? []),
Expand All @@ -66,27 +65,36 @@ export default function HomeScreen() {
);
const hiddenByMapping = pairedResults.length - visibleResults.length;

// One toolbar, headed in the latest grid and bare above search results.
const toolbar = (
<HomeToolbar
heading={
isSearching
? undefined
: { eyebrow: "Now airing", title: "Latest anime" }
}
mappedOnly={mappedOnly}
onMappedOnlyChange={setMappedOnly}
filtersOpen={filtersOpen}
onFiltersOpenChange={setFiltersOpen}
/>
);

return (
<View style={styles.root}>
<Text style={styles.tagline}>
Find which anime episodes cover which manga chapters.
</Text>

<TextInput
value={query}
onChangeText={setQuery}
placeholder="Search anime or manga…"
accessibilityRole="search"
accessibilityLabel="Search anime or manga"
placeholderTextColor={COLOR.textFaint}
style={styles.input}
autoCorrect={false}
returnKeyType="search"
/>

<MappedOnlyToggle value={mappedOnly} onChange={setMappedOnly} />

<GenreFilters />
{!immersive && (
<TextInput
value={query}
onChangeText={setQuery}
placeholder="Search anime or manga…"
accessibilityRole="search"
accessibilityLabel="Search anime or manga"
placeholderTextColor={COLOR.textFaint}
style={styles.input}
autoCorrect={false}
returnKeyType="search"
/>
)}

{error && (
<Text style={styles.error}>Something went wrong. Try again.</Text>
Expand All @@ -103,6 +111,8 @@ export default function HomeScreen() {
data={visibleResults}
keyExtractor={(item) => `series-${item.routeId}`}
renderItem={({ item }) => <SeriesCard entry={item} />}
ListHeaderComponent={toolbar}
ListHeaderComponentStyle={styles.listHeader}
ListEmptyComponent={
!isFetching && query === debouncedQuery ? (
<View style={styles.emptyWrap}>
Expand All @@ -120,20 +130,14 @@ export default function HomeScreen() {
/>
</>
) : (
<LatestReleases data={latestAnime ?? []} loading={latestFetching} />
<LatestReleases filters={filters} header={toolbar} />
)}
</View>
);
}

const styles = StyleSheet.create({
root: { flex: 1, padding: SPACE.xl, gap: SPACE.xl },
tagline: {
color: COLOR.textSecondary,
fontSize: 16,
letterSpacing: -0.2,
fontFamily: FONT.medium,
},
input: {
backgroundColor: COLOR.surface,
color: COLOR.textPrimary,
Expand All @@ -146,6 +150,7 @@ const styles = StyleSheet.create({
borderLeftColor: COLOR.accent,
},
spinnerWrap: { paddingTop: SPACE.xxxl },
listHeader: { paddingBottom: SPACE.xl },
emptyWrap: { paddingTop: SPACE.page },
empty: {
color: COLOR.textMuted,
Expand Down
15 changes: 5 additions & 10 deletions app/series/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
} from "react-native";
import { useLocalSearchParams } from "expo-router";
import { detailStats } from "@/data/seriesStats";
import { useFranchise, useMangaDex } from "@/queries/media";
import { useMangaDex } from "@/queries/media";
import { useSeries } from "@/queries/series";
import { FranchiseSeasons } from "@/components/FranchiseSeasons";
import { MappingSection } from "@/components/MappingSection";
import { SeriesHeader } from "@/components/SeriesHeader";
import { TitlesList } from "@/components/TitlesList";
Expand All @@ -25,10 +24,8 @@ export default function SeriesDetail() {
Number.isNaN(mediaId) ? null : mediaId,
);
const manga = entry?.manga ?? null;
const anime = entry?.anime ?? null;

const { data: mangadex, isFetching: mangadexLoading } = useMangaDex(manga);
const { data: franchise } = useFranchise(anime);

if (isLoading) {
return (
Expand All @@ -47,12 +44,14 @@ export default function SeriesDetail() {
}

const { primary, badge, routeId } = entry;
const totalChapters = mangadex?.chapters ?? manga?.chapters ?? null;
// AniList's totals first: MangaDex only counts what it hosts, a fraction of
// a licensed run. MangaDex fills in while AniList has no total yet.
const totalChapters = manga?.chapters ?? mangadex?.chapters ?? null;
const subParts = detailStats({
entry,
mapping: resolved?.mapping ?? null,
chapters: totalChapters,
volumes: mangadex?.volumes ?? manga?.volumes ?? null,
volumes: manga?.volumes ?? mangadex?.volumes ?? null,
});

return (
Expand All @@ -64,10 +63,6 @@ export default function SeriesDetail() {
isMapped={resolved?.source === "curated"}
/>

{!!anime && !!franchise && franchise.seasons.length > 1 && (
<FranchiseSeasons franchise={franchise} currentId={anime.id} />
)}

<MappingSection
resolved={resolved}
mediaId={mediaId}
Expand Down
2 changes: 1 addition & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ coveragePathIgnorePatterns = ["test/**"]
#
# So the bar is set by the weakest file, not the average — today that is
# `src/api/mangadex.ts` (53% lines / 74% funcs), whose network paths in
# `getMangaDexInfoByAniListId` are covered only through their parsers. Parked
# `getMangaDexSnapshot` are covered only through their parsers. Parked
# just under it so any regression trips the suite, rather than at a round
# number no existing file could fail. Raise both once that export is covered.
[test.coverageThreshold]
Expand Down
96 changes: 96 additions & 0 deletions e2e/popular-search.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { expect, test, type Page } from "@playwright/test";

/**
* Searches for twenty of the most popular, most searched series, typed the way
* people type them: partial, lower case, no punctuation. Each must surface its
* curated catalog entry with "Mapped only" left on (the default), which is the
* case that once came back empty when AniList ranked the series past its first
* page of results ("attack" put Attack on Titan at #21).
*
* The assertion targets the result's link to `/series/<manga id>`, the catalog's
* own key, so it holds whatever display title AniList returns.
*
* AniList allows 30 requests a minute per IP (`x-ratelimit-limit`), and twenty
* parallel page loads trip it, which the app shows as "Something went wrong".
* So the searches run one at a time, spaced out, and every AniList request
* other than the search itself (the home grid, covers) is answered with an
* empty page: only the search reaches AniList, one request per test.
*/
const SEARCH_OPERATIONS = /query\s+Search\b/;
const SPACING_MS = 3_000;

// Probes AniList once and, if the rest of the suite has used much of this
// minute's allowance, waits for the window to reset before searching.
const waitForAniListHeadroom = async (): Promise<void> => {
const res = await fetch("https://graphql.anilist.co", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ query: "{ Media(id: 1) { id } }" }),
});
const remaining = Number(res.headers.get("x-ratelimit-remaining") ?? 0);
const resetAt = Number(res.headers.get("x-ratelimit-reset") ?? 0) * 1000;
const retryAfter = Number(res.headers.get("retry-after") ?? 0) * 1000;
const wait =
res.status === 429
? retryAfter || 60_000
: remaining < 25
? Math.max(resetAt - Date.now(), 0) || 60_000
: 0;
await new Promise((resolve) => setTimeout(resolve, wait));
};

const onlySearchReachesAniList = async (page: Page): Promise<void> => {
await page.route("https://graphql.anilist.co/**", (route) =>
SEARCH_OPERATIONS.test(route.request().postData() ?? "")
? route.continue()
: route.fulfill({ json: { data: { Page: { media: [] } } } }),
);
};
const POPULAR: readonly { query: string; title: string; seriesId: number }[] = [
{ query: "attack", title: "Attack on Titan", seriesId: 53390 },
{ query: "one piece", title: "One Piece", seriesId: 30013 },
{ query: "naruto", title: "Naruto", seriesId: 30011 },
{ query: "demon slayer", title: "Demon Slayer", seriesId: 87216 },
{ query: "jujutsu", title: "Jujutsu Kaisen", seriesId: 101517 },
{ query: "my hero", title: "My Hero Academia", seriesId: 85486 },
{ query: "death note", title: "Death Note", seriesId: 30021 },
{ query: "fullmetal", title: "Fullmetal Alchemist", seriesId: 30025 },
{ query: "hunter x hunter", title: "Hunter x Hunter", seriesId: 30026 },
{ query: "chainsaw", title: "Chainsaw Man", seriesId: 105778 },
{ query: "spy x family", title: "SPY x FAMILY", seriesId: 108556 },
{ query: "bleach", title: "Bleach", seriesId: 30012 },
{ query: "dragon ball", title: "Dragon Ball", seriesId: 30042 },
{ query: "one punch", title: "One-Punch Man", seriesId: 74347 },
{ query: "tokyo ghoul", title: "Tokyo Ghoul", seriesId: 63327 },
{ query: "mob psycho", title: "Mob Psycho 100", seriesId: 85189 },
{ query: "black clover", title: "Black Clover", seriesId: 86123 },
{ query: "haikyu", title: "Haikyu!!", seriesId: 65243 },
{ query: "frieren", title: "Frieren", seriesId: 118586 },
{ query: "solo leveling", title: "Solo Leveling", seriesId: 105398 },
];

test.describe("popular searches", () => {
test.describe.configure({ mode: "default", timeout: 90_000 });

test.beforeAll(async () => {
test.setTimeout(90_000);
await waitForAniListHeadroom();
});

test.beforeEach(async ({ page }) => {
await page.waitForTimeout(SPACING_MS);
await onlySearchReachesAniList(page);
});

POPULAR.forEach(({ query, title, seriesId }) => {
test(`"${query}" finds ${title}`, async ({ page }) => {
await page.goto("/");
const box = page.getByPlaceholder(/search/i);
await expect(box).toBeVisible();
await box.fill(query);
await expect(
page.locator(`a[href="/series/${seriesId}"]`).first(),
).toBeVisible();
});
});
});
Loading
Loading