diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index d720dfb2a1..0bf0cd8c0f 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -121,7 +121,7 @@ smallvec.workspace = true smol.workspace = true strum.workspace = true sum_tree.workspace = true -taffy = "=0.9.0" +taffy = { version = "=0.9.0", features = ["debug"] } thiserror.workspace = true util.workspace = true uuid.workspace = true diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index 09afbff929..0669d36b2c 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -23,6 +23,7 @@ use crate::{ MouseClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Overflow, ParentElement, Pixels, Point, Render, ScrollWheelEvent, SharedString, Size, Style, StyleRefinement, Styled, Task, TooltipId, Visibility, Window, WindowControlArea, point, px, size, + taffy::{CONTAINER_LAYOUT_ID_TO_DEBUG, LAYOUT_ID_TO_DEBUG}, }; use collections::HashMap; use refineable::Refineable; @@ -1298,7 +1299,23 @@ impl Element for Div { .iter_mut() .map(|child| child.request_layout(window, cx)) .collect::>(); - window.request_layout(style, child_layout_ids.iter().copied(), cx) + let layout_id = + window.request_layout(style, child_layout_ids.iter().copied(), cx); + if let Some(global_id) = global_id.as_ref() + && global_id.0.ends_with(&["api-key-editor".into()]) + { + LAYOUT_ID_TO_DEBUG.with_borrow_mut(|layout_id_to_debug| { + *layout_id_to_debug = Some(layout_id) + }); + } + if let Some(global_id) = global_id.as_ref() + && global_id.0.ends_with(&["open-router-container".into()]) + { + CONTAINER_LAYOUT_ID_TO_DEBUG.with_borrow_mut(|layout_id_to_debug| { + *layout_id_to_debug = Some(layout_id) + }); + } + layout_id }) }, ) diff --git a/crates/gpui/src/taffy.rs b/crates/gpui/src/taffy.rs index ee21ecd8c4..61736e456c 100644 --- a/crates/gpui/src/taffy.rs +++ b/crates/gpui/src/taffy.rs @@ -3,7 +3,7 @@ use crate::{ }; use collections::{FxHashMap, FxHashSet}; use smallvec::SmallVec; -use std::{fmt::Debug, ops::Range}; +use std::{cell::RefCell, fmt::Debug, ops::Range}; use taffy::{ TaffyTree, TraversePartialTree as _, geometry::{Point as TaffyPoint, Rect as TaffyRect, Size as TaffySize}, @@ -11,6 +11,14 @@ use taffy::{ tree::NodeId, }; +thread_local! { + pub static LAYOUT_ID_TO_DEBUG: RefCell> = const { RefCell::new(None) }; +} + +thread_local! { + pub static CONTAINER_LAYOUT_ID_TO_DEBUG: RefCell> = const { RefCell::new(None) }; +} + type NodeMeasureFn = Box< dyn FnMut(Size>, Size, &mut Window, &mut App) -> Size, >; @@ -198,6 +206,14 @@ impl TaffyLayoutEngine { ) .expect(EXPECT_MESSAGE); + LAYOUT_ID_TO_DEBUG.with_borrow(|layout_id_to_debug| { + println!("Layout ID Debug: {:?}", layout_id_to_debug); + }); + + CONTAINER_LAYOUT_ID_TO_DEBUG.with_borrow(|layout_id| { + println!("Container Layout ID Debug: {:?}\n", layout_id); + }); + // println!("compute_layout took {:?}", started_at.elapsed()); } diff --git a/crates/language_models/src/provider/open_router.rs b/crates/language_models/src/provider/open_router.rs index 3a492086f1..6e56bb5344 100644 --- a/crates/language_models/src/provider/open_router.rs +++ b/crates/language_models/src/provider/open_router.rs @@ -853,6 +853,7 @@ impl Render for ConfigurationView { div().child(Label::new("Loading credentials...")).into_any() } else if self.should_render_editor(cx) { v_flex() + .id("open-router-container") .size_full() .on_action(cx.listener(Self::save_api_key)) .child(Label::new("To use Zed's agent with OpenRouter, you need to add an API key. Follow these steps:")) @@ -872,6 +873,7 @@ impl Render for ConfigurationView { ) .child( h_flex() + .id("api-key-editor") .w_full() .my_2() .px_2()