Skip to content

Add import/export settings buttons#9123

Open
Shadorc wants to merge 19 commits into
FreeTubeApp:developmentfrom
Shadorc:feat/export-settings
Open

Add import/export settings buttons#9123
Shadorc wants to merge 19 commits into
FreeTubeApp:developmentfrom
Shadorc:feat/export-settings

Conversation

@Shadorc
Copy link
Copy Markdown
Contributor

@Shadorc Shadorc commented May 10, 2026

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

#1018 (comment)
#7345

Description

This pull request adds support for importing and exporting FreeTube settings.

Some settings are not exportable, they are represented by the settingsNotTransferrable set inside settings.js. They are OS/user-specific settings, experimental settings, and settings that depend on process.env.

I'm not entirely satisfied with having to duplicate setting keys, but the other solution that I thought of was to replace the state object values with a more complex structure, having additional fields like isExportable. However, in my opinion, it would have required too much refactoring.

Screenshots

image image image

Testing

Basic test

  1. Change some settings (a and b)
  2. Export settings
  3. Change some other settings (c and d)
  4. Import settings
  5. Check that a and b have the same values as step 2 and that changes made on c & d in steps 3 have been reverted

Non-exportable setting test

  1. Changes value of proxy settings
  2. Export settings
  3. Revert change made on step 1
  4. Import settings
  5. Check that proxy settings are the same as step 3

UI test

  1. Minimize the window to make it similar in size to a phone
  2. Go to Settings > Data
  3. Check that the title, tooltip button and import/export buttons are correctly displayed
  4. Check that the tooltip bubble is not hidden by anything

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 10, 2026 15:56
@github-actions github-actions Bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label May 10, 2026
@absidue
Copy link
Copy Markdown
Member

absidue commented May 10, 2026

absidue was warning that it could be an issue with some settings, but I didn't experience problems with the mentioned settings.

You won't see a warning, it will purposefully silently drop them because they are not meant to be writeable by the window and you won't see any issues in the same window because in the same window you are showing the stuff in-memory in that window but it won't be saved to disk, synced to other windows or actually get used.

While I don't want to discourage new contributors, could I please ask that you put a bit more thought into your pull requests or at the very least put more effort into testing them, as this is the second one that you have submitted that doesn't actually work in practice.

@absidue absidue added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels May 10, 2026
@Shadorc
Copy link
Copy Markdown
Contributor Author

Shadorc commented May 10, 2026

You're right, I'm sorry. I'm a bit too eager to contribute. I did test my changes, but I saw your warning about the folder fields a bit late, and I only tested the settings value after import rather than actually testing whether the folders were correct.
I'll put this MR as draft and see if I can fix it and test it properly. I'll either close it if I can't fix it properly or mark it as ready otherwise.
Sorry for wasting your time, I know that's not cool!

@Shadorc Shadorc marked this pull request as draft May 10, 2026 18:09
auto-merge was automatically disabled May 10, 2026 18:09

Pull request was converted to draft

@Shadorc
Copy link
Copy Markdown
Contributor Author

Shadorc commented May 10, 2026

Maybe folder paths should not be allowed to be imported, does it really make sense? It is user and OS dependent, in most case the imported path would be invalid.
It could be an exception, with a little help icon indicating which settings (corresponding to paths) would not be part of the export / import process
What do you think?

@PikachuEXE
Copy link
Copy Markdown
Member

What probably should not be transferred:

@Shadorc
Copy link
Copy Markdown
Contributor Author

Shadorc commented May 11, 2026

I checked all the settings, I think that settings impacted by env like process.env.SUPPORTS_LOCAL_API and process.env.IS_ELECTRON should also be ignored. A custom logic for those settings could be implemented during import, but it's probably safer to not export them and it only concern one settings currently (if we consider that screenshotAskPath would be not exported anyway because it is a path).

Concerning passwords, they are not encrypted, so exporting them as plain text would not be an issue. As for whether this is relevant, I’d tend to say yes, but it could be changed if needed.

There are also settings that need the app to be restarted. I've made the implementation similar to the list of non-exportable settings for the declaration, and when they are imported, the user is prompted to restart the app or to revert the settings that needed a restart. It works but I will see if I find something more "elegant"

@Shadorc Shadorc marked this pull request as ready for review May 15, 2026 21:51
@github-actions github-actions Bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label May 15, 2026
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 15, 2026 21:52
@Shadorc
Copy link
Copy Markdown
Contributor Author

