mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-22 16:10:50 +00:00
* fix(terminal): separate prompt after unterminated command output Add a display-layer prompt line break handler so recognized shell prompts move to the next visual line when the final command output line is not newline terminated. Also add a terminal setting to toggle the behavior, sync support, i18n copy, and focused tests for prompt insertion. * fix review issue * Fix prompt cache initialization * Serialize terminal output writes for prompt breaks * Keep terminal status lines ordered with output * Fix prompt arming without command callback * Keep prompt display breaks out of session logs * Avoid prompt breaks for output suffix matches --------- Co-authored-by: yuzifu <yuzifu@TB16PGen5.Info> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
32 lines
859 B
TypeScript
32 lines
859 B
TypeScript
import type { RefObject } from "react";
|
|
import type { Host } from "../../../types";
|
|
import {
|
|
markPromptLineBreakCommandPending,
|
|
type PromptLineBreakState,
|
|
} from "./promptLineBreak";
|
|
|
|
type TerminalCommandExecutionContext = {
|
|
host: Pick<Host, "id" | "label">;
|
|
sessionId: string;
|
|
onCommandExecuted?: (
|
|
command: string,
|
|
hostId: string,
|
|
hostLabel: string,
|
|
sessionId: string,
|
|
) => void;
|
|
commandBufferRef: RefObject<string>;
|
|
promptLineBreakStateRef?: RefObject<PromptLineBreakState>;
|
|
};
|
|
|
|
export const recordTerminalCommandExecution = (
|
|
command: string,
|
|
ctx: TerminalCommandExecutionContext,
|
|
) => {
|
|
const cmd = command.trim();
|
|
if (cmd) {
|
|
ctx.onCommandExecuted?.(cmd, ctx.host.id, ctx.host.label, ctx.sessionId);
|
|
}
|
|
ctx.commandBufferRef.current = "";
|
|
markPromptLineBreakCommandPending(ctx.promptLineBreakStateRef);
|
|
};
|