Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions android/app/src/main/java/dev/opencode/mobile/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ import dev.opencode.mobile.ui.componentgallery.ComponentGalleryThemeMode
import dev.opencode.mobile.ui.componentgallery.components.ActionBarGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ActionPillGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ActionTileGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ActivityCardGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.AssistantMessageGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.AttachmentGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.BottomFadeGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.BottomSheetGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ButtonGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ChildSessionRowGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.StepRailGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ActivityCardGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ChoiceBadgeGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.CodeFileGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.CodeSnippetGalleryScreen
Expand All @@ -82,10 +81,10 @@ import dev.opencode.mobile.ui.componentgallery.components.DialogGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.DictationCardGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.DiffStatGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.EmptyStateGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.FileIconGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.FileTabsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.FilterTabsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.HunkNavigationPillGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.FileIconGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.IconsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.InlineNoticeGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.KeyValueRowGalleryScreen
Expand Down Expand Up @@ -117,6 +116,7 @@ import dev.opencode.mobile.ui.componentgallery.components.SkeletonIllustrationGa
import dev.opencode.mobile.ui.componentgallery.components.SnackbarGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.SplitPaneGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.StatusStackGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.StepRailGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.SyncingPillGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.TagGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.TextInputGalleryScreen
Expand Down Expand Up @@ -541,6 +541,8 @@ fun MainNavigation() {
settingsViewModel::setHideUserDirectoryPrefix,
showsWorktrees = HomeDisplayPreferences.showsWorktrees,
onShowsWorktreesChange = settingsViewModel::setShowsWorktrees,
sessionRowStyle = HomeDisplayPreferences.sessionRowStyle,
onSessionRowStyleChange = settingsViewModel::setSessionRowStyle,
recentWindowHours = HomeDisplayPreferences.recentWindowHours,
onRecentWindowHoursChange =
settingsViewModel::setRecentWindowHours,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,33 @@ object HomeSessionLocation {
const val SEPARATOR = " · "
}

/** Line 2 of a compact Home row (#803): `project / worktree`. */
object HomeCompactRowPath {
private val BRANCH_PREFIX = Regex("^(feature|fix|chore|opencode)/")

/**
* Worktree part of the line: the shortened branch, or the folder name on a detached HEAD or
* unknown branch. Null on the main checkout, for a non-repository project, and while
* [worktreesEnabled] is off.
*/
fun worktreeLabel(
project: HomeProject,
sessionDirectory: String?,
worktreesEnabled: Boolean = true,
): String? {
if (!worktreesEnabled || !project.isRepository) return null
val directory =
sessionDirectory?.trim()?.takeIf { it.isNotEmpty() }?.let(ServerPathPolicy::canonical)
?: return null
val worktree = project.worktree(directory) ?: HomeWorktree(directory = directory)
if (worktree.isMain) return null
return worktree.branch?.let(::shortBranch) ?: worktree.folderName
}

/** Drops a `feature/`, `fix/`, `chore/` or `opencode/` prefix; a bare prefix stays as it is. */
fun shortBranch(branch: String): String = branch.replace(BRANCH_PREFIX, "").ifEmpty { branch }
}

/** Copy shared by the scope picker, dock, and Run in chooser. */
object HomeWorktreeCopy {
const val MAIN_CHECKOUT = "main checkout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ object ProductAnalytics {
const val SETTINGS_OPEN_SYNTAX_PICKER = "settings_open_syntax_picker"
const val SETTINGS_TOGGLE_HIDE_USER_DIRECTORY = "settings_toggle_hide_user_directory"
const val SETTINGS_TOGGLE_WORKTREES = "settings_toggle_worktrees"
const val SETTINGS_OPEN_SESSION_ROWS_PICKER = "settings_open_session_rows_picker"
const val SETTINGS_SESSION_ROWS = "settings_session_rows"
const val SETTINGS_OPEN_RECENT_WINDOW_PICKER = "settings_open_recent_window_picker"
const val SETTINGS_TOGGLE_COLLAPSE_CONSECUTIVE_TOOL_CALLS = "settings_toggle_collapse_consecutive_tool_calls"
const val SETTINGS_TOGGLE_CHIP_TIMELINE = "settings_toggle_chip_timeline"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
package dev.opencode.mobile.domain.preferences

import android.content.Context
import android.content.SharedPreferences
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import dev.opencode.mobile.domain.home.HomeSessionLadder

/** How Home draws a session row (#803): two compact lines, or the three-line row from #798. */
enum class HomeSessionRowStyle(
val wireValue: String,
) {
Compact("compact"),
Classic("classic"),
;

companion object {
val DEFAULT = Compact

fun fromWire(value: String?): HomeSessionRowStyle? = entries.firstOrNull { it.wireValue == value }
}
}

object HomeDisplayPreferences {
private const val PREFS_NAME = "opencode_home_display"
private const val KEY_SHOW_SESSION_LIST_ON_HOME = "show_session_list_on_home"
Expand All @@ -15,6 +31,7 @@ object HomeDisplayPreferences {
private const val KEY_LAST_HOME_HIDDEN_AT_EPOCH_MS = "last_home_hidden_at_epoch_ms"
private const val KEY_SESSION_LIST_PROJECT_PICKER_ENABLED = "session_list_project_picker_enabled"
private const val KEY_SHOWS_WORKTREES = "shows_worktrees"
private const val KEY_SESSION_ROW_STYLE = "session_row_style"

/** When true, replace remote `/Users/…` or `/home/…` with `~` in path labels. */
var hideUserDirectoryPrefix: Boolean by mutableStateOf(true)
Expand All @@ -30,11 +47,17 @@ object HomeDisplayPreferences {
var showsWorktrees: Boolean by mutableStateOf(true)
private set

private var appContext: Context? = null
var sessionRowStyle: HomeSessionRowStyle by mutableStateOf(HomeSessionRowStyle.DEFAULT)
private set

private var preferences: SharedPreferences? = null

fun initialize(context: Context) {
appContext = context.applicationContext
val prefs = prefs() ?: return
initialize(context.applicationContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE))
}

internal fun initialize(prefs: SharedPreferences) {
preferences = prefs
hideUserDirectoryPrefix =
if (prefs.contains(KEY_HIDE_USER_DIRECTORY_PREFIX)) {
prefs.getBoolean(KEY_HIDE_USER_DIRECTORY_PREFIX, true)
Expand All @@ -46,6 +69,12 @@ object HomeDisplayPreferences {
prefs.getInt(KEY_RECENT_WINDOW_HOURS, HomeSessionLadder.DEFAULT_WINDOW_HOURS),
)
showsWorktrees = prefs.getBoolean(KEY_SHOWS_WORKTREES, true)
sessionRowStyle = HomeSessionRowStyle.fromWire(prefs.getString(KEY_SESSION_ROW_STYLE, null)) ?: HomeSessionRowStyle.DEFAULT
}

fun updateSessionRowStyle(value: HomeSessionRowStyle) {
sessionRowStyle = value
prefs()?.edit()?.putString(KEY_SESSION_ROW_STYLE, value.wireValue)?.apply()
}

fun updateShowsWorktrees(value: Boolean) {
Expand Down Expand Up @@ -89,11 +118,13 @@ object HomeDisplayPreferences {
?.remove(KEY_LAST_HOME_HIDDEN_AT_EPOCH_MS)
?.remove(KEY_SESSION_LIST_PROJECT_PICKER_ENABLED)
?.remove(KEY_SHOWS_WORKTREES)
?.remove(KEY_SESSION_ROW_STYLE)
?.apply()
hideUserDirectoryPrefix = true
showsWorktrees = true
sessionRowStyle = HomeSessionRowStyle.DEFAULT
recentWindowHours = HomeSessionLadder.DEFAULT_WINDOW_HOURS
}

private fun prefs() = appContext?.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
private fun prefs() = preferences
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import dev.opencode.mobile.theme.LetterAccent
import dev.opencode.mobile.ui.components.OpenCodeChoiceBadge
import dev.opencode.mobile.ui.components.OpenCodeListItem
import dev.opencode.mobile.ui.components.OpenCodeListItemAccessory
import dev.opencode.mobile.ui.components.OpenCodeListItemPath
import dev.opencode.mobile.ui.components.OpenCodeListItemStatus
import dev.opencode.mobile.ui.components.OpenCodeListItemStatusTone
import dev.opencode.mobile.ui.components.OpenCodeListItemStyle
import dev.opencode.mobile.ui.components.OpenCodeListItemSubtitleSegment
import dev.opencode.mobile.ui.components.OpenCodeListItemSubtitleTone
import dev.opencode.mobile.ui.components.OpenCodeListItemVariant
import dev.opencode.mobile.ui.components.StartDecorator
import dev.opencode.mobile.ui.icons.OpenCodeIcons

Expand Down Expand Up @@ -321,6 +323,28 @@ fun ListItemGalleryScreen(modifier: Modifier = Modifier) {
)
}

Text(text = "Compact variant", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurface)
Column {
galleryCompactRows.forEach { row ->
OpenCodeListItem(
title = row.title,
variant = OpenCodeListItemVariant.Compact,
path = row.path,
titleEmphasized = row.emphasized,
status = row.status,
caption = row.caption,
startDecorator =
StartDecorator.Tile(
character = row.path.project.first(),
accent = row.accent,
statusDot = row.status?.tone,
pulsing = row.pulsing,
),
onClick = {},
)
}
}

Text(text = "Title tag", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurface)
Column {
OpenCodeListItem(
Expand Down Expand Up @@ -393,3 +417,80 @@ fun ListItemGalleryScreen(modifier: Modifier = Modifier) {
)
}
}

private data class GalleryCompactRow(
val title: String,
val path: OpenCodeListItemPath,
val accent: LetterAccent,
val caption: String,
val status: OpenCodeListItemStatus? = null,
val pulsing: Boolean = false,
val emphasized: Boolean = false,
)

private val galleryCompactRows =
listOf(
GalleryCompactRow(
title = "Better action sheet tool results UI",
path = OpenCodeListItemPath("opencode-mobile", "794-readable-tool-results"),
accent = LetterAccent.Red,
caption = "4m ago",
status = OpenCodeListItemStatus("Running", OpenCodeListItemStatusTone.Interactive),
pulsing = true,
),
GalleryCompactRow(
title = "Skill session image message duplicate prompt",
path = OpenCodeListItemPath("opencode-mobile", "skill-image-duplicate-prompt"),
accent = LetterAccent.Red,
caption = "6m ago",
status = OpenCodeListItemStatus("Done", OpenCodeListItemStatusTone.Success),
emphasized = true,
),
GalleryCompactRow(
title = "Live reload for published sites",
path = OpenCodeListItemPath("artifact-publisher", "live-reload"),
accent = LetterAccent.Violet,
caption = "35m ago",
status = OpenCodeListItemStatus("Retrying · 2", OpenCodeListItemStatusTone.Warning),
),
GalleryCompactRow(
title = "Checking open PRs",
path = OpenCodeListItemPath("opencode-mobile", "skill-image-duplicate-prompt"),
accent = LetterAccent.Red,
caption = "17h ago",
status = OpenCodeListItemStatus("Failed", OpenCodeListItemStatusTone.Error),
emphasized = true,
),
GalleryCompactRow(
title = "Fix zsh prompt slowness",
path = OpenCodeListItemPath("dotfiles"),
accent = LetterAccent.Teal,
caption = "2h ago",
status = OpenCodeListItemStatus("Stopped", OpenCodeListItemStatusTone.Warning),
emphasized = true,
),
GalleryCompactRow(
title = "Idle on the main checkout: no dot, no pill",
path = OpenCodeListItemPath("opencode-mobile"),
accent = LetterAccent.Red,
caption = "2d ago",
),
GalleryCompactRow(
title = "Long names share line 2 by the 40/60 rule",
path =
OpenCodeListItemPath(
"opencode-mobile-enterprise-edition",
"ope-1042-show-worktree-and-project-on-home-rows",
),
accent = LetterAccent.Red,
caption = "13m ago",
status = OpenCodeListItemStatus("Ready", OpenCodeListItemStatusTone.Success),
emphasized = true,
),
GalleryCompactRow(
title = "A short project keeps its full width",
path = OpenCodeListItemPath("dotfiles", "806-clear-the-worktree-filter-when-it-is-empty"),
accent = LetterAccent.Teal,
caption = "1d ago",
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.domain.preferences.HomeSessionRowStyle
import dev.opencode.mobile.theme.LetterAccent
import dev.opencode.mobile.ui.components.OpenCodeBottomSheet
import dev.opencode.mobile.ui.components.OpenCodeBottomSheetHeight
Expand All @@ -31,6 +32,7 @@ fun SessionListGalleryScreen(modifier: Modifier = Modifier) {
var oneProject by rememberSaveable { mutableStateOf(false) }
var showProjectPicker by rememberSaveable { mutableStateOf(false) }
var loadStep by rememberSaveable { mutableStateOf(GalleryScopeLoadStep.None) }
var classicRows by rememberSaveable { mutableStateOf(false) }
val filterTabs =
galleryTabsWithNewProject(
base =
Expand All @@ -53,6 +55,7 @@ fun SessionListGalleryScreen(modifier: Modifier = Modifier) {
onAddProject = {},
onNewSession = {},
onRetryScopeLoad = { loadStep = GalleryScopeLoadStep.Loading },
rowStyle = if (classicRows) HomeSessionRowStyle.Classic else HomeSessionRowStyle.Compact,
modifier = Modifier.fillMaxSize(),
)
Row(
Expand All @@ -76,6 +79,11 @@ fun SessionListGalleryScreen(modifier: Modifier = Modifier) {
loadStep = GalleryScopeLoadStep.None
},
)
OpenCodeChoiceBadge(
label = if (classicRows) "Classic" else "Compact",
selected = classicRows,
onClick = { classicRows = !classicRows },
)
OpenCodeChoiceBadge(
label = loadStep.label,
selected = loadStep != GalleryScopeLoadStep.None,
Expand Down Expand Up @@ -124,6 +132,8 @@ private val sessionListGallerySamples: List<SessionListSession>
status = SessionListStatus.Running,
caption = "now",
updatedAtEpochMs = now,
projectName = "opencode-mobile",
compactWorktree = "794-readable-tool-results",
),
SessionListSession(
id = "session-2",
Expand All @@ -146,6 +156,7 @@ private val sessionListGallerySamples: List<SessionListSession>
status = SessionListStatus.Ready,
caption = "3h ago",
updatedAtEpochMs = now - 3 * 3_600_000L,
projectName = "opencode-mobile",
),
SessionListSession(
id = "session-done",
Expand Down Expand Up @@ -190,6 +201,9 @@ private val sessionListGallerySamples: List<SessionListSession>
status = SessionListStatus.Retrying,
caption = "now",
updatedAtEpochMs = now,
retryAttempt = 2,
projectName = "opencode-mobile",
compactWorktree = "ope-1042-show-worktree-and-project-on-home-rows",
),
SessionListSession(
id = "session-stale",
Expand Down
Loading
Loading