fix(web): Remove saved environments atomically#2917
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR introduces new IPC methods and persistence capabilities for atomic environment removal, with significant refactoring of error handling logic. An open review comment identifies a bug in error preservation. These changes warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate 933a157
57451d3 to
61426fd
Compare
Dismissing prior approval to re-evaluate 61426fd
61426fd to
177b89b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 177b89b. Configure here.
1e011dc to
cfc3112
Compare
cfc3112 to
c3497b0
Compare

Summary
Closes #2914.
This makes saved-environment removal use a single persistence operation that removes metadata and embedded credentials together, and tightens rollback behavior when replacing stale desktop SSH records.
Problem and Fix
removeSavedEnvironmentto the local persistence API and desktop IPC bridge so metadata and embedded secrets are removed atomically.Defensive Fixes
Validation
bun fmtbun lintbun typecheckbun run --filter @t3tools/desktop test -- DesktopSavedEnvironmentsbun run --filter @t3tools/web test -- localApi catalog service.addSavedEnvironment service.savedEnvironmentsChecklist
Note
Medium Risk
Changes saved-environment credential persistence, deletion ordering, and SSH cleanup timing; mistakes could leave stale credentials or inconsistent UI state, though behavior is covered by expanded tests.
Overview
Adds
removeSavedEnvironmentend-to-end (contracts, desktop IPC/preload,DesktopSavedEnvironments.removeEnvironment, browserremoveBrowserSavedEnvironment,LocalApi.persistence) so deleting a saved environment drops registry metadata and its embedded bearer secret in one persisted write instead of separate registry/secret updates.removeSavedEnvironmentin the web runtime is reordered: detach connections, callremovePersistedSavedEnvironment, then clear registry/runtime/UI state; desktop SSHdisconnectSshEnvironmentruns afterward (failures are logged, not rolled back). Full removal no longer callsremoveSavedEnvironmentBearerTokenseparately.Add/replace flows gain
persistSavedEnvironmentBearerTokenOrRollbackand registry snapshots that include both new and stale SSH ids when replacing a desktop SSH target; stale cleanup usesremoveStaleSavedEnvironmentRecord(atomic persist remove) with rollback that keeps the original error if rollback itself fails.Reviewed by Cursor Bugbot for commit cfc3112. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Remove saved environments atomically with rollback support
removeEnvironmenttoDesktopSavedEnvironmentsand aremoveSavedEnvironmentIPC channel so the main process can delete a saved environment's metadata and secrets together.removePersistedSavedEnvironmentto theLocalApipersistence contract, routing to the desktop bridge or browser local storage viaremoveBrowserSavedEnvironment.removeSavedEnvironmentin service.ts to remove the persisted record first and defer SSH cleanup, swallowing cleanup errors instead of blocking completion.addSavedEnvironmentrollback: stale SSH records are removed viaremoveStaleSavedEnvironmentRecord, bearer token persistence usespersistSavedEnvironmentBearerTokenOrRollback, and registry state is updated atomically withsetState.removeSavedEnvironmentno longer callsremoveSavedEnvironmentBearerToken; SSH cleanup failures are warned and swallowed rather than surfaced.Macroscope summarized c3497b0.