Compare commits

...
Author SHA1 Message Date
Brent Vatne 1960e5a886 Pin eas-cli 25.0.0, and start Explore's sessions with a public preview link
eas-cli 25 makes simulator sessions private by default and leaves the preview
token out of `simulator:get --json` for them. Explore reads the OS version from
the session's preview server with that token, so a private session would record
it as unknown.

- Pin eas-cli 25.0.0 (EAS_CLI_VERSION follows).
- Start the sessions Explore owns (capture and explore:binary) with
  --public-link, so the token is published.
- Read the token from previewApiUrl (eas-cli 25), from the expo.dev page's
  fragment, or from webPreviewUrl's query (earlier versions).
- Redact previewApiUrl in start failures.
2026-10-16 14:26:22 -07:00
Brent Vatne e3afc2a00c README: one place for local reviews, a framed hero, and a table of what you get
- Merge "Review a change before you push it" into the Quick start: the reports
  picker and the details of a local review now live there.
- Replace "What you get" with a row of three pictures under the hero (Compare,
  Screens, the PR comment), with the agent prompt collapsed beneath; Terms and
  How agents read a report move to Additional information.
- The hero is the Map zoomed in on the selected screen and framed as a window on
  a soft stage (readme-screenshots.mjs: stagedWindow, --zoom).
- Regenerate every screenshot from the euxy #157 fixtures, with the new Screens
  grid, and update the readme-refresh skill to this layout.
2026-10-16 13:08:35 -07:00
Brent Vatne a60ae5c6d8 Release 0.19.5 2026-10-16 12:39:06 -07:00
Brent Vatne d26e65db47 Add a README quick start, and run local reviews with no setup
- README: a Quick start of two steps (make the app buildable on EAS, then
  `npx @expo/explore capture`), with a prompt to paste into Claude Code or Codex.
- `capture` is a one-word name for `capture:review`.
- A local review reviews the working tree by default, untracked files included,
  as `eas build` uploads it. `--committed` reviews HEAD alone, and an eas.json
  with `cli.requireCommit: true` leaves uncommitted changes out, as eas build does.
- Without `.expo-explore/config.yaml`, a local review uses the config `setup`
  would write (or an uncommitted one in the checkout), so it works before setup.