Shadorc commented May 15, 2026

I'm now satisfied with the state of this MR!
I have updated my initial MR description accordingly.
I have also written and tested all the test cases that I could think of, they all pass.

auto-merge was automatically disabled May 15, 2026 21:54

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 15, 2026 21:54
auto-merge was automatically disabled May 15, 2026 22:01

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 15, 2026 22:02
return
}

if (process.env.IS_ELECTRON) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this mean the prompt is shown for web build (even though not officially supported) and will do nothing?

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Shadorc The difference is that in the other places it will never even get to that code, the electron check is just there to ensure that the electron only code gets removed properly during the build (as deadcode removal isn't guaranteed with Vue in the mix) and makes it clearer to people reading the code that it is electron only.

E.g. for the smooth scrolling switch is not shown outside of electron: https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/components/ThemeSettings.vue#L20 and the entire experimental settings component is Electron only: https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/views/Settings/Settings.vue#L174-L181

So you can either make the entire settings import and export feature electron only or write it in a way that also has a non-Electron restart and flexible enough that an Android specific restart could be added in downstream FreeTubeAndroid.

Copy link
Copy Markdown
Contributor Author

@Shadorc Shadorc May 18, 2026

Choose a reason for hiding this comment

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

Thanks for the clarification.
I had searched for settings depending on the IS_ELECTRON env var, but I missed disableSmoothScrolling and hideToTrayOnMinimize.

Concerning your suggestions, I see one more option.
Instead of making the entire feature electron-only, all electron-only settings could be marked as not transferrable.

It would not remove a lot of settings because, according to my searches, here are the settings depending on process.env:

/* Depends on process.env.IS_ELECTRON */
// ProxySettings
'useProxy',
'proxyProtocol',
'proxyHostname',
'proxyPort',
'proxyUsername',
'proxyPassword',
// ExternalPlayerSettings
'externalPlayer',
'externalPlayerExecutable',
'externalPlayerIgnoreWarnings',
'externalPlayerIgnoreDefaultArgs',
'externalPlayerCustomArgs',
'showAddedExternalPlayerCustomArgs',
// Others
'disableSmoothScrolling',
'hideToTrayOnMinimize',
'screenshotAskPath',
'screenshotFolderPath',

/* Depends on process.env.SUPPORTS_LOCAL_API */
'backendFallback',
'backendPreference',
'proxyVideos',

If we remove settings mentioned here, we get:

  /* Depends on process.env.IS_ELECTRON */
  // Others
  'disableSmoothScrolling',
  'hideToTrayOnMinimize',

  /* Depends on process.env.SUPPORTS_LOCAL_API */
  'backendFallback',
  'backendPreference',
  'proxyVideos',

The last three depend on process.env.SUPPORTS_LOCAL_API, they should probably not be transferrable.
hideToTrayOnMinimize is OS-specific because it is not available on macOS.
The remaining one is disableSmoothScrolling.

So, making the whole feature electron-only would only be useful to support the smooth scrolling feature but would prevent users from importing and exporting settings on mobile.
It could still be possible to later implement your idea of having a flexible way to restart the app, no matter if it's electron or not, and add the missing support for disableSmoothScrolling.

I will update my MR to change the settingsNotExportable with all the settings mentioned above.
Let me know what you think, I've tried to imagine the best scenario for users, code maintainability and complexity.

Comment thread src/renderer/components/DataSettings/DataSettings.vue
Comment thread src/renderer/store/modules/settings.js Outdated
Comment thread src/renderer/components/DataSettings/DataSettings.vue Outdated
auto-merge was automatically disabled May 18, 2026 11:49

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 18, 2026 11:49
auto-merge was automatically disabled May 18, 2026 14:38

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 18, 2026 14:38
@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc removed the PR: waiting for review For PRs that are complete, tested, and ready for review label May 18, 2026
@Shadorc Shadorc marked this pull request as draft May 18, 2026 16:14
auto-merge was automatically disabled May 18, 2026 16:14

Pull request was converted to draft

@Shadorc Shadorc marked this pull request as ready for review May 18, 2026 21:18
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 18, 2026 21:18
@github-actions github-actions Bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label May 18, 2026
@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc removed the PR: waiting for review For PRs that are complete, tested, and ready for review label May 19, 2026
auto-merge was automatically disabled May 19, 2026 18:09

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 19, 2026 18:09
auto-merge was automatically disabled May 19, 2026 19:09

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 19, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants