Defer level validation while editors are open

This commit is contained in:
Joe Tretter
2026-06-26 13:26:56 -05:00
parent 781b5090f7
commit 91913a9de8
3 changed files with 48 additions and 8 deletions

View File

@@ -388,11 +388,16 @@ fun GitHugApp() {
fun applyCommandResult(raw: String, newRepo: RepoState, lines: List<String>, echoCommand: Boolean) {
val startedAt = System.nanoTime()
val levelForResult = currentLevel
val solvedAfterCommand = levelForResult.validator(newRepo, raw)
val validationBlockedByEditor = editorState != null || gitMessageEditorState != null
val solvedAfterCommand = if (validationBlockedByEditor) {
false
} else {
levelForResult.validator(newRepo, raw)
}
val wasAlreadyCompleted = currentLevel.id in completedLevels
AppLog.d(
"GitHugApp",
"Command='$raw' level=${levelForResult.id} solved=$solvedAfterCommand alreadyCompleted=$wasAlreadyCompleted " +
"Command='$raw' level=${levelForResult.id} solved=$solvedAfterCommand validationBlockedByEditor=$validationBlockedByEditor alreadyCompleted=$wasAlreadyCompleted " +
"completedBefore=${completedLevels.sorted()} outputLineCount=${lines.size} repo=${newRepo.diagnosticSnapshot()}",
)
val newOutput = buildList {
@@ -519,14 +524,13 @@ fun GitHugApp() {
invocation = state.invocation,
message = state.content,
)
gitMessageEditorState = null
applyCommandResult(state.invocation.command, result.repo, result.outputLines, echoCommand = false)
result.nextEditor?.let { nextEditor ->
gitMessageEditorState = GitMessageEditorState(
gitMessageEditorState = result.nextEditor?.let { nextEditor ->
GitMessageEditorState(
invocation = nextEditor.invocation,
content = nextEditor.content,
)
}
applyCommandResult(state.invocation.command, result.repo, result.outputLines, echoCommand = false)
}
fun runCommand() {