Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Michael Sloan
297fd858e8
Code for debugging issue with no width available
This commit enables extremely verbose taffy logging and adds output of the layout ids for the Open Router settings container ID and the ID for the text input that has the issue.  https://gist.github.com/mgsloan/28a2d8d9c9c803fc60898eae9db1ec8e is the subsets of the logs starting with the first line with the container ID and ending with the last line that has the container ID (see the end of the logs for these IDs)

Repro for the issue:

* Set ui_font_size to 20 in user settings.json
* Open zed agent settings
* Expand Open Router settings
* Resize panel until the API key input field becomes small
2025-08-14 19:10:19 -06:00
4 changed files with 38 additions and 3 deletions

View file

@ -121,7 +121,7 @@ smallvec.workspace = true
smol.workspace = true smol.workspace = true
strum.workspace = true strum.workspace = true
sum_tree.workspace = true sum_tree.workspace = true
taffy = "=0.9.0" taffy = { version = "=0.9.0", features = ["debug"] }
thiserror.workspace = true thiserror.workspace = true
util.workspace = true util.workspace = true
uuid.workspace = true uuid.workspace = true

View file

@ -23,6 +23,7 @@ use crate::{
MouseClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Overflow, ParentElement, Pixels, MouseClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Overflow, ParentElement, Pixels,
Point, Render, ScrollWheelEvent, SharedString, Size, Style, StyleRefinement, Styled, Task, Point, Render, ScrollWheelEvent, SharedString, Size, Style, StyleRefinement, Styled, Task,
TooltipId, Visibility, Window, WindowControlArea, point, px, size, TooltipId, Visibility, Window, WindowControlArea, point, px, size,
taffy::{CONTAINER_LAYOUT_ID_TO_DEBUG, LAYOUT_ID_TO_DEBUG},
}; };
use collections::HashMap; use collections::HashMap;
use refineable::Refineable; use refineable::Refineable;
@ -1298,7 +1299,23 @@ impl Element for Div {
.iter_mut() .iter_mut()
.map(|child| child.request_layout(window, cx)) .map(|child| child.request_layout(window, cx))
.collect::<SmallVec<_>>(); .collect::<SmallVec<_>>();
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
}) })
}, },
) )

View file

@ -3,7 +3,7 @@ use crate::{
}; };
use collections::{FxHashMap, FxHashSet}; use collections::{FxHashMap, FxHashSet};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{fmt::Debug, ops::Range}; use std::{cell::RefCell, fmt::Debug, ops::Range};
use taffy::{ use taffy::{
TaffyTree, TraversePartialTree as _, TaffyTree, TraversePartialTree as _,
geometry::{Point as TaffyPoint, Rect as TaffyRect, Size as TaffySize}, geometry::{Point as TaffyPoint, Rect as TaffyRect, Size as TaffySize},
@ -11,6 +11,14 @@ use taffy::{
tree::NodeId, tree::NodeId,
}; };
thread_local! {
pub static LAYOUT_ID_TO_DEBUG: RefCell<Option<LayoutId>> = const { RefCell::new(None) };
}
thread_local! {
pub static CONTAINER_LAYOUT_ID_TO_DEBUG: RefCell<Option<LayoutId>> = const { RefCell::new(None) };
}
type NodeMeasureFn = Box< type NodeMeasureFn = Box<
dyn FnMut(Size<Option<Pixels>>, Size<AvailableSpace>, &mut Window, &mut App) -> Size<Pixels>, dyn FnMut(Size<Option<Pixels>>, Size<AvailableSpace>, &mut Window, &mut App) -> Size<Pixels>,
>; >;
@ -198,6 +206,14 @@ impl TaffyLayoutEngine {
) )
.expect(EXPECT_MESSAGE); .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()); // println!("compute_layout took {:?}", started_at.elapsed());
} }

View file

@ -853,6 +853,7 @@ impl Render for ConfigurationView {
div().child(Label::new("Loading credentials...")).into_any() div().child(Label::new("Loading credentials...")).into_any()
} else if self.should_render_editor(cx) { } else if self.should_render_editor(cx) {
v_flex() v_flex()
.id("open-router-container")
.size_full() .size_full()
.on_action(cx.listener(Self::save_api_key)) .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:")) .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( .child(
h_flex() h_flex()
.id("api-key-editor")
.w_full() .w_full()
.my_2() .my_2()
.px_2() .px_2()