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)
This commit is contained in:
Jason
2026-02-20 10:40:58 +08:00
parent 4440a14082
commit 7532308519
6 changed files with 12 additions and 23 deletions
+5 -11
View File
@@ -100,7 +100,7 @@ const DailyMemoryPanel: React.FC<DailyMemoryPanelProps> = ({
[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<DailyMemoryPanelProps> = ({
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 () => {
@@ -119,16 +119,11 @@ const WorkspaceFilesPanel: React.FC = () => {
</button>
);
})}
</div>
{/* Daily Memory section */}
<div className="mt-8">
<h3 className="text-sm font-medium text-foreground mb-3">
{t("workspace.dailyMemory.sectionTitle")}
</h3>
{/* Daily Memory — inline with workspace files */}
<button
onClick={() => setShowDailyMemory(true)}
className="w-full flex items-start gap-3 p-4 rounded-xl border border-border bg-card hover:bg-accent/50 transition-colors text-left group"
className="flex items-start gap-3 p-4 rounded-xl border border-border bg-card hover:bg-accent/50 transition-colors text-left group"
>
<div className="mt-0.5 text-muted-foreground group-hover:text-foreground transition-colors">
<Calendar className="w-5 h-5" />