Skip to content

Add Google Drive integration for browsing and importing files#3885

Draft
jbecke wants to merge 1 commit into
mainfrom
claude/serene-cori-wcalab
Draft

Add Google Drive integration for browsing and importing files#3885
jbecke wants to merge 1 commit into
mainfrom
claude/serene-cori-wcalab

Conversation

@jbecke

@jbecke jbecke commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements a complete Google Drive integration that allows Macro users to connect their Google Drive account via OAuth, browse their folder tree, and import selected files/folders into Macro as Projects and Documents.

Key Changes

Backend (Rust)

  • New google_drive crate with domain-driven architecture:

    • Domain models for Drive files, import requests/results, and user links
    • Port traits for Drive API, access tokens, repository, and import sink
    • Service implementation orchestrating browse and import operations with explicit work-stack (non-recursive) to ensure parents are created before children
    • Safety cap of 5,000 entities per import to prevent runaway recursion
  • Outbound adapters:

    • DriveApiClient: REST client for Google Drive API v3 with pagination support
    • AuthServiceAccessTokens: Resolves Drive access tokens via authentication_service with 30-minute redis caching
    • PgGoogleDriveLinkRepo: PostgreSQL persistence for user Drive connections
  • Inbound HTTP router (google_drive_router):

    • GET /files - List folder children for the picker UI
    • POST /import - Import selected Drive items into Macro
    • GET /connection - Check if user has connected Drive
  • Import sink (GoogleDriveImportSink):

    • Materializes imported Drive content as Macro Projects and Documents
    • Reuses existing document-creation pipeline (presigned upload + content lifecycle)
    • Records Drive → Macro mappings as foreign_entity rows for deduplication and traceability
    • Handles both binary files (download) and Google-native docs (export to concrete formats)
  • Authentication service integration:

    • New /link/google-drive endpoints for initiating and finalizing OAuth flow
    • Mirrors existing Gmail link pattern with FusionAuth identity-provider integration
    • New internal endpoint for retrieving Drive access tokens
  • Database migration: google_drive_links table to persist user Drive connections

Frontend (TypeScript/SolidJS)

  • Google Drive import dialog (GoogleDriveImportDialog):

    • Folder navigator with breadcrumb support
    • Checkbox selection for files/folders to import
    • Recursive folder import support
  • Query hooks (@queries/drive):

    • useGoogleDriveLinkStatusQuery - Check connection status
    • useInitGoogleDriveLink - Initiate OAuth flow
    • useFinalizeGoogleDriveLink - Complete OAuth flow
    • useDisconnectGoogleDrive - Disconnect Drive
    • useGoogleDriveFoldersQuery - Browse folder contents
    • useImportFromGoogleDrive - Import selected items
  • Account settings integration:

    • New Drive connection UI in Account component
    • OAuth callback handler (GoogleDriveLinkCallback)
    • Connection status display with reauthentication handling
  • Google Drive icon SVG for UI

Infrastructure

  • FusionAuth configuration for Google Drive identity provider (dev/prod)
  • Workspace member addition for new google_drive crate

Implementation Details

  • Import uses explicit work-stack rather than async recursion to guarantee parent folders are created before children
  • Access tokens cached in redis for 30 minutes to amortize refresh round-trips
  • Foreign entity mappings enable future deduplication and source tracing
  • Google-native documents (Docs/Sheets/Slides) are exported to concrete formats (DOCX/XLSX/PPTX)
  • OAuth flow mirrors existing Gmail integration pattern for consistency
  • Comprehensive test suite for service layer with stub implementations of all ports

https://claude.ai/code/session_01QwvJehxEZgSEH8RxA3Xecj

Lets a Macro user connect their Google Drive account and import selected
folders/files into Macro as Projects and Documents (one-way import, no sync) —
matching the "import folders, but no sync; pick which folder trees" feedback.

Backend
- New `google_drive` crate (hexagonal domain/ports/service/outbound/inbound):
  Drive v3 REST client, redis-cached access-token client (via
  authentication_service), a `google_drive_links` Postgres repo, and an import
  orchestration service that walks the selected tree via an explicit work-stack
  (parents before children) over a `DriveImportSink` port.
- authentication_service: `/link/google-drive` init/finalize/status/delete
  endpoints (reusing the shared Google OAuth callback) and an
  `/internal/google_drive_access_token` endpoint.
- document_storage_service: `DriveImportSink` adapter that creates Projects +
  Documents (reusing the existing presigned-upload + content pipeline) and
  records each Drive->Macro mapping in `foreign_entity`; wires
  `/google-drive/{files,import,connection}` under the authenticated router.
- authentication_service_client: `get_google_drive_access_token`.
- macro_db_client: `google_drive_links` migration.
- infra: `google_drive` FusionAuth IdP (Drive scopes, shared Google client).

Frontend (SolidJS)
- service-clients (auth + storage) and `@queries/drive` hooks for
  connect/status/browse/import.
- "Google Drive" row in Account settings (Enable/Disable/Reconnect + Import),
  an import dialog (folder navigator + multi-select), the OAuth callback route,
  and a Drive icon.

Notes
- Google-native docs (Docs/Sheets/Slides) are exported to PDF for a robust v1
  (they land directly in object storage); editable Office exports are a
  follow-up.
- The new `google_drive_links` SQLx queries require `just prepare_db` against a
  live Postgres to build offline (no DB was available in this environment, so
  the DB-touching crates and the dss/auth-service builds were not compiled
  here; the `google_drive` crate's non-DB surface, the auth client, and the
  frontend type-check all pass).

https://claude.ai/code/session_01QwvJehxEZgSEH8RxA3Xecj
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 66667a02-4e47-4715-9946-e39207bda178

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

@404Wolf

404Wolf commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

I wonder if we could bridge in https://rclone.org/ or something similar some how, and have support for like every cloud provider at once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants