Skip to content

Dev - #23

Merged
Retsomm merged 3 commits into
mainfrom
dev
Aug 1, 2026
Merged

Dev#23
Retsomm merged 3 commits into
mainfrom
dev

Conversation

@Retsomm

@Retsomm Retsomm commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor
    • Standardized styling across library, settings, reader, book, list, selection, sorting, and settings interfaces.
    • Preserved existing layouts, themes, controls, accessibility labels, and interactions.
  • Reliability
    • Bookmark updates continue to save correctly while retaining existing error logging behavior.
    • Reading, text-to-speech, sorting, annotations, search, copy, delete, and display behavior remain unchanged.

Retsomm and others added 2 commits August 1, 2026 19:30
依 RN 效能最佳實踐,將不依賴 props/state/theme 的樣式抽到各元件的
StyleSheet.create;隨 theme 顏色、props(如 width)、互動狀態變動的
部分仍用 style={[styles.x, { 動態值 }]} 合併,避免每次 render 產生
新物件、也讓之後套用 React.memo 的清單元件(如 BookCard)能真正生效。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
useBookmarks 原本依賴 setState updater 是否被提前同步執行來讀取新陣列,
在閱讀器頁面頻繁有其他 state 更新時該行為不保證發生,導致存進 AsyncStorage
的是舊值。改成跟 useAnnotations 一致的寫法:直接用當下 state 算出 next
再依序 setBookmarks/saveBookmarks。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
travel-in-time Ready Ready Preview Aug 1, 2026 12:09pm

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Retsomm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e6e50fd4-5966-4d75-b62f-177006a87b7f

📥 Commits

Reviewing files that changed from the base of the PR and between a60a456 and 2f57cff.

📒 Files selected for processing (1)
  • mobile/hooks/reader/useBookmarks.ts
📝 Walkthrough

Walkthrough

The mobile UI replaces inline React Native styles with local StyleSheet definitions across screens and components. Bookmark toggle and deletion handlers now derive updated lists directly from current state before persistence.

Changes

Mobile UI and bookmark changes

