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, InlineListItem,
14 InlineListSelection, InlineMessageKind, InlineSegment, InlineSession, InlineTextStyle,
15 InlineTheme,
16};
17
18use tui::run_tui;
19
20pub fn spawn_session(
21 theme: InlineTheme,
22 placeholder: Option<String>,
23 surface_preference: UiSurfacePreference,
24 inline_rows: u16,
25 show_timeline_pane: bool,
26) -> Result<InlineSession> {
27 let (command_tx, command_rx) = mpsc::unbounded_channel();
28 let (event_tx, event_rx) = mpsc::unbounded_channel();
29
30 tokio::spawn(async move {
31 if let Err(error) = run_tui(
32 command_rx,
33 event_tx,
34 theme,
35 placeholder,
36 surface_preference,
37 inline_rows,
38 show_timeline_pane,
39 )
40 .await
41 {
42 tracing::error!(%error, "inline session terminated unexpectedly");
43 }
44 });
45
46 Ok(InlineSession {
47 handle: InlineHandle { sender: command_tx },
48 events: event_rx,
49 })
50}