GeezerVison is showing github.com — OPE-63 Fix add-project listing, persistence, and iOS sheet presentation. · opencode-mobile/opencode-mobile@2fdb1fb
File treeExpand file treeCollapse file tree Open diff view settings main/java/dev/opencode/mobile componentgallery/components
test/java/dev/opencode/mobile/ui/main
ComponentGallery/Components md_arrow_downward.imageset md_subdirectory_arrow_right.imageset
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/data/remote/FilesystemApi.kt +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ package dev.opencode.mobile.data.remote | 3 | 3 | import dev.opencode.mobile.data.remote.dto.FileNodeDto | 4 | 4 | import dev.opencode.mobile.data.remote.dto.PathDto | 5 | 5 | import dev.opencode.mobile.network.OpencodeHttpClient | | 6 | +import dev.opencode.mobile.network.applyDirectory | 6 | 7 | import io.ktor.client.call.body | 7 | 8 | import io.ktor.client.request.get | 8 | 9 | import io.ktor.client.request.parameter | @@ -12,10 +13,12 @@ class FilesystemApi( | 12 | 13 | ) { | 13 | 14 | suspend fun getPaths(): PathDto = httpClient.get().get("path").body() | 14 | 15 |
| 15 | | - suspend fun listFiles(path: String): List<FileNodeDto> = | | 16 | + // Lists absoluteDirectory via path=. + directory= so paths outside the boot worktree work. | | 17 | + suspend fun listFiles(absoluteDirectory: String): List<FileNodeDto> = | 16 | 18 | httpClient | 17 | 19 | .get() | 18 | 20 | .get("file") { | 19 | | - parameter("path", path) | | 21 | + parameter("path", ".") | | 22 | + applyDirectory(absoluteDirectory) | 20 | 23 | }.body() | 21 | 24 | } |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/domain/filesystem/DefaultFilesystemRepository.kt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,5 +12,5 @@ class DefaultFilesystemRepository | 12 | 12 | override suspend fun getPaths(): ServerPaths = adapter.toServerPaths(api.getPaths()) | 13 | 13 |
| 14 | 14 | override suspend fun listDirectory(path: String): List<DirectoryNode> = | 15 | | - DirectoryListingPolicy.prepare(api.listFiles(path).map(adapter::toDirectoryNode)) | | 15 | + DirectoryListingPolicy.prepare(api.listFiles(absoluteDirectory = path).map(adapter::toDirectoryNode)) | 16 | 16 | } |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/ui/componentgallery/components/BottomSheetGalleryScreen.kt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -114,7 +114,7 @@ fun BottomSheetGalleryScreen(modifier: Modifier = Modifier) { | 114 | 114 | ) | 115 | 115 | OpenCodeBottomSheetEntry( | 116 | 116 | title = "/Users/demo/Projects", | 117 | | - startDecorator = BottomSheetEntryDecorator.Icon(OpenCodeIcons.Folder, null), | | 117 | + startDecorator = BottomSheetEntryDecorator.Icon(OpenCodeIcons.FolderCheck, null), | 118 | 118 | onClick = {}, | 119 | 119 | ) | 120 | 120 | } | |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/ui/componentgallery/components/IconsGalleryScreen.kt +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,13 +39,15 @@ fun IconsGalleryScreen(modifier: Modifier = Modifier) { | 39 | 39 | "edit" to OpenCodeIcons.Edit, | 40 | 40 | "expand_content" to OpenCodeIcons.ExpandContent, | 41 | 41 | "folder" to OpenCodeIcons.Folder, | | 42 | + "folder_check" to OpenCodeIcons.FolderCheck, | 42 | 43 | "more_vert" to OpenCodeIcons.MoreVert, | 43 | 44 | "search" to OpenCodeIcons.Search, | 44 | 45 | "architecture" to OpenCodeIcons.Architecture, | 45 | 46 | "archive" to OpenCodeIcons.Archive, | 46 | 47 | "cloud" to OpenCodeIcons.Cloud, | 47 | 48 | "stop" to OpenCodeIcons.Stop, | 48 | 49 | "stop_circle" to OpenCodeIcons.StopCircle, | | 50 | + "subdirectory_arrow_right" to OpenCodeIcons.SubdirectoryArrowRight, | 49 | 51 | "undo" to OpenCodeIcons.Undo, | 50 | 52 | "widgets" to OpenCodeIcons.Widgets, | 51 | 53 | ) | |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/ui/icons/OpenCodeIcons.kt +45Lines changed: 45 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,7 @@ private var _description: ImageVector? = null | 23 | 23 | private var _edit: ImageVector? = null | 24 | 24 | private var _expand_content: ImageVector? = null | 25 | 25 | private var _folder: ImageVector? = null | | 26 | +private var _folder_check: ImageVector? = null | 26 | 27 | private var _list: ImageVector? = null | 27 | 28 | private var _more_vert: ImageVector? = null | 28 | 29 | private var _search: ImageVector? = null | @@ -32,6 +33,7 @@ private var _archive: ImageVector? = null | 32 | 33 | private var _cloud: ImageVector? = null | 33 | 34 | private var _stop: ImageVector? = null | 34 | 35 | private var _stop_circle: ImageVector? = null | | 36 | +private var _subdirectory_arrow_right: ImageVector? = null | 35 | 37 | private var _undo: ImageVector? = null | 36 | 38 | private var _widgets: ImageVector? = null | 37 | 39 |
| @@ -292,6 +294,30 @@ private var _widgets: ImageVector? = null | 292 | 294 | return _folder!! | 293 | 295 | } | 294 | 296 |
| | 297 | + val FolderCheck: ImageVector | | 298 | + get() { | | 299 | + if (_folder_check != null) return _folder_check!! | | 300 | + _folder_check = ImageVector.Builder( | | 301 | + name = "FolderCheck", | | 302 | + defaultWidth = 24.dp, | | 303 | + defaultHeight = 24.dp, | | 304 | + viewportWidth = 960f, | | 305 | + viewportHeight = 960f, | | 306 | + ).apply { | | 307 | + group( | | 308 | + translationX = 0f, | | 309 | + translationY = 960f, | | 310 | + ) { | | 311 | + addPath( | | 312 | + pathData = PathParser().parsePathString("m434-297 226-227-56-56-170 170-85-85-57 57 142 141ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z").toNodes(), | | 313 | + fill = SolidColor(Color.Black), | | 314 | + pathFillType = PathFillType.NonZero, | | 315 | + ) | | 316 | + } | | 317 | + }.build() | | 318 | + return _folder_check!! | | 319 | + } | | 320 | + | 295 | 321 | val List: ImageVector | 296 | 322 | get() { | 297 | 323 | if (_list != null) return _list!! | @@ -463,6 +489,25 @@ private var _widgets: ImageVector? = null | 463 | 489 | return _stop_circle!! | 464 | 490 | } | 465 | 491 |
| | 492 | + val SubdirectoryArrowRight: ImageVector | | 493 | + get() { | | 494 | + if (_subdirectory_arrow_right != null) return _subdirectory_arrow_right!! | | 495 | + _subdirectory_arrow_right = ImageVector.Builder( | | 496 | + name = "SubdirectoryArrowRight", | | 497 | + defaultWidth = 24.dp, | | 498 | + defaultHeight = 24.dp, | | 499 | + viewportWidth = 24f, | | 500 | + viewportHeight = 24f, | | 501 | + ).apply { | | 502 | + addPath( | | 503 | + pathData = PathParser().parsePathString("m19 15-6 6-1.42-1.42L15.17 16H4V4h2v10h9.17l-3.59-3.58L13 9l6 6z").toNodes(), | | 504 | + fill = SolidColor(Color.Black), | | 505 | + pathFillType = PathFillType.NonZero, | | 506 | + ) | | 507 | + }.build() | | 508 | + return _subdirectory_arrow_right!! | | 509 | + } | | 510 | + | 466 | 511 | val Undo: ImageVector | 467 | 512 | get() { | 468 | 513 | if (_undo != null) return _undo!! | |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/ui/main/MainScreen.kt +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -218,7 +218,7 @@ internal fun MainScreen( | 218 | 218 | enabled = navigator.currentPath.isNotBlank() && !navigator.isLoading && !navigator.isValidating, | 219 | 219 | startDecorator = | 220 | 220 | BottomSheetEntryDecorator.Icon( | 221 | | - imageVector = OpenCodeIcons.Folder, | | 221 | + imageVector = OpenCodeIcons.FolderCheck, | 222 | 222 | contentDescription = null, | 223 | 223 | ), | 224 | 224 | onClick = onSelectCurrentDirectory, | @@ -263,7 +263,7 @@ internal fun MainScreen( | 263 | 263 | title = entry.name, | 264 | 264 | startDecorator = | 265 | 265 | BottomSheetEntryDecorator.Icon( | 266 | | - imageVector = OpenCodeIcons.Folder, | | 266 | + imageVector = OpenCodeIcons.SubdirectoryArrowRight, | 267 | 267 | contentDescription = null, | 268 | 268 | ), | 269 | 269 | onClick = { onNavigateAddProjectInto(entry.absolutePath) }, | |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/ui/main/MainScreenViewModel.kt +9-7Lines changed: 9 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,9 +156,11 @@ class MainScreenViewModel | 156 | 156 | updateAddProjectNavigator { it.copy(isValidating = true, errorMessage = null) } | 157 | 157 | val result = runCatching { projectRepository.getCurrentProject(directory = worktree) } | 158 | 158 | result | 159 | | - .onSuccess { project -> | 160 | | - connectionProfileStore.addWorktree(serverBaseUrl, project.worktree) | 161 | | - requestedFocusWorktree = project.worktree | | 159 | + .onSuccess { | | 160 | + // Persist the selected directory (web open-project behavior), not the | | 161 | + // /project/current worktree — non-git dirs resolve to global "/". | | 162 | + connectionProfileStore.addWorktree(serverBaseUrl, worktree) | | 163 | + requestedFocusWorktree = worktree | 162 | 164 | dismissAddProjectSheet() | 163 | 165 | runHomeLoad(skipProbe = true) | 164 | 166 | }.onFailure { error -> | @@ -321,7 +323,7 @@ class MainScreenViewModel | 321 | 323 | } | 322 | 324 |
| 323 | 325 | private suspend fun loadSection(worktree: String): ProjectSectionUi { | 324 | | - val project = projectRepository.getCurrentProject(directory = worktree) | | 326 | + projectRepository.getCurrentProject(directory = worktree) | 325 | 327 | val sessions = | 326 | 328 | sessionRepository | 327 | 329 | .listSessions(directory = worktree) | @@ -340,9 +342,9 @@ class MainScreenViewModel | 340 | 342 | } | 341 | 343 | return ProjectSectionUi( | 342 | 344 | worktree = worktree, | 343 | | - displayName = project.displayName, | 344 | | - pathSubtitle = project.worktree, | 345 | | - letter = letterCharacterForProject(project.displayName), | | 345 | + displayName = ProjectDomainAdapter.displayNameFromWorktree(worktree), | | 346 | + pathSubtitle = worktree, | | 347 | + letter = letterCharacterForProject(ProjectDomainAdapter.displayNameFromWorktree(worktree)), | 346 | 348 | letterAccent = letterAccentForWorktree(worktree), | 347 | 349 | previewSessions = summaries.take(PREVIEW_SESSION_LIMIT), | 348 | 350 | allSessions = summaries, | |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/test/java/dev/opencode/mobile/ui/main/MainScreenViewModelTest.kt +75Lines changed: 75 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -288,6 +288,77 @@ class MainScreenViewModelTest { | 288 | 288 | assertEquals(setOf("/one", "/two"), projectRepository.validatedDirectories.toSet()) | 289 | 289 | } | 290 | 290 |
| | 291 | + @Test | | 292 | + fun selectCurrentDirectory_persistsSelectedPathEvenWhenCurrentResolvesGlobal() = | | 293 | + runTest(testDispatcher) { | | 294 | + val store = FakeConnectionProfileStore(initial = listOf("/one")) | | 295 | + val projectRepository = | | 296 | + FakeProjectRepository( | | 297 | + bootWorktree = "/one", | | 298 | + projectsByDirectory = | | 299 | + mapOf( | | 300 | + "/home" to Project(id = "global", worktree = "/", displayName = "/"), | | 301 | + ), | | 302 | + ) | | 303 | + val filesystem = | | 304 | + FakeFilesystemRepository( | | 305 | + paths = ServerPaths(home = "/home", directory = "/home", worktree = "/"), | | 306 | + listings = mapOf("/home" to emptyList()), | | 307 | + ) | | 308 | + val viewModel = | | 309 | + createViewModel( | | 310 | + connectionProfileStore = store, | | 311 | + projectRepository = projectRepository, | | 312 | + filesystemRepository = filesystem, | | 313 | + sessionsByWorktree = mapOf("/one" to emptyList(), "/home" to emptyList()), | | 314 | + ) | | 315 | + advanceUntilIdle() | | 316 | + viewModel.showAddProjectSheet() | | 317 | + advanceUntilIdle() | | 318 | + viewModel.selectCurrentDirectory() | | 319 | + advanceUntilIdle() | | 320 | + val loaded = viewModel.uiState.value as MainScreenUiState.Loaded | | 321 | + assertEquals(listOf("/one", "/home"), store.added(serverUrl)) | | 322 | + assertEquals("/home", loaded.focusedWorktree) | | 323 | + assertTrue(!loaded.showAddProjectSheet) | | 324 | + } | | 325 | + | | 326 | + @Test | | 327 | + fun selectCurrentDirectory_nestedPathPersistsSelectedDirectory() = | | 328 | + runTest(testDispatcher) { | | 329 | + val store = FakeConnectionProfileStore(initial = listOf("/one")) | | 330 | + val projectRepository = | | 331 | + FakeProjectRepository( | | 332 | + bootWorktree = "/one", | | 333 | + projectsByDirectory = | | 334 | + mapOf( | | 335 | + "/repo/android" to | | 336 | + Project(id = "repo", worktree = "/repo", displayName = "repo"), | | 337 | + ), | | 338 | + ) | | 339 | + val filesystem = | | 340 | + FakeFilesystemRepository( | | 341 | + paths = ServerPaths(home = "/repo/android", directory = "/repo/android", worktree = "/"), | | 342 | + listings = mapOf("/repo/android" to emptyList()), | | 343 | + ) | | 344 | + val viewModel = | | 345 | + createViewModel( | | 346 | + connectionProfileStore = store, | | 347 | + projectRepository = projectRepository, | | 348 | + filesystemRepository = filesystem, | | 349 | + sessionsByWorktree = mapOf("/one" to emptyList(), "/repo/android" to emptyList()), | | 350 | + ) | | 351 | + advanceUntilIdle() | | 352 | + viewModel.showAddProjectSheet() | | 353 | + advanceUntilIdle() | | 354 | + viewModel.selectCurrentDirectory() | | 355 | + advanceUntilIdle() | | 356 | + val loaded = viewModel.uiState.value as MainScreenUiState.Loaded | | 357 | + assertEquals(listOf("/one", "/repo/android"), store.added(serverUrl)) | | 358 | + assertEquals("/repo/android", loaded.focusedWorktree) | | 359 | + assertTrue(!loaded.showAddProjectSheet) | | 360 | + } | | 361 | + | 291 | 362 | @Test | 292 | 363 | fun selectCurrentDirectory_validationFailureKeepsSheetOpen() = | 293 | 364 | runTest(testDispatcher) { | @@ -479,6 +550,7 @@ private class FakeProjectRepository( | 479 | 550 | private val shouldFailProbe: Boolean = false, | 480 | 551 | private val bootWorktree: String = "/boot/project", | 481 | 552 | private val currentProjectError: Throwable? = null, | | 553 | + private val projectsByDirectory: Map<String, Project> = emptyMap(), | 482 | 554 | ) : ProjectRepository { | 483 | 555 | val validatedDirectories = mutableListOf<String?>() | 484 | 556 |
| @@ -491,6 +563,9 @@ private class FakeProjectRepository( | 491 | 563 | override suspend fun getCurrentProject(directory: String?): Project { | 492 | 564 | validatedDirectories += directory | 493 | 565 | currentProjectError?.let { throw it } | | 566 | + if (directory != null) { | | 567 | + projectsByDirectory[directory]?.let { return it } | | 568 | + } | 494 | 569 | return Project(id = "p1", worktree = directory ?: bootWorktree, displayName = "demo") | 495 | 570 | } | 496 | 571 | } | |
Collapse file Copy file name to clipboardExpand all lines: api/opencode-projects.openapi.yaml +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,17 @@ paths: | 33 | 33 | - name: path | 34 | 34 | in: query | 35 | 35 | required: true | | 36 | + description: > | | 37 | + Path relative to the scoped instance directory. Use `.` when | | 38 | + browsing an absolute directory via the `directory` query parameter. | | 39 | + schema: | | 40 | + type: string | | 41 | + - name: directory | | 42 | + in: query | | 43 | + description: > | | 44 | + Absolute directory that becomes the server instance scope for this | | 45 | + request. Required when listing outside the server boot directory | | 46 | + (e.g. browsing home for Add project). | 36 | 47 | schema: | 37 | 48 | type: string | 38 | 49 | responses: | |
Collapse file Copy file name to clipboardExpand all lines: docs/design-system/icons.md +2-1Lines changed: 2 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,7 +34,8 @@ Some catalog icons have a stable product meaning beyond gallery samples: | 34 | 34 | | --- | --- | | 35 | 35 | | `widgets` | Home top-bar action that opens the developer-only Component Gallery (`accessibilityLabel`: Developer components) | | 36 | 36 | | `add` | **Add project** tile on home (start decorator) | | 37 | | -| `folder` | Directory rows and current path in Add project sheet | | | 37 | +| `folder_check` | **Current directory** row in Add project sheet | | | 38 | +| `subdirectory_arrow_right` | Subdirectory rows in Add project sheet | | 38 | 39 | | `arrow_upward` | **Go up** row in Add project sheet | | 39 | 40 | | `edit` | Edit/rename affordances in gallery and samples; not the gallery entry on home | | 40 | 41 | | `archive` | Session Chat overflow **Archive** action | | |
|