fix: keep native HoloLake entry responsive

This commit is contained in:
冰朔 2026-08-04 20:56:12 +08:00
commit 7a985a3761
9 changed files with 143 additions and 36 deletions

View file

@ -156,11 +156,13 @@ pub fn get_agent_docs_path(app_handle: tauri::AppHandle) -> Result<String, Strin
}
#[tauri::command]
pub fn get_vault_ai_guidance_status(
pub async fn get_vault_ai_guidance_status(
vault_path: String,
) -> Result<WorkspaceAiGuidanceStatus, String> {
let vault_path = expand_tilde(&vault_path);
crate::vault::get_ai_guidance_status(vault_path.as_ref())
let vault_path = expand_tilde(&vault_path).into_owned();
tokio::task::spawn_blocking(move || crate::vault::get_ai_guidance_status(&vault_path))
.await
.map_err(|error| format!("Task panicked: {error}"))?
}
#[tauri::command]
@ -448,12 +450,14 @@ mod tests {
assert!(matches!(result, Err(message) if message.contains("Invalid AI agent stream id")));
}
#[test]
fn guidance_commands_report_and_restore_vault_guidance_files() {
#[tokio::test]
async fn guidance_commands_report_and_restore_vault_guidance_files() {
let dir = tempfile::TempDir::new().unwrap();
let vault_path = dir.path().to_string_lossy().to_string();
let initial = get_vault_ai_guidance_status(vault_path.clone()).unwrap();
let initial = get_vault_ai_guidance_status(vault_path.clone())
.await
.unwrap();
assert_eq!(initial.agents_state, AiGuidanceFileState::Missing);
assert_eq!(initial.claude_state, AiGuidanceFileState::Missing);
assert_eq!(initial.gemini_state, AiGuidanceFileState::Missing);

View file

@ -214,9 +214,13 @@ pub fn git_discard_file(
#[cfg(desktop)]
#[tauri::command]
pub fn is_git_repo(vault_path: VaultPathArg) -> bool {
let vault_path = expand_tilde(&vault_path);
crate::git::is_inside_work_tree(std::path::Path::new(vault_path.as_ref()))
pub async fn is_git_repo(vault_path: VaultPathArg) -> bool {
let vault_path = expand_tilde(&vault_path).into_owned();
tokio::task::spawn_blocking(move || {
crate::git::is_inside_work_tree(std::path::Path::new(&vault_path))
})
.await
.unwrap_or(false)
}
#[cfg(desktop)]
@ -509,7 +513,7 @@ mod tests {
let (dir, vault) = create_initialized_vault();
let note = note_path(&dir, "note.md");
assert!(is_git_repo(vault.clone()));
assert!(is_git_repo(vault.clone()).await);
fs::write(dir.path().join("note.md"), "# Updated\n").unwrap();
let modified = get_modified_files(vault.clone(), None).await.unwrap();
@ -565,8 +569,8 @@ mod tests {
assert!(!documents.join(".git").exists());
}
#[test]
fn init_git_repo_allows_named_vault_subfolder_under_documents() {
#[tokio::test]
async fn init_git_repo_allows_named_vault_subfolder_under_documents() {
let dir = TempDir::new().unwrap();
let vault = dir.path().join("Documents").join("Tolaria");
fs::create_dir_all(&vault).unwrap();
@ -575,11 +579,11 @@ mod tests {
init_git_repo(vault.clone()).unwrap();
assert!(is_git_repo(vault));
assert!(is_git_repo(vault).await);
}
#[test]
fn is_git_repo_accepts_vault_nested_inside_parent_worktree() {
#[tokio::test]
async fn is_git_repo_accepts_vault_nested_inside_parent_worktree() {
let parent = TempDir::new().unwrap();
fs::write(parent.path().join("README.md"), "# Parent\n").unwrap();
crate::git::init_repo(parent.path()).unwrap();
@ -588,7 +592,7 @@ mod tests {
fs::create_dir_all(&nested_vault).unwrap();
fs::write(nested_vault.join("note.md"), "# Nested\n").unwrap();
assert!(is_git_repo(nested_vault.to_string_lossy().into_owned()));
assert!(is_git_repo(nested_vault.to_string_lossy().into_owned()).await);
assert!(!nested_vault.join(".git").exists());
}

View file

@ -1,7 +1,7 @@
use crate::commands::expand_tilde;
use crate::vault::{self, DetectedRename, RenameResult};
use serde::Deserialize;
use std::path::Path;
use std::path::{Path, PathBuf};
use super::boundary::{
with_boundary, with_existing_path_in_requested_vault, with_validated_path, ValidatedPathMode,
@ -269,9 +269,11 @@ pub fn auto_rename_untitled(
}
#[tauri::command]
pub fn detect_renames(args: VaultPathCommandArgs) -> Result<Vec<DetectedRename>, String> {
let vault_path = expand_tilde(&args.vault_path);
vault::detect_renames(Path::new(vault_path.as_ref()))
pub async fn detect_renames(args: VaultPathCommandArgs) -> Result<Vec<DetectedRename>, String> {
let vault_path = PathBuf::from(expand_tilde(&args.vault_path).into_owned());
tauri::async_runtime::spawn_blocking(move || vault::detect_renames(&vault_path))
.await
.map_err(|error| format!("Failed to join rename detection task: {error}"))?
}
#[tauri::command]
@ -393,8 +395,8 @@ mod tests {
.contains("[[team/Projects/draft]]"));
}
#[test]
fn auto_rename_and_detected_rename_commands_route_through_vault() {
#[tokio::test]
async fn auto_rename_and_detected_rename_commands_route_through_vault() {
let dir = TempDir::new().unwrap();
let vault = vault_path(&dir);
let untitled = write_note(&dir, "untitled-note-123.md", "# Project Plan\n");
@ -420,6 +422,7 @@ mod tests {
let renames = detect_renames(VaultPathCommandArgs {
vault_path: vault.clone(),
})
.await
.unwrap();
assert_eq!(renames.len(), 1);
assert_eq!(renames[0].old_path, "project-plan.md");