From 7532308519a45962edaebaa38d88ed1762dc99ab Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 20 Feb 2026 10:40:58 +0800 Subject: [PATCH] fix(workspace): sort daily memory by date and inline into file grid - Sort daily memory list by filename (YYYY-MM-DD.md) instead of mtime so editing an older file no longer bumps it to the top - Move daily memory card inline with workspace MD file buttons - Shorten card description across all locales - Defer file creation until user actually saves (no empty file on create) --- src-tauri/src/commands/workspace.rs | 4 ++-- src/components/workspace/DailyMemoryPanel.tsx | 16 +++++----------- src/components/workspace/WorkspaceFilesPanel.tsx | 9 ++------- src/i18n/locales/en.json | 2 +- src/i18n/locales/ja.json | 2 +- src/i18n/locales/zh.json | 2 +- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src-tauri/src/commands/workspace.rs b/src-tauri/src/commands/workspace.rs index 25dd97d9..fe5dd5b2 100644 --- a/src-tauri/src/commands/workspace.rs +++ b/src-tauri/src/commands/workspace.rs @@ -106,8 +106,8 @@ pub async fn list_daily_memory_files() -> Result, Strin }); } - // Sort by modified_at descending (newest first) - files.sort_by(|a, b| b.modified_at.cmp(&a.modified_at)); + // Sort by filename descending (newest date first, YYYY-MM-DD.md) + files.sort_by(|a, b| b.filename.cmp(&a.filename)); Ok(files) } diff --git a/src/components/workspace/DailyMemoryPanel.tsx b/src/components/workspace/DailyMemoryPanel.tsx index 0cbe9e1a..1ab21078 100644 --- a/src/components/workspace/DailyMemoryPanel.tsx +++ b/src/components/workspace/DailyMemoryPanel.tsx @@ -100,7 +100,7 @@ const DailyMemoryPanel: React.FC = ({ [t], ); - // Create today's note + // Create today's note (deferred — file is only persisted on save) const handleCreateToday = useCallback(async () => { const filename = getTodayFilename(); // Check if already exists in the list @@ -110,16 +110,10 @@ const DailyMemoryPanel: React.FC = ({ await openFile(filename); return; } - // Create with empty content, then open - try { - await workspaceApi.writeDailyMemoryFile(filename, ""); - await loadFiles(); - await openFile(filename); - } catch (err) { - console.error("Failed to create daily memory file:", err); - toast.error(t("workspace.dailyMemory.createFailed")); - } - }, [files, openFile, loadFiles, t]); + // Open editor with empty content — no file created until user saves + setEditingFile(filename); + setContent(""); + }, [files, openFile]); // Save current file const handleSave = useCallback(async () => { diff --git a/src/components/workspace/WorkspaceFilesPanel.tsx b/src/components/workspace/WorkspaceFilesPanel.tsx index 4e36640c..4b113b1a 100644 --- a/src/components/workspace/WorkspaceFilesPanel.tsx +++ b/src/components/workspace/WorkspaceFilesPanel.tsx @@ -119,16 +119,11 @@ const WorkspaceFilesPanel: React.FC = () => { ); })} - - {/* Daily Memory section */} -
-

- {t("workspace.dailyMemory.sectionTitle")} -

+ {/* Daily Memory — inline with workspace files */}