Skip to content

fix(watchstate): let profiles mark an audiobook listened - #3169

Merged
Quick104 merged 5 commits into
Silo-Server:mainfrom
Rhainland:fix/1253-audiobook-mark-listened
Oct 31, 2026
Merged

Quick104 merged 5 commits into
Silo-Server:mainfrom
Rhainland:fix/1253-audiobook-mark-listened

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1253
Validation tasks: changes #1256 C4; changes Silo-Server/silo-apple#339 C4; changes Silo-Server/silo-apple#340 C4; changes Silo-Server/silo-android#349 C4; changes Silo-Server/silo-android#350 C4

Marking an audiobook listened doesn't work. The web card menu offers Mark Listened, and iOS offers Mark as Finished on the audiobook screen. Both call POST /api/v2/watched/{id}, which answers 404 Item not found for every audiobook. The web shows an "Item not found" toast and nothing is saved. The watched-state resolver handled movies, series, seasons, episodes and ebooks, but not audiobooks.

This change lets the endpoint mark an audiobook listened or unlistened for the acting profile.

Approach

  • An audiobook is treated as a single item, like a movie. Marking it completes it, removes it from Continue Listening, and writes one manual history entry with the book's length. Unmarking clears the progress and keeps history.
  • The length is the sum of present files in the longest copy the profile can access, grouped by recording root and library. Catalog runtime is a fallback when a successful file lookup returns no usable duration. A file-query failure aborts the mark before any progress or history write; unmarking does not need that lookup.
  • Marking a book listened during a re-listen records another play, as for movies and episodes. Otherwise the action would silently do nothing and leave the book in Continue Listening.
  • Clearing an audiobook's resume position (DELETE /api/v2/progress/{id}/position) still answers 404, as documented.
  • The Audiobookshelf-compatible API reads the same progress rows, so ABS clients see the book as finished. ABS Reset Progress uses the shared history cutoff to clear listened state on native reads too, while keeping history. Reset requires an accessible audiobook. ABS reports acquire the shared profile history lock before reading the cutoff, and reports and session ticks stay newer than it, including after a future-dated retained play.
  • v1 /watched shares the handler and accepts audiobooks too. This repairs the broken mark operation under the documented bridge-usability exception; v1 still disables rewatch recording.

API descriptions for markWatched/unmarkWatched and the mark_watched_records_rewatch capability now name audiobooks; docs/progress-api.md and docs/architecture/api-contract.md match. The broader cross-device and cross-profile progress rules for audiobooks remain undecided on #1253. The C4 action paths listed above need re-validation after merge; C4/C10 acceptance remains blocked on that decision, and tvOS also needs Silo-Server/silo-apple#928.

Validation

  • New Postgres test (listed in scripts/ci/db-contracts.txt): mark mid-listen, mark during a re-listen, unmark, access-denied 404 and resume-position 404. It failed before the fix with not_found.
  • go test ./internal/api/handlers/... ./internal/apiv2/..., the handler DB pins, make verify-apiv2-openapi, verify-apiv2-web-types, verify-apiv2-contract, verify-route-inventory: pass.
  • Full gate on an integration build of this branch with the other Audiobooks #1253 fixes: see the summary on Audiobooks #1253.
  • Runtime: in the web app, Mark Listened now shows "Marked as listened" and the menu switches to Mark Unlistened; unmarking clears progress and keeps the history entry. A profile without access to the book still gets 404.
  • Review follow-up: TestAudiobookMarkListenedBoundariesPostgres failed on the original PR head for restricted-copy duration, file-read failure, and ABS reset. All three cases pass after the review fixes. Additional resume/finished cases failed on 9ebd69854 when reset covered future-dated history; those reports and subsequent session ticks are now visible to both native and ABS reads. The test is registered in the DB contract gate.
  • Initial review-fix checks: audiobook, handler and v2 packages; changed-line lint (0 issues); OpenAPI freshness; v2 semantic diff (0 changes); v1 route freeze; and local-path checks passed. The database gate passed 157 query pins and 372 contracts before the boundary cases were extracted into their own test; the extracted test passed separately. The full Go/web gate was not rerun locally.
  • Final reset follow-up: unknown and denied targets return 404, failed access resolution returns 403, and no rejected reset reaches persistence. A deterministic PostgreSQL reset/report interleaving now leaves both native and ABS progress at 120 seconds. These regressions fail on c66561bca and pass after the fix.
  • On b6e5754a8, the original mark test, all boundary cases, reset authority tests, all audiobook packages, the PostgreSQL user-store suite, and changed-line lint pass. The full Go/web/database gates were not rerun locally for this last follow-up. CI passes on final head b6e5754a8, including Go tests/lint/integration, database checks, web build/checks, all four web test shards, and the aggregate result. CodeRabbit, Kody, and Evidence checks pass; Macroscope evidence/validation-impact checks were skipped.
  • HTTP evidence was refreshed on a sandbox rebuilt from b6e5754a8 source. The restricted profile saves the allowed copy's 2400 seconds; ABS reset clears native completion and retains one manual play. Unknown and denied resets return 404 and leave zero cutoff rows. The build endpoint reports identity unavailable; production source hashes match the rebuilt checkout. Future-history/tick, injected file-error, access-resolver failure and concurrent reset/report cases remain test evidence. No device UI was used.
  • Rebased onto main at 19e98f9a5 (head fa3cf458b). The audiobook case now returns the series ID that fix(realtime): name the series on watched and progress events #2504 added to resolveWatchedTargets (empty, as for movies). Every commit builds; handler, v2, audiobook and user-store tests, changed-line lint, and the OpenAPI, web-types, v2 contract, route-inventory and local-path checks pass. PostgreSQL tests run in CI.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3169-review/

