mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
5dad3d0e65
* fix(logs): preserve connection log terminal replay data (#1733) Persist unsaved terminal replay buffers in a side store and merge on reload so pruned localStorage writes and cross-window sync no longer wipe captured session output. Also bind hotkey local terminals to sessionId and match captures strictly by session. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logs): merge side-store writes and handle quota failures (#1733) Fold existing localStorage terminal replay data before persisting the side store so multi-window writes do not clobber each other. Skip pruning the main connection-log blob when the side-store write fails so unsaved replay data is not dropped from disk. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logs): retain orphan side-store entries across window sync (#1733) Keep terminal replay buffers for log ids not yet present in this window's connection log snapshot, and warn when the main blob fallback write also fails under quota pressure. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logs): gate orphan side-store retention on persisted log ids (#1733) Only retain side-store replay buffers for log ids still present in the persisted connection-log blob, and write the pruned main blob before syncing the side store so deletions are not resurrected. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logs): prefer fresher local data when retaining orphan replays (#1733) When restoring side-store entries for log ids not yet in memory, use the merged local/ref snapshot instead of stale on-disk side-store bytes. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(logs): skip orphan side-store sync when main blob write fails (#1733) Avoid resurrecting deleted replay buffers from a stale persisted log-id set when the pruned connection-log blob could not be written. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
959 B
TypeScript
31 lines
959 B
TypeScript
import type { ConnectionLog } from "./models.ts";
|
|
|
|
interface TerminalDataCaptureTarget {
|
|
sessionId: string;
|
|
hostname?: string;
|
|
}
|
|
|
|
export const selectConnectionLogForTerminalDataCapture = (
|
|
connectionLogs: ConnectionLog[],
|
|
target: TerminalDataCaptureTarget,
|
|
): ConnectionLog | undefined => {
|
|
if (target.sessionId) {
|
|
const sessionMatches = connectionLogs
|
|
.filter((log) => log.sessionId === target.sessionId)
|
|
.sort((a, b) => b.startTime - a.startTime);
|
|
|
|
const openLog = sessionMatches.find((log) => !log.endTime && !log.terminalData);
|
|
if (openLog) return openLog;
|
|
|
|
return sessionMatches[0];
|
|
}
|
|
|
|
// Legacy logs created without sessionId (e.g. old hotkey local terminals).
|
|
return connectionLogs
|
|
.filter((log) => {
|
|
if (log.endTime || log.terminalData || log.sessionId) return false;
|
|
return !!target.hostname && log.hostname === target.hostname;
|
|
})
|
|
.sort((a, b) => b.startTime - a.startTime)[0];
|
|
};
|