madeveloper: make Issues and Pull requests actually open
- Commit
750dd9c695fc26cb6b591d1f2d910686cf6e73a9- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-19 17:05 UTC (16 days ago)
- Parents
be84724
The Home quick links for Issues and Pull requests were wired to empty onClick lambdas, Recent activity rows were not clickable at all, and no Issues/PR destinations existed - the data was loaded and then had nowhere to go. Add Route.Issues and Route.Prs with list screens in the existing style. Issue rows open the issue's GitHub page (that is where these mirrored issues live); PR rows open the hosted repo in-app when it is one of ours, else its git-host page. Home quick links and Recent activity rows now navigate to the lists. Loading speed: refresh() fetched repos, tests, issues and prs in four sequential round trips and parsed on the main thread. The four fetches now run as parallel async children (same error state on any IOException), and GitHostRepository does fetch and parse under Dispatchers.IO, catalog included. Tests: route round-trip covers the new destinations; screens test clicks Issues/Pull requests quick links and list rows, plus both empty states; screenshot preview updated for the new HomeScreen parameters. Verified: :madeveloper:testDevUnitTest (52 tests, 0 failures), :madeveloper:lintDev, clean recompile. Not run on-device.
Diff
madeveloper/src/main/java/com/vayunmathur/madeveloper/Navigation.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/Navigation.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/Navigation.ktindex 980c0f84e4..6e4a9ccfad 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/Navigation.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/Navigation.kt@@ -2,6 +2,8 @@ package com.vayunmathur.madeveloper import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect+import androidx.compose.ui.platform.LocalContext+import com.vayunmathur.library.ui.ExternalIntents import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.madeveloper.platform.MaDevViewModel@@ -10,6 +12,8 @@ import com.vayunmathur.madeveloper.ui.CommitScreen import com.vayunmathur.madeveloper.ui.CommitsScreen import com.vayunmathur.madeveloper.ui.FileScreen import com.vayunmathur.madeveloper.ui.HomeScreen+import com.vayunmathur.madeveloper.ui.IssuesScreen+import com.vayunmathur.madeveloper.ui.PullRequestsScreen import com.vayunmathur.madeveloper.ui.PushScreen import com.vayunmathur.madeveloper.ui.RepoScreen import com.vayunmathur.madeveloper.ui.TestsScreen@@ -18,6 +22,7 @@ import com.vayunmathur.madeveloper.ui.TestsScreen @Composable fun Navigation(viewModel: MaDevViewModel) { val backStack = rememberNavBackStack<Route>(Route.Home)+ val context = LocalContext.current LaunchedEffect(Unit) { viewModel.loadHome() } MainNavigation(backStack) { entry<Route.Home> {@@ -28,6 +33,28 @@ fun Navigation(viewModel: MaDevViewModel) { onOpenTests = { backStack.add(Route.Tests) }, onOpenCatalog = { backStack.add(Route.Catalog) }, onOpenPush = { backStack.add(Route.Push) },+ onOpenIssues = { backStack.add(Route.Issues) },+ onOpenPrs = { backStack.add(Route.Prs) },+ )+ }+ entry<Route.Issues> {+ IssuesScreen(+ state = viewModel.state,+ onOpenIssue = { issue -> ExternalIntents.openUrl(context, issue.webUrl) },+ onBack = { backStack.pop() },+ )+ }+ entry<Route.Prs> {+ PullRequestsScreen(+ state = viewModel.state,+ onOpenPr = { pr ->+ if (viewModel.repoByName(pr.hostRepo) != null) {+ backStack.add(Route.Repo(pr.hostRepo))+ } else {+ ExternalIntents.openUrl(context, pr.webUrl)+ }+ },+ onBack = { backStack.pop() }, ) } entry<Route.Repo> { route ->
madeveloper/src/main/java/com/vayunmathur/madeveloper/Route.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/Route.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/Route.ktindex 7c9049900e..0b887220a5 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/Route.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/Route.kt@@ -26,6 +26,14 @@ sealed interface Route : NavKey { /** One file in a repository on a branch, shown with line numbers. */ data class File(val repo: String, val path: String, val branch: String) : Route + @Serializable+ /** Open issues across hosted repos, from the git host issues page. */+ data object Issues : Route++ @Serializable+ /** Open pull requests across hosted repos, from the git host PR page. */+ data object Prs : Route+ @Serializable /** Full CI history from the git host tests page. */ data object Tests : Route
madeveloper/src/main/java/com/vayunmathur/madeveloper/data/GitHostRepository.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/data/GitHostRepository.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/data/GitHostRepository.ktindex 6f45d34c6f..6705c24cdb 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/data/GitHostRepository.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/data/GitHostRepository.kt@@ -1,6 +1,8 @@ package com.vayunmathur.madeveloper.data import com.vayunmathur.library.network.NetworkClient+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.withContext import com.vayunmathur.madeveloper.domain.CatalogApp import com.vayunmathur.madeveloper.domain.GitCommit import com.vayunmathur.madeveloper.domain.GitFile@@ -31,11 +33,12 @@ class GitHostRepository( private var fileCache: Map<String, GitFile> = emptyMap() /** Repositories from `GET /api/repos`. */- suspend fun repos(): List<GitRepo> = GitParsers.parseRepos(fetchText("$GIT_HOST/api/repos"))+ suspend fun repos(): List<GitRepo> = withContext(Dispatchers.IO) { GitParsers.parseRepos(fetchText("$GIT_HOST/api/repos")) } /** Branches and recent commits from `GET /api/repos/<repo>`. */- suspend fun repo(name: String): RepoDetail =+ suspend fun repo(name: String): RepoDetail = withContext(Dispatchers.IO) { GitParsers.parseRepoDetail(fetchText("$GIT_HOST/api/repos/${enc(name)}"))+ } /** One page of commits; [after] is the previous page's last sha. */ suspend fun commits(name: String, branch: String, limit: Int, after: String?): List<GitCommit> {@@ -43,28 +46,29 @@ class GitHostRepository( append("?branch=").append(enc(branch)).append("&limit=").append(limit) if (!after.isNullOrBlank()) append("&after=").append(enc(after)) }- return GitParsers.parseCommits(fetchText("$GIT_HOST/api/repos/${enc(name)}/commits$query"))+ return withContext(Dispatchers.IO) { GitParsers.parseCommits(fetchText("$GIT_HOST/api/repos/${enc(name)}/commits$query")) } } /** CI status from `/tests.json`. */- suspend fun tests(): TestsStatus = fetchText("$GIT_HOST/tests.json").let(GitParsers::parseTests)+ suspend fun tests(): TestsStatus = withContext(Dispatchers.IO) { fetchText("$GIT_HOST/tests.json").let(GitParsers::parseTests) } /** Open issues from `/issues.json?view=open`. */- suspend fun issues(): List<GitIssue> = GitParsers.parseIssues(fetchText("$GIT_HOST/issues.json?view=open"))+ suspend fun issues(): List<GitIssue> = withContext(Dispatchers.IO) { GitParsers.parseIssues(fetchText("$GIT_HOST/issues.json?view=open")) } /** Open pull requests from `/prs.json`. */- suspend fun prs(): List<GitPr> = GitParsers.parsePrs(fetchText("$GIT_HOST/prs.json"))+ suspend fun prs(): List<GitPr> = withContext(Dispatchers.IO) { GitParsers.parsePrs(fetchText("$GIT_HOST/prs.json")) } /** Available builds from the first-party F-Droid repo (read-only catalog). */- suspend fun catalog(): List<CatalogApp> =+ suspend fun catalog(): List<CatalogApp> = withContext(Dispatchers.IO) { GitParsers.parseFdroidIndex(fetchText("$FDROID_BASE/index-v2.json"), FDROID_BASE)+ } /** Tree of [path] in [repo] on [branch]; cached per repo+branch+path. */ suspend fun tree(repo: String, branch: String, path: String): List<TreeEntry> { val key = "$repo:$branch:$path" treeCache[key]?.let { return it } val url = "$GIT_HOST/api/repos/${enc(repo)}/tree?branch=${enc(branch)}&path=${enc(path)}"- val entries = GitParsers.parseTree(fetchText(url), path)+ val entries = withContext(Dispatchers.IO) { GitParsers.parseTree(fetchText(url), path) } treeCache = treeCache + (key to entries) return entries }@@ -74,7 +78,7 @@ class GitHostRepository( val key = "$repo:$branch:$path" fileCache[key]?.let { return it } val url = "$GIT_HOST/api/repos/${enc(repo)}/file?branch=${enc(branch)}&path=${enc(path)}"- val file = GitParsers.parseFile(fetchText(url))+ val file = withContext(Dispatchers.IO) { GitParsers.parseFile(fetchText(url)) } fileCache = fileCache + (key to file) return file }
madeveloper/src/main/java/com/vayunmathur/madeveloper/domain/GitModels.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/domain/GitModels.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/domain/GitModels.ktindex 127e6072ff..dca0efabf2 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/domain/GitModels.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/domain/GitModels.kt@@ -56,10 +56,19 @@ data class GitFile( data class GitIssue( val repo: String, val number: Int, val title: String, val author: String, val comments: Int, val labels: List<String>, val updatedAt: String,-)+) {+ /** GitHub page for this issue; [repo] is the `owner/name` slug issues are mirrored from. */+ val webUrl: String get() = "https://github.com/$repo/issues/$number"+} /** One pull request as served by `/prs.json`. */-data class GitPr(val repo: String, val number: Int, val title: String, val author: String)+data class GitPr(val repo: String, val number: Int, val title: String, val author: String) {+ /** Hosted repository name for this PR (`Modern-Apps.git` or an `owner/name` slug). */+ val hostRepo: String get() = repo.substringAfterLast('/').removeSuffix(".git")++ /** Git host page for this PR's repository. */+ val webUrl: String get() = "https://git.maproj.org/$hostRepo"+} /** One CI run from `/tests.json`. */ data class TestRun(
madeveloper/src/main/java/com/vayunmathur/madeveloper/platform/MaDevViewModel.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/platform/MaDevViewModel.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/platform/MaDevViewModel.ktindex b2358d2fce..d87ee94320 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/platform/MaDevViewModel.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/platform/MaDevViewModel.kt@@ -35,6 +35,8 @@ import com.vayunmathur.madeveloper.domain.RepoDetail import com.vayunmathur.madeveloper.domain.TestsStatus import com.vayunmathur.madeveloper.domain.TreeEntry import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.async+import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext@@ -95,12 +97,18 @@ class MaDevViewModel(app: Application) : AndroidViewModel(app) { state = state.copy(loading = true, error = null) viewModelScope.launch { try {- val repos = repo.repos()- val tests = repo.tests()- state = state.copy(- loading = false, repos = repos, tests = tests,- issues = repo.issues(), prs = repo.prs(),- )+ // All four host fetches run concurrently; any IOException+ // cancels the rest and lands in the same error state.+ coroutineScope {+ val repos = async { repo.repos() }+ val tests = async { repo.tests() }+ val issues = async { repo.issues() }+ val prs = async { repo.prs() }+ state = state.copy(+ loading = false, repos = repos.await(), tests = tests.await(),+ issues = issues.await(), prs = prs.await(),+ )+ } } catch (e: java.io.IOException) { state = state.copy(loading = false, error = e.message ?: "Could not reach git.maproj.org") }
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.ktindex 5ecf6584fc..a510fb2bb7 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt@@ -16,7 +16,6 @@ import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.platform.MaDevUiState /** Read-only catalog of available builds; installs arrive by server push. */
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.ktindex f05f5e90f1..a7f25b83b6 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt@@ -26,7 +26,6 @@ import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.platform.MaDevViewModel
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.ktindex 809d002bf0..f46a044e38 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt@@ -20,7 +20,6 @@ import com.vayunmathur.library.ui.LoadingState import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.platform.MaDevViewModel /** Paged commit list for one repository branch. */
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.ktindex 59de3f5bb6..87d0831237 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt@@ -28,7 +28,6 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.GitFile import com.vayunmathur.madeveloper.platform.MaDevViewModel
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.ktindex 5dccf344ea..d4258bdcc1 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt@@ -35,7 +35,6 @@ import com.vayunmathur.library.ui.LoadingState import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.domain.CiStatus import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.GitRepo@@ -50,6 +49,8 @@ fun HomeScreen( onOpenTests: () -> Unit, onOpenCatalog: () -> Unit, onOpenPush: () -> Unit,+ onOpenIssues: () -> Unit,+ onOpenPrs: () -> Unit, ) { AppScaffold( title = "Developer",@@ -95,7 +96,7 @@ fun HomeScreen( } } }- item { QuickLinksSection(state, onOpenTests, onOpenCatalog, onOpenPush) }+ item { QuickLinksSection(state, onOpenTests, onOpenCatalog, onOpenPush, onOpenIssues, onOpenPrs) } if (state.loading && state.repos.isEmpty()) { item { LoadingState(message = "Loading repositories…", modifier = Modifier.fillMaxWidth().height(160.dp)) } }@@ -130,7 +131,7 @@ fun HomeScreen( } } if (state.issues.isNotEmpty() || state.prs.isNotEmpty()) {- item { ActivitySection(state) }+ item { ActivitySection(state, onOpenIssues, onOpenPrs) } } } }@@ -176,6 +177,8 @@ private fun QuickLinksSection( onOpenTests: () -> Unit, onOpenCatalog: () -> Unit, onOpenPush: () -> Unit,+ onOpenIssues: () -> Unit,+ onOpenPrs: () -> Unit, ) { DashboardSection( title = "Quick links",@@ -188,11 +191,11 @@ private fun QuickLinksSection( QuickLinkRow("Pushed installs", "Pairing and pending installs", onOpenPush) { IconInstall() } if (state.issues.isNotEmpty()) { DashboardSectionDivider()- QuickLinkRow("Issues", "${state.issues.size} open across hosted repos", {}) { IconBugReport() }+ QuickLinkRow("Issues", "${state.issues.size} open across hosted repos", onOpenIssues) { IconBugReport() } } if (state.prs.isNotEmpty()) { DashboardSectionDivider()- QuickLinkRow("Pull requests", "${state.prs.size} open across hosted repos", {}) { IconMerge() }+ QuickLinkRow("Pull requests", "${state.prs.size} open across hosted repos", onOpenPrs) { IconMerge() } } } }@@ -214,7 +217,7 @@ private fun QuickLinkRow( } @Composable-private fun ActivitySection(state: MaDevUiState) {+private fun ActivitySection(state: MaDevUiState, onOpenIssues: () -> Unit, onOpenPrs: () -> Unit) { DashboardSection(title = "Recent activity") { state.issues.take(3).forEach { issue -> ListItem(@@ -223,6 +226,7 @@ private fun ActivitySection(state: MaDevUiState) { Text("${issue.repo} #${issue.number} · ${issue.author}") }, leadingContent = { IconBugReport() },+ modifier = Modifier.clickable(onClick = onOpenIssues), ) } state.prs.take(3).forEach { pr ->@@ -230,6 +234,7 @@ private fun ActivitySection(state: MaDevUiState) { headlineContent = { Text(pr.title, maxLines = 1) }, supportingContent = { Text("${pr.repo} #${pr.number} · ${pr.author}") }, leadingContent = { IconMerge() },+ modifier = Modifier.clickable(onClick = onOpenPrs), ) } }
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/IssuesScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/IssuesScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/IssuesScreen.ktnew file mode 100644index 0000000000..ae68de6fd4--- /dev/null+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/IssuesScreen.kt@@ -0,0 +1,85 @@+package com.vayunmathur.madeveloper.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconBugReport+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing+import com.vayunmathur.library.ui.Text+import com.vayunmathur.madeveloper.domain.GitIssue+import com.vayunmathur.madeveloper.platform.MaDevUiState++/**+ * Open issues across the hosted repositories, from `/issues.json`.+ * Rows open the issue's GitHub page — that is where these issues live;+ * the git host only mirrors the listing.+ */+@Composable+fun IssuesScreen(state: MaDevUiState, onOpenIssue: (GitIssue) -> Unit, onBack: () -> Unit) {+ AppScaffold(+ title = "Issues",+ subtitle = if (state.issues.isEmpty()) null else "${state.issues.size} open",+ onNavigateBack = onBack,+ ) { padding ->+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ if (state.issues.isEmpty()) {+ item {+ EmptyState(+ title = "No open issues loaded yet.",+ message = "Pull to refresh from Home once the git host is reachable.",+ )+ }+ } else {+ item {+ DashboardSection(+ title = "Open issues",+ leadingIcon = { modifier, tint -> IconBugReport(modifier, tint) },+ ) {+ state.issues.forEachIndexed { index, issue ->+ if (index > 0) DashboardSectionDivider()+ ListItem(+ headlineContent = { Text(issue.title, maxLines = 2) },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ Text("${issue.repo} #${issue.number} · ${issue.author}")+ if (issue.labels.isNotEmpty()) {+ Text(+ issue.labels.joinToString(" · "),+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.primary,+ )+ }+ }+ },+ trailingContent = {+ if (issue.comments > 0) {+ Text(+ "${issue.comments} comments",+ style = MaterialTheme.typography.bodySmall,+ )+ }+ },+ leadingContent = { IconBugReport() },+ modifier = Modifier.clickable { onOpenIssue(issue) },+ )+ }+ }+ }+ }+ }+ }+}
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PullRequestsScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PullRequestsScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PullRequestsScreen.ktnew file mode 100644index 0000000000..846e27da5c--- /dev/null+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PullRequestsScreen.kt@@ -0,0 +1,72 @@+package com.vayunmathur.madeveloper.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconMerge+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.Spacing+import com.vayunmathur.library.ui.Text+import com.vayunmathur.madeveloper.domain.GitPr+import com.vayunmathur.madeveloper.platform.MaDevUiState++/**+ * Open pull requests across the hosted repositories, from `/prs.json`.+ * Rows open the PR's repository: hosted PRs are reviewed there, and the+ * listing carries no per-PR page of its own.+ */+@Composable+fun PullRequestsScreen(state: MaDevUiState, onOpenPr: (GitPr) -> Unit, onBack: () -> Unit) {+ AppScaffold(+ title = "Pull requests",+ subtitle = if (state.prs.isEmpty()) null else "${state.prs.size} open",+ onNavigateBack = onBack,+ ) { padding ->+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ if (state.prs.isEmpty()) {+ item {+ EmptyState(+ title = "No open pull requests loaded yet.",+ message = "Pull to refresh from Home once the git host is reachable.",+ )+ }+ } else {+ item {+ DashboardSection(+ title = "Open pull requests",+ leadingIcon = { modifier, tint -> IconMerge(modifier, tint) },+ ) {+ state.prs.forEachIndexed { index, pr ->+ if (index > 0) DashboardSectionDivider()+ ListItem(+ headlineContent = { Text(pr.title, maxLines = 2) },+ supportingContent = {+ Text(+ buildString {+ append(pr.hostRepo)+ if (pr.number > 0) append(" #${pr.number}")+ if (pr.author.isNotBlank()) append(" · ${pr.author}")+ },+ )+ },+ leadingContent = { IconMerge() },+ modifier = Modifier.clickable { onOpenPr(pr) },+ )+ }+ }+ }+ }+ }+ }+}
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.ktindex 1f92ebd58b..403be2c82b 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt@@ -18,7 +18,6 @@ import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.domain.CiStatus import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.InstallPhase
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.ktindex e7dfaa8fa4..7d5f272751 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt@@ -43,7 +43,6 @@ import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.TextField-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.FileKind import com.vayunmathur.madeveloper.domain.TreeEntry
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.ktindex a655f6ece0..19de2b523a 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt@@ -19,7 +19,6 @@ import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.TestRun import com.vayunmathur.madeveloper.platform.MaDevUiState
madeveloper/src/screenshotTest/kotlin/com/vayunmathur/madeveloper/ui/MetadataPreviews.kt
diff --git a/madeveloper/src/screenshotTest/kotlin/com/vayunmathur/madeveloper/ui/MetadataPreviews.kt b/madeveloper/src/screenshotTest/kotlin/com/vayunmathur/madeveloper/ui/MetadataPreviews.ktindex 44448a4058..244da50f06 100644--- a/madeveloper/src/screenshotTest/kotlin/com/vayunmathur/madeveloper/ui/MetadataPreviews.kt+++ b/madeveloper/src/screenshotTest/kotlin/com/vayunmathur/madeveloper/ui/MetadataPreviews.kt@@ -20,6 +20,7 @@ class MetadataPreviews { HomeScreen( state = MaDevUiState(repos = listOf(GitRepo("Modern-Apps", "main", "abc12345", "Demo commit", "2026-11-16T00:00:00Z")), pairingCode = "ABC234"), onRefresh = {}, onOpenRepo = {}, onOpenTests = {}, onOpenCatalog = {}, onOpenPush = {},+ onOpenIssues = {}, onOpenPrs = {}, ) } }
madeveloper/src/test/java/com/vayunmathur/madeveloper/platform/MaDevViewModelTest.kt
diff --git a/madeveloper/src/test/java/com/vayunmathur/madeveloper/platform/MaDevViewModelTest.kt b/madeveloper/src/test/java/com/vayunmathur/madeveloper/platform/MaDevViewModelTest.ktindex 20eaeb3401..dca58e39d7 100644--- a/madeveloper/src/test/java/com/vayunmathur/madeveloper/platform/MaDevViewModelTest.kt+++ b/madeveloper/src/test/java/com/vayunmathur/madeveloper/platform/MaDevViewModelTest.kt@@ -258,6 +258,8 @@ class MaDevRouteTest { com.vayunmathur.madeveloper.Route.Commits("Modern-Apps", "main"), com.vayunmathur.madeveloper.Route.Commit("Modern-Apps", "main", "abc123"), com.vayunmathur.madeveloper.Route.File("Modern-Apps", "src/Main.kt", "dev"),+ com.vayunmathur.madeveloper.Route.Issues,+ com.vayunmathur.madeveloper.Route.Prs, com.vayunmathur.madeveloper.Route.Tests, com.vayunmathur.madeveloper.Route.Catalog, com.vayunmathur.madeveloper.Route.Push,
madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt
diff --git a/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt b/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.ktindex 7b4d6ee103..e1fdb1efd2 100644--- a/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt+++ b/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt@@ -15,6 +15,8 @@ import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider import com.vayunmathur.madeveloper.data.GitHostRepository import com.vayunmathur.madeveloper.domain.CatalogApp+import com.vayunmathur.madeveloper.domain.GitIssue+import com.vayunmathur.madeveloper.domain.GitPr import com.vayunmathur.madeveloper.domain.InstallPhase import com.vayunmathur.madeveloper.domain.PendingInstall import com.vayunmathur.madeveloper.domain.TestRun@@ -104,6 +106,12 @@ class MaDevScreensTest { catalog = listOf( CatalogApp("com.example.app", "Example", "Demo app", "1.0", 1L, 2048L, "/a_1.apk"), ),+ issues = listOf(+ GitIssue("vayun-mathur/Modern-Apps", 7, "Bug one", "vayun", 3, listOf("bug"), "2026-01-01"),+ ),+ prs = listOf(+ GitPr("Modern-Apps", 12, "Add thing", "vayun"),+ ), ) @Test fun homeShowsCiReposAndFiresNavigation() {@@ -111,6 +119,8 @@ class MaDevScreensTest { var testsOpened = 0 var catalogOpened = 0 var pushOpened = 0+ var issuesOpened = 0+ var prsOpened = 0 var refreshes = 0 rule.setContent { HomeScreen(@@ -120,6 +130,8 @@ class MaDevScreensTest { onOpenTests = { testsOpened++ }, onOpenCatalog = { catalogOpened++ }, onOpenPush = { pushOpened++ },+ onOpenIssues = { issuesOpened++ },+ onOpenPrs = { prsOpened++ }, ) } rule.onNodeWithText("Developer").assertIsDisplayed()@@ -132,20 +144,51 @@ class MaDevScreensTest { clickRow("Pushed installs") clickRow("Test history") clickRow("Available builds")+ clickRow("Issues")+ clickRow("Pull requests") rule.onNodeWithContentDescription("Refresh").performClick() clickRow("Modern-Apps") assertEquals("Modern-Apps", openedRepo) assertEquals(1, testsOpened) assertEquals(1, catalogOpened) assertEquals(1, pushOpened)+ assertEquals(1, issuesOpened)+ assertEquals(1, prsOpened) assertEquals(1, refreshes) } + @Test fun issuesAndPullRequestsScreensFireRowClicks() {+ var openedIssue: GitIssue? = null+ var openedPr: GitPr? = null+ var page by androidx.compose.runtime.mutableStateOf(0)+ rule.setContent {+ when (page) {+ 0 -> IssuesScreen(state(), onOpenIssue = { openedIssue = it }, onBack = {})+ 1 -> PullRequestsScreen(state(), onOpenPr = { openedPr = it }, onBack = {})+ 2 -> IssuesScreen(MaDevUiState(), onOpenIssue = {}, onBack = {})+ else -> PullRequestsScreen(MaDevUiState(), onOpenPr = {}, onBack = {})+ }+ }+ rule.onNodeWithText("Bug one").assertIsDisplayed()+ clickRow("Bug one")+ assertEquals(7, openedIssue?.number)+ assertEquals("Bug one", openedIssue?.title)+ rule.runOnIdle { page = 1 }+ rule.onNodeWithText("Add thing").assertIsDisplayed()+ clickRow("Add thing")+ assertEquals(12, openedPr?.number)+ assertEquals("Add thing", openedPr?.title)+ rule.runOnIdle { page = 2 }+ rule.onNodeWithText("No open issues loaded yet.").assertIsDisplayed()+ rule.runOnIdle { page = 3 }+ rule.onNodeWithText("No open pull requests loaded yet.").assertIsDisplayed()+ }+ @Test fun homeLoadingAndErrorStatesRender() { rule.setContent { HomeScreen( MaDevUiState(loading = true, error = "HTTP 404 for repos"),- {}, {}, {}, {}, {},+ {}, {}, {}, {}, {}, {}, {}, ) } rule.onNode(androidx.compose.ui.test.hasScrollAction())@@ -155,7 +198,7 @@ class MaDevScreensTest { @Test fun homeEmptyAndLanguageChipRender() { rule.setContent {- HomeScreen(MaDevUiState(pairingCode = "ABC234"), {}, {}, {}, {}, {})+ HomeScreen(MaDevUiState(pairingCode = "ABC234"), {}, {}, {}, {}, {}, {}, {}) } rule.onNode(androidx.compose.ui.test.hasScrollAction()) .performScrollToNode(androidx.compose.ui.test.hasText("No repositories"))