mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
77e1bc3214
* fix(session-logs): honor format for manual logs * test(session-logs): cover pager cleanup * fix(session-logs): preserve HTML host labels * fix(session-logs): report final write failures * fix(session-logs): clear failed recording state
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { useCallback } from "react";
|
|
import { netcattyBridge } from "../../infrastructure/services/netcattyBridge";
|
|
|
|
type ManualStartPayload = {
|
|
sessionId: string;
|
|
sessionName?: string;
|
|
preferredDirectory?: string;
|
|
format?: "txt" | "raw" | "html";
|
|
timestampsEnabled?: boolean;
|
|
initialLine?: string;
|
|
};
|
|
|
|
type ManualStopPayload = {
|
|
sessionId: string;
|
|
};
|
|
|
|
type ManualStatusPayload = {
|
|
sessionId: string;
|
|
};
|
|
|
|
export const useSessionLogBackend = () => {
|
|
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, error: "Session log bridge unavailable" };
|
|
}, []);
|
|
|
|
return { startManualSessionLog, stopManualSessionLog, getManualSessionLogStatus };
|
|
};
|