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 This PR introduces significant runtime behavior changes to saved environment persistence, including new IPC methods and atomic operation ordering with rollback handling. While well-tested, the changes affect critical data persistence flows and should be reviewed by someone familiar with this subsystem. 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
c3497b0 to
cc9d672
Compare
6033220 to
66e84a7
Compare
66e84a7 to
33193f4
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 ordering of credential/registry removal and SSH teardown plus rollback paths for add/replace flows; mistakes could leave orphaned or resurrected saved environments, though behavior is heavily covered by tests.
Overview
Adds
removeSavedEnvironmentend-to-end so saved environments are deleted in one persistence step (registry metadata plus embedded secrets on desktop/browser), wired through IPC,localApi, andremovePersistedSavedEnvironment.removeSavedEnvironmentnow tears down connections, persists removal first, then clears in-memory registry/runtime/UI state, and only then runs desktop SSH cleanup (failures are logged, not rolled back).disconnectSavedEnvironmentno longer deletes saved records; it only disconnects and, for SSH, clears the bearer token via the existing secret-removal path.Rollback when adding/replacing environments is tightened: bearer-token writes go through
persistSavedEnvironmentBearerTokenOrRollback, registry rollback can keep the original error when rollback itself fails, and replacing a stale desktop SSH target snapshots both environment ids and uses atomic removal for the old record with rollback if credential persistence or stale removal fails.Reviewed by Cursor Bugbot for commit 33193f4. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Remove saved environments atomically with rollback on credential persistence failure
removePersistedSavedEnvironmentacross desktop and browser persistence layers, wiring it through IPC (desktop:remove-saved-environment),DesktopBridge, andLocalApi.removeSavedEnvironmentin service.ts to delete the persisted record and update in-memory stores before running SSH cleanup; SSH cleanup errors are logged and ignored.removeStaleSavedEnvironmentRecordfor atomic replacement flows inaddSavedEnvironment, so stale records are removed from persistence without triggering bearer token deletion or disconnect.persistSavedEnvironmentBearerTokenOrRollback; rollback now preserves the primary error and attaches rollback failure context.removeSavedEnvironmentno longer calls the separate bearer token deletion step — token cleanup is handled implicitly by the desktop persistence layer when removing the record.Macroscope summarized 33193f4.