feat: auto-mark documents as completed on reaching last page#27
Open
specbug wants to merge 1 commit into
Open
Conversation
Adds reading-completion as a first-class state so finished docs stop blending
into the Reading list. Backend stamps `PDFFile.completed_at` the first time
`update_read_position` lands on the last page (auto-only, never cleared, and
silently skipped when total_pages is unknown). Frontend surfaces the state in
three places, all grayscale per DESIGN.md:
- LibraryScreen splits the document list into `READING` and `COMPLETED`
sections. Completed always sorts by completedAt desc regardless of the
active segmented sort, so the most recently finished sits on top.
- DocGlyph inverts to a sealed-stamp variant for completed docs (solid ink
fill, paper-colored starburst, small tick inset). No accent involved.
- PdfScreen topbar adds a mono `FINISHED · YYYY·MM·DD` tag next to the
author. The position-save promise now patches `fileMetadata.completed_at`
from the response so the tag appears live the instant the user reaches
the last page — no refresh required.
Backend wiring:
- `PDFFile.completed_at` nullable `DateTime(timezone=True)`.
- In-app idempotent migration `_migrate_pdf_file_completed_at` (mirrors
`_migrate_pdf_file_title`) plus standalone
`scripts/migrations/migrate_add_completed_at.py` for explicit runs.
- `PDFFileResponse.completed_at` exposed; `adapters.toLibraryDoc` projects
it as `{ completed, completedAt }`.
Docs:
- `CLAUDE.md` — capabilities bullet, Database Schema note, current-branch
block refreshed.
- `apps/webapp/DESIGN.md` — DocGlyph completed variant + per-screen intent
notes for Library / PDF.
Smoke-tested end to end via FastAPI TestClient against a forked database:
sub-last-page position update keeps completed_at null, last-page update
stamps it, scrolling back preserves the stamp, and rows with NULL
total_pages stay null even at impossible positions.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds reading completion as a first-class state. Finished docs stop blending into the Reading list and pick up a quiet visual marker everywhere they appear, without changing any reading behavior (you can still open, scroll, annotate, and review them as before).
PDFFile.completed_atthe first timePATCH /files/{id}/positionreportslast_read_position >= total_pages - 1. Auto-only — never cleared, never re-triggered. Silently skipped whentotal_pagesis unknown.READING(current sort applies) andCOMPLETED(always sorted bycompletedAtdesc). Completed docs end up at the bottom but in a self-contained, named section.doc.completed === true: solid ink fill, paper-colored starburst, small grayscale tick inset bottom-right. PerDESIGN.md§3, completion is not an accent moment, so the whole change is grayscale.FINISHED · YYYY·MM·DDtag next to the author whenever a doc is completed. The position-save promise patchesfileMetadata.completed_atfrom the response, so the tag flips in place the instant the user reaches the last page — no refresh required.Schema + migration
pdf_files.completed_at DATETIME NULL._migrate_pdf_file_completed_atruns on every backend boot (mirrors_migrate_pdf_file_title).apps/api/scripts/migrations/migrate_add_completed_at.pyfor explicit runs against deployed databases.PDFFileResponse.completed_atexposed;adapters.toLibraryDocprojects it as{ completed, completedAt }.Docs
CLAUDE.md— new capability bullet, Database Schema paragraph forcompleted_at, current-branch block refreshed.apps/webapp/DESIGN.md— DocGlyph entry gets a "Completed variant" subsection; per-screen intent table notes Library sectioning and the PdfScreenFINISHEDtag.Test plan
completed_atstaysNonecompleted_atstampedcompleted_atpreservedtotal_pages = NULLat position 999 →completed_atstaysNoneNULL.bun run buildcompiles (one pre-existing ESLint warning inPdfScreen.js:1027forscrollToPageIndexdep, unrelated to this change).READING · N+COMPLETED · Nsections; completed glyphs render the sealed-stamp variant; opening a completed doc shows theFINISHED · …topbar tag.Co-Authored-By: Claude noreply@anthropic.com