merge-steward 0.16.2 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,5 +10,9 @@ export declare function RepoRow({ repo, selected, showCursor, width, }: {
10
10
  showCursor: boolean;
11
11
  width: number;
12
12
  }): React.JSX.Element;
13
+ export declare function pickVisibleWindow(total: number, selectedIndex: number, availableRows: number): {
14
+ start: number;
15
+ end: number;
16
+ };
13
17
  export declare function OverviewView({ model, selectedRepoId, showCursor }: ListViewProps): React.JSX.Element;
14
18
  export {};
@@ -24,25 +24,42 @@ export function RepoRow({ repo, selected, showCursor, width, }) {
24
24
  : repo.repoFullName.padEnd(repoLabelWidth, " ");
25
25
  return (_jsxs(Box, { children: [_jsx(Text, { color: selected ? "cyan" : "gray", children: cursorChar }), _jsx(Text, { bold: selected, children: ` ${repoLabel} ` }), repo.offlineMessage ? (_jsx(Text, { color: "red", children: repo.offlineMessage })) : (_jsx(RepoTokens, { tokens: repo.tokens, width: tokenWidth }))] }));
26
26
  }
27
+ export function pickVisibleWindow(total, selectedIndex, availableRows) {
28
+ if (total === 0)
29
+ return { start: 0, end: 0 };
30
+ if (total <= availableRows)
31
+ return { start: 0, end: total };
32
+ const clamped = Math.max(0, Math.min(selectedIndex, total - 1));
33
+ let start = clamped;
34
+ let end = clamped + 1;
35
+ while (end - start < availableRows) {
36
+ if (start > 0 && (end === total || clamped - start <= end - 1 - clamped)) {
37
+ start -= 1;
38
+ }
39
+ else if (end < total) {
40
+ end += 1;
41
+ }
42
+ else {
43
+ break;
44
+ }
45
+ }
46
+ return { start, end };
47
+ }
27
48
  export function OverviewView({ model, selectedRepoId, showCursor }) {
28
49
  const { stdout } = useStdout();
29
50
  const rows = Math.max(3, stdout?.rows ?? 24);
30
51
  const width = Math.max(40, stdout?.columns ?? 80);
31
52
  const availableRows = Math.max(1, rows - 3);
32
- const selectedIndex = model.repos.findIndex((repo) => repo.repoId === selectedRepoId);
33
- const selected = selectedIndex >= 0 ? model.repos[selectedIndex] : model.repos[0];
34
- const others = model.repos.filter((repo) => repo !== selected);
35
- const ordered = [];
36
- if (selected)
37
- ordered.push(selected);
38
- ordered.push(...others);
39
- const quietLine = model.quietCount > 0 ? 1 : 0;
40
- const maxRepoLines = Math.max(1, availableRows - quietLine);
41
- const visible = ordered.slice(0, maxRepoLines);
42
- const hiddenActive = ordered.length - visible.length;
43
- const quietFooter = model.quietCount + hiddenActive;
53
+ const selectedIndex = Math.max(0, model.repos.findIndex((repo) => repo.repoId === selectedRepoId));
54
+ const quietReserve = model.repos.length > availableRows && model.quietCount > 0 ? 1 : 0;
55
+ const windowRows = Math.max(1, availableRows - quietReserve);
56
+ const { start, end } = pickVisibleWindow(model.repos.length, selectedIndex, windowRows);
57
+ const visible = model.repos.slice(start, end);
58
+ const hiddenQuiet = model.repos
59
+ .filter((repo, index) => !repo.hasActivity && repo.offlineMessage === null && (index < start || index >= end))
60
+ .length;
44
61
  if (visible.length === 0) {
45
62
  return _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: " " }) });
46
63
  }
47
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [visible.map((repo) => (_jsx(RepoRow, { repo: repo, selected: repo === selected, showCursor: showCursor, width: width - 2 }, repo.repoId))), quietFooter > 0 ? (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, children: `+${quietFooter} quiet` }) })) : null] }));
64
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [visible.map((repo) => (_jsx(RepoRow, { repo: repo, selected: repo.repoId === selectedRepoId, showCursor: showCursor, width: width - 2 }, repo.repoId))), hiddenQuiet > 0 ? (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, children: `+${hiddenQuiet} quiet` }) })) : null] }));
48
65
  }
@@ -197,22 +197,25 @@ export function buildDashboard(repos, opts = {}) {
197
197
  offlineMessage: null,
198
198
  };
199
199
  });
200
- const active = mapped.filter((repo) => repo.hasActivity || repo.offlineMessage);
201
- active.sort((left, right) => {
200
+ mapped.sort((left, right) => {
202
201
  if (left.offlineMessage !== null && right.offlineMessage === null)
203
202
  return 1;
204
203
  if (right.offlineMessage !== null && left.offlineMessage === null)
205
204
  return -1;
206
- const leftHasActive = left.entries.some((entry) => entry.kind === "running" || entry.kind === "queued");
207
- const rightHasActive = right.entries.some((entry) => entry.kind === "running" || entry.kind === "queued");
208
- if (leftHasActive !== rightHasActive)
209
- return leftHasActive ? -1 : 1;
205
+ const leftVisible = left.hasActivity || left.offlineMessage !== null;
206
+ const rightVisible = right.hasActivity || right.offlineMessage !== null;
207
+ if (leftVisible !== rightVisible)
208
+ return leftVisible ? -1 : 1;
209
+ const leftActive = left.entries.some((entry) => entry.kind === "running" || entry.kind === "queued");
210
+ const rightActive = right.entries.some((entry) => entry.kind === "running" || entry.kind === "queued");
211
+ if (leftActive !== rightActive)
212
+ return leftActive ? -1 : 1;
210
213
  if (left.latestActivityAt !== right.latestActivityAt)
211
214
  return right.latestActivityAt - left.latestActivityAt;
212
215
  return left.repoFullName.localeCompare(right.repoFullName);
213
216
  });
214
- const quietCount = mapped.length - active.length;
215
- return { repos: active, quietCount };
217
+ const quietCount = mapped.filter((repo) => !repo.hasActivity && repo.offlineMessage === null).length;
218
+ return { repos: mapped, quietCount };
216
219
  }
217
220
  export function clipSummary(summary, opts = {}) {
218
221
  if (!summary)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merge-steward",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Serial merge queue for GitHub — rebase, CI-gate, and merge PRs one at a time",
5
5
  "type": "module",
6
6
  "repository": {