Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eeeccf8
#929 Android: Search sessions on Home
ivanfenenko Nov 3, 2026
2bcdffb
#929 #833 Home top-bar overflow menu
ivanfenenko Nov 3, 2026
cd742c7
#833 Restore archived sessions
ivanfenenko Nov 3, 2026
84bebc6
#929 iOS: Search sessions on Home
ivanfenenko Nov 3, 2026
ae8a455
#929 Android: match iOS string keys, center chip letter, keep focus o…
ivanfenenko Nov 3, 2026
31e1fa0
Merge remote-tracking branch 'origin/feature/929-home-overflow-menu' …
ivanfenenko Nov 3, 2026
8c5bcf7
#929 Search sessions as the first Home menu entry
ivanfenenko Nov 3, 2026
64dfadd
Merge remote-tracking branch 'origin/feature/929-home-overflow-menu' …
ivanfenenko Nov 3, 2026
808f273
#833 Add Archived sessions to the Home menu
ivanfenenko Nov 3, 2026
5582127
Merge remote-tracking branch 'origin/feature/833-restore-archived-ses…
ivanfenenko Nov 3, 2026
90240c3
#929 Android: Include archived in session search
ivanfenenko Nov 3, 2026
aef2e53
#929 iOS: Include archived in session search
ivanfenenko Nov 3, 2026
1c2d422
#833 Fix archived sessions verification findings
ivanfenenko Nov 3, 2026
be7529a
#929 Search: keep server matches through failures, typing and Home ch…
ivanfenenko Nov 3, 2026
d09e0a3
#833 Address review findings on archived sessions
ivanfenenko Nov 3, 2026
fa295aa
#929 Keep the Android overflow menu at its content width with a divider
ivanfenenko Nov 3, 2026
a9d2fac
Merge remote-tracking branch 'origin/feature/929-home-overflow-menu' …
ivanfenenko Nov 3, 2026
2b21631
Merge remote-tracking branch 'origin/feature/833-restore-archived-ses…
ivanfenenko Nov 3, 2026
05e20ae
#833 Test that unarchive leaves server read state alone
ivanfenenko Nov 4, 2026
19ba2ef
#929 Android: show the search chips' titles
ivanfenenko Nov 4, 2026
9c98dd6
Merge main (#976 squash) into feature/833-restore-archived-sessions
ivanfenenko Nov 4, 2026
d6c2f29
#833 Address second review pass on archived sessions
ivanfenenko Nov 4, 2026
f30175e
#833 Test unarchiving an undone row again while the list lags
ivanfenenko Nov 4, 2026
3a47c60
Merge #977's final branch state into feature/929-search-sessions
ivanfenenko Nov 4, 2026
aad0f03
Merge main (#977 squash) into feature/929-search-sessions
ivanfenenko Nov 4, 2026
032ee67
#929 iOS: search the v1 worktrees Home folds into a project
ivanfenenko Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.opencode.mobile.ui.components

import androidx.activity.ComponentActivity
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.rememberScrollState
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertWidthIsAtLeast
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.theme.LetterAccent
import dev.opencode.mobile.theme.OpenCodeTheme
import dev.opencode.mobile.ui.icons.OpenCodeIcons
import org.junit.Rule
import org.junit.Test

/** Search's chips sit in a row that scrolls sideways; their titles must still show (#929). */
class OpenCodeMenuChipTest {
@get:Rule val composeTestRule = createAndroidComposeRule<ComponentActivity>()

@Test
fun titlesShow_inARowThatScrollsSideways() {
composeTestRule.setContent {
OpenCodeTheme {
Row(Modifier.horizontalScroll(rememberScrollState())) {
OpenCodeMenuChip(
title = "acme-invoices",
onClick = {},
leading = OpenCodeMenuChipLeading.Letter('A', LetterAccent.Teal),
selected = true,
)
OpenCodeMenuChip(
title = "Include archived · 2",
onClick = {},
leading = OpenCodeMenuChipLeading.Icon(OpenCodeIcons.Archive),
variant = OpenCodeMenuChipVariant.Toggle,
)
}
}
}

composeTestRule.onNodeWithText("acme-invoices", useUnmergedTree = true).assertIsDisplayed().assertWidthIsAtLeast(40.dp)
composeTestRule.onNodeWithText("Include archived · 2", useUnmergedTree = true).assertIsDisplayed().assertWidthIsAtLeast(40.dp)
}
}
2 changes: 2 additions & 0 deletions android/app/src/main/java/dev/opencode/mobile/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import dev.opencode.mobile.ui.componentgallery.components.KeyValueRowGalleryScre
import dev.opencode.mobile.ui.componentgallery.components.KeyboardHintGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ListGroupGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ListItemGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.MenuChipGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.MessageListGalleryDetailScreen
import dev.opencode.mobile.ui.componentgallery.components.MessageNoteGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ModalGalleryScreen
Expand Down Expand Up @@ -770,6 +771,7 @@ fun MainNavigation() {
ComponentGalleryEntryId.ReorderableList -> ReorderableListGalleryScreen()
ComponentGalleryEntryId.ChoiceBadge -> ChoiceBadgeGalleryScreen()
ComponentGalleryEntryId.FilterTabs -> FilterTabsGalleryScreen()
ComponentGalleryEntryId.MenuChip -> MenuChipGalleryScreen()
ComponentGalleryEntryId.ActionPill -> ActionPillGalleryScreen()
ComponentGalleryEntryId.ActionTile -> ActionTileGalleryScreen()
ComponentGalleryEntryId.FloatingPill -> FloatingPillGalleryScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ class SessionsApi private constructor(
applyDirectory(directory)
}.body()

suspend fun listSessions(directory: String? = null): List<SessionDto> =
/** [search] filters by title and [rootsOnly] drops child sessions (opencode 1.x; older servers ignore both). */
suspend fun listSessions(
directory: String? = null,
search: String? = null,
rootsOnly: Boolean = false,
): List<SessionDto> =
httpClient
.get()
.get("session") {
applyDirectory(directory)
search?.let { parameter("search", it) }
if (rootsOnly) parameter("roots", "true")
}.body()

suspend fun createSession(
Expand Down Expand Up @@ -449,6 +456,10 @@ class SessionsApi private constructor(
parentId: String? = null,
projectId: String? = null,
archived: Boolean? = null,
/** Only sessions without a parent (`parentID=null`); ignored when [parentId] is set. */
rootsOnly: Boolean = false,
/** Title filter. */
search: String? = null,
): List<V2SessionDto> {
val sessions = mutableListOf<V2SessionDto>()
var cursor: String? = null
Expand All @@ -463,8 +474,12 @@ class SessionsApi private constructor(
} else {
applyDirectory(directory)
}
parentId?.let { parameter("parentID", it) }
when {
parentId != null -> parameter("parentID", parentId)
rootsOnly -> parameter("parentID", "null")
}
archived?.let { parameter("archived", it.toString()) }
search?.let { parameter("search", it) }
cursor?.let { parameter("cursor", it) }
}.body<ApiListEnvelope<V2SessionDto>>()
sessions += envelope.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class DefaultSessionRepository
runCatching { remote.listSessions(directory) }
.getOrElse { throw adapter.mapError(it) }

override suspend fun searchSessions(
query: String,
directory: String?,
): List<Session> =
runCatching { remote.searchSessions(query, directory) }
.getOrElse { throw adapter.mapError(it) }

override suspend fun createSession(
parentId: String?,
title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ internal class ProtocolSelectedSessionRemote(

override suspend fun listSessions(directory: String?): List<Session> = selected().listSessions(directory)

override suspend fun searchSessions(
query: String,
directory: String?,
): List<Session> = selected().searchSessions(query, directory)

override suspend fun createSession(
parentId: String?,
title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ interface SessionRepository {

suspend fun listSessions(directory: String? = null): List<Session>

/**
* Active root sessions in [directory]'s list whose title contains [query] (#929). Servers
* search on their side; without that this filters the full list.
*/
suspend fun searchSessions(
query: String,
directory: String? = null,
): List<Session> = SessionTitleSearch.filter(listSessions(directory), query)

suspend fun createSession(
parentId: String? = null,
title: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.opencode.mobile.domain.session

/**
* Session search by title (#929): a case-insensitive substring match, the same rule the v1 and v2
* servers apply to their `search` query parameter.
*/
object SessionTitleSearch {
/** The query as searched: surrounding whitespace dropped; empty means no search. */
fun normalizedQuery(raw: String): String = raw.trim()

/** First case-insensitive occurrence of [query] in [title], or null (also for an empty query). */
fun matchRange(
title: String,
query: String,
): IntRange? {
val needle = normalizedQuery(query)
if (needle.isEmpty()) return null
val start = title.indexOf(needle, ignoreCase = true)
return if (start < 0) null else start until start + needle.length
}

fun matches(
title: String,
query: String,
): Boolean = matchRange(title, query) != null

/**
* What a search returns from a session list: active root sessions whose title matches. The
* remotes apply it to server replies too, since a server that ignores `search` lists everything.
*/
fun filter(
sessions: List<Session>,
query: String,
): List<Session> = sessions.activeSessions().rootSessions().filter { matches(it.title, query) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ internal class V1SessionRemote(

override suspend fun listSessions(directory: String?): List<Session> = api.listSessions(directory).map(adapter::toSession)

override suspend fun searchSessions(
query: String,
directory: String?,
): List<Session> =
SessionTitleSearch.filter(
api.listSessions(directory, search = SessionTitleSearch.normalizedQuery(query), rootsOnly = true).map(adapter::toSession),
query,
)

override suspend fun createSession(
parentId: String?,
title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,7 @@ internal class V2SessionRemote(
directory: String?,
archived: Boolean,
): List<Session> {
val projectId =
directory?.let { path ->
try {
listableProjectId(api.locationForSessionList(path))
} catch (error: CancellationException) {
throw error
} catch (_: Throwable) {
null
}
}
val projectId = projectIdForList(directory)
return api
.listSessionsV2(
directory = if (projectId == null) directory else null,
Expand All @@ -43,6 +34,33 @@ internal class V2SessionRemote(
).map(adapter::toSession)
}

override suspend fun searchSessions(
query: String,
directory: String?,
): List<Session> {
val projectId = projectIdForList(directory)
val sessions =
api.listSessionsV2(
directory = if (projectId == null) directory else null,
projectId = projectId,
archived = false,
rootsOnly = true,
search = SessionTitleSearch.normalizedQuery(query),
)
return SessionTitleSearch.filter(sessions.map(adapter::toSession), query)
}

private suspend fun projectIdForList(directory: String?): String? =
directory?.let { path ->
try {
listableProjectId(api.locationForSessionList(path))
} catch (error: CancellationException) {
throw error
} catch (_: Throwable) {
null
}
}

override suspend fun createSession(
parentId: String?,
title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum class ComponentGalleryEntryId {
ReorderableList,
ChoiceBadge,
FilterTabs,
MenuChip,
ActionPill,
ActionTile,
FloatingPill,
Expand Down Expand Up @@ -152,6 +153,12 @@ val ComponentGalleryEntries =
description = "Review shared type roles and platform mappings.",
category = ComponentGalleryCategory.Foundations,
),
ComponentGalleryEntry(
id = ComponentGalleryEntryId.MenuChip,
title = "Menu Chip",
description = "Capsule that shows a filter's current choice and opens a menu of the others, such as a search scope.",
category = ComponentGalleryCategory.Controls,
),
ComponentGalleryEntry(
id = ComponentGalleryEntryId.ActionPill,
title = "Action Pill",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,25 @@ fun ListItemGalleryScreen(modifier: Modifier = Modifier) {
startDecorator = startDecorator,
)

Text(text = "Title highlight", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurface)
OpenCodeListItem(
title = "Invoice export retries",
titleHighlight = 0 until 7,
subtitle = "~/Projects/acme-invoices",
caption = "2h ago",
startDecorator = StartDecorator.Letter('A', LetterAccent.Teal),
onClick = {},
)
OpenCodeListItem(
title = "Invoice export retries",
titleHighlight = 15 until 22,
variant = OpenCodeListItemVariant.Compact,
path = OpenCodeListItemPath(project = "acme-invoices"),
caption = "2h ago",
startDecorator = StartDecorator.Tile('A', LetterAccent.Teal),
onClick = {},
)

Text(text = "Detail line", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurface)
Column {
OpenCodeListItem(
Expand Down
Loading