Repository navigation
fix(ui): rows that don't fit wrap or scroll, in a long language and a small window #3600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
333bd0c
2d38ee5
b649a76
b34f015
5b470f0
a708647
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,9 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { | |
| .id_salt("assistant_settings_scroll") | ||
| .auto_shrink([false, true]) | ||
| .min_scrolled_height(0.0) | ||
| .max_height((ui.available_height() - 8.0).max(0.0)) | ||
| // The conversation keeps room for a few lines below, where it scrolls; in a short pane, | ||
| // less, so the settings keep most of it. | ||
| .max_height((ui.available_height() - 8.0 - CONVERSATION_ROOM.min(ui.available_height() * 0.3)).max(0.0)) | ||
| .show(ui, |ui| { | ||
| egui::Frame::NONE.inner_margin(egui::Margin::symmetric(12, 4)).show(ui, |ui| settings(app, ui, t)); | ||
| }); | ||
|
|
@@ -95,6 +97,9 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { | |
| }); | ||
| } | ||
|
|
||
| /// The height the conversation keeps under open settings, at most: never over 30% of the pane. | ||
| const CONVERSATION_ROOM: f32 = 96.0; | ||
|
|
||
| fn composer_panel(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, busy: bool, ctx: &egui::Context) { | ||
| egui::Panel::bottom("assistant_composer") | ||
| .frame(egui::Frame::NONE.fill(t.pane).inner_margin(egui::Margin::symmetric(10, 8))) | ||
|
|
@@ -260,13 +265,14 @@ fn provider_settings(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, cfg: &mut Co | |
| .labelled_by(address_label.id); | ||
| ui.end_row(); | ||
| let key_label = ui.label(tl!("API key")); | ||
| ui.horizontal(|ui| { | ||
| ui.horizontal_wrapped(|ui| { | ||
| let hint = if preset.is_some_and(|p| p.keyless) { tl!("not needed") } else { tl!("paste your key") }; | ||
| let width = crate::widgets::fit(ui, 150.0); | ||
| ui.add( | ||
| egui::TextEdit::singleline(&mut cfg.key) | ||
| .id(egui::Id::unique(FIELDS[2])) | ||
| .password(!app.assistant.show_key) | ||
| .desired_width(150.0) | ||
| .desired_width(width) | ||
| .hint_text(hint), | ||
| ) | ||
| .labelled_by(key_label.id); | ||
|
|
@@ -870,7 +876,8 @@ fn transcript(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, ctx: &egui::Context | |
| ui.add_space(8.0); | ||
| let mut chosen = None; | ||
| for s in SUGGESTIONS { | ||
| let b = egui::Button::new(RichText::new(tl!(s)).small()).corner_radius(12); | ||
| // Wrapped: a suggestion is wider than a narrow pane. | ||
| let b = egui::Button::new(RichText::new(tl!(s)).small()).corner_radius(12).wrap(); | ||
| if ui.add(b).clicked() { | ||
| chosen = Some(tl!(s).to_string()); | ||
| } | ||
|
|
@@ -1480,6 +1487,10 @@ pub(crate) mod tests { | |
| ); | ||
| h.run_steps(4); | ||
| h.get_by_label("Tokens for this message: 1 234 in, 5 out"); | ||
| // Below the provider's settings, which leave the conversation its room: folded, they make | ||
| // room for it. | ||
| h.get_by_label("AI provider").click(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new click folds the provider settings, but nothing asserts that it did. The test would pass if this click did nothing, so the comment above it ("folded, they make room for it") isn't checked. Add an assertion after the fold that a control inside the provider settings is gone, or that the conversation's line is now reachable, so the test fails without the fold. Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left for the release quality pass. |
||
| h.run_steps(4); | ||
| h.get_by_label("Show the tokens each message uses").click(); | ||
| h.run_steps(4); | ||
| assert!(h.query_by_label("Tokens for this message: 1 234 in, 5 out").is_none()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buttons' row height is read from last frame's measurement. On the frame the row starts or stops wrapping (for example when the pane is resized), the box is sized with the previous height for one frame, so the wrapped row can sit past the pane's bottom edge until the next frame is drawn. egui repaints on resize, so this probably settles at once and is not a lasting clip. Worth a note in the comment, or a test that resizes the pane between two frames and checks the row's position in the second. This is a new point, not the earlier concern about the fixed budget, which this change addresses.
Category: quality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left for the release quality pass: egui draws the next frame at once on a resize, so the row settles there.