Skip to content

An open-source, faster Devin alternative

TypeScript

Notes and API docs: GET /work/repositories and the new picker

Igor Zalutski via Computerbc790481f23a
diff --git a/WORK_API_NOTES.md b/WORK_API_NOTES.md
index 8ec3dd44..dd80bdd7 100644
--- a/WORK_API_NOTES.md
+++ b/WORK_API_NOTES.md
@@ -9,6 +9,12 @@ Build step 3, the service side. This file covers the shapes and headers, how the
- `problemMessage` is GitHub's words, for people.
- `GET /work/repository` returns `{ repository: Repository | null }`.
- `PUT /work/repository` returns the same shape.
+- `GET /work/repositories` returns, for the repository picker, `{ installations: [{ id, accountLogin, accountType, settingsUrl, repositories: [{ id, owner, name, private, defaultBranch, pushedAt: string | null }], truncated, problem, problemMessage }] }`.
+ - One entry per active GitHub installation of the organization, in one call. `id` is the value `PUT /work/repository` takes as `installationId`.
+ - `settingsUrl` is the installation's page on GitHub (`/organizations/<login>/settings/installations/<id>`, or `/settings/installations/<id>` for a user), built here so the web derives nothing.
+ - Repositories are sorted by `pushedAt`, newest first, never-pushed last, then by name. At most 500 per installation are read; `truncated` says more exist. The cap applies in GitHub's order, before the sort, so with more than 500 the newest may be among those left out.
+ - An installation GitHub reports gone or suspended comes back with its `problem` and no repositories. GitHub not answering is 503 `unavailable`.
+ - Nothing is stored and the index's write chain is not used; the installation tokens are cached as for the index's own reads. Scope: `work:read`.
- `GET /work/items?stage=open` returns `{ repository, head, asOf, building, items: Item[] }`, with an `ETag` header.
- `GET /work/items?stage=closed[&cursor&limit]` returns `{ items: Item[], nextCursor: string | null }`.
- `GET /work/items/{n}` returns `{ item: Item, body: string }`.
@@ -168,6 +174,7 @@ Measured with the fake GitHub in `work-index.test.ts`. The fake enforces the rea
| Operation | Calls |
| --- | --- |
| PUT repository | 2: the repository and the branch ref. |
+| GET repositories | 1 page of 100 per installation, up to 5 (500 repositories), plus a token when none is cached. |
| First build, 150 open + 500 closed | 154: 1 ref + 3 trees + 150 blobs. No commit calls. |
| Walk after that build | 5: 2 folder listings, then 3 pages of the import commit's 650 files. |
| Advance over 500 commits (400 non-item files, 100 item edits) | 115: 1 ref + 1 compare + 2 trees (root, `work/`) + 100 blobs + 1 listing page + 10 details. No rebuild. |
diff --git a/WORK_WEB_NOTES.md b/WORK_WEB_NOTES.md
index 4ab55922..061a6131 100644
--- a/WORK_WEB_NOTES.md
+++ b/WORK_WEB_NOTES.md
@@ -16,9 +16,12 @@ add fields without breaking the screens.
- Body: `{installationId, owner, name, branch}`.
- Returns `{repository}`.
- Sends an `Idempotency-Key` header.
- - `installationId` is the installation `id` string that `GET /managed-agents/computer` lists under `github.installations`.
- - `owner` is that installation's `accountLogin`.
- - The repository `name` is typed by hand, because no endpoint lists the repositories a computer installation can reach.
+ - The picker sends the chosen installation's `id`, the repository's `owner` and `name`, and its `defaultBranch` as `branch`. There is no branch input.
+- `GET /work/repositories` returns `{installations: [{id, accountLogin, accountType, settingsUrl, repositories: [{id, owner, name, private, defaultBranch, pushedAt}], truncated, problem, problemMessage}]}`, repositories already sorted most recently pushed first.
+ - The picker (`RepositorySetting.tsx`) follows the "import a repository" pattern: an account select when there is more than one installation, a search that filters by name as you type, a refresh button, and a list of about six rows that scrolls, each with a lock when private, the pushed time and Select. The current choice shows as Selected.
+ - The list is read again whenever the window regains focus (`refetchOnWindowFocus: 'always'`, past the 30 s default `staleTime`), so coming back from GitHub after granting access shows the new repository.
+ - Under the list, "Adjust GitHub App access" opens the installation's `settingsUrl` in a new tab.
+ - When the list loads with no installation, the "Connect GitHub" state shows, as before.
- `Repository` is `{installationId: string|number, owner, name, branch, problem?: string|null, problemMessage?: string|null}`.
- A non-empty `problem` means the repository cannot be read; the board then says so and links to settings.
- `problem` is a stable code (`access_denied`, `repository_not_found`, `installation_removed`, `installation_suspended`, `branch_not_found`, `github_app_not_configured`). The code is never shown: the web shows `problemMessage` when present, else its own sentence for a known code (`repositoryProblem` in `board.ts`), else a general one.
@@ -75,6 +78,7 @@ The web renders the server's `stage`, `readyToClose`, `attention`, `mine`, `warn
- unknown: outline
- Where things live:
- The repository setting is on the Computer page (`/computer#work-repository`), after "Your agent", and is also embedded in the board's no-repository state.
+ - The board's header names the repository it reads as a quiet link to that setting; when the repository has a problem the link reads "Settings".
- The rail gains one link, "Board" (`/computer/work`). It is shown unconditionally like Secrets; the page itself redirects when the organization has no computer.
## Preview mock
@@ -83,6 +87,7 @@ The web renders the server's `stage`, `readyToClose`, `attention`, `mine`, `warn
- The open-items poll goes through `workOpenItemsResponse`, which answers as the server does: an ETag over the page without `asOf`, a 304 while that ETag matches, and `Work-As-Of` on both.
- `problem` sends `access_denied` with a `problemMessage`.
+- `/repositories` lists eight repositories under `acme` and two under `acme-labs`, the preview's two installations. `?work=none` opens the picker.
- Item 31 has an unknown `updatedAt`; closed item 8 has no `closedAt` or `closedBy`.
- An unknown item number answers 404 `item_not_found`.
diff --git a/docs/api/overview.mdx b/docs/api/overview.mdx
index 5b9298ee..d3693136 100644
--- a/docs/api/overview.mdx
+++ b/docs/api/overview.mdx
@@ -53,7 +53,7 @@ A credential without a scope list has every scope.
| `sessions:write` | `turns.send`, `turns.cancel`, `sessions.update`, `sessions.interrupt`, `sessions.compact`, `sessions.suspend`, `sessions.resume`, setting a session aside, file upload |
| `asks:answer` | `asks.answer`, `asks.dismiss` |
| `terminals` | `terminals.open`, `terminals.resize`, `terminals.eof`, `terminals.close` |
-| `work:read` | `GET /work/repository`, `GET /work/items`, `GET /work/items/{number}`, `GET /work/items/{number}/history` |
+| `work:read` | `GET /work/repository`, `GET /work/repositories`, `GET /work/items`, `GET /work/items/{number}`, `GET /work/items/{number}/history` |
| `work:write` | `PUT /work/repository` |
`work:read` and `work:write` are granted only to a key that names them, never by a missing scope list or `*`. A session's own key is refused on `PUT /work/repository`.