Skip to content

Commit 1b08549

Browse files
oz-agentwarp-agent
andcommitted
Fix unreadable agent toolbelt chip text after theme change
The agent toolbelt editor (and agent input footer) snapshotted each context chip's text color when the chip renderer was constructed (`ContextChipKind::default_styles` -> `agent_view_chip_color`). That color is theme-derived, so after switching themes the cached value went stale — e.g. a color computed under a light theme (near-black) stayed on the chip when the user switched to a dark theme like Cyber Wave, rendering the value chips dark-on-dark and unreadable. The neighboring action chips were unaffected because they recompute `sub_text_color(background)` on every render. Recompute the agent-view chip color from the live theme at render time (mirroring the action chips), so the text always matches the current theme. Non-agent-view chips keep their snapshotted prompt colors. Co-Authored-By: Warp <agent@warp.dev>
1 parent 8d3baf9 commit 1b08549

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

app/src/context_chips/renderer.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use warpui::{Action, Element};
1414

1515
use super::context_chip::ContextChip;
1616
use super::display_chip::{chip_container, udi_font_size};
17-
use super::{spacing, ChipAvailability, ChipValue, ContextChipKind};
17+
use super::{agent_view_chip_color, spacing, ChipAvailability, ChipValue, ContextChipKind};
1818
use crate::appearance::Appearance;
1919
use crate::ui_components::icons;
2020

@@ -56,6 +56,12 @@ pub struct Renderer {
5656
remove_button_state_handle: MouseStateHandle,
5757
is_disabled: bool,
5858
tooltip_override_text: Option<String>,
59+
/// When true, the chip's text/icon color is recomputed from the live theme
60+
/// at render time (via [`agent_view_chip_color`]) instead of using the
61+
/// color snapshotted in `styles`. This keeps agent-view chips readable
62+
/// after a theme change, since `styles.value_color` is captured once at
63+
/// construction and would otherwise go stale.
64+
is_in_agent_view: bool,
5965
}
6066

6167
impl Renderer {
@@ -65,6 +71,7 @@ impl Renderer {
6571
value: ChipValue,
6672
styles: RendererStyles,
6773
availability: ChipAvailability,
74+
is_in_agent_view: bool,
6875
) -> Self {
6976
let is_disabled = !availability.is_enabled();
7077
let tooltip_override_text = availability.tooltip_override_text();
@@ -78,6 +85,7 @@ impl Renderer {
7885
remove_button_state_handle: Default::default(),
7986
is_disabled,
8087
tooltip_override_text,
88+
is_in_agent_view,
8189
}
8290
}
8391

@@ -104,6 +112,7 @@ impl Renderer {
104112
placeholder_value,
105113
styles,
106114
availability,
115+
is_in_agent_view,
107116
))
108117
}
109118

@@ -147,7 +156,14 @@ impl Renderer {
147156
remove_button: Option<Box<dyn Element>>,
148157
appearance: &Appearance,
149158
) -> Box<dyn Element> {
150-
let mut color = self.styles.value_color;
159+
// Agent-view chips recompute their color from the live theme so they
160+
// stay readable across theme changes; other chips keep the prompt color
161+
// snapshotted in `styles`.
162+
let mut color = if self.is_in_agent_view {
163+
agent_view_chip_color(appearance)
164+
} else {
165+
self.styles.value_color
166+
};
151167
if self.is_disabled {
152168
color.a = (color.a / 2).max(48);
153169
}

app/src/context_chips/renderer_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn test_constructor_availability_updates_disabled_state_and_tooltip_override() {
2424
ChipAvailability::Disabled(ChipDisabledReason::RequiresExecutable {
2525
command: "gh".to_string(),
2626
}),
27+
false,
2728
);
2829

2930
assert!(renderer.is_disabled);
@@ -51,6 +52,7 @@ fn test_constructor_availability_enabled_has_no_disabled_state_or_tooltip_overri
5152
Properties::default(),
5253
),
5354
ChipAvailability::Enabled,
55+
false,
5456
);
5557

5658
assert!(!renderer.is_disabled);

0 commit comments

Comments
 (0)