Skip to content

refactor: consolidate confirmOrAbort across deploy, destroy, and env rm#1269

Merged
thebiglabasky merged 13 commits intomainfrom
feat/confirm-or-abort-consolidation
Mar 27, 2026
Merged

refactor: consolidate confirmOrAbort across deploy, destroy, and env rm#1269
thebiglabasky merged 13 commits intomainfrom
feat/confirm-or-abort-consolidation

Conversation

@thebiglabasky
Copy link
Copy Markdown
Contributor

@thebiglabasky thebiglabasky commented Mar 24, 2026

Summary

Consolidates write-command confirmation around confirmOrAbort for deploy, destroy, and env rm, and fixes the follow-up issues found while manually validating the branch in both interactive and agent/CI-style flows.

  • authCommand.tsconfirmOrAbort supports an optional interactiveConfirm callback for commands needing custom confirmation in interactive mode.
  • env rm — uses confirmOrAbort instead of ad-hoc prompts() confirmation.
  • destroy — uses confirmOrAbort plus interactiveConfirm, preserving the type-the-project-name safeguard for interactive users while returning structured confirmation JSON in agent/CI mode.
  • deploy — uses confirmOrAbort and now exits for confirmation before parsing, bundling, or uploading anything in agent/CI mode. This keeps confirmation output machine-readable and avoids pre-confirm side effects.
  • baseCommand.ts / authCommand.ts — local-dev version replacement notices are suppressed outside interactive mode, and AuthCommand.init() now awaits BaseCommand.init() so interactive notices appear in the correct order.
  • api.spec.ts — CLI-mode detection tests now clear CODEX_* and related env vars so the suite is stable when run from Codex/Desktop environments.

No breaking changes

  • --force / -f preserved on all three commands
  • interactive confirmation behavior preserved
  • agent/CI confirmation still exits with code 2 and a structured confirmation_required payload
  • deploy --preview remains a server-side dry run and does not use the confirmation gate

Closes AI-163

Test plan

  • Unit tests for interactiveConfirm callback in confirm-or-abort.spec.ts
  • Confirmation flow tests for env rm, destroy, and deploy
  • Regression test that deploy exits for confirmation before parsing/bundling in agent mode
  • Regression test that AuthCommand.init() awaits BaseCommand.init()
  • Command metadata validation (readOnly/destructive/idempotent)
  • npm run prepare succeeds
  • AI context regenerated successfully
  • Full local test suite passes
  • checkly workspace: 709 passed, 2 skipped
  • create-checkly workspace: 19 passed

Manual validation notes

  • Reproduced the original issue where CI=1 checkly deploy emitted progress output before the confirmation JSON envelope.
  • Verified the fix locally: confirmation now happens before deploy parsing/bundling work, and interactive notice ordering is restored.

thebiglabasky and others added 4 commits March 24, 2026 01:31
Extends confirmOrAbort with an optional interactiveConfirm callback
for commands that need custom confirmation in interactive mode (e.g.
destroy's type-the-project-name prompt). Makes dryRun optional so
commands without --dry-run can omit it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces ad-hoc prompts() confirmation with confirmOrAbort so agent
and CI modes get structured JSON output (exit code 2) instead of
a silent prompt. No new flags added. --force/-f preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces ad-hoc text-match confirmation with confirmOrAbort. In
interactive mode, the type-the-project-name safeguard is preserved
via the interactiveConfirm callback. Agent/CI mode gets structured
JSON output (exit code 2). No new flags added. --force/-f preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces ad-hoc prompts() confirmation with confirmOrAbort so agent
and CI modes get structured JSON output (exit code 2). --preview flag
is untouched (server-side dry run). --force/-f preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
thebiglabasky and others added 2 commits March 24, 2026 08:53
- Restore mismatch feedback message in destroy's interactiveConfirm
- Make deploy preview wording more conversational
- Skip undefined/null flag values in buildConfirmCommand to avoid
  --config="undefined" in agent confirmCommand output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@MichaelHogers MichaelHogers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

letting Claude test out the commands for a bit, might be great to get another review in from you @sorccu since these are some of the core CLI commands

expect(api.validateAuthentication).not.toHaveBeenCalled()

releaseBaseInit()
await expect(initPromise).rejects.toThrow('Cannot write private member #account')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a pretty weird thing to test for. I assume you don't actually care about what the result of the initPromise is as long as it resolves somehow? If that's the case, I'd appreciate a comment making that clearer.

MichaelHogers
MichaelHogers previously approved these changes Mar 27, 2026
Copy link
Copy Markdown
Contributor

@MichaelHogers MichaelHogers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no findings from my side, but would require final approval from @sorccu

Comment on lines +82 to +84
if (detectCliMode() === 'interactive') {
this.log(`\nNotice: replacing version '${version}' with latest '${packageInformation.version}'. If you wish to test with a different version, please pass the CHECKLY_CLI_VERSION environment variable.\n`)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get rid of this message entirely. It only causes confusion.

description: 'Destroy all project resources',
changes: [
`PERMANENTLY delete ALL resources associated with the project "${checklyConfig.projectName}"`,
`Account: "${account.name}"`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit weird. This is how it looks like:

This will:
  - PERMANENTLY delete ALL resources associated with the project "temp-project-0E6CA056-1778-4577-8B8E-BA38470E689C"
  - Account: "simo@checklyhq.com"

? Type the project name "temp-project-0E6CA056-1778-4577-8B8E-BA38470E689C" to confirm: ›

Why is the account its own list item? It feels very out of place. It can even feel like it's saying the account will be deleted.

For reference, when you deploy, it's on the first line:

This will:
  - Deploy project "temp-project-0E6CA056-1778-4577-8B8E-BA38470E689C" to account "simo@checklyhq.com"
  - Schedule checks after deploy

? Proceed? › (y/N)

@sorccu
Copy link
Copy Markdown
Member

sorccu commented Mar 27, 2026

Left a couple comments. Nothing major. Up to you whether to address them or not. Seems good to me overall.

@thebiglabasky
Copy link
Copy Markdown
Contributor Author

@sorccu @MichaelHogers PTAL. Re-tested with Simo's suggestions which I think makes this much nicer. I'm pretty confident we can ship this

@thebiglabasky thebiglabasky merged commit 63f7171 into main Mar 27, 2026
4 checks passed
@thebiglabasky thebiglabasky deleted the feat/confirm-or-abort-consolidation branch March 27, 2026 16:28
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.

3 participants