feat(dev): support running alongside installed DBX

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-07-23 17:06:08 +08:00
1 parent 2318c48787
commit eab263d3b4
9 files changed
+197 -18

No files matched your search

+22 -3
View File
@@ -11,6 +11,16 @@ use crate::{
apply_debug_log_level, apply_desktop_settings, hide_main_window_for_close, request_app_close, CloseBehaviorState,
};
const DEVELOPMENT_OPEN_TABS_STATE_KEY: &str = "development_open_tabs";
fn open_tabs_state_key(debug_build: bool) -> &'static str {
if debug_build {
DEVELOPMENT_OPEN_TABS_STATE_KEY
} else {
"open_tabs"
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct DriverStoreMigrationResult {
pub driver_store_dir: Option<String>,
@@ -115,12 +125,12 @@ pub async fn save_editor_settings(state: State<'_, Arc<AppState>>, settings: ser
#[tauri::command]
pub async fn load_open_tabs_state(state: State<'_, Arc<AppState>>) -> Result<Option<serde_json::Value>, String> {
state.storage.load_open_tabs_state().await
state.storage.load_open_tabs_state_with_key(open_tabs_state_key(cfg!(debug_assertions))).await
}
#[tauri::command]
pub async fn save_open_tabs_state(state: State<'_, Arc<AppState>>, payload: serde_json::Value) -> Result<(), String> {
state.storage.save_open_tabs_state(&payload).await
state.storage.save_open_tabs_state_with_key(open_tabs_state_key(cfg!(debug_assertions)), &payload).await
}
#[tauri::command]
@@ -481,7 +491,10 @@ fn load_native_debug_logs_from_dir(log_dir: PathBuf) -> Result<String, String> {
#[cfg(test)]
mod tests {
use super::{driver_store_migration_result, resolve_driver_store_dirs_from_settings, DesktopSettings};
use super::{
driver_store_migration_result, open_tabs_state_key, resolve_driver_store_dirs_from_settings, DesktopSettings,
DEVELOPMENT_OPEN_TABS_STATE_KEY,
};
use std::path::PathBuf;
#[test]
@@ -548,6 +561,12 @@ mod tests {
assert_eq!(agents_dir, Some(PathBuf::from(path("D:/develop/DBX/agents"))));
}
#[test]
fn isolates_open_tabs_for_development_builds() {
assert_eq!(open_tabs_state_key(true), DEVELOPMENT_OPEN_TABS_STATE_KEY);
assert_eq!(open_tabs_state_key(false), "open_tabs");
}
fn path(value: &str) -> String {
value.replace('/', std::path::MAIN_SEPARATOR_STR)
}