Merge remote-tracking branch 'origin/master' into app-login

f1407b9 · gmorell · 2026-12-03 18:20

69 files +1815 -182
Message
{commit_body(@commit)}

Files changed

modified README.md
+12 −9
@@ -37,9 +37,9 @@ Source: `ssh://gabe@gg.neiam.co:22222/neiam/vigil.git` (branch `master`).
37 37 - **Organizations**: teams, roles and invites; membership can come from
38 38 OIDC or LDAP groups (NEIAM). There are API tokens and a Sentry-shaped
39 39 `/api/0` for project, key and issue management.
40 −- **Android app**: a read-only client for issues, events and monitors,
41 − paired by scanning a QR from the API tokens page, or signed in with
42 − NEIAM, a password or an emailed link.
40 +- **Android app**: issues, events and monitors, with triage (resolve,
41 + ignore, assign; swipes and bulk), paired by scanning a QR from the API
42 + tokens page, or signed in with NEIAM, a password or an emailed link.
43 43
44 44 ROADMAP.md is the design document: the wire contract, the architecture,
45 45 and what each slice built, as built.
@@ -105,16 +105,19 @@ See cli/README.md.
105 105
106 106 ### The Android app
107 107
108 −`android/` is a read-only phone client: issues across an organization or
109 −a project, each one's latest event and stack trace, and the cron and
110 −uptime monitors. To pair a phone, tick **Mobile app** when making a token
111 −under **Settings → API tokens** and scan the QR that appears; revoking the
112 −token signs the phone out. CI publishes signed builds to the forge's
108 +`android/` is a phone client: issues across an organization or a
109 +project, each one's latest event and stack trace, and the cron and uptime
110 +monitors; issues can be resolved, ignored and assigned there (swipe, or
111 +long-press for several). To pair a phone, tick **Mobile app** when making
112 +a token under **Settings → API tokens** (and **Read-only** for a phone
113 +that only looks) and scan the QR that appears; revoking the token signs
114 +the phone out. Phones paired before triage have a read-only token: pair
115 +them again with a new one. CI publishes signed builds to the forge's
113 116 F-Droid repository. See android/README.md.
114 117
115 118 The app can also sign in with NEIAM (OIDC in the system browser, with
116 119 PKCE) or by email (a sign-in link, or a password), through `/api/v1/auth/*`;
117 −each way in yields the same read-only token. Emailed sign-in links open the
120 +each way in yields a token of the Mobile app bundle (reading and triage). Emailed sign-in links open the
118 121 app when it is installed. The API, the security decisions and the deploy
119 122 notes (`ANDROID_CERT_FINGERPRINTS`, `/.well-known/assetlinks.json`,
120 123 `APP_LOGIN_REDIRECT_URI`) are in [docs/app-login.md](docs/app-login.md).
modified ROADMAP.md
+4 −0
@@ -532,6 +532,10 @@ This is new: GlitchTip throws `check_in` items away.
532 532 - Settings → API tokens has a **Mobile app** box that ticks the read bundle (`org:read project:read team:read member:read event:read`, `Vigil.ApiTokens.mobile_scopes/0`). A new token covering it is shown with a `vigil://pair?base=…&token=…` QR (EQRCode, as gitgud) and link. The app verifies against `GET /api/0/` before storing, and names any missing scope. A paired phone is its token: revoking it signs the phone out.
533 533 - New in `/api/0`, Sentry-shaped: `GET /organizations/{o}/issues/` (every visible project's issues, or `?project=`, with the issue search and Link cursors); `GET /projects/{o}/{p}/issues/{id}/` (group details: releases and a tag summary); `GET /projects/{o}/{p}/issues/{id}/events/latest/` (Sentry's event with `entries`: exception, message, breadcrumbs, request; frames with `context`, never `vars`). Issue lists now carry `userCount`, from the `user` tag.
534 534 - The app: org picker (skipped with one), issues (search, status, project, paging, pull to refresh), an issue with its latest event, cron and uptime monitors. `test/vigil_web/api/android_fixtures_test.exs` writes the responses the app's contract test decodes.
535 + - **Triage (as built):**
536 + - The **Mobile app** bundle now adds `event:write` (`mobile_scopes/0`); a **Read-only** sub-option leaves it out (`mobile_read_scopes/0`, the old bundle). `mobile?/1` checks the read bundle, so tokens made before still pair; `mobile_triage?/1` adds `event:write`, and the token list badges which.
537 + - The bulk `PUT /projects/{o}/{p}/issues/` takes Sentry's `assignedTo` (`"user:<id>"`, a bare id, an email/username, or `""`/`null` for nobody; teams refused) beside or instead of `status`, and `statusDetails: {"inNextRelease": true}` with `resolved`. It replies with what changed (`assignedTo` as the issue's actor); bad input is a 400 in Sentry's field-error shape. `GET /organizations/{o}/members/` (`member:read`) lists the assignable, in Sentry's member shape. Ignore durations and counts aren't supported (Vigil's ignore is for good), and delete stays web-only (`project:admin`).
538 + - The app reads its scopes from `GET /api/0/` at pairing and each start; with `event:write`, the issue screen resolves (now or in the next release), ignores, reopens and assigns (me, a member, nobody), and the list swipes (resolve / ignore) and long-presses into multi-select for bulk changes, one PUT per project. Every change offers Undo (each issue's former status or assignee, grouped); rows that no longer match the filter leave. Without it the issue screen says to pair a new token.
535 539
536 540 ---
537 541
modified android/DESCRIPTION.md
+2 −2
@@ -1,5 +1,5 @@
1 1 Your Vigil errors, cron monitors and uptime checks, on your phone.
2 2
3 −The read-only phone companion to Vigil, the self-hosted error tracker that speaks Sentry's protocol. See what is breaking across your organization or in one project: each issue's level, how often it happens and to how many users, its tags, and its latest event with the exception and stack trace (your own frames first, with the source around them), breadcrumbs and the request. Check which cron monitors are failing or late, and which uptime monitors are down.
3 +The phone companion to Vigil, the self-hosted error tracker that speaks Sentry's protocol. See what is breaking across your organization or in one project: each issue's level, how often it happens and to how many users, its tags, and its latest event with the exception and stack trace (your own frames first, with the source around them), breadcrumbs and the request. Triage as you go: swipe to resolve or ignore, long-press to select several, assign to yourself or a teammate, and undo any of it. Check which cron monitors are failing or late, and which uptime monitors are down.
4 4
5 −Pair by scanning the code on Vigil's Settings → API tokens page, after ticking "Mobile app". Revoke the token there and the phone is signed out.
5 +Pair by scanning the code on Vigil's Settings → API tokens page, after ticking "Mobile app" (and "Read-only" for a phone that should only look). Revoke the token there and the phone is signed out.
modified android/README.md
+36 −17
@@ -1,8 +1,9 @@
1 1 # Vigil Android client
2 2
3 −A read-only phone companion for [Vigil](../): what's breaking across an
3 +A phone companion for [Vigil](../): what's breaking across an
4 4 organization, each issue's latest event with its stack trace, and which
5 −cron and uptime monitors are failing. It talks to the same Sentry-shaped
5 +cron and uptime monitors are failing; and triage: resolve, ignore and
6 +assign issues from the list or the issue. It talks to the same Sentry-shaped
6 7 `/api/0` that sentry-cli uses, with an API token: scanned from the web, or
7 8 made for it when it signs in (`/api/v1/auth/*`).
8 9
@@ -14,14 +15,26 @@ of the neiam family: the same Compose shell, the web's own OKLCh themes
14 15
15 16 | Surface | |
16 17 |---|---|
17 −| **Log-in** | The family's shared log-in page: **Scan** (the QR from Settings → API tokens, its `vigil://pair` link, or the server and token typed in), **Sign in with NEIAM** (SSO in a Custom Tab), or **Username** (email me a sign-in link, or a password). Each way in ends with the same kind of read-only token. See [docs/app-login.md](../docs/app-login.md) |
18 +| **Log-in** | The family's shared log-in page: **Scan** (the QR from Settings → API tokens, its `vigil://pair` link, or the server and token typed in), **Sign in with NEIAM** (SSO in a Custom Tab), or **Username** (email me a sign-in link, or a password). Each way in ends with a token of the Mobile app bundle (reading, plus triage). See [docs/app-login.md](../docs/app-login.md) |
18 19 | **Organizations** | Picked once and remembered; skipped when you're in only one. Switch from the menu |
19 −| **Issues** | Across the organization or one project; Unresolved (the default), Ignored, Resolved or All; the web's search syntax (`level:error`, `release:1.2`, `browser:Firefox`, free text). Level, title, culprit, events, users, last seen and project per row. Pages load as you scroll (Sentry's Link-header cursors); pull to refresh |
20 −| **Issue** | Counts, first and last seen, releases, assignee; the latest event's exception chain and stack, newest call first, in-app frames outlined with their source lines and library frames folded; breadcrumbs, the request, the event's tags, user and runtime; a tag summary. **Open in browser** goes to the web page, where it can be triaged |
20 +| **Issues** | Across the organization or one project; Unresolved (the default), Ignored, Resolved or All; the web's search syntax (`level:error`, `release:1.2`, `assigned:me`, `browser:Firefox`, free text). Level, title, culprit, events, users, status, assignee, last seen and project per row. Pages load as you scroll (Sentry's Link-header cursors); pull to refresh |
21 +| **Triage in the list** | Swipe right to resolve, left to ignore (from Resolved: right reopens; from Ignored: right resolves, left reopens), with **Undo** in the snackbar. Long-press to select, tap to add more, then resolve, ignore, assign, resolve in next release or unresolve them all: one request per project. A row that no longer matches the filter leaves the list |
22 +| **Issue** | Status and assignee; counts, first and last seen, releases; the latest event's exception chain and stack, newest call first, in-app frames outlined with their source lines and library frames folded; breadcrumbs, the request, the event's tags, user and runtime; a tag summary. **Open in browser** goes to the web page |
23 +| **Triage on an issue** | Resolve, Resolve in next release, Ignore, Unresolve (whichever make sense from its status), and Assign: to you, a member, or nobody. Each with **Undo**; a refusal shows the server's reason |
21 24 | **Monitors** | Cron monitors (health, schedule, last check-in, next due) and uptime monitors (up or down, why, response time, certificate expiry), failing ones first |
22 25
23 −Nothing in the app changes anything on the server: the token it asks for
24 −is read-only.
26 +The only changes the app makes are an issue's status and assignee, through
27 +Sentry's bulk `PUT …/issues/?id=…`, which needs `event:write`. A token made
28 +with **Read-only** ticked (or before the app could triage) has no
29 +`event:write`: the app then shows no triage controls, and the issue screen
30 +says that a new token, paired again, brings them. The app asks the server
31 +for its scopes at every start (**Check again** asks at once), but a
32 +token's scopes never change, so re-pairing is the way.
33 +
34 +Not here, on purpose: **delete** (it needs `project:admin`, which the
35 +mobile bundle doesn't carry, so a lost phone can't delete), comments,
36 +sharing, and ignoring "for a while" or "until N more events" (the server's
37 +ignore, like the web's, is for good).
25 38
26 39 The summary and description F-Droid shows come from
27 40 [`DESCRIPTION.md`](DESCRIPTION.md): the summary on the first line (80
@@ -45,17 +58,19 @@ bigtrippr's and waxx's, so the family builds from one Gradle cache.
45 58 ## Pairing (Scan)
46 59
47 60 1. Signed in on the web: **Settings → API tokens**. Tick **Mobile app**,
48 − which ticks the read-only bundle the app needs (`org:read`,
49 − `project:read`, `team:read`, `member:read`, `event:read`), give the
50 − token a label and create it.
61 + which ticks the bundle the app uses (`org:read`, `project:read`,
62 + `team:read`, `member:read`, `event:read`, and `event:write` for
63 + triage), give the token a label and create it. Tick **Read-only** under
64 + it to leave out `event:write`: the phone can look but not touch.
51 65 2. A QR appears beside the token, encoding
52 66 `vigil://pair?base=<server>&token=<token>`, with the same link under it.
53 67 3. In the app, **Scan** and point it at the QR. Or open the link on the
54 68 phone (the Scan sheet opens filled in; tap **Pair**), or paste the link
55 69 or enter the server and token by hand in the sheet.
56 70 4. The app calls `GET /api/0/` and keeps the pair only once the server
57 − names the token's owner. A token short of the bundle still pairs; the
58 − screens it can't read say so.
71 + names the token's owner. A token short of the read bundle still pairs;
72 + the screens it can't read say so. A token without `event:write` pairs
73 + read-only: the issue screens say how to get triage.
59 74
60 75 A paired phone *is* its token: there is no separate device list. Revoke
61 76 the token on the tokens page and the app notices on its next request and
@@ -164,6 +179,8 @@ All under `/api/0`, with `Authorization: Bearer <token>`:
164 179 | `GET /projects/{org}/{project}/issues/{id}/events/latest/` | `event:read` | Sentry's event shape (`entries`) |
165 180 | `GET /organizations/{org}/monitors/` | `project:read` | cron monitors, with Vigil's `health` |
166 181 | `GET /organizations/{org}/uptime/` | `project:read` | Vigil's own |
182 +| `GET /organizations/{org}/members/` | `member:read` | Sentry's member shape; who to assign to |
183 +| `PUT /projects/{org}/{project}/issues/?id=…&id=…` | `event:write` | Sentry's bulk mutate: `{"status": …}` and/or `{"assignedTo": "user:<id>" \| ""}`; one per project |
167 184
168 185 Signing in (no token yet) uses `/api/v1/auth/*`, the API every neiam app
169 186 shares: see [docs/app-login.md](../docs/app-login.md).
@@ -233,7 +250,8 @@ app/src/main/java/org/neiam/vigil/app/
233 250 TokenStore.kt # (server, token), encrypted; https upgrade
234 251 PrefsStore.kt # theme and organization
235 252 VigilClient.kt # Retrofit interface, error messages
236 − Models.kt # JSON shapes; the mobile scope bundle
253 + Models.kt # JSON shapes; the mobile scope bundle; Account
254 + Triage.kt # status actions, undo plans, filter matching
237 255 auth/
238 256 VigilLoginHost.kt # Vigil's glue for the shared log-in page
239 257 login/ # the log-in page, the same in every neiam app:
@@ -242,16 +260,17 @@ app/src/main/java/org/neiam/vigil/app/
242 260 ui/
243 261 OrgPickerScreen.kt
244 262 HomeScreen.kt # Issues | Monitors tabs; menu: org, theme, unpair
245 − IssuesTab.kt # search, filters, paged list
246 − IssueScreen.kt # details, latest event, tags
263 + IssuesTab.kt # search, filters, paged list; swipes, multi-select
264 + IssueScreen.kt # details, triage, latest event, tags
265 + Triage.kt # runs a triage with Undo; assign dialog
247 266 MonitorsTab.kt # cron and uptime
248 267 Loading.kt # load / refresh / error states
249 268 Common.kt # app bar title, pills, sections, times
250 269 ThemePicker.kt
251 270 theme/ # the web's themes, status colours and B612
252 271 app/src/test/
253 − …/LinksTest.kt, ContractTest.kt, CommonTest.kt
254 − …/auth/login/ # methods parsing, PKCE, link matching, errors
272 + …/LinksTest.kt, ContractTest.kt, TriageTest.kt, CommonTest.kt
273 + …/auth/login/ # methods parsing, PKCE, link matching, errors, server choice
255 274 resources/api/*.json # real API responses the contract test decodes
256 275 ```
257 276
modified android/app/src/main/java/org/neiam/vigil/app/MainActivity.kt
+31 −1
@@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
15 15 import androidx.compose.runtime.LaunchedEffect
16 16 import androidx.compose.runtime.collectAsState
17 17 import androidx.compose.runtime.getValue
18 +import androidx.compose.runtime.mutableIntStateOf
18 19 import androidx.compose.runtime.mutableStateOf
19 20 import androidx.compose.runtime.remember
20 21 import androidx.compose.runtime.setValue
@@ -32,6 +33,7 @@ import org.neiam.vigil.app.auth.login.AuthLinkHandler
32 33 import org.neiam.vigil.app.auth.login.LoginFlows
33 34 import org.neiam.vigil.app.auth.login.LoginPrefs
34 35 import org.neiam.vigil.app.auth.login.LoginScreen
36 +import org.neiam.vigil.app.data.Account
35 37 import org.neiam.vigil.app.data.PrefsStore
36 38 import org.neiam.vigil.app.data.TokenStore
37 39 import org.neiam.vigil.app.data.VigilClient
@@ -42,6 +44,7 @@ import org.neiam.vigil.app.ui.OrgPickerScreen
42 44 import org.neiam.vigil.app.ui.theme.AppTheme
43 45 import org.neiam.vigil.app.ui.theme.VigilTheme
44 46 import org.neiam.vigil.app.ui.theme.appThemeForKey
47 +import retrofit2.HttpException
45 48
46 49 /**
47 50 * The one activity. Routes: login (the shared log-in page, auth/login:
@@ -128,6 +131,11 @@ private fun VigilApp(
128 131 val nav = rememberNavController()
129 132 var credentials by remember { mutableStateOf(tokens.load()) }
130 133 val api = remember(credentials) { credentials?.let(VigilClient::authenticated) }
134 + // Who we are and what the token may do: as stored at pairing, then
135 + // asked again at each start (and on request), so triage shows up
136 + // without re-pairing when the token allows it.
137 + var account by remember { mutableStateOf(tokens.loadAccount()) }
138 + var accountCheck by remember { mutableIntStateOf(0) }
131 139 val start = remember {
132 140 when {
133 141 credentials == null || goToLogin.value -> "login"
@@ -150,9 +158,27 @@ private fun VigilApp(
150 158 // A 401 means the token was revoked (or expired): this phone is signed out.
151 159 fun unauthorized() = unpair()
152 160
153 − // Signed in, by any way in: the stored token is the one to use now.
161 + LaunchedEffect(api, accountCheck) {
162 + val signedIn = api ?: return@LaunchedEffect
163 + try {
164 + val root = signedIn.root()
165 + if (root.user != null) {
166 + account = Account.of(root).also(tokens::saveAccount)
167 + }
168 + } catch (e: HttpException) {
169 + if (e.code() == 401) unauthorized()
170 + } catch (e: kotlinx.coroutines.CancellationException) {
171 + throw e
172 + } catch (_: Exception) {
173 + // Offline: keep what we had.
174 + }
175 + }
176 +
177 + // Signed in, by any way in: the stored token is the one to use now
178 + // (its account is asked for at once, by the effect above).
154 179 fun signedIn() {
155 180 credentials = tokens.load()
181 + account = tokens.loadAccount()
156 182 nav.navigate("orgs?auto=true") { popUpTo(0) }
157 183 }
158 184
@@ -194,6 +220,8 @@ private fun VigilApp(
194 220 HomeScreen(
195 221 api = signedIn,
196 222 org = org,
223 + account = account,
224 + onCheckAccount = { accountCheck++ },
197 225 theme = theme,
198 226 themeKey = themeKey,
199 227 onPickTheme = onPickTheme,
@@ -221,6 +249,8 @@ private fun VigilApp(
221 249 org = args?.getString("org").orEmpty(),
222 250 project = args?.getString("project").orEmpty(),
223 251 id = args?.getString("id").orEmpty(),
252 + account = account,
253 + onCheckAccount = { accountCheck++ },
224 254 onBack = { nav.popBackStack() },
225 255 onUnauthorized = ::unauthorized,
226 256 )
modified android/app/src/main/java/org/neiam/vigil/app/auth/VigilLoginHost.kt
+3 −0

Click to load diff…

modified android/app/src/main/java/org/neiam/vigil/app/data/Models.kt
+77 −4

Click to load diff…

modified android/app/src/main/java/org/neiam/vigil/app/data/TokenStore.kt
+21 −1

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/data/Triage.kt
+115 −0

Click to load diff…

modified android/app/src/main/java/org/neiam/vigil/app/data/VigilClient.kt
+64 −9

Click to load diff…

modified android/app/src/main/java/org/neiam/vigil/app/ui/HomeScreen.kt
+9 −1

Click to load diff…

modified android/app/src/main/java/org/neiam/vigil/app/ui/IssueScreen.kt
+146 −6

Click to load diff…

modified android/app/src/main/java/org/neiam/vigil/app/ui/IssuesTab.kt
+339 −48

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/Triage.kt
+283 −0

Click to load diff…

modified android/app/src/test/java/org/neiam/vigil/app/data/ContractTest.kt
+31 −0

Click to load diff…

added android/app/src/test/java/org/neiam/vigil/app/data/TriageTest.kt
+129 −0

Click to load diff…

modified android/app/src/test/resources/api/event.json
+5 −5

Click to load diff…

modified android/app/src/test/resources/api/issue.json
+10 −5

Click to load diff…

added android/app/src/test/resources/api/issue_update.json
+10 −0

Click to load diff…

modified android/app/src/test/resources/api/issues.json
+10 −5

Click to load diff…

modified android/app/src/test/resources/api/issues_link.txt
+1 −1

Click to load diff…

added android/app/src/test/resources/api/members.json
+19 −0

Click to load diff…

modified android/app/src/test/resources/api/monitors.json
+5 −5

Click to load diff…

modified android/app/src/test/resources/api/organizations.json
+2 −2

Click to load diff…

modified android/app/src/test/resources/api/projects.json
+4 −4

Click to load diff…

modified android/app/src/test/resources/api/root.json
+9 −8

Click to load diff…

modified android/app/src/test/resources/api/uptime.json
+2 −2

Click to load diff…

modified docs/app-login.md
+2 −1

Click to load diff…

modified lib/vigil/api_tokens.ex
+25 −8

Click to load diff…

modified lib/vigil_web/api/v0/issue_controller.ex
+85 −20

Click to load diff…

modified lib/vigil_web/api/v0/organization_controller.ex
+13 −1

Click to load diff…

modified lib/vigil_web/api/v0/project_json.ex
+31 −2

Click to load diff…

modified lib/vigil_web/live/api_token_live.ex
+40 −10

Click to load diff…

modified lib/vigil_web/router.ex
+4 −2

Click to load diff…

modified test/vigil_web/api/android_fixtures_test.exs
+14 −1

Click to load diff…

modified test/vigil_web/api/mobile_api_test.exs
+169 −1

Click to load diff…

modified test/vigil_web/live/api_token_live_test.exs
+53 −1

Click to load diff…

Parents: 4934a5d 7ad8440