Skip to content

fix(vault): don't collapse +30s skip to 0 when duration is unknown - #573

Merged
github-actions[bot] merged 1 commit into
devfrom
fix/vault-player-skip-forward-clamp
Aug 25, 2026
Merged

github-actions[bot] merged 1 commit into
devfrom
fix/vault-player-skip-forward-clamp

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

Summary

  • VaultPlayerViewModel.onSkipForward clamped the skip target against
    exo.duration.coerceAtLeast(0), which collapses to 0 while duration is
    still C.TIME_UNSET (negative) — seeking to the very start of the book
    instead of leaving the skip a plain forward nudge.
  • Extracted the target computation into a pure skipForwardTarget() helper
    (unit-testable without a real ExoPlayer) and switched onSkipForward to
    use it, guarding durationMs > 0 before clamping.

Tests

  • New VaultPlayerSkipForwardTargetTest covers: unknown duration (full skip
    applied), known duration (clamped), and negative position (never goes
    below 0).
  • Confirmed the new test fails on the pre-fix logic (reverted the guard
    locally, saw 1/3 tests red) before restoring the fix, per AGENTS.md's
    "prove a new test can fail" rule.
  • ./gradlew :feature:vault:testDebugUnitTest passes in full locally.

Note on overlapping work

This duplicates the L1 commit already present on the still-open
PR #537 (issue #530's 8-finding batch, currently labeled
status:needs-info after exhausting its turn budget partway through L1-L5).
Issue #564 states PR #537 is "now-closed," but as of this writing it is not
— it's open, stuck on human triage, and its diff already contains this
exact fix plus L2-L5. Since #564 was filed specifically to split L1 out into
its own small PR (per the human-facing recommendation logged in #537's
comments), this PR implements that split using the same approach #537
already validated. Once this merges, whoever resumes #537 should drop its
now-redundant L1 commit.

