feat: add memory system activity display

Implements issue #118 to display auto-memory system operations and
provide a browser for viewing memory files.

Backend changes:
- Detect memory file operations in format_tool_description()
- Add emoji icons (📝/💾) for memory Read/Write/Edit operations
- Add list_memory_files() Tauri command to find all memory files
- Add 4 new tests for memory detection logic
- Update Tauri capabilities to allow reading .claude directory

Frontend changes:
- Create MemoryBrowserPanel component with file list and viewer
- Add memory panel to main app layout
- Support Markdown rendering of memory file contents
- Add loading states and error handling

Testing:
- All 354 Rust tests passing
- TypeScript type-checks pass

Co-Authored-By: Hikari <hikari@nhcarrigan.com>
This commit is contained in:
2026-02-07 12:01:31 -08:00
committed by Naomi Carrigan
parent e40ae989f7
commit 89e99b1524
7 changed files with 606 additions and 4 deletions
+1 -1
View File
@@ -1636,7 +1636,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hikari-desktop"
version = "1.3.0"
version = "1.4.0"
dependencies = [
"chrono",
"dirs 5.0.1",
+12
View File
@@ -28,6 +28,18 @@
"identifier": "fs:allow-write-file",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:scope",
"allow": [
{ "path": "$HOME/.claude/**" }
]
},
{
"identifier": "fs:allow-read-text-file",
"allow": [
{ "path": "$HOME/.claude/**" }
]
},
"core:window:allow-set-size",
"core:window:allow-set-always-on-top",
"core:window:allow-inner-size",
+70
View File
@@ -1167,6 +1167,76 @@ pub async fn close_application(app_handle: AppHandle) -> Result<(), String> {
Ok(())
}
#[derive(serde::Serialize)]
pub struct MemoryFilesResponse {
pub files: Vec<String>,
}
#[tauri::command]
pub async fn list_memory_files() -> Result<MemoryFilesResponse, String> {
use std::fs;
// Get the .claude directory in the user's home
let home_dir = match dirs::home_dir() {
Some(dir) => dir,
None => return Err("Could not find home directory".to_string()),
};
let claude_dir = home_dir.join(".claude");
let projects_dir = claude_dir.join("projects");
if !projects_dir.exists() {
return Ok(MemoryFilesResponse { files: Vec::new() });
}
let mut memory_files = Vec::new();
// Recursively find all memory directories
fn find_memory_files(dir: &std::path::Path, files: &mut Vec<String>) -> std::io::Result<()> {
if !dir.is_dir() {
return Ok(());
}
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
// Check if this is a "memory" directory
if path.file_name().and_then(|n| n.to_str()) == Some("memory") {
// List all files in the memory directory
for mem_entry in fs::read_dir(&path)? {
let mem_entry = mem_entry?;
let mem_path = mem_entry.path();
if mem_path.is_file() {
if let Some(path_str) = mem_path.to_str() {
files.push(path_str.to_string());
}
}
}
} else {
// Recurse into subdirectories
find_memory_files(&path, files)?;
}
}
}
Ok(())
}
if let Err(e) = find_memory_files(&projects_dir, &mut memory_files) {
return Err(format!("Failed to list memory files: {}", e));
}
// Sort files alphabetically
memory_files.sort();
Ok(MemoryFilesResponse {
files: memory_files,
})
}
#[cfg(test)]
mod tests {
use super::*;
+1
View File
@@ -197,6 +197,7 @@ pub fn run() {
stop_discord_rpc,
log_discord_rpc,
close_application,
list_memory_files,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
+64 -3
View File
@@ -1505,10 +1505,21 @@ fn get_tool_state(tool_name: &str) -> CharacterState {
}
fn format_tool_description(name: &str, input: &serde_json::Value) -> String {
// Helper function to check if a path is a memory file
fn is_memory_path(path: &str) -> bool {
path.contains("/.claude/") && (path.contains("/memory/") || path.ends_with("/MEMORY.md"))
}
match name {
"Read" => {
if let Some(path) = input.get("file_path").and_then(|v| v.as_str()) {
format!("Reading file: {}", path)
if is_memory_path(path) {
// Extract just the filename for cleaner display
let filename = path.split('/').last().unwrap_or(path);
format!("📝 Reading memory: {}", filename)
} else {
format!("Reading file: {}", path)
}
} else {
"Reading file...".to_string()
}
@@ -1527,9 +1538,26 @@ fn format_tool_description(name: &str, input: &serde_json::Value) -> String {
"Searching in files...".to_string()
}
}
"Edit" | "Write" => {
"Edit" => {
if let Some(path) = input.get("file_path").and_then(|v| v.as_str()) {
format!("Editing: {}", path)
if is_memory_path(path) {
let filename = path.split('/').last().unwrap_or(path);
format!("💾 Updating memory: {}", filename)
} else {
format!("Editing: {}", path)
}
} else {
"Editing file...".to_string()
}
}
"Write" => {
if let Some(path) = input.get("file_path").and_then(|v| v.as_str()) {
if is_memory_path(path) {
let filename = path.split('/').last().unwrap_or(path);
format!("💾 Writing memory: {}", filename)
} else {
format!("Editing: {}", path)
}
} else {
"Editing file...".to_string()
}
@@ -1714,6 +1742,39 @@ mod tests {
assert_eq!(desc, "Using tool: CustomTool");
}
#[test]
fn test_format_tool_description_memory_read() {
let input =
serde_json::json!({"file_path": "/home/user/.claude/projects/test/memory/MEMORY.md"});
let desc = format_tool_description("Read", &input);
assert_eq!(desc, "📝 Reading memory: MEMORY.md");
}
#[test]
fn test_format_tool_description_memory_write() {
let input = serde_json::json!(
{"file_path": "/home/user/.claude/projects/test/memory/notes.md"}
);
let desc = format_tool_description("Write", &input);
assert_eq!(desc, "💾 Writing memory: notes.md");
}
#[test]
fn test_format_tool_description_memory_edit() {
let input = serde_json::json!(
{"file_path": "/home/user/.claude/projects/test/memory/patterns.md"}
);
let desc = format_tool_description("Edit", &input);
assert_eq!(desc, "💾 Updating memory: patterns.md");
}
#[test]
fn test_format_tool_description_non_memory_read() {
let input = serde_json::json!({"file_path": "/home/user/code/test.txt"});
let desc = format_tool_description("Read", &input);
assert_eq!(desc, "Reading file: /home/user/code/test.txt");
}
#[test]
fn test_wsl_bridge_new() {
let bridge = WslBridge::new();
@@ -0,0 +1,456 @@
<script lang="ts">
import { onMount } from "svelte";
import { invoke } from "@tauri-apps/api/core";
import { readTextFile } from "@tauri-apps/plugin-fs";
import Markdown from "./Markdown.svelte";
let memoryFiles: string[] = $state([]);
let selectedFile: string | null = $state(null);
let fileContent: string = $state("");
let isLoading = $state(false);
let error: string | null = $state(null);
let isPanelOpen = $state(false);
interface MemoryFilesResponse {
files: string[];
}
async function loadMemoryFiles() {
isLoading = true;
error = null;
try {
const response = await invoke<MemoryFilesResponse>("list_memory_files");
memoryFiles = response.files;
} catch (e) {
error = `Failed to load memory files: ${e}`;
console.error(error);
} finally {
isLoading = false;
}
}
async function loadFileContent(filePath: string) {
isLoading = true;
error = null;
try {
const content = await readTextFile(filePath);
fileContent = content;
selectedFile = filePath;
} catch (e) {
error = `Failed to read file: ${e}`;
console.error(error);
fileContent = "";
} finally {
isLoading = false;
}
}
function getFileName(path: string): string {
return path.split("/").pop() || path;
}
function togglePanel() {
isPanelOpen = !isPanelOpen;
if (isPanelOpen && memoryFiles.length === 0) {
loadMemoryFiles();
}
}
onMount(() => {
// Don't load on mount - only when panel is opened
});
</script>
<button class="memory-toggle" onclick={togglePanel} title="Memory Browser">
<svg
class="icon"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
/>
</svg>
<span class="label">Memory</span>
</button>
{#if isPanelOpen}
<div class="memory-panel">
<div class="panel-header">
<div class="header-title">
<svg
class="header-icon"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
/>
</svg>
<h3>Memory Files</h3>
</div>
<button class="close-btn" onclick={togglePanel} title="Close">
<svg
class="close-icon"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
</div>
<div class="panel-content">
{#if isLoading && memoryFiles.length === 0}
<div class="loading">
<svg
class="spinner"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
/>
</svg>
Loading memory files...
</div>
{:else if error}
<div class="error">
<p>{error}</p>
<button class="retry-btn" onclick={loadMemoryFiles}>Retry</button>
</div>
{:else if memoryFiles.length === 0}
<div class="empty">
<p>No memory files found.</p>
<p class="hint">Memory files are created automatically as I learn from our conversations!</p>
</div>
{:else}
<div class="panel-layout">
<div class="file-list">
{#each memoryFiles as file}
<button
class="file-item"
class:active={selectedFile === file}
onclick={() => loadFileContent(file)}
>
<svg
class="file-icon"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
/>
</svg>
<span class="file-name">{getFileName(file)}</span>
</button>
{/each}
</div>
<div class="file-viewer">
{#if selectedFile && fileContent}
<div class="viewer-header">
<h4>{getFileName(selectedFile)}</h4>
</div>
<div class="viewer-content">
<Markdown content={fileContent} />
</div>
{:else if selectedFile && isLoading}
<div class="loading-file">
<svg
class="spinner"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
/>
</svg>
Loading file...
</div>
{:else}
<div class="no-selection">
<p>Select a memory file to view its contents</p>
</div>
{/if}
</div>
</div>
{/if}
</div>
</div>
{/if}
<style>
.memory-toggle {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 8px;
color: var(--text-primary);
cursor: pointer;
transition: all 0.2s ease;
}
.memory-toggle:hover {
background: var(--bg-hover);
border-color: var(--accent-primary);
}
.icon {
width: 1.25rem;
height: 1.25rem;
}
.label {
font-size: 0.875rem;
font-weight: 500;
}
.memory-panel {
position: fixed;
top: 0;
right: 0;
width: 600px;
height: 100vh;
background: var(--bg-primary);
border-left: 1px solid var(--border-color);
box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
z-index: 1000;
display: flex;
flex-direction: column;
}
.panel-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
border-bottom: 1px solid var(--border-color);
background: var(--bg-secondary);
}
.header-title {
display: flex;
align-items: center;
gap: 0.75rem;
}
.header-icon {
width: 1.5rem;
height: 1.5rem;
color: var(--accent-primary);
}
.panel-header h3 {
margin: 0;
font-size: 1.125rem;
font-weight: 600;
color: var(--text-primary);
}
.close-btn {
padding: 0.5rem;
background: transparent;
border: none;
color: var(--text-secondary);
cursor: pointer;
border-radius: 4px;
transition: all 0.2s ease;
}
.close-btn:hover {
background: var(--bg-hover);
color: var(--text-primary);
}
.close-icon {
width: 1.25rem;
height: 1.25rem;
}
.panel-content {
flex: 1;
overflow-y: auto;
padding: 1.5rem;
}
.loading,
.error,
.empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
padding: 3rem 1.5rem;
text-align: center;
color: var(--text-secondary);
}
.spinner {
width: 2.5rem;
height: 2.5rem;
animation: spin 1s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.error p {
color: var(--terminal-error, #f87171);
}
.retry-btn {
padding: 0.5rem 1rem;
background: var(--accent-primary);
border: none;
border-radius: 6px;
color: white;
cursor: pointer;
font-weight: 500;
transition: all 0.2s ease;
}
.retry-btn:hover {
opacity: 0.9;
}
.hint {
font-size: 0.875rem;
font-style: italic;
max-width: 400px;
}
.panel-layout {
display: grid;
grid-template-columns: 200px 1fr;
gap: 1.5rem;
height: 100%;
}
.file-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.file-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 8px;
color: var(--text-primary);
cursor: pointer;
text-align: left;
transition: all 0.2s ease;
}
.file-item:hover {
background: var(--bg-hover);
border-color: var(--accent-primary);
}
.file-item.active {
background: var(--accent-primary);
border-color: var(--accent-primary);
color: white;
}
.file-icon {
width: 1.25rem;
height: 1.25rem;
flex-shrink: 0;
}
.file-name {
font-size: 0.875rem;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-viewer {
display: flex;
flex-direction: column;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 8px;
overflow: hidden;
}
.viewer-header {
padding: 1rem 1.5rem;
border-bottom: 1px solid var(--border-color);
background: var(--bg-primary);
}
.viewer-header h4 {
margin: 0;
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
}
.viewer-content {
flex: 1;
padding: 1.5rem;
overflow-y: auto;
color: var(--text-primary);
}
.loading-file,
.no-selection {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
padding: 3rem 1.5rem;
color: var(--text-secondary);
}
</style>
+2
View File
@@ -33,6 +33,7 @@
import AchievementsPanel from "$lib/components/AchievementsPanel.svelte";
import UpdateNotification from "$lib/components/UpdateNotification.svelte";
import CloseAppConfirmModal from "$lib/components/CloseAppConfirmModal.svelte";
import MemoryBrowserPanel from "$lib/components/MemoryBrowserPanel.svelte";
import { debugConsoleStore } from "$lib/stores/debugConsole";
let initialized = false;
@@ -513,6 +514,7 @@
<PermissionModal />
<UserQuestionModal />
<ConfigSidebar />
<MemoryBrowserPanel />
<AchievementNotification />
<AchievementsPanel
bind:isOpen={achievementPanelOpen}