Skip to content

Commit 70da515

Browse files
matteodepaloalvaro-shopify
authored andcommitted
Hide shortcuts in ConcurrentOutput when aborted
1 parent e6dff28 commit 70da515

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/cli-kit/src/private/node/ui/components/ConcurrentOutput.test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ describe('ConcurrentOutput', () => {
239239
"0000-00-00 00:00:00 │ backend │ first backend message
240240
0000-00-00 00:00:00 │ backend │ second backend message
241241
0000-00-00 00:00:00 │ backend │ third backend message
242+
243+
Preview URL: https://shopify.com
242244
"
243245
`)
244246

@@ -286,11 +288,13 @@ describe('ConcurrentOutput', () => {
286288
"0000-00-00 00:00:00 │ backend │ first backend message
287289
0000-00-00 00:00:00 │ backend │ second backend message
288290
0000-00-00 00:00:00 │ backend │ third backend message
291+
292+
Preview URL: https://shopify.com
289293
"
290294
`)
291295
})
292296

293-
test("doesn't render the footer when the processes resolve", async () => {
297+
test("doesn't render the shortcuts when the processes resolve", async () => {
294298
// Given
295299
const backendProcess = {
296300
prefix: 'backend',
@@ -329,6 +333,8 @@ describe('ConcurrentOutput', () => {
329333
"0000-00-00 00:00:00 │ backend │ first backend message
330334
0000-00-00 00:00:00 │ backend │ second backend message
331335
0000-00-00 00:00:00 │ backend │ third backend message
336+
337+
Preview URL: https://shopify.com
332338
"
333339
`)
334340
})

packages/cli-kit/src/private/node/ui/components/ConcurrentOutput.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,17 @@ const ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({
120120
)
121121
}
122122

123+
const {isAborted} = useAbortSignal(abortSignal)
124+
125+
const useShortcuts = isRawModeSupported && state === ConcurrentOutputState.Running && !isAborted
126+
123127
useInput(
124128
(input, key) => {
125129
handleCtrlC(input, key)
126130

127131
onInput!(input, key, () => treeKill('SIGINT'))
128132
},
129-
// isRawModeSupported can be undefined even if the type doesn't say so
130-
// Ink is checking that isActive is actually === false, not falsey
131-
{isActive: typeof onInput !== 'undefined' && Boolean(isRawModeSupported)},
133+
{isActive: typeof onInput !== 'undefined' && useShortcuts},
132134
)
133135

134136
useAsyncAndUnmount(runProcesses, {
@@ -140,8 +142,6 @@ const ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({
140142
},
141143
})
142144

143-
const {isAborted} = useAbortSignal(abortSignal)
144-
145145
return (
146146
<>
147147
<Static items={processOutput}>
@@ -181,9 +181,9 @@ const ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({
181181
)
182182
}}
183183
</Static>
184-
{state === ConcurrentOutputState.Running && !isAborted && footer ? (
184+
{footer ? (
185185
<Box marginY={1} flexDirection="column" flexGrow={1}>
186-
{isRawModeSupported ? (
186+
{useShortcuts ? (
187187
<Box flexDirection="column">
188188
{footer.shortcuts.map((shortcut, index) => (
189189
<Text key={index}>
@@ -193,7 +193,7 @@ const ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({
193193
</Box>
194194
) : null}
195195
{footer.subTitle ? (
196-
<Box marginTop={isRawModeSupported ? 1 : 0}>
196+
<Box marginTop={useShortcuts ? 1 : 0}>
197197
<Text>{footer.subTitle}</Text>
198198
</Box>
199199
) : null}

0 commit comments

Comments
 (0)