feat(layout): relax MAM_MIN_PANE_COLS to 15 and remove vertical height constraints for scrollable terminal split
This commit is contained in:
@@ -70,8 +70,8 @@ def extract_panes(data: Dict[str, Any]) -> List[PaneInfo]:
|
||||
|
||||
def compute_2xk_layout(
|
||||
data: Dict[str, Any],
|
||||
min_cols: int = 40,
|
||||
min_rows: int = 20,
|
||||
min_cols: int = 15,
|
||||
min_rows: int = 0,
|
||||
max_columns: Optional[int] = None,
|
||||
default_anchor_id: Optional[str] = None
|
||||
) -> LayoutDecision:
|
||||
@@ -90,8 +90,8 @@ def compute_2xk_layout(
|
||||
if len(panes) == 1:
|
||||
p = panes[0]
|
||||
# In 2xK grid, 1 pane -> 2 panes: split down to create top and bottom rows
|
||||
# Check height overflow if dimensions known
|
||||
if p.height > 0 and p.height // 2 < min_rows:
|
||||
# Check height overflow only if min_rows > 0 is explicitly configured
|
||||
if min_rows > 0 and p.height > 0 and p.height // 2 < min_rows:
|
||||
# If height is too small for 2 rows, try splitting right if width allows
|
||||
if p.width > 0 and p.width // 2 >= min_cols:
|
||||
return LayoutDecision(target_pane_id=p.pane_id, direction="right", reason="single_pane_height_constrained")
|
||||
@@ -153,8 +153,8 @@ def compute_2xk_layout(
|
||||
|
||||
if singleton_col is not None:
|
||||
target_p = singleton_col[0]
|
||||
# Check height
|
||||
if target_p.height > 0 and target_p.height // 2 < min_rows:
|
||||
# Check height only if min_rows > 0
|
||||
if min_rows > 0 and target_p.height > 0 and target_p.height // 2 < min_rows:
|
||||
return LayoutDecision(target_pane_id=target_p.pane_id, direction="overflow", is_overflow=True, reason="singleton_height_overflow")
|
||||
return LayoutDecision(target_pane_id=target_p.pane_id, direction="down", reason="fill_singleton_column")
|
||||
|
||||
@@ -176,7 +176,7 @@ def _env_int(*names: str, default: Optional[int] = None) -> Optional[int]:
|
||||
"""First *valid* int among the env vars in *names*, else `default`.
|
||||
|
||||
`default` is an explicit parameter rather than an `or` at the call site so a
|
||||
legitimate 0 survives (MAM_MIN_PANE_COLS=0 means 0, not the 40 default).
|
||||
legitimate 0 survives (MAM_MIN_PANE_COLS=0 means 0, not the 15 default).
|
||||
|
||||
An unparsable value is skipped rather than raised or treated as terminal: a
|
||||
typo in an operator's shell must not take the whole layout call down (lib.sh
|
||||
@@ -198,8 +198,8 @@ def _env_int(*names: str, default: Optional[int] = None) -> Optional[int]:
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Compute 2xK grid TUI layout split direction")
|
||||
parser.add_argument("--min-cols", type=int, default=_env_int("MAM_MIN_COLS", "MAM_MIN_PANE_COLS", default=40))
|
||||
parser.add_argument("--min-rows", type=int, default=_env_int("MAM_MIN_ROWS", "MAM_MIN_PANE_ROWS", default=20))
|
||||
parser.add_argument("--min-cols", type=int, default=_env_int("MAM_MIN_COLS", "MAM_MIN_PANE_COLS", default=15))
|
||||
parser.add_argument("--min-rows", type=int, default=_env_int("MAM_MIN_ROWS", "MAM_MIN_PANE_ROWS", default=0))
|
||||
parser.add_argument("--max-cols", type=int, default=_env_int("MAM_MAX_COLS", "MAM_MAX_PANE_COLS"))
|
||||
parser.add_argument("--sample-pane", type=str, default=None)
|
||||
parser.add_argument("--json", action="store_true", help="Output full JSON decision")
|
||||
|
||||
Reference in New Issue
Block a user