Continue row: only manga with something left after the last chapter read

GET /api/library returns `left` per manga: chapters after the newest saved
position that are unfinished, unread, or were last read more than 7 days
before it (a reread from the start). The continue row lists manga with
left > 0, so caught-up series drop out until a new chapter arrives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MaashkinoozheandClaude Opus 5.5 committed 2026-11-01 11:27:02 +01:00
1 parent dddf9bb4ac
commit 9b529d7709
5 files changed
+110 -6

No files matched your search

+1 -1
View File
@@ -148,7 +148,7 @@ completeness.
- **Flow page gap:** Settings → Reading lets each user keep the normal separator between Flow pages or remove it for continuous webtoon artwork and text that crosses image edges. - **Flow page gap:** Settings → Reading lets each user keep the normal separator between Flow pages or remove it for continuous webtoon artwork and text that crosses image edges.
- **Page tone:** the reader's **Tone** button cycles Original → Inverted → Sepia → Dim → Extra dim in Flow, Page and Book. It changes only the artwork, never the controls or site theme. The choice is saved per user; it can also be selected in Settings → User → Reading. - **Page tone:** the reader's **Tone** button cycles Original → Inverted → Sepia → Dim → Extra dim in Flow, Page and Book. It changes only the artwork, never the controls or site theme. The choice is saved per user; it can also be selected in Settings → User → Reading.
- **Active Reading Clock:** opt in under Settings → User → Reading time & privacy. No scrolling-speed limit; a visit counts at 60% viewed-page coverage and saves on exit. Pauses in the background or after 30 seconds without reader activity. Tap the clock for this visit's time, coverage, qualification and loading wait. - **Active Reading Clock:** opt in under Settings → User → Reading time & privacy. No scrolling-speed limit; a visit counts at 60% viewed-page coverage and saves on exit. Pauses in the background or after 30 seconds without reader activity. Tap the clock for this visit's time, coverage, qualification and loading wait.
- **Continue where you left off:** the first line of the library content (below the search, filters and tags) is one row of the five manga you read most recently and have not finished (same tiles as the grid; they stay in the grid too). It hides while a search is typed, a status filter is set, or the library is sorted by *Recently read*; tags and collection grouping do not affect it. Turn it off under Settings → User → Reading → *Library page*. - **Continue where you left off:** the first line of the library content (below the search, filters and tags) is one row of the five manga you read most recently that still have something left after the last chapter you read (same tiles as the grid; they stay in the grid too). Left means an unfinished last chapter, an unread later chapter, or — when you are rereading — a later chapter last read more than a week before your current position. A manga you have caught up on drops out until a new chapter arrives. It hides while a search is typed, a status filter is set, or the library is sorted by *Recently read*; tags and collection grouping do not affect it. Turn it off under Settings → User → Reading → *Library page*.
- **Your Reading Story:** private active-time summaries appear on the library and manga pages when history exists. Chapter rows show the last timed read (60%-coverage visit), rereads remain visible as lifetime time, and Settings lets each user hide, export, or delete their own history. No leaderboards or speed ranking are used. - **Your Reading Story:** private active-time summaries appear on the library and manga pages when history exists. Chapter rows show the last timed read (60%-coverage visit), rereads remain visible as lifetime time, and Settings lets each user hide, export, or delete their own history. No leaderboards or speed ranking are used.
- **Tap / click zones:** - **Tap / click zones:**
- Tapping **beside the pages** always shows or hides the controls. - Tapping **beside the pages** always shows or hides the controls.
+1 -1
View File
@@ -201,7 +201,7 @@ All requests and responses are JSON. POSTs require `Content-Type: application/js
| `GET /api/reader-sessions` | user | `{ enabled, current, latestFrom, latest, sessions: [{ id, device, created, seen, current, locked, reader }] }` | | `GET /api/reader-sessions` | user | `{ enabled, current, latestFrom, latest, sessions: [{ id, device, created, seen, current, locked, reader }] }` |
| `POST /api/reader-sessions` `{id, action}` | user | `follow`: the session drops its own reader settings and follows the latest; `latest`: its settings become the latest | | `POST /api/reader-sessions` `{id, action}` | user | `follow`: the session drops its own reader settings and follows the latest; `latest`: its settings become the latest |
| `POST /api/password` `{old, new}` | user | Change password | | `POST /api/password` `{old, new}` | user | Change password |
| `GET /api/library` | user | Manga list with covers, counts, the user's read count, unread notifications, last read, and optional personal Reading Story aggregates | | `GET /api/library` | user | Manga list with covers, counts, the user's read count, unread notifications, last read, `left` (chapters after the newest saved position that are unfinished, unread, or last read over 7 days before it, i.e. a reread; 0 = caught up), and optional personal Reading Story aggregates |
| `GET /api/manga?m=` | user | Manga details, books, chapters with ranked versions, progress, optional chapter-time summaries, and `continue` target | | `GET /api/manga?m=` | user | Manga details, books, chapters with ranked versions, progress, optional chapter-time summaries, and `continue` target |
| `GET /api/chapter?m=&c=[&v=]` | user | Pages (`u, w, h, t, r`), direction, versions, prev/next, progress, `latest` (as in `/api/progress/latest`), optional Active Reading Clock summary, plus all books and chapters of the manga (with the user's read state) for the chapter picker. Also marks that chapter's notifications read | | `GET /api/chapter?m=&c=[&v=]` | user | Pages (`u, w, h, t, r`), direction, versions, prev/next, progress, `latest` (as in `/api/progress/latest`), optional Active Reading Clock summary, plus all books and chapters of the manga (with the user's read state) for the chapter picker. Also marks that chapter's notifications read |
| `POST /api/progress` `{m, c, v, p, n, done, shift[, tab, seen]}` | user | Save the reading position. With `seen`, a save is refused (`{ok:false, stale:true, latest}`) when another tab saved a newer position of this manga since; otherwise `{ok:true, t}` | | `POST /api/progress` `{m, c, v, p, n, done, shift[, tab, seen]}` | user | Save the reading position. With `seen`, a save is refused (`{ok:false, stale:true, latest}`) when another tab saved a newer position of this manga since; otherwise `{ok:true, t}` |
+3 -2
View File
@@ -55,8 +55,9 @@
h('option', { value: 'grouped' }, 'Group collections'), h('option', { value: 'expanded' }, 'Expand collections'), h('option', { value: 'individual' }, 'Individual manga')); h('option', { value: 'grouped' }, 'Group collections'), h('option', { value: 'expanded' }, 'Expand collections'), h('option', { value: 'individual' }, 'Individual manga'));
grouping.value = ['grouped', 'expanded', 'individual'].includes(store.get('grouping')) ? store.get('grouping') : 'grouped'; grouping.value = ['grouped', 'expanded', 'individual'].includes(store.get('grouping')) ? store.get('grouping') : 'grouped';
grouping.onchange = render; grouping.onchange = render;
// Started but unfinished manga, most recently read first; the same manga still appear in the grid. // Started manga with chapters left after the last one read (first read or reread, server `left`),
const continueItems = data.mangas.filter(m => m.lastRead && m.read < m.chapters) // most recently read first; the same manga still appear in the grid.
const continueItems = data.mangas.filter(m => m.lastRead && m.left > 0)
.sort((a, b) => b.lastRead - a.lastRead).slice(0, 5); .sort((a, b) => b.lastRead - a.lastRead).slice(0, 5);
const continueRow = h('section', { class: 'continue-row', 'aria-label': 'Continue where you left off', hidden: true }, const continueRow = h('section', { class: 'continue-row', 'aria-label': 'Continue where you left off', hidden: true },
h('div', { class: 'continue-banner' }, h('span', { 'aria-hidden': 'true' }, '▶'), 'Continue where you left off'), h('div', { class: 'continue-banner' }, h('span', { 'aria-hidden': 'true' }, '▶'), 'Continue where you left off'),
+13 -2
View File
@@ -465,6 +465,17 @@ function continueOf(m, prog, s) {
const next = m.chapters.slice(m.chapters.indexOf(last.ch) + 1).find(ok); const next = m.chapters.slice(m.chapters.indexOf(last.ch) + 1).find(ok);
return next ? { c: next.id, at, text: 'Read next · ' + next.label } : { c: last.ch.id, v: last.p.v, at, text: 'Read again · ' + last.ch.label }; return next ? { c: next.id, at, text: 'Read next · ' + next.label } : { c: last.ch.id, v: last.p.v, at, text: 'Read again · ' + last.ch.label };
} }
// A chapter after the head counts as read in this pass only if it is done and was saved within this
// gap before the head; older ones belong to an earlier pass, so the head is a reread.
const REREAD_GAP_MS = 7 * 24 * 3600 * 1000;
// Chapters still ahead of the head: never finished, or last read in an earlier pass. 0 = caught up.
function leftOf(m, prog, s) {
const last = lastOf(m, prog);
if (!last) return 0;
const after = m.chapters.slice(m.chapters.indexOf(last.ch) + 1).filter(c => !(s.skipExtras && c.extra));
return after.filter(c => { const p = prog[c.id]; return !p || !p.done || last.p.t - p.t > REREAD_GAP_MS; }).length
+ (last.p.done ? 0 : 1);
}
// What a reader tab compares itself with (stale reading sessions, docs/architecture.md). // What a reader tab compares itself with (stale reading sessions, docs/architecture.md).
function latestOf(m, prog, s) { function latestOf(m, prog, s) {
const last = lastOf(m, prog); const last = lastOf(m, prog);
@@ -620,7 +631,7 @@ const routes = {
'GET /api/library': ({ u }) => { 'GET /api/library': ({ u }) => {
const prog = db.progress[u.name] || {}, fol = db.follows[u.name] || {}, notes = (db.notes[u.name] || []).filter(n => !n.read); const prog = db.progress[u.name] || {}, fol = db.follows[u.name] || {}, notes = (db.notes[u.name] || []).filter(n => !n.read);
const showStory = settingsOf(u).readingStory; const s = settingsOf(u), showStory = s.readingStory;
const mangas = lib.mangas.map(m => { const mangas = lib.mangas.map(m => {
const p = prog[m.id] || {}, meta = m.meta || {}, release = firstReleaseOf(meta); const p = prog[m.id] || {}, meta = m.meta || {}, release = firstReleaseOf(meta);
return { return {
@@ -630,7 +641,7 @@ const routes = {
tags: Array.isArray(meta.tags) ? meta.tags : (meta.tags ? [String(meta.tags)] : []), status: meta.status || '', year: meta.year || '', tags: Array.isArray(meta.tags) ? meta.tags : (meta.tags ? [String(meta.tags)] : []), status: meta.status || '', year: meta.year || '',
firstRelease: release.label, firstReleaseAt: release.time, firstRelease: release.label, firstReleaseAt: release.time,
read: m.chapters.filter(c => p[c.id] && p[c.id].done).length, read: m.chapters.filter(c => p[c.id] && p[c.id].done).length,
lastRead: Object.values(p).reduce((t, x) => Math.max(t, x.t || 0), 0), lastRead: Object.values(p).reduce((t, x) => Math.max(t, x.t || 0), 0), left: leftOf(m, p, s),
following: !!fol[m.id], unread: notes.filter(n => n.m === m.id).length, following: !!fol[m.id], unread: notes.filter(n => n.m === m.id).length,
reading: showStory ? mangaInsight(mangaReadingOf(u, m), m.chapters.map(ch => ch.id)) : null, reading: showStory ? mangaInsight(mangaReadingOf(u, m), m.chapters.map(ch => ch.id)) : null,
}; };
+92
View File
@@ -0,0 +1,92 @@
'use strict';
// "Continue where you left off" only lists manga with something left after the last chapter read:
// unread chapters, or chapters last read in an earlier pass (a reread).
const test = require('node:test'), assert = require('node:assert/strict');
const fs = require('fs'), os = require('os'), path = require('path'), net = require('net');
const { spawn } = require('child_process');
const { Canvas } = require('../tools/png');
async function freePort() {
const listener = net.createServer();
await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve));
const port = listener.address().port;
await new Promise(resolve => listener.close(resolve));
return port;
}
async function start(library, data) {
const port = await freePort(), output = [];
const child = spawn(process.execPath, ['server.js'], { cwd: path.resolve(__dirname, '..'), windowsHide: true,
env: { ...process.env, LIBRARY: library, DATA: data, PORT: String(port), SCAN_INTERVAL: '0', FULL_SCAN_INTERVAL: '0',
SCRAPER_URL: 'http://127.0.0.1:9', SCRAPER_TOKEN: 'fixture-token', SCRAPER_TOKEN_FILE: '', BACKUP: '', GREATEST_COVER_WARM: '0' } });
child.stdout.on('data', d => output.push(String(d)));
child.stderr.on('data', d => output.push(String(d)));
const base = `http://127.0.0.1:${port}`;
let ready = false;
for (let n = 0; n < 100 && !ready; n++) {
ready = await fetch(base + '/health').then(r => r.ok).catch(() => false);
if (!ready) await new Promise(resolve => setTimeout(resolve, 50));
}
assert.ok(ready, output.join(''));
return { child, base };
}
async function stop(child) {
if (child && child.exitCode === null) { child.kill(); await new Promise(resolve => child.once('exit', resolve)); }
}
test('the continue row counts chapters left after the head, rereads included', { timeout: 30000 }, async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'mc-left-'));
let server;
try {
const library = path.join(root, 'library'), data = path.join(root, 'data');
for (const title of ['Moon Garden', 'Sun Field'])
for (const ch of ['c001 One', 'c002 Two', 'c003 Three', 'c004 Four']) {
const dir = path.join(library, title, 'v01', ch);
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(path.join(dir, '001.png'), new Canvas(60, 90, [40, 60, 120]).png());
}
fs.mkdirSync(data);
server = await start(library, data);
let { base } = server;
const post = (cookie, url, body) => fetch(base + url, { method: 'POST',
headers: { 'content-type': 'application/json', cookie }, body: JSON.stringify(body) }).then(r => r.json());
const get = (cookie, url) => fetch(base + url, { headers: { cookie } }).then(r => r.json());
const signup = await fetch(base + '/api/signup', { method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ name: 'alice', password: 'alice-password' }) });
const alice = signup.headers.get('set-cookie').split(';')[0];
await post(alice, '/api/admin/rescan', { full: true });
const ids = async m => (await get(alice, '/api/manga?m=' + encodeURIComponent(m))).chapters.map(c => ({ c: c.id, v: c.versions[0].id }));
const moon = await ids('Moon Garden'), sun = await ids('Sun Field');
const done = (m, ch) => post(alice, '/api/progress', { m, ...ch, p: 0, n: 1, done: true });
const left = async () => Object.fromEntries((await get(alice, '/api/library')).mangas.map(m => [m.id, m.left]));
// First read stopped after chapter 2: two chapters left. Finished: nothing left.
for (const ch of moon.slice(0, 2)) await done('Moon Garden', ch);
for (const ch of sun) await done('Sun Field', ch);
assert.deepEqual(await left(), { 'Moon Garden': 2, 'Sun Field': 0 });
// Unfinished head: the rest of that chapter is still left.
await post(alice, '/api/progress', { m: 'Moon Garden', ...moon[2], p: 0, n: 1 });
assert.equal((await left())['Moon Garden'], 2);
// Glancing back at chapter 1 right after finishing is not a reread.
await done('Sun Field', sun[0]);
assert.equal((await left())['Sun Field'], 0);
// The finish was a month ago: rereading chapters 1-2 now leaves 3-4 from the earlier pass.
await new Promise(resolve => setTimeout(resolve, 700));
await stop(server.child);
const dbFile = path.join(data, 'db.json'), db = JSON.parse(fs.readFileSync(dbFile, 'utf8'));
const month = 30 * 24 * 3600 * 1000, sunProgress = db.progress.alice['Sun Field'];
for (const p of Object.values(sunProgress)) { p.t -= month; p.doneAt -= month; }
sunProgress[sun[0].c].t += month;
fs.writeFileSync(dbFile, JSON.stringify(db));
server = await start(library, data);
base = server.base;
await done('Sun Field', sun[1]);
assert.equal((await left())['Sun Field'], 2);
} finally {
await stop(server && server.child);
fs.rmSync(root, { recursive: true, force: true });
}
});