aboutsummaryrefslogtreecommitdiffstats
path: root/crates/asist-app/src/session.rs
diff options
context:
space:
mode:
authorelvis <elvis@claros.ar>2026-09-26 20:20:19 -0300
committerelvis <elvis@claros.ar>2026-09-26 20:20:19 -0300
commit8518a63f55153e7f45fd49ad6caff5555f4e374f (patch)
tree636684eea3fa6f35d78282ab95eb687ef49154af /crates/asist-app/src/session.rs
parent69de76dc9cbedc6092d1e5ce84094a8030de1470 (diff)
downloadasist-p-main.tar.gz
asist-p-main.zip
Translate code, comments, logs and terminal UI to English; add English README; rename scriptsHEADmain
Diffstat (limited to 'crates/asist-app/src/session.rs')
-rw-r--r--crates/asist-app/src/session.rs50
1 files changed, 23 insertions, 27 deletions
diff --git a/crates/asist-app/src/session.rs b/crates/asist-app/src/session.rs
index b74a4f3..8d273c7 100644
--- a/crates/asist-app/src/session.rs
+++ b/crates/asist-app/src/session.rs
@@ -1,10 +1,9 @@
-//! Estado compartido entre los hilos del pipeline.
+//! State shared between the pipeline threads.
//!
-//! Sólo hay dos cosas que de verdad tienen que compartirse: qué turno es el
-//! vigente, y las banderas que permiten cortar lo que está en marcha. Todo lo
-//! demás viaja por canales. Mantener esta superficie pequeña es lo que hace
-//! que la interrupción sea razonable de seguir: cortar es subir el turno y
-//! levantar dos banderas.
+//! Only two things really need sharing: which turn is current, and the flags
+//! that allow cutting whatever is in progress. Everything else travels over
+//! channels. Keeping this surface small is what keeps interruption easy to
+//! follow: cutting means bumping the turn and raising two flags.
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::Arc;
@@ -18,16 +17,16 @@ pub struct Session {
}
struct Inner {
- /// Turno que se está atendiendo. Cualquier trabajo de un turno anterior
- /// que aparezca por un canal es basura y se tira.
+ /// Turn being served. Any work from an earlier turn that shows up on a
+ /// channel is garbage and is thrown away.
current: AtomicU64,
- /// El asistente está hablando (o a punto de hacerlo).
+ /// The assistant is talking (or about to).
speaking: AtomicBool,
/// Cierre solicitado.
stopping: AtomicBool,
- /// Corta la respuesta del modelo en curso.
+ /// Cuts the model answer in progress.
llm: Cancel,
- /// Corta la síntesis en curso.
+ /// Cuts the synthesis in progress.
tts: Cancel,
}
@@ -54,7 +53,7 @@ impl Session {
TurnId(self.inner.current.load(Ordering::SeqCst))
}
- /// Abre un turno nuevo y devuelve su identificador.
+ /// Opens a new turn and returns its id.
pub fn begin_turn(&self) -> TurnId {
let id = TurnId(self.inner.current.fetch_add(1, Ordering::SeqCst) + 1);
self.inner.llm.reset();
@@ -62,15 +61,15 @@ impl Session {
id
}
- /// ¿Sigue siendo `turn` el turno vigente?
+ /// Is `turn` still the current turn?
///
- /// Lo consultan los hilos antes de gastar trabajo: una frase que
- /// pertenece a un turno ya superado no debe sintetizarse ni oírse.
+ /// Threads check it before spending work: a sentence that belongs to an
+ /// outdated turn must be neither synthesized nor heard.
pub fn is_current(&self, turn: TurnId) -> bool {
turn == self.current()
}
- /// Corta todo lo que esté en marcha para el turno actual.
+ /// Cuts everything in progress for the current turn.
pub fn interrupt(&self) {
self.inner.llm.cancel();
self.inner.tts.cancel();
@@ -108,7 +107,7 @@ mod tests {
use super::*;
#[test]
- fn cada_turno_recibe_un_identificador_creciente() {
+ fn each_turn_gets_an_increasing_id() {
let session = Session::new();
assert_eq!(session.begin_turn(), TurnId(1));
assert_eq!(session.begin_turn(), TurnId(2));
@@ -116,18 +115,15 @@ mod tests {
}
#[test]
- fn el_trabajo_de_un_turno_viejo_deja_de_ser_vigente() {
+ fn work_from_an_old_turn_becomes_stale() {
let session = Session::new();
- let primero = session.begin_turn();
+ let first = session.begin_turn();
session.begin_turn();
- assert!(
- !session.is_current(primero),
- "el turno viejo debe descartarse"
- );
+ assert!(!session.is_current(first), "the old turn must be discarded");
}
#[test]
- fn abrir_turno_rearma_las_cancelaciones() {
+ fn opening_a_turn_rearms_cancellation() {
let session = Session::new();
session.begin_turn();
session.interrupt();
@@ -136,12 +132,12 @@ mod tests {
session.begin_turn();
assert!(
!session.llm_cancel().is_cancelled(),
- "un turno nuevo no puede heredar la cancelación del anterior"
+ "a new turn must not inherit the previous cancellation"
);
}
#[test]
- fn interrumpir_calla_y_cancela_las_dos_etapas() {
+ fn interrupting_silences_and_cancels_both_stages() {
let session = Session::new();
session.begin_turn();
session.set_speaking(true);
@@ -151,7 +147,7 @@ mod tests {
}
#[test]
- fn pedir_el_cierre_tambien_interrumpe() {
+ fn requesting_shutdown_also_interrupts() {
let session = Session::new();
session.request_stop();
assert!(session.is_stopping());