GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(project-selection): curated multi-project home on iOS and Android · opencode-mobile/opencode-mobile@4d99d0d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • CONTEXT.md
  • android
    • app
      • build.gradle.kts
      • src
        • main/java/dev/opencode/mobile
          • Navigation.kt
          • NavigationKeys.kt
          • data
            • local
              • ConnectionProfilePreferences.kt
              • DataStoreConnectionProfileStore.kt
            • remote
              • HealthApi.kt
              • MessagesApi.kt
              • ProjectsApi.kt
              • SessionsApi.kt
              • dto
                • ProjectDtos.kt
          • di
            • ConnectionModule.kt
            • ProjectModule.kt
          • domain
            • connection
              • ConnectionProfileStore.kt
            • message
              • DefaultMessageRepository.kt
              • MessageRepository.kt
            • project
              • DefaultProjectRepository.kt
              • ProjectDomainAdapter.kt
              • ProjectModels.kt
              • ProjectRepository.kt
            • session
              • DefaultSessionRepository.kt
              • SessionDomainAdapter.kt
              • SessionModels.kt
              • SessionRepository.kt
          • network
            • DirectoryQuery.kt
          • theme
            • WorktreeLetterAccent.kt
          • ui
            • componentgallery/components
              • IconsGalleryScreen.kt
            • icons
              • OpenCodeIcons.kt
            • main
              • MainScreen.kt
              • MainScreenViewModel.kt
            • sessionchat
              • SessionChatScreen.kt
              • SessionChatViewModel.kt
        • test/java/dev/opencode/mobile
          • data/local
            • ConnectionProfileStoreTest.kt
          • ui
            • main
              • MainScreenViewModelTest.kt
            • sessionchat
              • SessionChatViewModelTest.kt
    • gradle
      • libs.versions.toml
  • api
    • opencode-projects.openapi.yaml
  • docs
    • design-system
      • icons.md
    • feasibility.md
    • features
      • project-list-home
        • decisions.md
        • plan.md
      • project-selection
        • decisions.md
        • manual-test.md
        • parity-gaps.md
        • plan.md
        • progress.md
      • sync-probe
        • plan.md
  • icons
    • .manifest-hash
    • manifest.yaml
  • ios/OpenCode Mobile
    • OpenCode MobileTests
      • ConnectionProfileStoreTests.swift
      • ProjectListHomeViewModelTests.swift
      • SessionChatViewModelTests.swift
    • OpenCode Mobile
      • DI
        • AppContainer.swift
      • Data/Remote
        • MessagesAPIClient.swift
        • ProjectDTOs.swift
        • ProjectsAPIClient.swift
        • SessionDTOs.swift
        • SessionsAPIClient.swift
      • Domain
        • Connection
          • ConnectionProfileStore.swift
        • Message
          • MessageRepository.swift
        • Project
          • ProjectDomainAdapter.swift
          • ProjectModels.swift
          • ProjectRepository.swift
        • Session
          • SessionDomainAdapter.swift
          • SessionModels.swift
          • SessionRepository.swift
      • Icons
        • OpenCodeIcon.swift
      • MaterialIcons.xcassets/md_widgets.imageset
        • Contents.json
        • icon.svg
      • Network
        • DirectoryQuery.swift
        • ServerConnection.swift
      • ProjectListHomeView.swift
      • ProjectListHomeViewModel.swift
      • SessionChatView.swift
      • SessionChatViewModel.swift
      • WorktreeLetterAccent.swift

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CONTEXT.md‎

Copy file name to clipboardExpand all lines: CONTEXT.md
+19-8Lines changed: 19 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ sessions from native iOS and Android apps.
55

66
The project documents product scope, feasibility, and native app architecture.
77
App shells exist under `android/` and `ios/OpenCode Mobile/`. Session list home
8-
loads real sessions via **Session Repository**; Session Chat loads messages and
9-
sends async prompts via **Message Repository** (hand-written HTTP clients; see
10-
`docs/features/session-repository/` and `docs/features/message-repository/`).
8+
loads curated **added projects** and sessions via **Project Selection**;
9+
**Session Repository** and **Message Repository** scope calls with `directory`;
10+
Session Chat sends async prompts (see `docs/features/project-selection/`,
11+
`docs/features/session-repository/`, `docs/features/message-repository/`).
1112
OpenAPI fetch tooling and maintained sessions/messages specs exist; full `/doc`
1213
codegen is not wired into app builds yet.
1314
Release processes are not started.
@@ -41,16 +42,26 @@ does not provide that transport.
4142

