opencode-github-pr 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Duncan Williams
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,441 @@
1
- # Temporary Holding Version
1
+ # opencode-github-pr
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/opencode-github-pr)](https://www.npmjs.com/package/opencode-github-pr)
4
+ [![CI](https://github.com/987poiuytrewq/opencode-github-pr/actions/workflows/ci.yml/badge.svg)](https://github.com/987poiuytrewq/opencode-github-pr/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
6
+
7
+ A GitHub pull request dashboard for the [OpenCode](https://opencode.ai) V2 sidebar. See your PRs for the current
8
+ repository, their CI, review and merge status, and jump straight to the right page on GitHub, without leaving OpenCode.
9
+
10
+ <img src="https://raw.githubusercontent.com/987poiuytrewq/opencode-github-pr/main/demo/demo.gif" alt="The PR dashboard in the OpenCode sidebar, paging through PRs and changing filters" width="552" />
11
+
12
+ ## Features
13
+
14
+ - **PR list in the sidebar** for the repository of the active session, refreshed automatically.
15
+ - **Status at a glance:** mergeability, CI checks, reviews and unresolved review comments on every row.
16
+ - **Click-through to GitHub:** each part of a row opens the matching GitHub page (overview, checks, files or merge
17
+ status).
18
+ - **Filters:** show PRs for the current branch, authored by you, assigned to you, or all of them, and choose open,
19
+ closed or all states.
20
+ - **Follows your theme:** colours come from your active OpenCode theme, and every colour and icon can be overridden.
21
+ - **Nerd Font or plain Unicode icons**, so it looks right whether or not your terminal font has Nerd Font glyphs.
22
+ - **Works with GitHub.com and GitHub Enterprise Server**, over HTTPS or SSH remotes, including linked Git worktrees.
23
+
24
+ ## Requirements
25
+
26
+ - OpenCode **2.0.20 or later** (V2 plugin API).
27
+ - [Bun](https://bun.sh), if installing from source.
28
+ - A GitHub token, or the [GitHub CLI](https://cli.github.com) signed in with `gh auth login`. See
29
+ [Authentication](#authentication).
30
+ - A terminal font that supports Nerd Font glyphs, or set `iconStyle` to `"unicode"` to use standard Unicode symbols.
31
+
32
+ ## Install from npm
33
+
34
+ Add the package name to the `plugins` array in your OpenCode config, either globally at
35
+ `~/.config/opencode/opencode.json` or in a project's `opencode.json`:
36
+
37
+ ```json
38
+ {
39
+ "$schema": "https://opencode.ai/config.json",
40
+ "plugins": ["opencode-github-pr"]
41
+ }
42
+ ```
43
+
44
+ Run `/reload` in the TUI. OpenCode installs the package from npm and the **Pull Requests** panel appears in the session
45
+ sidebar.
46
+
47
+ To pass [options](#configuration), keep the plugin registered in `opencode.json` and add a matching entry to the
48
+ global CLI config at `~/.config/opencode/cli.json` (or `$XDG_CONFIG_HOME/opencode/cli.json`):
49
+
50
+ ```json
51
+ {
52
+ "$schema": "https://opencode.ai/v2/cli.json",
53
+ "plugins": [
54
+ {
55
+ "package": "opencode-github-pr",
56
+ "options": {
57
+ "iconStyle": "unicode"
58
+ }
59
+ }
60
+ ]
61
+ }
62
+ ```
63
+
64
+ ## Install from source
65
+
66
+ 1. Clone the repository and install its dependencies:
67
+
68
+ ```bash
69
+ git clone https://github.com/987poiuytrewq/opencode-github-pr.git
70
+ cd opencode-github-pr
71
+ bun install
72
+ ```
73
+
74
+ The install also builds the package's TUI entrypoint. The npm artifact ships this precompiled JavaScript so
75
+ OpenCode's isolated plugin cache can resolve the OpenTUI JSX runtime through the host's shared runtime modules.
76
+
77
+ 2. Add the clone's absolute path to the `plugins` array in your OpenCode config. Use the global config at
78
+ `~/.config/opencode/opencode.json` to get the dashboard in every project, or a project's `opencode.json` for just
79
+ that project:
80
+
81
+ ```json
82
+ {
83
+ "$schema": "https://opencode.ai/config.json",
84
+ "plugins": [
85
+ {
86
+ "package": "/absolute/path/to/opencode-github-pr"
87
+ }
88
+ ]
89
+ }
90
+ ```
91
+
92
+ 3. Run `/reload` in the TUI. The **Pull Requests** panel appears in the session sidebar.
93
+
94
+ However you install it, register the package in `opencode.json` so its server part is available. Put TUI
95
+ [options](#configuration) in the global `cli.json` entry for the same package. The CLI loads the TUI part from the
96
+ server's plugin list, including when it is connected to a remote server.
97
+
98
+ ## Authentication
99
+
100
+ The plugin looks for a token in this order:
101
+
102
+ 1. `GITHUB_TOKEN`
103
+ 2. `GH_TOKEN`
104
+ 3. `GITHUB_PERSONAL_ACCESS_TOKEN`
105
+ 4. `gh auth token` (for the Enterprise host when [`GITHUB_ENTERPRISE_URL`](#github-enterprise-server) is set)
106
+
107
+ If you already use the GitHub CLI, `gh auth login` is all you need. Environment variables must be set where the
108
+ OpenCode server process starts; a token exported in a different shell won't be seen.
109
+
110
+ The token only needs read access. The dashboard doesn't change anything on GitHub.
111
+
112
+ | Token type | What it needs |
113
+ | --- | --- |
114
+ | `gh auth login` | The default scopes are enough. |
115
+ | Classic personal access token | `repo` for private repositories; no scope for public ones. |
116
+ | Fine-grained personal access token | Read access to **Pull requests** and **Commit statuses** on the repositories you use. |
117
+
118
+ ## Using the dashboard
119
+
120
+ The dashboard shows PRs for the repository the active session is working in. It finds the repository from the Git
121
+ remotes: `origin` first, then any other remote that points at GitHub (or your Enterprise host).
122
+
123
+ ### Reading a row
124
+
125
+ Each PR takes two lines. The first has a PR icon and the title. The second has the PR number, the lines added
126
+ and removed, and on the right, the unresolved comment count, review status and check status.
127
+
128
+ | Element | Meaning | Click opens |
129
+ | --- | --- | --- |
130
+ | PR icon | Green: ready to merge (including `HAS_HOOKS` when reviews are approved or not required). Red: merge conflict or changes requested. Yellow: blocked, behind, unstable or review required. Grey: draft, closed or unknown. Your theme's info colour: merged ([use GitHub's purple](#colours) instead). | Merge status panel |
131
+ | Title | The PR title, shortened to fit the sidebar. | PR overview |
132
+ | `#128` | PR number. | PR overview |
133
+ | `+42 -7` | Lines added and removed. | Files changed |
134
+ | Comment icon and count | Unresolved review threads. Hidden when there are none. | Files changed |
135
+ | Review icon | Green: approved. Red: changes requested. Yellow: review requested. Grey: commented. | PR overview |
136
+ | Check dot | Green: passing. Red: failing. Yellow: pending. Grey: neutral or skipped. | Checks |
137
+
138
+ When reviews or checks are in more than one state, each state gets its own icon with a count, for example three green
139
+ dots and one red dot for three passing checks and one failing.
140
+
141
+ On older GitHub Enterprise Server versions that report `mergeStateStatus` or `reviewDecision` as unknown GraphQL fields,
142
+ the dashboard retries once without those fields and continues with the remaining PR data. It does not retry unrelated
143
+ GraphQL errors, including other `422` responses.
144
+
145
+ ### Filters
146
+
147
+ The two labels at the top right of the panel are filters. Click one to cycle through its values.
148
+
149
+ | Filter | Values | Default |
150
+ | --- | --- | --- |
151
+ | Scope | `branch` (PRs from the current branch), `author` (opened by you), `assignee` (assigned to you), `all` | `author` |
152
+ | Status | `open`, `closed` (closed or merged), `all` | `open` |
153
+
154
+ You can change the defaults with [`defaultScope` and `defaultStatusFilter`](#configuration).
155
+
156
+ ### Pages
157
+
158
+ The panel shows five PRs at a time, most recently updated first. When there are more, use the arrows at the bottom
159
+ of the panel to page through them. The counter between the arrows shows the current page and the total, for example
160
+ `2 of 7`. Change the number per page with [`pageSize`](#configuration).
161
+
162
+ ### Commands
163
+
164
+ These commands are available as slash commands and in the command palette, under **PR Dashboard**:
165
+
166
+ | Slash command | Palette title | What it does |
167
+ | --- | --- | --- |
168
+ | `/pr-refresh` | PRs: Refresh dashboard | Reloads the PR list now. |
169
+ | `/pr-open` | PRs: Open selected in browser | Opens the PR you last clicked, or the first PR in the list. |
170
+
171
+ ### Refreshing
172
+
173
+ The list refreshes when OpenCode starts, each time a session goes idle (for example after the agent finishes a task),
174
+ and every 60 seconds while a session is open. Use `/pr-refresh` to reload it on demand. Change the interval with
175
+ [`refreshIntervalMs`](#configuration).
176
+
177
+ ### How PRs are loaded
178
+
179
+ The filters are applied by GitHub, so the dashboard only downloads PRs that match them:
180
+
181
+ - `all` and `branch` use the repository's PR list, so new PRs appear on the next refresh.
182
+ - `author` and `assignee` use GitHub search. Search can take a short while to index a new PR, so a PR you've just
183
+ opened may appear a refresh or two later. To bridge that delay, the dashboard also checks a small number of the
184
+ repository's newest PRs and adds matching ones that search hasn't returned yet. Set `recentPRsLimit` to `0` to disable
185
+ this supplement. GitHub search also returns at most 1,000 PRs; when you reach that limit, the panel says so.
186
+
187
+ PRs load in batches. The first batch holds four pages' worth (20 PRs with the default page size). Moving to another
188
+ page starts loading the next batch in the background, so paging stays quick. If you reach the last loaded page
189
+ before the next batch arrives, the panel moves on as soon as it does. Changing a filter loads that filter's first
190
+ batch. Use [`pageSize` and `pagesPerBatch`](#configuration) to change how much is loaded at a time.
191
+
192
+ ## Configuration
193
+
194
+ Pass options in the matching plugin entry's `options` object in the global
195
+ `~/.config/opencode/cli.json` (or `$XDG_CONFIG_HOME/opencode/cli.json`). CLI config is global, so these options apply
196
+ to all projects. Every option is optional. For a source installation, use the clone's absolute path as the `package`
197
+ value:
198
+
199
+ ```json
200
+ {
201
+ "$schema": "https://opencode.ai/v2/cli.json",
202
+ "plugins": [
203
+ {
204
+ "package": "opencode-github-pr",
205
+ "options": {
206
+ "pageSize": 8,
207
+ "refreshIntervalMs": 30000,
208
+ "recentPRsLimit": 5,
209
+ "defaultScope": "all",
210
+ "defaultStatusFilter": "open",
211
+ "spacing": {
212
+ "iconToCount": 0,
213
+ "sameTypeGroups": 0,
214
+ "differentTypeGroups": 1
215
+ },
216
+ "showSingleStatusCount": false
217
+ }
218
+ }
219
+ ]
220
+ }
221
+ ```
222
+
223
+ | Option | Default | Description |
224
+ | --- | --- | --- |
225
+ | `enabled` | `true` | Set to `false` to turn the dashboard off without uninstalling it. |
226
+ | `pageSize` | `5` | PRs shown per page. |
227
+ | `pagesPerBatch` | `4` | Pages of PRs to load from GitHub at a time, so each batch is `pageSize × pagesPerBatch` PRs. The minimum is `4`; lower values are raised to it. See [How PRs are loaded](#how-prs-are-loaded). |
228
+ | `refreshIntervalMs` | `60000` | How often the list refreshes while a session is open, in milliseconds. |
229
+ | `requestTimeoutMs` | `15000` | How long to wait for a GitHub request before giving up, in milliseconds. |
230
+ | `recentPRsLimit` | `5` | For `author` and `assignee` scopes, check up to this many newest repository PRs to fill search-index gaps. Set to `0` to disable; values above `100` are capped. |
231
+ | `defaultScope` | `"author"` | Scope filter at startup: `branch`, `author`, `assignee` or `all`. |
232
+ | `defaultStatusFilter` | `"open"` | Status filter at startup: `open`, `closed` or `all`. |
233
+ | `iconStyle` | `"nerd"` | Icon set: `"nerd"` for Nerd Font glyphs, or `"unicode"` for standard Unicode symbols that work in any font. See [Icons](#icons). |
234
+ | `colors` | Theme | Colour overrides. See [Colours](#colours). |
235
+ | `icons` | From `iconStyle` | Overrides for individual icons. See [Icons](#icons). |
236
+ | `spacing` | See below | Gaps, in terminal cells, between an indicator's icon and count, between same-type groups, and between comment/review/check types. Each gap is clamped to `0`–`4`. |
237
+ | `showSingleStatusCount` | `false` | Show counts for review and check badges even when there is only one status group. |
238
+
239
+ `spacing` accepts `iconToCount`, `sameTypeGroups` and `differentTypeGroups`. Its defaults are `0`, `0` and `1`,
240
+ respectively. For example, set `iconToCount` to `1` to put one cell between each status icon and its count.
241
+
242
+ Most numeric options must be positive numbers. `recentPRsLimit` accepts `0` through `100`, and spacing gaps accept
243
+ `0` through `4`; invalid values fall back to their defaults.
244
+
245
+ ### Colours
246
+
247
+ By default, colours come from your active OpenCode theme. Override any of them with a colour string such as
248
+ `"#a371f7"`:
249
+
250
+ | Key | Used for | Default theme token |
251
+ | --- | --- | --- |
252
+ | `panelAlt` | Background of each row's second line | Raised background |
253
+ | `text` | PR titles and the panel heading | Text |
254
+ | `muted` | Secondary text, neutral states | Muted text |
255
+ | `accent` | Hovered filters and page arrows | Primary action text |
256
+ | `success` | Passing checks, approvals, mergeable PRs, additions | Success text |
257
+ | `warning` | Pending checks, requested reviews, warnings | Warning text |
258
+ | `error` | Failing checks, requested changes, conflicts, deletions, errors | Error text |
259
+ | `draft` | Draft PR icon | Muted text |
260
+ | `merged` | Merged PR icon | Info text |
261
+
262
+ To show merged PRs in GitHub's purple instead of your theme's info colour, set `merged` to `"#a371f7"` (GitHub's dark
263
+ theme) or `"#8250df"` (GitHub's light theme). Colour and icon overrides go inside the plugin entry's `options` in
264
+ `cli.json`, next to the other options:
265
+
266
+ ```json
267
+ {
268
+ "$schema": "https://opencode.ai/v2/cli.json",
269
+ "plugins": [
270
+ {
271
+ "package": "opencode-github-pr",
272
+ "options": {
273
+ "colors": {
274
+ "merged": "#a371f7"
275
+ }
276
+ }
277
+ }
278
+ ]
279
+ }
280
+ ```
281
+
282
+ ### Icons
283
+
284
+ `iconStyle` picks the icon set. Nerd Font glyphs are the default; set `"unicode"` if your terminal font doesn't have
285
+ them. Set it in the matching plugin entry's `options` in `cli.json`:
286
+
287
+ ```json
288
+ {
289
+ "options": {
290
+ "iconStyle": "unicode"
291
+ }
292
+ }
293
+ ```
294
+
295
+ | Key | Nerd Font (default) | Unicode | Used for |
296
+ | --- | --- | --- | --- |
297
+ | `openPR` | `U+E726` | `•` | Open PRs |
298
+ | `closedPR` | `U+E726` | `•` | Closed PRs |
299
+ | `draftPR` | `U+E726` | `•` | Draft PRs |
300
+ | `mergedPR` | `U+E727` | `•` | Merged PRs |
301
+ | `review` | `U+F4FF` | `✓` | Review status |
302
+ | `openComment` | `U+F017A` | `■` | Unresolved review threads |
303
+ | `check` | `●` | `●` | CI check status |
304
+ | `scope` | `U+F4D7` | *(none)* | Icon before the filter labels |
305
+ | `loading` | `U+F051F` | `…` | Loading messages |
306
+ | `info` | `U+F129` | `ℹ` | Informational messages |
307
+ | `error` | `U+E654` | `⚠` | Error messages |
308
+ | `previousPage` | `U+EB6F` | `◀` | Previous page arrow |
309
+ | `nextPage` | `U+EB70` | `▶` | Next page arrow |
310
+
311
+ To change individual icons, set them in `icons`. These override the chosen style. An empty string hides an icon;
312
+ whitespace-only values are ignored.
313
+
314
+ #### Plain-text icons
315
+
316
+ If neither set suits your font, replace every icon with ASCII characters:
317
+
318
+ ```json
319
+ {
320
+ "options": {
321
+ "icons": {
322
+ "openPR": "o",
323
+ "closedPR": "c",
324
+ "draftPR": "d",
325
+ "mergedPR": "m",
326
+ "review": "R",
327
+ "openComment": "C",
328
+ "check": "*",
329
+ "scope": "@",
330
+ "loading": "...",
331
+ "info": "i",
332
+ "error": "!",
333
+ "previousPage": "<",
334
+ "nextPage": ">"
335
+ }
336
+ }
337
+ }
338
+ ```
339
+
340
+ ## GitHub Enterprise Server
341
+
342
+ Set `GITHUB_ENTERPRISE_URL` where the OpenCode server starts:
343
+
344
+ ```bash
345
+ export GITHUB_ENTERPRISE_URL="https://github.example.com"
346
+ ```
347
+
348
+ Use the server URL or its `/api/v3` URL; it must be HTTPS. The plugin then recognises remotes on that host, uses its
349
+ APIs, and asks `gh auth token` for that host's token. While it is set, github.com remotes aren't recognised. Leave it
350
+ unset for GitHub.com.
351
+
352
+ ## Troubleshooting
353
+
354
+ | You see | What to do |
355
+ | --- | --- |
356
+ | No **Pull Requests** panel | Check that the package is registered in `opencode.json` and that `enabled` isn't `false`, then reload OpenCode. If you installed from source, check that `bun install` has run in the clone. Plugin load errors are written to `~/.local/share/opencode/log/opencode.log`. |
357
+ | Plugin options or colour overrides have no effect | Put the options in the matching plugin entry in the global `~/.config/opencode/cli.json` (or `$XDG_CONFIG_HOME/opencode/cli.json`), not in `opencode.json`, then run `/reload` in the TUI. For a source install, the `package` path in `cli.json` must point to the same clone registered in `opencode.json`. |
358
+ | Icons show as boxes or question marks | Your terminal font doesn't have Nerd Font glyphs. Set `iconStyle` to `"unicode"`, install a Nerd Font, or use [plain-text icons](#plain-text-icons). |
359
+ | **No GitHub repo** | The session's directory isn't a Git repository with a GitHub remote. Add a remote, or open a session in the right project. For Enterprise, check `GITHUB_ENTERPRISE_URL`. |
360
+ | **GitHub sign-in failed** | No valid token was found. Run `gh auth login`, or set `GITHUB_TOKEN` where the OpenCode server starts. |
361
+ | **Permission denied** or **Repo not found** | Your token can't read this repository. Check its scopes or fine-grained permissions, and SSO authorisation for organisation repositories. |
362
+ | **Rate limit exceeded** | GitHub's API limit has been reached. The panel shows when you can try again. Raise `refreshIntervalMs` and avoid paging forward unnecessarily to use less quota. |
363
+ | **Request timed out** or **Cannot reach GitHub** | Check your connection or proxy. On slow networks, raise `requestTimeoutMs`. |
364
+ | **No matching PRs** | No PRs match the current filters. Click the scope or status label to widen them. Under `author` or `assignee`, a PR opened moments ago may not be in GitHub's search index yet; it appears on a later refresh. |
365
+ | **GitHub search is limited to 1,000 matching PRs** | The `author` and `assignee` filters use GitHub search, which returns at most 1,000 PRs. Switch the status filter to `open` or the scope to `all` to see older PRs. |
366
+ | `branch` scope is empty | The current branch has no PR, or the session is in detached HEAD. |
367
+
368
+ ## Releasing
369
+
370
+ Releases are published to npm by GitHub Actions after a GitHub Release is published. To make a release:
371
+
372
+ 1. Set the `version` in `package.json` to the release version and merge that change to `main`.
373
+ 2. Create and publish a GitHub Release with the matching `v`-prefixed tag (for example, package version `0.2.0` uses
374
+ tag `v0.2.0`).
375
+ 3. The release workflow verifies the tag and package version, runs the full CI suite, then publishes to npm with
376
+ provenance. Prereleases are not published. The archival `v0.1.0` release is tested but not republished because that
377
+ version already exists on npm.
378
+
379
+ The repository's npm package must be configured for **trusted publishing** on npmjs.com to use GitHub Actions as the
380
+ publisher, with repository `987poiuytrewq/opencode-github-pr`, workflow `release.yml`, and environment `npm`. The
381
+ workflow's `npm` environment can also be configured with required reviewers to gate publication.
382
+
383
+ ## Development
384
+
385
+ ```bash
386
+ bun install
387
+ make opencode
388
+ ```
389
+
390
+ `make opencode` starts OpenCode on this checkout with the plugin loaded from it, using a temporary config so your own
391
+ OpenCode config isn't changed. It uses `GH_TOKEN`, `GITHUB_TOKEN` or `GITHUB_PERSONAL_ACCESS_TOKEN` if set, otherwise
392
+ `gh auth token`.
393
+
394
+ ### Project layout
395
+
396
+ | Path | Contents |
397
+ | --- | --- |
398
+ | `plugins/pr-dashboard.ts` | Server part: plugin registration. |
399
+ | `plugins/pr-dashboard.tui.tsx` | TUI part: sidebar slot, commands and refresh scheduling. |
400
+ | `plugins/app/` | Solid UI components, options and theme handling. |
401
+ | `plugins/domain/` | Pure logic: filters, status rollups, formatting and messages. |
402
+ | `plugins/infra/` | Git remote detection, Octokit client and GitHub queries. |
403
+ | `tests/` | Unit, integration and end-to-end tests. |
404
+ | `demo/` | Demo recording script and fixtures. |
405
+
406
+ ### Tests
407
+
408
+ | Command | Runs |
409
+ | --- | --- |
410
+ | `make test` | Everything below. |
411
+ | `make format-check` | Formatting, and checks that the first JSON example in this README is strict JSON. |
412
+ | `make typecheck` | TypeScript. |
413
+ | `make test-unit` | Unit tests. |
414
+ | `make test-integration` | Integration tests. |
415
+ | `make test-e2e` | End-to-end tests against a real OpenCode TUI in tmux. |
416
+
417
+ The end-to-end tests need `tmux` and the OpenCode CLI. `make ci-tools` installs version `2.0.20` by default; override it
418
+ with `OPENCODE_VERSION` to install another version. To run against an already installed binary, use:
419
+
420
+ ```bash
421
+ make test-e2e OPENCODE_BIN=/path/to/opencode
422
+ ```
423
+
424
+ CI runs the full test suite against the latest stable patch from each current OpenCode V2 minor line: `2.0.32`,
425
+ `2.1.4`, `2.2.7` and `2.3.2`. OpenCode V1 and older patch releases are not covered by this matrix. Update the matrix
426
+ in `.github/workflows/ci.yml` as new V2 minor lines are released.
427
+
428
+ ### Recording the demo
429
+
430
+ ```bash
431
+ make demo
432
+ ```
433
+
434
+ This records the real OpenCode TUI with fictional PR data, then writes `demo/demo.cast` and `demo/demo.gif`. It needs
435
+ `asciinema`, `agg`, `tmux`, Bun and the OpenCode CLI. It runs in a temporary repository and home directory with GitHub
436
+ access turned off, so it doesn't touch your config or make network requests. Replay it with
437
+ `asciinema play demo/demo.cast`.
438
+
439
+ ## License
440
+
441
+ [MIT](LICENSE)
@@ -0,0 +1,224 @@
1
+ import {
2
+ DashboardStatus,
3
+ type DashboardState,
4
+ type PR,
5
+ } from "../plugins/domain/types";
6
+ import { filterPRs } from "../plugins/domain/pr-filters";
7
+
8
+ function demoPR(overrides: Partial<PR> & Pick<PR, "number" | "title">): PR {
9
+ const { number, title, ...values } = overrides;
10
+ return {
11
+ number,
12
+ title,
13
+ url: `https://github.com/acme/launchpad/pull/${number}`,
14
+ isDraft: false,
15
+ isMerged: false,
16
+ isClosed: values.isClosed ?? values.isMerged ?? false,
17
+ headRefName: "feature/demo",
18
+ authorLogin: "octocat",
19
+ assigneeLogins: ["octocat"],
20
+ additions: 64,
21
+ deletions: 18,
22
+ baseRefName: "main",
23
+ mergeable: "MERGEABLE",
24
+ mergeStateStatus: "CLEAN",
25
+ reviewDecision: null,
26
+ statusCheckRollup: { state: "SUCCESS" },
27
+ checkStatuses: ["SUCCESS"],
28
+ reviewThreads: [],
29
+ reviewRequests: [],
30
+ latestReviews: [],
31
+ ...values,
32
+ };
33
+ }
34
+
35
+ const demoPRs: PR[] = [
36
+ demoPR({
37
+ number: 248,
38
+ title: "Add passkey sign-in",
39
+ headRefName: "feature/passkeys",
40
+ additions: 128,
41
+ deletions: 36,
42
+ mergeStateStatus: "HAS_HOOKS",
43
+ reviewDecision: "APPROVED",
44
+ reviewRequests: [
45
+ { type: "user", login: "alex" },
46
+ { type: "team", slug: "platform" },
47
+ ],
48
+ reviewThreads: [{ isResolved: true }],
49
+ latestReviews: [{ author: { login: "samantha" }, state: "APPROVED" }],
50
+ }),
51
+ demoPR({
52
+ number: 247,
53
+ title: "Retry expired sessions",
54
+ additions: 86,
55
+ deletions: 14,
56
+ assigneeLogins: ["mia"],
57
+ mergeStateStatus: "BLOCKED",
58
+ reviewDecision: "REVIEW_REQUIRED",
59
+ statusCheckRollup: { state: "FAILURE" },
60
+ checkStatuses: ["SUCCESS", "FAILURE"],
61
+ reviewRequests: [
62
+ { type: "user", login: "alex" },
63
+ { type: "user", login: "mia" },
64
+ { type: "team", slug: "release-engineering" },
65
+ ],
66
+ reviewThreads: [{ isResolved: false }, { isResolved: true }],
67
+ latestReviews: [{ author: { login: "jules" }, state: "COMMENTED" }],
68
+ }),
69
+ demoPR({
70
+ number: 246,
71
+ title: "Add audit log filters",
72
+ additions: 52,
73
+ deletions: 21,
74
+ headRefName: "feature/audit-filters",
75
+ mergeStateStatus: "BEHIND",
76
+ statusCheckRollup: { state: "PENDING" },
77
+ checkStatuses: ["SUCCESS", "IN_PROGRESS"],
78
+ reviewRequests: [{ type: "team", slug: "design-systems" }],
79
+ latestReviews: [{ author: { login: "jules" }, state: "COMMENTED" }],
80
+ }),
81
+ demoPR({
82
+ number: 245,
83
+ title: "Improve keyboard navigation",
84
+ additions: 41,
85
+ deletions: 11,
86
+ assigneeLogins: ["mia"],
87
+ mergeStateStatus: "UNSTABLE",
88
+ reviewDecision: "CHANGES_REQUESTED",
89
+ reviewRequests: [{ type: "user", login: "alex" }],
90
+ latestReviews: [
91
+ { author: { login: "samantha" }, state: "CHANGES_REQUESTED" },
92
+ ],
93
+ }),
94
+ demoPR({
95
+ number: 244,
96
+ title: "Cache organization membership",
97
+ additions: 23,
98
+ deletions: 6,
99
+ statusCheckRollup: { state: "PENDING" },
100
+ checkStatuses: ["QUEUED"],
101
+ reviewRequests: [
102
+ { type: "user", login: "mia" },
103
+ { type: "user", login: "jules" },
104
+ { type: "team", slug: "docs" },
105
+ ],
106
+ latestReviews: [
107
+ { author: { login: "samantha" }, state: "APPROVED" },
108
+ { author: { login: "jules" }, state: "APPROVED" },
109
+ ],
110
+ }),
111
+ demoPR({
112
+ number: 243,
113
+ title: "Add CLI configuration hints",
114
+ additions: 31,
115
+ deletions: 9,
116
+ assigneeLogins: ["mia"],
117
+ }),
118
+ demoPR({
119
+ number: 242,
120
+ title: "Simplify session settings",
121
+ additions: 17,
122
+ deletions: 22,
123
+ isDraft: true,
124
+ mergeable: "CONFLICTING",
125
+ statusCheckRollup: { state: "FAILURE" },
126
+ checkStatuses: ["FAILURE"],
127
+ assigneeLogins: ["octocat"],
128
+ }),
129
+ demoPR({
130
+ number: 241,
131
+ title: "Add workspace export",
132
+ additions: 74,
133
+ deletions: 13,
134
+ headRefName: "feature/workspace-export",
135
+ authorLogin: "octocat",
136
+ assigneeLogins: ["samantha"],
137
+ statusCheckRollup: { state: "PENDING" },
138
+ checkStatuses: ["SUCCESS", "EXPECTED"],
139
+ }),
140
+ demoPR({
141
+ number: 240,
142
+ title: "Fix landing page contrast",
143
+ additions: 12,
144
+ deletions: 7,
145
+ authorLogin: "mia",
146
+ assigneeLogins: ["octocat"],
147
+ }),
148
+ demoPR({
149
+ number: 239,
150
+ title: "Prepare the v2.4 release",
151
+ additions: 104,
152
+ deletions: 28,
153
+ isMerged: true,
154
+ isClosed: true,
155
+ latestReviews: [{ author: { login: "samantha" }, state: "APPROVED" }],
156
+ }),
157
+ demoPR({
158
+ number: 238,
159
+ title: "Remove legacy auth fallback",
160
+ additions: 9,
161
+ deletions: 33,
162
+ authorLogin: "jules",
163
+ assigneeLogins: ["octocat"],
164
+ isClosed: true,
165
+ mergeable: "CONFLICTING",
166
+ statusCheckRollup: { state: "FAILURE" },
167
+ checkStatuses: ["FAILURE"],
168
+ }),
169
+ demoPR({
170
+ number: 237,
171
+ title: "Streamline onboarding",
172
+ additions: 65,
173
+ deletions: 4,
174
+ isMerged: true,
175
+ isClosed: true,
176
+ latestReviews: [{ author: { login: "mia" }, state: "APPROVED" }],
177
+ }),
178
+ ];
179
+
180
+ export function demoDashboardState(): DashboardState {
181
+ return {
182
+ status: DashboardStatus.Ok,
183
+ repo: { owner: "acme", repo: "launchpad" },
184
+ prs: demoPRs.map((pr) => ({
185
+ ...pr,
186
+ assigneeLogins: [...pr.assigneeLogins],
187
+ checkStatuses: pr.checkStatuses ? [...pr.checkStatuses] : null,
188
+ reviewThreads: pr.reviewThreads
189
+ ? pr.reviewThreads.map((thread) => ({ ...thread }))
190
+ : null,
191
+ reviewRequests: pr.reviewRequests
192
+ ? pr.reviewRequests.map((request) => ({ ...request }))
193
+ : null,
194
+ latestReviews: pr.latestReviews
195
+ ? pr.latestReviews.map((review) => ({
196
+ ...review,
197
+ author: { ...review.author },
198
+ }))
199
+ : null,
200
+ })),
201
+ currentBranch: "feature/passkeys",
202
+ viewerLogin: "octocat",
203
+ fetchedAt: 0,
204
+ pagination: {
205
+ listing: "open",
206
+ scope: "author",
207
+ scopeValue: null,
208
+ cursor: null,
209
+ hasMore: false,
210
+ totalCount: filterPRs(
211
+ demoPRs,
212
+ "author",
213
+ "open",
214
+ "feature/passkeys",
215
+ "octocat",
216
+ ).length,
217
+ pagesLoaded: 1,
218
+ searchResultsFetched: 0,
219
+ supplementalPRCount: 0,
220
+ loading: false,
221
+ limitReached: false,
222
+ },
223
+ };
224
+ }