feat(layout): relax MAM_MIN_PANE_COLS to 15 and remove vertical height constraints for scrollable terminal split

This commit is contained in:
2026-08-26 09:44:02 +09:00
parent d1efce2971
commit f3ac68f36d
5 changed files with 134 additions and 166 deletions
+51 -54
View File
@@ -865,88 +865,85 @@ def test_lib_sh_new_session_passes_mam_ws_label(mam_sandbox):
# ==============================================================================
# FEATURE: 2xK Grid Layout Engine (min_cols=40 & multi-pane workspace tiling)
# FEATURE: 2xK Grid Layout Engine (min_cols=15 & min_rows=0 multi-pane workspace tiling)
# ==============================================================================
def test_layout_default_min_cols_40_in_tier1():
"""Verify default min_cols=40 behavior across compute_2xk_layout in Tier 1 suite."""
def test_layout_default_min_cols_15_in_tier1():
"""Verify default min_cols=15 behavior across compute_2xk_layout in Tier 1 suite."""
from lib_py.layout import compute_2xk_layout
# 1. 2 panes in 80 col width (80 // 2 = 40 == min_cols 40) -> splits right cleanly
payload_80 = {
# 1. 2 panes in 30 col width (30 // 2 = 15 == min_cols 15) -> splits right cleanly
payload_30 = {
"result": {
"panes": [
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": 80, "height": 40}},
{"pane_id": "p2", "rect": {"x": 0, "y": 40, "width": 80, "height": 40}}
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": 30, "height": 20}},
{"pane_id": "p2", "rect": {"x": 0, "y": 20, "width": 30, "height": 20}}
]
}
}
decision = compute_2xk_layout(payload_80)
decision = compute_2xk_layout(payload_30)
assert decision.direction == "right"
assert not decision.is_overflow
assert decision.reason == "new_column_right"
# 2. 2 panes in 79 col width (79 // 2 = 39 < min_cols 40) -> column_width_overflow
payload_79 = {
# 2. 2 panes in 29 col width (29 // 2 = 14 < min_cols 15) -> column_width_overflow
payload_29 = {
"result": {
"panes": [
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": 79, "height": 40}},
{"pane_id": "p2", "rect": {"x": 0, "y": 40, "width": 79, "height": 40}}
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": 29, "height": 20}},
{"pane_id": "p2", "rect": {"x": 0, "y": 20, "width": 29, "height": 20}}
]
}
}
decision_overflow = compute_2xk_layout(payload_79)
decision_overflow = compute_2xk_layout(payload_29)
assert decision_overflow.direction == "overflow"
assert decision_overflow.is_overflow
assert decision_overflow.reason == "column_width_overflow"
def test_layout_single_workspace_90_100_cols_tiling_tier1():
"""Verify 3-4 agents tiling in standard 90-100 col terminal windows within a single workspace."""
def test_layout_single_workspace_54x23_compact_tiling_tier1():
"""Verify 3-4 agents tiling in standard 80x24 (54x23 content) terminal windows within a single workspace."""
from lib_py.layout import compute_2xk_layout
for total_w in [90, 100]:
half_w = total_w // 2
# Step 1: 1 pane -> 2 panes (split down without height constraint)
p1 = {"result": {"panes": [{"pane_id": "p1", "rect": {"x": 26, "y": 1, "width": 54, "height": 23}}]}}
d1 = compute_2xk_layout(p1)
assert d1.direction == "down"
assert d1.target_pane_id == "p1"
assert not d1.is_overflow
# Step 1: 1 pane -> 2 panes (split down)
p1 = {"result": {"panes": [{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": total_w, "height": 40}}]}}
d1 = compute_2xk_layout(p1)
assert d1.direction == "down"
assert d1.target_pane_id == "p1"
assert not d1.is_overflow
# Step 2: 2 panes -> 3 panes (split right to open 2nd column)
p2 = {"result": {"panes": [
{"pane_id": "p1", "rect": {"x": 26, "y": 1, "width": 54, "height": 11}},
{"pane_id": "p2", "rect": {"x": 26, "y": 12, "width": 54, "height": 11}}
]}}
d2 = compute_2xk_layout(p2)
assert d2.direction == "right"
assert d2.target_pane_id == "p1"
assert not d2.is_overflow
# Step 2: 2 panes -> 3 panes (split right to open 2nd column)
p2 = {"result": {"panes": [
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": total_w, "height": 20}},
{"pane_id": "p2", "rect": {"x": 0, "y": 20, "width": total_w, "height": 20}}
]}}
d2 = compute_2xk_layout(p2)
assert d2.direction == "right"
assert d2.target_pane_id == "p1"
assert not d2.is_overflow
# Step 3: 3 panes -> 4 panes (split singleton 2nd column down)
p3 = {"result": {"panes": [
{"pane_id": "p1", "rect": {"x": 26, "y": 1, "width": 27, "height": 11}},
{"pane_id": "p2", "rect": {"x": 26, "y": 12, "width": 27, "height": 11}},
{"pane_id": "p3", "rect": {"x": 53, "y": 1, "width": 27, "height": 23}}
]}}
d3 = compute_2xk_layout(p3)
assert d3.direction == "down"
assert d3.target_pane_id == "p3"
assert not d3.is_overflow
# Step 3: 3 panes -> 4 panes (split singleton 2nd column down)
p3 = {"result": {"panes": [
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": half_w, "height": 20}},
{"pane_id": "p2", "rect": {"x": 0, "y": 20, "width": half_w, "height": 20}},
{"pane_id": "p3", "rect": {"x": half_w, "y": 0, "width": half_w, "height": 40}}
]}}
d3 = compute_2xk_layout(p3)
assert d3.direction == "down"
assert d3.target_pane_id == "p3"
assert not d3.is_overflow
# Step 4: 4 panes (2x2 complete) -> 5th agent overflows to fresh workspace
p4 = {"result": {"panes": [
{"pane_id": "p1", "rect": {"x": 0, "y": 0, "width": half_w, "height": 20}},
{"pane_id": "p2", "rect": {"x": 0, "y": 20, "width": half_w, "height": 20}},
{"pane_id": "p3", "rect": {"x": half_w, "y": 0, "width": half_w, "height": 20}},
{"pane_id": "p4", "rect": {"x": half_w, "y": 20, "width": half_w, "height": 20}}
]}}
d4 = compute_2xk_layout(p4)
assert d4.direction == "overflow"
assert d4.is_overflow
assert d4.reason == "column_width_overflow"
# Step 4: 4 panes (2x2 complete) -> 5th agent overflows to fresh workspace (27 // 2 = 13 < 15)
p4 = {"result": {"panes": [
{"pane_id": "p1", "rect": {"x": 26, "y": 1, "width": 27, "height": 11}},
{"pane_id": "p2", "rect": {"x": 26, "y": 12, "width": 27, "height": 11}},
{"pane_id": "p3", "rect": {"x": 53, "y": 1, "width": 27, "height": 11}},
{"pane_id": "p4", "rect": {"x": 53, "y": 12, "width": 27, "height": 11}}
]}}
d4 = compute_2xk_layout(p4)
assert d4.direction == "overflow"
assert d4.is_overflow
assert d4.reason == "column_width_overflow"