techfreakworm commited on
Commit
0cf63ed
·
unverified ·
1 Parent(s): 5a6543d

fix: after a run the head of its report fits in the rail with the monitor, so following it no longer slides the monitor's top out of view: the monitor gives up the height instead (#20)

Browse files

Review round 4, minor 6. fit() sized the rail at scroll 0 for the monitor, caption, panel and
Generate only; when a run ended, follow() scrolled the rail to bring the Done card's head (or a
failure's next step) in, which cropped the top 51 px of the result at 1366 and 1280. fit() now
counts that head, from Generate's foot in the rail's flow to the head's bottom plus its scroll
margin, and the monitor gives up the height, letterboxed, down to its 180 px floor; follow() and
fit() share reportTarget(), so they make room for, and follow, the same element. (The 89 px crop
when Generate is pressed with the rail scrolled, S5b, needs the monitor scroll repeated once the
start step's outputs land, in blocks.py.)

Files changed (2) hide show
  1. ltx25_studio/ui/chrome.py +32 -12
  2. tests/test_ui_shell.py +16 -0
ltx25_studio/ui/chrome.py CHANGED
@@ -850,7 +850,8 @@ _SCRIPT = """
850
  document.documentElement.style.setProperty(
851
  '--mr-rail-offset', (now + window.innerHeight - end) + 'px');
852
  };
853
- // At rail scroll 0 the rail holds the monitor, its caption, the cost panel and Generate.
 
854
  // Taller than the rail (a short window): the monitor gives up height first, down to
855
  // 180 px, letterboxed; whatever of the panel still runs under Generate fades into it, and
856
  // the figure line (figureLine, below) stands above the button if that hides the figure.
@@ -858,6 +859,27 @@ _SCRIPT = """
858
  // stays put from mode to mode.
859
  const MONITOR_FLOOR = 180;
860
  const CAPTION_LINES = 4;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
861
  const fit = () => {
862
  const rail = byId('rail'), monitor = byId('monitor'), caption = byId('monitor-caption');
863
  const cost = byId('cost'), commit = byId('commit'), line = byId('commit-line');
@@ -882,7 +904,11 @@ _SCRIPT = """
882
  .reduce((sum, note) => sum + note.offsetHeight + px(getComputedStyle(note).marginTop), 0);
883
  const lineShown = rail.classList.contains('mr-figure-under') && !!line && line.offsetHeight > 0;
884
  const commitH = commit.offsetHeight - (lineShown ? line.offsetHeight + px(ks.rowGap) : 0);
885
- const above = (m, c) => m + gap + c + gap + cost.offsetHeight + gap + px(ks.marginTop) + commitH;
 
 
 
 
886
  let monitorH = natural, captionMin = captionH;
887
  const over = above(natural, captionH) - avail;
888
  if (over > 0) monitorH = Math.max(MONITOR_FLOOR, natural - over);
@@ -953,16 +979,10 @@ _SCRIPT = """
953
  let lastReport = '';
954
  const follow = () => {
955
  const summary = byId('run-summary'), status = byId('run-status');
956
- const head = status ? status.querySelector('h3') : null;
957
- let key = '', target = null;
958
- if (summary && summary.offsetHeight > 0 && summary.textContent.trim()) {
959
- key = 'done:' + summary.textContent.trim().slice(0, 300);
960
- target = summary.querySelector('.mr-done-head') || summary;
961
- } else if (head) {
962
- key = 'failed:' + status.textContent.trim().slice(0, 300);
963
- const step = head.nextElementSibling;
964
- target = step && step.tagName === 'P' ? step : head;
965
- }
966
  if (key === lastReport) return;
967
  lastReport = key;
968
  if (target && wide()) target.scrollIntoView({ block: 'nearest', behavior: still() ? 'auto' : 'smooth' });
 
850
  document.documentElement.style.setProperty(
851
  '--mr-rail-offset', (now + window.innerHeight - end) + 'px');
852
  };
853
+ // At rail scroll 0 the rail holds the monitor, its caption, the cost panel and Generate,
854
+ // and after a run the head of its report.
855
  // Taller than the rail (a short window): the monitor gives up height first, down to
856
  // 180 px, letterboxed; whatever of the panel still runs under Generate fades into it, and
857
  // the figure line (figureLine, below) stands above the button if that hides the figure.
 
859
  // stays put from mode to mode.
860
  const MONITOR_FLOOR = 180;
861
  const CAPTION_LINES = 4;
862
+ // The head of a run's report: the Done card's head, or a failure's next step (its headline
863
+ // just above it). follow() brings it into view when a run ends; fit() makes room for it.
864
+ const reportTarget = () => {
865
+ const summary = byId('run-summary'), status = byId('run-status');
866
+ if (summary && summary.offsetHeight > 0 && summary.textContent.trim()) {
867
+ return summary.querySelector('.mr-done-head') || summary;
868
+ }
869
+ const head = status ? status.querySelector('h3') : null;
870
+ if (!head) return null;
871
+ const step = head.nextElementSibling;
872
+ return step && step.tagName === 'P' ? step : head;
873
+ };
874
+ // From Generate's foot in the rail's flow to the bottom of `target`, with its scroll
875
+ // margin: the first row after Generate that takes room starts one gap below its foot.
876
+ const reportBelow = (commit, target, gap) => {
877
+ let next = commit.nextElementSibling;
878
+ while (next && (next.offsetHeight < 2 || getComputedStyle(next).position === 'absolute')) {
879
+ next = next.nextElementSibling;
880
+ }
881
+ return next ? gap + target.getBoundingClientRect().bottom - next.getBoundingClientRect().top + 12 : 0;
882
+ };
883
  const fit = () => {
884
  const rail = byId('rail'), monitor = byId('monitor'), caption = byId('monitor-caption');
885
  const cost = byId('cost'), commit = byId('commit'), line = byId('commit-line');
 
904
  .reduce((sum, note) => sum + note.offsetHeight + px(getComputedStyle(note).marginTop), 0);
905
  const lineShown = rail.classList.contains('mr-figure-under') && !!line && line.offsetHeight > 0;
906
  const commitH = commit.offsetHeight - (lineShown ? line.offsetHeight + px(ks.rowGap) : 0);
907
+ // after a run its report's head fits too, so following it never slides the monitor's top
908
+ // out of view: the monitor gives up the height instead (down to its floor)
909
+ const target = reportTarget();
910
+ const reportH = target ? reportBelow(commit, target, gap) : 0;
911
+ const above = (m, c) => m + gap + c + gap + cost.offsetHeight + gap + px(ks.marginTop) + commitH + reportH;
912
  let monitorH = natural, captionMin = captionH;
913
  const over = above(natural, captionH) - avail;
914
  if (over > 0) monitorH = Math.max(MONITOR_FLOOR, natural - over);
 
979
  let lastReport = '';
980
  const follow = () => {
981
  const summary = byId('run-summary'), status = byId('run-status');
982
+ const target = reportTarget();
983
+ let key = '';
984
+ if (target && summary && summary.contains(target)) key = 'done:' + summary.textContent.trim().slice(0, 300);
985
+ else if (target) key = 'failed:' + status.textContent.trim().slice(0, 300);
 
 
 
 
 
 
986
  if (key === lastReport) return;
987
  lastReport = key;
988
  if (target && wide()) target.scrollIntoView({ block: 'nearest', behavior: still() ? 'auto' : 'smooth' });
tests/test_ui_shell.py CHANGED
@@ -100,3 +100,19 @@ def test_an_empty_actions_row_or_recent_runs_takes_no_room_in_the_rail():
100
  css = chrome._css()
101
  rule = "#rail > :is(#report-actions, #recent):not(:has(button:not(.hidden))) { display: none !important; }"
102
  assert rule in css
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  css = chrome._css()
101
  rule = "#rail > :is(#report-actions, #recent):not(:has(button:not(.hidden))) { display: none !important; }"
102
  assert rule in css
103
+
104
+
105
+ def test_after_a_run_the_head_of_its_report_fits_with_the_monitor_at_rail_scroll_0():
106
+ """Minor 6: the rail followed the report's head by scrolling, which slid the monitor's top
107
+ 51 px out of view at 1366 and 1280; the monitor now gives up that height instead."""
108
+ script = chrome.head_html()
109
+ target = _function(script, "const reportTarget = () => {")
110
+ assert "summary.querySelector('.mr-done-head') || summary" in target
111
+ assert "return step && step.tagName === 'P' ? step : head;" in target
112
+ fit = _function(script, "const fit = () => {")
113
+ assert "const reportH = target ? reportBelow(commit, target, gap) : 0;" in fit
114
+ assert "+ commitH + reportH;" in fit
115
+ follow = _function(script, "const follow = () => {")
116
+ assert "const target = reportTarget();" in follow, "the same head follow() brings into view"
117
+ below = _function(script, "const reportBelow = (commit, target, gap) => {")
118
+ assert "target.getBoundingClientRect().bottom - next.getBoundingClientRect().top + 12" in below