Add GitHub keymap sync tab with OAuth, diff viewer, and PR creation#64
Draft
Copilot wants to merge 4 commits into
Draft
Add GitHub keymap sync tab with OAuth, diff viewer, and PR creation#64Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
- Add Cloudflare Worker for GitHub OAuth flow with CSRF state validation - Add GitHub API client library (src/lib/github.ts) - Add ZMK keymap file patching and diff generation utilities - Add useGitHub React hook for GitHub state management - Add GitHubPage with repo/file selector and diff viewer - Add GitHub tab to app navigation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: cormoran <7994064+cormoran@users.noreply.github.com>
…tary Layer, etc. correctly Co-authored-by: cormoran <7994064+cormoran@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add feature to load zmk-config repository and update .keymap
Add GitHub keymap sync tab with OAuth, diff viewer, and PR creation
Feb 20, 2026
🚀 Cloudflare Workers PreviewPreview URL: https://60c9d58a-dya-studio.cormoran707.workers.dev Deployed from commit dfc7ecf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new "GitHub" tab that lets users sync their current keyboard configuration to a zmk-config repository via a GitHub pull request. In demo mode, the feature is fully functional with fake data so users can explore the workflow without a real keyboard or GitHub account.
Architecture
Cloudflare Worker OAuth (
src/worker.ts)Handles the server-side OAuth token exchange, keeping
GITHUB_CLIENT_SECREToff the client. Uses a state cookie for CSRF protection, then delivers the token to the opener window viapostMessage(origin-restricted) before self-closing.GET /api/auth/github/login→ redirect to GitHub OAuthGET /api/auth/github/callback→ exchange code, postMessage token, close popupWorks locally via
wrangler devwith a.dev.varsfile.GitHub API client (
src/lib/github.ts)Thin fetch wrappers for: user info, repo listing, tree traversal (finds
.keymapfiles), file read, branch creation, file commit (PUT), and PR creation.Keymap file generator (
src/lib/keymapFileGenerator.ts)bindingToZmk()— converts aBehaviorBindingto ZMK syntax (&kp A,&trans,&mo 1,< 2 A,&mt LCTRL A, etc.)patchKeymapFile()— replaces eachbindings = < ... >;block in the.keymapsource with bindings from the keyboard's current state (matched by layer index)generateDiff()— LCS-based line-by-line diff returning typedDiffLine[]Hook (
src/hooks/useGitHub.ts)Manages OAuth popup flow, repo/file selection, diff generation, and PR commit. Demo mode is detected from
deviceNamecontaining"Demo"and injects fake repos + a sample.keymapfile.Page (
src/pages/GitHubPage.tsx)Sequential UI: demo banner → auth → repo selector → file selector → diff viewer (green/red line-by-line with line numbers) → "Create Pull Request" button.
Local Setup
Create
.dev.vars:Register a GitHub OAuth App with callback
http://localhost:8787/api/auth/github/callback.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.