-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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/withmod.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):
ghCLI token —gh auth tokengives an existing PAT if the user hasghinstalled. Zero-friction for developers.- OAuth Device Flow — GitHub's device flow for users without
ghCLI. Similar to the Google Drive OAuth flow insrc-tauri/src/locations/gdrive/auth.rs. - 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 treeGET /repos/{owner}/{repo}/contents/{path}?ref={branch}— file/directory contentsGET /repos/{owner}/{repo}/branches— list branchesGET /repos/{owner}/{repo}/releases— list releasesGET /repos/{owner}/{repo}/releases/{id}/assets— release assetsGET /users/{owner}/gists— list gistsPUT /repos/{owner}/{repo}/contents/{path}— create/update fileDELETE /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.comURLs and convert togithub://scheme innormalizePath()insrc/store/useAppStore.ts - Types (
src/types/index.ts): May needremote_id,download_urlfields onFileItem(already exist from gdrive support)
Acceptance Criteria
-
LocationProvidertrait implemented forgithubscheme - Can browse public repos without auth
- Can authenticate via
ghCLI 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.comURLs and converts togithub://scheme - Release assets are downloadable
- Registered in provider registry and all existing commands work automatically