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//! - `managed`: enables the **External services** settings page and the Docker
22//!   lifecycle for GROBID, Ollama, and llama.cpp. It implies `ragrig`.
23//! - `grobid`: additionally enables GROBID/BibTeX reference ingestion through
24//!   [`grobid-bibtex`](https://crates.io/crates/grobid-bibtex), the reference
25//!   rows, and their hover copy actions. It implies `managed`.
26
27#![forbid(unsafe_code)]
28#![warn(missing_docs)]
29
30mod agent_bar;
31mod attachments;
32mod cancel;
33mod chat_view;
34mod composer;
35pub mod editor;
36mod icon;
37mod markdown;
38mod model;
39pub mod paths;
40#[cfg(feature = "ragrig")]
41mod rag;
42#[cfg(feature = "grobid")]
43mod references;
44#[cfg(feature = "managed")]
45mod services;
46mod session_picker;
47mod setting_fields;
48mod settings;
49mod side_panel;
50
51pub mod prelude;
52
53pub use agent_bar::{AgentBar, AgentBarEvent};
54pub use attachments::{AttachmentEvent, AttachmentRows};
55pub use cancel::CancelFlag;
56pub use chat_view::{ChatIdentity, ChatView, ChatViewEvent, EmptyState};
57pub use composer::{Composer, ComposerEvent};
58pub use editor::*;
59pub use icon::ChatIcon;
60pub use markdown::stabilize_markdown;
61pub use model::*;
62pub use paths::{expand_home, home_relative, prompt_for_paths_at};
63#[cfg(feature = "ragrig")]
64pub use rag::*;
65#[cfg(feature = "grobid")]
66pub use references::{
67    CitationAttachment, ReferenceAction, ReferenceCopy, ReferenceEntry, ReferenceOptions,
68    ReferenceProgress, ReferenceReport, ReferenceRow, ReferenceSelection, ReferenceSelectionBar,
69    ReferenceStage, keys_text, paths_text,
70};
71#[cfg(feature = "managed")]
72pub use services::{
73    ContainerStatus, DockerStatus, ExternalServiceEvent, ExternalServices, GROBID_DISCOVERY_PORTS,
74    LLAMACPP_DISCOVERY_PORTS, MANAGED_GROBID_CONTAINER, MANAGED_GROBID_PORT, MANAGED_GROBID_URL,
75    MANAGED_LLAMACPP_CONTAINER, MANAGED_LLAMACPP_PORT, MANAGED_LLAMACPP_URL,
76    MANAGED_OLLAMA_CONTAINER, MANAGED_OLLAMA_PORT, MANAGED_OLLAMA_URL, OLLAMA_DISCOVERY_PORTS,
77    Probe, ProbeStatus, ServiceKind, ServiceLaunch, docker_message, existing_url,
78    external_services_page, llama_base_url, normalize_grobid_url, normalize_http_url,
79    normalize_url, ollama_models, probe,
80};
81#[cfg(feature = "grobid")]
82pub use services::{
83    GrobidContainerStatus, GrobidDockerStatus, GrobidProbe, GrobidProbeStatus, GrobidService,
84    GrobidServiceEvent,
85};
86pub use session_picker::{SessionPicker, SessionPickerEvent};
87pub use setting_fields::{
88    Control, SettingRow, control, dirty_color, dirty_header, dropdown_control, number_control,
89    path_control, path_control_home, path_setting, switch_control, text_control, token_control,
90    token_slider,
91};
92pub use settings::{chat_settings, chat_settings_page};
93pub use side_panel::SidePanel;
94
95use gpui_kit::App;
96
97/// Initializes the GPUI kit and Ragrig UI state.
98///
99/// Call once after constructing the application and before opening windows:
100///
101/// ```no_run
102/// use gpui_kit::application;
103///
104/// application().run(|cx| {
105///     ragrig_gpui::init(cx);
106///     // open your window here
107/// });
108/// ```
109pub fn init(cx: &mut App) {
110    gpui_kit::init(cx);
111}