v1.4.0: Auto-compact streaming, Bedrock summarization support, subagent orchestration, and Galaxy rebrand continuation
Major features: - Auto-compact: triggers conversation summarization when context window >= 85%, compacts Bedrock message history to a summary pair, and tracks live context tokens - Bedrock summarization: plumbs `is_summarization` flag through translator/client/response pipeline, handles SummarizeConversation input type, and marks `summarized` in metadata - Session restore: rebuilds bedrock_message_history from persisted task messages via newly-public `convert_proto_message`, preventing empty history on reconnect - Subagent orchestration: adds SubagentQuestion/Answer/CompletionSummary event types, parent-child question routing with depth limits, retry counting, and drain methods - Summarization UI: inline SummarizationView in AI blocks with progress/finished states Refactors: - Rename WarpTheme → GalaxyTheme across ~100 files (rebrand continuation) - Rename warp_home_config_dir → galaxy_home_config_dir and related path functions - Predefined rules: replace "System Defined Rule #N" with descriptive names (e.g. "Correctness Over Speed", "Never Guess") and add lookup helpers - Usage view: replace cumulative input/output token display with live context tokens, cache hit rate calculation, and separate cache read/write stats - Telemetry: remove verbose doc comments, simplify trait definitions - Facts view: simplify delete permission check (always allow local deletion) - Remove warp_managed_paths_watcher.rs (dead code) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
eaa2ddc75e
commit
6f54e2cb30
@@ -52,7 +52,7 @@ fn base_warp_config_dir_name() -> String {
|
||||
///
|
||||
/// This preserves the historical `.warp*` directory shape while still isolating dev, local,
|
||||
/// integration, oss, and optional development profiles.
|
||||
pub fn warp_home_config_dir_name() -> String {
|
||||
pub fn galaxy_home_config_dir_name() -> String {
|
||||
let base_dir_name = base_warp_config_dir_name();
|
||||
|
||||
if let Some(data_profile) = ChannelState::data_profile() {
|
||||
@@ -67,13 +67,13 @@ pub fn warp_home_config_dir_name() -> String {
|
||||
/// Unlike [`data_dir`] and [`config_local_dir`] on non-macOS platforms, this intentionally keeps
|
||||
/// user-facing config under a `.warp-core*` directory in the home directory instead of
|
||||
/// using the platform XDG/AppData project directories.
|
||||
pub fn warp_home_config_dir() -> Option<PathBuf> {
|
||||
dirs::home_dir().map(|home_dir| home_dir.join(warp_home_config_dir_name()))
|
||||
pub fn galaxy_home_config_dir() -> Option<PathBuf> {
|
||||
dirs::home_dir().map(|home_dir| home_dir.join(galaxy_home_config_dir_name()))
|
||||
}
|
||||
|
||||
/// Returns the legacy `~/.warp*` config directory path for the current channel,
|
||||
/// used to detect and migrate data from a previous Warp installation.
|
||||
pub fn legacy_warp_home_config_dir() -> Option<PathBuf> {
|
||||
pub fn legacy_galaxy_home_config_dir() -> Option<PathBuf> {
|
||||
let base = LEGACY_WARP_CONFIG_DIR;
|
||||
let dir_name = match ChannelState::channel() {
|
||||
Channel::Stable | Channel::Preview => base.to_owned(),
|
||||
@@ -100,10 +100,10 @@ pub fn legacy_warp_home_config_dir() -> Option<PathBuf> {
|
||||
/// - The new directory already exists.
|
||||
/// - The old directory does not exist.
|
||||
pub fn migrate_legacy_config_dir_if_needed() {
|
||||
let Some(old_dir) = legacy_warp_home_config_dir() else {
|
||||
let Some(old_dir) = legacy_galaxy_home_config_dir() else {
|
||||
return;
|
||||
};
|
||||
let Some(new_dir) = warp_home_config_dir() else {
|
||||
let Some(new_dir) = galaxy_home_config_dir() else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -198,12 +198,12 @@ pub fn migrate_legacy_config_dir_if_needed() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn warp_home_skills_dir() -> Option<PathBuf> {
|
||||
warp_home_config_dir().map(|warp_config_dir| warp_config_dir.join("skills"))
|
||||
pub fn galaxy_home_skills_dir() -> Option<PathBuf> {
|
||||
galaxy_home_config_dir().map(|warp_config_dir| warp_config_dir.join("skills"))
|
||||
}
|
||||
|
||||
pub fn warp_home_mcp_config_file_path() -> Option<PathBuf> {
|
||||
warp_home_config_dir().map(|warp_config_dir| warp_config_dir.join(".mcp.json"))
|
||||
pub fn galaxy_home_mcp_config_file_path() -> Option<PathBuf> {
|
||||
galaxy_home_config_dir().map(|warp_config_dir| warp_config_dir.join(".mcp.json"))
|
||||
}
|
||||
|
||||
/// Returns the macOS config directory name for the current channel.
|
||||
|
||||
@@ -37,7 +37,7 @@ fn test_config_local_dir_path() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_warp_home_config_dir_path() {
|
||||
fn test_galaxy_home_config_dir_path() {
|
||||
let home_dir = home_dir().expect("Should be able to compute home directory");
|
||||
let expected_dir_name = match ChannelState::data_profile() {
|
||||
Some(data_profile) => format!(".warp-core-oss-{data_profile}"),
|
||||
@@ -45,20 +45,20 @@ fn test_warp_home_config_dir_path() {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
warp_home_config_dir(),
|
||||
galaxy_home_config_dir(),
|
||||
Some(home_dir.join(expected_dir_name))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_warp_home_skills_and_mcp_paths() {
|
||||
let Some(config_dir) = warp_home_config_dir() else {
|
||||
let Some(config_dir) = galaxy_home_config_dir() else {
|
||||
panic!("Should be able to compute Warp home config directory");
|
||||
};
|
||||
|
||||
assert_eq!(warp_home_skills_dir(), Some(config_dir.join("skills")));
|
||||
assert_eq!(galaxy_home_skills_dir(), Some(config_dir.join("skills")));
|
||||
assert_eq!(
|
||||
warp_home_mcp_config_file_path(),
|
||||
galaxy_home_mcp_config_file_path(),
|
||||
Some(config_dir.join(".mcp.json"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,62 +1,19 @@
|
||||
use std::{fmt, marker::PhantomData};
|
||||
|
||||
use galaxyui::{AppContext, Entity, SingletonEntity};
|
||||
use serde_json::Value;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
// Re-export for macro use.
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub use inventory::submit;
|
||||
|
||||
use crate::{
|
||||
channel::{Channel, ChannelState},
|
||||
features::FeatureFlag,
|
||||
};
|
||||
use crate::features::FeatureFlag;
|
||||
|
||||
/// Core trait defining telemetry event behavior.
|
||||
///
|
||||
/// This trait encapsulates the basic functionality required for any telemetry event
|
||||
/// in the Warp ecosystem. It enables events to be defined in any crate while maintaining
|
||||
/// consistent telemetry reporting behavior.
|
||||
pub trait TelemetryEvent: RegisteredTelemetryEvent {
|
||||
/// Returns the name of the telemetry event.
|
||||
///
|
||||
/// The name should be a stable identifier that uniquely identifies this type of event.
|
||||
/// It is used for analytics tracking and should remain consistent over time.
|
||||
///
|
||||
/// Returns a borrowed string to avoid allocations for static event names.
|
||||
fn name(&self) -> &'static str;
|
||||
|
||||
/// Returns optional structured data associated with this event.
|
||||
///
|
||||
/// The payload allows events to include additional context or metadata beyond
|
||||
/// just the event name. This is useful for including dynamic data about the
|
||||
/// event occurrence.
|
||||
///
|
||||
/// Returns None if the event has no additional data to report.
|
||||
fn payload(&self) -> Option<Value>;
|
||||
|
||||
/// Returns a human-readable description of what this event represents.
|
||||
///
|
||||
/// The description should clearly explain the significance of the event to help
|
||||
/// with analytics and monitoring. This is used both for documentation and
|
||||
/// telemetry dashboards.
|
||||
fn description(&self) -> &'static str;
|
||||
|
||||
/// Determines if an event is enabled in the current build. This only works when all
|
||||
/// feature flags are set appropriately, so this should be used when running
|
||||
/// the bundled app.
|
||||
fn enablement_state(&self) -> EnablementState;
|
||||
|
||||
/// Returns whether this event contains user-generated content (UGC).
|
||||
///
|
||||
/// Events containing UGC may need special handling for privacy and data
|
||||
/// retention reasons. This flag helps route the event to the appropriate
|
||||
/// analytics destination.
|
||||
fn contains_ugc(&self) -> bool;
|
||||
|
||||
/// Returns an iterator over the descriptors for all telemetry events of this type.
|
||||
fn event_descs() -> impl Iterator<Item = Box<dyn TelemetryEventDesc>>;
|
||||
}
|
||||
|
||||
@@ -72,40 +29,28 @@ macro_rules! register_telemetry_event {
|
||||
};
|
||||
}
|
||||
|
||||
/// Marker trait for known telemetry events. We rely on this to print an exhaustive telemetry
|
||||
/// table in Warp's documentation.
|
||||
///
|
||||
/// DO NOT implement this trait directly - use the [`register_telemetry_event!`] macro instead.
|
||||
pub trait RegisteredTelemetryEvent {}
|
||||
|
||||
/// An abstract description of a telemetry event we may emit. Every [`TelemetryEvent`] has a
|
||||
/// corresponding [`TelemetryEventDesc`].
|
||||
pub trait TelemetryEventDesc: fmt::Debug {
|
||||
pub trait TelemetryEventDesc: std::fmt::Debug {
|
||||
fn name(&self) -> &'static str;
|
||||
fn description(&self) -> &'static str;
|
||||
fn enablement_state(&self) -> EnablementState;
|
||||
}
|
||||
|
||||
/// A type-erased version of [`TelemetryEventRegistration`]. This is only used by the
|
||||
/// [`register_telemetry_event!`] macro implementation.
|
||||
#[doc(hidden)]
|
||||
pub trait AnyTelemetryEventRegistration: Sync {
|
||||
/// Returns an iterator over the descriptors for all telemetry events in this [`TelemetryEvent`] implementation.
|
||||
fn events(&self) -> Box<dyn Iterator<Item = Box<dyn TelemetryEventDesc>>>;
|
||||
}
|
||||
|
||||
/// Adapter for statically registering all [`TelemetryEvent`] implementations.
|
||||
#[doc(hidden)]
|
||||
pub struct TelemetryEventRegistration<T: TelemetryEvent + 'static> {
|
||||
/// Marker that `TelemetryEventRegistration` references `T`, but doesn't own a `T` value.
|
||||
/// See https://doc.rust-lang.org/nomicon/phantom-data.html
|
||||
_marker: PhantomData<fn(T) -> T>,
|
||||
_marker: std::marker::PhantomData<fn(T) -> T>,
|
||||
}
|
||||
|
||||
impl<T: TelemetryEvent + 'static> TelemetryEventRegistration<T> {
|
||||
pub const fn adapt() -> &'static dyn AnyTelemetryEventRegistration {
|
||||
&Self {
|
||||
_marker: PhantomData,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,9 +61,6 @@ impl<T: TelemetryEvent + 'static> AnyTelemetryEventRegistration for TelemetryEve
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an iterator over all discriminants of `T` as [`TelemetryEventDesc`]s.
|
||||
///
|
||||
/// Telemetry events that use [`strum`] may use this to implement [`TelemetryEvent::event_descs`].
|
||||
pub fn enum_events<T>() -> impl Iterator<Item = Box<dyn TelemetryEventDesc>>
|
||||
where
|
||||
T: strum::IntoDiscriminant,
|
||||
@@ -128,107 +70,47 @@ where
|
||||
.map(|discriminant| Box::new(discriminant) as Box<dyn TelemetryEventDesc>)
|
||||
}
|
||||
|
||||
// Collect adapters for all registered telemetry events. Because `inventory::collect!` requires a
|
||||
// concrete type, we use `&static dyn Trait` to erase the generics.
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
inventory::collect!(&'static dyn AnyTelemetryEventRegistration);
|
||||
|
||||
/// Returns all registered telemetry events. This is not available in WASM builds, as it relies on
|
||||
/// the [`inventory`] crate, which does not fully work in our WASM configuration.
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub fn all_events() -> impl Iterator<Item = Box<dyn TelemetryEventDesc>> {
|
||||
inventory::iter::<&'static dyn AnyTelemetryEventRegistration>().flat_map(|meta| meta.events())
|
||||
}
|
||||
|
||||
// Sends a telemetry `track` event to Rudderstack asynchronously. It adds events to the static
|
||||
// telemetry queue that is periodically flushed to the Rudderstack API.
|
||||
// This is the recommended way of recording telemetry events.
|
||||
// You should almost always use this, unless the recording is time-sensitive and cannot be lost.
|
||||
// To send a telemetry event synchronously, use [`send_telemetry_sync_from_ctx`].
|
||||
/// No-op: telemetry has been removed from Galaxy.
|
||||
#[macro_export]
|
||||
macro_rules! send_telemetry_from_ctx {
|
||||
($event:expr, $ctx:expr) => {
|
||||
#[allow(unused_imports)]
|
||||
use galaxy_core::telemetry::TelemetryEvent as _;
|
||||
let event = $event;
|
||||
if event.enablement_state().is_enabled() {
|
||||
let auth_state =
|
||||
<$crate::telemetry::TelemetryContextModel as galaxyui::SingletonEntity>::handle(
|
||||
$ctx,
|
||||
)
|
||||
.as_ref($ctx);
|
||||
let user_id = auth_state.user_id($ctx);
|
||||
let anonymous_id = auth_state.anonymous_id($ctx);
|
||||
galaxyui::record_telemetry_from_ctx!(
|
||||
user_id,
|
||||
anonymous_id,
|
||||
event.name().into(),
|
||||
event.payload(),
|
||||
event.contains_ugc(),
|
||||
$ctx
|
||||
);
|
||||
}
|
||||
let _ = &$event;
|
||||
let _ = &$ctx;
|
||||
};
|
||||
}
|
||||
|
||||
/// Sends telemetry `track` event to Rudderstack API asynchronously. This is the same as the
|
||||
/// [`send_telemetry_from_ctx`], except it can be called in instances where you only have
|
||||
/// a `AppContext` rather than a `ViewContext`/`ModelContext`.
|
||||
///
|
||||
/// If possible, use [`send_telemetry_from_ctx`].
|
||||
/// No-op: telemetry has been removed from Galaxy.
|
||||
#[macro_export]
|
||||
macro_rules! send_telemetry_from_app_ctx {
|
||||
($event:expr, $app_ctx:expr) => {
|
||||
let event = $event;
|
||||
if event.enablement_state().is_enabled() {
|
||||
let auth_state =
|
||||
<$crate::telemetry::TelemetryContextModel as galaxyui::SingletonEntity>::handle(
|
||||
$app_ctx,
|
||||
)
|
||||
.as_ref($app_ctx);
|
||||
let user_id = auth_state.user_id($app_ctx.as_ref());
|
||||
let anonymous_id = auth_state.anonymous_id($app_ctx.as_ref());
|
||||
galaxyui::record_telemetry_on_executor!(
|
||||
user_id,
|
||||
anonymous_id,
|
||||
event.name().into(),
|
||||
event.payload(),
|
||||
event.contains_ugc(),
|
||||
$app_ctx.background_executor()
|
||||
);
|
||||
}
|
||||
let _ = &$event;
|
||||
let _ = &$app_ctx;
|
||||
};
|
||||
}
|
||||
|
||||
/// Gives information about when a telemetry event is enabled.
|
||||
#[derive(Debug)]
|
||||
pub enum EnablementState {
|
||||
Always,
|
||||
/// The telemetry event is enabled when a particular feature flag is enabled.
|
||||
Flag(FeatureFlag),
|
||||
/// The event is enabled if the app is running in one of the contained channels.
|
||||
ChannelSpecific {
|
||||
channels: Vec<Channel>,
|
||||
},
|
||||
ChannelSpecific { channels: Vec<crate::channel::Channel> },
|
||||
}
|
||||
|
||||
impl EnablementState {
|
||||
pub fn is_enabled(&self) -> bool {
|
||||
match self {
|
||||
EnablementState::Always => true,
|
||||
EnablementState::Flag(flag) => flag.is_enabled(),
|
||||
EnablementState::ChannelSpecific { channels } => {
|
||||
let app_channel = ChannelState::channel();
|
||||
channels.contains(&app_channel)
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for the context provider that allows us to send telemetry payloads.
|
||||
pub trait TelemetryContextProvider {
|
||||
fn user_id(&self, ctx: &AppContext) -> Option<String>;
|
||||
|
||||
fn anonymous_id(&self, ctx: &AppContext) -> String;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use galaxyui::{
|
||||
Entity, ModelContext, SingletonEntity,
|
||||
};
|
||||
|
||||
use super::{builder::UiBuilder, theme::WarpTheme};
|
||||
use super::{builder::UiBuilder, theme::GalaxyTheme};
|
||||
|
||||
/// The standard font size to use for headers (e.g.: in dialogs).
|
||||
const HEADER_FONT_SIZE: f32 = 18.;
|
||||
@@ -17,7 +17,7 @@ pub const DEFAULT_COMMAND_PALETTE_FONT_SIZE: f32 = 14.0;
|
||||
/// to individually listen for changes. The most prominent examples are
|
||||
/// settings related to themes and fonts.
|
||||
pub struct Appearance {
|
||||
theme: WarpTheme,
|
||||
theme: GalaxyTheme,
|
||||
monospace_font_family: FamilyId,
|
||||
monospace_font_size: f32,
|
||||
monospace_font_weight: Weight,
|
||||
@@ -71,7 +71,7 @@ pub enum AppearanceEvent {
|
||||
impl Appearance {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
theme: WarpTheme,
|
||||
theme: GalaxyTheme,
|
||||
monospace_font_family: FamilyId,
|
||||
monospace_font_size: f32,
|
||||
monospace_font_weight: Weight,
|
||||
@@ -105,7 +105,7 @@ impl Appearance {
|
||||
|
||||
use crate::ui::theme::{mock_terminal_colors, Details, Fill};
|
||||
|
||||
let mock_theme = WarpTheme::new(
|
||||
let mock_theme = GalaxyTheme::new(
|
||||
Fill::Solid(ColorU::from_u32(0x000000ff)),
|
||||
ColorU::from_u32(0xffffffff),
|
||||
Fill::Solid(ColorU::new(18, 123, 156, 255)),
|
||||
@@ -137,7 +137,7 @@ impl Appearance {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_theme(&mut self, new_theme: WarpTheme, ctx: &mut ModelContext<Self>) {
|
||||
pub fn set_theme(&mut self, new_theme: GalaxyTheme, ctx: &mut ModelContext<Self>) {
|
||||
self.theme = new_theme;
|
||||
self.ui_builder = UiBuilder::new(
|
||||
self.theme.clone(),
|
||||
@@ -274,7 +274,7 @@ impl Appearance {
|
||||
&self.ui_builder
|
||||
}
|
||||
|
||||
pub fn theme(&self) -> &WarpTheme {
|
||||
pub fn theme(&self) -> &GalaxyTheme {
|
||||
&self.theme
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||
|
||||
use super::color::{blend::Blend, contrast::MinimumAllowedContrast, ContrastingColor};
|
||||
use super::theme::color::internal_colors::{self, text_main};
|
||||
use super::theme::{Fill, WarpTheme};
|
||||
use super::theme::{Fill, GalaxyTheme};
|
||||
use galaxyui::color::ColorU;
|
||||
use galaxyui::elements::{
|
||||
ChildAnchor, ConstrainedBox, Container, CornerRadius, CrossAxisAlignment, Flex, Hoverable,
|
||||
@@ -59,7 +59,7 @@ pub const DEFAULT_KEYBOARD_SHORTCUT_HEIGHT: f32 = 24.;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct UiBuilder {
|
||||
warp_theme: WarpTheme,
|
||||
warp_theme: GalaxyTheme,
|
||||
ui_font_family: FamilyId,
|
||||
ui_font_size: f32,
|
||||
command_palette_font_size: f32,
|
||||
@@ -68,7 +68,7 @@ pub struct UiBuilder {
|
||||
|
||||
impl UiBuilder {
|
||||
pub fn new(
|
||||
warp_theme: WarpTheme,
|
||||
warp_theme: GalaxyTheme,
|
||||
ui_font_family: FamilyId,
|
||||
ui_font_size: f32,
|
||||
command_palette_font_size: f32,
|
||||
@@ -1196,7 +1196,7 @@ impl UiBuilder {
|
||||
self.command_palette_font_size
|
||||
}
|
||||
|
||||
pub fn warp_theme(&self) -> &WarpTheme {
|
||||
pub fn warp_theme(&self) -> &GalaxyTheme {
|
||||
&self.warp_theme
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use self::internal_colors::{
|
||||
neutral_4,
|
||||
};
|
||||
|
||||
use super::{AnsiColor, AnsiColorIdentifier, Fill, TerminalColors, WarpTheme};
|
||||
use super::{AnsiColor, AnsiColorIdentifier, Fill, TerminalColors, GalaxyTheme};
|
||||
|
||||
use crate::ui::color::{
|
||||
blend::Blend,
|
||||
@@ -88,7 +88,7 @@ impl Default for CustomDetails {
|
||||
}
|
||||
|
||||
// Core colors
|
||||
impl WarpTheme {
|
||||
impl GalaxyTheme {
|
||||
pub fn accent(&self) -> Fill {
|
||||
self.accent
|
||||
}
|
||||
@@ -225,7 +225,7 @@ impl WarpTheme {
|
||||
}
|
||||
|
||||
// Feature-specific theme colors
|
||||
impl WarpTheme {
|
||||
impl GalaxyTheme {
|
||||
pub fn foreground_button_color(&self) -> Fill {
|
||||
let details = self.details();
|
||||
self.background.blend(
|
||||
@@ -362,7 +362,7 @@ impl WarpTheme {
|
||||
}
|
||||
|
||||
// ANSI color blends
|
||||
impl WarpTheme {
|
||||
impl GalaxyTheme {
|
||||
pub fn ansi_bg(&self, ansi_color: AnsiColor) -> ColorU {
|
||||
let ansi_fill = Fill::from(ansi_color);
|
||||
self.background()
|
||||
@@ -419,30 +419,30 @@ impl WarpTheme {
|
||||
}
|
||||
|
||||
/// Internal color system tokens, defined in "Colors" [Figma project](https://www.figma.com/design/dnvTdLbfFaosFSP00F30S0/Colors).
|
||||
/// Should not be used directly outside of reusable components. Use color methods on `WarpTheme` instead.
|
||||
/// Should not be used directly outside of reusable components. Use color methods on `GalaxyTheme` instead.
|
||||
pub mod internal_colors {
|
||||
use galaxyui::color::ColorU;
|
||||
|
||||
use super::{Fill, WarpTheme};
|
||||
use super::{Fill, GalaxyTheme};
|
||||
use crate::ui::color::blend::Blend;
|
||||
use crate::ui::color::coloru_with_opacity;
|
||||
|
||||
/// Calculates the font color based on contrast needs for text legibility.
|
||||
/// The font color is a mixture of the `warp_theme`'s background and foreground
|
||||
/// colors, and the supplied `background` color.
|
||||
fn font_color(warp_theme: &WarpTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
fn font_color(warp_theme: &GalaxyTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
warp_theme.font_color(background).into_solid()
|
||||
}
|
||||
|
||||
/// Used for UI elements like buttons to which we want to call attention.
|
||||
/// Allows gradients so shouldn't be used for small elements.
|
||||
pub fn accent(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.accent()
|
||||
}
|
||||
|
||||
/// Hover state for UI elements like buttons to which we want to call attention.
|
||||
/// Allows gradients so shouldn't be used for small elements.
|
||||
pub fn accent_hover(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_hover(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme
|
||||
.accent()
|
||||
.blend(&warp_theme.foreground().with_opacity(40))
|
||||
@@ -452,148 +452,148 @@ pub mod internal_colors {
|
||||
/// to which we want to call attention.
|
||||
/// Allows gradients so shouldn't be used for small elements.
|
||||
#[allow(dead_code)]
|
||||
pub fn accent_pressed(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_pressed(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme
|
||||
.accent()
|
||||
.blend(&warp_theme.background().with_opacity(30))
|
||||
}
|
||||
|
||||
/// The color of most text throughout the UI.
|
||||
pub fn text_main(warp_theme: &WarpTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
pub fn text_main(warp_theme: &GalaxyTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
coloru_with_opacity(font_color(warp_theme, background), 90)
|
||||
}
|
||||
|
||||
/// The color of subheaders and similar lower priority text.
|
||||
pub fn text_sub(warp_theme: &WarpTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
pub fn text_sub(warp_theme: &GalaxyTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
coloru_with_opacity(font_color(warp_theme, background), 60)
|
||||
}
|
||||
|
||||
/// The color of text elements that are disabled or the lowest priority.
|
||||
pub fn text_disabled(warp_theme: &WarpTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
pub fn text_disabled(warp_theme: &GalaxyTheme, background: impl Into<ColorU>) -> ColorU {
|
||||
coloru_with_opacity(font_color(warp_theme, background), 40)
|
||||
}
|
||||
|
||||
// TODO (roland): evaluate whether text_disabled above is intentionally different or if it should be consolidated with this
|
||||
// which matches figma mocks.
|
||||
pub fn semantic_text_disabled(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn semantic_text_disabled(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&fg_overlay_5(warp_theme))
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn neutral_1(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_1(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(5))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn neutral_2(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_2(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(10))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn neutral_3(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_3(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(15))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn neutral_4(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_4(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(20))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn neutral_5(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_5(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(40))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn neutral_6(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_6(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(60))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn neutral_7(warp_theme: &WarpTheme) -> ColorU {
|
||||
pub fn neutral_7(warp_theme: &GalaxyTheme) -> ColorU {
|
||||
warp_theme
|
||||
.background()
|
||||
.blend(&warp_theme.foreground().with_opacity(90))
|
||||
.into_solid()
|
||||
}
|
||||
|
||||
pub fn fg_overlay_1(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_1(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(5)
|
||||
}
|
||||
|
||||
pub fn fg_overlay_2(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_2(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(10)
|
||||
}
|
||||
|
||||
pub fn fg_overlay_3(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_3(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(15)
|
||||
}
|
||||
|
||||
pub fn fg_overlay_4(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_4(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(20)
|
||||
}
|
||||
|
||||
pub fn fg_overlay_5(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_5(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(40)
|
||||
}
|
||||
|
||||
pub fn fg_overlay_6(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_6(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(60)
|
||||
}
|
||||
|
||||
pub fn fg_overlay_7(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn fg_overlay_7(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.foreground().with_opacity(90)
|
||||
}
|
||||
|
||||
pub fn accent_bg_strong(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_bg_strong(warp_theme: &GalaxyTheme) -> Fill {
|
||||
Fill::Solid(warp_theme.background().into_solid())
|
||||
.blend(&warp_theme.accent().with_opacity(60))
|
||||
}
|
||||
|
||||
pub fn accent_bg(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_bg(warp_theme: &GalaxyTheme) -> Fill {
|
||||
Fill::Solid(warp_theme.background().into_solid())
|
||||
.blend(&warp_theme.accent().with_opacity(40))
|
||||
}
|
||||
|
||||
pub fn accent_fg_strong(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_fg_strong(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme
|
||||
.foreground()
|
||||
.blend(&warp_theme.accent().with_opacity(60))
|
||||
}
|
||||
|
||||
pub fn accent_fg(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_fg(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme
|
||||
.foreground()
|
||||
.blend(&warp_theme.accent().with_opacity(40))
|
||||
}
|
||||
|
||||
pub fn accent_overlay_1(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_overlay_1(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.accent().with_opacity(10)
|
||||
}
|
||||
|
||||
pub fn accent_overlay_2(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_overlay_2(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.accent().with_opacity(25)
|
||||
}
|
||||
|
||||
pub fn accent_overlay_3(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_overlay_3(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.accent().with_opacity(40)
|
||||
}
|
||||
|
||||
pub fn accent_overlay_4(warp_theme: &WarpTheme) -> Fill {
|
||||
pub fn accent_overlay_4(warp_theme: &GalaxyTheme) -> Fill {
|
||||
warp_theme.accent().with_opacity(60)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ impl TerminalColors {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||
pub struct WarpTheme {
|
||||
pub struct GalaxyTheme {
|
||||
background: Fill,
|
||||
accent: Fill,
|
||||
#[serde(with = "hex_color")]
|
||||
@@ -617,7 +617,7 @@ pub struct WarpTheme {
|
||||
name: Option<String>,
|
||||
}
|
||||
|
||||
impl WarpTheme {
|
||||
impl GalaxyTheme {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
bg: Fill,
|
||||
@@ -629,7 +629,7 @@ impl WarpTheme {
|
||||
background_image: Option<Image>,
|
||||
name: Option<String>,
|
||||
) -> Self {
|
||||
WarpTheme {
|
||||
GalaxyTheme {
|
||||
background: bg,
|
||||
foreground,
|
||||
accent,
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::*;
|
||||
|
||||
#[test]
|
||||
fn serialize_test() {
|
||||
let theme = WarpTheme::new(
|
||||
let theme = GalaxyTheme::new(
|
||||
Fill::Solid(ColorU::from_u32(0x20A5BAFF)),
|
||||
ColorU::from_u32(0x20A5BAFF),
|
||||
Fill::Solid(ColorU::from_u32(0x20A5BAFF)),
|
||||
@@ -45,7 +45,7 @@ name: test_theme
|
||||
|
||||
#[test]
|
||||
fn deserialize_with_name_test() {
|
||||
let theme = serde_yaml::from_str::<WarpTheme>(
|
||||
let theme = serde_yaml::from_str::<GalaxyTheme>(
|
||||
r##"---
|
||||
background: "#20a5ba"
|
||||
accent: "#20a5ba"
|
||||
@@ -75,7 +75,7 @@ name: test_theme
|
||||
)
|
||||
.expect("Couldn't deserialize");
|
||||
|
||||
let expected_theme = WarpTheme::new(
|
||||
let expected_theme = GalaxyTheme::new(
|
||||
Fill::Solid(ColorU::from_u32(0x20A5BAFF)),
|
||||
ColorU::from_u32(0x20A5BAFF),
|
||||
Fill::Solid(ColorU::from_u32(0x20A5BAFF)),
|
||||
@@ -91,7 +91,7 @@ name: test_theme
|
||||
|
||||
#[test]
|
||||
fn deserialize_without_name_test() {
|
||||
let theme = serde_yaml::from_str::<WarpTheme>(
|
||||
let theme = serde_yaml::from_str::<GalaxyTheme>(
|
||||
r##"---
|
||||
background: "#20a5ba"
|
||||
accent: "#20a5ba"
|
||||
@@ -120,7 +120,7 @@ terminal_colors:
|
||||
)
|
||||
.expect("Couldn't deserialize");
|
||||
|
||||
let expected_theme = WarpTheme::new(
|
||||
let expected_theme = GalaxyTheme::new(
|
||||
Fill::Solid(ColorU::from_u32(0x20A5BAFF)),
|
||||
ColorU::from_u32(0x20A5BAFF),
|
||||
Fill::Solid(ColorU::from_u32(0x20A5BAFF)),
|
||||
|
||||
Reference in New Issue
Block a user