From df77d67210690a88bb8bbf224541878817e881ac Mon Sep 17 00:00:00 2001 From: Stanislau Palyn Date: Wed, 17 Sep 2025 10:19:28 +0200 Subject: [PATCH] [vcs] IJPL-198982 Implement subtle dumb mode indication in Commit GitOrigin-RevId: ecde9ef71784803d5473971fd59a54a6998924e8 --- platform/vcs-api/api-dump.txt | 3 + .../vcs/commit/CommitWorkflowHandler.kt | 1 + .../resources/messages/VcsBundle.properties | 2 +- .../vcs/commit/CommitProgressPanel.kt | 19 ++++- .../commit/NonModalCommitWorkflowHandler.kt | 78 +++++++++++++++---- .../vcs/commit/NonModalCommitWorkflowUi.kt | 5 ++ 6 files changed, 89 insertions(+), 19 deletions(-) diff --git a/platform/vcs-api/api-dump.txt b/platform/vcs-api/api-dump.txt index 9ea8207fa4ea..afd7be6d8a86 100644 --- a/platform/vcs-api/api-dump.txt +++ b/platform/vcs-api/api-dump.txt @@ -2129,6 +2129,9 @@ f:com.intellij.vcs.commit.CommitChecksResult$OnlyChecks f:com.intellij.vcs.commit.CommitChecksResult$Passed - com.intellij.vcs.commit.CommitChecksResult - sf:INSTANCE:com.intellij.vcs.commit.CommitChecksResult$Passed +f:com.intellij.vcs.commit.CommitChecksResult$SmartModeRequired +- com.intellij.vcs.commit.CommitChecksResult +- sf:INSTANCE:com.intellij.vcs.commit.CommitChecksResult$SmartModeRequired com.intellij.vcs.commit.CommitExecutorListener - java.util.EventListener - a:executorCalled(com.intellij.openapi.vcs.changes.CommitExecutor):V diff --git a/platform/vcs-api/src/com/intellij/vcs/commit/CommitWorkflowHandler.kt b/platform/vcs-api/src/com/intellij/vcs/commit/CommitWorkflowHandler.kt index 4a8327145b02..1f65bc742903 100644 --- a/platform/vcs-api/src/com/intellij/vcs/commit/CommitWorkflowHandler.kt +++ b/platform/vcs-api/src/com/intellij/vcs/commit/CommitWorkflowHandler.kt @@ -25,6 +25,7 @@ sealed class CommitChecksResult { class Failed(val toCloseWindow: Boolean = false) : CommitChecksResult() object Cancelled : CommitChecksResult() object ExecutionError : CommitChecksResult() + object SmartModeRequired : CommitChecksResult() val shouldCommit: Boolean get() = this is Passed val shouldCloseWindow: Boolean get() = this is Failed && toCloseWindow diff --git a/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties b/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties index 40124b0b9d3f..50b26e55318f 100644 --- a/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties +++ b/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties @@ -16,7 +16,7 @@ vcs.revision.name.current=Current error.no.changes.to.commit=Select files to commit error.no.commit.message=Specify commit message error.no.changes.no.commit.message=Select files to commit and specify commit message -label.commit.checks.not.available.during.indexing=Commit checks are not available during indexing +label.commit.checks.not.available.during.indexing=Some commit checks are not available during indexing commit.checks.on.commit.progress.text=Committing\u2026 commit.checks.on.commit.progress.text.with.context=Committing: {0} commit.checks.only.progress.text=Running commit checks\u2026 diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/CommitProgressPanel.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/CommitProgressPanel.kt index be15b248e584..983e36a642d1 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/CommitProgressPanel.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/CommitProgressPanel.kt @@ -49,6 +49,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import org.jetbrains.annotations.ApiStatus import java.awt.Dimension import java.awt.Font import java.awt.event.ComponentAdapter @@ -97,6 +98,7 @@ open class CommitProgressPanel(project: Project) : CommitProgressUi, InclusionLi private val dumbModeFlow: MutableStateFlow = MutableStateFlow(false) override var isDumbMode: Boolean by dumbModeFlow::value + private var shouldWarnAboutDumbMode: Boolean = false init { scope.launch { @@ -238,11 +240,26 @@ open class CommitProgressPanel(project: Project) : CommitProgressUi, InclusionLi return failuresPanel.getFailures() } + @ApiStatus.Internal + override fun showWarningAboutDumbMode() { + shouldWarnAboutDumbMode = true + update() + } + + @ApiStatus.Internal + override fun hideWarningAboutDumbMode() { + shouldWarnAboutDumbMode = false + update() + } + override fun documentChanged(event: DocumentEvent) = clearError() override fun inclusionChanged() = clearError() protected fun update() { + if (!isDumbMode) { + shouldWarnAboutDumbMode = false + } val error = buildErrorText() when { @@ -263,7 +280,7 @@ open class CommitProgressPanel(project: Project) : CommitProgressUi, InclusionLi announceCommitErrorAlarm?.cancelAndRequest() } } - isDumbMode -> label.setWarning(message("label.commit.checks.not.available.during.indexing")) + isDumbMode && shouldWarnAboutDumbMode -> label.setWarning(message("label.commit.checks.not.available.during.indexing")) else -> label.isVisible = false } revalidatePanel() diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowHandler.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowHandler.kt index fd09a73df163..f62e9ac85e74 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowHandler.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowHandler.kt @@ -68,6 +68,7 @@ abstract class NonModalCommitWorkflowHandler try { val handlers = workflow.commitHandlers @@ -341,12 +348,15 @@ abstract class NonModalCommitWorkflowHandler() if (!skipEarlyCommitChecks) { @@ -355,6 +365,10 @@ abstract class NonModalCommitWorkflowHandler): NonModalCommitChecksFailure? { + val dumbService = DumbService.getInstance(project) + val hasBlockedSmartChecks = commitChecks.any { commitCheck -> + !dumbService.isUsableInCurrentContext(commitCheck) + } + + if (hasBlockedSmartChecks) { + smartChecksWereBlocked = true + ui.commitProgressUi.showWarningAboutDumbMode() + return NonModalCommitChecksFailure.SMART_MODE_REQUIRED + } + smartChecksWereBlocked = false + ui.commitProgressUi.hideWarningAboutDumbMode() + return null + } + private suspend fun runEarlyCommitChecks(commitInfo: DynamicCommitInfo, commitChecks: List): NonModalCommitChecksFailure? { val problems = commitChecks.mapWithProgress { commitCheck -> AbstractCommitWorkflow.runCommitCheck(project, commitCheck, commitInfo) @@ -407,10 +437,12 @@ abstract class NonModalCommitWorkflowHandler, - @Suppress("DEPRECATION") - metaHandlers: List): NonModalCommitChecksFailure? { + private suspend fun runModificationCommitChecks( + commitInfo: DynamicCommitInfo, + commitChecks: List, + @Suppress("DEPRECATION") + metaHandlers: List, + ): NonModalCommitChecksFailure? { if (metaHandlers.isEmpty() && commitChecks.isEmpty()) return null return workflow.runModificationCommitChecks underChangelist@{ @@ -451,8 +483,10 @@ abstract class NonModalCommitWorkflowHandler): NonModalCommitChecksFailure? { + private suspend fun runSyncPostCommitChecks( + commitInfo: DynamicCommitInfo, + commitChecks: List, + ): NonModalCommitChecksFailure? { val problems = commitChecks.mapWithProgress { commitCheck -> AbstractCommitWorkflow.runCommitCheck(project, commitCheck, commitInfo) }.filterNotNull() @@ -479,6 +513,7 @@ abstract class NonModalCommitWorkflowHandler { @@ -486,6 +521,8 @@ abstract class NonModalCommitWorkflowHandler { isCommitChecksResultUpToDate = RecentCommitChecks.POST_FAILED } + NonModalCommitChecksFailure.SMART_MODE_REQUIRED -> { + isCommitChecksResultUpToDate = RecentCommitChecks.SMART_MODE_REQUIRED + } NonModalCommitChecksFailure.ABORTED, - NonModalCommitChecksFailure.ERROR -> { + NonModalCommitChecksFailure.ERROR, + -> { isCommitChecksResultUpToDate = RecentCommitChecks.FAILED } } @@ -513,6 +554,9 @@ abstract class NonModalCommitWorkflowHandler) -private enum class NonModalCommitChecksFailure { EARLY_FAILED, MODIFICATIONS_FAILED, POST_FAILED, ABORTED, ERROR } +private enum class NonModalCommitChecksFailure { EARLY_FAILED, MODIFICATIONS_FAILED, POST_FAILED, ABORTED, ERROR, SMART_MODE_REQUIRED } -private enum class RecentCommitChecks { UNKNOWN, PASSED, EARLY_FAILED, MODIFICATIONS_FAILED, POST_FAILED, FAILED } +private enum class RecentCommitChecks { UNKNOWN, PASSED, EARLY_FAILED, MODIFICATIONS_FAILED, POST_FAILED, FAILED, SMART_MODE_REQUIRED } diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowUi.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowUi.kt index dbe81e61e29b..aadf5b926865 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowUi.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/NonModalCommitWorkflowUi.kt @@ -42,4 +42,9 @@ interface CommitProgressUi { fun clearCommitCheckFailures() fun getCommitCheckFailures(): List + + @ApiStatus.Internal + fun showWarningAboutDumbMode() + @ApiStatus.Internal + fun hideWarningAboutDumbMode() } \ No newline at end of file