Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(update): port the unattended restart scheduler's decisions

rokartur80c786ec2dcd
diff --git a/native/crates/app/src/update.rs b/native/crates/app/src/update.rs
index 7301e0bf009..681d7619f64 100644
--- a/native/crates/app/src/update.rs
+++ b/native/crates/app/src/update.rs
@@ -3,6 +3,7 @@
//! by a helper after the app quits. The feed format is in port/notes.md ("Update feed").
pub mod install;
+pub mod unattended_restart;
use std::io::Read;
use std::path::PathBuf;
diff --git a/native/crates/app/src/update/unattended_restart.rs b/native/crates/app/src/update/unattended_restart.rs
new file mode 100644
index 00000000000..cc5b4cc9b17
--- /dev/null
+++ b/native/crates/app/src/update/unattended_restart.rs
@@ -0,0 +1,218 @@
+//! platform/update/electron-main/unattendedRestartScheduler.ts: restarts to apply a downloaded update once the screen
+//! has been locked for a minute, while every window can be restored exactly as it is. The caller owns the timers and
+//! the OS: it passes the power events in, evaluates when a step asks, and keeps the machine awake while
+//! `keep_awake_until` is ahead. No telemetry is sent (port/notes.md Privacy), so with `update.restartWhenIdle` off
+//! nothing runs, as upstream's does at telemetry level NONE, and the outcomes upstream reports are not kept.
+
+#![cfg_attr(not(test), expect(dead_code, reason = "the next step of the lifecycle row's unattendedRestart gap wires the scheduler to the power events and the update service"))]
+
+use std::time::{Duration, Instant};
+
+use crate::workbench::unattended_restart::{Readiness, describe_blockers};
+
+/// `UNATTENDED_RESTART_LOCKED_DURATION`.
+pub const LOCKED_DURATION: Duration = Duration::from_secs(60);
+/// Lets the machine sleep again when the restart does not happen in time.
+pub const KEEP_AWAKE_LIMIT: Duration = Duration::from_secs(3 * 60);
+const RETRY_INTERVAL: Duration = Duration::from_secs(60);
+/// Some platforms blur the focused window right before they report the screen lock.
+const FOCUS_LOSS_AT_LOCK_GRACE_PERIOD: Duration = Duration::from_secs(1);
+
+/// What the caller does next.
+#[derive(Debug, PartialEq)]
+pub enum Step {
+ Nothing,
+ EvaluateAt(Instant),
+ /// `quitAndInstall({ unattended: true, relaunchInBackground })`, then `restart_returned`.
+ Restart { in_background: bool },
+}
+
+/// What an evaluation reads: the windows' readiness with the app's own blockers, and the system state.
+pub struct Checks {
+ pub readiness: Readiness,
+ /// `getSystemIdleState`, which reports the lock only shortly after the lock event.
+ pub idle_state: &'static str,
+ pub on_battery: bool,
+ pub thermal_state: &'static str,
+}
+
+#[derive(Default)]
+pub struct Scheduler {
+ locked_since: Option<Instant>,
+ active_when_locked: bool,
+ last_window_blur: Option<Instant>,
+ last_blockers: Option<Vec<&'static str>>,
+ checked_since_lock: bool,
+ done: bool,
+ /// `pendingRestart.toVersion`: the update an unattended restart is under way for. While it is set, the windows
+ /// are restored exactly on the next start (`restoreExactlyOnNextStartup`).
+ pub pending: Option<String>,
+ keep_awake_since: Option<Instant>,
+ /// An update the last unattended restart did not install.
+ failed_update_version: Option<String>,
+}
+
+fn is_under_thermal_pressure(state: &str) -> bool {
+ matches!(state, "serious" | "critical")
+}
+
+impl Scheduler {
+ pub fn new(failed_update_version: Option<String>) -> Self {
+ Scheduler { failed_update_version, ..Scheduler::default() }
+ }
+
+ pub fn window_blurred(&mut self, now: Instant) {
+ self.last_window_blur = Some(now);
+ }
+
+ /// `onDidLockScreen`: evaluates right away, to keep the machine awake when everything would work.
+ pub fn screen_locked(&mut self, now: Instant, window_focused: bool) -> Step {
+ self.locked_since = Some(now);
+ self.active_when_locked = window_focused || self.last_window_blur.is_some_and(|blur| now - blur <= FOCUS_LOSS_AT_LOCK_GRACE_PERIOD);
+ self.last_blockers = None;
+ self.checked_since_lock = false;
+ self.done = false;
+ self.schedule(now)
+ }
+
+ /// `onDidUnlockScreen`: the caller drops the scheduled evaluation and cancels a restart that still checks for a
+ /// newer update.
+ pub fn screen_unlocked(&mut self) {
+ self.locked_since = None;
+ self.allow_sleep("the screen got unlocked");
+ }
+
+ /// `onDidSuspend`: the caller cancels as on unlock.
+ pub fn suspended(&mut self) {
+ self.allow_sleep("the machine went to sleep anyway, for example because the lid got closed");
+ }
+
+ /// `onDidResume`: the user might be about to return, so the clock starts again.
+ pub fn resumed(&mut self, now: Instant) -> Step {
+ if self.locked_since.is_none() {
+ return Step::Nothing;
+ }
+ self.locked_since = Some(now);
+ self.checked_since_lock = false;
+ self.schedule(now)
+ }
+
+ /// `onDidSwitchToBattery` and a thermal state change: the caller cancels a restart under way when this is true.
+ pub fn power_changed(&mut self, on_battery: bool, thermal_state: &str) -> bool {
+ let reason = if on_battery { "the machine runs on battery" } else { "the machine is under thermal pressure" };
+ let constrained = on_battery || is_under_thermal_pressure(thermal_state);
+ if constrained {
+ self.allow_sleep(reason);
+ }
+ constrained
+ }
+
+ /// `updateService.onStateChange`: `ready` back while a restart is pending is a vetoed shutdown.
+ pub fn update_state_changed(&mut self, now: Instant, ready: bool, restarting: bool) -> Step {
+ if !ready {
+ if !restarting {
+ self.allow_sleep("the update is no longer ready");
+ }
+ return Step::Nothing;
+ }
+ if self.pending.is_none() {
+ return self.schedule(now);
+ }
+ eprintln!("[update] update#unattendedRestart - the restart was vetoed");
+ self.pending = None;
+ self.allow_sleep("the restart was vetoed");
+ self.done = false;
+ self.last_blockers = Some(vec!["shutdown.vetoed"]);
+ self.schedule(now + RETRY_INTERVAL)
+ }
+
+ /// `evaluate`: `update` is the version of the Ready update, `enabled` is `update.restartWhenIdle`.
+ pub fn evaluate(&mut self, now: Instant, update: Option<&str>, enabled: bool, checks: Checks) -> Step {
+ let (Some(locked_since), Some(update)) = (self.locked_since, update) else { return Step::Nothing };
+ if self.done || !enabled {
+ return Step::Nothing;
+ }
+ let due_at = locked_since + LOCKED_DURATION;
+ let is_due = now >= due_at;
+ if !is_due && self.checked_since_lock {
+ return Step::EvaluateAt(due_at);
+ }
+ self.checked_since_lock = true;
+ let readiness = self.blockers(is_due, update, checks);
+ if !readiness.blockers.is_empty() {
+ self.allow_sleep("the restart is blocked");
+ // Retried every minute, so only changes are logged.
+ if self.last_blockers.as_ref() != Some(&readiness.blockers) {
+ eprintln!("[update] update#unattendedRestart - not restarting: {}", describe_blockers(&readiness));
+ }
+ self.last_blockers = Some(readiness.blockers);
+ return Step::EvaluateAt(if is_due { now + RETRY_INTERVAL } else { due_at });
+ }
+ self.last_blockers = Some(Vec::new());
+ if !is_due {
+ self.keep_machine_awake(now);
+ return Step::EvaluateAt(due_at);
+ }
+ self.done = true;
+ let in_background = !self.active_when_locked;
+ eprintln!("[update] update#unattendedRestart - restarting {} to apply the update while the screen is locked", if in_background { "in the background" } else { "in the foreground" });
+ self.pending = Some(update.to_owned());
+ Step::Restart { in_background }
+ }
+
+ /// After `quitAndInstall` returned: unless the update service is Restarting, a newer update postponed the
+ /// restart (a veto comes later, as `update_state_changed`).
+ pub fn restart_returned(&mut self, restarting: bool) {
+ if !restarting {
+ self.pending = None;
+ self.done = false;
+ }
+ }
+
+ /// While this is ahead, the machine must not go to sleep (`powerSaveBlocker` `prevent-app-suspension`).
+ pub fn keep_awake_until(&self) -> Option<Instant> {
+ self.keep_awake_since.map(|since| since + KEEP_AWAKE_LIMIT)
+ }
+
+ /// `getBlockers` past the windows' answers, which the caller already put in `readiness`.
+ fn blockers(&self, is_due: bool, update: &str, checks: Checks) -> Readiness {
+ let mut readiness = checks.readiness;
+ let system = [
+ (self.failed_update_version.as_deref() == Some(update), "update.installFailed"),
+ // The check right after the lock event relies on that event.
+ (is_due && checks.idle_state != "locked", "system.notLocked"),
+ (checks.on_battery, "system.onBatteryPower"),
+ (is_under_thermal_pressure(checks.thermal_state), "system.thermalPressure"),
+ ];
+ for (blocks, blocker) in system {
+ if blocks && !readiness.blockers.contains(&blocker) {
+ readiness.blockers.push(blocker);
+ }
+ }
+ readiness.blockers.sort_unstable();
+ readiness
+ }
+
+ fn schedule(&self, at: Instant) -> Step {
+ if self.locked_since.is_none() || self.done {
+ return Step::Nothing;
+ }
+ Step::EvaluateAt(at)
+ }
+
+ fn keep_machine_awake(&mut self, now: Instant) {
+ if self.keep_awake_since.is_none() {
+ self.keep_awake_since = Some(now);
+ eprintln!("[update] update#unattendedRestart - keeping the machine awake until the restart is due");
+ }
+ }
+
+ fn allow_sleep(&mut self, reason: &str) {
+ if self.keep_awake_since.take().is_some() {
+ eprintln!("[update] update#unattendedRestart - letting the machine sleep again: {reason}");
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests;
diff --git a/native/crates/app/src/update/unattended_restart/tests.rs b/native/crates/app/src/update/unattended_restart/tests.rs
new file mode 100644
index 00000000000..535917d8dd9
--- /dev/null
+++ b/native/crates/app/src/update/unattended_restart/tests.rs
@@ -0,0 +1,297 @@
+//! unattendedRestartScheduler.test.ts against a fixture that plays the caller: it runs the evaluations at the times the
+//! steps ask for, and logs what upstream's fixture logs, without the telemetry outcomes the port does not send.
+
+use super::*;
+
+const SECOND: Duration = Duration::from_secs(1);
+const MINUTE: Duration = Duration::from_secs(60);
+const VERSION: &str = "0123456789abcdef0123456789abcdef01234567";
+
+struct Fixture {
+ scheduler: Scheduler,
+ now: Instant,
+ next: Option<Instant>,
+ log: Vec<&'static str>,
+ awake: bool,
+ enabled: bool,
+ focused: bool,
+ /// The version of the Ready update; `None` while the update service is in another state.
+ update: Option<&'static str>,
+ /// Blockers the window reports for consecutive checks; afterwards it reports none.
+ window_blockers: Vec<Vec<&'static str>>,
+ /// Like macOS, the idle state reports the lock only a second after the lock event.
+ locked_at: Option<Instant>,
+ on_battery: bool,
+ thermal_state: &'static str,
+ /// Whether the first restart finds a newer update, which postpones it.
+ newer_update_on_restart: bool,
+}
+
+impl Fixture {
+ fn new() -> Self {
+ Fixture {
+ scheduler: Scheduler::default(),
+ now: Instant::now(),
+ next: None,
+ log: Vec::new(),
+ awake: false,
+ enabled: true,
+ focused: true,
+ update: Some(VERSION),
+ window_blockers: Vec::new(),
+ locked_at: None,
+ on_battery: false,
+ thermal_state: "nominal",
+ newer_update_on_restart: false,
+ }
+ }
+
+ fn lock(&mut self) {
+ self.locked_at = Some(self.now);
+ let step = self.scheduler.screen_locked(self.now, self.focused);
+ self.follow(step);
+ }
+
+ fn unlock(&mut self) {
+ self.locked_at = None;
+ self.next = None;
+ self.scheduler.screen_unlocked();
+ self.sync_awake();
+ }
+
+ fn suspend(&mut self) {
+ self.next = None;
+ self.scheduler.suspended();
+ self.sync_awake();
+ }
+
+ fn resume(&mut self) {
+ let step = self.scheduler.resumed(self.now);
+ self.follow(step);
+ }
+
+ fn switch_to_battery(&mut self) {
+ self.on_battery = true;
+ self.scheduler.power_changed(true, self.thermal_state);
+ self.sync_awake();
+ }
+
+ fn change_thermal_state(&mut self, state: &'static str) {
+ self.thermal_state = state;
+ self.scheduler.power_changed(self.on_battery, state);
+ self.sync_awake();
+ }
+
+ /// The update service's Ready, also what a vetoed shutdown puts back.
+ fn set_update_ready(&mut self) {
+ self.update = Some(VERSION);
+ let step = self.scheduler.update_state_changed(self.now, true, false);
+ self.follow(step);
+ }
+
+ fn wait(&mut self, duration: Duration) {
+ let end = self.now + duration;
+ while let Some(at) = self.next.filter(|at| *at <= end) {
+ self.now = at;
+ self.next = None;
+ let checks = Checks {
+ readiness: Readiness { blockers: if self.window_blockers.is_empty() { Vec::new() } else { self.window_blockers.remove(0) }, details: Default::default() },
+ idle_state: if self.locked_at.is_some_and(|locked| self.now >= locked + SECOND) { "locked" } else { "active" },
+ on_battery: self.on_battery,
+ thermal_state: self.thermal_state,
+ };
+ let step = self.scheduler.evaluate(self.now, self.update, self.enabled, checks);
+ self.follow(step);
+ }
+ self.now = end;
+ }
+
+ fn follow(&mut self, step: Step) {
+ match step {
+ Step::Nothing => {}
+ Step::EvaluateAt(at) => self.next = Some(at),
+ Step::Restart { in_background } => {
+ self.log.push(if in_background { "quitAndInstall(background)" } else { "quitAndInstall(foreground)" });
+ self.update = None;
+ let newer_update = std::mem::take(&mut self.newer_update_on_restart);
+ if newer_update {
+ // Overwriting: the update service downloads the newer update instead of restarting.
+ let step = self.scheduler.update_state_changed(self.now, false, false);
+ self.follow(step);
+ }
+ self.scheduler.restart_returned(!newer_update);
+ }
+ }
+ self.sync_awake();
+ }
+
+ fn sync_awake(&mut self) {
+ let awake = self.scheduler.keep_awake_until().is_some_and(|until| until > self.now);
+ if awake != self.awake {
+ self.awake = awake;
+ self.log.push(if awake { "keepAwake" } else { "allowSleep" });
+ }
+ }
+}
+
+#[test]
+fn keeps_the_machine_awake_from_the_lock_and_restarts_once_the_screen_has_been_locked_long_enough() {
+ let mut fixture = Fixture::new();
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION - 20 * SECOND);
+ let before_threshold = fixture.log.clone();
+ fixture.wait(MINUTE);
+ assert_eq!(before_threshold, ["keepAwake"]);
+ assert_eq!(fixture.log, ["keepAwake", "quitAndInstall(foreground)"]);
+ assert_eq!(fixture.scheduler.pending.as_deref(), Some(VERSION));
+}
+
+/// "only measures eligibility when the setting is disabled": without telemetry, nothing runs.
+#[test]
+fn does_nothing_when_the_setting_is_disabled() {
+ let mut fixture = Fixture { enabled: false, ..Fixture::new() };
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 30 * MINUTE);
+ assert_eq!(fixture.log, Vec::<&str>::new());
+ assert_eq!(fixture.scheduler.pending, None);
+}
+
+#[test]
+fn restores_the_windows_in_the_background_when_another_application_had_focus_when_the_screen_got_locked() {
+ let mut fixture = Fixture { focused: false, ..Fixture::new() };
+ fixture.scheduler.window_blurred(fixture.now);
+ fixture.wait(5 * SECOND);
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 20 * SECOND);
+ assert_eq!(fixture.log, ["keepAwake", "quitAndInstall(background)"]);
+}
+
+#[test]
+fn treats_a_window_that_lost_focus_as_the_screen_got_locked_as_focused() {
+ let mut fixture = Fixture { focused: false, ..Fixture::new() };
+ fixture.scheduler.window_blurred(fixture.now);
+ fixture.wait(Duration::from_millis(500));
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 20 * SECOND);
+ assert_eq!(fixture.log, ["keepAwake", "quitAndInstall(foreground)"]);
+}
+
+#[test]
+fn only_keeps_the_machine_awake_while_it_is_on_power() {
+ let mut on_battery = Fixture { on_battery: true, ..Fixture::new() };
+ let mut unplugged = Fixture::new();
+ on_battery.lock();
+ unplugged.lock();
+ on_battery.wait(20 * SECOND);
+ unplugged.wait(20 * SECOND);
+ unplugged.switch_to_battery();
+ on_battery.wait(LOCKED_DURATION);
+ unplugged.wait(LOCKED_DURATION);
+ on_battery.unlock();
+ unplugged.unlock();
+ assert_eq!(on_battery.log, Vec::<&str>::new());
+ assert_eq!(unplugged.log, ["keepAwake", "allowSleep"]);
+}
+
+#[test]
+fn lets_the_machine_sleep_as_soon_as_it_is_under_thermal_pressure_and_does_not_restart_then() {
+ let mut fixture = Fixture::new();
+ fixture.lock();
+ fixture.wait(20 * SECOND);
+ fixture.change_thermal_state("fair");
+ let when_fair = fixture.log.clone();
+ fixture.change_thermal_state("serious");
+ let when_serious = fixture.log.clone();
+ fixture.wait(LOCKED_DURATION);
+ fixture.unlock();
+ assert_eq!(when_fair, ["keepAwake"]);
+ assert_eq!(when_serious, ["keepAwake", "allowSleep"]);
+ assert_eq!(fixture.log, ["keepAwake", "allowSleep"]);
+}
+
+#[test]
+fn retries_while_a_window_cannot_be_restored_and_restarts_once_it_can() {
+ let mut fixture = Fixture { window_blockers: vec![vec!["terminal.runningProcess"], vec!["terminal.runningProcess"]], ..Fixture::new() };
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 2 * MINUTE);
+ assert_eq!(fixture.log, ["quitAndInstall(foreground)"]);
+}
+
+#[test]
+fn retries_when_the_shutdown_is_vetoed() {
+ let mut fixture = Fixture::new();
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 20 * SECOND);
+ fixture.set_update_ready();
+ let after_veto = fixture.scheduler.pending.clone();
+ fixture.wait(30 * SECOND);
+ let before_retry = fixture.log.clone();
+ fixture.wait(2 * MINUTE);
+ assert_eq!(after_veto, None);
+ assert_eq!(before_retry, ["keepAwake", "quitAndInstall(foreground)", "allowSleep"]);
+ assert_eq!(fixture.log, ["keepAwake", "quitAndInstall(foreground)", "allowSleep", "quitAndInstall(foreground)"]);
+ assert_eq!(fixture.scheduler.pending.as_deref(), Some(VERSION));
+}
+
+#[test]
+fn restarts_once_a_newer_update_that_postponed_the_restart_is_ready() {
+ let mut fixture = Fixture { newer_update_on_restart: true, ..Fixture::new() };
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 20 * SECOND);
+ let while_postponed = fixture.log.clone();
+ let pending_while_postponed = fixture.scheduler.pending.clone();
+ fixture.set_update_ready();
+ fixture.wait(20 * SECOND);
+ assert_eq!(while_postponed, ["keepAwake", "quitAndInstall(foreground)", "allowSleep"]);
+ assert_eq!(pending_while_postponed, None);
+ assert_eq!(fixture.log, ["keepAwake", "quitAndInstall(foreground)", "allowSleep", "quitAndInstall(foreground)"]);
+}
+
+#[test]
+fn does_not_restart_again_for_an_update_that_the_last_unattended_restart_did_not_install() {
+ let mut same_update = Fixture { scheduler: Scheduler::new(Some(VERSION.into())), ..Fixture::new() };
+ let mut newer_update = Fixture { scheduler: Scheduler::new(Some("fedcba9876543210fedcba9876543210fedcba98".into())), ..Fixture::new() };
+ for fixture in [&mut same_update, &mut newer_update] {
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 20 * SECOND);
+ }
+ assert_eq!(same_update.log, Vec::<&str>::new());
+ assert_eq!(newer_update.log, ["keepAwake", "quitAndInstall(foreground)"]);
+}
+
+#[test]
+fn keeps_the_machine_awake_again_when_it_resumes_while_locked_and_restarts_the_clock() {
+ let mut fixture = Fixture::new();
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION - 20 * SECOND);
+ fixture.suspend();
+ fixture.wait(60 * MINUTE);
+ fixture.resume();
+ fixture.wait(LOCKED_DURATION - 20 * SECOND);
+ let before_threshold = fixture.log.clone();
+ fixture.wait(MINUTE);
+ assert_eq!(before_threshold, ["keepAwake", "allowSleep", "keepAwake"]);
+ assert_eq!(fixture.log, ["keepAwake", "allowSleep", "keepAwake", "quitAndInstall(foreground)"]);
+}
+
+#[test]
+fn waits_for_the_update_to_be_ready() {
+ let mut fixture = Fixture { update: None, ..Fixture::new() };
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION + 60 * MINUTE);
+ let before_ready = fixture.log.clone();
+ fixture.set_update_ready();
+ fixture.wait(20 * SECOND);
+ assert_eq!(before_ready, Vec::<&str>::new());
+ assert_eq!(fixture.log, ["quitAndInstall(foreground)"]);
+}
+
+#[test]
+fn lets_the_machine_sleep_again_when_the_screen_is_unlocked_before_the_restart_is_due() {
+ let mut fixture = Fixture::new();
+ fixture.lock();
+ fixture.wait(LOCKED_DURATION - 20 * SECOND);
+ fixture.unlock();
+ fixture.wait(60 * MINUTE);
+ assert_eq!(fixture.log, ["keepAwake", "allowSleep"]);
+}
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index 380af56f2fe..1267c5f5f5e 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -247,7 +247,7 @@ mod text_input;
mod timeline_view;
mod title_bar_actions;
mod type_navigation;
-mod unattended_restart;
+pub(crate) mod unattended_restart;
mod unicode_highlight;
mod unusual_line_terminators;
pub(crate) mod scm_actions;
diff --git a/port/ledger.md b/port/ledger.md
index 5e92f88ef7b..67bad782872 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -408,7 +408,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/services/languageDetection | workbench service | M13 | verified | | language_detection.rs (languageDetectionWebWorker.ts `detectLanguagesImpl`, `adjustLanguageConfidence`, the 10000 char sample) and workbench/language_detection.rs (`LanguageDetectionWorkerClient`: the file name guess first, then @vscode/vscode-languagedetection 1.0.23 with its model in a Bun worker from the app's node_modules, model ids mapped as `getLanguageId`; `autoDetectLanguage` of textEditorModel.ts for untitled models and extensionless plain text files, 600 ms throttle, skipped after an explicit language and with `workbench.editor.languageDetection` off): cargo test -p app language_detection (the worker test runs the real model). The history biases only feed the regexp model, which 1.147.0 does not ship (`vscode-regexp-languagedetection` is not a dependency), so neither side has it; no telemetry |
| workbench/services/languageStatus | workbench service | M13 | verified | | `$setLanguageStatus` / `$removeLanguageStatus`, statuses matched by selector, ordered by severity, source, id (workbench/language_status.rs): cargo test -p app language_status |
| workbench/services/layout | workbench service | M11 | ported | [3 L] editor_status.rs:606, content_hover.rs:498: no workbench-wide Tab order (the browser's DOM order): Tab stops at the content hover's ends, and Tab on the status bar in Tab Focus Mode keeps the focus (port/notes.md Toggle Tab Key Moves Focus) <br> [3 L] workbench.rs:591: the Workbench is one GPUI view, so every scroll frame of any list renders and lays out every part again, where upstream's DOM updates only the scrolled list; `scroll_frame_time` median / p95 at 42d10fe2347: Explorer 11.5 / 15.7 ms, Editor 18.0 / 19.2 to 42.0 ms, Settings 12.4 / 16.8 ms over the 8 ms gate (Extensions 2.8 / 3.0 meets it); per frame taffy lays out the whole workbench (6.6 ms of the Explorer frame), each `key_context` caller clones every `config.*` key (keyboard.rs:400), the menubar and the timeline toolbar are rebuilt; the next step is the part-entity split, side bar first (port/notes.md Scroll frame costs, cheap steps). GUI (Studio at load 33 to 57, 60 Hz display, 690 trackpad events in 7 s): main thread in `Window::draw` 86% scrolling the Explorer (800 files), 89% the Extensions @builtin list (port/notes.md Scroll frame costs) | layout.ts as a split-view tree (workbench/layout.rs): panel position (bottom, top, left, right) and alignment, primary side bar left or right, maximized panel with `panelMaximizationSupportedWhen`, hidden parts, persisted sizes and positions; zen mode (zen_mode.rs) with its settings and restore; centered layout (centered_layout.rs) with its sashes and stored margins; View > Appearance entries and the Panel Position and Align Panel submenus (cargo test -p app -- layout part_grid centered_layout zen_mode); layoutActions.ts Customize Layout quick pick (workbench/customize_layout.rs) with live items, Restore Defaults and Close, Toggle Activity Bar Visibility, Align Quick Input Top/Center (cargo test -p app -- customize_layout toggling_the_activity_bar; ui-pair m11/manage-menu.json, port/results/manage-menu.md; missing until then though the title bar showed its button); ui-pair layout-positions.json and layout-zen.json against the reference (port/results/layout.md). The pairs run with `zenMode.fullScreen` off. Maximize Secondary Side Bar (`workbench.action.maximizeAuxiliaryBar`, `restoreAuxiliaryBar`, `toggleMaximizedAuxiliaryBar`, the title's toggle) hides the other parts and restores them (workbench/panel.rs; cargo test -p app -- maximizing_the_secondary_side_bar_hides_the_other_parts_and_restore_brings_them_back). Zen mode enforces `zenMode.showTabs` on the main editor part until it ends (layout.ts `toggleZenMode` `enforcePartOptions`; workbench/zen_mode.rs `editor_show_tabs`; cargo test -p app -- show_tabs_picks_the_title_control_and_zen_mode_enforces_its_own); navigationActions.ts `workbench.action.focusNextPart`/`focusPreviousPart` (F6, Shift+F6) walk editor, panel, auxiliary bar, status bar, activity bar and side bar past the hidden ones with layout.ts `focusPart` (the pane container's first expanded view; workbench/part_navigation.rs; cargo test -p app f6_walks_the_visible_parts); in an editor window F6 goes between its editor and its own status bar, whose entry focus is kept per window (workbench/auxiliary_windows.rs `auxiliary_status_bar`, workbench/status_entries.rs; cargo test -p app f6_in_an_editor_window_reaches_its_own_status_bar) |
-| workbench/services/lifecycle | workbench service | M11 | ported | [3 L] unattendedRestart.ts: the editor detail names the scheme where upstream names `typeId`, `workbench.floatingWindowNotRestorable` cannot occur (the port's auxiliary windows are all editor parts), and nothing calls `can_restart_unattended` yet: platform/update's `UnattendedRestartScheduler` (restart to update while the screen is locked, with `update.restartWhenIdle` on), `quitAndInstall` with `unattended` and windowsStateHandler.ts `setNextExactRestore` are not ported <br> [3 S] terminal/pty.rs:95: `hasChildProcesses` is a foreground process group other than the shell's, so a background job (`cmd &`) does not block the restart where upstream's childProcessMonitor.ts sees it | workbench/lifecycle.rs: ShutdownReason, onBeforeShutdown vetoes on quit, close button, closeWindow, reload and load (`window.confirmBeforeClose`, backup tracker auto save, hot exit, showSaveConfirm); cargo test -p app lifecycle; no phases or onWillShutdown joiners; workbench/unattended_restart.rs: `canRestartUnattended` with its blocker aggregation and change log, and the participants `workbench.starting` (2.5 s after restore), dialog, quick input, transient workspace, modal editor, editors not restored or not restorable, `debug.sessionActive`, `tasks.running`, the backup tracker's `workingCopy.*` and `cli.waitingForEditorClose`, terminalUnattendedRestart.ts, testingUnattendedRestart.ts, `testing.continuousRun`, webviewUnattendedRestart.ts and notebookUnattendedRestart.ts: cargo test -p app unattended_restart (unattendedRestart.test.ts, terminalUnattendedRestart.test.ts, testingUnattendedRestart.test.ts); verified: cargo test -p app backup_tracker lifecycle (workingCopyBackupTracker.test.ts); ui-pair hot-exit.json `dirty`, `restored` vs the reference (port/results/windows.md, milestone 11 verification) |
+| workbench/services/lifecycle | workbench service | M11 | ported | [3 L] unattendedRestart.ts: the editor detail names the scheme where upstream names `typeId`, `workbench.floatingWindowNotRestorable` cannot occur (the port's auxiliary windows are all editor parts), and nothing calls `can_restart_unattended` or update/unattended_restart.rs yet: the scheduler is not wired to the power events, its timers, the keep-awake `powerSaveBlocker`, the update service's state and the windows' readiness, and `getWindowBlockers`, `hasArgumentsLostOnRelaunch`, the remembered failed update (`update.unattendedRestartFailedUpdate`), `quitAndInstall` with `unattended`, `relaunchInBackground` and its cancellation token, and windowsStateHandler.ts `setNextExactRestore` are not ported <br> [3 S] terminal/pty.rs:95: `hasChildProcesses` is a foreground process group other than the shell's, so a background job (`cmd &`) does not block the restart where upstream's childProcessMonitor.ts sees it | workbench/lifecycle.rs: ShutdownReason, onBeforeShutdown vetoes on quit, close button, closeWindow, reload and load (`window.confirmBeforeClose`, backup tracker auto save, hot exit, showSaveConfirm); cargo test -p app lifecycle; no phases or onWillShutdown joiners; workbench/unattended_restart.rs: `canRestartUnattended` with its blocker aggregation and change log, and the participants `workbench.starting` (2.5 s after restore), dialog, quick input, transient workspace, modal editor, editors not restored or not restorable, `debug.sessionActive`, `tasks.running`, the backup tracker's `workingCopy.*` and `cli.waitingForEditorClose`, terminalUnattendedRestart.ts, testingUnattendedRestart.ts, `testing.continuousRun`, webviewUnattendedRestart.ts and notebookUnattendedRestart.ts: cargo test -p app unattended_restart (unattendedRestart.test.ts, terminalUnattendedRestart.test.ts, testingUnattendedRestart.test.ts); update/unattended_restart.rs: unattendedRestartScheduler.ts's decisions (keep awake from the lock, restart once locked a minute, retry every minute, veto, a newer update postponing, battery and thermal pressure, resume restarting the clock, the update not installed last time) over injected time: cargo test -p app update::unattended_restart (13 of unattendedRestartScheduler.test.ts's cases, without the telemetry outcomes the port does not send); verified: cargo test -p app backup_tracker lifecycle (workingCopyBackupTracker.test.ts); ui-pair hot-exit.json `dirty`, `restored` vs the reference (port/results/windows.md, milestone 11 verification) |
| workbench/services/localTranscription | workbench service | | removed | | no AI or Microsoft services by decision (port/notes.md); API stays inert |
| workbench/services/localization | workbench service | M18 | verified | | ui-pair port/fixtures/extensions/ui-display-language.json: picking Deutsch installs MS-CEINTL.vscode-language-pack-de with the "Installing Deutsch language support..." progress and asks "Restart VSRustium to switch to Deutsch?"; localeService.ts: argv.json `locale` written and cleared, restart dialog, install of an MS-CEINTL pack: cargo test -p app nls localization; Command Palette titles, categories and descriptions translate by the reference call's module and key (port/tools/ref-commands with ref-nls-clone.ts; cargo test -p app a_palette_title_two_modules), menu bar items, side bar titles and pane headers by the reference's `nlsKeys` per menu, view and container (cargo test -p app menu_bar_items_and_view_titles_resolve_per_scope); other surfaces stay English (port/notes.md) |
| workbench/services/log | workbench service | M6 | verified | | output/log_levels.rs: defaultLogLevels.ts argv.json `log-level` read and write, `getDefaultLogLevel`, `parseLogLevel`; logs_actions.rs `setDefaultLogLevel` (cargo test -p app set_default_log_level_writes_argv, reads_and_writes_argv_log_levels); the Window log as logConstants.ts `windowLogId`; electron-browser logService.ts in a test run: the host console reaches stdout/stderr through the session; output/log_levels.rs: defaultLogLevels.ts argv.json `log-level` read and write, `getDefaultLogLevel`, `parseLogLevel`; logs_actions.rs `setDefaultLogLevel` (cargo test -p app set_default_log_level_writes_argv, reads_and_writes_argv_log_levels); the Window log as logConstants.ts `windowLogId` |