Skip to content

Commit 56621d7

Browse files
committed
feat: Improved subprogress display
1 parent d266cb7 commit 56621d7

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
"deploy": "npm run pkg && npm run notarize && npm run upload",
146146
"prepublishOnly": "npm run build"
147147
},
148-
"version": "1.1.0-beta8",
148+
"version": "1.1.0-beta9",
149149
"bugs": "https://github.com/codifycli/codify/issues",
150150
"keywords": [
151151
"oclif",

src/ui/components/progress/progress-display.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,24 @@ export function SubProgressDisplay(
7878
) {
7979
const { subProgresses } = props;
8080

81-
return <>{
82-
subProgresses && subProgresses
83-
// Sort the subprocesses so that in progress ones are always at the bottom
84-
.sort((a, b) => a.status === ProgressStatus.IN_PROGRESS ? 1 : -1)
85-
// Limit the max number of subprocesses to 5. Too many doesn't look good and causes a wasm memory access error (yoga)
86-
.slice(Math.max(0, subProgresses.length - 5), subProgresses.length)
87-
.map((s, idx) =>
88-
s.status === ProgressStatus.IN_PROGRESS
89-
? <Spinner key={idx} label={s.label} type="dots" />
90-
: <Text key={idx}><Text color='greenBright'></Text> {s.label}</Text>
91-
)
92-
}</>
81+
if (!subProgresses) return <></>;
82+
83+
const MAX_VISIBLE = 5;
84+
const hiddenCount = Math.max(0, subProgresses.length - MAX_VISIBLE);
85+
86+
// Take the last (MAX_VISIBLE - 1) chronologically, leaving room for the "and N others" row
87+
const visibleSlice = subProgresses.slice(Math.max(0, subProgresses.length - (MAX_VISIBLE - 1)));
88+
// Sort within the visible slice so in-progress items appear at the bottom
89+
const sorted = [...visibleSlice].sort((a, b) => a.status === ProgressStatus.IN_PROGRESS ? 1 : -1);
90+
91+
return <>
92+
{hiddenCount > 0 && (
93+
<Text dimColor> and {hiddenCount} other{hiddenCount !== 1 ? 's' : ''}...</Text>
94+
)}
95+
{sorted.map((s, idx) =>
96+
s.status === ProgressStatus.IN_PROGRESS
97+
? <Spinner key={idx} label={s.label} type="dots" />
98+
: <Text key={idx}><Text color='greenBright'></Text> {s.label}</Text>
99+
)}
100+
</>
93101
}

0 commit comments

Comments
 (0)