fix(core): prefer vertical layout categorically if there are less tha… (#31221)
…n 75 characters of width <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> Auto layout is always based on an aspect ratio which lead to horizontal layout even when there is very little horizontal space. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Auto layout prefers vertical layout with less than 75 characters of width which will allow 50 characters (75 * 2/3) for terminal output. It should be enough to show a URL in most cases:   ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
c92b4a3d50
commit
fa654c6520
@ -400,6 +400,11 @@ impl LayoutManager {
|
|||||||
/// - Number of tasks (single task prefers vertical layout)
|
/// - Number of tasks (single task prefers vertical layout)
|
||||||
/// - Minimum dimensions requirements
|
/// - Minimum dimensions requirements
|
||||||
fn is_vertical_layout_preferred(&self, terminal_width: u16, terminal_height: u16) -> bool {
|
fn is_vertical_layout_preferred(&self, terminal_width: u16, terminal_height: u16) -> bool {
|
||||||
|
// Screen is pretty narrow so always prefer vertical layout
|
||||||
|
if terminal_width < 75 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate aspect ratio (width/height)
|
// Calculate aspect ratio (width/height)
|
||||||
let aspect_ratio = terminal_width as f32 / terminal_height as f32;
|
let aspect_ratio = terminal_width as f32 / terminal_height as f32;
|
||||||
|
|
||||||
@ -865,6 +870,29 @@ mod tests {
|
|||||||
insta::assert_snapshot!(terminal.backend());
|
insta::assert_snapshot!(terminal.backend());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Visual test for narrow screen rendering (width < 75)
|
||||||
|
#[test]
|
||||||
|
fn test_visualize_narrow_screen_layout() {
|
||||||
|
// Create layout with auto mode, which should pick vertical layout for narrow screens
|
||||||
|
let mut layout_manager = LayoutManager::new(5);
|
||||||
|
layout_manager.set_mode(LayoutMode::Auto);
|
||||||
|
layout_manager.set_task_list_visibility(TaskListVisibility::Visible);
|
||||||
|
layout_manager.set_pane_arrangement(PaneArrangement::Single);
|
||||||
|
layout_manager.set_task_count(5);
|
||||||
|
|
||||||
|
// Test with a narrow screen (width < 75)
|
||||||
|
let terminal = render_layout(74, 40, &layout_manager);
|
||||||
|
insta::assert_snapshot!("narrow_screen_layout", terminal.backend());
|
||||||
|
|
||||||
|
// Also test with extremely narrow screen
|
||||||
|
let terminal = render_layout(50, 40, &layout_manager);
|
||||||
|
insta::assert_snapshot!("extremely_narrow_screen_layout", terminal.backend());
|
||||||
|
|
||||||
|
// Also test with slightly narrow screen
|
||||||
|
let terminal = render_layout(80, 40, &layout_manager);
|
||||||
|
insta::assert_snapshot!("slightly_narrow_screen_layout", terminal.backend());
|
||||||
|
}
|
||||||
|
|
||||||
// These tests will run even without the snapshot feature enabled
|
// These tests will run even without the snapshot feature enabled
|
||||||
// to verify layout calculations are correct
|
// to verify layout calculations are correct
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
source: packages/nx/src/native/tui/components/layout_manager.rs
|
||||||
|
expression: terminal.backend()
|
||||||
|
---
|
||||||
|
"┌Task List───────────────────────────────────────┐"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"└────────────────────────────────────────────────┘"
|
||||||
|
" "
|
||||||
|
"┌Terminal Pane 1─────────────────────────────────┐"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"└────────────────────────────────────────────────┘"
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
source: packages/nx/src/native/tui/components/layout_manager.rs
|
||||||
|
expression: terminal.backend()
|
||||||
|
---
|
||||||
|
"┌Task List───────────────────────────────────────────────────────────────┐"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"└────────────────────────────────────────────────────────────────────────┘"
|
||||||
|
" "
|
||||||
|
"┌Terminal Pane 1─────────────────────────────────────────────────────────┐"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"│ │"
|
||||||
|
"└────────────────────────────────────────────────────────────────────────┘"
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
source: packages/nx/src/native/tui/components/layout_manager.rs
|
||||||
|
expression: terminal.backend()
|
||||||
|
---
|
||||||
|
"┌Task List───────────────┐ ┌Terminal Pane 1───────────────────────────────────┐"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"│ │ │ │"
|
||||||
|
"└────────────────────────┘ └──────────────────────────────────────────────────┘"
|
||||||
Loading…
x
Reference in New Issue
Block a user