Skip to content

feat(ui): add workspace init confirmation before syncing#2822

Merged
tusharmath merged 2 commits intomainfrom
feat-sync-confirmation
Apr 3, 2026
Merged

feat(ui): add workspace init confirmation before syncing#2822
tusharmath merged 2 commits intomainfrom
feat-sync-confirmation

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 3, 2026

Summary

Add an explicit user consent prompt before syncing a workspace directory, preventing unintended data sharing with ForgeCode Services.

Context

Previously, invoking a sync on an uninitialized directory would immediately begin syncing and sharing its contents with ForgeCode Services without any user acknowledgment. This is a privacy-sensitive operation and users should be given a clear opportunity to accept or decline before the sync proceeds.

Changes

  • Added a confirmation prompt in on_workspace_init that informs users their directory contents will be synced and shared with ForgeCode Services, with yes as the default answer.
  • If the user declines, workspace initialization is aborted and a cancellation notice is printed to the console.
  • Added a post-init guard in the sync flow: after calling on_workspace_init, the workspace is re-checked and if it still does not exist (because the user declined), the sync is aborted early rather than proceeding with stale state.

Key Implementation Details

The confirmation uses ForgeWidget::confirm with with_default(true), so pressing Enter accepts by default. The unwrap_or(false) on the result ensures any prompt failure safely cancels the operation. The guard added at the call-site after on_workspace_init keeps the sync path honest — it does not assume initialization succeeded.

Testing

# Run the main crate tests
cargo insta test --accept -p forge_main

# Manual verification — run forge on a new directory and decline the prompt
cargo run -- sync /tmp/test-new-dir
# Expected: prompt appears, typing 'n' prints cancellation notice and exits cleanly

# Accept the prompt
cargo run -- sync /tmp/test-new-dir
# Expected: workspace is initialized and sync proceeds normally

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 3, 2026
@tusharmath tusharmath changed the title feat sync confirmation feat(ui): add workspace init confirmation before syncing Apr 3, 2026
@tusharmath tusharmath merged commit e18b9d1 into main Apr 3, 2026
9 checks passed
@tusharmath tusharmath deleted the feat-sync-confirmation branch April 3, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant