feat(tauri): persist unpack logs and clean sidecar output
Unpack logs lived only in memory, so closing the app dropped history. Unrar progress also flooded stdout with carriage-return redraws, which made the log viewer noisy and hard to search. Persist the last twenty entries to unpack-logs.json under the app data directory, load them on startup, and rewrite stdout/stderr through a small terminal-sequence cleaner (CR/LF, backspace, control chars) before storage and display. Sort the unpack-logs window newest-first by finish or start time. Test plan: - cargo test -p lanspread-tauri-deno-ts -- terminal_log unpack_log - Run an unpack, restart the app, open unpack logs: prior entries remain - Confirm progress lines collapse to final text instead of spam Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -33,6 +33,9 @@ const formatLogTime = (timestampMs: number): string => {
|
||||
return new Date(timestampMs).toLocaleString();
|
||||
};
|
||||
|
||||
const logSortTime = (entry: UnpackLogEntry): number =>
|
||||
entry.finished_at_ms > 0 ? entry.finished_at_ms : entry.started_at_ms;
|
||||
|
||||
const basename = (path: string): string => {
|
||||
const segments = path.split(/[\\/]/);
|
||||
return segments[segments.length - 1] || path;
|
||||
@@ -97,6 +100,10 @@ export const UnpackLogsWindow = () => {
|
||||
|
||||
out.push({ entry, originalIndex, stdoutLines, stderrLines, matchCount });
|
||||
});
|
||||
out.sort((a, b) => {
|
||||
const timestampDelta = logSortTime(b.entry) - logSortTime(a.entry);
|
||||
return timestampDelta !== 0 ? timestampDelta : b.originalIndex - a.originalIndex;
|
||||
});
|
||||
return out;
|
||||
}, [logs, errorsOnly, regex]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user