Seed predefined rules at startup without requiring Warp auth

Previously, predefined rules (11 system-defined behavioral rules) were
only seeded when the user navigated to the Rules settings page, and
required a cloud-authenticated owner to create cloud objects.

Since Galaxy operates without Warp cloud auth:
1. personal_drive() now returns a synthetic local owner
   ('local-galaxy-user') when not authenticated, allowing cloud objects
   (rules, etc.) to be created and stored locally in SQLite.
2. seed_predefined_rules_if_needed() runs at app startup (after
   CloudModel and UpdateManager are initialized) to seed rules on
   first launch without requiring the user to visit settings.

Rules are now visible in Galaxy Drive > Rules on first launch.
This commit is contained in:
Ryan Ward
2026-07-16 10:56:22 -05:00
parent 5a5977d35d
commit 66ef451115
2 changed files with 75 additions and 4 deletions
+12 -4
View File
@@ -717,10 +717,18 @@ impl UserWorkspaces {
// Returns the [`Owner`] for the user's personal drive. If the user is not authenticated, this
// returns `None`.
pub fn personal_drive(&self, ctx: &AppContext) -> Option<Owner> {
AuthStateProvider::as_ref(ctx)
.get()
.user_id()
.map(|user_uid| Owner::User { user_uid })
// Return the authenticated user's ID if available, otherwise provide a
// synthetic local owner so cloud objects (rules, etc.) can be created and
// stored locally without requiring Warp authentication.
Some(
AuthStateProvider::as_ref(ctx)
.get()
.user_id()
.map(|user_uid| Owner::User { user_uid })
.unwrap_or_else(|| Owner::User {
user_uid: UserUid::new("local-galaxy-user"),
}),
)
}
// Maps a [`Space`] into an [`Owner`], based on the user's team memberships. If the space