Skip to content

Commit f0cc722

Browse files
committed
Add a spinner anim to the "Project syncing" message
1 parent c8b8fed commit f0cc722

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

kobweb/src/main/kotlin/com/varabyte/kobweb/cli/common/GradleUtils.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.varabyte.kobweb.cli.common
33
import com.varabyte.kobweb.cli.common.kotter.handleConsoleOutput
44
import com.varabyte.kobweb.server.api.ServerEnvironment
55
import com.varabyte.kobweb.server.api.SiteLayout
6+
import com.varabyte.kotter.foundation.anim.textAnimOf
67
import com.varabyte.kotter.foundation.collections.liveListOf
78
import com.varabyte.kotter.foundation.input.Key
89
import com.varabyte.kotter.foundation.input.Keys
@@ -282,6 +283,8 @@ fun RunScope.handleGradleOutput(line: String, isError: Boolean, onGradleEvent: (
282283
// Windows flickering while still presenting enough information for users. If people complain,
283284
// 5 is too small, we can allow users to configure this somehow, e.g. via CLI params.
284285
class GradleAlertBundle(session: Session, private val pageSize: Int = 5) {
286+
private val spinnerAnim = session.textAnimOf(Anims.SPINNER)
287+
285288
private val warnings = session.liveListOf<GradleAlert.Warning>()
286289
private val errors = session.liveListOf<GradleAlert.Error>()
287290
private var lastProgressEvent by session.liveVarOf<GradleAlert.Progress?>(null)
@@ -363,19 +366,19 @@ class GradleAlertBundle(session: Session, private val pageSize: Int = 5) {
363366
fun renderSyncMessage(renderScope: RenderScope) = renderScope.apply {
364367
renderScope.apply {
365368
if (!hasFirstTaskRun) {
366-
val syncMessage = "Syncing project"
369+
val syncMessage = "$spinnerAnim Syncing project"
367370
black(isBright = true) {
368371
text(syncMessage)
369372
val session = renderScope.section.session
370-
val descTruncated = lastProgressEvent?.let {
371-
session.textMetrics.truncateToWidth(
372-
it.desc,
373+
(lastProgressEvent?.desc ?: "Initializing").let { desc ->
374+
val descTruncated = session.textMetrics.truncateToWidth(
375+
desc,
373376
// -3 accounts for parentheses and space
374377
session.terminalSize.width - syncMessage.length - 3,
375378
ellipsis = EllipsisPresets.SYMBOL
376379
)
377-
} ?: "Initializing"
378-
text(" ($descTruncated)")
380+
text(" ($descTruncated)")
381+
}
379382
textLine()
380383
}
381384

0 commit comments

Comments
 (0)