4243
A saved mobile configuration for one reachable opencode server.
4344

44-
A Connection Profile includes the server base URL, authentication fields, and
45-
the result of a health check. It represents how the mobile client reaches
45+
A Connection Profile includes the server base URL, authentication fields, the
46+
result of a health check, and an ordered list of **added project** worktree paths
47+
the user chose to show on home. It represents how the mobile client reaches
4648
opencode, not a user account.
4749

50+
### Added project
51+
52+
A development project worktree the user explicitly added to the home list for a
53+
Connection Profile.
54+
55+
Adding a project is local curation only; it does not create a project on the
56+
server. The app scopes API calls with that worktree path.
57+
4858
### current project
4959

50-
The development project currently served by an opencode server.
60+
The project context the opencode server uses for a request.
5161

52-
The mobile client may display project information returned by the server, but v1
53-
does not promise project switching or project launching.
62+
When the mobile client sends `directory={worktree}` on API calls, **current
63+
project** means that worktree. With no `directory` parameter, it means the
64+
server process boot worktree (`GET /project/current` without a query).
5465

5566
### session
5667

Collapse file

‎android/app/build.gradle.kts‎

Copy file name to clipboardExpand all lines: android/app/build.gradle.kts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,5 @@ dependencies {
8585
implementation(libs.ktor.serialization.kotlinx.json)
8686
implementation(libs.ktor.client.auth)
8787
implementation(libs.kotlinx.serialization.json)
88+
implementation(libs.androidx.datastore.preferences)
8889
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/Navigation.kt‎

Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/Navigation.kt
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ fun MainNavigation() {
6161
entry<ProjectListHome> {
6262
MainScreen(
6363
onDeveloperComponentsClick = { backStack.add(ComponentGalleryHome) },
64-
onSessionClick = { session -> backStack.add(SessionChat(session.id, session.title)) },
64+
onSessionClick = { target ->
65+
backStack.add(SessionChat(target.sessionId, target.title, target.worktree))
66+
},
6567
)
6668
}
6769
entry<ComponentGalleryHome> {
@@ -91,6 +93,7 @@ fun MainNavigation() {
9193
SessionChatScreen(
9294
sessionId = key.sessionId,
9395
sessionTitle = key.sessionTitle,
96+
worktree = key.worktree,
9497
onNavigateBack = { backStack.removeLastOrNull() },
9598
)
9699
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/NavigationKeys.kt‎

Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/NavigationKeys.kt
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import kotlinx.serialization.Serializable
88
@Serializable data object ComponentGalleryHome : NavKey
99

1010
@Serializable data class ComponentGalleryDetail(val entryId: ComponentGalleryEntryId) : NavKey
11-
@Serializable data class SessionChat(val sessionId: String, val sessionTitle: String) : NavKey
11+
@Serializable data class SessionChat(val sessionId: String, val sessionTitle: String, val worktree: String) : NavKey
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/data/local/ConnectionProfilePreferences.kt‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dev.opencode.mobile.data.local
2+
3+
import android.content.Context
4+
import androidx.datastore.core.DataStore
5+
import androidx.datastore.preferences.core.Preferences
6+
import androidx.datastore.preferences.preferencesDataStore
7+
8+
val Context.connectionProfileDataStore: DataStore<Preferences> by
9+
preferencesDataStore(name = "connection_profiles")
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/data/local/DataStoreConnectionProfileStore.kt‎

Copy file name to clipboard
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package dev.opencode.mobile.data.local
2+
3+
import android.content.Context
4+
import androidx.datastore.preferences.core.edit
5+
import androidx.datastore.preferences.core.stringPreferencesKey
6+
import dagger.hilt.android.qualifiers.ApplicationContext
7+
import dev.opencode.mobile.domain.connection.ConnectionProfileStore
8+
import javax.inject.Inject
9+
import kotlinx.coroutines.flow.first
10+
import kotlinx.serialization.encodeToString
11+
import kotlinx.serialization.json.Json
12+
13+
class DataStoreConnectionProfileStore
14+
@Inject
15+
constructor(
16+
@ApplicationContext private val context: Context,
17+
private val json: Json,
18+
) : ConnectionProfileStore {
19+
override suspend fun addedWorktrees(serverBaseUrl: String): List<String> {
20+
val prefs = context.connectionProfileDataStore.data.first()
21+
return decodeWorktrees(prefs[stringPreferencesKey(serverBaseUrl)])
22+
}
23+
24+
override suspend fun addWorktree(serverBaseUrl: String, worktree: String) {
25+
context.connectionProfileDataStore.edit { prefs ->
26+
val key = stringPreferencesKey(serverBaseUrl)
27+
val current = decodeWorktrees(prefs[key]).toMutableList()
28+
if (worktree !in current) {
29+
current.add(worktree)
30+
prefs[key] = json.encodeToString(current)
31+
}
32+
}
33+
}
34+
35+
private fun decodeWorktrees(raw: String?): List<String> {
36+
if (raw.isNullOrBlank()) return emptyList()
37+
return runCatching { json.decodeFromString<List<String>>(raw) }.getOrDefault(emptyList())
38+
}
39+
40+
override suspend fun setAddedWorktrees(serverBaseUrl: String, worktrees: List<String>) {
41+
context.connectionProfileDataStore.edit { prefs ->
42+
prefs[stringPreferencesKey(serverBaseUrl)] = json.encodeToString(worktrees.distinct())
43+
}
44+
}
45+
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/data/remote/HealthApi.kt‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.opencode.mobile.data.remote
2+
3+
import dev.opencode.mobile.data.remote.dto.HealthDto
4+
import io.ktor.client.HttpClient
5+
import io.ktor.client.call.body
6+
import io.ktor.client.request.get
7+
8+
class HealthApi(
9+
private val httpClient: HttpClient,
10+
) {
11+
suspend fun getHealth(): HealthDto = httpClient.get("global/health").body()
12+
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/data/remote/MessagesApi.kt‎

Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/data/remote/MessagesApi.kt
+24-8Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dev.opencode.mobile.data.remote
22

33
import dev.opencode.mobile.data.remote.dto.MessageDto
44
import dev.opencode.mobile.data.remote.dto.SendMessageRequestDto
5+
import dev.opencode.mobile.network.applyDirectory
56
import io.ktor.client.HttpClient
67
import io.ktor.client.call.body
78
import io.ktor.client.request.get
@@ -13,17 +14,32 @@ import io.ktor.http.isSuccess
1314
class MessagesApi(
1415
private val httpClient: HttpClient,
1516
) {
16-
suspend fun listMessages(sessionId: String): List<MessageDto> =
17-
httpClient.get("session/$sessionId/message").body()
17+
suspend fun listMessages(sessionId: String, directory: String? = null): List<MessageDto> =
18+
httpClient.get("session/$sessionId/message") {
19+
applyDirectory(directory)
20+
}.body()
1821

19-
suspend fun getMessage(sessionId: String, messageId: String): MessageDto =
20-
httpClient.get("session/$sessionId/message/$messageId").body()
22+
suspend fun getMessage(sessionId: String, messageId: String, directory: String? = null): MessageDto =
23+
httpClient.get("session/$sessionId/message/$messageId") {
24+
applyDirectory(directory)
25+
}.body()
2126

22-
suspend fun sendMessage(sessionId: String, body: SendMessageRequestDto): MessageDto =
23-
httpClient.post("session/$sessionId/message") { setBody(body) }.body()
27+
suspend fun sendMessage(
28+
sessionId: String,
29+
body: SendMessageRequestDto,
30+
directory: String? = null,
31+
): MessageDto =
32+
httpClient.post("session/$sessionId/message") {
33+
applyDirectory(directory)
34+
setBody(body)
35+
}.body()
2436

25-
suspend fun sendPromptAsync(sessionId: String, body: SendMessageRequestDto) {
26-
val response: HttpResponse = httpClient.post("session/$sessionId/prompt_async") { setBody(body) }
37+
suspend fun sendPromptAsync(sessionId: String, body: SendMessageRequestDto, directory: String? = null) {
38+
val response: HttpResponse =
39+
httpClient.post("session/$sessionId/prompt_async") {
40+
applyDirectory(directory)
41+
setBody(body)
42+
}
2743
if (!response.status.isSuccess()) {
2844
error("prompt_async failed with status ${response.status.value}")
2945
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/data/remote/ProjectsApi.kt‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.opencode.mobile.data.remote
2+
3+
import dev.opencode.mobile.data.remote.dto.ProjectDto
4+
import dev.opencode.mobile.network.applyDirectory
5+
import io.ktor.client.HttpClient
6+
import io.ktor.client.call.body
7+
import io.ktor.client.request.get
8+
9+
class ProjectsApi(
10+
private val httpClient: HttpClient,
11+
) {
12+
suspend fun listProjects(): List<ProjectDto> = httpClient.get("project").body()
13+
14+
suspend fun getCurrentProject(directory: String? = null): ProjectDto =
15+
httpClient.get("project/current") {
16+
applyDirectory(directory)
17+
}.body()
18+
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/data/remote/SessionsApi.kt‎

Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/data/remote/SessionsApi.kt
+83-33Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import dev.opencode.mobile.data.remote.dto.SessionDto
1010
import dev.opencode.mobile.data.remote.dto.SummarizeSessionRequestDto
1111
import dev.opencode.mobile.data.remote.dto.TodoDto
1212
import dev.opencode.mobile.data.remote.dto.UpdateSessionRequestDto
13+
import dev.opencode.mobile.network.applyDirectory
1314
import io.ktor.client.HttpClient
1415
import io.ktor.client.call.body
1516
import io.ktor.client.request.delete
@@ -23,65 +24,114 @@ import kotlinx.serialization.json.JsonObject
2324
class SessionsApi(
2425
private val httpClient: HttpClient,
2526
) {
26-
suspend fun listSessions(): List<SessionDto> =
27-
httpClient.get("session").body()
27+
suspend fun listSessions(directory: String? = null): List<SessionDto> =
28+
httpClient.get("session") {
29+
applyDirectory(directory)
30+
}.body()
2831

29-
suspend fun createSession(body: CreateSessionRequestDto): SessionDto =
30-
httpClient.post("session") { setBody(body) }.body()
32+
suspend fun createSession(body: CreateSessionRequestDto, directory: String? = null): SessionDto =
33+
httpClient.post("session") {
34+
applyDirectory(directory)
35+
setBody(body)
36+
}.body()
3137

32-
suspend fun getAllSessionStatuses(): Map<String, JsonObject> =
33-
httpClient.get("session/status").body()
38+
suspend fun getAllSessionStatuses(directory: String? = null): Map<String, JsonObject> =
39+
httpClient.get("session/status") {
40+
applyDirectory(directory)
41+
}.body()
3442

35-
suspend fun getSession(id: String): SessionDto =
36-
httpClient.get("session/$id").body()
43+
suspend fun getSession(id: String, directory: String? = null): SessionDto =
44+
httpClient.get("session/$id") {
45+
applyDirectory(directory)
46+
}.body()
3747

38-
suspend fun updateSession(id: String, body: UpdateSessionRequestDto): SessionDto =
39-
httpClient.patch("session/$id") { setBody(body) }.body()
48+
suspend fun updateSession(id: String, body: UpdateSessionRequestDto, directory: String? = null): SessionDto =
49+
httpClient.patch("session/$id") {
50+
applyDirectory(directory)
51+
setBody(body)
52+
}.body()
4053

41-
suspend fun deleteSession(id: String): Boolean =
42-
httpClient.delete("session/$id").body()
54+
suspend fun deleteSession(id: String, directory: String? = null): Boolean =
55+
httpClient.delete("session/$id") {
56+
applyDirectory(directory)
57+
}.body()
4358

44-
suspend fun listChildSessions(id: String): List<SessionDto> =
45-
httpClient.get("session/$id/children").body()
59+
suspend fun listChildSessions(id: String, directory: String? = null): List<SessionDto> =
60+
httpClient.get("session/$id/children") {
61+
applyDirectory(directory)
62+
}.body()
4663

47-
suspend fun listSessionTodos(id: String): List<TodoDto> =
48-
httpClient.get("session/$id/todo").body()
64+
suspend fun listSessionTodos(id: String, directory: String? = null): List<TodoDto> =
65+
httpClient.get("session/$id/todo") {
66+
applyDirectory(directory)
67+
}.body()
4968

50-
suspend fun initializeSessionAgents(id: String, body: InitSessionRequestDto): Boolean =
51-
httpClient.post("session/$id/init") { setBody(body) }.body()
69+
suspend fun initializeSessionAgents(
70+
id: String,
71+
body: InitSessionRequestDto,
72+
directory: String? = null,
73+
): Boolean =
74+
httpClient.post("session/$id/init") {
75+
applyDirectory(directory)
76+
setBody(body)
77+
}.body()
5278

53-
suspend fun forkSession(id: String, body: ForkSessionRequestDto): SessionDto =
54-
httpClient.post("session/$id/fork") { setBody(body) }.body()
79+
suspend fun forkSession(id: String, body: ForkSessionRequestDto, directory: String? = null): SessionDto =
80+
httpClient.post("session/$id/fork") {
81+
applyDirectory(directory)
82+
setBody(body)
83+
}.body()
5584

56-
suspend fun abortSession(id: String): Boolean =
57-
httpClient.post("session/$id/abort").body()
85+
suspend fun abortSession(id: String, directory: String? = null): Boolean =
86+
httpClient.post("session/$id/abort") {
87+
applyDirectory(directory)
88+
}.body()
5889

59-
suspend fun shareSession(id: String): SessionDto =
60-
httpClient.post("session/$id/share").body()
90+
suspend fun shareSession(id: String, directory: String? = null): SessionDto =
91+
httpClient.post("session/$id/share") {
92+
applyDirectory(directory)
93+
}.body()
6194

62-
suspend fun unshareSession(id: String): SessionDto =
63-
httpClient.delete("session/$id/share").body()
95+
suspend fun unshareSession(id: String, directory: String? = null): SessionDto =
96+
httpClient.delete("session/$id/share") {
97+
applyDirectory(directory)
98+
}.body()
6499

65-
suspend fun getSessionDiff(id: String, messageId: String?): List<FileDiffDto> =
100+
suspend fun getSessionDiff(id: String, messageId: String?, directory: String? = null): List<FileDiffDto> =
66101
httpClient.get("session/$id/diff") {
102+
applyDirectory(directory)
67103
messageId?.let { parameter("messageID", it) }
68104
}.body()
69105

70-
suspend fun summarizeSession(id: String, body: SummarizeSessionRequestDto): Boolean =
71-
httpClient.post("session/$id/summarize") { setBody(body) }.body()
106+
suspend fun summarizeSession(
107+
id: String,
108+
body: SummarizeSessionRequestDto,
109+
directory: String? = null,
110+
): Boolean =
111+
httpClient.post("session/$id/summarize") {
112+
applyDirectory(directory)
113+
setBody(body)
114+
}.body()
72115

73-
suspend fun revertSession(id: String, body: RevertSessionRequestDto): Boolean =
74-
httpClient.post("session/$id/revert") { setBody(body) }.body()
116+
suspend fun revertSession(id: String, body: RevertSessionRequestDto, directory: String? = null): Boolean =
117+
httpClient.post("session/$id/revert") {
118+
applyDirectory(directory)
119+
setBody(body)
120+
}.body()
75121

76-
suspend fun unrevertSession(id: String): Boolean =
77-
httpClient.post("session/$id/unrevert").body()
122+
suspend fun unrevertSession(id: String, directory: String? = null): Boolean =
123+
httpClient.post("session/$id/unrevert") {
124+
applyDirectory(directory)
125+
}.body()
78126

79127
suspend fun respondToPermission(
80128
sessionId: String,
81129
permissionId: String,
82130
body: PermissionResponseRequestDto,
131+
directory: String? = null,
83132
): Boolean =
84133
httpClient.post("session/$sessionId/permissions/$permissionId") {
134+
applyDirectory(directory)
85135
setBody(body)
86136
}.body()
87137
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.