Skip to content

Commit 16bcb58

Browse files
committed
Fix project recovery and integrate the desktop menus
Accept OneDrive placeholders for managed projects and register .align on Windows. Keep startup cleanup responsive, preserve folder relinks when reopening projects, and make project commands safe during recovery. Integrate autosave and cache controls with the desktop sidebar.
1 parent d7b6ae5 commit 16bcb58

14 files changed

Lines changed: 621 additions & 142 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/align-gpui/Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ align-cli = { path = "../align-cli" }
3535

3636
[target.'cfg(windows)'.dependencies]
3737
velopack = "1.2.0"
38+
winreg = "0.55"
3839
windows-sys = { version = "0.59", features = [
3940
"Wdk_System_SystemServices",
41+
"Win32_Storage_FileSystem",
42+
"Win32_System_SystemServices",
4043
"Win32_System_SystemInformation",
4144
"Win32_UI_WindowsAndMessaging",
45+
"Win32_UI_Shell",
4246
] }
4347

4448
[target.'cfg(windows)'.build-dependencies]

‎crates/align-gpui/src/main.rs‎

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ mod text_input;
1717
mod theme;
1818
mod updater;
1919
mod views;
20+
#[cfg(windows)]
21+
mod windows_association;
2022

2123
use align_core::CacheSettings;
2224
use gpui::{
@@ -75,10 +77,7 @@ struct AppView(Entity<views::AlignApp>);
7577
impl Global for AppView {}
7678

7779
fn show_about(cx: &mut App) {
78-
let Some(view) = cx.try_global::<AppView>().map(|app| app.0.clone()) else {
79-
return;
80-
};
81-
view.update(cx, |this, cx| {
80+
update_view(cx, |this, cx| {
8281
this.data.show_about = true;
8382
cx.notify();
8483
});
@@ -99,10 +98,7 @@ fn show_agent_setup(cx: &mut App) {
9998
}
10099

101100
fn clear_analysis_cache(cx: &mut App) {
102-
let Some(view) = cx.try_global::<AppView>().map(|app| app.0.clone()) else {
103-
return;
104-
};
105-
view.update(cx, |this, cx| {
101+
update_view(cx, |this, cx| {
106102
if this.data.has_active_job() {
107103
this.set_analysis_cache_status(
108104
"Wait for the current operation before clearing the cache.".into(),
@@ -155,30 +151,30 @@ fn clear_current_analysis_cache(cx: &mut App) {
155151
}
156152

157153
fn set_cache_retention(days: Option<u64>, cx: &mut App) {
158-
let mut settings = CacheSettings::load();
159-
settings.retention_days = days;
160-
let status = match settings.save() {
161-
Ok(()) => match days {
162-
Some(days) => format!("Analysis cache retention set to {days} days."),
163-
None => "Analysis cache retention set to Keep Until Cleared.".into(),
164-
},
165-
Err(error) => format!("Could not save analysis cache settings: {error}"),
166-
};
167154
update_view(cx, |this, cx| {
155+
let mut settings = CacheSettings::load();
156+
settings.retention_days = days;
157+
let status = match settings.save() {
158+
Ok(()) => match days {
159+
Some(days) => format!("Analysis cache retention set to {days} days."),
160+
None => "Analysis cache retention set to Keep Until Cleared.".into(),
161+
},
162+
Err(error) => format!("Could not save analysis cache settings: {error}"),
163+
};
168164
this.refresh_project_menus(cx);
169165
this.set_analysis_cache_status(status, cx);
170166
});
171167
}
172168

173169
fn toggle_analysis_cache(cx: &mut App) {
174-
let mut settings = CacheSettings::load();
175-
settings.enabled = !settings.enabled;
176-
let status = match settings.save() {
177-
Ok(()) if settings.enabled => "On-disk analysis cache enabled for new runs.".into(),
178-
Ok(()) => "On-disk analysis cache disabled for new runs.".into(),
179-
Err(error) => format!("Could not save analysis cache settings: {error}"),
180-
};
181170
update_view(cx, |this, cx| {
171+
let mut settings = CacheSettings::load();
172+
settings.enabled = !settings.enabled;
173+
let status = match settings.save() {
174+
Ok(()) if settings.enabled => "On-disk analysis cache enabled for new runs.".into(),
175+
Ok(()) => "On-disk analysis cache disabled for new runs.".into(),
176+
Err(error) => format!("Could not save analysis cache settings: {error}"),
177+
};
182178
this.refresh_project_menus(cx);
183179
this.set_analysis_cache_status(status, cx);
184180
});
@@ -191,12 +187,16 @@ fn update_view(
191187
let Some(view) = cx.try_global::<AppView>().map(|app| app.0.clone()) else {
192188
return;
193189
};
194-
view.update(cx, update);
190+
view.update(cx, |view, cx| {
191+
if !view.project_busy() {
192+
update(view, cx);
193+
}
194+
});
195195
}
196196

197197
fn set_appearance(appearance: theme::AppearancePreference, cx: &mut App) {
198-
appearance.save();
199198
update_view(cx, |this, cx| {
199+
appearance.save();
200200
this.data.appearance = appearance;
201201
this.refresh_project_menus(cx);
202202
cx.notify();
@@ -292,10 +292,38 @@ fn app_menus(
292292
MenuItem::action("Clear Current Project", ClearCurrentAnalysisCache),
293293
MenuItem::action("Clear All", ClearAnalysisCache),
294294
MenuItem::separator(),
295-
MenuItem::action(if cache.retention_days == Some(7) { "✓ Keep for 7 Days" } else { "Keep for 7 Days" }, KeepAnalysisCache7Days),
296-
MenuItem::action(if cache.retention_days == Some(30) { "✓ Keep for 30 Days" } else { "Keep for 30 Days" }, KeepAnalysisCache30Days),
297-
MenuItem::action(if cache.retention_days == Some(90) { "✓ Keep for 90 Days" } else { "Keep for 90 Days" }, KeepAnalysisCache90Days),
298-
MenuItem::action(if cache.retention_days == None { "✓ Keep Until Cleared" } else { "Keep Until Cleared" }, KeepAnalysisCacheForever),
295+
MenuItem::action(
296+
if cache.retention_days == Some(7) {
297+
"✓ Keep for 7 Days"
298+
} else {
299+
"Keep for 7 Days"
300+
},
301+
KeepAnalysisCache7Days,
302+
),
303+
MenuItem::action(
304+
if cache.retention_days == Some(30) {
305+
"✓ Keep for 30 Days"
306+
} else {
307+
"Keep for 30 Days"
308+
},
309+
KeepAnalysisCache30Days,
310+
),
311+
MenuItem::action(
312+
if cache.retention_days == Some(90) {
313+
"✓ Keep for 90 Days"
314+
} else {
315+
"Keep for 90 Days"
316+
},
317+
KeepAnalysisCache90Days,
318+
),
319+
MenuItem::action(
320+
if cache.retention_days.is_none() {
321+
"✓ Keep Until Cleared"
322+
} else {
323+
"Keep Until Cleared"
324+
},
325+
KeepAnalysisCacheForever,
326+
),
299327
],
300328
}),
301329
],
@@ -346,7 +374,7 @@ fn main() {
346374
align_cli::main_entry();
347375
}
348376
#[cfg(windows)]
349-
velopack::VelopackApp::build().run();
377+
windows_association::run_installer_hooks();
350378

351379
struct SessionCleanup;
352380
impl Drop for SessionCleanup {

0 commit comments

Comments
 (0)