Skip to content

feat(sync): restore missing files and archive only with detach --archive - #857

Merged
ctawiah merged 5 commits into
mainfrom
ctawiah/sync-restore-missing-files
Oct 14, 2026
Merged

ctawiah merged 5 commits into
mainfrom
ctawiah/sync-restore-missing-files

Conversation

@ctawiah

@ctawiah ctawiah commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Context

A missing local file made sync archive the variation in LaunchDarkly. A file is often missing only because the working copy does not have it yet, for example after a Git pull or a branch switch. A plain sync, or a watch session that applies changes, could then archive a variation that other engineers use.

This PR is stacked on #856. That PR makes sync.lock track every project, so sync can find a variation whose file is missing.

What changes

  • Sync restores a missing local file from LaunchDarkly. The sync plan never archives a variation, so the archive_server action is removed.
  • ldcli sync prompts detach <selector> --archive is the only way to archive a variation. It archives each selected variation in LaunchDarkly, and then stops syncing it.
  • detach --archive asks for confirmation in a terminal. With --no-input, it needs --yes, the same rule as other destructive changes.
  • The archive runs first, and an already archived variation does not fail. If a later step fails, the same command can run again.
  • The confirmation prompt moves to the interactive package, so sync and detach use one copy.
  • The command is now ldcli sync prompts, plural, like the other resource commands. There is no alias for sync prompt.

Stop syncing a variation and archive it:

ldcli sync prompts detach production/support/default --archive --yes --no-input

Review focus

  • Is it right that a missing file always comes back, and that only detach --archive archives?
  • Is the order in detach --archive safe when a step fails: archive, then baseline, then file deletion?
  • Is the archive confirmation clear in the terminal and with --no-input?

Verification

  • go build ./...
  • go vet ./...
  • go test -race ./internal/sync/... ./cmd/sync/...
  • TestPromptRestoresTrackedMissingFileInsteadOfArchiving deletes a tracked file, runs sync, and checks that the file comes back and nothing is archived.

Related changes

  1. feat(sync): keep each working copy's baseline in sync.lock #856: keep each working copy's baseline in sync.lock
  2. This PR: restore missing files and archive only with detach --archive

Devin Review


Note

Overview
Sync no longer archives missing local variations. A missing managed file (e.g. after git pull or branch switch) is treated as restore from LaunchDarkly instead of pushing an archive. The archive_server plan action and related conflict/diff paths are removed; server-side archive is only via detach.

ldcli sync prompts detach --archive optionally archives selected variations in LaunchDarkly before stopping sync. Archive runs first (idempotent if already archived), then baseline and local cleanup; terminal confirmation or --yes with --no-input. Shared interactive.Confirm powers sync apply and detach archive prompts; conflict resolution uses SelectInline so prior output stays visible.

CLI rename: sync prompt → sync prompts (examples/tests updated; no alias).

Baseline / sync.lock: Copies without a lock file no longer inherit the remote manifest as their baseline (avoids tracking other branches’ entries). version is not written to sync.lock (versions stay on the remote manifest for optimistic updates). ref for linked variations is stored in the lock and used when recreating missing wrapper files; restore fails safely if the linked file is missing or diverges.

Breaking: Scripts using ldcli sync prompt must switch to sync prompts. Behavior change: deleting a tracked file and running sync restores it rather than archiving in LD.

Reviewed by Cursor Bugbot for commit 3d1afe5. Bugbot is set up for automated code reviews on this repo. Configure here.

launchdarkly/ldcli · GitHub
Skip to content

This repository is temporarily unavailable.

The backend storage is temporarily offline. Usually this means the storage server is undergoing maintenance. Please contact support if the problem persists.

Check our status site for updates

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.

2 participants