diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f22ca65..2e06c17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ # Variables), baked into the build so the sign-in dialog doesn't ask for them: # KIVI_GITHUB_CLIENT_ID the GitHub App's Client ID (Iv23…) # KIVI_GITHUB_APP_SLUG its URL name (github.com/apps/) +# KIVI_GITLAB_CLIENT_ID the gitlab.com OAuth application's ID (device flow) name: CI @@ -53,6 +54,7 @@ jobs: run: | gjs -m tests/models.js gjs -m tests/review.js + gjs -m tests/gitlab.js gjs -m tests/diff.js gjs -m tests/nets.js @@ -134,6 +136,7 @@ jobs: env: KIVI_GITHUB_CLIENT_ID: ${{ vars.KIVI_GITHUB_CLIENT_ID }} KIVI_GITHUB_APP_SLUG: ${{ vars.KIVI_GITHUB_APP_SLUG }} + KIVI_GITLAB_CLIENT_ID: ${{ vars.KIVI_GITLAB_CLIENT_ID }} APPIMAGE_EXTRACT_AND_RUN: "1" # the AppImage tooling runs without FUSE run: cargo tauri build @@ -178,6 +181,7 @@ jobs: env: KIVI_GITHUB_CLIENT_ID: ${{ vars.KIVI_GITHUB_CLIENT_ID }} KIVI_GITHUB_APP_SLUG: ${{ vars.KIVI_GITHUB_APP_SLUG }} + KIVI_GITLAB_CLIENT_ID: ${{ vars.KIVI_GITLAB_CLIENT_ID }} run: cargo tauri build --no-bundle - name: Name the .exe after the version @@ -229,6 +233,7 @@ jobs: env: KIVI_GITHUB_CLIENT_ID: ${{ vars.KIVI_GITHUB_CLIENT_ID }} KIVI_GITHUB_APP_SLUG: ${{ vars.KIVI_GITHUB_APP_SLUG }} + KIVI_GITLAB_CLIENT_ID: ${{ vars.KIVI_GITLAB_CLIENT_ID }} run: cargo tauri build --target universal-apple-darwin - uses: actions/upload-artifact@v4 diff --git a/CLAUDE.md b/CLAUDE.md index 2f89673..b994f84 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,10 +1,11 @@ # KiVi — Tauri 2 desktop app -KiVi renders KiCad 6–10 projects (schematic, PCB, 3D, BOM) from GitHub -repositories or local folders, with a project gallery, a pull request inbox, -a visual diff and review comments pinned to parts/nets that are stored as -ordinary GitHub PR review comments. GitHub stays the backend for source -control, diffs and review comments. +KiVi renders KiCad 6–10 projects (schematic, PCB, 3D, BOM) from GitHub and +GitLab (gitlab.com) repositories or local folders, with a project gallery, a +pull/merge request inbox, a visual diff and review comments pinned to +parts/nets that are stored as ordinary PR review comments (GitHub) or MR file +discussions (GitLab). The forge stays the backend for source control, diffs +and review comments. README.md is the user-facing pitch and developer reference (build, layout, test commands); `docs/README.md` is the user guide (every feature, GitHub App @@ -49,7 +50,8 @@ README doesn't: conventions, environment and pitfalls. glides to the Top or Bottom preset around it (`Board3D.focusOn(box, side)`, `onView` presses the preset button). Clicks inside a view never move it. - **Forges** (`src/forge/`): every GitHub request (REST, GraphQL, raw files, - search) and github.com link is in `src/forge/github.js`; the rest of the app + search) and github.com link is in `src/forge/github.js`, every GitLab one in + `src/forge/gitlab.js` (REST v4; gitlab.com only, the user's choice); the rest of the app talks to a forge object only (`forge()` / `forgeInHash()` / `parseRepoSpec()` from `src/forge/index.js`, whose JSDoc typedefs are the interface: `Forge`, `Source`, `RepoInfo`, `PullRequest`, `ChangedFile`, `Comparison`, @@ -57,12 +59,30 @@ README doesn't: conventions, environment and pitfalls. GitHub JSON. Forge sources carry `source.forge` (app code tests that, not `kind === "github"`); page hashes use `forge.hashKey` (`gh=`); review stores and diff specs carry `forge` (an id, GitHub by default). A new forge - = a new adapter added to `FORGES` (`tests/review.js` checks each one has - every member). Not forge-neutral yet: tokens and sign-in (settings `token`, - the GitHub App device flow in tauri.js, which uses `github` directly), the - Rust git commands (github.com URLs in git.rs/git_http.rs, `git_link_github`) - and most UI wording ("GitHub"). No DOM or Tauri in `src/forge/`: it runs - under gjs. + = a new adapter added to `FORGES`, its sign-in URLs to lib.rs `OAUTH_URLS` + and its host to git.rs `FORGE_HOSTS` (`tests/review.js` checks each one has + every member and its sign-in URLs are allowed). Tokens and sign-in are per + forge (see Signing in). UI text names the forge (`f.name`, `f.words`: + "pull request"/"merge request", `#12`/`!12`, "Fixes #N"/"Closes #N"; + `forgeNames()` = "GitHub or GitLab"). No DOM or Tauri in `src/forge/`: it + runs under gjs. +- Repository keys (`repoKey`/`parseRepoKey`, forge/index.js): settings + `watchRepos`, `hiddenRepos`, `localCopies`, the gallery index and + `kivi.kicadRepos` hold "owner/repo" for GitHub (as earlier versions saved + them, no migration) and "gitlab:group/sub/project" for GitLab. GitLab + namespaces may hold "/": owner = everything before the last "/" + (`splitNwo`); `gl=` links and `pr=group/sub/project#5` parse that way. +- GitLab specifics (gitlab.js): the API answers CORS for any origin, so pages + call it directly; raw web URLs don't, so files come from + `/repository/files/…/raw?lfs=true`. Trees are listed 100 entries per request + (keyset pages via `Link` headers; sizes not listed, so no "too large" + thumbnail check). MR comments = file discussions (`position_type: "file"` + with the MR's `diff_refs`); signed out GitLab answers 401 for discussions + and notes, also on public projects (`readsNeedSignIn`; issue comments say + so). Gallery signed in: member projects, Reporter+, not archived (the + user's choice). Unauthenticated gitlab.com rate-limits per IP + (`unauthenticated_traffic_per_ip`, hit easily while testing; Retry-After + isn't exposed through CORS). - `src/desktop/` holds the Tauri integration; it's a no-op when `window.__TAURI__` is missing (`isDesktop`), which is what lets the pages run in a plain headless browser for tests. @@ -75,7 +95,7 @@ README doesn't: conventions, environment and pitfalls. each loads on first show, since they cost API requests). There's no Watched drawer or recent folders list any more (the user's choice): repositories are added with "+" → Remote project… (`watchRepos`). **Reload** (`#reload`) clears - `hiddenRepos` and lists every repository again, so removed GitHub + `hiddenRepos` and lists every repository again, so removed GitHub/GitLab repositories come back (the user's choice; local projects stay removed). - **Projects** (`src/desktop/projects.js` + `thumb-worker.js`): a card grid of every `.kicad_pro` in reachable repositories, with board thumbnails. Caches: @@ -84,11 +104,11 @@ README doesn't: conventions, environment and pitfalls. SHA). 48 cards per page; boards over 30 MB get no thumbnail. - **"+" menu** (`src/desktop/add-project.js`, `#add-project`, a `