The linked page retains the original-head HTTP capture and refreshes the final capture at b6e5754a8 with the same synthetic fixture values in a new sandbox. It includes native/ABS responses, SQL history/cutoff reads, and tests that fail before the fixes and pass afterward. It also links the author's original desktop and phone-width card-menu captures (before e6df1d8ed, after this branch).

Risks

The capability mark_watched_records_rewatch now also covers audiobooks. A client that reads it to decide whether marking a re-listened book adds a play sees the new behaviour. A transient file-query failure now returns an error instead of recording a fallback duration; the user can retry the mark.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

Note

Review fixes by Quick104: gpt-6.1-sol in T3 Code using the Codex provider authored the access, error-handling, ABS reset/access/serialization/timestamp, regression-test, and documentation follow-ups. Independent review: claude-opus-5-5 in T3 Code. Quick104's rebase onto current main: claude-opus-5-5 in Claude Code (T3 Code). The original author's disclosure below records their implementation and earlier review.

  • Harness: Claude Code (T3 Code)
  • Tool(s): Claude Code, Codex CLI, GitHub CLI, Playwright, Docker, ffmpeg
  • Model(s): claude-opus-5-5; gpt-6.1-sol (review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Independent Claude Opus 5.5 and GPT 6.1 Sol reviews of the branch diff (correctness, repo standards, the bug as described). GPT found nothing. Opus noted that this adds a third way to total a book's length; it is kept because the catalog runtime can't be trusted here until the duration fix merges, and the two agree for single-folder books.

Note

Add audiobook support to watched-state marking and ABS reset in watchstate

  • ItemsHandler.lookupWatchedTarget now accepts audiobooks, and played audiobook targets get a duration from audiobookDurationSeconds, which sums accessible file durations per recording copy, picks the longest group, and falls back to catalog runtime or zero. Unplayed audiobooks skip the duration lookup.
  • ItemsHandler.SetWatchedState includes audiobooks in the rewatch condition, so a watched audiobook with a resume position can record another play. ItemsHandler.ClearResumePosition explicitly rejects audiobooks with 404.
  • ABS Reset Progress (Handler.handleDeleteItemProgress) now requires an accessible audiobook and returns 404 for unknown or inaccessible targets. ABSProgressStore.DeleteProgress clears watched state via ClearWatchedState instead of deleting the row directly, keeping history behind a cutoff.
  • ABS progress writes (UpsertProgress, UpdateProgressPosition) now take the shared profile history-cutoff lock (LockHistoryCutoff) and set timestamps at least one second after an item's hidden_before cutoff.
  • Adds database-backed tests in watch_state_unwatch_db_test.go covering access enforcement, rewatch recording, ABS reset concurrency, and boundary cases. Updates the v2 API contract and docs.
  • Behavioral Change: ABSProgressStore.DeleteProgress no longer deletes the progress row directly; check handleDeleteItemProgress and DeleteProgress if ABS resets previously expected a raw row deletion. Clearing a resume position now returns 404 for audiobooks.

Macroscope summarized fa3cf45.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fcdd663a-c62c-4eb5-8feb-0d83711be0ce
Commits

Reviewing files that changed from the base of the PR and between c66561b and b6e5754.

Files selected for processing: 6
  • docs/progress-api.md
  • internal/api/handlers/watch_state_unwatch_db_test.go
  • internal/audiobooks/abs/access_scope_test.go
  • internal/audiobooks/abs/extras_handlers.go
  • internal/audiobooks/abs_progress_store.go
  • internal/userstore/pgstore/progress.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Walkthrough

Audiobooks are now supported by watched-state handling. Manual play duration uses accessible audiobook file copies, with catalog runtime as a fallback. Audiobookshelf progress deletion clears listened state while retaining history. API descriptions and PostgreSQL tests cover these changes.

Changes: Audiobook watched-state flow

Layer / File(s) Summary
Resolve audiobook targets and duration
internal/api/handlers/items.go
Watched-target lookup accepts audiobooks. Manual play duration sums positive file durations by media folder and canonical root, uses the longest total, and falls back to catalog runtime.
Apply and verify audiobook watched state
internal/api/handlers/watch_state_service.go, internal/audiobooks/abs_progress_store.go, internal/userstore/pgstore/progress.go, internal/audiobooks/abs/*, internal/api/handlers/watch_state_unwatch_db_test.go, scripts/ci/db-contracts.txt
Marking an audiobook watched during a rewatch can record another play. Clearing its resume position returns 404. Audiobookshelf progress deletion clears watched state while retaining history, and progress timestamps are coordinated with history cutoffs. PostgreSQL tests cover access, duration, progress, history, and reset behavior.
Describe audiobook watched-state behavior
contracts/api/v2/openapi.json, docs/architecture/api-contract.md, docs/progress-api.md, internal/apiv2/*, web/src/api/v2/schema.ts
API descriptions include audiobooks among watched-state targets and rewatch behavior. They also document audiobook duration rules, reset behavior, and the exclusion of audiobooks from clearResumePosition.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ItemsHandler
  participant AudiobookFileLookup
  participant WatchStateService
  ItemsHandler->>AudiobookFileLookup: resolve accessible audiobook durations
  AudiobookFileLookup->>ItemsHandler: return duration or lookup error
  ItemsHandler->>WatchStateService: set audiobook watched state and duration
Loading

Possibly related issues

  • Silo-Server/silo-server#1253: The PR adds audiobook watched-state marking, history entries, and progress behavior. The issue’s cross-device and cross-profile progress rule remains unresolved.
  • Silo-Server/silo-server#3098: The PR uses the longest accessible copy’s duration for manual audiobook history, addressing a related multi-file duration concern.
  • Silo-Server/silo-server#1256: The PR changes the shared audiobook watched-state API used by Web, though the issue’s client validation remains outstanding.
  • Silo-Server/silo-server#1254: The PR changes server-side audiobook watched state, progress, history, and access resolution. Resume validation remains unresolved.

Possibly related PRs

Suggested labels: api-v2, impact: playback, javascript

Suggested reviewers: blurbery

Merge Risk: Minimal · up to fa3cf

No actionable merge-blocking issue was identified in the audiobook watched-state changes. Normal merge checks can proceed.

Security architecture risk: Low · up to fa3cf

The expanded operation preserves item-access checks and profile ownership. The main remaining risk is a narrowly scoped concurrency issue: simultaneous marking and resetting can leave different completion views inconsistent for the same audiobook. No cross-profile access or privilege expansion was identified in the inspected paths.

Retained concerns

  • Low · reliability · inferred: Native marking does not participate in the cutoff serialization used by ABS reset. When no committed progress row exists, a native mark can insert progress, reset can commit its cutoff and delete no visible row, and the mark can then insert completion history newer than that cutoff. After commit, cutoff-filtered progress reads hide the progress while completion-history reads restore completion. The expanded audiobook lifecycle therefore has a cross-client reset-convergence gap. The impact is limited to the same profile and audiobook; no authorization bypass is established.
Security review details

Security Blast Radius

  • inferred — The inspected mutation paths affect the authenticated profile's audiobook progress, completion history, and associated notifications. Their predicates retain user/profile/item scoping; the identified concurrency issue does not establish access to another profile or library.

Trust Boundaries and Controls

  • observed — The caller-controlled content ID remains subject to catalog access checks. Native profile selection passes through viewer-access resolution, and the v2 command uses context-derived identity rather than accepting ownership identifiers in its operation input.

Resilience and Maintainability Implications

  • observed — ABS session-position updates remain update-only, so they cannot recreate a missing progress row. Reset publishes its success event only after persistence succeeds. The added concurrency test covers an ABS report waiting behind reset, not a native mark inserting a previously absent row.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: allowing profiles to mark audiobooks as listened.
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.
Description check Passed The description states the problem (Mark Listened and Mark as Finished for audiobooks return 404 on POST /api/v2/watched/{id}), the approach (audiobook treated as a single item, duration from accessib…
Full details: Description check

Explanation

The description states the problem (Mark Listened and Mark as Finished for audiobooks return 404 on POST /api/v2/watched/{id}), the approach (audiobook treated as a single item, duration from accessible files with catalog fallback, ABS reset changes), and validation steps. It is directly related to the changeset, so the check passes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 9 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 27, 2026
@silo-kody

silo-kody Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 27, 2026
Comment thread internal/api/handlers/items.go Outdated
Comment on lines +2666 to +2667
byFolder[file.MediaFolderID] += file.Duration
longest = max(longest, byFolder[file.MediaFolderID])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Duration overcounting occurs when grouping only by MediaFolderID because scanner.upsertAudiobookMediaItem reuses an existing content ID through findAudiobookDuplicate even for copies with different canonical roots, counting duplicate physical copies in the same library as additional parts. Marking the book listened persists the inflated duration in progress and manual history; sum parts per physical book root within each library, then select the longest copy.

Prompt for LLM

File internal/api/handlers/items.go:

Line 2666 to 2667:

Duration overcounting occurs when grouping only by MediaFolderID because scanner.upsertAudiobookMediaItem reuses an existing content ID through findAudiobookDuplicate even for copies with different canonical roots, counting duplicate physical copies in the same library as additional parts. Marking the book listened persists the inflated duration in progress and manual history; sum parts per physical book root within each library, then select the longest copy.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 62bd62d: files are now summed per recording root within a library, and the book counts its longest copy. The Mark Listened test now has a second copy in the same library.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks—that addresses the reported overcounting: summing per recording root within each library keeps duplicate copies separate, and selecting the longest copy avoids adding them together. The second copy in the same library adds regression coverage for the scenario flagged here.

Based on your description of 62bd62d6b, this suggestion is addressed; I haven’t independently verified the commit.

@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

The change is visible: marking an audiobook now succeeds and changes its listened/progress state. The linked evidence is described as web card-menu captures, so it does not show these affected surfaces:

  • Audiobook playback state: the book leaves Continue Listening and its detail action changes from Resume to Listen after marking listened; add before-and-after captures of the same book in those states, including the unmark flow if shown (desktop and phone-width web where affected).
  • iOS audiobook screen: “Mark as Finished” now succeeds instead of returning not found; add before-and-after iOS captures or a recording showing the action and resulting finished state.

Suggested fix: No code diff is needed; add the missing surface evidence to the linked evidence page.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@Rhainland

Copy link
Copy Markdown
Contributor Author

Not adding more captures. The evidence page shows the menu action succeeding and the book's watched state changing. Continue Listening and the Resume/Listen label read that same state, so they follow it. The iOS Mark as Finished result is recorded on Silo-Server/silo-apple#339; iOS needs no change because it calls the same endpoint.

@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3665fd8c-bb81-4350-a7f4-798b9f7d55e0
Commits

Reviewing files that changed from the base of the PR and between 62b1a6e and 62bd62d.

Files selected for processing: 10
  • contracts/api/v2/openapi.json
  • docs/architecture/api-contract.md
  • docs/progress-api.md
  • internal/api/handlers/items.go
  • internal/api/handlers/watch_state_service.go
  • internal/api/handlers/watch_state_unwatch_db_test.go
  • internal/apiv2/progress.go
  • internal/apiv2/watch.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread internal/api/handlers/items.go Resolved
Comment thread internal/api/handlers/items.go Resolved
@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026

Copy link
Copy Markdown

The changed POST/DELETE /api/v2/watched/{id} path reaches audiobook C4 actions across Web, iOS, and Android. The Android phone/tablet card menus also call it, despite the detail screen lacking a Finished control. Marking changes listened state, in-progress/Continue Listening, and history. The parent #1253 progress decision remains unresolved; tvOS C4 also depends on the separate, still-open #928 control change. The builds below are those recorded in the task comments; the integration runs were local.

task case surface validated build classification reason
Silo-Server/silo-apple#339 C4 iPad C4 blocked; iOS 876fbd31c53c; server integration 62b1a6e82 + #3165–#3173 major change The same Finished request now reaches the supported server path; C4 remains blocked by the profile-progress decision.
Silo-Server/silo-apple#340 C4 tvOS tvOS 876fbd31c53c + #927–#929; server e6df1d8ed → integration 62b1a6e82 + #3165–#3173 major change The server path changes, but open #928 supplies the missing Finished control; tvOS C4 still needs that change.
Silo-Server/silo-android#349 C4 Android phone C4 blocked; Android e9c410096; server integration 62b1a6e82 + #3165–#3173 major change Card-menu watched writes use this endpoint; action outcome changes, while cross-device/profile progress remains blocked.
Silo-Server/silo-android#349 C4 Android tablet C4 blocked; Android e9c410096; server integration 62b1a6e82 + #3165–#3173 major change The shared card-menu write reaches this endpoint; action outcome changes, while progress semantics remain blocked.
#1256 C4 Web Web e6df1d8ed; server e6df1d8ed → integration 62b1a6e82 + #3165–#3173 unblocks The recorded Mark Listened 404 is removed; re-test watched/unwatched and history; progress semantics remain blocked.
Silo-Server/silo-apple#339 C4 iPhone iOS 876fbd31c53c; server e6df1d8ed → integration 62b1a6e82 + #3165–#3173 unblocks The recorded Mark as Finished 404 is removed; re-test on iPhone; profile/cross-device rules remain blocked.
Silo-Server/silo-android#350 C4 Android TV Android TV e9c410096 + #703–#708; server e6df1d8ed → integration 62b1a6e82 + #3165–#3173 unblocks The recorded card-menu 404 is removed; re-test after server merge; progress semantics remain blocked.

For the major-change rows, the PR description should explain why these C4 paths change and that they need re-validation after merge. Keep the unresolved progress semantics blocked; tvOS also needs #928's control before its UI flow can be re-tested.

Suggested fix: Replace the current Validation tasks: line with:

Validation tasks: unblocks #1256 C4; unblocks Silo-Server/silo-apple#339 C4 (iPhone); changes Silo-Server/silo-apple#339 C4 (iPad); changes Silo-Server/silo-apple#340 C4 (tvOS); changes Silo-Server/silo-android#349 C4 (phone/tablet); unblocks Silo-Server/silo-android#350 C4

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 62bd62d6b3535fba1cb02c490142ac65e0e931c9 against 62b1a6e82408eb4be3409255583bf8b0a192a69f. The audiobook regression test passes on the head and fails on the base with not_found. Two additional issues reproduced against PostgreSQL; I am fixing them on this branch.

Note

AI disclosure: gpt-6.1-sol in T3 Code using the Codex provider. Independent review: claude-opus-5-5 in T3 Code.

Comment thread internal/api/handlers/items.go Resolved
Comment thread internal/api/handlers/items.go Resolved
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Quick104 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fit: 9/10 · Readiness: 9/10 — ready.

Reviewed original head 62bd62d6b3535fba1cb02c490142ac65e0e931c9 against base 62b1a6e82408eb4be3409255583bf8b0a192a69f. The review fixes are pushed and verified at b6e5754a82e28edd9e98480723f8523bdc431d9d.

Rebased onto main at 19e98f9a5, so the branch was rewritten; the head is now fa3cf458b. One conflict needed a code change: #2504 added a series ID return to resolveWatchedTargets, and the audiobook case now returns an empty series ID, as movies and ebooks do. Every rebased commit builds. Handler, v2, audiobook and user-store package tests pass, as do changed-line lint and the OpenAPI, web-types, v2 contract, route-inventory and local-path checks. The PostgreSQL tests did not run locally; CI's database job covers them. 🤖 Claude Code in T3 Code (claude-opus-5-5)

This repairs existing audiobook mark controls at the shared server boundary and reuses the completion transaction. It fits the current correctness work while keeping audiobooks in beta. The verified findings are addressed:

  • P2, restricted-copy duration: a denied 4200-second copy could set the saved duration when the allowed copy was 2400 seconds. Duration now uses accessible files.
  • P3, ABS reset: retained completed history could restore native completion after ABS deleted progress. Reset now clears completion through the shared history cutoff and retains the play.
  • P2, ABS reports after reset: future-dated history could hide new reports, and a concurrent reset/report could still use a stale cutoff snapshot. Reports now acquire the shared profile history lock before reading the cutoff; reports and session ticks preserve timestamps beyond it.
  • P3, reset target validation: unknown and denied IDs could create cutoff rows, and access-resolution errors were bypassed. Reset now requires an accessible audiobook before persistence. The arbitrary-key write is confirmed; cross-profile mutation and storage exhaustion were not demonstrated.
  • Existing file-query finding: failed file reads now abort marks before progress or history writes. Unmarking skips that read. The protocol docs also describe the successful-lookup catalog-runtime fallback.

The original PostgreSQL test fails on the PR base with not_found. The duration/error/reset cases fail on the original PR head; future-cutoff cases fail on 9ebd69854; reset authority and concurrent reset/report cases fail on c66561bca. All pass with the final fixes. The concurrency test uses real stores and observable PostgreSQL lock waits. Final local checks passed for the original mark test, every boundary case, reset authority tests, all audiobook packages, the PostgreSQL user-store suite, and changed-line lint. Earlier handler/v2, OpenAPI/contract/route/local-path and database-gate checks passed; the full Go/web/database gates were not rerun locally for this last follow-up. CI passes on final head b6e5754a8: Go tests, lint, integration, database checks, web build/checks, all four web test shards, and the aggregate result. CodeRabbit, Kody, and Evidence checks pass. Cache pruning, the Claude action, and Macroscope evidence/validation-impact checks were skipped.

HTTP evidence was refreshed on a sandbox rebuilt from the final source. The restricted profile saves 2400 seconds; ABS reset returns 204, removes native completion, and retains one manual play. Unknown and denied reset targets return 404 and leave zero cutoff rows. The runtime build endpoint reports identity unavailable; matching production source hashes support the rebuild check. The original before capture remains linked, with the separate sandbox runs stated explicitly. Future-history/tick, injected file-error, access-resolver failure, and concurrency cases remain test evidence. No device UI was used.

Validated features: the structured passed-case set was empty; rehearsal comments do not establish human acceptance. Re-test audiobook C4 on Web (#1256), iPhone/iPad (Silo-Server/silo-apple#339), tvOS (Silo-Server/silo-apple#340), Android phone/tablet (Silo-Server/silo-android#349), and Android TV (Silo-Server/silo-android#350). Broader C4/C10 acceptance remains blocked by #1253; tvOS also needs Silo-Server/silo-apple#928. No board status or validation results were changed.

Existing Apple actions use the shared endpoint. Android has no audiobook mark control on the checked main branch; its validation task records the follow-up. No client contract change is required here. Jellyfin excludes audiobooks from this surface; ABS reset parity is handled here. The public beta audiobook/ABS manual pages do not describe these controls, so no manual issue is needed. The original desktop and phone-width card-menu captures still cover the normal flow.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3169-review/

Review method: native gpt-6.1-sol passes plus one independent claude-opus-5-5 round. Kody identified the future-cutoff issue, and CodeRabbit's updated architecture note prompted the final target/concurrency checks; I independently reproduced them and authored the fixes. CodeRabbit withdrew the v1 objection under the documented critical bridge-fix exception; v1 still passes recordRewatch=false. All temporary review resources were removed. Review complete; the PR remains open for a maintainer to merge.

Note

AI disclosure: gpt-6.1-sol in T3 Code using the Codex provider. Independent review: claude-opus-5-5 in T3 Code. Rebase onto current main: claude-opus-5-5 in Claude Code (T3 Code).

@coderabbitai coderabbitai Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase impact: playback Can't play, stalls, or wrong media javascript Pull requests that update javascript code labels Oct 28, 2026
if err != nil {
return fmt.Errorf("abs_progress_store: open user store: %w", err)
}
if err := store.ClearWatchedState(ctx, profileID, []string{contentID}, time.Now().UTC()); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Progress visibility mismatch in internal/audiobooks/abs_progress_store.go occurs after Reset when ClearWatchedState raises hidden_before to the newest retained watched_at and ABSProgressStore.UpsertProgress writes time.Now() without advancing past that cutoff: a future-dated retained play causes subsequent listening or mark-finished progress saved through ABS to appear in ABS but remain filtered out by native GetProgress until that date. Advance updated_at past the cutoff for ABS progress writes, as PostgresUserStore.UpdateProgress already does.

Prompt for LLM

File internal/audiobooks/abs_progress_store.go:

Line 215:

Progress visibility mismatch in internal/audiobooks/abs_progress_store.go occurs after Reset when ClearWatchedState raises hidden_before to the newest retained watched_at and ABSProgressStore.UpsertProgress writes time.Now() without advancing past that cutoff: a future-dated retained play causes subsequent listening or mark-finished progress saved through ABS to appear in ABS but remain filtered out by native GetProgress until that date. Advance updated_at past the cutoff for ABS progress writes, as PostgresUserStore.UpdateProgress already does.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed against PostgreSQL: after reset covers a future-dated retained play, both an ABS resume report and a finished report are absent from native reads. The new regression fails on 9ebd69854 for both states. I am advancing ABS write timestamps past the shared cutoff and checking session-sync writes too, so a later tick cannot hide the row again. I am fixing this on the branch.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for confirming against PostgreSQL. That validates the finding on 9ebd69854 for both resume and finished reports.

Checking session-sync writes is important: every ABS write that refreshes progress must keep updated_at strictly greater than the shared cutoff, so a later tick cannot hide the row again.

The regression should verify native visibility after reset → ABS resume/finished report → session-sync tick, while confirming retained history stays intact. The planned fix addresses the reported issue; it remains open pending the branch changes and passing regression results.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in c66561bca. ABS reports and session ticks now advance beyond the shared cutoff; ticks also preserve the existing row timestamp. The PostgreSQL resume/finished cases fail on 9ebd69854 and pass after the fix. An intermediate run also confirmed that fixing reports alone still hid progress on the next session tick, so the regression checks both writes. The original mark/reset cases, all audiobook packages, and changed-line lint pass.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the follow-up. Based on the reported changes and PostgreSQL regression results, this finding is addressed by c66561bca.

Covering both ABS reports and subsequent session ticks closes the visibility gap: progress stays strictly newer than the shared cutoff, and ticks preserve the existing row timestamp rather than moving it backward. The fail-before/pass-after coverage for both resume and finished states directly exercises the reported bug.

I haven’t independently inspected the commit or rerun the tests; this assessment is based on your results.

@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026

Copy link
Copy Markdown

The linked web card-menu evidence covers the Mark Listened state change, but the commits since that evidence review add two user-visible effects it does not show:

  • internal/api/handlers/items.go: audiobook manual-play duration is now based on the longest accessible copy and is exposed in progress/history reads. Add before-and-after response excerpts for a multi-copy audiobook showing the recorded duration.
  • internal/audiobooks/abs_progress_store.go: ABS Reset Progress now clears the listened state returned to native reads while retaining the history entry. Add before-and-after response excerpts (or affected-client captures) showing reset state and retained history.

Suggested fix: Add these response excerpts or captures to the linked evidence page.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6387b776-a359-4827-8886-cd5c0334ecc6
Commits

Reviewing files that changed from the base of the PR and between 62bd62d and 9ebd698.

Files selected for processing: 5
  • docs/progress-api.md
  • internal/api/handlers/items.go
  • internal/api/handlers/watch_state_unwatch_db_test.go
  • internal/audiobooks/abs_progress_store.go
  • scripts/ci/db-contracts.txt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Comment thread docs/progress-api.md Resolved
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Oct 28, 2026
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Rhainland and others added 5 commits October 30, 2026 23:45
POST /api/v2/watched/{id} answered 404 for an audiobook because the
watched-state resolver only knew movies, ebooks, series, seasons and
episodes. It now resolves an audiobook as a leaf sized to the whole
book (the sum of its present files, not the first file or the catalog
runtime), so marking completes it, ends Continue Listening and records
one manual play like a movie, and unmarking clears it. A re-listen in
progress records another play, as a movie rewatch does.

clearResumePosition keeps answering 404 for an audiobook.
Two copies of the same recording in one library share an item, and summing
files per library counted the second copy as more parts, doubling the length
stored on the manual play. Sum files per recording root and keep the longest
copy.
@Quick104
Quick104 force-pushed the fix/1253-audiobook-mark-listened branch from b6e5754 to fa3cf45 Compare October 31, 2026 03:49
@silo-kody

silo-kody Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit abae88c into Silo-Server:main Oct 31, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: playback Can't play, stalls, or wrong media javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants