fix(secrets): restore unsaved-changes guard for settings tab navigation#4009
fix(secrets): restore unsaved-changes guard for settings tab navigation#4009waleedlatif1 merged 6 commits intostagingfrom
Conversation
PR SummaryMedium Risk Overview Updates the settings sidebar to block tab switches and Back navigation when dirty, showing a discard-confirmation modal and only navigating after explicit confirmation. Refactors environment variable typing by moving Reviewed by Cursor Bugbot for commit 522f3e2. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
- Add useSettingsDirtyStore (stores/settings/dirty) to track dirty state across the settings sidebar and section components - Wire credentials-manager and integrations-manager to sync dirty state to the store and clean up on unmount; also reset store synchronously in handleDiscardAndNavigate - Update settings-sidebar to check dirty state before tab switches and Back navigation, showing an Unsaved Changes dialog if needed - Remove dead stores/settings/environment directory; move EnvironmentVariable type into lib/environment/api
- Add isMicrosoftContentUrl helper with typed allowlist covering SharePoint, OneDrive, and Teams CDN domains - Replace loose substring checks in Teams webhook handler with parsed-hostname matching to prevent bypass via partial domain names - Deduplicate OneDrive share-link detection into isOneDriveShareLink flag and use searchParams API instead of string splitting
Greptile SummaryThis PR fixes a navigation guard regression in the settings sidebar: the sidebar's button-based Key changes:
Confidence Score: 5/5Safe to merge — no P0/P1 issues found across all 13 changed files All prior review concerns (type re-exports, smba.trafficmanager.net wildcard, mount/unmount race) were addressed in follow-up commits. The unsaved-changes guard logic is correct for both Back and tab-switch paths. The Microsoft content URL allowlist uses parsed-hostname matching which is secure against substring-bypass. The type refactoring is clean with no dangling import paths. No files require special attention Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Sidebar as SettingsSidebar
participant Store as useSettingsDirtyStore
participant Manager as credentials/integrations-manager
participant Router
User->>Manager: edits form field
Manager->>Store: setDirty(true) [via useEffect]
User->>Sidebar: clicks different tab
Sidebar->>Store: requestNavigation(section)
Store-->>Sidebar: false (isDirty=true, pendingSection set)
Sidebar->>Sidebar: setShowDiscardDialog(true)
alt User confirms discard
User->>Sidebar: clicks Discard Changes
Sidebar->>Store: confirmNavigation()
Store-->>Sidebar: pendingSection
Sidebar->>Router: replace(getSettingsHref(section))
Manager->>Store: reset() on unmount
else User cancels
User->>Sidebar: clicks Keep Editing
Sidebar->>Store: cancelNavigation()
Store-->>Sidebar: pendingSection=null
end
Note over Sidebar,Store: Back button path
User->>Sidebar: clicks Back (isDirty=true)
Sidebar->>Sidebar: setShowDiscardDialog(true)
Note over Store: pendingSection stays null
User->>Sidebar: clicks Discard Changes
Sidebar->>Store: confirmNavigation()
Store-->>Sidebar: null (no pending section)
Sidebar->>Router: push(popSettingsReturnUrl)
Reviews (4): Last reviewed commit: "fix(teams): add 1drv.com apex to OneDriv..." | Re-trigger Greptile |
apps/sim/app/workspace/[workspaceId]/settings/components/credentials/credentials-manager.tsx
Show resolved
Hide resolved
|
@greptile |
|
@cursor review |
…owlist The subdomain check for smba.trafficmanager.net was unnecessary — Azure Traffic Manager does not support nested subdomains of existing profiles, but the pattern still raised a valid audit concern. Teams bot-framework attachment URLs from this host fall through to the generic fetchWithDNSPinning branch, which provides the same protection without the ambiguity.
...orkspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-sidebar.tsx
Show resolved
Hide resolved
…workspace env query
|
@greptile |
|
@cursor review |
1drv.com (apex) is a short-link domain functionally equivalent to 1drv.ms and requires share-token resolution, not direct fetch. CDN subdomains (files.1drv.com) are unaffected — the exact-match check leaves them on the direct-fetch path.
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 522f3e2. Configure here.
Summary
Type of Change
Testing
Tested manually
Checklist