Fix for always downloading to default directory with firefox extension#319
Merged
SuperCoolPencil merged 3 commits intoSurgeDM:mainfrom Apr 4, 2026
Merged
Fix for always downloading to default directory with firefox extension#319SuperCoolPencil merged 3 commits intoSurgeDM:mainfrom
SuperCoolPencil merged 3 commits intoSurgeDM:mainfrom
Conversation
Pass directory information to pendingDuplicates and sendToSurge
Fix for always downloading to default directory with firefox extension
Comment on lines
728
to
738
| @@ -734,7 +734,7 @@ async function handleDownloadIntercept(downloadItem) { | |||
| const result = await sendToSurge( | |||
| downloadItem.url, | |||
| filename, | |||
| '' | |||
| directory | |||
| ); | |||
Contributor
There was a problem hiding this comment.
No tests included for this bug fix
This patch corrects a silent data-loss bug (downloads ignoring the user-selected directory), but ships without any automated tests. Consider adding coverage for:
extractPathInfowith a Windows path (e.g.C:/Users/foo/Downloads/file.zip) returns{ directory: 'C:/Users/foo/Downloads', filename: 'file.zip' }extractPathInfowith a POSIX path returns the correct splithandleDownloadInterceptpasses a non-emptydirectorytosendToSurge(integration)- Edge case:
downloadItem.filenameis empty — both fields default to''
Rule Used: What: All code changes must include tests for edge... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: extension-firefox/background.js
Line: 728-738
Comment:
**No tests included for this bug fix**
This patch corrects a silent data-loss bug (downloads ignoring the user-selected directory), but ships without any automated tests. Consider adding coverage for:
- `extractPathInfo` with a Windows path (e.g. `C:/Users/foo/Downloads/file.zip`) returns `{ directory: 'C:/Users/foo/Downloads', filename: 'file.zip' }`
- `extractPathInfo` with a POSIX path returns the correct split
- `handleDownloadIntercept` passes a non-empty `directory` to `sendToSurge` (integration)
- Edge case: `downloadItem.filename` is empty — both fields default to `''`
**Rule Used:** What: All code changes must include tests for edge... ([source](https://app.greptile.com/review/custom-context?memory=2b22782d-3452-4d55-b059-e631b2540ce8))
How can I resolve this? If you propose a fix, please make it concise.Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Contributor
Author
|
This is meant as a quick fix for #302 |
SuperCoolPencil
approved these changes
Apr 4, 2026
Member
SuperCoolPencil
left a comment
There was a problem hiding this comment.
Thank you so much for contributing :)
SuperCoolPencil
added a commit
that referenced
this pull request
Apr 6, 2026
- Fix directory bug from PR #319: directory is now extracted and forwarded in both normal and duplicate download paths - sendToSurge now correctly takes 4 args (url, filename, directory, headers) instead of the broken 3-arg signature that passed captured headers as the directory argument - Extract inline confirmDuplicate/skipDuplicate logic into named functions - Use explicit types (PendingDup interface) instead of inline tuples - Remove unused _healthCheckTimer/_syncIntervalTimer variables - Simplify getBaseUrl: drop the redundant cachedPort branch, just scan - Add proper directory storage to pendingDuplicates for the duplicate confirmation flow - Consistent formatting: one function per clear purpose Co-Authored-By: Claude Opus 4.6 <[email protected]>
SuperCoolPencil
added a commit
that referenced
this pull request
Apr 6, 2026
- Fix directory bug from PR #319: directory is now extracted and forwarded in both normal and duplicate download paths - sendToSurge now correctly takes 4 args (url, filename, directory, headers) instead of the broken 3-arg signature that passed captured headers as the directory argument - Extract inline confirmDuplicate/skipDuplicate logic into named functions - Use explicit types (PendingDup interface) instead of inline tuples - Remove unused _healthCheckTimer/_syncIntervalTimer variables - Simplify getBaseUrl: drop the redundant cachedPort branch, just scan - Add proper directory storage to pendingDuplicates for the duplicate confirmation flow - Consistent formatting: one function per clear purpose Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pass non-empty directory information to
pendingDuplicates()andsendToSurge()Greptile Summary
This PR fixes a silent bug where the Firefox extension always sent an empty directory string to Surge, causing every download to land in Surge's default directory instead of the user-selected location.
The fix is minimal and correct:
handleDownloadInterceptalready calledextractPathInfoto parsedownloadItem.filenameinto{ filename, directory }, but the extracteddirectorywas discarded in both the duplicate-confirmation path (directory: ''hardcoded inpendingDuplicates.set) and the normal download path (onlyfilenamewas destructured before callingsendToSurge). Both call-sites now properly forward the extracteddirectory.extractPathInfocorrectly handles Windows (C:/…) and POSIX (/…) absolute paths and is unchanged.sendToSurgealready guards the path field withif (absolutePath), so downloads with no directory information still fall back to Surge's default — no regression risk.confirmDuplicatemessage case) also readspending.directorywhen callingsendToSurge, so it too now benefits from the correct stored value.Confidence Score: 5/5
Safe to merge — targeted two-line fix with no regression risk
The change is minimal and precisely correct: it stops discarding the already-extracted directory in two call-sites. The guard in sendToSurge (if absolutePath) preserves fallback behaviour when no directory is present. No new logic is introduced and no existing behaviour is broken.
No files require special attention
Important Files Changed
Sequence Diagram
sequenceDiagram participant Browser participant handleDownloadIntercept participant extractPathInfo participant Target as sendToSurge / pendingDuplicates Browser->>handleDownloadIntercept: onCreated(downloadItem) alt duplicate detected handleDownloadIntercept->>extractPathInfo: extractPathInfo(downloadItem) extractPathInfo-->>handleDownloadIntercept: { filename, directory } handleDownloadIntercept->>Target: pendingDuplicates.set(id, { filename, directory, … }) Note over Target: Previously directory was hardcoded '' else surge running handleDownloadIntercept->>extractPathInfo: extractPathInfo(downloadItem) extractPathInfo-->>handleDownloadIntercept: { filename, directory } handleDownloadIntercept->>Target: sendToSurge(url, filename, directory) Note over Target: Previously directory was hardcoded '' Target-->>handleDownloadIntercept: { success } endGreploops — Automatically fix all review issues by running
/greploopsin Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.
Reviews (2): Last reviewed commit: "shorthand for directory path" | Re-trigger Greptile