Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Aug 19, 2025

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

  • Bug fix

Testing

Manually, high frequency refreshes and using GDrive blcok with all tools.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Aug 19, 2025 10:45pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 19, 2025 10:45pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs August 19, 2025 19:52 Inactive
@vercel vercel bot temporarily deployed to Preview – docs August 19, 2025 19:54 Inactive
@vercel vercel bot temporarily deployed to Preview – docs August 19, 2025 19:56 Inactive
@vercel vercel bot temporarily deployed to Preview – docs August 19, 2025 22:41 Inactive
@icecrasher321 icecrasher321 merged commit 334e827 into staging Aug 19, 2025
5 checks passed
@icecrasher321 icecrasher321 changed the title fix(oauth-block): race condition for rendering credential selectors and other subblocks + gdrive fixes fix(oauth-block): race condition for rendering credential selectors and other subblocks + gdrive fixes + subblock dependency consolidation Aug 19, 2025
@waleedlatif1 waleedlatif1 deleted the fix/oauth-block-race-cond branch August 20, 2025 01:33
Sg312 pushed a commit that referenced this pull request Aug 20, 2025
…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
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant