Skip to content

Conversation

@nicoschmdt
Copy link
Contributor

@nicoschmdt nicoschmdt commented Nov 6, 2025

fix: #3642, fix: #3284

Had to change the folder download logic to know when the download operation has finished to disable/enable the buttons.

For some reason the size of the loaded file presented to the user in the UI is sometimes smaller than the resulting size of the compressed file. From what I understood, this is related to axios compressing the files on the go; thus it can not inform the total size during the operation

Summary by Sourcery

Refactor the settings menu’s log download flow to use a new FolderManager and axios-based downloads with progress tracking, add a reusable ProgressInformation component for UI feedback, and prevent concurrent operations by disabling buttons while activities are in progress.

New Features:

  • Implement file download over axios with progress events in filebrowser, replacing the previous window.open approach
  • Introduce FolderManager utility to orchestrate folder downloads with progress tracking
  • Add ProgressInformation Vue component to display real-time download and deletion progress

Enhancements:

  • Refactor SettingsMenu to integrate FolderManager and ProgressInformation and disable download/remove buttons during active operations

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 6, 2025

Reviewer's Guide

Refactored the log download flow by replacing direct filebrowser calls with a new FolderManager that streams downloads via axios, added a reusable ProgressInformation component for both download and deletion progress, and updated the SettingsMenu to use these abstractions and disable controls during operations.

Sequence diagram for log download flow with FolderManager

sequenceDiagram
  actor User
  participant SettingsMenu
  participant FolderManager
  participant filebrowser
  participant back_axios
  participant ProgressInformation

  User->>SettingsMenu: Clicks 'Download log files'
  SettingsMenu->>FolderManager: downloadFolder('system_logs')
  FolderManager->>filebrowser: fetchFolder('system_logs')
  filebrowser-->>FolderManager: returns folder
  FolderManager->>filebrowser: downloadFolder(folder, progressHandler)
  filebrowser->>back_axios: GET /raw/{folder.path}/?algo=zip
  back_axios-->>filebrowser: Streams download progress
  filebrowser-->>FolderManager: Calls progressHandler(event)
  FolderManager->>ProgressInformation: Updates progress props
  FolderManager-->>SettingsMenu: Operation complete
  SettingsMenu->>ProgressInformation: Show completion
Loading

Class diagram for new FolderManager and ProgressInformation components

classDiagram
  class FolderManager {
    +downloadedBytes: number
    +totalBytes: number
    +startTime: number
    +downloadSpeed: number
    +inProgress: boolean
    +downloadFolder(logs: string): Promise<void>
    +resetDownloadVariables(): void
  }

  class ProgressInformation {
    +type: string
    +operation: string
    +currentSize: number
    +totalSize: number
    +downloadSpeed: number
    +currentPath: string
    +status: string
    +formatSize(kb_bytes: number): string
  }

  SettingsMenu --> FolderManager : uses
  SettingsMenu --> ProgressInformation : uses
Loading

File-Level Changes

Change Details Files
Overhauled download implementation to support progress tracking
  • Added progressHandler parameter to filebrowser.downloadFolder
  • Replaced window.open with axios GET requests and Blob creation
  • Emitted success and error notifications after download
core/frontend/src/libs/filebrowser.ts
Created FolderManager to manage download state
  • Implemented inProgress flag, byte counters, and download speed calculation
  • Wrapped filebrowser.downloadFolder with progress callbacks
  • Reset progress variables on completion
core/frontend/src/utils/folder_manager.ts
Introduced ProgressInformation component for UI feedback
  • New Vue component rendering progress bars and metadata
  • Handles both 'download' and 'deletion' display modes
  • Formats sizes and speeds using helper functions
core/frontend/src/components/common/ProgressInformation.vue
Refactored SettingsMenu to use FolderManager and ProgressInformation
  • Imported and instantiated system and mavlink FolderManager instances
  • Disabled buttons based on inProgress flags
  • Replaced manual progress UI blocks with ProgressInformation usage
  • Updated download methods to call FolderManager.downloadFolder
core/frontend/src/components/app/SettingsMenu.vue

Assessment against linked issues

Issue Objective Addressed Explanation
#3642 Prevent the user from clicking the 'Download' button while files are being deleted.

Possibly linked issues

  • #User can click 'Download' while files are being deleted: PR disables download and delete buttons during ongoing operations, preventing the simultaneous actions described in the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Remove the debug console.log statements from FolderManager once the progress logic is verified so the console isn’t cluttered in production.
  • Instead of showing the progress bar as always indeterminate, consider switching to a determinate mode that uses currentSize/totalSize to display actual download percentage.
  • Unify the async style in filebrowser.downloadFolder by using try/catch around await rather than mixing await with .then/.catch for clearer error handling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Remove the debug console.log statements from FolderManager once the progress logic is verified so the console isn’t cluttered in production.
- Instead of showing the progress bar as always indeterminate, consider switching to a determinate mode that uses currentSize/totalSize to display actual download percentage.
- Unify the async style in filebrowser.downloadFolder by using try/catch around await rather than mixing await with .then/.catch for clearer error handling.

## Individual Comments

### Comment 1
<location> `core/frontend/src/libs/filebrowser.ts:179-183` </location>
<code_context>
+      onDownloadProgress: progressHandler,
+    })
+    .then((response) => {
+      const blob = new Blob([response.data], { type: 'application/zip' })
+      const blobURL = window.URL.createObjectURL(blob)
+      const a = document.createElement('a')
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Missing responseType configuration for binary data.

Set 'responseType: "blob"' in the axios request to prevent data corruption when handling binary downloads.

```suggestion
    await back_axios({
      method: 'get',
      url: url,
      responseType: 'blob',
      onDownloadProgress: progressHandler,
    })
```
</issue_to_address>

### Comment 2
<location> `core/frontend/src/components/common/ProgressInformation.vue:18` </location>
<code_context>
+        Total: {{ formatSize(totalSize / 1024) }}
+      </div>
+      <div class="text-caption">
+        Speed: {{ formatSize(downloadSpeed / 1024) }}/ms
+      </div>
+    </div>
</code_context>

<issue_to_address>
**nitpick:** Unit for download speed is likely incorrect.

Use 'KB/s' or 'MB/s' instead of 'KB/ms' to improve clarity and align with standard conventions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@joaoantoniocardoso
Copy link
Member

thus it can not inform the total size during the operation

I don't think that's a problem. I think the original idea for that size was the disk usage size, not the compressed download size

Copy link
Member

@joaoantoniocardoso joaoantoniocardoso left a comment

Choose a reason for hiding this comment

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

The browser doesn't show me the zip file after I wait for the download preparation:

cant_download_logs.mp4

@nicoschmdt nicoschmdt force-pushed the fix-logs-download-deletion branch 2 times, most recently from cf35665 to beb8990 Compare November 6, 2025 19:59
@nicoschmdt nicoschmdt force-pushed the fix-logs-download-deletion branch from beb8990 to 5e9984d Compare November 10, 2025 16:51
@joaoantoniocardoso
Copy link
Member

Hmm, two things here:

  1. The numbers on Chrome seem too hectic:
download_chrome_hectic_numbers.mp4

  1. I can't make it work on Firefox:
firefox_buggy_download_maybe_permission_issue.mp4
image image

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.

User can click "Download" while files are being deleted bug: User can delete system logs after triggering download

2 participants