From 4773be702acebcbb24d47fcec9e6e4ccd6a4f604 Mon Sep 17 00:00:00 2001 From: Hare Date: Sat, 30 May 2026 03:20:34 +0900 Subject: [PATCH] fix: remove profile aliases --- crates/manifest/src/paths.rs | 2 +- crates/manifest/src/profile.rs | 120 +-------------------------------- crates/tui/src/spawn.rs | 6 +- docs/manifest-profiles.md | 5 +- 4 files changed, 7 insertions(+), 126 deletions(-) diff --git a/crates/manifest/src/paths.rs b/crates/manifest/src/paths.rs index 3126fa10..ed3a23ef 100644 --- a/crates/manifest/src/paths.rs +++ b/crates/manifest/src/paths.rs @@ -112,7 +112,7 @@ pub fn user_manifest_path_with_env_override() -> Option { user_manifest_path_from_env(std::env::var_os(USER_MANIFEST_ENV)).or_else(user_manifest_path) } -/// `/profiles.toml` — user profile registry/default/alias configuration. +/// `/profiles.toml` — user profile registry/default configuration. /// /// This is application/profile selection configuration, not a Pod manifest /// layer. It deliberately ignores [`USER_MANIFEST_ENV`]. diff --git a/crates/manifest/src/profile.rs b/crates/manifest/src/profile.rs index e47aa184..6886031a 100644 --- a/crates/manifest/src/profile.rs +++ b/crates/manifest/src/profile.rs @@ -153,13 +153,12 @@ impl ProfileRegistryEntry { } /// Discovered profile registry. User/project `profiles.toml` files contribute -/// only profile discovery metadata (entries, aliases, defaults); those files are +/// only profile discovery metadata (entries and defaults); those files are /// application/project UX configuration, not Pod runtime manifests and are not /// merged into the selected profile's runtime manifest. #[derive(Debug, Clone, Default)] pub struct ProfileRegistry { entries: Vec, - aliases: Vec, default: Option, } @@ -194,25 +193,6 @@ impl ProfileRegistry { source: Option, name: &str, ) -> Result<&ProfileRegistryEntry, ProfileError> { - let alias_matches: Vec<_> = self - .aliases - .iter() - .filter(|alias| alias.name == name && source.is_none_or(|s| s == alias.source)) - .collect(); - match alias_matches.as_slice() { - [alias] => return self.select_named(alias.target_source, &alias.target_name), - [] => {} - _ => { - return Err(ProfileError::AmbiguousProfileName { - name: name.to_string(), - matches: alias_matches - .iter() - .map(|alias| format!("{}:{}", alias.source, alias.name)) - .collect(), - }); - } - } - let matches: Vec<_> = self .entries .iter() @@ -237,10 +217,6 @@ impl ProfileRegistry { self.entries.push(entry); } - fn push_alias(&mut self, alias: ProfileAlias) { - self.aliases.push(alias); - } - fn set_default(&mut self, default: ProfileDefault) { self.default = Some(default); } @@ -260,14 +236,6 @@ impl ProfileRegistry { } } -#[derive(Debug, Clone, PartialEq, Eq)] -struct ProfileAlias { - source: ProfileRegistrySource, - name: String, - target_source: Option, - target_name: String, -} - #[derive(Debug, Clone, PartialEq, Eq)] struct ProfileDefault { source: Option, @@ -520,8 +488,6 @@ struct ProfileRegistryDocument { default: Option, #[serde(default, alias = "entries")] profile: BTreeMap, - #[serde(default, alias = "aliases")] - alias: BTreeMap, } #[derive(Debug, Deserialize)] @@ -574,16 +540,6 @@ fn load_profile_registry_file( }); } - for (name, target) in config.alias { - let (target_source, target_name) = parse_profile_ref(&target); - registry.push_alias(ProfileAlias { - source, - name, - target_source: target_source.or(Some(source)), - target_name, - }); - } - if let Some(default) = config.default { let (default_source, default_name) = parse_profile_ref(&default); registry.set_default(ProfileDefault { @@ -1109,49 +1065,7 @@ description = "Project coder" } #[test] - fn config_alias_unqualified_target_resolves_within_declaring_source() { - let tmp = TempDir::new().unwrap(); - let user_config = tmp.path().join("profiles.toml"); - let project_dir = tmp.path().join("project/.insomnia"); - std::fs::create_dir_all(&project_dir).unwrap(); - let project_config = project_dir.join("profiles.toml"); - std::fs::write( - &user_config, - r#" -[profile] -coder = "profiles/user-coder.nix" -"#, - ) - .unwrap(); - std::fs::write( - &project_config, - r#" -[profile] -coder = "profiles/project-coder.nix" -[alias] -default-coder = "coder" -"#, - ) - .unwrap(); - - let registry = - ProfileDiscovery::with_sources(None, Some(user_config), Some(project_config)) - .discover() - .unwrap(); - let selected = registry - .select(&ProfileSelector::source_named( - ProfileRegistrySource::Project, - "default-coder", - )) - .unwrap(); - - assert_eq!(selected.source, ProfileRegistrySource::Project); - assert_eq!(selected.name, "coder"); - assert!(selected.path.ends_with("profiles/project-coder.nix")); - } - - #[test] - fn config_default_alias_marks_resolved_default_entry() { + fn default_marks_direct_profile_entry() { let tmp = TempDir::new().unwrap(); let project_dir = tmp.path().join("project/.insomnia"); std::fs::create_dir_all(&project_dir).unwrap(); @@ -1159,11 +1073,9 @@ default-coder = "coder" std::fs::write( &project_config, r#" -default = "work" +default = "coder" [profile] coder = "profiles/coder.nix" -[alias] -work = "coder" "#, ) .unwrap(); @@ -1215,30 +1127,4 @@ work = "coder" .unwrap(); assert_eq!(selected.path, PathBuf::from("/project/coder.nix")); } - - #[test] - fn aliases_resolve_within_their_source() { - let mut registry = ProfileRegistry::default(); - registry.push_entry(ProfileRegistryEntry { - source: ProfileRegistrySource::Project, - name: "coder".to_string(), - path: PathBuf::from("/project/coder.nix"), - description: None, - is_default: false, - }); - registry.push_alias(ProfileAlias { - source: ProfileRegistrySource::Project, - name: "default-coder".to_string(), - target_source: Some(ProfileRegistrySource::Project), - target_name: "coder".to_string(), - }); - - let selected = registry - .select(&ProfileSelector::source_named( - ProfileRegistrySource::Project, - "default-coder", - )) - .unwrap(); - assert_eq!(selected.name, "coder"); - } } diff --git a/crates/tui/src/spawn.rs b/crates/tui/src/spawn.rs index ca8b1b3f..9d70df26 100644 --- a/crates/tui/src/spawn.rs +++ b/crates/tui/src/spawn.rs @@ -901,7 +901,7 @@ permission = "write" } #[test] - fn profile_choices_use_project_registry_default_alias() { + fn profile_choices_use_project_registry_default() { let temp = tempfile::tempdir().unwrap(); let project = temp.path().join("project"); let insomnia = project.join(".insomnia"); @@ -909,11 +909,9 @@ permission = "write" std::fs::write( insomnia.join("profiles.toml"), r#" -default = "work" +default = "coder" [profile] coder = "profiles/coder.nix" -[alias] -work = "coder" "#, ) .unwrap(); diff --git a/docs/manifest-profiles.md b/docs/manifest-profiles.md index be70b0ff..74bbc692 100644 --- a/docs/manifest-profiles.md +++ b/docs/manifest-profiles.md @@ -51,9 +51,6 @@ default = "coder" [profile] coder = "profiles/coder.nix" reviewer = "profiles/reviewer.nix" - -[alias] -work = "project:coder" ``` Table entries can carry descriptions: @@ -64,7 +61,7 @@ path = "profiles/coder.nix" description = "Project coding assistant" ``` -Relative registry paths are resolved against the `profiles.toml` file that declares them. Discovery checks bundled builtin profiles, then the user registry at `/profiles.toml`, then the nearest project registry at `.insomnia/profiles.toml`. Later defaults override earlier defaults, so a project default wins over a user default. Unqualified alias/default targets resolve within the declaring source by default. Unqualified ambiguous names fail closed: +Relative registry paths are resolved against the `profiles.toml` file that declares them. Discovery checks bundled builtin profiles, then the user registry at `/profiles.toml`, then the nearest project registry at `.insomnia/profiles.toml`. Later defaults override earlier defaults, so a project default wins over a user default. Unqualified defaults resolve within the declaring source by default. Unqualified ambiguous names fail closed: ```sh insomnia --profile coder # fails if both user:coder and project:coder exist