Skip to main content

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 widget: it exports the editor roundtrip contract
6//! ([`editor`]) so hosting applications such as Scico can plug in their
7//! own editor component.
8//!
9//! # State model
10//!
11//! The reducers in [`ChatState`] are plain data. [`ChatView`] wraps one in an
12//! entity, keeps one `TextViewState` per message for incremental Markdown, and
13//! renders it with `MessageScroller`. [`Composer`] owns its input and emits
14//! [`ComposerEvent`]s; it does not know about a controller.
15//!
16//! # Feature flags
17//!
18//! - `ragrig` (default): enables the Ragrig controller, full settings page,
19//!   and the composite [`RagChat`] surface. The worker uses a dedicated Tokio
20//!   runtime thread.
21//! - `grobid`: enables GROBID/BibTeX reference ingestion through
22//!   [`grobid-bibtex`](https://crates.io/crates/grobid-bibtex), the reference
23//!   rows, and their hover copy actions. It implies `ragrig`.
24
25#![forbid(unsafe_code)]
26#![warn(missing_docs)]
27
28mod agent_bar;
29mod attachments;
30mod cancel;
31mod chat_view;
32mod composer;
33pub mod editor;
34mod icon;
35mod markdown;
36mod model;
37#[cfg(feature = "ragrig")]
38mod rag;
39#[cfg(feature = "grobid")]
40mod references;
41#[cfg(feature = "grobid")]
42mod services;
43mod session_picker;
44mod setting_fields;
45mod settings;
46mod side_panel;
47
48pub mod prelude;
49
50pub use agent_bar::{AgentBar, AgentBarEvent};
51pub use attachments::{AttachmentEvent, AttachmentRows};
52pub use cancel::CancelFlag;
53pub use chat_view::{ChatIdentity, ChatView, ChatViewEvent, EmptyState};
54pub use composer::{Composer, ComposerEvent};
55pub use editor::*;
56pub use icon::ChatIcon;
57pub use markdown::stabilize_markdown;
58pub use model::*;
59#[cfg(feature = "ragrig")]
60pub use rag::*;
61#[cfg(feature = "grobid")]
62pub use references::{
63    CitationAttachment, ReferenceAction, ReferenceCopy, ReferenceEntry, ReferenceOptions,
64    ReferenceProgress, ReferenceReport, ReferenceRow, ReferenceSelection, ReferenceSelectionBar,
65    ReferenceStage, keys_text, paths_text,
66};
67#[cfg(feature = "grobid")]
68pub use services::{
69    GROBID_DISCOVERY_PORTS, GrobidContainerStatus, GrobidDockerStatus, GrobidProbe,
70    GrobidProbeStatus, GrobidService, GrobidServiceEvent, MANAGED_GROBID_CONTAINER,
71    MANAGED_GROBID_PORT, MANAGED_GROBID_URL, external_services_page, normalize_grobid_url,
72};
73pub use session_picker::{SessionPicker, SessionPickerEvent};
74pub use setting_fields::{
75    Control, SettingRow, control, dirty_color, dirty_header, dropdown_control, number_control,
76    path_control, path_setting, switch_control, text_control, token_control, token_slider,
77};
78pub use settings::{chat_settings, chat_settings_page};
79pub use side_panel::SidePanel;
80
81use gpui_kit::App;
82
83/// Initializes the GPUI kit and Ragrig UI state.
84///
85/// Call once after constructing the application and before opening windows:
86///
87/// ```no_run
88/// use gpui_kit::application;
89///
90/// application().run(|cx| {
91///     ragrig_gpui::init(cx);
92///     // open your window here
93/// });
94/// ```
95pub fn init(cx: &mut App) {
96    gpui_kit::init(cx);
97}