-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(oauth-block): race condition for rendering credential selectors and other subblocks + gdrive fixes + subblock dependency consolidation #1029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nd other subblocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR addresses a critical race condition affecting OAuth credential selectors and enhances Google Drive integration with shared drives support. The main changes include:
Race Condition Fix: The core issue was in the use-sub-block-value.ts hook where credential selectors weren't rendering names properly due to timing issues during workflow initialization. The fix subscribes to activeWorkflowId from the workflow registry, ensuring the hook recomputes when the active workflow changes and preventing null values during component mount.
File Selector Refactoring: The FileSelectorInput component underwent significant refactoring to eliminate dual state management. All local state variables (selectedFileId, fileInfo, etc.) and their synchronization logic via useEffect were removed in favor of direct store access through useSubBlockValue hooks. This creates a single source of truth and eliminates the synchronization race condition.
Google Drive Shared Drives Support: Multiple Google Drive tools (list.ts, upload.ts, create_folder.ts) now include supportsAllDrives=true parameter in API calls, enabling proper functionality with Google Workspace shared drives. The drive file route (/api/tools/drive/file/route.ts) adds shortcut resolution logic to display actual target file details instead of confusing shortcut metadata.
Enhanced Authorization: The drive files API route replaces manual database credential validation with a centralized authorizeCredentialUse function, improving concurrency control and supporting workflow-scoped credential sharing for collaborators.
These changes integrate with the existing OAuth and workflow systems by ensuring proper state management through the established useSubBlockValue pattern and maintaining backward compatibility with the block configuration architecture.
Confidence score: 4/5
- This PR addresses real production issues with good technical solutions but involves complex state management changes
- Score reflects solid implementation of race condition fixes and API enhancements, though the state management refactoring touches critical UI components
- Pay close attention to the file selector refactoring and OAuth credential authorization changes as they modify core user interaction flows
7 files reviewed, 1 comment
…nd other subblocks + gdrive fixes (#1029) * fix(oauth-block): race condition for rendering credential selectors and other subblocks * fix import * add dependsOn field to track cros-subblock deps * remove redundant check * remove redundant checks * remove misleading comment * fix * fix jira * fix * fix * confluence * fix triggers * fix * fix * make trigger creds collab supported * fix for backwards compat * fix trigger modal
…nd other subblocks + gdrive fixes (simstudioai#1029) * fix(oauth-block): race condition for rendering credential selectors and other subblocks * fix import * add dependsOn field to track cros-subblock deps * remove redundant check * remove redundant checks * remove misleading comment * fix * fix jira * fix * fix * confluence * fix triggers * fix * fix * make trigger creds collab supported * fix for backwards compat * fix trigger modal
Summary
Credential Selector not rendering name of credential due to race condition. This PR fixes that.
Cleanup unused code in file-selector.
Fix Gdrive endpoints to work with shared drives correctly.
Add dependsOn field to subblock config that can track dependencies between subblocks
- Can grey out child subblocks until parents are selected
- Can clear child subblocks when parents are cleared / changed
Type of Change
Testing
Manually, high frequency refreshes and using GDrive blcok with all tools.
Checklist