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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ npm run test:e2e
- PDF 内部页码链接在点击所在的阅读窗口跳转;较慢的链接解析不会覆盖之后的翻页、同页选择或速翻操作。无法解析的链接会在原窗口提示,按 Esc 可关闭提示
- PDF 内部链接在原阅读窗口打开目标页,保留其他窗口的位置和缩放;用 Enter 跳到其他页后,可继续用方向键翻页。链接解析期间若已把焦点移到工具栏或其他窗口,不会把焦点抢回
- 最多新增到 12 张夹页,可通过上下移动按钮调整顺序;移除正在对照的夹页时可选择是否保留窗口
- 夹页的铅笔按钮可编辑名称与备注,例如「定义」「证明」「图示」。名称最多 80 字、备注最多 500 字,留空名称恢复页码;点击「保存」后随阅读现场存到本机。取消或 Esc 不保存草稿,切换书籍、速翻、卡片/列表视图或侧栏/抽屉布局也会取消编辑,普通阅读页码或活动窗口变化会保留草稿;原 PDF 不受影响
- 点击左上角 LeafSpace 回到书库。切换书籍、回到书库前,会先保存当前现场
- 页码、缩放、夹页与窗口布局在操作停止后自动保存;切到后台时会尽早尝试保存待存更改。只有真正保存完成才显示「已保存到本机」。存储失败或上次现场未恢复时仍需明确重试,后台保存不能保证在系统结束进程前完成
- 有尚未保存的阅读更改、进行中或失败的保存、未保存的 PDF 时,刷新或关闭页面会请求浏览器离开确认;保存成功后不再提示。浏览器控制提示文字与显示条件,手机进程被结束时可能不会提示,请保留原 PDF
- 若 PDF 本机副本保存失败,可继续阅读并「重试保存」;系统会先补存原 PDF,再保存最新现场,不会悄悄丢下无法重新打开的书籍
- 若上次现场读取失败,切换书籍和返回书库不会覆盖它。可重试恢复;选择「保存现场」时需明确确认是否用当前现场替换
- 若上次现场读取失败,切换书籍和返回书库不会覆盖它。可重试恢复;选择「保存现场」时需明确确认是否用当前现场替换。仍无法读取比较版本时不会盲目覆盖
- 多个标签页打开同一本书时,保存会在同一存储事务中检查现场版本。检测到其他页的更改后,会保留本页尚未保存的页码、夹页和窗口,暂停自动保存与切换;可继续阅读,或明确选择「载入已存现场」「用此页覆盖」。取消不会改变任一现场,任一确认后若检测到其他页再次保存,仍会保留本页并重新提示冲突
- 冲突期间请勿关闭仍有未存更改的标签页。载入会放弃本页未存现场,覆盖会替换检测到的已存现场,两者都需确认;原 PDF 不受影响。已打开的旧版页境仍可能使用旧保存方式,更新后请先保存并关闭或刷新旧版标签页
- 关闭错误提示后,顶部「查看问题」可重新打开原有说明和重试入口;查看说明不会自动重试或覆盖现场
- 若单页绘制失败,阅读区会显示「重试此页」;明确重试只重新绘制这一页,保留书籍、缩放、夹页与窗口现场,也可以直接翻到其他页继续阅读
- 最近列表展示 3 本书,但不会删除更早书籍的 PDF 或阅读现场;重新导入同一本 PDF 可恢复
Expand Down
17 changes: 17 additions & 0 deletions docs/specs/shared-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ unholdPage(pageNumber: number): void
reorderHeldPages(fromIndex: number, toIndex: number): void
markHeldPageOpen(pageNumber: number, windowId: string): void
markHeldPageClosed(pageNumber: number, windowId: string): void
updatePageMetadata(id: string, generation: number, changes: Pick<HeldPage, 'customName' | 'note'>): boolean
```

### 5.4 Window actions
Expand Down Expand Up @@ -259,3 +260,19 @@ clearWorkspace(documentId: string): Promise<void>
- Pinch preview transforms pixels locally; release commits one clamped reader scale with the original paper point anchored to the ending midpoint. It never changes another window or the browser viewport scale. Existing 10–400% stored scale compatibility is retained.
- Timeline pointer preview is transient and never enters book/window stores or autosave. A normal release commits once to the originating active window. Moving more than56px vertically from the starting track position marks release as cancel; moving back resumes preview. Escape/Space, lost capture, pointercancel, blur, book/window/overlay change cancel. Native range keyboard and independent change input remain available.
- Chromium CDP native touch input and cross-engine DOM TouchEvent contracts are separate evidence categories. iPhone-sized WebKit emulation is not physical iOS testing.

## Cross-tab workspace persistence

- `WorkspaceSnapshot.revision?: string` is an opaque write identity. Existing v1/v2 snapshots remain readable without migration or PDF conversion. The comparison token includes the complete lightweight record to detect legacy writers, even with identical timestamps or reused/missing revisions.
- `PersistenceService.saveWorkspace(snapshot, expectedVersion)` returns the committed snapshot. Absence is represented by `null`; it never implies permission to replace an existing record. Read/compare/write and lightweight metadata commit share one IndexedDB readwrite transaction. A sidecar failure rolls back the snapshot too. Failed schema upgrades retain the existing read-only legacy fallback.
- An owned identical-content save returns the existing snapshot without changing timestamps, revision or metadata. A stale identical-content save still conflicts. PDF payloads are never rewritten by workspace saves.
- Each opening owns a mutable persistence cursor, separate from request generations and exit baselines. Queued same-opening saves read the cursor at execution and advance it only after transaction success. An earlier conflict halts subsequent queued requests. No BroadcastChannel event is required for correctness.
- A conflict preserves the stored snapshot and every live page, zoom, held-page and window state. It blocks auto/hidden saves and library/import transitions, survives alert dismissal, and retains the unsaved-exit warning. Ordinary Save only exposes resolution controls.
- Confirmed reload compares a fresh read to the exact detected version before replacing live state; another committed change refreshes conflict details and requires new confirmation. Read/validation failure preserves the live scene, including rollback after partial legacy-layout application. Confirmed overwrite is bound to the exact detected version; another committed change requires a new explicit decision. Cancellation changes neither scene. A confirmed reload immediately retires older link/held-read navigation while its read is pending; accepted same-page scene replacement also retires reference owners. Failed partial application restores content while metadata generations stay monotonic.
- A still-unread failed-restore replacement requires a successful comparison read before CAS; it never falls back to blind overwriting. Existing running pre-fix tabs cannot be forced to respect CAS. Modern code detects their subsequent changes; users should close or refresh older-version tabs before parallel reading.

## Held-page metadata editing

- Metadata edits patch only explicitly changed `customName`/`note` fields. Names normalize to one trimmed line (80 Unicode code points); notes retain interior newlines (500 code points). Blank fields clear the override. Invalid edits fail atomically; legacy fields are never truncated during read, cancel, restore, or an unrelated edit.
- `heldStore.metadataGeneration` is transient and advances only on reset/restore, not thumbnail, ordering, or linked-window changes. Metadata writes require the opening generation plus live held-page ID; App additionally checks the book's document/session and loading/restore ownership. Metadata uses the pre-existing saved fields; metadataGeneration never enters snapshots.
- The inline editor is a transient draft. Save/cancel are separate from navigation; starting editor pointer input disposes a pending held-read transaction and cancels long-press recognition. Enter/Escape during IME composition stay inside the editor. Escape cancels an ordinary draft before global reference/drawer closing. Document/session/replaced held-list, removed held-page, and temporary surface/layout interruptions retire the draft. Ordinary reader page/active-window changes, consulting another held card, reordering, and window blur preserve it, including a delayed source-owned PDF link resolution. Removing the edited page retires its draft; removing another page does not.
6 changes: 3 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export default defineConfig({
},
{ name: 'firefox', testIgnore: '**/native-touch.test.ts', use: { ...devices['Desktop Firefox'], viewport: { width: 1440, height: 900 } } },
{ name: 'webkit', testIgnore: '**/native-touch.test.ts', use: { ...devices['Desktop Safari'], viewport: { width: 1440, height: 900 } } },
{ name: 'mobile-webkit', testMatch: ['**/gesture-contract.test.ts', '**/site-icons.test.ts', '**/storage-recovery.test.ts', '**/held-read-intent.test.ts', '**/thumbnail-actions.test.ts', '**/fit-width.test.ts', '**/password-recovery.test.ts', '**/hidden-save.test.ts', '**/recovery-access.test.ts', '**/reader-activation.test.ts', '**/mixed-pages.test.ts', '**/pdf-decoders.test.ts', '**/pdf-fonts.test.ts', '**/render-recovery.test.ts', '**/pdf-links.test.ts'], use: { ...devices['iPhone 13'] } },
{ name: 'mobile-webkit', testMatch: ['**/gesture-contract.test.ts', '**/site-icons.test.ts', '**/storage-recovery.test.ts', '**/held-read-intent.test.ts', '**/held-metadata.test.ts', '**/thumbnail-actions.test.ts', '**/fit-width.test.ts', '**/password-recovery.test.ts', '**/hidden-save.test.ts', '**/recovery-access.test.ts', '**/reader-activation.test.ts', '**/mixed-pages.test.ts', '**/pdf-decoders.test.ts', '**/pdf-fonts.test.ts', '**/render-recovery.test.ts', '**/pdf-links.test.ts'], use: { ...devices['iPhone 13'] } },
{
name: 'tablet',
testMatch: ['**/responsive.test.ts', '**/native-touch.test.ts', '**/gesture-contract.test.ts', '**/site-icons.test.ts', '**/storage-recovery.test.ts', '**/held-read-intent.test.ts', '**/thumbnail-actions.test.ts', '**/fit-width.test.ts', '**/password-recovery.test.ts', '**/hidden-save.test.ts', '**/recovery-access.test.ts', '**/reader-activation.test.ts', '**/mixed-pages.test.ts', '**/pdf-decoders.test.ts', '**/pdf-fonts.test.ts', '**/render-recovery.test.ts', '**/pdf-links.test.ts'],
testMatch: ['**/responsive.test.ts', '**/native-touch.test.ts', '**/gesture-contract.test.ts', '**/site-icons.test.ts', '**/storage-recovery.test.ts', '**/held-read-intent.test.ts', '**/held-metadata.test.ts', '**/thumbnail-actions.test.ts', '**/fit-width.test.ts', '**/password-recovery.test.ts', '**/hidden-save.test.ts', '**/recovery-access.test.ts', '**/reader-activation.test.ts', '**/mixed-pages.test.ts', '**/pdf-decoders.test.ts', '**/pdf-fonts.test.ts', '**/render-recovery.test.ts', '**/pdf-links.test.ts'],
use: { ...devices['Desktop Chrome'], viewport: { width: 768, height: 1024 }, hasTouch: true, launchOptions: executablePath ? { executablePath } : {} },
},
{
name: 'mobile',
testMatch: ['**/responsive.test.ts', '**/native-touch.test.ts', '**/gesture-contract.test.ts', '**/site-icons.test.ts', '**/storage-recovery.test.ts', '**/held-read-intent.test.ts', '**/thumbnail-actions.test.ts', '**/fit-width.test.ts', '**/password-recovery.test.ts', '**/hidden-save.test.ts', '**/recovery-access.test.ts', '**/reader-activation.test.ts', '**/mixed-pages.test.ts', '**/pdf-decoders.test.ts', '**/pdf-fonts.test.ts', '**/render-recovery.test.ts', '**/pdf-links.test.ts'],
testMatch: ['**/responsive.test.ts', '**/native-touch.test.ts', '**/gesture-contract.test.ts', '**/site-icons.test.ts', '**/storage-recovery.test.ts', '**/held-read-intent.test.ts', '**/held-metadata.test.ts', '**/thumbnail-actions.test.ts', '**/fit-width.test.ts', '**/password-recovery.test.ts', '**/hidden-save.test.ts', '**/recovery-access.test.ts', '**/reader-activation.test.ts', '**/mixed-pages.test.ts', '**/pdf-decoders.test.ts', '**/pdf-fonts.test.ts', '**/render-recovery.test.ts', '**/pdf-links.test.ts'],
use: { ...devices['Pixel 7'], viewport: { width: 390, height: 844 }, defaultBrowserType: 'chromium', launchOptions: executablePath ? { executablePath } : {} },
},
],
Expand Down
Loading
Loading