No sensitive paths touched (feature/vault/** isn't on agent-policy.yml's
sensitive_paths list), no security/release-blocker signal in the issue.

Closes #564.

VaultPlayerViewModel.onSkipForward clamped the skip target against
exo.duration.coerceAtLeast(0), which collapses to 0 while duration is
still C.TIME_UNSET (negative) — seeking to the very start of the book
instead of leaving the skip a plain forward nudge. Extracted the
target computation into skipForwardTarget() so it's unit-testable
without a real ExoPlayer.

Closes #564.
@github-actions
github-actions Bot marked this pull request as ready for review August 25, 2026 05:47
@github-actions github-actions Bot added the risk:low Principal review classified this PR as low risk label Aug 25, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-qa PR open, awaiting qa-agent verification label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pipeline is at capacity (7/5 active runs) — skipping this QA run. Re-apply status:needs-qa once activity settles, or re-trigger manually via workflow_dispatch.

@libravault-xyz libravault-xyz added status:needs-qa PR open, awaiting qa-agent verification and removed status:needs-qa PR open, awaiting qa-agent verification labels Aug 25, 2026 — with Claude
@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

QA verification — PR #573 vs issue #564

Issue type: bug report (no acceptance checklist) — checklist is "repro no longer reproduces, and a regression test proves it."

  • ✅ Repro no longer reproduces. Traced the pre-fix code (b82a7e8^): onSkipForward computed exo.seekTo((exo.currentPosition + SKIP_MS).coerceAtMost(exo.duration.coerceAtLeast(0))). With duration = C.TIME_UNSET (negative), duration.coerceAtLeast(0) → 0, so target.coerceAtMost(0) → 0 — confirms the exact "+30s collapses to 0" bug from the issue. The fix extracts skipForwardTarget() and only clamps against durationMs when durationMs > 0, otherwise clamps only at 0 (never negative). Manually replayed the old formula against the new test's inputs and confirmed it would return 0 instead of 30_000 — i.e. the new test is a real regression guard, not one that passes on both old and new code.
  • ✅ Regression test proves it. VaultPlayerSkipForwardTargetTest (3 cases: unknown duration → full skip applied, known duration → clamped, negative position → never goes below 0) exercises the real extracted function directly (no mocks involved — pure Long arithmetic), so there's no relaxed-mock-hides-the-bug risk here.
  • ✅ Closes L1: VaultPlayerViewModel skip-forward collapses to 0 when duration unknown #564 as stated; guard change is exactly what the issue asked for (duration > 0 before clamping).

Tests run:

./gradlew :feature:vault:testDebugUnitTest --continue
BUILD SUCCESSFUL in 4m 34s
211 actionable tasks: 166 executed, 45 from cache
  • feature:vault module: 148 testcases total, 0 failures, 0 errors (verified via the module's test-results/testDebugUnitTest/*.xml).
  • New test class VaultPlayerSkipForwardTargetTest: 3/3 passed (tests="3" failures="0" errors="0").
  • Scoped the run to :feature:vault:testDebugUnitTest rather than the full repo-wide testDebugUnitTest: skipForwardTarget is internal and only referenced within VaultPlayerViewModel.kt/its test, and only :app depends on feature:vault (no other module depends on it), so there's no cross-module surface this change could regress. Full-suite run wasn't run.

Regressions / related areas: onSkipBack and the startPositionTicker's own exo.duration.coerceAtLeast(0) usage (UI-state display only) are untouched and out of scope for this issue — no interaction with the changed code path.

AGENTS.md conventions:

  • ✅ Test file at correct mirrored path, class name <Subject>Test.kt, backtick-style method names.
  • ✅ Pure helper (skipForwardTarget) marked internal rather than private, per the stated pattern.
  • ✅ "Prove a new test can fail" — PR description states this was done locally (revert guard → 1/3 red); independently corroborated above by tracing the pre-fix formula by hand.
  • ✅ Single commit, Conventional Commits format (fix(vault): …), branch name fix/<short-slug>.
  • ✅ No hardcoded versions, no sensitive paths touched.

Note on the PR's "overlapping work" section: verified independently — PR #537 (issue #530's batch, contained this same L1 fix) was open when #573 was created and was closed ~2 minutes later, consistent with the PR description's account. Not a QA blocker.

No gaps found.

QA verdict: PASS

@github-actions github-actions Bot removed the status:needs-qa PR open, awaiting qa-agent verification label Aug 25, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-review QA passed, awaiting principal-review-agent label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Principal review — verdict: auto-merge

Risk label: risk:low, confirmed current — re-ran .github/scripts/classify_pr_risk.py origin/dev HEAD myself (45 changed lines, no sensitive-path match, well under the 400-line auto-merge cap). No commits landed after the label was set.

What I verified directly (not just read/trusted)

  • The fix is correct. skipForwardTarget() only clamps against durationMs when it's > 0; otherwise the +30s nudge applies unclamped, then the whole result is floored at 0. Matches the stated bug: C.TIME_UNSET is negative, so the old exo.duration.coerceAtLeast(0) collapsed the target to 0 while duration was still unknown.
  • Ran the new test suite for real: :feature:vault:testDebugUnitTest --tests VaultPlayerSkipForwardTargetTest → 3/3 pass, BUILD SUCCESSFUL.
  • Independently reproduced the "prove it can fail" claim (AGENTS.md's rule): reverted the durationMs > 0 guard locally (back to unconditionally clamping against durationMs.coerceAtLeast(0)) and reran — exactly 1/3 tests goes red (skips forward by the full amount when duration is unknown), matching the PR description's account precisely. Restored the file afterward (working tree now clean).
  • Test level/conventions match AGENTS.md: pure JVM JUnit 5 (correct level — no Android types involved), helper marked internal rather than private, backtick-named test methods, file at the conventional path/naming.
  • No sensitive paths touched — feature/vault/** isn't on agent-policy.yml's sensitive_paths list, confirmed by reading the file directly.
  • No new networking dependency/call introduced.
  • The "overlapping work with PR fix(vault): code review cleanup batch (L1-L8) #537" note checked out. At the time this PR's commit landed (05:47:01Z), fix(vault): code review cleanup batch (L1-L8) #537 was in fact still open — a human (libravault-xyz) closed it two minutes later (05:49:00Z), specifically to split it into independent issues including L1: VaultPlayerViewModel skip-forward collapses to 0 when duration unknown #564 (this PR's source), explicitly inviting exactly this "rebase the validated L1 diff into its own PR" approach in the closing comment. No actual duplication risk: dev's current VaultPlayerViewModel.kt still has the unfixed clamp, so this PR is the first to land it.
  • CI: JVM unit tests and QA agent both green on the latest push; no CI/workflow files touched by this diff.

Minor, non-blocking observation

onSkipBack() (a few lines below onSkipForward()) only clamps against 0 and never touches duration, so it has no analogous bug — noting only for completeness, not a finding.

No CONFIRMED findings. Small, correctly-scoped, well-tested fix — clearing for auto-merge.

@github-actions github-actions Bot added status:approved-auto-merge Principal review passed, risk:low — will auto-merge and removed status:needs-review QA passed, awaiting principal-review-agent labels Aug 25, 2026
@github-actions
github-actions Bot merged commit c70be2d into dev Aug 25, 2026
28 checks passed
libravault-xyz added a commit that referenced this pull request Aug 25, 2026
…IME_UNSET bug

Merges origin/dev through PR #573 — resolves a second modify/delete conflict
on VaultPlayerViewModel.kt (kept deleted, per this branch), which #573 had
touched to fix issue #564 (skip-forward collapsed to the start of the book
while duration was still C.TIME_UNSET).

That fix's own logic (skipForwardTarget()) duplicated an existing, already-
tested utility this branch's PlayerViewModel just never used: SeekClamp.clamp
(feature:player/service), already relied on by LibraryViewModel.seekBy and
ReaderViewModel.seekByAudiobook for exactly this C.TIME_UNSET case. Ported
#573's fix onto PlayerViewModel.skipForward()/skipBack() via SeekClamp instead
of reintroducing a second, vault-only copy of the same clamp logic — this
fixes the identical bug for the shared audiobook player screen too (both
real-file and vault audio), not just the vault-specific path #573 patched.
Deleted the now-orphaned VaultPlayerSkipForwardTargetTest.kt; SeekClampTest
already covers the same TIME_UNSET boundary case.

feature:player, feature:vault test suites green; app compiles both flavors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Principal review classified this PR as low risk status:approved-auto-merge Principal review passed, risk:low — will auto-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

L1: VaultPlayerViewModel skip-forward collapses to 0 when duration unknown

1 participant