Skip to content

Improve download recovery and feed tracking - #96

Merged
D3SOX merged 5 commits into
masterfrom
download-recovery-and-feed-tracking
Aug 5, 2026
Merged

Improve download recovery and feed tracking#96
D3SOX merged 5 commits into
masterfrom
download-recovery-and-feed-tracking

Conversation

@D3SOX

@D3SOX D3SOX commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • offer one-click retries with alternative browser modes after gated download failures
  • remove bracketed premiere prefixes during metadata cleanup
  • only save feed checkpoints after playback was initiated from a feed card

Root cause

The userscript polled SoundCloud's global player and treated any matching loaded feed card as feed-originated playback. Tracks started elsewhere could therefore overwrite a feed checkpoint.

Validation

  • 31 Bun tests passed
  • source lint passed
  • Web UI TypeScript check passed
  • userscript parse check passed
  • diff checks passed

Summary by CodeRabbit

  • New Features

    • Added retry buttons to error messages, allowing downloads to restart using available browser modes.
    • Improved metadata cleanup by removing premiere promotion tags and optional separators.
    • Updated cleanup guidance to mention premiere tags.
    • Added separate controls for resetting newer and older feed checkpoints.
  • Bug Fixes

    • Improved track detection across supported feed layouts.
    • Feed checkpoints now track playback only after explicit activation and reset correctly outside feeds.
    • Prevented unrelated playback updates from overwriting saved feed information.
    • Improved feed navigation and click handling.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The userscript now detects additional track layouts, records feed checkpoints from explicit playback origins, and provides directional resume and reset controls. The web UI expands promotional-tag cleanup and retries failed downloads with alternative browser modes.

Changes

Feed playback tracking

Layer / File(s) Summary
Track detection and URL normalization
userscript/sc-gate-dl.user.js
Track URLs now support .trackItem title links, and tags is reserved during URL normalization.
Playback-origin checkpoint tracking
userscript/sc-gate-dl.user.js, userscript/sc-gate-dl.test.ts
Playback tracking uses explicit origins and played URLs, ignores unrelated updates, clears state outside feed pages, and advances directional checkpoints.
Directional resume and reset controls
userscript/sc-gate-dl.user.js
Feed navigation uses separate newer and older resume links and reset buttons with updated click handling and styles.

Web UI workflows

Layer / File(s) Summary
Promotional-tag cleanup
webui/src/components/App.tsx, webui/src/components/App.test.ts
cleanPromoTags is exported, removes optional separators after bracketed promo tags, and has tests for premiere prefixes. The tooltip lists premiere tags.
Browser-mode download retry
webui/src/components/App.tsx
Download startup records the attempted browser mode, reports startup errors, and offers retries with other browser modes.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes to download recovery and feed tracking.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch download-recovery-and-feed-tracking

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

@D3SOX
D3SOX marked this pull request as ready for review August 5, 2026 11:18

@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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
webui/src/components/App.tsx (1)

418-439: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear the previous error before starting a retry.

When startDownload starts a retry, it updates progress but preserves job.error. If the retry succeeds, later state updates preserve the old error, so the successful download still shows the previous error banner. Set error: null in the startup state update.

Proposed fix
 			setJob((prev) => ({
 				...prev,
+				error: null,
 				progress: {
 					stage: 'handling_gates',
🤖 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 `@webui/src/components/App.tsx` around lines 418 - 439, Update the startup
setJob state update in startDownload to set error to null while resetting
progress for a retry, ensuring subsequent successful state updates do not
preserve the previous error banner.
🤖 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 `@userscript/sc-gate-dl.user.js`:
- Around line 595-603: Replace the page-wide feedPlaybackActive flag with
playback-session state tied to the feed-card playback origin. Update
recordPlayingFeedTrack and the feed-card click handling near the existing flag
assignment so unrelated global-player or queue playback clears or replaces that
state even while isFeedPage() remains true, while valid playback from the active
feed card continues recording. Add a regression test covering selection of an
unrelated track while staying on a feed route.

In `@webui/src/components/App.tsx`:
- Line 439: Update the download-start flow and retry handling in App.tsx to
persist the effective mode used by each job, using retryBrowserMode when present
and otherwise the mode passed to startDownload. Ensure the retry filter uses
this stored job mode rather than the current browserMode preference, so
asynchronous preference updates cannot hide the failed mode’s alternative.
- Around line 1035-1050: Update the failed job-start catch path near
startDownload to mark the job progress as an error/retryable state when setting
job.error, so the existing retry-button condition using job.progress?.stage ===
'error' renders for /start failures. Preserve normal handling-gates progress for
successful or non-failed flows.

---

Outside diff comments:
In `@webui/src/components/App.tsx`:
- Around line 418-439: Update the startup setJob state update in startDownload
to set error to null while resetting progress for a retry, ensuring subsequent
successful state updates do not preserve the previous error banner.
🪄 Autofix

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: b67f95ee-29bc-4328-84a2-0631b09ba184

📥 Commits

Reviewing files that changed from the base of the PR and between bd0858c and 3f83b79.

📒 Files selected for processing (3)
  • userscript/sc-gate-dl.user.js
  • webui/src/components/App.test.ts
  • webui/src/components/App.tsx

Comment thread userscript/sc-gate-dl.user.js Outdated
Comment thread webui/src/components/App.tsx Outdated
Comment thread webui/src/components/App.tsx
@D3SOX

D3SOX commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

🧹 Nitpick comments (1)
userscript/sc-gate-dl.test.ts (1)

1-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace node:fs with Bun.file.

Use await Bun.file(new URL('./sc-gate-dl.user.js', import.meta.url)).text() to load the userscript. This follows the Bun API guideline and preserves the test contract.

🤖 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 `@userscript/sc-gate-dl.test.ts` around lines 1 - 13, Replace the
readFileSync-based source loading in sc-gate-dl.test.ts with Bun.file(new
URL('./sc-gate-dl.user.js', import.meta.url)).text(), making the surrounding
test setup asynchronous as needed while preserving the existing source value and
test contract.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@userscript/sc-gate-dl.test.ts`:
- Around line 1-13: Replace the readFileSync-based source loading in
sc-gate-dl.test.ts with Bun.file(new URL('./sc-gate-dl.user.js',
import.meta.url)).text(), making the surrounding test setup asynchronous as
needed while preserving the existing source value and test contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b916b00-7e1d-43e6-a8e0-429bf79b5f46

📥 Commits

Reviewing files that changed from the base of the PR and between 3f83b79 and 12b1d89.

📒 Files selected for processing (3)
  • userscript/sc-gate-dl.test.ts
  • userscript/sc-gate-dl.user.js
  • webui/src/components/App.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • webui/src/components/App.tsx

@D3SOX
D3SOX merged commit d0dc7b1 into master Aug 5, 2026
1 check passed
@D3SOX
D3SOX deleted the download-recovery-and-feed-tracking branch August 5, 2026 12:02
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