generated from nhcarrigan/template
fix: memory files tab empty on Windows #140
Generated
+1
-1
@@ -1636,7 +1636,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hikari-desktop"
|
name = "hikari-desktop"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
|
|||||||
@@ -1166,6 +1166,55 @@ pub struct MemoryFilesResponse {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn list_memory_files() -> Result<MemoryFilesResponse, String> {
|
pub async fn list_memory_files() -> Result<MemoryFilesResponse, String> {
|
||||||
|
// On Windows, we need to look in the WSL home directory
|
||||||
|
// On Linux/Mac, use the native home directory
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
list_memory_files_via_wsl().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
list_memory_files_native().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List memory files via WSL (for Windows)
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
async fn list_memory_files_via_wsl() -> Result<MemoryFilesResponse, String> {
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
// Use WSL to find all memory files in the WSL home directory
|
||||||
|
// This script finds all "memory" directories and lists their files
|
||||||
|
let script = r#"
|
||||||
|
find ~/.claude/projects -type d -name memory 2>/dev/null | while read dir; do
|
||||||
|
find "$dir" -maxdepth 1 -type f 2>/dev/null
|
||||||
|
done | sort
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let output = Command::new("wsl")
|
||||||
|
.args(["-e", "bash", "-l", "-c", script])
|
||||||
|
.output()
|
||||||
|
.map_err(|e| format!("Failed to execute WSL command: {}", e))?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
|
return Err(format!("Failed to list memory files: {}", stderr));
|
||||||
|
}
|
||||||
|
|
||||||
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
|
let files: Vec<String> = stdout
|
||||||
|
.lines()
|
||||||
|
.filter(|line| !line.trim().is_empty())
|
||||||
|
.map(|line| line.trim().to_string())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Ok(MemoryFilesResponse { files })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List memory files using native filesystem (for Linux/Mac)
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
async fn list_memory_files_native() -> Result<MemoryFilesResponse, String> {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
// Get the .claude directory in the user's home
|
// Get the .claude directory in the user's home
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { readTextFile } from "@tauri-apps/plugin-fs";
|
|
||||||
import Markdown from "./Markdown.svelte";
|
import Markdown from "./Markdown.svelte";
|
||||||
|
|
||||||
let memoryFiles: string[] = $state([]);
|
let memoryFiles: string[] = $state([]);
|
||||||
@@ -33,7 +32,8 @@
|
|||||||
isLoading = true;
|
isLoading = true;
|
||||||
error = null;
|
error = null;
|
||||||
try {
|
try {
|
||||||
const content = await readTextFile(filePath);
|
// Use our backend command instead of Tauri plugin to handle WSL paths
|
||||||
|
const content = await invoke<string>("read_file_content", { path: filePath });
|
||||||
fileContent = content;
|
fileContent = content;
|
||||||
selectedFile = filePath;
|
selectedFile = filePath;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user