Repository navigation
fix(web): exit the reader through history so back doesn't re-open it - #281
Conversation
|
Warning Review limit reached
Next review available in: 47 minutes Limit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe reader now checks router history before handling back clicks. Direct entries use route replacement. Next-chapter links replace the current reader entry. Tests cover history traversal, fallback navigation, and both next-chapter controls. ChangesReader navigation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized navigation change preserves direct-link and modified-click behavior while correcting the reader exit path; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant EbookReader
participant hasRouterHistory
participant ReactRouter
participant SeriesPage
EbookReader->>hasRouterHistory: Check router history index
hasRouterHistory-->>EbookReader: Return history availability
EbookReader->>ReactRouter: Navigate -1 for eligible back click
ReactRouter->>SeriesPage: Restore prior route
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 800873ce96
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| event.preventDefault(); | ||
| navigate(-1); |
There was a problem hiding this comment.
Preserve reader exit target after Next chapter
When a manga chapter is opened with the in-reader Next link, that link is a normal <Link> push, so the previous history entry is another /reader/ebook/... page while backHref still points at the series via backTo. This handler now prevents the backHref navigation and always calls navigate(-1) whenever history exists, so Back on chapter 2 returns to chapter 1 instead of exiting to the series, and users who advanced through several chapters have to walk back through each prior reader page.
Useful? React with 👍 / 👎.
Code reviewFound 1 issue:
Back handler that pops a single entry: silo-server/web/src/pages/EbookReader.tsx Lines 599 to 622 in 800873c Pushing next-chapter links (header and end-of-book CTA): silo-server/web/src/pages/EbookReader.tsx Lines 637 to 639 in 800873c silo-server/web/src/pages/EbookReader.tsx Lines 1305 to 1307 in 800873c Contrast with the existing silo-server/web/src/pages/EbookReader.tsx Lines 303 to 305 in 800873c 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
The reader's header back control was a plain Link push: exiting to the series page stacked a second series entry on top of the reader, so pressing back on the series page navigated to the reader again. Plain left-clicks now consume the reader's history entry (navigate(-1)) when in-app history exists; the href remains for modified clicks and as the fallback for direct deep links into the reader. The history-availability check is extracted to lib/backNavigation and shared with PageBack, which already used the same pattern. Fixes Silo-Server#189 Co-Authored-By: Claude Fable 5 <[email protected]>
800873c to
3b4eec6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 147e9b02ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| !hasRouterHistory() | ||
| ) { | ||
| return; |
There was a problem hiding this comment.
Replace the reader entry when no history exists
When the reader is opened directly in a fresh tab or after a full-page navigation, React Router initializes the current entry with idx === 0, so this branch returns and lets the <Link> perform a push. The resulting history is [reader, backHref], meaning pressing browser Back on the destination immediately reopens the reader—the same loop this change is intended to eliminate. The no-history fallback should replace the reader entry with backHref rather than push it.
Useful? React with 👍 / 👎.
Problem
Exiting the manga/ebook reader to the series page, then pressing back on the series page, re-opened the reader. The reader's header back control was a plain
<Link>push: history became[…, series, reader, series], so back landed on the reader again — an inescapable loop unless the user force-navigated elsewhere.Approach
Plain left-clicks on the reader's back control now consume the reader's history entry (
navigate(-1)) when in-app history exists, so history returns to wherever the reader was opened from. Thehrefis preserved for modified clicks (open in new tab) and remains the fallback when the reader was opened as a direct deep link (no in-app history).The history-availability predicate is extracted to
lib/backNavigation.tsand shared withPageBack, which already implemented the same pattern — one definition instead of two copies.Testing
New regression test: history seeded as
[origin, reader]withbackTopointing at a third URL — clicking Back must land on the origin entry, not a fresh push ofbackTo(fails on the old push behavior). Existing backTo-sanitization tests still pass (the href is unchanged). Full EbookReader + PageBack suites green;pnpm run lint+format:checkclean. (Two unrelated test files fail identically on clean origin/main — pre-existing upstream breakage, verified by stash comparison.)Fixes #189
AI-use disclosure
Implemented with Claude Code (test-first); human-reviewed before submission.
🤖 Generated with Claude Code
Summary by CodeRabbit