Skip to content

feat: Add GitHub as a browsable location provider #234

@BrianLeishman

Description

@BrianLeishman

Summary

Add GitHub as a location provider so users can paste a GitHub link and browse repositories, branches, files, releases, and gists like a filesystem — the same way Google Drive and SMB shares work today.

URI Scheme

github://owner/repo/tree/branch/path/to/file
github://owner/gists/

Mirrors GitHub URL structure. Could also detect and convert github.com URLs pasted into the path bar.

Virtual Root Structure

Per-repo virtual folders (similar to Google Drive's My Drive, Shared drives, etc.):

  • Code — default branch file tree (landing view)
  • Branches — list all branches → browse each branch's tree
  • Releases — list releases → browse downloadable assets
  • Gists — at user level (github://owner/gists/) — list and browse gist files

Capabilities

Capability Supported Notes
Read Yes Public repos immediately; private repos via auth
Write Limited Create/delete files via Contents API, create releases
Create directories No Git doesn't have empty directories
Delete Limited Delete files via Contents API
Rename Limited Delete + create via Contents API
Copy No Not a native GitHub concept
Move No Delete + create
Watching No requiresExplicitRefresh: true
Thumbnails Yes Download to temp → generate locally (same pattern as gdrive)

Technical Notes

Provider Architecture

Follows the existing LocationProvider trait pattern:

  • New module: src-tauri/src/locations/github/ with mod.rs, provider.rs, auth.rs
  • Register in provider registry at src-tauri/src/locations/mod.rs (same pattern as gdrive/smb registration around lines 26-40)
  • Scheme: github

Authentication

Options (in priority order):

  1. gh CLI tokengh auth token gives an existing PAT if the user has gh installed. Zero-friction for developers.
  2. OAuth Device Flow — GitHub's device flow for users without gh CLI. Similar to the Google Drive OAuth flow in src-tauri/src/locations/gdrive/auth.rs.
  3. No auth — public repos work without authentication (lower rate limits).

API

GitHub REST API v3 (via octocrab or reqwest):

  • GET /repos/{owner}/{repo}/git/trees/{branch}?recursive=1 — file tree
  • GET /repos/{owner}/{repo}/contents/{path}?ref={branch} — file/directory contents
  • GET /repos/{owner}/{repo}/branches — list branches
  • GET /repos/{owner}/{repo}/releases — list releases
  • GET /repos/{owner}/{repo}/releases/{id}/assets — release assets
  • GET /users/{owner}/gists — list gists
  • PUT /repos/{owner}/{repo}/contents/{path} — create/update file
  • DELETE /repos/{owner}/{repo}/contents/{path} — delete file

Cross-Provider Paste

New cases in paste_items_to_location() in src-tauri/src/commands.rs (around line 2230+):

("github", "file")   → download file via Contents API raw URL → copy to local path
("file", "github")   → upload via Contents API PUT
("github", "gdrive") → download to temp → upload to gdrive
("gdrive", "github") → download to temp → upload via Contents API
("github", "smb")    → download to temp → upload_file_to_smb()
("smb", "github")    → download_file_from_smb() to temp → upload via Contents API
("github", "github") → same-provider: provider.copy() (create via Contents API)

Thumbnail Generation

Add github handling in src-tauri/src/thumbnails/generators/mod.rs — download file to temp directory (same pattern as gdrive thumbnails), then call generate_local().

Frontend

  • Sidebar (src/components/Sidebar.tsx): New "GitHub" section with GitHub icon, add repo button, list of connected repos/accounts
  • Path bar: Detect github.com URLs and convert to github:// scheme in normalizePath() in src/store/useAppStore.ts
  • Types (src/types/index.ts): May need remote_id, download_url fields on FileItem (already exist from gdrive support)

Acceptance Criteria

  • LocationProvider trait implemented for github scheme
  • Can browse public repos without auth
  • Can authenticate via gh CLI token or OAuth device flow for private repos
  • Virtual folders: Code (default branch), Branches, Releases, Gists
  • Can navigate into branches and browse file trees
  • Can download/open files from GitHub repos
  • Thumbnails generate for supported file types (images, PDFs, etc.)
  • Cross-provider paste works (github↔file, github↔gdrive, github↔smb)
  • Sidebar shows GitHub section with add/remove repo UI
  • Path bar accepts github.com URLs and converts to github:// scheme
  • Release assets are downloadable
  • Registered in provider registry and all existing commands work automatically

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions