pub struct TranscriptLayout<'w, 's> { /* private fields */ }Expand description
Lays out an agent’s transcript as the terminal view draws it, without
drawing it: for any agent, shown or not, in a run with the terminal or
without, by the view’s own layout (its order, its renderers, wrapping
and the matches it lights), so an export, a copy, a search or a screen
reader reads what the view shows. Each layout renders and wraps the
whole transcript, so lay one out when asked, not every frame. It is
there in any run with the TuiPlugin, and takes
the TranscriptView to lay out with, such as a pane’s, so a system
that changes the view lays out with it too.
use rig_harness::prelude::*;
use rig_tui::{MainPane, TranscriptLayout, TranscriptView};
/// `/export`: the agent's transcript as the main pane draws it, a line
/// per row.
fn export(
In(args): In<CommandArgs>,
layout: TranscriptLayout,
view: Single<&TranscriptView, With<MainPane>>,
) {
let width = view.width().unwrap_or(100);
let Some(laid_out) = layout.lay_out(&view, args.agent, width) else {
return;
};
let rows: Vec<&str> = laid_out.rows().iter().map(|row| row.text.as_str()).collect();
std::fs::write("transcript.txt", rows.join("\n")).ok();
}Implementations§
Source§impl TranscriptLayout<'_, '_>
impl TranscriptLayout<'_, '_>
Sourcepub fn lay_out(
&self,
view: &TranscriptView,
agent: Entity,
width: u16,
) -> Option<DrawnTranscript>
pub fn lay_out( &self, view: &TranscriptView, agent: Entity, width: u16, ) -> Option<DrawnTranscript>
agent’s transcript laid out in rows width columns wide (as
TranscriptView::width says the view draws it; u16::MAX keeps
a line in one row), the matches of view’s highlights counted, as
the view would draw it with view. It has no rows on screen. DrawnTranscript::item takes one item’s rows out of
it. None when agent is no agent.
Trait Implementations§
impl<'w, 's> ReadOnlySystemParam for TranscriptLayout<'w, 's>where
Query<'w, 's, (&'static AgentId, &'static Conversation)>: ReadOnlySystemParam,
Query<'w, 's, &'static ActiveTurn>: ReadOnlySystemParam,
Query<'w, 's, &'static Calls>: ReadOnlySystemParam,
Query<'w, 's, &'static Partial, Without<SupersededBy>>: ReadOnlySystemParam,
Query<'w, 's, (&'static Effect, &'static Incoming, &'static ForAgent), (With<Started>, Without<Outcome>)>: ReadOnlySystemParam,
Looks<'w, 's>: ReadOnlySystemParam,
CallStates<'w, 's>: ReadOnlySystemParam,
Query<'w, 's, (Entity, &'static Effect, (Option<&'static ToolRequest>, Option<&'static ModelRequest>, Option<&'static SentTo>), (Option<&'static ForAgent>, Option<&'static Outcome>), (Has<Started>, Has<Partial>)), Without<Settled>>: ReadOnlySystemParam,
Query<'w, 's, &'static Name>: ReadOnlySystemParam,
Res<'w, CallFacts>: ReadOnlySystemParam,
Query<'w, 's, &'static StreamingCalls>: ReadOnlySystemParam,
Res<'w, Notices>: ReadOnlySystemParam,
Res<'w, Theme>: ReadOnlySystemParam,
Source§impl SystemParam for TranscriptLayout<'_, '_>
impl SystemParam for TranscriptLayout<'_, '_>
Source§type Item<'w, 's> = TranscriptLayout<'w, 's>
type Item<'w, 's> = TranscriptLayout<'w, 's>
Self, instantiated with new lifetimes. Read moreSource§fn init_access(
state: &Self::State,
system_meta: &mut SystemMeta,
system_access: &mut SystemAccess,
world: &mut World,
)
fn init_access( state: &Self::State, system_meta: &mut SystemMeta, system_access: &mut SystemAccess, world: &mut World, )
Source§fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
SystemParam’s state.
This is used to apply Commands during ApplyDeferred.Source§fn queue(
state: &mut Self::State,
system_meta: &SystemMeta,
world: DeferredWorld<'_>,
)
fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )
ApplyDeferred.Source§unsafe fn get_param<'w, 's>(
state: &'s mut Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: Tick,
) -> Result<Self::Item<'w, 's>, SystemParamValidationError>
unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Result<Self::Item<'w, 's>, SystemParamValidationError>
SystemParamFunction. Read moreAuto Trait Implementations§
impl<'w, 's> !RefUnwindSafe for TranscriptLayout<'w, 's>
impl<'w, 's> !UnwindSafe for TranscriptLayout<'w, 's>
impl<'w, 's> Freeze for TranscriptLayout<'w, 's>
impl<'w, 's> Send for TranscriptLayout<'w, 's>
impl<'w, 's> Sync for TranscriptLayout<'w, 's>
impl<'w, 's> Unpin for TranscriptLayout<'w, 's>
impl<'w, 's> UnsafeUnpin for TranscriptLayout<'w, 's>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more