Introduit le module application `workstate` (modèle de read-model live + snapshots des conversations/délégations en cours) et l'expose via la couche terminal (exports mod/registry). Câble la surface Tauri : DTO, commande et state pour exposer le live-state au frontend (lib + state + commands), avec tests. QA verte. Réserve environnementale non bloquante : tests loopback socket Unix réels non exécutables en sandbox (UnixListener::bind PermissionDenied), alternatives avec skips vertes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
1.9 KiB
Rust
39 lines
1.9 KiB
Rust
//! Terminal use cases (ARCHITECTURE §6, L3).
|
|
//!
|
|
//! Each use case is a struct carrying its ports as `Arc<dyn Port>` and exposing a
|
|
//! single `execute(input) -> Result<output, AppError>` method (**Single
|
|
//! Responsibility**). They talk **only** to the [`domain::ports::PtyPort`] (plus
|
|
//! the [`domain::ports::EventBus`] for `OpenTerminal`); the composition root
|
|
//! injects the concrete [`infrastructure::PortablePtyAdapter`].
|
|
//!
|
|
//! - [`OpenTerminal`] — resolve the cwd, spawn a PTY, create a
|
|
//! [`domain::TerminalSession`], register the live handle, publish an event.
|
|
//! - [`WriteToTerminal`] — forward bytes (keystrokes) to a PTY.
|
|
//! - [`ResizeTerminal`] — resize a PTY.
|
|
//! - [`CloseTerminal`] — kill a PTY and forget its handle.
|
|
//!
|
|
//! # Where the active-session registry lives, and why
|
|
//!
|
|
//! The domain [`PtyPort`] is *handle-oriented*: `spawn` returns a
|
|
//! [`domain::ports::PtyHandle`] that every later call (`write`/`resize`/`kill`)
|
|
//! must reference. Something has to remember, per [`SessionId`], the live
|
|
//! `PtyHandle` (and the `TerminalSession` snapshot) between IPC calls. That state
|
|
//! is **not domain state** (it is the in-flight wiring of an I/O resource), and
|
|
//! it must not live in the adapter alone (other use cases need to address a
|
|
//! session by id). It therefore lives in [`TerminalSessions`], an **application
|
|
//! service** injected into the terminal use cases (and held in the composition
|
|
//! root behind an `Arc`). This keeps the domain pure and the registry shared,
|
|
//! testable, and transport-agnostic.
|
|
|
|
mod registry;
|
|
mod usecases;
|
|
|
|
pub use registry::{
|
|
LiveAgentRegistry, LiveSessionKind, LiveSessionSnapshot, LiveSessions, StructuredSessions,
|
|
TerminalSessions,
|
|
};
|
|
pub use usecases::{
|
|
CloseTerminal, CloseTerminalInput, CloseTerminalOutput, OpenTerminal, OpenTerminalInput,
|
|
OpenTerminalOutput, ResizeTerminal, ResizeTerminalInput, WriteToTerminal, WriteToTerminalInput,
|
|
};
|