1use anyhow::Result;
2use tokio::sync::mpsc;
3
4use crate::config::types::UiSurfacePreference;
5
6mod session;
7mod style;
8mod tui;
9mod types;
10
11pub use style::{convert_style, theme_from_styles};
12pub use types::{
13 InlineCommand, InlineEvent, InlineHandle, InlineHeaderContext, InlineMessageKind,
14 InlineSegment, InlineSession, InlineTextStyle, InlineTheme,
15};
16
17use tui::run_tui;
18
19pub fn spawn_session(
20 theme: InlineTheme,
21 placeholder: Option<String>,
22 surface_preference: UiSurfacePreference,
23 inline_rows: u16,
24 show_timeline_pane: bool,
25) -> Result<InlineSession> {
26 let (command_tx, command_rx) = mpsc::unbounded_channel();
27 let (event_tx, event_rx) = mpsc::unbounded_channel();
28
29 tokio::spawn(async move {
30 if let Err(error) = run_tui(
31 command_rx,
32 event_tx,
33 theme,
34 placeholder,
35 surface_preference,
36 inline_rows,
37 show_timeline_pane,
38 )
39 .await
40 {
41 tracing::error!(%error, "inline session terminated unexpectedly");
42 }
43 });
44
45 Ok(InlineSession {
46 handle: InlineHandle { sender: command_tx },
47 events: event_rx,
48 })
49}