From 6c70d6a60b286f7cfbbde4e428d41c8de2c7e77a Mon Sep 17 00:00:00 2001 From: diogo464 Date: Thu, 14 Aug 2025 15:34:42 +0100 Subject: feat: improve DriveLogEntry types with discriminated unions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace generic DriveLogEntry with action-specific discriminated unions - Add DriveLogEntryCreateFile, CreateDir, Remove, Rename types - Update Drive_log parsing to create correct union types based on action - Add type guards (isCreateFileEntry, isRenameEntry, etc.) for safe access - Enhance History UI to properly display rename operations (old → new) - Change log_id to revision to match Rust OperationHeader structure - Improve type safety and maintainability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/components/history/HistoryView.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'frontend/components') diff --git a/frontend/components/history/HistoryView.tsx b/frontend/components/history/HistoryView.tsx index b01e4c6..d9d3dc2 100644 --- a/frontend/components/history/HistoryView.tsx +++ b/frontend/components/history/HistoryView.tsx @@ -1,4 +1,4 @@ -import { DriveLogEntry } from "@/lib/drive_types" +import { DriveLogEntry, isCreateFileEntry, isRenameEntry } from "@/lib/drive_types" import { DriveHeader } from "@/components/drive/DriveHeader" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Button } from "@/components/ui/button" @@ -102,7 +102,7 @@ export function HistoryView({ entries, currentPage, hasNextPage, hasPrevPage, to ) : ( entries.map((entry) => ( - + {formatDateTime(entry.timestamp)} @@ -115,19 +115,23 @@ export function HistoryView({ entries, currentPage, hasNextPage, hasPrevPage, to {entry.email} - {entry.action === "create_file" && entry.blob_id !== "-" ? ( + {isCreateFileEntry(entry) ? ( {entry.path} + ) : isRenameEntry(entry) ? ( + + {entry.old_path} → {entry.new_path} + ) : ( - entry.path + 'path' in entry ? entry.path : '' )} - {formatFileSize(entry.size)} + {isCreateFileEntry(entry) ? formatFileSize(entry.size) : '-'} )) -- cgit