Initial public release of Warp.

Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
David Stern
2026-04-28 08:43:33 -05:00
commit 0dbd3d567a
4982 changed files with 1431549 additions and 0 deletions
@@ -0,0 +1,58 @@
use super::search_item::DiffSetSearchItem;
use crate::code_review::diff_state::DiffMode;
use crate::search::ai_context_menu::mixer::AIContextMenuSearchableAction;
use crate::search::data_source::{Query, QueryResult};
use crate::search::mixer::{DataSourceRunErrorWrapper, SyncDataSource};
use warpui::AppContext;
const UNCOMMITTED_CHANGES_NAME: &str = "uncommitted changes";
const MAIN_BRANCH_CHANGES_NAME: &str = "changes vs. main branch";
pub struct DiffSetDataSource;
impl SyncDataSource for DiffSetDataSource {
type Action = AIContextMenuSearchableAction;
fn run_query(
&self,
query: &Query,
_app: &AppContext,
) -> Result<Vec<QueryResult<Self::Action>>, DataSourceRunErrorWrapper> {
// Filter based on query if provided
let query_text = &query.text.to_lowercase();
let mut results: Vec<QueryResult<Self::Action>> = vec![];
// Add uncommitted changes option
if let Some(match_result) =
fuzzy_match::match_indices_case_insensitive(UNCOMMITTED_CHANGES_NAME, query_text)
{
results.push(
DiffSetSearchItem {
diff_mode: DiffMode::Head,
match_result,
}
.into(),
);
}
// Add main branch comparison option
if let Some(match_result) =
fuzzy_match::match_indices_case_insensitive(MAIN_BRANCH_CHANGES_NAME, query_text)
{
results.push(
DiffSetSearchItem {
diff_mode: DiffMode::MainBranch,
match_result,
}
.into(),
);
}
Ok(results)
}
}
impl warpui::Entity for DiffSetDataSource {
type Event = ();
}
@@ -0,0 +1,4 @@
#[cfg(feature = "local_fs")]
pub(super) mod data_source;
#[cfg(feature = "local_fs")]
pub(super) mod search_item;
@@ -0,0 +1,120 @@
use crate::appearance::Appearance;
use crate::code_review::diff_state::DiffMode;
use crate::search::ai_context_menu::mixer::AIContextMenuSearchableAction;
use crate::search::ai_context_menu::styles;
use crate::search::item::SearchItem;
use crate::search::result_renderer::ItemHighlightState;
use fuzzy_match::FuzzyMatchResult;
use ordered_float::OrderedFloat;
use warpui::elements::{
ConstrainedBox, Container, CrossAxisAlignment, Flex, Icon, ParentElement, Text,
};
use warpui::{AppContext, Element, SingletonEntity};
#[derive(Debug, Clone)]
pub struct DiffSetSearchItem {
pub diff_mode: DiffMode,
pub match_result: FuzzyMatchResult,
}
impl DiffSetSearchItem {
pub fn name(&self) -> String {
match &self.diff_mode {
DiffMode::Head => "Uncommitted changes".to_string(),
DiffMode::MainBranch => "Changes vs. main branch".to_string(),
DiffMode::OtherBranch(branch) => format!("Changes vs. {branch}"),
}
}
pub fn description(&self) -> String {
match &self.diff_mode {
DiffMode::Head => "All uncommitted changes in the working directory".to_string(),
DiffMode::MainBranch => "All changes compared to the main branch".to_string(),
DiffMode::OtherBranch(branch) => format!("All changes compared to {branch}"),
}
}
}
impl SearchItem for DiffSetSearchItem {
type Action = AIContextMenuSearchableAction;
fn render_icon(
&self,
highlight_state: ItemHighlightState,
appearance: &Appearance,
) -> Box<dyn Element> {
Container::new(
ConstrainedBox::new(
Icon::new(
"bundled/svg/diff.svg",
highlight_state.icon_fill(appearance).into_solid(),
)
.finish(),
)
.with_width(styles::ICON_SIZE)
.with_height(styles::ICON_SIZE)
.finish(),
)
.with_margin_right(styles::MARGIN_RIGHT)
.finish()
}
fn render_item(
&self,
highlight_state: ItemHighlightState,
app: &AppContext,
) -> Box<dyn Element> {
let appearance = Appearance::as_ref(app);
let name_text = Text::new(
self.name(),
appearance.ui_font_family(),
appearance.monospace_font_size() - 1.0,
)
.with_color(highlight_state.main_text_fill(appearance).into_solid());
let description_text = Text::new(
self.description(),
appearance.ui_font_family(),
appearance.monospace_font_size() - 2.0,
)
.with_color(highlight_state.sub_text_fill(appearance).into_solid());
Flex::row()
.with_cross_axis_alignment(CrossAxisAlignment::Center)
.with_child(name_text.finish())
.with_child(
Container::new(description_text.finish())
.with_padding_left(6.)
.finish(),
)
.finish()
}
fn priority_tier(&self) -> u8 {
// Prioritize diffsets above other items.
1
}
fn score(&self) -> OrderedFloat<f64> {
OrderedFloat(self.match_result.score as f64)
}
fn accept_result(&self) -> Self::Action {
AIContextMenuSearchableAction::InsertDiffSet {
diff_mode: self.diff_mode.clone(),
}
}
fn execute_result(&self) -> Self::Action {
self.accept_result()
}
fn accessibility_label(&self) -> String {
format!("{} - {}", self.name(), self.description())
}
}
#[cfg(test)]
#[path = "search_item_tests.rs"]
mod tests;
@@ -0,0 +1,17 @@
use super::DiffSetSearchItem;
use crate::code_review::diff_state::DiffMode;
use crate::search::item::SearchItem;
#[test]
fn diffset_has_higher_priority_tier() {
let match_result =
fuzzy_match::match_indices_case_insensitive("uncommitted changes", "uncommitted")
.expect("query should match");
let item = DiffSetSearchItem {
diff_mode: DiffMode::Head,
match_result,
};
assert_eq!(item.priority_tier(), 1);
}