Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(settings-import): copy extensions Open VSX cannot install (#3)

Artur Rok5d0a91fe41a8
diff --git a/native/crates/app/src/settings_import.rs b/native/crates/app/src/settings_import.rs
index eab1cd45450..5d408d528e4 100644
--- a/native/crates/app/src/settings_import.rs
+++ b/native/crates/app/src/settings_import.rs
@@ -145,6 +145,20 @@ fn extension_ids(folder: &Path) -> Vec<String> {
ids
}
+/// Where `id` is installed in `folder`: its `extensions.json` entry, else the folder whose package.json names it.
+pub fn extension_folder(folder: &Path, id: &str) -> Option<PathBuf> {
+ if let Some(Value::Array(entries)) = parse(&folder.join("extensions.json")) {
+ let entry = entries.iter().find(|entry| entry["identifier"]["id"].as_str().is_some_and(|other| other.eq_ignore_ascii_case(id)))?;
+ return match entry["relativeLocation"].as_str() {
+ Some(relative) => Some(folder.join(relative)),
+ None => entry["location"]["path"].as_str().map(PathBuf::from),
+ };
+ }
+ let children = std::fs::read_dir(folder).ok()?.flatten().map(|entry| entry.path());
+ // shortcut: of two versions the greater folder name wins (1.9 over 1.10), compare versions if that bites.
+ children.filter(|path| parse(&path.join("package.json")).is_some_and(|manifest| exthost::extension_management::gallery_extension_id(&manifest) == id)).max()
+}
+
/// What `write` changed, for the report.
#[derive(Debug, Default, PartialEq)]
pub struct Written {
diff --git a/native/crates/app/src/settings_import/tests.rs b/native/crates/app/src/settings_import/tests.rs
index 606c8cd2a95..69895c3c891 100644
--- a/native/crates/app/src/settings_import/tests.rs
+++ b/native/crates/app/src/settings_import/tests.rs
@@ -87,6 +87,15 @@ fn an_empty_profile_takes_keybindings_json_with_its_comments() {
std::fs::remove_dir_all(&root).unwrap();
}
+#[test]
+fn finds_an_extensions_folder_by_extensions_json_else_by_its_manifest() {
+ let vscode = source("VS Code").extensions_dir;
+ assert_eq!(extension_folder(&vscode, "rust-lang.rust-analyzer"), Some(vscode.join("rust-lang.rust-analyzer-0.3.2000")));
+ assert_eq!(extension_folder(&vscode, "vscodevim.vim"), None);
+ let vscodium = source("VSCodium").extensions_dir;
+ assert_eq!(extension_folder(&vscodium, "vscodevim.vim"), Some(vscodium.join("vscodevim.vim-1.29.0")));
+}
+
/// The extensions VS Code has disabled (`extensionsIdentifiers/disabled` in its global storage) are read, and the
/// database is opened read-only.
#[test]
diff --git a/native/crates/app/src/workbench/settings_import.rs b/native/crates/app/src/workbench/settings_import.rs
index 765790c8fe0..44c5d10caf0 100644
--- a/native/crates/app/src/workbench/settings_import.rs
+++ b/native/crates/app/src/workbench/settings_import.rs
@@ -1,7 +1,8 @@
//! `workbench.action.importSettings` and its first-run offer (port feature, Artur): pick an installed VS Code,
//! Cursor or VSCodium, see what will be imported, and write it into the current profile; the extensions are
-//! installed again from Open VSX.
+//! installed again from Open VSX, and the ones Open VSX cannot give are copied from that editor's extensions folder.
+use exthost::extension_management::Job;
use gpui::{Context, Window};
use serde_json::Value;
@@ -99,12 +100,13 @@ impl Workbench {
extensions: if chosen.contains(&3) { import.extensions } else { Vec::new() },
disabled_extensions: if chosen.contains(&3) { import.disabled_extensions } else { Vec::new() },
};
- let _ = workbench.update_in(cx, |workbench, window, cx| workbench.write_settings_import(source.name, import, window, cx));
+ let _ = workbench.update_in(cx, |workbench, window, cx| workbench.write_settings_import(&source, import, window, cx));
})
.detach();
}
- fn write_settings_import(&mut self, name: &'static str, import: Import, window: &mut Window, cx: &mut Context<Self>) {
+ fn write_settings_import(&mut self, source: &Source, import: Import, window: &mut Window, cx: &mut Context<Self>) {
+ let name = source.name;
let Some(profile) = self.user_data_profiles.state.as_ref().map(|state| state.current.clone()) else { return };
let settings_file = self.settings.lock().unwrap().user_files().settings.clone();
let target = Target { settings: &settings_file, keybindings: &profile.keybindings_resource, snippets_home: &profile.snippets_home };
@@ -126,7 +128,7 @@ impl Workbench {
}
}
let message = format!(
- "Imported from {name}: {} settings, {} keyboard shortcuts, {} snippet files; installing {} extensions from Open VSX.",
+ "Imported from {name}: {} settings, {} keyboard shortcuts, {} snippet files; installing {} extensions from Open VSX, else from {name}'s extensions folder.",
written.settings,
written.keybindings,
written.snippets,
@@ -137,9 +139,23 @@ impl Workbench {
if missing.is_empty() {
return;
}
- let failed = self.install_gallery_extensions(missing, window, cx);
+ let from_gallery = self.install_gallery_extensions(missing, window, cx);
+ let extensions_dir = source.extensions_dir.clone();
cx.spawn(async move |workbench, cx| {
- let failed = failed.await;
+ let mut failed = Vec::new();
+ for (id, reason) in from_gallery.await {
+ // A publisher the user did not trust stays out.
+ let folder = settings_import::extension_folder(&extensions_dir, &id).filter(|_| reason != super::trusted_publishers::CANCELED);
+ let Some(folder) = folder else {
+ failed.push((id, reason));
+ continue;
+ };
+ let Ok(reply) = workbench.update(cx, |workbench, _| workbench.host.run_extensions(Job::InstallFolder(folder))) else { return };
+ match reply.await.unwrap_or_else(|_| Err("The extension host is not running.".into())) {
+ Ok(running) => drop(workbench.update(cx, |workbench, cx| workbench.set_running_extensions(running, cx))),
+ Err(error) => failed.push((id, format!("{reason} Copying it from {name} failed: {error}"))),
+ }
+ }
if failed.is_empty() {
return;
}
@@ -226,15 +242,12 @@ pub(super) mod tests {
url
}
- /// extensionManagementService.ts `installGalleryExtensions`: the extensions of two untrusted publishers ask for
- /// trust once, in one dialog that names both.
- #[gpui::test]
- fn imported_extensions_ask_for_publisher_trust_once(cx: &mut TestAppContext) {
- let gallery_url = two_publisher_gallery();
+ /// A window whose profile lives in a fresh temporary `dir`, installing from `gallery_url`.
+ fn import_window<'a>(name: &str, gallery_url: String, cx: &'a mut TestAppContext) -> (gpui::Entity<Workbench>, &'a mut gpui::VisualTestContext, std::path::PathBuf) {
let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();
let themes = exthost::scan::scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();
let theme = crate::theme::load_theme(&[themes], "Dark Modern").unwrap();
- let dir = std::env::temp_dir().join(format!("code-gpui-settings-import-trust-{}", std::process::id()));
+ let dir = std::env::temp_dir().join(format!("code-gpui-settings-import-{name}-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
let user = dir.join("data/User");
std::fs::create_dir_all(&user).unwrap();
@@ -248,9 +261,18 @@ pub(super) mod tests {
workbench.gallery_url = gallery_url;
workbench
});
+ (workbench, cx, dir)
+ }
+
+ /// extensionManagementService.ts `installGalleryExtensions`: the extensions of two untrusted publishers ask for
+ /// trust once, in one dialog that names both.
+ #[gpui::test]
+ fn imported_extensions_ask_for_publisher_trust_once(cx: &mut TestAppContext) {
+ let (workbench, cx, dir) = import_window("trust", two_publisher_gallery(), cx);
let ids = vec!["redhat.vscode-yaml".to_owned(), "beta.vscode-yaml".to_owned()];
+ let source = Source { name: "VS Code", user_dir: dir.join("Code/User"), extensions_dir: dir.join(".vscode/extensions") };
let import = Import { extensions: ids, disabled_extensions: vec!["beta.vscode-yaml".into()], ..Import::default() };
- workbench.update_in(cx, |workbench, window, cx| workbench.write_settings_import("VS Code", import, window, cx));
+ workbench.update_in(cx, |workbench, window, cx| workbench.write_settings_import(&source, import, window, cx));
cx.run_until_parked();
let messages: Vec<String> = workbench.read_with(cx, |workbench, _| workbench.dialogs.iter().map(|shown| shown.dialog.message.clone()).collect());
assert_eq!(messages, ["Do you trust publishers \"Red Hat\" and \"Beta\"?"]);
@@ -258,4 +280,22 @@ pub(super) mod tests {
assert_eq!(disabled.iter().map(|identifier| identifier.id.as_str()).collect::<Vec<_>>(), ["beta.vscode-yaml"]);
std::fs::remove_dir_all(dir).unwrap();
}
+
+ /// An extension Open VSX does not have is copied from the source's extensions folder; one missing there too is
+ /// reported with the gallery's reason alone. The test host does not run, so the copy fails with that error.
+ #[gpui::test]
+ fn extensions_open_vsx_lacks_are_copied_from_the_source(cx: &mut TestAppContext) {
+ let empty = serde_json::json!({ "results": [{ "extensions": [], "resultMetadata": [{ "metadataType": "ResultCount", "metadataItems": [{ "name": "TotalCount", "count": 0 }] }] }] });
+ let (workbench, cx, dir) = import_window("copy", serve_gallery(empty.to_string()), cx);
+ let source = Source { name: "VS Code", user_dir: dir.join("Code/User"), extensions_dir: dir.join(".vscode/extensions") };
+ std::fs::create_dir_all(source.extensions_dir.join("alpha.one-1.0.0")).unwrap();
+ std::fs::write(source.extensions_dir.join("alpha.one-1.0.0/package.json"), r#"{ "name": "one", "publisher": "alpha", "version": "1.0.0" }"#).unwrap();
+ let import = Import { extensions: vec!["alpha.one".into(), "beta.two".into()], ..Import::default() };
+ workbench.update_in(cx, |workbench, window, cx| workbench.write_settings_import(&source, import, window, cx));
+ cx.run_until_parked();
+ let messages: Vec<String> = workbench.read_with(cx, |workbench, _| workbench.notifications.model.items.iter().map(|item| item.message.raw.clone()).collect());
+ let expected = "Extensions from VS Code that were not installed:\nalpha.one: The extension 'alpha.one' cannot be installed because it was not found. Copying it from VS Code failed: The extension host is not running.\nbeta.two: The extension 'beta.two' cannot be installed because it was not found.";
+ assert!(messages.iter().any(|message| message == expected), "{messages:?}");
+ std::fs::remove_dir_all(dir).unwrap();
+ }
}
diff --git a/native/crates/exthost/src/extension_management.rs b/native/crates/exthost/src/extension_management.rs
index e1c057bf450..98e60ac3c6f 100644
--- a/native/crates/exthost/src/extension_management.rs
+++ b/native/crates/exthost/src/extension_management.rs
@@ -66,18 +66,32 @@ impl UserExtensions {
/// `install(vsix)`: checks the engine, extracts into `<publisher>.<name>-<version>` and adds it to the profile,
/// replacing other versions. Returns the installed extension as the host gets it.
pub fn install_vsix(&self, vsix: &Path) -> anyhow::Result<ScannedExtension> {
- self.install(vsix, None)
+ let (archive, manifest) = read_vsix(vsix)?;
+ self.install(&manifest, None, |temp| archive.extract("extension", temp))
+ }
+
+ /// An extension folder of another editor (port feature, the settings import): copied as a VSIX is extracted,
+ /// without that editor's `__metadata`.
+ pub fn install_folder(&self, folder: &Path) -> anyhow::Result<ScannedExtension> {
+ let manifest_file = folder.join("package.json");
+ let mut manifest: Value = serde_json::from_slice(&std::fs::read(&manifest_file).with_context(|| format!("reading {}", manifest_file.display()))?)?;
+ manifest.as_object_mut().context("package.json is not an object")?.remove("__metadata");
+ self.install(&manifest, None, |temp| {
+ copy_folder(folder, temp)?;
+ Ok(std::fs::write(temp.join("package.json"), serde_json::to_vec(&manifest)?)?)
+ })
}
/// `InstallGalleryExtensionTask`: the downloaded VSIX of `gallery`, which must be the extension and version it names.
/// The same version already installed only gets the gallery metadata.
pub fn install_gallery(&self, vsix: &Path, gallery: &GalleryExtension) -> anyhow::Result<ScannedExtension> {
- self.install(vsix, Some(gallery))
+ let (archive, manifest) = read_vsix(vsix)?;
+ self.install(&manifest, Some(gallery), |temp| archive.extract("extension", temp))
}
- fn install(&self, vsix: &Path, gallery: Option<&GalleryExtension>) -> anyhow::Result<ScannedExtension> {
- let (archive, manifest) = read_vsix(vsix)?;
- let id = gallery_extension_id(&manifest);
+ /// `fill` writes the extension's files into the temporary folder that becomes its location.
+ fn install(&self, manifest: &Value, gallery: Option<&GalleryExtension>, fill: impl FnOnce(&Path) -> anyhow::Result<()>) -> anyhow::Result<ScannedExtension> {
+ let id = gallery_extension_id(manifest);
let version = manifest["version"].as_str().unwrap_or_default();
if let Some(gallery) = gallery
&& (!gallery.id.eq_ignore_ascii_case(&id) || gallery.version != version)
@@ -111,9 +125,9 @@ impl UserExtensions {
// Installing a VSIX always replaces the folder of the same version, installed or marked as removed.
self.unset_for_removal(&key)?;
if location.exists() {
- delete_folder(&location).with_context(|| format!("Please restart {} before reinstalling {}.", crate::product_name(), display_name(&manifest)))?;
+ delete_folder(&location).with_context(|| format!("Please restart {} before reinstalling {}.", crate::product_name(), display_name(manifest)))?;
}
- self.extract(&archive, &location)?;
+ self.extract(fill, &location)?;
}
Some(gallery) => {
let has_pre_release = existing.is_some_and(|existing| existing["metadata"]["hasPreReleaseVersion"] == true);
@@ -135,7 +149,7 @@ impl UserExtensions {
if location.exists() {
delete_folder(&location)?;
}
- self.extract(&archive, &location)?;
+ self.extract(fill, &location)?;
}
}
}
@@ -264,10 +278,10 @@ impl UserExtensions {
}
/// `extractUserExtension`: into a `.<id>` folder first, `__metadata` written, then renamed into place.
- fn extract(&self, archive: &Archive, location: &Path) -> anyhow::Result<()> {
+ fn extract(&self, fill: impl FnOnce(&Path) -> anyhow::Result<()>, location: &Path) -> anyhow::Result<()> {
let temp = self.folder.join(format!(".{}", unique_suffix()));
std::fs::create_dir_all(&temp)?;
- let extracted = archive.extract("extension", &temp).and_then(|()| {
+ let extracted = fill(&temp).and_then(|()| {
let manifest_file = temp.join("package.json");
let mut manifest: Value = serde_json::from_slice(&std::fs::read(&manifest_file)?)?;
let size = folder_size(&temp);
@@ -343,6 +357,7 @@ impl UserExtensions {
pub enum Job {
InstallVsix(PathBuf),
InstallGallery(PathBuf, Box<GalleryExtension>),
+ InstallFolder(PathBuf),
Uninstall(String),
/// An enablement change: the extensions to start and the ids to stop, nothing on disk.
Delta(Vec<ScannedExtension>, Vec<String>),
@@ -371,6 +386,11 @@ impl WindowExtensions {
let id = installed.id.clone();
(vec![installed], vec![id])
}
+ Job::InstallFolder(folder) => {
+ let installed = self.user.install_folder(&folder)?;
+ let id = installed.id.clone();
+ (vec![installed], vec![id])
+ }
Job::Uninstall(id) => {
self.user.uninstall(&id)?;
let builtin = self.builtins.iter().find(|builtin| builtin.id.eq_ignore_ascii_case(&id)).cloned();
@@ -465,6 +485,24 @@ fn delete_folder(location: &Path) -> anyhow::Result<()> {
Ok(std::fs::remove_dir_all(renamed)?)
}
+/// Symbolic links are copied as links.
+fn copy_folder(from: &Path, to: &Path) -> anyhow::Result<()> {
+ for child in std::fs::read_dir(from).with_context(|| format!("reading {}", from.display()))? {
+ let child = child?;
+ let target = to.join(child.file_name());
+ let kind = child.file_type()?;
+ if kind.is_symlink() {
+ std::os::unix::fs::symlink(std::fs::read_link(child.path())?, &target)?;
+ } else if kind.is_dir() {
+ std::fs::create_dir_all(&target)?;
+ copy_folder(&child.path(), &target)?;
+ } else {
+ std::fs::copy(child.path(), &target)?;
+ }
+ }
+ Ok(())
+}
+
fn folder_size(folder: &Path) -> u64 {
std::fs::read_dir(folder)
.into_iter()
diff --git a/native/crates/exthost/src/extension_management/tests.rs b/native/crates/exthost/src/extension_management/tests.rs
index 789d41a4284..a4a8064c807 100644
--- a/native/crates/exthost/src/extension_management/tests.rs
+++ b/native/crates/exthost/src/extension_management/tests.rs
@@ -50,6 +50,22 @@ fn installs_a_vsix_into_the_profile() {
assert_eq!(scanned.iter().map(|extension| extension.id.as_str()).collect::<Vec<_>>(), ["Port.Sample"]);
}
+#[test]
+fn installs_another_editors_extension_folder_without_its_metadata() {
+ let fixture = Fixture::new("folder");
+ let folder = fixture.root.join("vscode/port.sample-1.0.0-darwin-arm64");
+ std::fs::create_dir_all(folder.join("out")).unwrap();
+ let manifest = json!({ "name": "Sample", "publisher": "Port", "version": "1.0.0", "engines": { "vscode": "^1.80.0" }, "__metadata": { "id": "marketplace-uuid", "source": "gallery" } });
+ std::fs::write(folder.join("package.json"), manifest.to_string()).unwrap();
+ std::fs::write(folder.join("out/main.js"), "exports.activate = () => {};").unwrap();
+ let installed = fixture.extensions.install_folder(&folder).unwrap();
+ assert_eq!(installed.location, fixture.extensions.folder.join("port.sample-1.0.0"));
+ assert!(installed.location.join("out/main.js").is_file());
+ assert_eq!(installed.description["uuid"], Value::Null);
+ assert_eq!(fixture.profile_ids(), [("port.sample".to_owned(), "port.sample-1.0.0".to_owned())]);
+ assert!(folder.join("package.json").is_file(), "the source folder stays");
+}
+
#[test]
fn keeps_double_spaces_in_manifest_strings() {
let fixture = Fixture::new("spaces");
diff --git a/port/ledger.md b/port/ledger.md
index fef1d4791d0..e9df8b4c676 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -662,7 +662,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| telemetry/source-search | cross-cutting check | M19 | verified | | port/tools/telemetry-source-check: no telemetry or experimentation endpoint in the release binary, out-exthost and the 86 shipped built-ins with their 339 resolved packages (18370 files); SELF_TEST=1 finds 9 files in the inert packages |
| telemetry/network-capture | cross-cutting check | M19 | verified | | port/tools/network-capture, 600 s with no user action, fresh user data: folder window (eager git, npm, github activated) and empty window, no outbound traffic from the app's process tree; the control curl is seen each run. An earlier folder run with traffic was another session's keystrokes opening JSON files (json-language-features schema downloads), so runs take the Studio GUI lock |
| gallery/open-vsx | cross-cutting check | M18 | verified | | exthost/src/gallery.rs: query, latest-version resource, version choice, download with signature check; cargo test -p exthost gallery (upstream extensionGalleryService.test.ts sorting and filterLatestExtensionVersionsForTargetPlatform cases, Open VSX resource fixture); `workbench.extensions.installExtension redhat.vscode-yaml` downloads 2.0.0 from open-vsx.org, verifies it and activates without restart, not-found errors as upstream: PORT_GALLERY=1 port/tools/extensions-check |
-| port/settings-import | port feature | M10 | verified | | app/src/settings_import.rs and workbench/settings_import.rs: `Preferences: Import from VS Code, Cursor or VSCodium...` and a first-run offer read `~/Library/Application Support/{Code,Cursor,VSCodium}/User` (settings.json, keybindings.json, snippets, the theme ids with the settings) and `~/.vscode/extensions`, `~/.cursor/extensions`, `~/.vscode-oss/extensions`, show the parts with their counts, write into the current profile and install the extensions from Open VSX as a profile import does (userDataProfileImportExportService.ts, extensionsResource.ts `apply`): one gallery query, one publisher trust dialog for all publishers (extensionManagementService.ts `installGalleryExtensions`), an "Installing Extensions..." progress notification and an error that names each extension not installed with why; the extensions VS Code has disabled (`extensionsIdentifiers/disabled` in its `globalStorage/state.vscdb`, read-only) are disabled before they install; a profile without keybindings gets `keybindings.json` as written, comments included; the color, file icon and product icon themes the settings name apply once their extension is installed (workbenchThemeService.ts registry `onDidChange`); AI, sign-in, telemetry, remote and the editors' own settings and extensions are left out. The contents pick starts with every part checked (`picked` selects with `canSelectMany`, quickInputController.ts `pick`). cargo test -p app settings_import installed_extensions_bring (9 passed, `accepting_the_contents_pick_imports_every_part` fails when the checked items do not start selected, `imported_extensions_ask_for_publisher_trust_once` fails with one dialog per extension, `installed_extensions_bring_the_themes_the_settings_name` fails without the restore on `set_running_extensions`, `an_empty_profile_takes_keybindings_json_with_its_comments` and `reads_the_disabled_extensions` fail without their fixes) on port/fixtures/settings-import; release GUI on the host lane, one import each from VS Code, Cursor and VSCodium fixtures under a scratch HOME through the command palette: settings, keybindings and snippets land in the profile's User folder, `cursor.*` dropped |
+| port/settings-import | port feature | M10 | verified | | app/src/settings_import.rs and workbench/settings_import.rs: `Preferences: Import from VS Code, Cursor or VSCodium...` and a first-run offer read `~/Library/Application Support/{Code,Cursor,VSCodium}/User` (settings.json, keybindings.json, snippets, the theme ids with the settings) and `~/.vscode/extensions`, `~/.cursor/extensions`, `~/.vscode-oss/extensions`, show the parts with their counts, write into the current profile and install the extensions from Open VSX as a profile import does (userDataProfileImportExportService.ts, extensionsResource.ts `apply`): one gallery query, one publisher trust dialog for all publishers (extensionManagementService.ts `installGalleryExtensions`), an "Installing Extensions..." progress notification, then each extension Open VSX did not install (except an untrusted publisher's) copied from the source's extensions folder, and an error that names each extension still not installed with why; the extensions VS Code has disabled (`extensionsIdentifiers/disabled` in its `globalStorage/state.vscdb`, read-only) are disabled before they install; a profile without keybindings gets `keybindings.json` as written, comments included; the color, file icon and product icon themes the settings name apply once their extension is installed (workbenchThemeService.ts registry `onDidChange`); AI, sign-in, telemetry, remote and the editors' own settings and extensions are left out. The contents pick starts with every part checked (`picked` selects with `canSelectMany`, quickInputController.ts `pick`). cargo test -p app settings_import installed_extensions_bring (11 passed, `extensions_open_vsx_lacks_are_copied_from_the_source` fails without the copy fallback, `accepting_the_contents_pick_imports_every_part` fails when the checked items do not start selected, `imported_extensions_ask_for_publisher_trust_once` fails with one dialog per extension, `installed_extensions_bring_the_themes_the_settings_name` fails without the restore on `set_running_extensions`, `an_empty_profile_takes_keybindings_json_with_its_comments` and `reads_the_disabled_extensions` fail without their fixes) on port/fixtures/settings-import; release GUI on the host lane, one import each from VS Code, Cursor and VSCodium fixtures under a scratch HOME through the command palette: settings, keybindings and snippets land in the profile's User folder, `cursor.*` dropped |
| look/screenshot-diff | cross-cutting check | | verified | | port/tools/pixel-check: CDP reference capture and Metal readback in 3 themes, pixeldiff reference vs itself 0 different; baseline in port/results/pixels.md |
| perf/memory-benchmark | cross-cutting check | | verified | | port/tools/bench (Wu method), 3 runs on Studio; port/results/benchmark.md: exthost Bun 57 MiB, Node 98 MiB, reference 151 MiB |
diff --git a/port/notes.md b/port/notes.md
index cbf92b97a6e..d831af52e18 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -174,7 +174,7 @@ Done when: api-tests `configuration.test` and `state.test` pass as in the refere
- Profiles at startup (`app/src/user_data_profile.rs`, windowsMainService.ts `resolveProfileForBrowserWindow`): `--profile <name>` (created when missing), `--profile-temp` (main.rs `CliProfile`, `forceProfile`/`forceTempProfile`: only the window a command line opens, the first start's or a second instance's; without paths that start opens just its new empty window, as app.ts and launchMainService.ts; windows from the menu take the workspace's profile), else the workspace's association, else `window.newWindowProfile`, else the default; the choice is associated with the workspace unless the window develops an extension. The profile gives the settings, tasks and mcp files (`config::service::UserFiles`), the keybindings file, `state.vscdb` of its global storage and its `extensions.json` (`UserExtensions::extensions_file`; an uninstalled folder stays while another profile's extensions.json lists it). A profile with its own settings reads the default profile's application settings and `workbench.settings.applyToAllProfiles` as the application layer, its own file with PROFILE_SCOPES (cargo test -p config profile_tests). The user snippets folder is not read by the port yet (no user snippets loader); the profile's `snippets` folder is used by export, import and settings import.
- Switching profiles (`workbench/user_data_profile.rs` `change_current_profile`): the settings layers, keybindings, profile storage and user extensions move to the new profile's files, then `workbench/extension_host_restart.rs` restarts the host, since the port has no window reload: the session thread sends Terminate, the workbench drops what the host registered (commands, language features, SCM, webview views, URI handlers and openers, the host's markers), and a new session starts with the current extensions, settings and storage. `workbench.action.restartExtensionHost` uses the same path. StorageScope.APPLICATION keys stay in the default profile's state.vscdb across switches (`application_storage`, the same storage as `profile_storage` in the default profile). The extension under development runs again without its tests.
- Profiles editor (`workbench/profiles_editor_view.rs`): the modal part with the sidebar and the contents view, rename, Use for Current/New Windows, Contents, Folders & Workspaces, the new profile form (Copy from a profile or an imported template, the Copy, Default or None source of each resource) and Export/Import of `.code-profile` files from a file or a URL (`app/src/profile_template.rs`). A non-default profile's Source radio writes its `useDefaultFlags`; for the current profile the window switches to the updated profile. The Icon row opens the icon picker (`workbench/icon_select_box.rs`, iconSelectBox.ts with the `iconSelectBox.*` commands): Search icons over the 83 `ICONS` in 36px cells, 12 a row, in a sticky hover under the icon. The activity bar's Manage item shows the current profile's icon, or the two-letter profile badge when it has none (globalCompositeBar.ts). The new profile form is named `Untitled N`, keeps Cancel, Preview and Create (Replace when a copy takes an existing name) under its scrolling body and validates as `NewProfileElement.validate`; its sidebar row has the dirty dot, Cancel and, while copying a profile, Export.... shortcut: Preview stores its profile instead of a transient one (each window is its own process, a transient profile would not reach the preview window); Cancel removes it. port/results/profiles.md.
-- Settings import (`app/src/settings_import.rs`, `workbench/settings_import.rs`; Artur, no upstream counterpart): Preferences: Import from VS Code, Cursor or VSCodium..., and an offer on the first start with the default user data (no `--user-data-dir`) and no settings.json yet, shown once (`settingsImport.offered` in application storage). Keybindings already present are not duplicated; existing snippet files are kept; extensions are installed from Open VSX. The first import installed one extension at a time, each with its own publisher trust dialog queued behind the others, and dropped their results; it now runs like a profile import (one query, one trust dialog, progress, the failures listed), disables what VS Code has disabled, keeps keybindings.json comments when the profile has no keybindings yet, and the theme settings apply when their extension arrives. Settings the port removed (chat.*, github.copilot.*, the AI search toggle) stay left out by design. Fixtures in port/fixtures/settings-import.
+- Settings import (`app/src/settings_import.rs`, `workbench/settings_import.rs`; Artur, no upstream counterpart): Preferences: Import from VS Code, Cursor or VSCodium..., and an offer on the first start with the default user data (no `--user-data-dir`) and no settings.json yet, shown once (`settingsImport.offered` in application storage). Keybindings already present are not duplicated; existing snippet files are kept; extensions are installed from Open VSX, and one Open VSX does not have or cannot install (not found, offline, an incompatible version) is copied from the source's extensions folder instead (`UserExtensions::install_folder`, without that editor's `__metadata`); a publisher the user did not trust is not copied either. The first import installed one extension at a time, each with its own publisher trust dialog queued behind the others, and dropped their results; it now runs like a profile import (one query, one trust dialog, progress, the failures listed), disables what VS Code has disabled, keeps keybindings.json comments when the profile has no keybindings yet, and the theme settings apply when their extension arrives. Settings the port removed (chat.*, github.copilot.*, the AI search toggle) stay left out by design. Fixtures in port/fixtures/settings-import.
- configuration-editing's own tests run with `port/tools/extension-tests configuration-editing` (a built-in extension's out/test from the reference checkout, against vsrustium): 18 passing. They needed `_executeCompletionItemProvider` and `_executeLinkProvider` to send cancellation tokens (`host.call_cancellable`, as rpcProtocol.ts does for a method whose last parameter is a token), `$acceptLanguageIds` at host start and restart (`vscode.languages.getLanguages`), `getContextKeyInfo` (the reference's `RawContextKey.all()`, dumped by `port/tools/ref-commands` into `contextkey/reference-context-keys.json`; rerun it when the reference moves) and the development copy of a built-in keeping `isBuiltin` (`scanExtensionsUnderDevelopment`), which `@vscode/internal-github`'s allowlist checks. The extensions.json cases expect `ms-vscode.js-debug`: the Studio mirror needs `port/tools/fetch-builtin-extensions` once.
### Milestone 10 handoff (next session)