mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-10 16:21:22 +00:00
* feat: open saved session logs from terminal toolbar Add one-click access to the current automatic or manual session log, flush before opening, and reuse application selection with a remembered log preference. Preserve recording controls and current-session ownership across worker routing and reconnects. Refs #3807 * fix(logging): preserve saved logs on failed reconnect and localize failures Address both Codex review findings with generation- and identity-checked replacement cleanup and localized user-facing error handling. * fix(logging): guard successful main-process session replacement Add shared inactive-log cleanup to fallback start handlers with regression coverage. Registration activation follows separately. * fix(logging): enable log lifecycle cleanup for main-process fallback * fix(terminal): keep log cleanup and tuck open-log into More actions Always end a raw session-log write stream on finalize, including when a flush already disabled it. Keep immediate snapshot retries, and pause them only while prepare is waiting so a disk error can be reported. Show open, reveal, and open-with in the toolbar overflow menu when logging is active, instead of a default toolbar button. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(logging): back off failed snapshot writes and drop retired log actions Persistent snapshot failures retry on a growing delay instead of a tight loop, and still flush immediately when new output arrives. Hide open-log actions after a successful reconnect retires a stopped manual log. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(terminal): keep open-log actions after automatic logging is turned off The current automatic log keeps recording until reconnect, so the menu stays available for that connection and clears on the next successful connect. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(terminal): derive log menu availability from saved session logs * fix(terminal): nest session log actions in one More actions submenu Collapse Open, Show in folder, and the two open-with actions into a Session log submenu that follows the Terminal Encoding menu, and drop the remembered-application hint. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { useCallback } from "react";
|
|
import { netcattyBridge } from "../../infrastructure/services/netcattyBridge";
|
|
|
|
type ManualChoosePathPayload = {
|
|
sessionId: string;
|
|
sessionName?: string;
|
|
preferredDirectory?: string;
|
|
format?: "txt" | "raw" | "html";
|
|
};
|
|
|
|
type ManualStartPayload = {
|
|
sessionId: string;
|
|
sessionName?: string;
|
|
preferredDirectory?: string;
|
|
/**
|
|
* Opaque token from chooseManualSessionLogPath. Required for the post-dialog
|
|
* second phase; raw file paths from the renderer are rejected.
|
|
*/
|
|
selectionToken?: string;
|
|
format?: "txt" | "raw" | "html";
|
|
timestampsEnabled?: boolean;
|
|
initialLine?: string;
|
|
alternateScreenActive?: boolean;
|
|
};
|
|
|
|
type ManualStopPayload = {
|
|
sessionId: string;
|
|
};
|
|
|
|
type ManualStatusPayload = {
|
|
sessionId: string;
|
|
};
|
|
|
|
export const useSessionLogBackend = () => {
|
|
const chooseManualSessionLogPath = useCallback(async (payload: ManualChoosePathPayload) => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.chooseManualSessionLogPath?.(payload)
|
|
?? { success: false, canceled: false, error: "Session log bridge unavailable" };
|
|
}, []);
|
|
|
|
const startManualSessionLog = useCallback(async (payload: ManualStartPayload) => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.startManualSessionLog?.(payload) ?? { success: false, started: false, error: "Session log bridge unavailable" };
|
|
}, []);
|
|
|
|
const stopManualSessionLog = useCallback(async (payload: ManualStopPayload) => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.stopManualSessionLog?.(payload) ?? { success: false, stopped: false, error: "Session log bridge unavailable" };
|
|
}, []);
|
|
|
|
const getManualSessionLogStatus = useCallback(async (payload: ManualStatusPayload) => {
|
|
const bridge = netcattyBridge.get();
|
|
return bridge?.getManualSessionLogStatus?.(payload) ?? { success: false, isLogging: false, hasSessionLog: false, error: "Session log bridge unavailable" };
|
|
}, []);
|
|
|
|
return {
|
|
chooseManualSessionLogPath,
|
|
startManualSessionLog,
|
|
stopManualSessionLog,
|
|
getManualSessionLogStatus,
|
|
};
|
|
};
|