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;
37pub mod paths;
38#[cfg(feature = "ragrig")]
39mod rag;
40#[cfg(feature = "grobid")]
41mod references;
42#[cfg(feature = "grobid")]
43mod services;
44mod session_picker;
45mod setting_fields;
46mod settings;
47mod side_panel;
48
49pub mod prelude;
50
51pub use agent_bar::{AgentBar, AgentBarEvent};
52pub use attachments::{AttachmentEvent, AttachmentRows};
53pub use cancel::CancelFlag;
54pub use chat_view::{ChatIdentity, ChatView, ChatViewEvent, EmptyState};
55pub use composer::{Composer, ComposerEvent};
56pub use editor::*;
57pub use icon::ChatIcon;
58pub use markdown::stabilize_markdown;
59pub use model::*;
60pub use paths::{expand_home, home_relative, prompt_for_paths_at};
61#[cfg(feature = "ragrig")]
62pub use rag::*;
63#[cfg(feature = "grobid")]
64pub use references::{
65    CitationAttachment, ReferenceAction, ReferenceCopy, ReferenceEntry, ReferenceOptions,
66    ReferenceProgress, ReferenceReport, ReferenceRow, ReferenceSelection, ReferenceSelectionBar,
67    ReferenceStage, keys_text, paths_text,
68};
69#[cfg(feature = "grobid")]
70pub use services::{
71    GROBID_DISCOVERY_PORTS, GrobidContainerStatus, GrobidDockerStatus, GrobidProbe,
72    GrobidProbeStatus, GrobidService, GrobidServiceEvent, MANAGED_GROBID_CONTAINER,
73    MANAGED_GROBID_PORT, MANAGED_GROBID_URL, external_services_page, normalize_grobid_url,
74};
75pub use session_picker::{SessionPicker, SessionPickerEvent};
76pub use setting_fields::{
77    Control, SettingRow, control, dirty_color, dirty_header, dropdown_control, number_control,
78    path_control, path_control_home, path_setting, switch_control, text_control, token_control,
79    token_slider,
80};
81pub use settings::{chat_settings, chat_settings_page};
82pub use side_panel::SidePanel;
83
84use gpui_kit::App;
85
86/// Initializes the GPUI kit and Ragrig UI state.
87///
88/// Call once after constructing the application and before opening windows:
89///
90/// ```no_run
91/// use gpui_kit::application;
92///
93/// application().run(|cx| {
94///     ragrig_gpui::init(cx);
95///     // open your window here
96/// });
97/// ```
98pub fn init(cx: &mut App) {
99    gpui_kit::init(cx);
100}