- setup prefers a simulator profile named `explore` when there are several.
2026-10-16 12:36:38 -07:00
Brent Vatne 47f37988a5 Release 0.19.4 2026-10-15 23:06:16 -07:00
Brent Vatne 1a5a95af63 Show Screens as one grid of screen cards, with arrow-key stepping and ⌃1/2/3 (#4) 2026-10-15 23:06:09 -07:00
45 changed files with 860 additions and 244 deletions

No files matched your search

+116 -86
View File
@@ -4,11 +4,52 @@ Explore maps your app: a screenshot of every screen, connected by the taps betwe
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-hero-dark.png">
<img alt="Explore's Map of the euxy app with the new About screen selected: every screen as a card laid out by distance from the launch screen, and the Inspector on the right showing the About capture as an added screen with its transitions" src="docs/screenshots/readme-hero-light.png">
<img alt="Explore's Map of a euxy pull request, zoomed in on the new About screen, marked Added among the modified Patterns screens, with its transitions highlighted and the Inspector open on it, shown as a window on a soft stage" src="docs/screenshots/readme-hero-light.png">
</picture>
**See a real report:** [euxy](https://explore-example--euxy.expo.app/p/rfcoic27ccgnrmzgijubxkmuzmptcrva?platform=ios), a MIDI sequencer, reviewed by Explore. It is redeployed with the current Viewer on every merge to main.
<table>
<tr>
<td width="33%" valign="top">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-compare-dark.png">
<img width="100%" alt="The Compare view with the euxy Patterns screen's before and after captures side by side: each pattern row's tempo moved out of the subtitle into its own column on the right, the changed subtitles outlined in both" src="docs/screenshots/readme-compare-light.png">
</picture>
<strong>Compare</strong>: each changed screen before and after, with the changed regions outlined.
</td>
<td width="33%" valign="top">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-screens-dark.png">
<img width="100%" alt="The Screens view of a euxy review: the app/ route tree on the left under Changed 9 and All 19, and a grid of screen cards beside it in the same order, each with its route below the screenshot and a dot before it: green for the new /about, orange for modified screens such as /activity-log, /settings and /patterns, red for the removed /channel-surf" src="docs/screenshots/readme-screens-light.png">
</picture>
<strong>Screens</strong>: every capture in one grid, beside the route tree, with a dot for what changed.
</td>
<td width="33%" valign="top">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-pr-comment-dark.png">
<img width="100%" alt="Explore's GitHub PR comment on a euxy PR: the heading links to the iOS and Android reports, a table with one row per platform giving device, result and an Open link, the Added, Removed, Modified, Needs review and Source-affected screens as collapsed lists, fading out below them" src="docs/screenshots/readme-pr-comment-light.png">
</picture>
<strong>A comment on every PR</strong>: with <a href="#set-up-ci">CI</a>, the report links and the added, removed and modified screens.
</td>
</tr>
</table>
<details>
<summary><strong>Ask an agent about a report</strong></summary>
Paste this into Claude Code, Codex, Cursor, or any tool that can fetch a URL. In the Viewer, **Hand off to AI** fills it in for you:
```text
Review the visual changes in this PR. Expo Explore report: <report link>
Fetch the link first. It explains the report's JSON API. Go through the changed screens,
compare the before and after screenshots, and tell me which changes look intended and
which look like regressions. For each regression, name the source file to fix.
```
</details>
<details>
<summary><strong>Requirements</strong></summary>
@@ -20,9 +61,75 @@ Explore maps your app: a screenshot of every screen, connected by the taps betwe
</details>
## Try it on your app
## Quick start
Paste this into Claude Code or Codex from your app's directory. It explores a build you point to, or an Expo project straight from its source:
Review a change to your own app, on your machine. You need an Expo SDK 57+ app with Expo Router or React Navigation, Node.js 24.12+, and EAS Simulator access ([join the waitlist](https://expo.dev/services/simulators)). No API keys, no CI.
From your app's directory:
1. **Make the app buildable on EAS, if it is not yet.**
```sh
npx eas-cli@latest login
npx eas-cli@latest init
```
Then set `ios.bundleIdentifier` in your app config, add a simulator profile to `eas.json`, and commit. The review builds your last commit as the "before".
```json
{ "build": { "explore": { "ios": { "simulator": true } } } }
```
2. **Change a screen, then review the change.** Edit some text near the top of a screen (Explore captures the first screenful) and run:
```sh
npx @expo/explore capture
```
Explore builds your last commit and your uncommitted changes on EAS, captures the screens the changes can affect, before and after, on EAS Simulator, and opens the report in your browser. The first run waits for an EAS build; later runs reuse it while your native code is unchanged.
Or paste this into Claude Code or Codex from your app's directory:
```text
Show me an Expo Explore review of a change to this app. Follow the "Review a change on
this machine" section of https://unpkg.com/@expo/explore/skills/explore-setup/SKILL.md.
If the app cannot build for the iOS Simulator on EAS yet, set that up (an EAS project,
ios.bundleIdentifier, an "explore" profile with ios.simulator: true) and ask me before
you commit it. If I have no uncommitted changes, change some text near the top of a
screen. Then run npx @expo/explore capture and open the report.
```
Every run is kept on your machine for 30 days. `npx @expo/explore reports` lists your local reviews, explorations and uploaded reports with their commits, and reopens or hosts one without capturing again:
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-reports-dark.png">
<img alt="npx @expo/explore reports in a terminal: the Expo Explore wordmark, then one line per saved run (a local review of HEAD vs main selected, an exploration of an app, and PR #1), and below them the selected run's head and base commits with their messages and its 13 modified, 2 added, 2 removed and 17 need-review screens" src="docs/screenshots/readme-reports-light.png">
</picture>
<details>
<summary><strong>Other commits, and what a review does</strong></summary>
```sh
npx @expo/explore capture # HEAD and your uncommitted changes, against where HEAD left the default branch
npx @expo/explore capture --committed # HEAD alone
npx @expo/explore capture --base v1.3.0 --head v1.4.0 --scope all --upload
```
- It checks out both commits as temporary worktrees, installs their dependencies, captures every configured platform on EAS Simulator (`--platform` picks one), and opens the report in a local Viewer. `--upload` hosts it and prints the link; `report:upload <report.zip>` hosts one you already have.
- Your checkout, index and branches are never touched. Your uncommitted changes, untracked files included, are reviewed as `eas build` would upload them; `--committed`, or `cli.requireCommit: true` in `eas.json`, leaves them out.
- It runs both commits' code on your machine, as you: installing their dependencies, evaluating the app config, and bundling the JavaScript. That is what checking them out and running them would do, so review only commits you would run, and someone else's branch only if you trust it.
- Installs run without credential environment variables, which keeps tokens out of reach of a registry a commit's `.npmrc` names; that is not a sandbox. A registry that needs `${NPM_TOKEN}` in the project's `.npmrc` must be authenticated in your own `~/.npmrc`.
- Captures are cached in `~/.cache/expo-explore`, so the same base is not captured twice (`--no-cache` skips it); a capture unused for 30 days goes, and the cache stays under 2 GB. Ctrl+C stops the run's simulator sessions.
- Like a CI review, it builds on EAS (reusing a matching build) and runs simulator sessions: expect several minutes and EAS usage.
- Saved runs take up to 2 GB in all, the oldest going first. `reports add <report.zip>` keeps a report you downloaded, such as a PR's `explore-review` artifact.
</details>
Explore uses its defaults until you run `npx @expo/explore setup`, which writes `.expo-explore/config.yaml` for you to change. Next: [review every pull request](#set-up-ci).
## Map every screen of any app
To map every screen of an app instead, with no config, paste this into Claude Code or Codex from your app's directory. It explores a build you point to, or an Expo project straight from its source:
```text
Show me Expo Explore working on this app. Follow
@@ -87,42 +194,6 @@ One card per screen the run reached, laid out by how many taps it took, with the
</details>
### Review a change before you push it
Once Explore is [set up](#set-up-ci) (`.expo-explore/config.yaml` committed), the review a PR gets also runs on your machine, between any two commits. No tokens or keys to set: it uses your `eas login` and your Claude Code or Codex login.
```text
Review my current changes with Expo Explore. Follow the "Review a change on this machine"
section of https://unpkg.com/@expo/explore/skills/explore-setup/SKILL.md, compare my
branch (with my uncommitted changes) against main, and open the report.
```
Every run is kept on your machine for 30 days. `npx @expo/explore reports` lists your local reviews, explorations and uploaded reports with their commits, and reopens or hosts one without capturing again:
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-reports-dark.png">
<img alt="npx @expo/explore reports in a terminal: the Expo Explore wordmark, then one line per saved run (a local review of HEAD vs main selected, an exploration of an app, and PR #1), and below them the selected run's head and base commits with their messages and its 13 modified, 2 added, 2 removed and 17 need-review screens" src="docs/screenshots/readme-reports-light.png">
</picture>
<details>
<summary><strong>Run it yourself</strong></summary>
```sh
npx @expo/explore capture:review # HEAD against where it left the default branch
npx @expo/explore capture:review --uncommitted # your uncommitted changes too
npx @expo/explore capture:review --base v1.3.0 --head v1.4.0 --scope all --upload
```
- It checks out both commits as temporary worktrees, installs their dependencies, captures every configured platform on EAS Simulator (`--platform` picks one), and opens the report in a local Viewer. `--upload` hosts it and prints the link; `report:upload <report.zip>` hosts one you already have.
- Your checkout, index and branches are never touched. `--uncommitted` takes tracked changes only; `--include-untracked` adds untracked files, which are uploaded with the EAS build.
- It runs both commits' code on your machine, as you: installing their dependencies, evaluating the app config, and bundling the JavaScript. That is what checking them out and running them would do, so review only commits you would run, and someone else's branch only if you trust it.
- Installs run without credential environment variables, which keeps tokens out of reach of a registry a commit's `.npmrc` names; that is not a sandbox. A registry that needs `${NPM_TOKEN}` in the project's `.npmrc` must be authenticated in your own `~/.npmrc`.
- Captures are cached in `~/.cache/expo-explore`, so the same base is not captured twice (`--no-cache` skips it); a capture unused for 30 days goes, and the cache stays under 2 GB. Ctrl+C stops the run's simulator sessions.
- Like a CI review, it builds on EAS (reusing a matching build) and runs simulator sessions: expect several minutes and EAS usage.
- Saved runs take up to 2 GB in all, the oldest going first. `reports add <report.zip>` keeps a report you downloaded, such as a PR's `explore-review` artifact.
</details>
## Set up CI
Explore runs in your repository's GitHub Actions in two ways, both from the same setup: a review on every pull request, and a comparison of any two commits, such as a release against the last one.
@@ -154,8 +225,8 @@ report:
```
- Run `expo-explore setup --workflows` after enabling it to add the `deploy` job.
- A [comparison of two commits](#compare-any-two-commits) links its hosted report from the run's summary instead of a PR comment. `capture:review --upload` on your machine deploys to the same project with your `eas login`.
- `expo-explore report:upload <report.zip>...` hosts reports already on your machine the same way: a review's reports (one per platform, from `capture:review --output` or a downloaded `explore-review` artifact) or an `explore:binary` report.
- A [comparison of two commits](#compare-any-two-commits) links its hosted report from the run's summary instead of a PR comment. `capture --upload` on your machine deploys to the same project with your `eas login`.
- `expo-explore report:upload <report.zip>...` hosts reports already on your machine the same way: a review's reports (one per platform, from `capture --output` or a downloaded `explore-review` artifact) or an `explore:binary` report.
- `EXPO_TOKEN` must be able to create the EAS project, so use a [robot user's](https://docs.expo.dev/accounts/programmatic-access/) token.
- The report is encrypted, and only a request carrying the link's token can open it. Treat the link like a shared file link; see [report access](docs/private-review.md#hosted-previews).
@@ -172,7 +243,7 @@ The prompt above walks through these steps with you. To do them yourself:
- `EXPO_TOKEN`: create it in [Expo access tokens](https://expo.dev/settings/access-tokens). For [hosted previews](#hosted-previews), use a [robot user](https://docs.expo.dev/accounts/programmatic-access/) that can create projects.
- A secret for each `{{secret:NAME}}` in your setup steps. Run `npx @expo/explore setup --workflows` after you add one.
4. Commit, merge to the default branch, and run **Expo Explore baseline** from GitHub Actions.
5. Open a PR. **Expo Explore review** runs and posts a comment with the report. To see a whole review of your branch first, run `npx @expo/explore capture:review` on your machine.
5. Open a PR. **Expo Explore review** runs and posts a comment with the report. To see a whole review of your branch first, run `npx @expo/explore capture` on your machine.
A failed run shows an error code and a next action in the PR comment; see [CI troubleshooting](docs/quickstart-ci.md#diagnose-a-failed-run).
@@ -252,7 +323,7 @@ There are a few ways to snapshot a release:
- **On demand:** in your repository's Actions tab, open **Expo Explore compare**, choose **Run workflow**, and set `base` to the last release's tag (`v1.3.0`), `head` to the new tag or release candidate (`v1.4.0-rc.1`), `scope` to `all` and `expires-in` to `never`. The run's summary links the report.
- **Automatically, on every tag:** add the `release-review.yml` in [The comparison workflow](#compare) below. It compares each tag, release candidates included, with the last stable tag, so a release candidate is reviewed against what people have now.
- **On your machine, without CI:** `npx @expo/explore capture:review --base v1.3.0 --head v1.4.0 --scope all --upload`, with your `eas login`. `npx @expo/explore reports` lists the runs you have kept.
- **On your machine, without CI:** `npx @expo/explore capture --base v1.3.0 --head v1.4.0 --scope all --upload`, with your `eas login`. `npx @expo/explore reports` lists the runs you have kept.
`scope: all` captures every screen, not only those whose source changed, so the report shows the whole release with what changed since the last one marked; `expires-in: never` keeps its link.
@@ -329,46 +400,7 @@ If the sign-in can't be typed (one-time codes, email links, Sign in with Apple o
When a run stops early, `gap:list --dir <output>` says what blocked it.
## What you get
### A comment on every PR
The report links, a row per platform, and the added, removed and modified screens.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-pr-comment-dark.png">
<img alt="Explore's GitHub PR comment on a euxy PR: the heading links to the iOS and Android reports, a table with one row per platform giving device, result and an Open link, the Added, Removed, Modified, Needs review and Source-affected screens as collapsed lists, fading out below them" src="docs/screenshots/readme-pr-comment-light.png">
</picture>
### Compare
Each changed screen before and after, with the changed regions outlined.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-compare-dark.png">
<img alt="The Compare view with the euxy Patterns screen's before and after captures side by side: each pattern row's tempo moved out of the subtitle into its own column on the right, the changed subtitles outlined in both" src="docs/screenshots/readme-compare-light.png">
</picture>
### Screens
Every capture, in a section per route folder, with a route tree whose folders fold away and a **Changed** / **All** filter.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-screens-dark.png">
<img alt="The Screens view of a euxy review: a foldable route tree on the left with Changed and All above it, and the screens in sections named after their app/ folder (Launch, Sequencer, Settings, Patterns) with each folder path beneath, the new About screen marked Added, Activity Log and Settings marked Modified, and the Sequencer marked No visible change" src="docs/screenshots/readme-screens-light.png">
</picture>
### Ask an agent about it
Paste this into Claude Code, Codex, Cursor, or any tool that can fetch a URL. In the Viewer, **Hand off to AI** fills it in for you:
```text
Review the visual changes in this PR. Expo Explore report: <report link>
Fetch the link first. It explains the report's JSON API. Go through the changed screens,
compare the before and after screenshots, and tell me which changes look intended and
which look like regressions. For each regression, name the source file to fix.
```
## Additional information
<details>
<summary><strong>Terms in the report</strong></summary>
@@ -397,8 +429,6 @@ curl -s "$LINK/api/v1/screens?status=modified" | jq '.items[] | {route, status,
</details>
## Additional information
<details>
<summary><strong>How it works</strong></summary>
@@ -408,7 +438,7 @@ curl -s "$LINK/api/v1/screens?status=modified" | jq '.items[] | {route, status,
4. It compares the captures. A screen with a source change is **Modified** if its captures differ.
5. It uploads the report to GitHub Actions and posts a PR comment.
The same review runs for any two commits without a PR ([`explore-compare.yml`](#compare-any-two-commits), linking the report from the run summary) and on your machine (`capture:review`, [above](#review-a-change-before-you-push-it)). The workflows' logic lives in `expo-explore ci:*` commands, so a fix reaches CI with the `@expo/explore` version the workflows pin.
The same review runs for any two commits without a PR ([`explore-compare.yml`](#compare-any-two-commits), linking the report from the run summary) and on your machine (`capture`, [above](#quick-start)). The workflows' logic lives in `expo-explore ci:*` commands, so a fix reaches CI with the `@expo/explore` version the workflows pin.
Reports and baselines are kept for 30 days and diagnostics for 7. Hosted deployments are never deleted automatically; see [report access](docs/private-review.md).
Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 KiB

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 KiB

After

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 870 KiB

After

Width:  |  Height:  |  Size: 847 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 KiB

After

Width:  |  Height:  |  Size: 830 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 KiB

After

Width:  |  Height:  |  Size: 642 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 606 KiB

After

Width:  |  Height:  |  Size: 643 KiB

+61 -63
View File
@@ -1,12 +1,12 @@
{
"name": "@expo/explore",
"version": "0.19.3",
"version": "0.19.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@expo/explore",
"version": "0.19.3",
"version": "0.19.5",
"license": "MIT",
"dependencies": {
"@expo/repack-app": "0.10.1",
@@ -14,6 +14,7 @@
"@zip.js/zip.js": "2.16.0",
"agent-device": "0.21.15",
"ajv": "^8.17.1",
"eas-cli": "25.0.0",
"pngjs": "7.0.0",
"typescript": "^5.9.3",
"yaml": "^2.9.0",
@@ -48,7 +49,7 @@
"optionalDependencies": {
"@anthropic-ai/claude-agent-sdk": "0.3.285",
"@openai/codex": "0.159.2",
"eas-cli": "24.4.2"
"eas-cli": "25.0.0"
}
},
"node_modules/@0no-co/graphql.web": {
@@ -1600,15 +1601,15 @@
}
},
"node_modules/@expo/eas-build-job": {
"version": "24.3.0",
"resolved": "https://registry.npmjs.org/@expo/eas-build-job/-/eas-build-job-24.3.0.tgz",
"integrity": "sha512-CyDUm8B8pSH38XZg8QzdPaxukThspSWfJ4ccUBCzBLs/qL6SknaLVswD3OTxNQmirrZUyo72DfzupSxHDZOeyw==",
"version": "25.0.0",
"resolved": "https://registry.npmjs.org/@expo/eas-build-job/-/eas-build-job-25.0.0.tgz",
"integrity": "sha512-Vuai42tVopKuK2KFyTWUsW9cL1YMY1dWhFAKz+evUV5AKaMCk4dYxOYZ6tBWNhIJ15bGK3p4N0YUomlAqubFWg==",
"license": "MIT",
"optional": true,
"dependencies": {
"@expo/logger": "24.0.0",
"@expo/logger": "25.0.0",
"@expo/results": "1.0.0",
"@expo/turtle-spawn": "24.0.0",
"@expo/turtle-spawn": "25.0.0",
"joi": "^17.13.1",
"semver": "^7.6.2",
"zod": "^4.3.5"
@@ -1642,14 +1643,14 @@
}
},
"node_modules/@expo/eas-json": {
"version": "24.3.0",
"resolved": "https://registry.npmjs.org/@expo/eas-json/-/eas-json-24.3.0.tgz",
"integrity": "sha512-FIdvHmGeRFB0BoA4+aicn/tnpUUTSre4cCrN/hk6xkHOlpbjDVyl2tFaEe0RpiI1itrQ2ze/KTUYqdyecfHv0Q==",
"version": "25.0.0",
"resolved": "https://registry.npmjs.org/@expo/eas-json/-/eas-json-25.0.0.tgz",
"integrity": "sha512-ilPw4O0Lnce/6lbu1GPwega8KF2GqTio9vuNFjNaGL78pfxz7GdktBsJ9JRaGtiM0LYdPa09W2FYb7DcMY8xWA==",
"license": "MIT",
"optional": true,
"dependencies": {
"@babel/code-frame": "7.23.5",
"@expo/eas-build-job": "24.3.0",
"@expo/eas-build-job": "25.0.0",
"chalk": "4.1.2",
"env-string": "1.0.1",
"fs-extra": "11.2.0",
@@ -1900,9 +1901,9 @@
}
},
"node_modules/@expo/logger": {
"version": "24.0.0",
"resolved": "https://registry.npmjs.org/@expo/logger/-/logger-24.0.0.tgz",
"integrity": "sha512-LezHQbZbqa7papq2ciCmwEjz4gUxe3b4oIdl3IU/wp3WGy+zQ4s+xKdDuUCbDLVkbqABBgVNqFav4ucXo1Gh/w==",
"version": "25.0.0",
"resolved": "https://registry.npmjs.org/@expo/logger/-/logger-25.0.0.tgz",
"integrity": "sha512-KcNOYmeJH8GESYEjbiewg+LU98XH/yBs368XlPqmEHVZekkbOONpIzPd5AFcFRWO1BW0c2nl/58BUI876UFT8A==",
"license": "BUSL-1.1",
"optional": true,
"dependencies": {
@@ -2592,14 +2593,14 @@
}
},
"node_modules/@expo/steps": {
"version": "24.3.0",
"resolved": "https://registry.npmjs.org/@expo/steps/-/steps-24.3.0.tgz",
"integrity": "sha512-y0zuyUaivXiq1l7D0x9xosUbhtknDwQ4v669smGslshEYXZAuxYQJo0L6H0MRuRsaZn6N8zvfICBM+4n/n4Xeg==",
"version": "25.0.0",
"resolved": "https://registry.npmjs.org/@expo/steps/-/steps-25.0.0.tgz",
"integrity": "sha512-+o04mm5akQJRX0j9TwwkdZiuNM9swLxw9DsDPtFhbWceg95gky/vc/0qF200kjZL4DEMfd/WhzngBW9aqJ0JQg==",
"license": "BUSL-1.1",
"optional": true,
"dependencies": {
"@expo/eas-build-job": "24.3.0",
"@expo/logger": "24.0.0",
"@expo/eas-build-job": "25.0.0",
"@expo/logger": "25.0.0",
"@expo/spawn-async": "^1.7.2",
"arg": "^5.0.2",
"fast-glob": "^3.3.2",
@@ -2637,13 +2638,13 @@
"optional": true
},
"node_modules/@expo/turtle-spawn": {
"version": "24.0.0",
"resolved": "https://registry.npmjs.org/@expo/turtle-spawn/-/turtle-spawn-24.0.0.tgz",
"integrity": "sha512-HtumnPY7iVCc6vDmSmjsUEvhIPnmwVzpQ2aNPxAX+G0M2Zst88DAlItOd7mZUPSNNO8qp3izDPtqmI0fdLYPng==",
"version": "25.0.0",
"resolved": "https://registry.npmjs.org/@expo/turtle-spawn/-/turtle-spawn-25.0.0.tgz",
"integrity": "sha512-XBQZ2azxh0IWozO5hCxIJt150LjIGbk6VZakeyA6UXPHp1ESenm97o0JIHOvzQNOgBV481muV88KmIWHGt0yIA==",
"license": "BUSL-1.1",
"optional": true,
"dependencies": {
"@expo/logger": "24.0.0",
"@expo/logger": "25.0.0",
"@expo/spawn-async": "^1.7.2"
}
},
@@ -4556,6 +4557,16 @@
"node": ">=0.4.0"
}
},
"node_modules/agent-base": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
"integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">= 14"
}
},
"node_modules/agent-cli-detector": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/agent-cli-detector/-/agent-cli-detector-0.1.7.tgz",
@@ -5711,9 +5722,9 @@
}
},
"node_modules/eas-cli": {
"version": "24.4.2",
"resolved": "https://registry.npmjs.org/eas-cli/-/eas-cli-24.4.2.tgz",
"integrity": "sha512-7tXqvzZ+4hRBS9p8Voo0PB2Ruapvqc9LLn99ZSw5m2VOQITAxdNhj8PcF+RAV3by7lMGT0oFotP7+/v3FDjpyg==",
"version": "25.0.0",
"resolved": "https://registry.npmjs.org/eas-cli/-/eas-cli-25.0.0.tgz",
"integrity": "sha512-FBY3pIo/3L0s+8KK5ZpMKzlLrA5jOmr5kOpoOwkAXsxMrI4vo+LNoEsciRcOxjce9efc08GqEEPc/CxLRAWIvA==",
"license": "MIT",
"optional": true,
"dependencies": {
@@ -5721,11 +5732,11 @@
"@expo/code-signing-certificates": "0.0.5",
"@expo/config": "55.0.10",
"@expo/config-plugins": "55.0.7",
"@expo/eas-build-job": "24.3.0",
"@expo/eas-json": "24.3.0",
"@expo/eas-build-job": "25.0.0",
"@expo/eas-json": "25.0.0",
"@expo/env": "^1.0.0",
"@expo/json-file": "8.3.3",
"@expo/logger": "24.0.0",
"@expo/logger": "25.0.0",
"@expo/multipart-body-parser": "2.0.0",
"@expo/osascript": "2.1.4",
"@expo/package-manager": "1.9.10",
@@ -5737,7 +5748,7 @@
"@expo/results": "1.0.0",
"@expo/rudder-sdk-node": "1.1.1",
"@expo/spawn-async": "1.7.2",
"@expo/steps": "24.3.0",
"@expo/steps": "25.0.0",
"@expo/timeago.js": "1.0.0",
"@oclif/core": "^4.8.3",
"@oclif/plugin-autocomplete": "^3.2.40",
@@ -5768,7 +5779,7 @@
"gradle-to-js": "2.0.1",
"graphql": "16.8.1",
"graphql-tag": "2.12.6",
"https-proxy-agent": "5.0.1",
"https-proxy-agent": "7.0.6",
"ignore": "5.3.0",
"indent-string": "4.0.0",
"invariant": "^2.2.2",
@@ -5817,19 +5828,6 @@
"node": "^20.18.3 || >=22.0.0"
}
},
"node_modules/eas-cli/node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"license": "MIT",
"optional": true,
"dependencies": {
"debug": "4"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/eas-cli/node_modules/ajv": {
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz",
@@ -5847,20 +5845,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/eas-cli/node_modules/https-proxy-agent": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
"license": "MIT",
"optional": true,
"dependencies": {
"agent-base": "6",
"debug": "4"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/eas-cli/node_modules/ignore": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz",
@@ -7399,6 +7383,20 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/https-proxy-agent": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
"license": "MIT",
"optional": true,
"dependencies": {
"agent-base": "^7.1.2",
"debug": "4"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/hyperlinker": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/hyperlinker/-/hyperlinker-1.0.0.tgz",
@@ -7808,13 +7806,13 @@
}
},
"node_modules/jsep": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/jsep/-/jsep-1.4.0.tgz",
"integrity": "sha512-B7qPcEVE3NVkmSJbaYxvv4cHkVW7DQsZz13pUMrfS8z8Q/BuShN+gcTXrUlPiGqM2/t/EEaI030bpxMqY8gMlw==",
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/jsep/-/jsep-1.6.0.tgz",
"integrity": "sha512-Y8Tr54CX7B5YGAwo7/n8eumidEX3Opx98RyyQVnlHqUaZcPA8uUzL2v1rshr9ypW9Q6hNjfJtg3sL+8kaNE7TA==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">= 10.16.0"
"node": ">= 20.16.0"
}
},
"node_modules/jsesc": {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/explore",
"version": "0.19.3",
"version": "0.19.5",
"description": "Source-driven mobile app maps, deterministic CI capture, and visual reviews",
"license": "MIT",
"type": "module",
@@ -73,7 +73,7 @@
"optionalDependencies": {
"@anthropic-ai/claude-agent-sdk": "0.3.285",
"@openai/codex": "0.159.2",
"eas-cli": "24.4.2"
"eas-cli": "25.0.0"
},
"devDependencies": {
"@anthropic-ai/claude-code": "2.1.285",
+42 -3
View File
@@ -6,7 +6,8 @@
// [--pr https://github.com/brentvatne/euxy/pull/148]
//
// --report a sealed review report (the hosted link's report.zip?platform=ios, or the PR's zip artifact)
// --select the route selected on the hero Map (opens the Inspector); default /settings
// --select the route selected on the hero Map (opens the Inspector); default /settings. The hero zooms in around it
// (--zoom, default 73%) and is framed as a window on a soft stage, like the PR comment
// --compare the Compare key of a modified screen: the slug in the Viewer's #/compare/<key> URL; default patterns
// --pr a GitHub PR URL whose Explore comment becomes readme-pr-comment-light.png (public repository): the comment
// at its own size on a soft stage, cut off with a fade after the list of changed screens
@@ -22,6 +23,7 @@ const { values: args } = parseArgs({
select: { type: "string", default: "/settings" },
compare: { type: "string", default: "patterns" },
pr: { type: "string" },
zoom: { type: "string", default: "73" },
},
});
if (!args.report) {
@@ -31,7 +33,7 @@ if (!args.report) {
const out = fileURLToPath(new URL("../docs/screenshots/", import.meta.url));
const SHOTS = [
{ file: "readme-hero", hash: "#/map", viewport: { width: 2200, height: 1240 }, click: "Fit canvas", select: args.select },
{ file: "readme-hero", hash: "#/map", viewport: { width: 1376, height: 774 }, click: "Fit canvas", select: args.select, zoom: Number(args.zoom), framed: true },
{ file: "readme-compare", hash: `#/compare/${args.compare}`, viewport: { width: 1760, height: 1000 } },
{ file: "readme-screens", hash: "#/screens", viewport: { width: 1760, height: 1000 } },
];
@@ -58,11 +60,28 @@ try {
await page.mouse.move(400, shot.viewport.height - 30);
await page.waitForTimeout(1500);
}
if (shot.zoom) {
// Zoom around the selected screen with the wheel, which keeps it under the pointer, then pan it left and up, clear
// of the minimap and the bottom bar. The camera stops at the first wheel step past the zoom asked for.
const box = await page.locator(`.screen-screenshot-target[title="${shot.select}"]`).boundingBox();
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
for (let step = 0; step < 60; step++) {
if (Number((await page.locator(".zoom-button span").first().textContent()).replace("%", "")) >= shot.zoom) break;
await page.keyboard.down("Control");
await page.mouse.wheel(0, -12);
await page.keyboard.up("Control");
await page.waitForTimeout(150);
}
await page.mouse.wheel(160, 90);
await page.mouse.move(shot.viewport.width - 60, shot.viewport.height / 2);
await page.waitForTimeout(1200);
}
if (shot.hash.startsWith("#/compare/") && !page.url().includes(shot.hash)) {
throw new Error(`Compare key ${args.compare} is not a screen of this report (the Viewer went to ${page.url()}); pass --compare <key> from a #/compare/<key> URL.`);
}
const path = `${out}${shot.file}-${theme}.png`;
await page.screenshot({ path });
if (shot.framed) await writeFile(path, await stagedWindow(browser, await page.screenshot(), shot.viewport, theme));
else await page.screenshot({ path });
console.log(path);
await context.close();
}
@@ -95,6 +114,26 @@ try {
await server.close?.();
}
/**
* A Viewer screenshot as a window on a rounded 1600×900 stage (drawn at 2x), with a hairline border and a soft shadow,
* as the post about Explore frames it. The corners outside the stage stay transparent, so it sits on either GitHub theme.
*/
async function stagedWindow(browser, shot, viewport, theme) {
const dark = theme === "dark";
const stage = dark ? "#151B23" : "#F6F8FA";
const border = dark ? "#3D444D" : "#D1D9E0";
const shadow = dark ? "0 2px 4px rgba(1,4,9,0.4), 0 30px 70px rgba(1,4,9,0.6)" : "0 2px 4px rgba(17,17,17,0.04), 0 30px 70px rgba(17,17,17,0.14)";
const context = await browser.newContext({ viewport: { width: 1600, height: 900 }, deviceScaleFactor: 2 });
const page = await context.newPage();
await page.setContent(`<!doctype html><html><body style="margin:0;background:transparent">
<div id="stage" style="position:relative;width:1600px;height:900px;background:${stage};border-radius:22px;overflow:hidden">
<img src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:${(1600 - viewport.width) / 2}px;top:${(900 - viewport.height) / 2}px;width:${viewport.width}px;height:${viewport.height}px;box-sizing:border-box;border:1px solid ${border};border-radius:14px;box-shadow:${shadow}">
</div></body></html>`);
const png = await page.locator("#stage").screenshot({ omitBackground: true });
await context.close();
return png;
}
/**
* The comment on a rounded stage as wide as the README column (880 px, drawn at 2x), with a soft shadow and a fade at
* the cut. The corners outside the stage stay transparent, so the image sits on either GitHub theme.
+6 -6
View File
@@ -152,18 +152,18 @@ Repeat `expo-explore doctor --json` and fix each `fail` until none remain, colle
## Review a change on this machine
Once `.expo-explore/config.yaml` is committed, the same review CI runs works locally, between any two commits:
The same review CI runs works locally, between any two commits. It reads `.expo-explore/config.yaml` from the head commit, else from the checkout when setup wrote it but it is not committed, else uses the defaults `setup --non-interactive` would write (with several simulator profiles, the one named `explore`), so it works before setup:
```sh
npx @expo/explore capture:review # HEAD against where it left the default branch
npx @expo/explore capture:review --uncommitted # your uncommitted changes to tracked files against HEAD's base
npx @expo/explore capture:review --base v1.3.0 --head v1.4.0 --scope all
npx @expo/explore capture # HEAD and the uncommitted changes, against where HEAD left the default branch
npx @expo/explore capture --committed # HEAD alone
npx @expo/explore capture --base v1.3.0 --head v1.4.0 --scope all
```
- It prints which commits it compares. Each is checked out as a detached worktree in a temporary directory, its dependencies installed (frozen lockfile, no scripts, no Explore credentials in the environment), and removed afterwards; the user's checkout, index and branches are never touched.
- It runs both commits' code as the user (dependency installs, the app config, bundling). Before reviewing a branch the user did not write, say so and ask; credential-free installs are not a sandbox.
- Logins: `EXPO_TOKEN` and the provider's API key when they are set; otherwise the user's `eas login` and their local `claude` or `codex` login for the configured provider. If `eas whoami` fails, tell them to run `eas login`.
- `--uncommitted` includes tracked files only. `--include-untracked` adds untracked, non-ignored files, which are uploaded with the EAS build, so check the listed files first and never include secrets.
- Without `--head`, the head is HEAD plus the working tree's changes, untracked non-ignored files included, which is what `eas build` uploads. It lists them; check that list for secrets the user would not want built. `--committed` reviews HEAD alone, and an `eas.json` with `cli.requireCommit: true` leaves the changes out unless `--uncommitted` is passed.
- Every configured platform is reviewed unless `--platform` picks one. It opens the report in a local Viewer; `--upload` hosts it instead and prints the link, `--no-open` or `--json` only prints the report paths.
- Every run is kept on this machine for 30 days: `npx @expo/explore reports list` (or `--json`) shows them, `reports open <id|latest>` reopens one in the local Viewer, and `reports upload <id>` hosts it without capturing again. Run bare in a terminal, `reports` is an arrow-key picker for the user.
- To host a report after the fact, run `npx @expo/explore report:upload <report.zip>...` with the paths it printed (or the `--output` directory's `<platform>/report.zip`), one per platform. It uses the same project as `--upload` and does not capture again.
@@ -176,7 +176,7 @@ npx @expo/explore capture:review --base v1.3.0 --head v1.4.0 --scope all
- **Releases.** Unless the user asks otherwise, compare each release with the last stable release, with `scope: all` (every screen, so the report shows the whole release with what changed marked) and, when hosted previews are on, `expires-in: never` (the link outlives the 30-day artifact). For every tag as it is pushed, add the `release-review.yml` from the README's "Compare any two commits" section: it finds the newest earlier tag without a `-` (so a release candidate is compared with the last stable release) and calls `explore-compare.yml` with `secrets: inherit` and `permissions: { contents: read, actions: read }`. A nightly compares with yesterday's tag; a release branch with `main`.
- **Once, on demand.** The workflow must be on the default branch to be dispatched: `gh workflow run explore-compare.yml -f base=<ref> -f head=<ref> -f scope=all -f expires-in=never`, or **Run workflow** under Actions → Expo Explore compare.
- **Without CI.** `npx @expo/explore capture:review --base <ref> --head <ref> --scope all --upload` runs the same comparison on this machine (see the previous section).
- **Without CI.** `npx @expo/explore capture --base <ref> --head <ref> --scope all --upload` runs the same comparison on this machine (see the previous section).
- Call the workflow once per workflow run (a second call in the same run reuses the first one's artifact names). A `base` the baseline workflow captured in the last 30 days is reused, so only `head` is captured.
- To verify, run it once on the latest tag and open the run's summary: it lists each platform's result and links the report.
+7 -7
View File
@@ -1,6 +1,6 @@
---
name: readme-refresh
description: Refresh Expo Explore's README.md with euxy (github.com/brentvatne/euxy) as the reference app. Regenerate every screenshot in docs/screenshots from a current euxy review report and PR comment, then re-read the README as a first-time user: the top level only says what Explore does, links the live euxy example, and gives a prompt to copy for trying it on your app and one for setting up CI; everything else lives in collapsibles. Use after a Viewer or PR-comment change that the README shows, a new command or setting, or a release that made a README claim stale. Not for the docs/ guides or the shipped skills.
description: Refresh Expo Explore's README.md with euxy (github.com/brentvatne/euxy) as the reference app. Regenerate every screenshot in docs/screenshots from a current euxy review report and PR comment, then re-read the README as a first-time user: the top level only says what Explore does, links the live euxy example, gives numbered quick-start steps for reviewing a change to your own app, a prompt to copy for exploring any build, and one for setting up CI; everything else lives in collapsibles. Use after a Viewer or PR-comment change that the README shows, a new command or setting, or a release that made a README claim stale. Not for the docs/ guides or the shipped skills.
---
# Refresh the README
@@ -53,18 +53,18 @@ cd - && npm run build:cli && node scripts/readme-reports-rows.mjs > /tmp/reports
- The script renders the picker as the CLI draws it (96 columns, the newest run selected) and writes the terminal body as HTML: each coloured piece is exactly its characters wide, so columns line up, and the wordmark is drawn as cell rectangles, since a design tool's font does not draw `█▀▄` cell for cell.
- In Paper, replace the frame named "Terminal" inside each artboard's window with that HTML, check both artboards in a screenshot (crisp wordmark, aligned columns, the selected row highlighted to the end, coloured counts), and export both at 2x as `readme-reports-light.png` and `readme-reports-dark.png`. The window's title bar reads `npx @expo/explore reports`, as people run it.
Look at every PNG you produced before committing, light and dark: the selected screen should be the one you asked for, the Compare view must show Before and After with outlines, the Screens grid must show the Added/Removed/Modified badges, the PR comment must show the heading links and result glyphs. Describe each in its Markdown alt text as what the picture shows, not what the feature is.
Look at every PNG you produced before committing, light and dark: the selected screen should be the one you asked for, the Compare view must show Before and After with outlines, the Screens grid must show the added, removed and modified status dots, the PR comment must show the heading links and result glyphs. Describe each in its Markdown alt text as what the picture shows, not what the feature is.
## 3. Pass over the content as a first-time user
Read the README top to bottom once without opening a collapsible. At that level it may only answer, in this order:
1. What Explore is (one short paragraph), the hero image, and the link to the live euxy example (`explore-example--euxy.expo.app`, redeployed on every merge to main by `.github/workflows/example-report.yml`).
2. **Try it on your app**: one sentence and a prompt to paste into Claude Code or Codex that gets a simulator build of any app (Expo or not, or just a build) and runs `explore:binary` on it. After its collapsibles, **Review a change before you push it**: one sentence, a prompt that runs `capture:review` locally (the explore-setup skill's "Review a change on this machine" section) on a set-up app, and the `reports` picker image (`readme-reports-*.png`) with one sentence on saved runs, at the top level, not inside a collapsible. Each section keeps its own "Run it yourself"; never put one section between another's prompt and its collapsibles.
3. **Set up CI**: one sentence, then two subsections, each a sentence on what it gives and a prompt to paste: **Review on every PR** (the setup prompt, then a few grouped collapsibles: Hosted previews first, then Manual setup (the setup prompt's steps done by hand, in order: setup, doctor, secrets, baseline, first PR), Capture modes: deterministic or agent, iOS, Android, or both, Keep your setup current) and **Compare any two commits** (a prompt that follows the explore-setup skill's "Compare any two commits" section, the ways to snapshot a release as bullets, then the comparison workflow collapsed).
4. **What you get**: the PR comment, Compare, and Screens, each a heading, one line, and its picture, then a prompt for asking an agent about a report.
1. What Explore is (one short paragraph), the hero image, and the link to the live euxy example (`explore-example--euxy.expo.app`, redeployed on every merge to main by `.github/workflows/example-report.yml`). Under it, one table row of three pictures with a one-line caption each: Compare, Screens, and the PR comment (which says it needs CI), then the agent prompt collapsed as **Ask an agent about a report**. The hero is a zoomed Map framed as a window on a stage (`stagedWindow` in the script); the three below are plain.
2. **Quick start**: the smallest set of steps to see a review of the reader's own Expo app on their machine, numbered and with nothing optional in them: make the app buildable on EAS (login, init, bundle identifier, a simulator profile named `explore`) and commit (the before build is the last commit), then edit a screen near its top and run `capture`, which reviews uncommitted changes as `eas build` would upload them and uses setup's defaults when there is no config. After the steps, a prompt that has Claude Code or Codex do the same through the explore-setup skill's "Review a change on this machine" section. Then the `reports` picker image (`readme-reports-*.png`) with one sentence on saved runs, at the top level, and one collapsible for other commits (`--committed`, `--base`/`--head`) and what a review does on the machine. Run the steps on a fresh `create-expo-app` before changing them.
3. **Map every screen of any app**: one sentence and a prompt to paste into Claude Code or Codex that gets a simulator build of any app (Expo or not, or just a build) and runs `explore:binary` on it. Each section keeps its own "Run it yourself"; never put one section between another's prompt and its collapsibles.
4. **Set up CI**: one sentence, then two subsections, each a sentence on what it gives and a prompt to paste: **Review on every PR** (the setup prompt, then a few grouped collapsibles: Hosted previews first, then Manual setup (the setup prompt's steps done by hand, in order: setup, doctor, secrets, baseline, first PR), Capture modes: deterministic or agent, iOS, Android, or both, Keep your setup current) and **Compare any two commits** (a prompt that follows the explore-setup skill's "Compare any two commits" section, the ways to snapshot a release as bullets, then the comparison workflow collapsed).
Lead with prompts, not explanations: a reader should be able to copy something and see Explore work. Everything else, the manual commands, requirements, options, the manual setup, capture modes, hosted previews, iOS and Android, agent mode, repository settings, how agents read a report, how it works, limitations, contributing, goes into a `<details>` block under the section it belongs to, with a `<summary>` that says what the reader will find. Keep bullets to one or two sentences. Group related collapsibles rather than adding one per topic, so a section shows a handful, not nine. Requirements sit collapsed right under the example report link. Keep the collapsibles' `id` attributes that other docs link to (`#hosted-previews`, `#platforms`, `#compare`, `#agents`), and keep the Inspiration section (screenmap and Revyl's Atlas).
Lead with prompts, not explanations: a reader should be able to copy something and see Explore work. Everything else, the manual commands, requirements, options, the manual setup, capture modes, hosted previews, iOS and Android, agent mode, repository settings, how agents read a report, how it works, limitations, contributing, goes into a `<details>` block under the section it belongs to, with a `<summary>` that says what the reader will find. Keep bullets to one or two sentences. Group related collapsibles rather than adding one per topic, so a section shows a handful, not nine. Requirements sit collapsed right under the example report link. Keep the collapsibles' `id` attributes that other docs link to (`#hosted-previews`, `#platforms`, `#compare`, `#agents`); the Terms and How agents read a report collapsibles live under Additional information, and keep the Inspiration section (screenmap and Revyl's Atlas).
Check that each prompt still works as written:
- the skill links it names (`https://unpkg.com/@expo/explore/skills/...`) are files the package ships (`files` in `package.json`), and they open from the published release;
+1 -1
View File
@@ -610,7 +610,7 @@ export async function runBinaryExploration(options: BinaryExploreOptions): Promi
await writeFile(dotenvPath, SIMULATOR_DOTENV_HEADER, { flag: "wx", mode: 0o600 });
let startError: unknown;
try {
const started = eas(["simulator:start", "--name", sessionName, "--platform", platform, "--device", device, "--type", "agent-device", "--package-version", AGENT_DEVICE_VERSION,
const started = eas(["simulator:start", "--name", sessionName, "--platform", platform, "--device", device, "--type", "agent-device", "--package-version", AGENT_DEVICE_VERSION, "--public-link",
"--max-duration-minutes", String(limits.maxDurationMinutes + 5), "--out-config-type", "dotenv", "--non-interactive"], 20 * 60_000);
if (started.status !== 0) throw new Error(started.stderr || started.stdout || "eas simulator:start failed");
} catch (error) { startError = error; }
+1 -1
View File
@@ -1,6 +1,6 @@
import { CiError } from "../shared/ci-errors.js";
export const EAS_CLI_VERSION = "24.4.2";
export const EAS_CLI_VERSION = "25.0.0";
export { AGENT_DEVICE_VERSION } from "../shared/agent-device-version.js";
export const CONTROLLER_SESSION = "expo-explore-runtime";
+1 -1
View File
@@ -446,7 +446,7 @@ async function executeCiMap(options: CiMapOptions, setStage: (stage: string) =>
await writeFile(dotenvPath, SIMULATOR_DOTENV_HEADER, { flag: "wx", mode: 0o600 });
let startError: unknown;
try { eas(["simulator:start", "--name", sessionName, "--platform", options.platform, "--device", options.device,
"--type", "agent-device", "--package-version", AGENT_DEVICE_VERSION, "--build-id", easBuildId,
"--type", "agent-device", "--package-version", AGENT_DEVICE_VERSION, "--build-id", easBuildId, "--public-link",
"--max-duration-minutes", String(options.maxDurationMinutes), "--out-config-type", "dotenv", "--non-interactive"], 20 * 60_000, simulatorProject); }
catch (error) { startError = error; }
const handoff = await readSimulatorDotenvHandoff(dotenvPath);
+9 -5
View File
@@ -100,7 +100,7 @@ export function simulatorStartFailure(error: unknown, secrets: readonly string[]
message: source.message.replace(/\\+(["'/])/g, "$1"),
nextAction: "Inspect the EAS simulator start failure." }), { secrets });
const message = failure.message
.replace(/\b(?:AGENT_DEVICE_[A-Z_]+|EAS_SIMULATOR_[A-Z_]+|EXPO_TOKEN|agentDeviceRemoteSession(?:Token|Url)|webPreviewUrl)["']?\s*[:=][^\r\n]*/g, "[REDACTED_HANDOFF]")
.replace(/\b(?:AGENT_DEVICE_[A-Z_]+|EAS_SIMULATOR_[A-Z_]+|EXPO_TOKEN|agentDeviceRemoteSession(?:Token|Url)|webPreviewUrl|previewApiUrl)["']?\s*[:=][^\r\n]*/g, "[REDACTED_HANDOFF]")
.replace(/\b[A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s<>"']+/g, "[REDACTED_URL]")
.slice(0, 1600);
return { code: failure.code, stage: "session", message,
@@ -361,11 +361,15 @@ export function collectRuntime(options: CiMapOptions & { platform: NonNullable<C
export async function simulatorOsVersion(session: string, deviceId: string, transport: typeof fetch, platform: "ios" | "android" = "ios"): Promise<string> {
const value = parseJson(session, "eas simulator:get");
const remote = isRecord(value) && isRecord(value.remoteConfig) ? value.remoteConfig : {};
if (typeof remote.webPreviewUrl !== "string") throw new Error("EAS did not publish the simulator preview URL");
const preview = new URL(remote.webPreviewUrl);
// eas-cli 25 publishes the preview server itself as previewApiUrl, with the token in its query, but only for a
// session started with --public-link; its webPreviewUrl is then an expo.dev page with the token in the fragment.
// Earlier versions folded the token into webPreviewUrl's query. A private session's output has no token at all.
const published = typeof remote.previewApiUrl === "string" ? remote.previewApiUrl : remote.webPreviewUrl;
if (typeof published !== "string") throw new Error("EAS did not publish the simulator preview URL");
const preview = new URL(published);
if (preview.protocol !== "https:" || preview.username || preview.password) throw new Error("The simulator preview URL is not HTTPS");
// eas-cli --json folds the preview token into the URL; the catalog takes it as a bearer credential.
const token = preview.searchParams.get("token");
// The catalog takes the preview token as a bearer credential.
const token = preview.searchParams.get("token") ?? new URLSearchParams(preview.hash.slice(1)).get("token");
const catalog = new URL(framedSimulatorPreviewServer(preview) ?? preview.origin);
if (!SIMULATOR_PREVIEW_HOST.test(catalog.hostname)) throw new Error(`The simulator preview URL names no preview server: ${preview.origin}${preview.pathname}`);
// The iOS preview server lists simulators at /grid/api; the Android one has no grid and lists
+58 -14
View File
@@ -8,7 +8,7 @@ import { runCiReview } from "./pipeline.js";
import { resolveCommit } from "./workflow-steps.js";
import { ciLayout, installCommand, type PackageManager } from "./workflow-install.js";
import { configPlatforms, readExploreConfig, resolvePlatformConfig, withRunOverrides, DEFAULT_EXPLORE_CONFIG_PATH, type ExploreConfig, type ExplorePlatform } from "../config/explore-config.js";
import { AGENT_PROVIDERS } from "../config/setup.js";
import { AGENT_PROVIDERS, defaultExploreConfig } from "../config/setup.js";
import type { PrepareCiExplorationOptions } from "../capture/agent/exploration.js";
import { createCiAgentSession } from "../capture/agent/session.js";
import { createLocalCiAgentSession } from "../capture/agent/session-local.js";
@@ -32,10 +32,10 @@ export type LocalReviewOptions = {
project: string;
base?: string | undefined;
head?: string | undefined;
/** Review uncommitted changes to tracked files as the head (the working tree, not a commit). */
/** Review HEAD alone, leaving out the working tree's changes. */
committed?: boolean | undefined;
/** Review the working tree even when eas.json sets cli.requireCommit. Without --head this is the default. */
uncommitted?: boolean | undefined;
/** With `uncommitted`: also include untracked files that are not ignored. */
untracked?: boolean | undefined;
platform?: ExplorePlatform | undefined;
scope?: string | undefined;
expiresIn?: string | undefined;
@@ -89,7 +89,7 @@ export async function snapshotWorkingTree(root: string, options: { untracked?: b
for (const file of untracked) bytes += (await stat(join(root, file)).catch(() => ({ size: 0 }))).size;
if (bytes > UNTRACKED_LIMIT_BYTES) throw new CiError({ code: "LOCAL_REVIEW_UNTRACKED_TOO_LARGE", stage: "preflight",
message: `The untracked files add up to ${Math.round(bytes / 1024 / 1024)} MB; they would be uploaded with the EAS build.`,
nextAction: "Ignore or commit the large files, or leave out --include-untracked." });
nextAction: "Ignore or commit the large files, or pass --committed to review HEAD alone." });
must(git(root, ["add", options.untracked ? "-A" : "-u", "--", "."], environment), "Cannot stage the working tree", "Check the repository's state.");
const tree = must(git(root, ["write-tree"], environment), "Cannot write the working tree", "Check the repository's state.");
await rm(index, { force: true });
@@ -271,6 +271,49 @@ export async function stopRecordedSessions(outputs: string[], environment: NodeJ
return stopped;
}
/**
* What the head of a review without --head is: the working tree, as `eas build` uploads it (tracked and untracked
* files, not ignored ones), unless the app's eas.json sets cli.requireCommit, which makes eas build refuse uncommitted
* changes, or --committed asks for HEAD alone. --head names a commit, so the working tree is never part of it.
*/
export async function reviewHeadSource(options: Pick<LocalReviewOptions, "head" | "committed" | "uncommitted">, project: string):
Promise<"working-tree" | "commit" | "require-commit"> {
const namedHead = options.head !== undefined && options.head !== "HEAD";
if (options.uncommitted && (namedHead || options.committed)) throw new CiError({ code: "LOCAL_REVIEW_UNCOMMITTED_HEAD", stage: "preflight",
message: "--uncommitted reviews the working tree, which is on top of HEAD.", nextAction: `Leave out ${namedHead ? "--head" : "--committed"}, or leave out --uncommitted.` });
if (namedHead || options.committed) return "commit";
if (options.uncommitted) return "working-tree";
let eas: unknown;
try { eas = JSON.parse(await readFile(join(project, "eas.json"), "utf8")); } catch { return "working-tree"; }
const cli = eas !== null && typeof eas === "object" ? (eas as { cli?: unknown }).cli : undefined;
return cli !== null && typeof cli === "object" && (cli as { requireCommit?: unknown }).requireCommit === true ? "require-commit" : "working-tree";
}
/**
* The config a local review runs with: the head commit's; else the one in your checkout, when setup has written it but
* it is not committed yet; else the defaults setup would write, so an app can be reviewed before it is set up. A
* config path passed with --config must be in the head commit.
*/
export async function localReviewConfig(options: { project: string; head: string; configPath: string; explicit: boolean;
platform?: ExplorePlatform | undefined; progress?: Progress }): Promise<ExploreConfig> {
const progress = options.progress ?? silentProgress;
if (options.explicit || await exists(join(options.head, options.configPath))) return readExploreConfig(options.head, options.configPath);
if (await exists(join(options.project, options.configPath))) {
progress(`config: ${options.configPath} from your checkout (it is not in the head commit)`);
return readExploreConfig(options.project, options.configPath);
}
let config: ExploreConfig;
try { config = await defaultExploreConfig(options.project, options.platform); }
catch (error) {
throw new CiError({ code: "LOCAL_REVIEW_CONFIG_DEFAULTS", stage: "preflight",
message: `There is no ${options.configPath}, so this review uses setup's defaults, which need this: ${(error as Error).message}`,
nextAction: "Fix that and rerun (with several simulator profiles, the one named explore is used), or run expo-explore setup to write a config." });
}
progress(`config: none yet, so setup's defaults (${config.app.bundleId}, EAS profile ${config.app.easProfile}, ${config.device.name}); `
+ "expo-explore setup writes one you can change");
return config;
}
export async function runLocalReview(options: LocalReviewOptions): Promise<LocalReviewResult> {
const environment = { ...(options.environment ?? process.env) };
const progress = options.progress ?? silentProgress;
@@ -306,14 +349,14 @@ export async function runLocalReview(options: LocalReviewOptions): Promise<Local
// The commits.
const headRef = options.head ?? "HEAD";
let head: LocalReviewResult["head"];
if (options.uncommitted) {
if (options.head && options.head !== "HEAD") throw new CiError({ code: "LOCAL_REVIEW_UNCOMMITTED_HEAD", stage: "preflight",
message: "--uncommitted reviews the working tree, which is on top of HEAD.", nextAction: "Leave out --head, or leave out --uncommitted." });
const snapshot = await snapshotWorkingTree(root, { untracked: options.untracked, work });
const source = await reviewHeadSource(options, project);
if (source === "require-commit") progress("head: HEAD; eas.json sets cli.requireCommit, so uncommitted changes are left out as eas build leaves them out (--uncommitted includes them)");
if (source === "working-tree") {
const snapshot = await snapshotWorkingTree(root, { untracked: true, work });
head = snapshot ? { ref: "uncommitted changes", sha: snapshot.sha, uncommitted: snapshot.changed } : { ref: "HEAD", sha: resolveCommit(root, "HEAD", "head") };
if (snapshot) progress(`head: your uncommitted changes to ${snapshot.changed.length} file${snapshot.changed.length === 1 ? "" : "s"}`
+ (snapshot.untracked.length ? ` (untracked, uploaded with the build and kept in .git/objects until git gc: ${snapshot.untracked.join(", ")})` : ""));
else progress("head: no uncommitted changes, reviewing HEAD");
if (snapshot) progress(`head: HEAD with your uncommitted changes to ${snapshot.changed.length} file${snapshot.changed.length === 1 ? "" : "s"}, as eas build would upload them`
+ (snapshot.untracked.length ? ` (untracked, kept in .git/objects until git gc: ${snapshot.untracked.join(", ")})` : "") + "; --committed leaves them out");
else progress("head: HEAD (no uncommitted changes)");
} else {
const sha = resolveCommit(root, headRef, "head");
head = { ref: reportRef(root, headRef, sha), sha };
@@ -321,7 +364,7 @@ export async function runLocalReview(options: LocalReviewOptions): Promise<Local
const baseSha = options.base ? resolveCommit(root, options.base, "base") : undefined;
const base = options.base && baseSha ? { ref: reportRef(root, options.base, baseSha), sha: baseSha } : defaultBase(root, head.sha);
if (base.sha === head.sha) throw new CiError({ code: "COMPARE_SAME_COMMIT", stage: "preflight", message: `${base.ref} and ${head.ref} are the same commit (${head.sha.slice(0, 8)}).`,
nextAction: "Pass --base with an earlier commit, or --uncommitted to review your uncommitted changes." });
nextAction: "Change something to review it, or pass --base with an earlier commit." });
progress(`comparing ${head.ref} (${head.sha.slice(0, 8)}) with ${base.ref} (${base.sha.slice(0, 8)})`);
// The checkouts, and the config at head.
@@ -333,7 +376,8 @@ export async function runLocalReview(options: LocalReviewOptions): Promise<Local
}
const projects = { base: join(checkouts.base, appDirectory), head: join(checkouts.head, appDirectory) };
const configPath = options.configPath ?? DEFAULT_EXPLORE_CONFIG_PATH;
const rawConfig = await readExploreConfig(projects.head, configPath);
const rawConfig = await localReviewConfig({ project, head: projects.head, configPath, explicit: options.configPath !== undefined,
platform: options.platform, progress });
const platforms = options.platform ? [options.platform] : configPlatforms(rawConfig);
const repository = repositoryName(root, rawConfig);
+5 -2
View File
@@ -26,9 +26,12 @@ const aliases: Record<string, string> = {
"config platforms": "config:platforms",
};
/** One-word names for commands people type: `capture` is the local review, `capture:review` without its CI flags. */
const shortNames: Record<string, string> = { capture: "capture:review" };
const first = argv[0] ?? "help";
const pair = `${first} ${argv[1] ?? ""}`.trim();
export const command = aliases[pair] ?? first;
export const command = aliases[pair] ?? shortNames[first] ?? first;
export const resultContract = ["source:verify", "capture:review", "capture:baseline", "ci:report", "ci:publish", "ci:failure", "ci:deploy", "ci:pr", "ci:find-baseline", "ci:compare-refs", "ci:after-capture", "config:platforms", "explore:binary", "explore:session", "report:upload", "reports"].includes(command)
? "explore.result" : QUERY_CONTRACT;
const commandArgCount = aliases[pair] ? 2 : 1;
@@ -81,7 +84,7 @@ const flagKinds: Record<string, Record<string, "value" | "boolean">> = {
export: { output: "value" },
"export:web": {catalog:"value",output:"value"},
"capture:review": { "base-project":"value", "head-project":"value", "pull-request":"value", compare:"value", output:"value", config:"value", platform:"value", scope:"value", "expires-in":"value",
base:"value", head:"value", project:"value", uncommitted:"boolean", "include-untracked":"boolean", upload:"boolean", "no-open":"boolean", "no-cache":"boolean", port:"value" },
base:"value", head:"value", project:"value", committed:"boolean", uncommitted:"boolean", "include-untracked":"boolean", upload:"boolean", "no-open":"boolean", "no-cache":"boolean", port:"value" },
+3 -2
View File
@@ -221,11 +221,12 @@ export async function captureBaseline(): Promise<void> {
output({ ok: true, ...await runBaselineCi({ ...(platform ? { platform } : {}), project, sha: required("sha"), output: required("output"), config, progress: stderrProgress() }) });
}
/** `capture:review [--base REF] [--head REF | --uncommitted]`: a local review, opened in the Viewer or hosted with --upload. */
/** `capture` (or `capture:review`) `[--base REF] [--head REF | --committed]`: a local review, opened in the Viewer or hosted with --upload. */
async function localReview(): Promise<void> {
const platform = platformFlag();
const result = await runLocalReview({ project: flag("project") ?? process.cwd(), base: flag("base"), head: flag("head"),
uncommitted: has("uncommitted"), untracked: has("include-untracked"), ...(platform ? { platform } : {}),
// --include-untracked is accepted from before untracked files were included by default.
committed: has("committed"), uncommitted: has("uncommitted"), ...(platform ? { platform } : {}),
scope: flag("scope"), expiresIn: flag("expires-in"), cache: !has("no-cache"), configPath: flag("config"), progress: stderrProgress() });
if (has("output")) {
for (const report of result.reports) {
+6 -3
View File
@@ -17,11 +17,14 @@ const GET_STARTED = `Get started (run these in the Expo app's directory):
(--offline skips EAS and GitHub; --check-model sends one small request with the local provider key)
doctor --capture [--project DIRECTORY] [--output DIRECTORY] [--platform ios|android] [--yes]
(captures the committed HEAD like the baseline workflow, with your eas login, and reports each route)
capture:review [--base REF] [--head REF | --uncommitted [--include-untracked]] [--platform ios|android] [--scope all|changes]
capture [--base REF] [--head REF | --committed] [--platform ios|android] [--scope all|changes]
[--upload [--expires-in 7d|30d|never]] [--no-open] [--no-cache] [--output DIRECTORY] [--project DIRECTORY]
(on this machine: checks out both commits in temporary worktrees, captures them with your eas login and your
local claude or codex login, and opens the report; the base defaults to where HEAD left the default branch;
it runs both commits' code as you, so review only commits you would run)
local claude or codex login, and opens the report; the head is HEAD with your uncommitted changes, as eas build
uploads them (--committed, or cli.requireCommit in eas.json, leaves them out); the base defaults to where HEAD
left the default branch;
without .expo-explore/config.yaml it uses the defaults setup would write;
it runs both commits' code as you, so review only commits you would run; capture:review is the same command)
view [--catalog FILE] [--port N] [--no-open]
(opens a report in the Viewer)
reports [list | open ID | add REPORT... | upload ID | rm ID | prune] [--all] [--json]
+1 -1
View File
@@ -176,7 +176,7 @@ async function uploadSavedRun(run: SavedRun): Promise<void> {
}
function listLines(runs: SavedRun[], now = Date.now()): string[] {
if (!runs.length) return ["No saved runs yet. expo-explore capture:review reviews your branch on this machine, and its report is kept here."];
if (!runs.length) return ["No saved runs yet. expo-explore capture reviews your branch on this machine, and its report is kept here."];
const idWidth = Math.max(...runs.map(run => run.id.length));
return [...runs.map(run => `${run.id.padEnd(idWidth)} ${kindLabel(run).padEnd(9)}${runTitle(run)} (${run.platforms.join(", ")}, ${friendlyTime(run.createdAt, now)})`),
"", "Open one with: expo-explore reports open <id>"];
+1 -1
View File
@@ -129,7 +129,7 @@ export function renderPicker(state: PickerState, options: { width: number; heigh
if (!runs.length) {
const empty = state.runs.length
? [` ${paint.dim(state.filter ? `Nothing matches "${state.filter}".` : `No saved runs of ${state.repository}. Press tab for every repository.`)}`]
: [` ${paint.text("No saved runs yet.")}`, ` ${paint.dim("expo-explore capture:review reviews your branch on this machine, and its report is kept here.")}`];
: [` ${paint.text("No saved runs yet.")}`, ` ${paint.dim("expo-explore capture reviews your branch on this machine, and its report is kept here.")}`];
return [...header, ...empty, "", ...footer].map(line => fit(line, width));
}
const selected = runs[Math.min(state.selected, runs.length - 1)]!;
+15 -2
View File
@@ -4,7 +4,7 @@ import { dirname, join, resolve } from "node:path";
import { createInterface } from "node:readline/promises";
import { fileURLToPath } from "node:url";
import { stringify } from "yaml";
import { DEFAULT_EXPLORE_CONFIG_PATH, readExploreConfig, validateExploreConfig, type ExploreConfig } from "./explore-config.js";
import { DEFAULT_EXPLORE_CONFIG_PATH, readExploreConfig, validateExploreConfig, type ExploreConfig, type ExplorePlatform } from "./explore-config.js";
import { explorationSecretNames } from "./exploration-inputs.js";
import type { RouteEntryReport } from "../ci/route-entry.js";
import type { CiInstallResult } from "../ci/workflow-install.js";
@@ -60,6 +60,8 @@ type SetupOptions = {
appState?: string | undefined;
workflows?: boolean | undefined;
nonInteractive?: boolean;
/** Return the config without writing anything. */
dryRun?: boolean;
check?: boolean;
};
type Interaction = {
@@ -234,6 +236,14 @@ export type SetupResult = {
nextSteps?: string[];
};
/**
* The config `setup --non-interactive` would write, without writing it: what a local review runs with in an app that
* has no config yet. Throws setup's errors when the app cannot be built for capture.
*/
export async function defaultExploreConfig(project: string, platform?: ExplorePlatform): Promise<ExploreConfig> {
return (await runExploreSetup({ project, platform, nonInteractive: true, dryRun: true })).config;
}
/**
* The guided setup. It writes what it can derive (app identity, mode, route parameters it was given,
* an agent-instructions draft, CI files) and hands the app-specific flows to the user's coding agent.
@@ -290,7 +300,9 @@ export async function runExploreSetup(options: SetupOptions = {}, interaction?:
}
const schemes = Array.isArray(app.scheme) ? app.scheme.filter((value): value is string => typeof value === "string") : undefined;
const scheme = await choose("URL scheme (optional)", options.scheme, schemes?.[0] ?? string(app.scheme), schemes);
const profile = await choose(platform === "android" ? "EAS emulator (APK) build profile" : "EAS simulator build profile", options.profile, profiles.length === 1 ? profiles[0]! : "", profiles);
const profile = await choose(platform === "android" ? "EAS emulator (APK) build profile" : "EAS simulator build profile", options.profile,
// With several, the one named explore, the name the README and the explore-setup skill give it.
profiles.length === 1 ? profiles[0]! : profiles.includes("explore") ? "explore" : "", profiles);
if (!profiles.includes(profile)) throw new Error(`Choose ${platform === "android" ? "an Android APK" : "a simulator"} profile from eas.json with --profile: ${profiles.join(", ")}.`);
const inferredProvider = dependencies["expo-router"] ? "expo-router" : dependencies["@react-navigation/native"] ? "react-navigation" : "auto";
const provider = await choose("Navigation provider", options.navigation, inferredProvider, ["auto", "expo-router", "react-navigation"]);
@@ -390,6 +402,7 @@ export async function runExploreSetup(options: SetupOptions = {}, interaction?:
const answer = await ui!.ask("Write this config? (yes/no)", "yes");
if (!/^(y|yes)$/i.test(answer.trim())) throw new Error("Setup canceled; no config was written.");
}
if (options.dryRun) return { path, config, created: false };
await mkdir(parent, { recursive: true });
await writeFile(path, yaml, { flag: "wx" });
if (instructions) await writeFile(instructionsPath, instructions, { flag: "wx" });
+7 -4
View File
@@ -406,10 +406,13 @@ test("the Screens tree folds by row, by keyboard, and all at once, and remembers
await tree.getByRole("button", { name: "Expand all" }).click();
await expect.poll(() => rows.count()).toBe(expandedRows);
// Section headings name the folder, with the path beneath.
const onboarding = page.getByRole("region", { name: "Onboarding" });
await expect(onboarding.getByRole("heading", { level: 2 })).toHaveText("Onboarding");
await expect(onboarding.locator(".screens-section-head .path")).toHaveText("app/onboarding");
// The tree names the folders, so the page beside it is one grid without section headings, in the tree's order.
await expect(page.locator(".screens-page .screens-section-head")).toHaveCount(0);
await expect(page.locator(".screens-page .screens-grid")).toHaveCount(1);
const treeOrder = await tree.locator(".screens-tree-row[data-screen-id]").evaluateAll(rows => rows.map(row => row.dataset.screenId));
const gridOrder = await page.locator(".screens-page .screens-cell").evaluateAll(cells => cells.map(cell => cell.dataset.screenId));
assert.ok(gridOrder.length > 1);
assert.deepEqual(gridOrder, treeOrder);
assert.deepEqual(errors, []);
});
+96 -2
View File
@@ -1309,7 +1309,100 @@ for (const canvas of ["map", "screens"] as const) {
});
}
test("reuses the Map screenshot card visual in Screens, with the route at the card's left edge", async ({ page }) => {
test("← and → step through the Screens cards in page order, with focus, and leave the tree's arrows alone", async ({ page }) => {
await serveWorkspace(page);
await page.goto("/screens");
const grid = page.getByRole("main", { name: "Screens" });
await grid.getByRole("button", { name: /^All/ }).click();
const cells = grid.locator(".screens-grid .screens-cell");
const ids = await cells.evaluateAll(elements => elements.map(element => element.getAttribute("data-screen-id")!));
expect(ids.length).toBeGreaterThan(2);
const card = (id: string) => grid.locator(`.screens-cell[data-screen-id="${id}"] .screen-screenshot-card`);
const target = (id: string) => grid.locator(`.screens-cell[data-screen-id="${id}"] .screen-screenshot-target`);
// With nothing selected, → starts at the first card.
await expect(grid.locator(".screen-screenshot-card.selected")).toHaveCount(0);
await page.keyboard.press("ArrowRight");
await expect(card(ids[0]!)).toHaveClass(/selected/);
await expect(target(ids[0]!)).toBeFocused();
await page.keyboard.press("ArrowRight");
await expect(card(ids[1]!)).toHaveClass(/selected/);
await expect(target(ids[1]!)).toBeFocused();
await page.keyboard.press("ArrowRight");
await expect(card(ids[2]!)).toHaveClass(/selected/);
await page.keyboard.press("ArrowLeft");
await expect(card(ids[1]!)).toHaveClass(/selected/);
await expect(card(ids[2]!)).not.toHaveClass(/selected/);
// ↓ and ↑ move a row, to the card in the same column.
const tops = await cells.evaluateAll(elements => elements.map(element => Math.round(element.getBoundingClientRect().top)));
const columns = tops.filter(top => top === tops[0]).length;
if (ids.length > 1 + columns) {
await page.keyboard.press("ArrowDown");
await expect(card(ids[1 + columns]!)).toHaveClass(/selected/);
await expect(target(ids[1 + columns]!)).toBeFocused();
await page.keyboard.press("ArrowUp");
await expect(card(ids[1]!)).toHaveClass(/selected/);
}
// Held, → keeps stepping, as in Compare, and stops on release.
const selectedAt = async () => ids.indexOf((await grid.locator(".screens-cell:has(.screen-screenshot-card.selected)").getAttribute("data-screen-id"))!);
const from = await selectedAt();
await page.keyboard.down("ArrowRight");
await expect.poll(selectedAt, { timeout: 4000 }).toBeGreaterThanOrEqual(Math.min(ids.length - 1, from + 3));
await page.keyboard.up("ArrowRight");
const released = await selectedAt();
await page.waitForTimeout(500);
expect(await selectedAt()).toBe(released);
// Return opens the pick in the Inspector, from the card or from anywhere on the page.
const inspector = page.getByRole("complementary", { name: "Inspector panel" });
await expect(inspector).toBeHidden();
await page.keyboard.press("Enter");
await expect(inspector).toBeVisible();
await page.keyboard.press("Escape");
await expect(inspector).toBeHidden();
await page.evaluate(() => (document.activeElement as HTMLElement | null)?.blur());
await page.keyboard.press("Enter");
await expect(inspector).toBeVisible();
await page.keyboard.press("Escape");
await expect(inspector).toBeHidden();
// In the tree, ← and → fold and unfold rows; they do not step the cards.
const picked = await selectedAt();
const row = grid.locator(".screens-tree-row").first();
await row.focus();
await page.keyboard.press("ArrowLeft");
await expect(card(ids[picked]!)).toHaveClass(/selected/);
});
test("→ steps the Screens cards right after Screens is opened from the toolbar, and from a pick that Changed hides", async ({ page }) => {
await serveWorkspace(page);
await page.goto("/map");
await page.getByRole("group", { name: "Canvas view" }).getByRole("button", { name: "Screens", exact: true }).click();
const grid = page.getByRole("main", { name: "Screens" });
const cells = grid.locator(".screens-grid .screens-cell");
await expect(cells.first()).toBeVisible();
// Focus is still on the toolbar's Screens button.
await page.keyboard.press("ArrowRight");
await expect(cells.first().locator(".screen-screenshot-card")).toHaveClass(/selected/);
// Pick a screen that Changed hides, then show Changed: → goes to the next changed card after it in the tree.
await grid.getByRole("button", { name: /^All/ }).click();
const all = await cells.evaluateAll(elements => elements.map(element => element.getAttribute("data-screen-id")!));
await grid.getByRole("button", { name: /^Changed/ }).click();
const changed = await cells.evaluateAll(elements => elements.map(element => element.getAttribute("data-screen-id")!));
const hidden = all.find((id, position) => !changed.includes(id) && all.slice(position + 1).some(next => changed.includes(next)));
test.skip(!hidden, "the fixture has no unchanged screen before a changed one");
await grid.getByRole("button", { name: /^All/ }).click();
await grid.locator(`.screens-cell[data-screen-id="${hidden}"] .screen-screenshot-target`).click();
await grid.getByRole("button", { name: /^Changed/ }).click();
const expected = all.slice(all.indexOf(hidden!) + 1).find(id => changed.includes(id))!;
await page.keyboard.press("ArrowRight");
await expect(grid.locator(`.screens-cell[data-screen-id="${expected}"] .screen-screenshot-card`)).toHaveClass(/selected/);
});
test("reuses the Map screenshot card in Screens, with the route under the screenshot at the card's left edge", async ({ page }) => {
await serveWorkspace(page);
await page.goto("/screens");
@@ -1337,8 +1430,9 @@ test("reuses the Map screenshot card visual in Screens, with the route at the ca
};
});
expect(layout.flexDirection).toBe("column");
// The card is the Map's, so the heading still comes first in the markup; Screens shows it as the card's footer.
expect(layout.headingBeforeImage).toBe(true);
expect(layout.headingTop).toBeLessThan(layout.imageTop);
expect(layout.headingTop).toBeGreaterThan(layout.imageTop);
expect(layout.titleLeftDelta).toBeLessThan(1);
}
+27 -1
View File
@@ -150,7 +150,8 @@ async function fixture(t, settings = {}) {
app: { id: settings.wrongProject ? 'foreign-project' : PROJECT_ID, slug: 'example', ownerAccount: { name: 'acme' } },
remoteConfig: { agentDeviceRemoteSessionUrl: 'https://controller.example/session', agentDeviceRemoteSessionToken: DAEMON_TOKEN,
// eas-cli --json folds the preview token into an expo.dev page that frames the preview server.
webPreviewUrl: settings.webPreviewUrl ?? `https://expo.dev/simulator-preview/${PREVIEW_ID}?token=${PREVIEW_TOKEN}` } });
webPreviewUrl: settings.webPreviewUrl ?? `https://expo.dev/simulator-preview/${PREVIEW_ID}?token=${PREVIEW_TOKEN}`,
...(settings.previewApiUrl ? { previewApiUrl: settings.previewApiUrl } : {}) } });
if (command === 'simulator:stop') {
if (settings.stopFailure) throw new Error('stop unavailable');
return json({ id: 'session-1', status: 'STOPPED' });
@@ -356,6 +357,31 @@ test('a preview URL that names the preview server directly reads its catalog', a
assert.deepEqual(f.catalogRequests.map(request => request.url), [`https://web-preview-${PREVIEW_ID}.eas-simulator.ngrok.dev/grid/api?limit=1000`]);
});
test('sessions start with a public preview link, and eas-cli 25 publishes its token on previewApiUrl', async t => {
// eas-cli 25 omits the preview token from a private session's --json output; a --public-link session carries it on
// previewApiUrl (the preview server itself) and in the fragment of the expo.dev page.
const f = await fixture(t, { webPreviewUrl: `https://expo.dev/simulator-preview/${PREVIEW_ID}#token=${PREVIEW_TOKEN}`,
previewApiUrl: `https://web-preview-${PREVIEW_ID}.eas-simulator.ngrok.dev/?token=${PREVIEW_TOKEN}` });
const result = await runCiMap(f.options);
assert.ok(f.requests.find(request => request.args[0] === 'simulator:start').args.includes('--public-link'));
assert.equal(result.simulatorRuntime.osVersion, '26.5');
assert.deepEqual(f.catalogRequests.map(request => request.url), [`https://web-preview-${PREVIEW_ID}.eas-simulator.ngrok.dev/grid/api?limit=1000`]);
});
test('a preview token in the expo.dev page fragment reaches the framed preview server', async t => {
const f = await fixture(t, { webPreviewUrl: `https://expo.dev/simulator-preview/${PREVIEW_ID}#token=${PREVIEW_TOKEN}` });
const result = await runCiMap(f.options);
assert.equal(result.simulatorRuntime.osVersion, '26.5');
assert.equal(f.catalogRequests.length, 1);
});
test('a private session publishes no preview token, so the OS version is unknown and capture goes on', async t => {
const f = await fixture(t, { webPreviewUrl: `https://expo.dev/simulator-preview/${PREVIEW_ID}` });
const result = await runCiMap(f.options);
assert.equal(result.outcomes[f.ids.home].status, 'captured');
assert.ok(f.catalogRequests.every(request => request.authorization === null), 'no credential is invented');
});
test('an unrecognized preview URL is not sent the preview token', async t => {
const f = await fixture(t, { webPreviewUrl: `https://preview.example/session?token=${PREVIEW_TOKEN}` });
const result = await runCiMap(f.options);
+13
View File
@@ -122,6 +122,19 @@ test("version prints the package version", () => {
}
});
test("capture is the local review, capture:review by a shorter name", async (t) => {
const outside = await mkdtemp(join(tmpdir(), "explore-capture-"));
t.after(() => rm(outside, { recursive: true, force: true }));
const failures = ["capture", "capture:review"].map(command => [
runFailure(outside, [command, "--bogus", "--json"]),
runFailure(outside, [command, "--committed", "--json"]),
]);
assert.deepEqual(failures[0], failures[1], "the same flags, errors and result contract");
assert.equal(failures[0][0].command, "capture:review");
assert.equal(failures[0][0].diagnostic.code, "CLI_ARGUMENT_INVALID");
assert.equal(failures[0][1].diagnostic.code, "LOCAL_REVIEW_GIT_FAILED", "--committed is a known flag; outside a repository the review stops");
});
test("removed map-writing commands fail as unknown commands", () => {
for (const command of ["init", "screen:add", "attempt:commit", "frontier:claim", "gap:add", "finish"]) {
const result = spawnSync(process.execPath, [cli, command], { cwd: root, encoding: "utf8" });
+1 -1
View File
@@ -130,7 +130,7 @@ function runtimeFor(side, map, expectedSamples = 3, capturedSamples = expectedSa
observationId: observation.id,
expectedSampleCount: expectedSamples,
controllerPackageVersion: "0.20.2",
easCliVersion: "24.4.2",
easCliVersion: "25.0.0",
},
runtime: {
kind: "eas-agent-device-raw",
+51 -1
View File
@@ -5,7 +5,7 @@ import { spawnSync } from 'node:child_process';
import { lstat, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { appEnvironment, captureCacheDirectory, defaultBase, installDependencies, keepCapture, localInstallCommand, reportRef, runLocalReview, snapshotWorkingTree } from '../../dist/ci/local-review.js';
import { appEnvironment, captureCacheDirectory, defaultBase, installDependencies, keepCapture, localInstallCommand, localReviewConfig, reportRef, reviewHeadSource, runLocalReview, snapshotWorkingTree } from '../../dist/ci/local-review.js';
import { mkdir, readdir } from 'node:fs/promises';
import { startLocalReportServer } from '../../dist/report/local-report-server.js';
import { fixture, git } from '../helpers/public-ci-fixture.mjs';
@@ -56,6 +56,56 @@ test('the working tree becomes a commit on HEAD without touching the index, file
assert.deepEqual({ status: git(root, 'status', '--porcelain'), index: git(root, 'diff', '--cached', '--name-only'), refs: git(root, 'for-each-ref'), head: git(root, 'rev-parse', 'HEAD') }, before);
});
test('the head is the working tree, as eas build uploads it, unless --committed, --head, or eas.json requireCommit says otherwise', async t => {
const project = await scratch(t, 'explore-local-head-');
assert.equal(await reviewHeadSource({}, project), 'working-tree', 'no eas.json');
await writeFile(join(project, 'eas.json'), JSON.stringify({ cli: { version: '>= 16' }, build: {} }));
assert.equal(await reviewHeadSource({}, project), 'working-tree');
assert.equal(await reviewHeadSource({ committed: true }, project), 'commit');
assert.equal(await reviewHeadSource({ head: 'HEAD' }, project), 'working-tree', '--head HEAD is the default head');
assert.equal(await reviewHeadSource({ head: 'v1.0.0' }, project), 'commit');
await writeFile(join(project, 'eas.json'), JSON.stringify({ cli: { requireCommit: true } }));
assert.equal(await reviewHeadSource({}, project), 'require-commit', 'eas build refuses uncommitted changes here, so the review leaves them out');
assert.equal(await reviewHeadSource({ uncommitted: true }, project), 'working-tree', '--uncommitted includes them anyway');
await writeFile(join(project, 'eas.json'), '{ not json');
assert.equal(await reviewHeadSource({}, project), 'working-tree');
for (const conflict of [{ uncommitted: true, head: 'v1.0.0' }, { uncommitted: true, committed: true }]) {
await assert.rejects(reviewHeadSource(conflict, project), { code: 'LOCAL_REVIEW_UNCOMMITTED_HEAD' });
}
});
test('a review uses the head commit\'s config, else an uncommitted one, else the defaults setup would write', async t => {
const project = await scratch(t, 'explore-local-app-');
const head = await scratch(t, 'explore-local-head-');
const json = (path, value) => writeFile(join(project, path), JSON.stringify(value));
await json('package.json', { dependencies: { expo: '*', 'expo-router': '*' } });
await json('app.json', { expo: { name: 'Test app', scheme: 'test-app', ios: { bundleIdentifier: 'com.example.test' } } });
await json('eas.json', { build: { explore: { ios: { simulator: true } } } });
const configPath = '.expo-explore/config.yaml';
const resolve = (options = {}) => localReviewConfig({ project, head, configPath, explicit: false, ...options });
const messages = [];
const defaults = await resolve({ progress: message => messages.push(message) });
assert.equal(defaults.mode, 'deterministic');
assert.deepEqual([defaults.app.platform, defaults.app.bundleId, defaults.app.easProfile, defaults.app.scheme], ['ios', 'com.example.test', 'explore', 'test-app']);
assert.equal(defaults.navigation.provider, 'expo-router');
assert.equal(defaults.exploration.scope, 'changes');
assert.match(messages.join('\n'), /setup's defaults \(com\.example\.test, EAS profile explore, iPhone 17\)/);
await assert.rejects(lstat(join(project, '.expo-explore')), { code: 'ENOENT' }, 'the defaults are not written');
const config = name => `mode: deterministic\napp:\n name: ${name}\n platform: ios\n bundleId: com.example.test\n easProfile: explore\n`
+ 'navigation:\n provider: expo-router\ndevice:\n name: iPhone 17\nexploration:\n scope: changes\n';
await mkdir(join(project, '.expo-explore')); await writeFile(join(project, configPath), config('Checkout'));
assert.equal((await resolve()).app.name, 'Checkout', 'setup ran but its config is not committed yet');
await mkdir(join(head, '.expo-explore')); await writeFile(join(head, configPath), config('Head'));
assert.equal((await resolve()).app.name, 'Head', 'the commit under review wins');
await assert.rejects(resolve({ configPath: 'other.yaml', explicit: true }), { code: 'CONFIG_READ_FAILED' }, 'a --config path must be in the commit');
await rm(join(project, '.expo-explore'), { recursive: true }); await rm(join(head, '.expo-explore'), { recursive: true });
await rm(join(project, 'eas.json'));
await assert.rejects(resolve(), error => error.code === 'LOCAL_REVIEW_CONFIG_DEFAULTS' && /no \.expo-explore\/config\.yaml.*No eas\.json found/s.test(error.message));
});
test('with no base, a branch is compared with where it left the default branch', async t => {
const root = await repository(t);
const fork = git(root, 'rev-parse', 'HEAD');
+1 -1
View File
@@ -60,7 +60,7 @@ function state(overrides = {}) {
phase: 'ready', pullRequest, mode: 'changes', executionMode: 'deterministic', configPath: '.expo-explore/config.yaml', links,
startedAt: Date.parse('2026-09-11T03:00:48Z'), updatedAt: Date.parse('2026-09-11T03:07:00Z'),
build: { appName: 'Example', appVersion: '1.4.0', appBuildNumber: '27', platform: 'ios', easProfile: 'explore', easBuildId: 'eas-build', reusedEasBuild: true },
runtime: { provider: 'eas-simulator', controller: 'agent-device', controllerPackageVersion: '0.20.2', easCliVersion: '24.4.2', platform: 'ios', deviceModel: 'iPhone 17', osVersion: '26.5', locale: 'en-US', orientation: 'portrait', colorScheme: 'light', sessionLifecycle: 'stopped' },
runtime: { provider: 'eas-simulator', controller: 'agent-device', controllerPackageVersion: '0.20.2', easCliVersion: '25.0.0', platform: 'ios', deviceModel: 'iPhone 17', osVersion: '26.5', locale: 'en-US', orientation: 'portrait', colorScheme: 'light', sessionLifecycle: 'stopped' },
capture: { planned: { base: 3, head: 3 }, done: { base: 3, head: 3 }, baseFromCache: true },
review: evidenceReview(),
evidence: {
+1 -1
View File
@@ -13,7 +13,7 @@ const BASE_SHA = "a".repeat(40);
const HEAD_SHA = "b".repeat(40);
const PNG = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", "base64");
const EXECUTION = {
provider: "eas-simulator", controller: "agent-device", controllerPackageVersion: AGENT_DEVICE_VERSION, easCliVersion: "24.4.2",
provider: "eas-simulator", controller: "agent-device", controllerPackageVersion: AGENT_DEVICE_VERSION, easCliVersion: "25.0.0",
platform: "ios", deviceModel: "iPhone 17", osVersion: "26.0", locale: "en-US", orientation: "portrait",
colorScheme: "light", sessionLifecycle: "stopped",
};
+2 -2
View File
@@ -15,7 +15,7 @@ function execution(overrides = {}) {
provider: "eas-simulator",
controller: "agent-device",
controllerPackageVersion: AGENT_DEVICE_VERSION,
easCliVersion: "24.4.2",
easCliVersion: "25.0.0",
platform: "ios",
deviceModel: "iPhone 17",
osVersion: "26.0",
@@ -188,7 +188,7 @@ test("projects one map surface into the five runtime evidence groups", () => {
assert.equal(result.groups.interaction.transitionCount.value, 1);
assert.equal(result.groups.ui.landmarks.value.length, 0);
assert.equal(result.groups.environment.controllerPackageVersion?.value, AGENT_DEVICE_VERSION);
assert.equal(result.groups.environment.easCliVersion?.value, "24.4.2");
assert.equal(result.groups.environment.easCliVersion?.value, "25.0.0");
});
test("normalizes multi-line labels and treats only open parser gaps as truncation", () => {
+15 -1
View File
@@ -3,7 +3,7 @@ import test from "node:test";
const { tsImport } = await import("tsx/esm/api");
const { indexMap } = await tsImport("../../viewer/src/utils/model.ts", import.meta.url);
const { screenTree } = await tsImport("../../viewer/src/utils/screen-tree.ts", import.meta.url);
const { screenTree, treeScreenOrder } = await tsImport("../../viewer/src/utils/screen-tree.ts", import.meta.url);
const at = (second) => `2026-10-13T00:00:${String(second).padStart(2, "0")}.000Z`;
function screen(id, title, depth, extra = {}) {
@@ -49,6 +49,20 @@ test("with route files, sections follow the app directory and the tabs lead", ()
assert.deepEqual(folders, ["(tabs)/"]);
});
test("the screens' order is the tree's, depth first: a nested folder's screens come right after their parent's", () => {
// The folders are found as settings, feed, settings/security: sections keep that order, while the tree nests
// security under settings. The Screens grid and its arrow keys follow the tree, as the sidebar reads.
const screens = [screen("profile", "A profile", 1), screen("feed", "B feed", 1), screen("security", "C security", 1), screen("loose", "D loose", 1)];
const routeFiles = new Map([
["profile", "app/settings/profile.tsx"],
["feed", "app/feed/index.tsx"],
["security", "app/settings/security/index.tsx"],
]);
const tree = screenTree(screens, indexMap(map({ screens })), routeFiles);
assert.deepEqual(tree.sections.flatMap(section => section.screenIds), ["profile", "feed", "security", "loose"]);
assert.deepEqual(treeScreenOrder(tree), ["profile", "security", "feed", "loose"]);
});
test("a black-box exploration groups by the tab each screen was opened from", () => {
const screens = [
screen("seq", "Sequencer", 0),
+7 -2
View File
@@ -78,11 +78,16 @@ test("EAS profile inheritance is respected and device builds cannot be selected"
explore: { extends: "base", ios: { buildConfiguration: "Release" } },
production: { extends: "base", ios: { simulator: false } },
} });
await assert.rejects(runExploreSetup({ project, ...options }), /--profile/);
await assert.rejects(runExploreSetup({ project, ...options, profile: "production" }), /--profile/);
await assert.rejects(stat(path), { code: "ENOENT" });
await runExploreSetup({ project, ...options, profile: "explore" });
// Of several simulator profiles, the one named explore is the default; without one, setup asks for --profile.
await runExploreSetup({ project, ...options });
assert.equal((await readExploreConfig(project)).app.easProfile, "explore");
await rm(path);
await json("eas.json", { build: { base: { ios: { simulator: true } }, sim: { extends: "base" } } });
await assert.rejects(runExploreSetup({ project, ...options }), /--profile: base, sim/);
await runExploreSetup({ project, ...options, profile: "sim" });
assert.equal((await readExploreConfig(project)).app.easProfile, "sim");
});
test("dynamic config uses the app's Expo resolver instead of stale app.json", async (t) => {
+17 -1
View File
@@ -15,6 +15,21 @@ test("hints print modifiers in Apple's ⌥⇧⌘ order and as Ctrl+Alt+Shift els
assert.equal(formatShortcut(SHORTCUTS.camera.fit, true), "⇧1");
assert.equal(formatShortcut({ code: "KeyT", key: "T", mod: true, alt: true }, false), "Ctrl+Alt+T");
assert.equal(formatShortcut(SHORTCUTS.edit.redo, false), "Ctrl+Shift+Z");
// The Control key itself prints as ⌃ on a Mac, where ⌘ would be a different key.
assert.equal(formatShortcut(SHORTCUTS.canvasByNumber.screens, true), "⌃2");
assert.equal(formatShortcut(SHORTCUTS.canvasByNumber.screens, false), "Ctrl+2");
});
test("Ctrl+1, Ctrl+2 and Ctrl+3 reach Map, Screens and Compare with Control alone, never ⌘ (the browser's tab keys)", () => {
assert.equal(matchesShortcut(key("Digit1", { ctrlKey: true }), SHORTCUTS.canvasByNumber.map), true);
assert.equal(matchesShortcut(key("Digit2", { ctrlKey: true }), SHORTCUTS.canvasByNumber.screens), true);
assert.equal(matchesShortcut(key("Digit3", { ctrlKey: true }), SHORTCUTS.canvasByNumber.compare), true);
assert.equal(matchesShortcut(key("Digit1", { metaKey: true }), SHORTCUTS.canvasByNumber.map), false);
assert.equal(matchesShortcut(key("Digit1", { ctrlKey: true, metaKey: true }), SHORTCUTS.canvasByNumber.map), false);
assert.equal(matchesShortcut(key("Digit1", { ctrlKey: true, shiftKey: true }), SHORTCUTS.canvasByNumber.map), false);
// Compare's 1, 2, 3 (Split, Swipe, Flip) stay plain digits.
assert.equal(matchesShortcut(key("Digit1", { ctrlKey: true }), SHORTCUTS.compare.split), false);
assert.equal(matchesShortcut(key("Digit1"), SHORTCUTS.canvasByNumber.map), false);
});
test("a chord matches only its own modifiers, on either ⌘ or Ctrl", () => {
@@ -35,7 +50,8 @@ test("no two shortcuts share a chord", () => {
const seen = new Map();
for (const [group, entries] of Object.entries(SHORTCUTS)) {
for (const [name, shortcut] of Object.entries(entries)) {
const chord = `${shortcut.code}:${Boolean(shortcut.mod)}:${Boolean(shortcut.alt)}:${Boolean(shortcut.shift)}`;
// Off Apple keyboards ⌘ is Ctrl, so a Control chord clashes with the same ⌘ chord.
const chord = `${shortcut.code}:${Boolean(shortcut.mod || shortcut.ctrl)}:${Boolean(shortcut.alt)}:${Boolean(shortcut.shift)}`;
const clash = seen.get(chord);
assert.ok(!clash, `${group}.${name} repeats ${clash}`);
seen.set(chord, `${group}.${name}`);
+5 -1
View File
@@ -46,6 +46,7 @@ import {
type ThemePreference,
} from "./utils/navigation";
import {
CANVAS_NUMBER_KEYS,
matchesShortcut,
modalOpen,
SHORTCUTS,
@@ -142,7 +143,10 @@ const LEGACY_COLLAPSED_STORAGE_KEY = "expo-explore:panel-collapsed";
const RIGHT_COLLAPSED_STORAGE_KEY = "expo-explore:right-panel-collapsed";
// The shell's keyboard map, paired with what each key selects. Read as lists so a key and the
// thing it reaches stay one entry.
const CANVAS_KEYS = Object.entries(SHORTCUTS.canvas) as [CanvasView, Shortcut][];
const CANVAS_KEYS = [
...Object.entries(SHORTCUTS.canvas),
...(CANVAS_NUMBER_KEYS ? Object.entries(SHORTCUTS.canvasByNumber) : []),
] as [CanvasView, Shortcut][];
/** Before data loads there is no comparison to assume. A workspace reparses the URL on arrival. */
const EMPTY_ROUTE_CONTEXT: RouteContext = {
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { createPortal } from "react-dom";
import { X } from "lucide-react";
import { formatShortcut, SHORTCUTS, type Shortcut } from "../../utils/shortcuts";
import { CANVAS_NUMBER_KEYS, formatShortcut, SHORTCUTS, type Shortcut } from "../../utils/shortcuts";
import type { CanvasView } from "../../utils/navigation";
import { useModalDialog } from "../../hooks/use-modal-dialog";
@@ -63,6 +63,9 @@ export function shortcutGroups(context: ShortcutContext): Group[][] {
label: context.hasChanges ? "Map, Screens, Compare" : "Map, Screens",
keys: sections.map((section) => SHORTCUTS.canvas[section]),
},
...(CANVAS_NUMBER_KEYS
? [{ label: "The same, by their place in the toolbar", keys: sections.map((section) => SHORTCUTS.canvasByNumber[section]) }]
: []),
{ label: "Search screens", keys: [SHORTCUTS.app.search] },
...(context.handoff ? [{ label: "Hand off to AI", keys: [SHORTCUTS.app.handoff] }] : []),
...(context.hasChanges ? [{ label: "Changed screens menu", keys: [SHORTCUTS.app.changes] }] : []),
@@ -83,9 +86,17 @@ export function shortcutGroups(context: ShortcutContext): Group[][] {
{ label: "Close the inspector, then deselect", keys: ["Esc"] },
],
};
const screensGroup: Group = {
title: "Screens",
rows: [
{ label: "Move through the screens", keys: ["←", "→", "↑", "↓"] },
{ label: "Close the inspector, then deselect", keys: ["Esc"] },
],
};
const here: Group[] = context.canvas === "compare"
? [reviewGroup(context)]
: [...(context.review ? [reviewGroup(context)] : []), ...(context.canvas === "map" ? [mapGroup] : []), CAMERA];
: [...(context.review ? [reviewGroup(context)] : []), ...(context.canvas === "map" ? [mapGroup] : []),
...(context.canvas === "screens" ? [screensGroup] : []), CAMERA];
return [here, [goTo, view]];
}
+85
View File
@@ -184,6 +184,91 @@ button.screens-tree-row:hover { color: var(--text); background: var(--panel-hove
.screens-cell-via { overflow: hidden; color: var(--tertiary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.screens-cell-elsewhere { color: var(--modified); font-size: 11px; font-weight: 600; }
/* ── Desktop grid ── */
/* One evenly spaced grid. Each screen is a card: the screenshot in a grey well and the route under it, with the
status as the tree's dot before it, the way file browsers show documents. Nothing is framed in the status colour,
so the page reads as a list of screens rather than a canvas of them. */
.screens-page:not(.phone) .screens-sections { display: block; padding-top: 0; }
.screens-page:not(.phone) .screens-grid { gap: 12px; }
/* Wide enough for a 28-character route after the dot, in the footer's 10.5px mono with room to spare: Linux's
fonts set it at about 183px. Five cards fit beside the tree at 1440px. */
.screens-page:not(.phone) .screens-cell { width: 216px; }
.screens-page:not(.phone) .screens-cell .screen-screenshot-card {
overflow: hidden;
gap: 0;
border: 1px solid var(--border-subtle);
border-radius: 12px;
background: var(--surface);
transition: border-color 120ms ease, box-shadow 120ms ease;
}
.screens-page:not(.phone) .screens-cell .screen-screenshot-card:has(.screen-screenshot-target:hover) { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-subtle)); }
.screens-page:not(.phone) .screens-cell .screen-screenshot-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* The status is laid out against the card, not the screenshot, so it can sit in the footer. */
.screens-page:not(.phone) .screens-cell :is(.screen-screenshot-slot, .diff-frame) { position: static; }
.screens-page:not(.phone) .screens-cell .screen-screenshot-slot { order: 1; height: 236px; flex: none; padding: 12px 0; background: var(--element); }
.screens-page:not(.phone) .screens-cell .screen-screenshot-card.selected .screen-screenshot-slot { background: var(--accent-soft); }
.screens-page:not(.phone) .screens-cell .screen-node-image img,
.screens-page:not(.phone) .screens-cell .screen-node-image > .image-placeholder,
.screens-page:not(.phone) .screens-cell .screen-screenshot-card .diff-frame .screen-node-image img,
.screens-page:not(.phone) .screens-cell .screen-screenshot-card .diff-frame .screen-node-image > .image-placeholder {
border-color: transparent;
border-radius: 8px;
box-shadow: 0 1px 3px rgb(0 0 0 / 0.14);
}
/* The image box hugs the screenshot, so its corners and shadow are the screenshot's and no box shows around it. */
/* The screenshot fits the well both ways at its own proportions (styles.css's max-width and max-height), so a
landscape capture is framed as itself, not letterboxed inside a portrait-sized box. */
.screens-page:not(.phone) .screens-cell .screen-node-image img { width: auto; height: auto; background: transparent; }
/* No screenshot: the well has a size here, so the placeholder fits it the way styles.css fits it to a Map slot,
at the screenshot's proportions, rather than by the cell's width as a phone's cell does (phone.css). */
.screens-page:not(.phone) .screens-cell .screen-node-image:has(> .image-placeholder) { container-type: size; }
.screens-page:not(.phone) .screens-cell .screen-node-image > .image-placeholder {
width: min(
100cqw - 2 * var(--frame-border),
(100cqh - 2 * var(--frame-border)) * var(--screenshot-width) / var(--screenshot-height),
var(--screenshot-width) * 1px
);
height: min(
100cqh - 2 * var(--frame-border),
(100cqw - 2 * var(--frame-border)) * var(--screenshot-height) / var(--screenshot-width),
var(--screenshot-height) * 1px
);
aspect-ratio: auto;
}
/* A selected card's button is pressed, and a focused pressed button brightens (styles.css). Here that would wash out
the screenshot and, as a filter, become the box the status is placed in, lifting it into the well. Keyboard focus
rings the card instead. */
.screens-page:not(.phone) .screens-cell .screen-screenshot-target:focus-visible { filter: none; outline: 0; }
.screens-page:not(.phone) .screens-cell .screen-screenshot-card:has(.screen-screenshot-target:focus-visible) {
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 42%, transparent);
}
.screens-page:not(.phone) .screens-cell .screen-screenshot-card.selected:has(.screen-screenshot-target:focus-visible) {
box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 32%, transparent);
}
.screens-page:not(.phone) .screens-cell .screen-node-heading { order: 2; min-height: 0; padding: 10px 6px 10px 8px; }
.screens-page:not(.phone) .screens-cell .screen-screenshot-card:has(.diff-label) .screen-node-heading { padding-left: 20px; }
.screens-page:not(.phone) .screens-cell .screen-node-title { font-size: 10.5px; line-height: 14px; }
.screens-page:not(.phone) .screens-cell .screen-screenshot-card.selected .screen-node-title { color: var(--accent-strong); font-weight: 600; }
/* The status is the tree's dot before the route, in the status colour (a square for accessibility only); the word
stays in the label's accessible name. */
.screens-page:not(.phone) .screens-cell .screen-screenshot-card .diff-label {
top: auto;
bottom: 13.5px;
left: 8px;
width: 7px;
height: 7px;
overflow: hidden;
padding: 0;
border-radius: 50%;
color: transparent;
background: var(--diff);
box-shadow: none;
font-size: 0;
transform: none;
}
.screens-page:not(.phone) .screens-cell .diff-accessibility-only .diff-label { border-radius: 2px; }
.screens-page:not(.phone) .screens-cell :is(.screens-cell-via, .screens-cell-elsewhere) { padding-inline: 2px; }
/* ── Phone ── */
/* The space under the top bar is a block, not padding: both engines inset a sticky child's rest
position by the scroll container's padding, which pushed the section bar a bar's height too low. */
+142 -18
View File
@@ -5,9 +5,11 @@ import { primaryScreenshotForScreen, screenshotSize } from "../../utils/screen-i
import { diffClass, type BuildDiff, type DiffStatus } from "../../utils/build-diff";
import { focusStatusOf, isCapturedChange } from "../../utils/changed-screens";
import { displayPathForScreen, screenLabel } from "../../utils/screen-path";
import { screenTree, treeIndex, treeNodeKey, type ScreenTree, type ScreenTreeNode } from "../../utils/screen-tree";
import { screenTree, treeIndex, treeNodeKey, treeScreenOrder, type ScreenTree, type ScreenTreeNode } from "../../utils/screen-tree";
import type { Appearance } from "../../utils/appearance";
import type { FocusRequest, FocusStatus } from "../../utils/navigation";
import { shortcutsLive } from "../../utils/shortcuts";
import { HOLD_INITIAL_DELAY_MS, holdIntervalMs } from "../../utils/key-hold";
import { ScreenScreenshotCard } from "../canvas/screen-screenshot-card";
import { useCanvasVisibleFrame } from "../canvas/visible-frame-provider";
import { PhoneSheet } from "../phone/phone-chrome";
@@ -75,6 +77,26 @@ function cardId(id: string): string {
return `screens-card-${id.replace(/[^A-Za-z0-9_-]/g, "_")}`;
}
/**
* The card in the row above or below a screen's, nearest it across: read from where the cards sit, so it follows the
* grid however many columns the page has room for. A short last row still takes ↓ from the row above it.
*/
function cardInNextRow(from: string, ids: readonly string[], down: boolean): string | undefined {
const box = (id: string) => document.getElementById(cardId(id))?.getBoundingClientRect();
const here = box(from);
if (!here) return undefined;
const centre = (rect: DOMRect) => rect.left + rect.width / 2;
const rows = ids.flatMap(id => {
const rect = box(id);
return rect && (down ? rect.top >= here.bottom - 1 : rect.bottom <= here.top + 1) ? [{ id, rect }] : [];
});
if (!rows.length) return undefined;
const nearestTop = down ? Math.min(...rows.map(row => row.rect.top)) : Math.max(...rows.map(row => row.rect.top));
const row = rows.filter(candidate => Math.abs(candidate.rect.top - nearestTop) < 1);
return row.reduce((best, candidate) =>
Math.abs(centre(candidate.rect) - centre(here)) < Math.abs(centre(best.rect) - centre(here)) ? candidate : best).id;
}
function sectionAnchor(id: string): string {
return `screens-section-${id.replace(/[^A-Za-z0-9_-]/g, "_")}`;
}
@@ -168,6 +190,7 @@ function TreeRows(props: {
<button type="button" style={style}
className={`screens-tree-row${node.tab ? " tab" : ""}${props.visible.has(screen.id) ? "" : " filtered"}`}
aria-current={props.selectedScreenId === screen.id ? "true" : undefined}
data-screen-id={screen.id}
aria-expanded={key ? open : undefined}
data-tree-key={key}
onClick={() => props.onSelect(screen.id)}>
@@ -202,8 +225,8 @@ function Legend(props: { others: Appearance[] }) {
}
/**
* Screens as a page that scrolls: a section per route folder (or per tab, when there are no route
* files), with the tree of them beside it on desktop and behind a Tree button on a phone.
* Screens as a page that scrolls. On desktop, one grid of every screen in the order of the tree beside it; on a
* phone, a section per route folder (or per tab, when there are no route files), with the tree behind a Tree button.
*/
export function ScreensView(props: ScreensViewProps) {
const tree: ScreenTree = useMemo(
@@ -222,6 +245,9 @@ export function ScreensView(props: ScreensViewProps) {
const sections = tree.sections
.map(section => ({ ...section, screenIds: section.screenIds.filter(id => shown.has(id)) }))
.filter(section => section.screenIds.length > 0);
// The desktop grid reads in the tree's order, not the sections' (screen-tree.ts).
const treeOrder = useMemo(() => treeScreenOrder(tree), [tree]);
const order = props.phone ? sections.flatMap(section => section.screenIds) : treeOrder.filter(id => shown.has(id));
const others = [...new Set([...(props.changedElsewhere?.values() ?? [])].flat())];
// Folding. All keeps the reader's folds and remembers them per report. Changed folds separately, starting
@@ -321,12 +347,118 @@ export function ScreensView(props: ScreensViewProps) {
requestAnimationFrame(() => document.getElementById(cardId(id))?.scrollIntoView({ block: "center", behavior: "smooth" }));
};
// On desktop the arrow keys move through the cards: ← and → in their order on the page (`order`), as the arrows step
// through screens in Compare, and ↑ and ↓ to the card above or below, by where the cards sit, so they follow the grid
// at any width. A step picks the screen as the tree does, leaving the Inspector as it is, and focus follows it; with
// nothing picked, → and ↓ start at the first card, and a pick that Changed hides steps from where it sits in the tree.
// The tree's rows keep their arrow keys, and so do the Inspector's controls. Phones are left as they were.
// Held, an arrow keeps stepping as Compare's do (key-hold.ts). Return opens the picked screen in the Inspector, as a
// click on its card does; on the card itself the button already does.
const orderRef = useRef(order);
orderRef.current = order;
const treeOrderRef = useRef(treeOrder);
treeOrderRef.current = treeOrder;
const selectedRef = useRef(selected);
selectedRef.current = selected;
const pickRef = useRef(props.onPickScreen ?? props.onSelectScreen);
pickRef.current = props.onPickScreen ?? props.onSelectScreen;
const openRef = useRef(props.onSelectScreen);
openRef.current = props.onSelectScreen;
useEffect(() => {
if (props.phone) return;
/** The card an arrow moves to from `from` (the pick, or the last card a hold stepped to). */
const next = (code: string, from: string | undefined): string | undefined => {
const ids = orderRef.current;
const vertical = code === "ArrowUp" || code === "ArrowDown";
const forward = code === "ArrowRight" || code === "ArrowDown";
if (from && ids.includes(from)) return vertical ? cardInNextRow(from, ids, forward) : ids[ids.indexOf(from) + (forward ? 1 : -1)];
if (from && treeOrderRef.current.includes(from)) {
// Picked, but hidden by Changed: the nearest shown card past it in the tree's order.
const shownIds = new Set(ids);
const all = treeOrderRef.current;
const at = all.indexOf(from);
return (forward ? all.slice(at + 1) : all.slice(0, at).reverse()).find(candidate => shownIds.has(candidate));
}
return forward ? ids[0] : ids[ids.length - 1];
};
const go = (id: string) => {
pickRef.current(id);
requestAnimationFrame(() => document.getElementById(cardId(id))?.querySelector<HTMLElement>(".screen-screenshot-target")?.focus({ preventScroll: true }));
};
let hold: { code: string; at: string; timer: ReturnType<typeof setTimeout> } | undefined;
const endHold = () => {
if (hold) clearTimeout(hold.timer);
hold = undefined;
};
const beginHold = (code: string, at: string) => {
endHold();
let step = 1;
const tick = () => {
const id = hold && next(code, hold.at);
if (!hold || !id) { endHold(); return; }
go(id);
hold = { code, at: id, timer: setTimeout(tick, holdIntervalMs(step)) };
step += 1;
};
hold = { code, at, timer: setTimeout(tick, HOLD_INITIAL_DELAY_MS) };
};
const onKeyDown = (event: globalThis.KeyboardEvent) => {
const arrow = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.code);
if (!arrow && event.key !== "Enter") return;
// The browser's own repeat of a held arrow would scroll the page under the hold.
if (event.repeat && hold?.code === event.code) { event.preventDefault(); return; }
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey || event.defaultPrevented || !shortcutsLive(event)) return;
const target = event.target instanceof Element ? event.target : null;
if (!arrow) {
// Return on a button or a link presses it; elsewhere on the page it opens the pick.
const selectedId = selectedRef.current;
if (target?.closest("button, a, [role=\"button\"]") || !target?.closest("body") || !selectedId || !orderRef.current.includes(selectedId)) return;
if (target !== document.body && !target.closest(".screens-page")) return;
event.preventDefault();
openRef.current(selectedId);
return;
}
// The page, or the bottom toolbar that Screens was just opened from; its buttons have no arrow keys of their own.
const onPage = !target || target === document.body || target.closest(".screens-page, .canvas-toolbar") !== null;
if (!onPage || target?.closest(".screens-tree-list")) return;
const id = next(event.code, selectedRef.current);
if (!id) return;
event.preventDefault();
go(id);
beginHold(event.code, id);
};
const onKeyUp = (event: globalThis.KeyboardEvent) => {
if (hold && event.code === hold.code) endHold();
};
window.addEventListener("keydown", onKeyDown);
window.addEventListener("keyup", onKeyUp);
window.addEventListener("blur", endHold);
return () => {
endHold();
window.removeEventListener("keydown", onKeyDown);
window.removeEventListener("keyup", onKeyUp);
window.removeEventListener("blur", endHold);
};
}, [props.phone]);
// The Inspector floats over the right edge; the page keeps its content clear of it.
const { visibleFrame } = useCanvasVisibleFrame();
const style = !props.phone && visibleFrame
? ({ "--screens-right-inset": `calc(100% - ${visibleFrame.x + visibleFrame.width}px)` } as CSSProperties)
: undefined;
const cell = (id: string) => {
const screen = props.index.screens.get(id);
return screen ? (
<ScreenCell key={id} screen={screen} index={props.index} diff={props.diff}
elsewhere={isChanged(props.diff, id) ? undefined : props.changedElsewhere?.get(id)}
via={tree.via.get(id)}
selected={props.selectedScreenId === id}
dimmed={Boolean(props.focus?.length) && !props.focus!.some((state) => state === focusStatusOf(props.diff?.screens.get(id)))}
onSelect={() => props.onSelectScreen(id)} />
) : null;
};
const treeRows = (
<ul className="screens-tree-list" onKeyDown={onTreeKey}>
<TreeRows nodes={tree.tree} depth={0} index={props.index} diff={props.diff} elsewhere={props.changedElsewhere}
@@ -378,28 +510,20 @@ export function ScreensView(props: ScreensViewProps) {
</aside>
)}
<div className="screens-sections">
{sections.map(section => (
{props.phone ? sections.map(section => (
<section key={section.id} id={sectionAnchor(section.id)} className="screens-section" aria-label={section.name ?? section.title}>
<header className="screens-section-head">
<h2>{section.name ?? section.title}</h2>
{section.path ? <span className="path">{breakAfterSlashes(section.title)}</span>
: section.subtitle ? <span>{section.subtitle}</span> : null}
</header>
<div className="screens-grid">
{section.screenIds.map(id => {
const screen = props.index.screens.get(id);
return screen ? (
<ScreenCell key={id} screen={screen} index={props.index} diff={props.diff}
elsewhere={isChanged(props.diff, id) ? undefined : props.changedElsewhere?.get(id)}
via={tree.via.get(id)}
selected={props.selectedScreenId === id}
dimmed={Boolean(props.focus?.length) && !props.focus!.some((state) => state === focusStatusOf(props.diff?.screens.get(id)))}
onSelect={() => props.onSelectScreen(id)} />
) : null;
})}
</div>
<div className="screens-grid">{section.screenIds.map(cell)}</div>
</section>
))}
)) : (
// On desktop the tree beside the page already shows the folders, so every screen sits in one evenly
// spaced grid in the tree's order, without headings between them.
<div className="screens-grid">{order.map(cell)}</div>
)}
</div>
</div>
+1 -1
View File
@@ -54,7 +54,7 @@ export function handoffPrompt(input: HandoffInput, view?: HandoffView): string {
input.pageUrl,
"",
`Fetch the link first${local ? " (from this machine, with curl if your fetch tool refuses local addresses)" : ""}. It explains the report's JSON API. Go through the changed screens, compare the before and after screenshots${appearances}, and tell me which changes look intended and which look like regressions. For each regression, name the source file to fix.`,
...(local ? ["", "The link is served by `expo-explore capture:review` on this machine and stops working when it exits."] : []),
...(local ? ["", "The link is served by `expo-explore capture` on this machine and stops working when it exits."] : []),
];
if (view) {
const where = [view.screen, view.view, view.platform, view.appearance].filter(Boolean).join(" · ");
+2 -2
View File
@@ -4,8 +4,8 @@
* or a spinner accelerates. The browser's own key repeat is ignored (its rate is a fixed OS setting),
* so the hold is timed here and ends on key up, blur, or the end of the list.
*/
export const HOLD_INITIAL_DELAY_MS = 400;
export const HOLD_FIRST_INTERVAL_MS = 300;
export const HOLD_INITIAL_DELAY_MS = 250;
export const HOLD_FIRST_INTERVAL_MS = 200;
export const HOLD_FLOOR_INTERVAL_MS = 70;
const HOLD_DECAY = 0.8;
+16
View File
@@ -228,6 +228,22 @@ export type ScreenTreeIndex = {
parents: Map<string, string>;
};
/**
* Every screen in the order the tree lists it: depth first, so a subfolder's screens follow its parent folder's own,
* where sections list folders in the order they were found. A screen the tree leaves out comes last.
*/
export function treeScreenOrder(tree: ScreenTree): string[] {
const ids: string[] = [];
const walk = (nodes: readonly ScreenTreeNode[]) => {
for (const node of nodes) {
if (node.kind === "screen") ids.push(node.screenId);
walk(node.children);
}
};
walk(tree.tree);
return [...new Set([...ids, ...tree.sections.flatMap(section => section.screenIds)])];
}
export function treeIndex(tree: readonly ScreenTreeNode[]): ScreenTreeIndex {
const index: ScreenTreeIndex = { keys: [], screensUnder: new Map(), ancestors: new Map(), parents: new Map() };
const walk = (nodes: readonly ScreenTreeNode[], above: string[]): string[] => nodes.flatMap((node) => {
+23 -3
View File
@@ -7,6 +7,8 @@ export type Shortcut = {
code: string;
/** ⌘ on Apple keyboards, Ctrl everywhere else. */
mod?: boolean;
/** The Control key itself on every keyboard, for chords whose ⌘ form the browser keeps (⌘1–⌘9 switch tabs). */
ctrl?: boolean;
/** ⌥ on Apple keyboards, Alt everywhere else. */
alt?: boolean;
shift?: boolean;
@@ -17,6 +19,12 @@ export type Shortcut = {
const APPLE = typeof navigator !== "undefined"
&& /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent);
/**
* Whether Ctrl+1–3 reach the page. On Apple keyboards ⌃ is free (the browser's tab keys are ⌘1–9); elsewhere the
* browser keeps Ctrl+1–8 for its tabs, so those keys are neither handled nor printed there.
*/
export const CANVAS_NUMBER_KEYS = APPLE;
function mod(code: string, key: string): Shortcut {
return { code, key, mod: true };
}
@@ -25,6 +33,10 @@ function modShift(code: string, key: string): Shortcut {
return { code, key, mod: true, shift: true };
}
function ctrl(code: string, key: string): Shortcut {
return { code, key, ctrl: true };
}
function shift(code: string, key: string): Shortcut {
return { code, key, shift: true };
}
@@ -68,6 +80,12 @@ export const SHORTCUTS = {
screens: plain("KeyS", "S"),
compare: plain("KeyC", "C"),
},
/** The canvases by their place in the toolbar, as tabs are numbered elsewhere. Apple keyboards only (CANVAS_NUMBER_KEYS). */
canvasByNumber: {
map: ctrl("Digit1", "1"),
screens: ctrl("Digit2", "2"),
compare: ctrl("Digit3", "3"),
},
/** Compare only. The arrows walk changed screens; J and K walk the changed areas of one. */
compare: {
previousScreen: plain("ArrowLeft", "←"),
@@ -92,10 +110,10 @@ export const SHORTCUTS = {
/** The hint, in the idiom of the keyboard reading it: Apple's ⌥⇧⌘ order, or Ctrl+Alt+Shift. */
export function formatShortcut(shortcut: Shortcut, apple = APPLE): string {
if (apple) {
return `${shortcut.alt ? "⌥" : ""}${shortcut.shift ? "⇧" : ""}${shortcut.mod ? "⌘" : ""}${shortcut.key}`;
return `${shortcut.ctrl ? "⌃" : ""}${shortcut.alt ? "⌥" : ""}${shortcut.shift ? "⇧" : ""}${shortcut.mod ? "⌘" : ""}${shortcut.key}`;
}
const parts: string[] = [];
if (shortcut.mod) parts.push("Ctrl");
if (shortcut.mod || shortcut.ctrl) parts.push("Ctrl");
if (shortcut.alt) parts.push("Alt");
if (shortcut.shift) parts.push("Shift");
parts.push(shortcut.key);
@@ -104,7 +122,9 @@ export function formatShortcut(shortcut: Shortcut, apple = APPLE): string {
export function matchesShortcut(event: KeyboardEvent, shortcut: Shortcut): boolean {
if (event.code !== shortcut.code) return false;
if ((event.metaKey || event.ctrlKey) !== Boolean(shortcut.mod)) return false;
if (shortcut.ctrl) {
if (!event.ctrlKey || event.metaKey) return false;
} else if ((event.metaKey || event.ctrlKey) !== Boolean(shortcut.mod)) return false;
if (event.shiftKey !== Boolean(shortcut.shift)) return false;
return event.altKey === Boolean(shortcut.alt);
}