Layer / File(s) Summary
Screen stylesheet extraction
mobile/app/(tabs)/index.tsx, mobile/app/(tabs)/settings.tsx
Centralizes screen layout, typography, list, toggle, and WebView styles.
Reader and card stylesheet extraction
mobile/app/reader/[id].tsx, mobile/components/BookCard.tsx
Centralizes reader controls, overlays, progress indicators, covers, metadata, and deletion-control styles.
Panel and control stylesheet extraction
mobile/components/ListPanel.tsx, mobile/components/SelectionBar.tsx, mobile/components/SettingsPanel.tsx, mobile/components/SortControl.tsx
Centralizes styles for navigation, annotations, reading settings, selection actions, and sorting controls.
Bookmark state update changes
mobile/hooks/reader/useBookmarks.ts
Bookmark toggle and deletion handlers derive updated lists directly from bookmarks before state updates and persistence.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "Dev" is too generic and does not describe the stylesheet refactoring or bookmark state update. Replace "Dev" with a concise title that identifies the main change, such as "Refactor mobile styles into StyleSheet definitions".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@mobile/app/`(tabs)/index.tsx:
- Around line 189-206: Replace all reviewed inline JSX style props with
className bindings, preserving conditional theme and active-state behavior:
update mobile/app/(tabs)/index.tsx lines 189-206 for the safe-area, title, and
empty-state styles; mobile/app/(tabs)/settings.tsx lines 9-27 for the safe-area,
rows, labels, and switch; mobile/app/reader/[id].tsx lines 127-155 for the
reader header and controls; mobile/components/BookCard.tsx lines 32-44 for cover
and placeholder; mobile/components/ListPanel.tsx lines 118-123 and the remaining
panel controls; mobile/components/SelectionBar.tsx lines 30-44 for the selection
bar and swatches; mobile/components/SettingsPanel.tsx lines 46-60 for
helper-generated and JSX styles; and mobile/components/SortControl.tsx lines
21-30 for sort-control styles. Use the existing stylesheet/extraction classes
rather than introducing new inline objects.

In `@mobile/hooks/reader/useBookmarks.ts`:
- Around line 27-29: Update handleToggleBookmark and handleDeleteBookmark to use
a functional bookmarks state updater or reducer so consecutive calls compose
from the latest state instead of the captured snapshot. Move saveBookmarks out
of both handlers into a synchronization effect or equivalent that persists each
committed final bookmarks state, preserving the existing bookmark mutations and
id association.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e88edca-4641-432c-aef2-4c7a958fd3da

📥 Commits

Reviewing files that changed from the base of the PR and between 859357b and a60a456.

📒 Files selected for processing (9)
  • mobile/app/(tabs)/index.tsx
  • mobile/app/(tabs)/settings.tsx
  • mobile/app/reader/[id].tsx
  • mobile/components/BookCard.tsx
  • mobile/components/ListPanel.tsx
  • mobile/components/SelectionBar.tsx
  • mobile/components/SettingsPanel.tsx
  • mobile/components/SortControl.tsx
  • mobile/hooks/reader/useBookmarks.ts

Comment on lines +189 to +206
<SafeAreaView edges={['top']} style={[styles.safeArea, { backgroundColor: colors.paperBg }]}>
<View style={styles.header}>
<Text style={[styles.headerTitle, { color: colors.ink }]}>
書櫃 <Text style={[styles.headerCount, { color: colors.ink3 }]}>{books.length} 本</Text>
</Text>
<Pressable onPress={handleAddBook} hitSlop={12}>
<Text style={{ fontSize: 16, color: '#2563eb' }}>+ 加入書籍</Text>
<Text style={styles.addButtonText}>+ 加入書籍</Text>
</Pressable>
</View>

{books.length > 0 && (
<View style={{ paddingHorizontal: 16, paddingBottom: 12 }}>
<View style={styles.sortWrapper}>
<SortControl sort={sort} onSortChange={setSort} />
</View>
)}

{!loading && books.length === 0 ? (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<View style={styles.emptyState}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Use className and remove inline style props.

The stylesheet extraction still leaves inline JSX style objects in every reviewed component. Replace these style props with className bindings, including conditional theme and active-state classes.

  • mobile/app/(tabs)/index.tsx#L189-L206: Replace the safe-area, title, and empty-state style props.
  • mobile/app/(tabs)/settings.tsx#L9-L27: Replace the safe-area, row, label, and switch style props.
  • mobile/app/reader/[id].tsx#L127-L155: Replace the reader header and control style props.
  • mobile/components/BookCard.tsx#L32-L44: Replace cover and placeholder style props.
  • mobile/components/ListPanel.tsx#L118-L123: Replace table-of-contents style props and apply the same change to the remaining panel controls.
  • mobile/components/SelectionBar.tsx#L30-L44: Replace selection-bar and color-swatch style props.
  • mobile/components/SettingsPanel.tsx#L46-L60: Replace helper-generated and JSX style props.
  • mobile/components/SortControl.tsx#L21-L30: Replace sort-control style props.

As per coding guidelines, **/*.tsx: React JSX 頁面/元件中應使用 className 寫法,並避免使用 inline style.

📍 Affects 8 files
  • mobile/app/(tabs)/index.tsx#L189-L206 (this comment)
  • mobile/app/(tabs)/settings.tsx#L9-L27
  • mobile/app/reader/[id].tsx#L127-L155
  • mobile/components/BookCard.tsx#L32-L44
  • mobile/components/ListPanel.tsx#L118-L123
  • mobile/components/SelectionBar.tsx#L30-L44
  • mobile/components/SettingsPanel.tsx#L46-L60
  • mobile/components/SortControl.tsx#L21-L30
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@mobile/app/`(tabs)/index.tsx around lines 189 - 206, Replace all reviewed
inline JSX style props with className bindings, preserving conditional theme and
active-state behavior: update mobile/app/(tabs)/index.tsx lines 189-206 for the
safe-area, title, and empty-state styles; mobile/app/(tabs)/settings.tsx lines
9-27 for the safe-area, rows, labels, and switch; mobile/app/reader/[id].tsx
lines 127-155 for the reader header and controls; mobile/components/BookCard.tsx
lines 32-44 for cover and placeholder; mobile/components/ListPanel.tsx lines
118-123 and the remaining panel controls; mobile/components/SelectionBar.tsx
lines 30-44 for the selection bar and swatches;
mobile/components/SettingsPanel.tsx lines 46-60 for helper-generated and JSX
styles; and mobile/components/SortControl.tsx lines 21-30 for sort-control
styles. Use the existing stylesheet/extraction classes rather than introducing
new inline objects.

Source: Coding guidelines

Comment thread mobile/hooks/reader/useBookmarks.ts Outdated
handleToggleBookmark/handleDeleteBookmark 原本從 closure 裡的 bookmarks
快照算出 next 再同步存檔,連續呼叫(例如書籤清單連點兩個刪除)會用同一份
舊 snapshot,後者蓋掉前者。改成 functional updater 疊加狀態,saveBookmarks
移到跟著已提交 bookmarks state 變化的 effect 裡執行,同時維持前一輪修的
「不讀取 setState updater 尚未執行的舊值」。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Retsomm
Retsomm merged commit ccc0b8b into main Aug 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant