ragrig_gpui/lib.rs
1//! Reusable [GPUI](https://gpui.rs) components for Ragrig.
2//!
3//! `ragrig-gpui` packages the chat, composer, transcript, attachment, session,
4//! agent-status and settings surfaces needed to build a RAG front end. The
5//! crate contains no editor: hosting applications such as Sciscraper compose
6//! these components into their own layout.
7//!
8//! # State model
9//!
10//! The reducers in [`ChatState`] are plain data. [`ChatView`] wraps one in an
11//! entity, keeps one `TextViewState` per message for incremental Markdown, and
12//! renders it with `MessageScroller`. [`Composer`] owns its input and emits
13//! [`ComposerEvent`]s; it does not know about a controller.
14//!
15//! # Feature flags
16//!
17//! - `ragrig` (default): enables the Ragrig controller, full settings page,
18//! and the composite [`RagChat`] surface. The worker uses a dedicated Tokio
19//! runtime thread.
20//! - `grobid`: enables GROBID/BibTeX reference ingestion through
21//! [`grobid-bibtex`](https://crates.io/crates/grobid-bibtex), the reference
22//! rows, and their hover copy actions. It implies `ragrig`.
23
24#![forbid(unsafe_code)]
25#![warn(missing_docs)]
26
27mod agent_bar;
28mod attachments;
29mod cancel;
30mod chat_view;
31mod composer;
32mod markdown;
33mod model;
34#[cfg(feature = "ragrig")]
35mod rag;
36#[cfg(feature = "grobid")]
37mod references;
38mod session_picker;
39mod settings;
40mod side_panel;
41
42pub mod prelude;
43
44pub use agent_bar::{AgentBar, AgentBarEvent};
45pub use attachments::{AttachmentEvent, AttachmentRows};
46pub use cancel::CancelFlag;
47pub use chat_view::{ChatView, ChatViewEvent, EmptyState};
48pub use composer::{Composer, ComposerEvent};
49pub use markdown::stabilize_markdown;
50pub use model::*;
51#[cfg(feature = "ragrig")]
52pub use rag::*;
53#[cfg(feature = "grobid")]
54pub use references::{
55 CitationAttachment, ReferenceAction, ReferenceCopy, ReferenceEntry, ReferenceOptions,
56 ReferenceProgress, ReferenceReport, ReferenceRow, ReferenceSelection, ReferenceSelectionBar,
57 ReferenceStage, keys_text, paths_text,
58};
59pub use session_picker::{SessionPicker, SessionPickerEvent};
60pub use settings::{chat_settings, chat_settings_page};
61pub use side_panel::SidePanel;
62
63use gpui_kit::App;
64
65/// Initializes the GPUI kit and Ragrig UI state.
66///
67/// Call once after constructing the application and before opening windows:
68///
69/// ```no_run
70/// use gpui_kit::application;
71///
72/// application().run(|cx| {
73/// ragrig_gpui::init(cx);
74/// // open your window here
75/// });
76/// ```
77pub fn init(cx: &mut App) {
78 gpui_kit::init(cx);
79}