Skip to content

refactor(cli): simplify features: Option<Vec<String>> to Vec<String>#14607

Merged
Legend-Master merged 8 commits intotauri-apps:devfrom
sftse:none-empty
Dec 29, 2025
Merged

refactor(cli): simplify features: Option<Vec<String>> to Vec<String>#14607
Legend-Master merged 8 commits intotauri-apps:devfrom
sftse:none-empty

Conversation

@sftse
Copy link
Copy Markdown
Contributor

@sftse sftse commented Dec 4, 2025

Noticed a code pattern where None is used in place of an empty vector. The resulting code has to transform between different representations and liberally uses get_or_insert on the None. This is a bit roundabout, so use empty Vec as a replacement for None.

Empty Vecs don't allocate, so this changes nothing except make the code shorter.

Not entirely sure, but also think this fixes a bug where the code paths of None and Some(Vec::new()) would have diverged.

@sftse sftse requested a review from a team as a code owner December 4, 2025 13:53
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Dec 4, 2025
Comment on lines +181 to +190
fn is_empty(v: &[String]) -> bool {
v.is_empty()
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CliOptions {
pub dev: bool,
pub features: Option<Vec<String>>,
#[serde(default)]
#[serde(skip_serializing_if = "is_empty")]
pub features: Vec<String>,
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.

This Serialize and Deserialize impl is the only publically visible way the change of internal fields might be observable. This uses serde configuration so serialization strings remain identical.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is also different from before, it used to be something like "features": null in JSON

Since I'm not the most familiar with where is this used, I'll leave it to @FabianLars @lucasfernog

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.

Think I checked this (not at workstation rn) and only used internally, will get back to you.

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.

Made a commit highlighting where serialization is used. This seems purely internal, so going with the simpler serialization.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unresolved this so we get to see this more obviously if anyone ever get back to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 4, 2025

Package Changes Through e68c805

There are 6 changes which include tauri-utils with patch, tauri-build with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-runtime-wry with patch, tauri with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.1 2.8.2
tauri-bundler 2.7.5 2.7.6
tauri-runtime 2.9.2 2.9.3
tauri-runtime-wry 2.9.3 2.9.4
tauri-codegen 2.5.2 2.5.3
tauri-macros 2.5.2 2.5.3
tauri-plugin 2.5.2 2.5.3
tauri-build 2.5.3 2.5.4
tauri 2.9.5 2.9.6
@tauri-apps/cli 2.9.6 2.9.7
tauri-cli 2.9.6 2.9.7

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@sftse
Copy link
Copy Markdown
Contributor Author

sftse commented Dec 5, 2025

@FabianLars
Fixed CI

@sftse
Copy link
Copy Markdown
Contributor Author

sftse commented Dec 5, 2025

I'm a bit confused by how the change sets work, the bot suggested

---
"@tauri-apps/api": patch
"tauri-utils": patch
"tauri-macos-sign": patch
"tauri-bundler": patch
"tauri-runtime": patch
"tauri-runtime-wry": patch
"tauri-codegen": patch
"tauri-macros": patch
"tauri-plugin": patch
"tauri-build": patch
"tauri": patch
"@tauri-apps/cli": patch
"tauri-cli": patch
"tauri-driver": patch
---

even though only tauri-cli has any changes. Is this correct?

@FabianLars
Copy link
Copy Markdown
Member

no the bot just lists all existing packages. just remove all that you didn't touch (eg in your case only tauri-cli needs to be there)

Legend-Master
Legend-Master previously approved these changes Dec 6, 2025
Copy link
Copy Markdown
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

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

Thanks

Comment on lines +181 to +190
fn is_empty(v: &[String]) -> bool {
v.is_empty()
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CliOptions {
pub dev: bool,
pub features: Option<Vec<String>>,
#[serde(default)]
#[serde(skip_serializing_if = "is_empty")]
pub features: Vec<String>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is also different from before, it used to be something like "features": null in JSON

Since I'm not the most familiar with where is this used, I'll leave it to @FabianLars @lucasfernog

@sftse
Copy link
Copy Markdown
Contributor Author

sftse commented Dec 28, 2025

RFR

Legend-Master
Legend-Master previously approved these changes Dec 28, 2025
Legend-Master
Legend-Master previously approved these changes Dec 29, 2025
Copy link
Copy Markdown
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

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

Thanks

@Legend-Master Legend-Master changed the title None empty refactor(cli): simplify features: Option<Vec<String>> to Vec<String> Dec 29, 2025
@Legend-Master Legend-Master merged commit a2abe2e into tauri-apps:dev Dec 29, 2025
18 of 19 checks passed
@github-project-automation github-project-automation bot moved this from 📬Proposal to 🔎 In audit in Roadmap Dec 29, 2025
@sftse sftse deleted the none-empty branch December 29, 2025 16:36
sftse added a commit to sftse/tauri that referenced this pull request Dec 29, 2025
sftse added a commit to sftse/tauri that referenced this pull request Dec 29, 2025
sftse added a commit to sftse/tauri that referenced this pull request Dec 29, 2025
Legend-Master added a commit that referenced this pull request Jan 17, 2026
* refactor(tauri-cli): introduce replacement functions

* refactor(tauri-cli): apply replacement to remove.rs

* refactor(tauri-cli): apply replacement to icon.rs

* refactor(tauri-cli): apply replacement to bundle.rs

* refactor(tauri-cli): apply replacement to build.rs

* refactor(tauri-cli): apply replacement to add.rs

* refactor(tauri-cli): apply replacement to dev.rs

* refactor(tauri-cli): less controlflow

* refactor(tauri-cli): split config loading from locking static

* refactor(tauri-cli): remove duplicate checks covered by if let Some(tauri_dir) = tauri_dir

tauri_dir.is_some() must be true, otherwise the entire block is not run, so the frontend_dir check
is irrelevant

* fmt

* refactor(tauri-cli): apply replacement to inspect.rs

* refactor(tauri-cli): dont use statics for config

* refactor(tauri-cli): finish threading directory paths through functions

* fix: clippy

* fixup CI

* refactor(tauri-cli): dont need mutex

* refactor(tauri-cli): rescope mutex use to minimal necessary

* fix CI, reduce mutex use

* fixup PR #14607

* fix: clippy

* refactor(tauri-cli): remove ConfigHandle

* refactor(tauri-cli): remove more unwraps and panicing functions

* refactor(tauri-cli): less mutexes

* refactor(tauri-cli): undo mistaken change, address review comment

* Split android build to 2 functions

* Pass in dirs to migration v1 like the v2 beta

* Add change file

---------

Co-authored-by: Tony <legendmastertony@gmail.com>
iamxiaojianzheng pushed a commit to iamxiaojianzheng/tauri that referenced this pull request Jan 26, 2026
* refactor(tauri-cli): introduce replacement functions

* refactor(tauri-cli): apply replacement to remove.rs

* refactor(tauri-cli): apply replacement to icon.rs

* refactor(tauri-cli): apply replacement to bundle.rs

* refactor(tauri-cli): apply replacement to build.rs

* refactor(tauri-cli): apply replacement to add.rs

* refactor(tauri-cli): apply replacement to dev.rs

* refactor(tauri-cli): less controlflow

* refactor(tauri-cli): split config loading from locking static

* refactor(tauri-cli): remove duplicate checks covered by if let Some(tauri_dir) = tauri_dir

tauri_dir.is_some() must be true, otherwise the entire block is not run, so the frontend_dir check
is irrelevant

* fmt

* refactor(tauri-cli): apply replacement to inspect.rs

* refactor(tauri-cli): dont use statics for config

* refactor(tauri-cli): finish threading directory paths through functions

* fix: clippy

* fixup CI

* refactor(tauri-cli): dont need mutex

* refactor(tauri-cli): rescope mutex use to minimal necessary

* fix CI, reduce mutex use

* fixup PR tauri-apps#14607

* fix: clippy

* refactor(tauri-cli): remove ConfigHandle

* refactor(tauri-cli): remove more unwraps and panicing functions

* refactor(tauri-cli): less mutexes

* refactor(tauri-cli): undo mistaken change, address review comment

* Split android build to 2 functions

* Pass in dirs to migration v1 like the v2 beta

* Add change file

---------

Co-authored-by: Tony <legendmastertony@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 In audit

Development

Successfully merging this pull request may close these issues.

3 participants