Skip to main content

vtcode_core/tools/
pty.rs

1//! PTY session management.
2//!
3//! The PTY implementation only needs `portable-pty`, so it compiles
4//! identically in TUI and headless builds with no feature gating.
5
6mod command_utils;
7mod formatting;
8mod manager;
9mod manager_utils;
10mod preview;
11mod screen_backend;
12mod scrollback;
13mod session;
14mod types;
15
16pub use command_utils::{is_cargo_command, is_cargo_command_string, is_development_toolchain_command};
17pub use manager::PtyManager;
18pub use portable_pty::PtySize;
19pub use preview::PtyPreviewRenderer;
20pub use types::{PtyCommandRequest, PtyCommandResult, PtyOutputCallback};
21
22/// Bounded-memory metadata for a PTY session's complete output spool.
23#[derive(Debug, Clone, PartialEq, Eq)]
24pub(crate) struct PtyOutputStats {
25    pub total_bytes: u64,
26    pub truncated: bool,
27    pub spool_path: String,
28    pub spool_available: bool,
29    pub spool_complete: bool,
30    pub spool_integrity: Option<crate::tools::output_spooler::SpoolIntegrity>,
31}
32
33/// Termination behavior used when closing a PTY session.
34///
35/// `Graceful` writes `exit\n` and gives the child a SIGTERM grace window so
36/// in-session closes let it clean up. `Immediate` goes straight to a process-
37/// group SIGKILL: user-initiated program exit must not park the terminal on a
38/// 500 ms grace window per live session when the OS reaps any remainder at
39/// process exit anyway.
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum PtyCloseMode {
42    Graceful,
43    Immediate,
44}