Skip to content

Commit afc205a

Browse files
fix(profile): reject digit-leading names; pass --profile to autostart
Digit-leading profiles (e.g. '1work') pass the alphanumeric check but produce invalid D-Bus well-known-name elements on Linux, preventing single-instance registration and startup. Fix: require the first char to be a letter (is_ascii_alphabetic). Autostart did not preserve the selected profile: the OS login item was registered without arguments, so every relaunch resolved to 'default'. Fix: pass ['--profile', name] to tauri_plugin_autostart::init when the active profile is not 'default'. Addresses Greptile P1 findings on PR #241.
1 parent b962356 commit afc205a

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎src-tauri/src/lib.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,13 @@ pub fn run() {
937937
.plugin(tauri_plugin_dialog::init())
938938
.plugin(tauri_plugin_autostart::init(
939939
MacosLauncher::AppleScript,
940-
Some(vec![]),
940+
// Pass --profile so the OS login item relaunches the selected
941+
// profile, not always `default`.
942+
if profile::is_default(&cli_args.profile) {
943+
Some(vec![])
944+
} else {
945+
Some(vec!["--profile", cli_args.profile.as_str()])
946+
},
941947
))
942948
.plugin(single_instance_plugin(&cli_args.profile))
943949
// Serve the module-alert HTML with a valid Origin for the webview.

‎src-tauri/src/profile.rs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ pub fn validate_profile(name: &str) -> Result<(), String> {
2929
));
3030
}
3131
let first = name.chars().next().unwrap();
32-
if !first.is_ascii_alphanumeric() {
32+
if !first.is_ascii_alphabetic() {
3333
return Err(format!(
34-
"profile name must start with a letter or digit, got '{first}'"
34+
"profile name must start with a letter, got '{first}'"
3535
));
3636
}
3737
for c in name.chars() {
@@ -160,7 +160,14 @@ mod tests {
160160
validate_profile("Research").is_err(),
161161
"uppercase should be rejected"
162162
);
163-
assert!(validate_profile("-bad").is_err(), "must start with alnum");
163+
assert!(
164+
validate_profile("-bad").is_err(),
165+
"must start with a letter"
166+
);
167+
assert!(
168+
validate_profile("1work").is_err(),
169+
"digit-leading profiles produce invalid D-Bus names"
170+
);
164171
assert!(validate_profile("bad name").is_err(), "spaces not allowed");
165172
assert!(
166173
validate_profile("a/b").is_err(),

0 commit comments

Comments
 (0)