Skip to content

fix(safe-mode): guard silent-mode confirm against rapid re-entry#1156

Merged
datlechin merged 1 commit into
mainfrom
fix/safe-mode-silent-reentry-guard
May 9, 2026
Merged

fix(safe-mode): guard silent-mode confirm against rapid re-entry#1156
datlechin merged 1 commit into
mainfrom
fix/safe-mode-silent-reentry-guard

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Both .silent branches in QueryExecutionCoordinator (dispatchStatements lines 68-84 and dispatchParameterizedStatements lines 141-153) now set the same isShowingSafeModePrompt re-entry flag the requiresConfirmation branch already used:

if level == .silent {
    guard !parent.isShowingSafeModePrompt else { return }
    parent.isShowingSafeModePrompt = true
    Task { [parent] in
        defer { parent.isShowingSafeModePrompt = false }
        ...
    }
}

The flag is set synchronously before the Task spawns, then cleared in a defer inside the closure.

Why this matters

This is bug R3 from the full-app audit. Holding Cmd+Return on a connection at safe-mode level .silent previously spawned multiple Tasks, each awaiting confirmDangerousQueryIfNeeded / confirmDangerousQueries. Two confirmation sheets could stack on top of each other, the user could confirm both, and the same dangerous query (e.g. DELETE FROM users WHERE 1=1) would run twice. The .requiresConfirmation branch already had this guard, so this PR brings the .silent branch in line.

Test plan

  • Set safe-mode level .silent, hold Cmd+Return on a dangerous query, confirm only one confirmation sheet appears at a time.
  • Confirm or cancel the sheet; the next Cmd+Return is processed normally afterwards.
  • swiftlint --strict clean.

@datlechin datlechin merged commit 12b7b2a into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the fix/safe-mode-silent-reentry-guard branch May 9, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant