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
4 changes: 0 additions & 4 deletions android/app/src/main/java/dev/opencode/mobile/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,6 @@ fun MainNavigation() {
settingsViewModel::setFollowUpDelivery,
supportsFollowUpDelivery =
settingsViewModel.supportsFollowUpDelivery(),
composerDictation =
SessionChatDisplayPreferences.composerDictation,
onComposerDictationChange =
settingsViewModel::setComposerDictation,
textMateEnabled = MarkdownHighlightPreferences.textMateEnabled,
onTextMateEnabledChange = settingsViewModel::setTextMateEnabled,
productAnalyticsConsented =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ object ProductAnalytics {
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"
const val SETTINGS_TOGGLE_COMPOSER_DICTATION = "settings_toggle_composer_dictation"
const val SETTINGS_CLEAR_SESSION_CACHE = "settings_clear_session_cache"
const val SETTINGS_OPEN_PRIVACY_POLICY = "settings_open_privacy_policy"
const val SETTINGS_TOGGLE_PRODUCT_ANALYTICS = "settings_toggle_product_analytics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ object SessionChatDisplayPreferences {
private const val KEY_FOLLOW_UP_DELIVERY = "follow_up_delivery"
private const val KEY_CHIP_TIMELINE_INTRO_DONE = "chip_timeline_intro_done"
private const val KEY_CHIP_TIMELINE_INTRO_SNOOZED_UNTIL = "chip_timeline_intro_snoozed_until"
private const val KEY_COMPOSER_DICTATION = "composer_dictation"
const val DEFAULT_COLLAPSE_CONSECUTIVE_TOOL_CALLS = true
const val DEFAULT_CHIP_TIMELINE = false
const val DEFAULT_COMPOSER_DICTATION = false
val DEFAULT_FOLLOW_UP_DELIVERY = FollowUpDelivery.Steer

/** When true, a run of two or more consecutive visible tool parts in one
Expand All @@ -45,10 +43,6 @@ object SessionChatDisplayPreferences {
var chipTimelineIntroSnoozedUntilMillis: Long? by mutableStateOf(null)
private set

/** Speak into the composer. Off until the user turns this on. */
var composerDictation: Boolean by mutableStateOf(DEFAULT_COMPOSER_DICTATION)
private set

/** True while the `session_chat_chip_timeline` flag allows the mode at all (OPE-269). */
val chipTimelineAvailable: Boolean
get() = FeatureFlags.isEnabled(FeatureFlag.SessionChatChipTimeline)
Expand Down Expand Up @@ -84,7 +78,6 @@ object SessionChatDisplayPreferences {
} else {
null
}
composerDictation = prefs.getBoolean(KEY_COMPOSER_DICTATION, DEFAULT_COMPOSER_DICTATION)
}

fun updateCollapseConsecutiveToolCalls(value: Boolean) {
Expand All @@ -97,11 +90,6 @@ object SessionChatDisplayPreferences {
prefs()?.edit()?.putString(KEY_FOLLOW_UP_DELIVERY, value.wireValue)?.apply()
}

fun updateComposerDictation(value: Boolean) {
composerDictation = value
prefs()?.edit()?.putBoolean(KEY_COMPOSER_DICTATION, value)?.apply()
}

/** Any explicit choice, from Settings or the intro sheet, also ends the intro. */
fun updateChipTimeline(value: Boolean) {
chipTimelinePreference = value
Expand Down Expand Up @@ -165,14 +153,12 @@ object SessionChatDisplayPreferences {
?.remove(KEY_CHIP_TIMELINE)
?.remove(KEY_CHIP_TIMELINE_INTRO_DONE)
?.remove(KEY_CHIP_TIMELINE_INTRO_SNOOZED_UNTIL)
?.remove(KEY_COMPOSER_DICTATION)
?.apply()
collapseConsecutiveToolCalls = DEFAULT_COLLAPSE_CONSECUTIVE_TOOL_CALLS
followUpDelivery = DEFAULT_FOLLOW_UP_DELIVERY
chipTimelinePreference = DEFAULT_CHIP_TIMELINE
chipTimelineIntroDone = false
chipTimelineIntroSnoozedUntilMillis = null
composerDictation = DEFAULT_COMPOSER_DICTATION
}

private fun prefs() = appContext?.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private fun FeedbackActions(
onClick = { addMenuOpen = true },
)
}
if (state.composerDictationEnabled && showsMic) {
if (showsMic) {
OpenCodeButton(
variant = OpenCodeButtonVariant.IconCircle(OpenCodeIcons.Mic, "Dictate"),
contrast = OpenCodeButtonContrast.Low,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import dev.opencode.mobile.domain.feedback.FeedbackScreenshot
import dev.opencode.mobile.domain.feedback.FeedbackSharePayload
import dev.opencode.mobile.domain.feedback.FeedbackSubmitResult
import dev.opencode.mobile.domain.feedback.FeedbackSubmitter
import dev.opencode.mobile.domain.preferences.SessionChatDisplayPreferences
import dev.opencode.mobile.ui.sessionchat.ComposerDictationPhase
import dev.opencode.mobile.ui.sessionchat.ComposerDictationUiState
import kotlinx.coroutines.CancellationException
Expand Down Expand Up @@ -68,7 +67,6 @@ data class FeedbackUiState(
val page: FeedbackPage = FeedbackPage.Compose,
/** Redacted log lines for the Diagnostic log page; null while loading. */
val logPreviewLines: List<String>? = null,
val composerDictationEnabled: Boolean = false,
val dictation: ComposerDictationUiState? = null,
val status: FeedbackSendStatus = FeedbackSendStatus.Idle,
/** A share sheet the screen should open once, then [FeedbackViewModel.consumeShare]. */
Expand Down Expand Up @@ -128,7 +126,6 @@ class FeedbackViewModel
private val renderer: FeedbackAttachmentRenderer,
) : ViewModel() {
internal var nowMs: () -> Long = { System.currentTimeMillis() }
internal var dictationEnabled: () -> Boolean = { SessionChatDisplayPreferences.composerDictation }
internal var dictationFinishDelayMs: Long = 350

private val mutableState = MutableStateFlow(FeedbackUiState())
Expand All @@ -154,7 +151,7 @@ class FeedbackViewModel
) {
invalidateDictationInsert()
if (isSending) {
mutableState.update { it.copy(page = FeedbackPage.Compose, composerDictationEnabled = dictationEnabled()) }
mutableState.update { it.copy(page = FeedbackPage.Compose) }
return
}
val captured = capturedJpeg?.let { FeedbackScreenshot(it) }
Expand All @@ -174,7 +171,6 @@ class FeedbackViewModel
capturedScreenshot = captured,
includeLogs = if (keepDraft) current.includeLogs else true,
logWindow = if (keepDraft) current.logWindow else DiagnosticLogExportWindow.DEFAULT,
composerDictationEnabled = dictationEnabled(),
)
}
}
Expand Down Expand Up @@ -378,7 +374,7 @@ class FeedbackViewModel
languageLabel: String,
onDevice: Boolean,
) {
if (!dictationEnabled() || isSending) return
if (isSending) return
invalidateDictationInsert()
mutableState.update {
it.copy(
Expand All @@ -397,7 +393,6 @@ class FeedbackViewModel
phase: ComposerDictationPhase,
message: String? = null,
) {
if (!dictationEnabled()) return
if (
phase != ComposerDictationPhase.PermissionDenied &&
phase != ComposerDictationPhase.ModelNotInstalled &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,7 @@ fun SessionChatScreen(
uiState.composer.followUpDelivery.takeIf {
uiState.composer.supportsFollowUpDelivery
},
showDictationButton =
uiState.composerDictationEnabled && dictationSupport.showsMic,
showDictationButton = dictationSupport.showsMic,
)
}
val composerFocus = rememberOpenCodeSessionComposerFocus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ data class SessionChatUiState(
val expandedStepParagraphs: Map<String, Int> = emptyMap(),
/** One-time Chip timeline intro sheet (OPE-270). */
val chipTimelineIntroVisible: Boolean = false,
/** Settings gate for the composer mic. Off until the user turns it on. */
val composerDictationEnabled: Boolean = false,
/** Null while idle. A value shows the dictation card in place of prompt entry. */
val dictation: ComposerDictationUiState? = null,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,8 @@ class SessionChatViewModel
// expansion id with the chip count at tap time; reset per session.
private var expandedStepParagraphs: Map<String, Int> = emptyMap()

// Composer dictation card. Preference off hides the mic; an active card is cancelled
// without inserting when the preference, mode, background, or screen goes away.
private var composerDictationEnabled = SessionChatDisplayPreferences.composerDictation
// Composer dictation card. An active card is cancelled without inserting when the
// mode, background, or screen goes away.
private var dictation: ComposerDictationUiState? = null
private var dictationGeneration = 0
private var dictationInsertJob: Job? = null
Expand Down Expand Up @@ -342,18 +341,6 @@ class SessionChatViewModel
timeline.updateChipTimeline(enabled)
}
}
viewModelScope.launch {
snapshotFlow { SessionChatDisplayPreferences.composerDictation }
.distinctUntilChanged()
.collect { enabled ->
composerDictationEnabled = enabled
if (!enabled && dictation != null) {
cancelActiveDictation()
} else {
publishUiState()
}
}
}
}

fun bind(
Expand Down Expand Up @@ -589,7 +576,6 @@ class SessionChatViewModel
languageLabel: String,
onDevice: Boolean,
) {
if (!SessionChatDisplayPreferences.composerDictation) return
invalidateDictationInsert()
dictation =
ComposerDictationUiState(
Expand All @@ -605,7 +591,6 @@ class SessionChatViewModel
phase: ComposerDictationPhase,
message: String? = null,
) {
if (!SessionChatDisplayPreferences.composerDictation) return
if (
phase != ComposerDictationPhase.PermissionDenied &&
phase != ComposerDictationPhase.ModelNotInstalled &&
Expand Down Expand Up @@ -1706,7 +1691,6 @@ class SessionChatViewModel
projectLetterAccent = projectLetterAccent,
worktreeCheckout = worktreeCheckout,
sessionBranchPill = repoStrip.state.value.toSessionBranchPill(),
composerDictationEnabled = composerDictationEnabled,
dictation = dictation,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ fun SettingsScreen(
followUpDelivery: FollowUpDelivery,
onFollowUpDeliveryChange: (FollowUpDelivery) -> Unit,
supportsFollowUpDelivery: Boolean,
composerDictation: Boolean,
onComposerDictationChange: (Boolean) -> Unit,
textMateEnabled: Boolean,
onTextMateEnabledChange: (Boolean) -> Unit,
productAnalyticsConsented: Boolean,
Expand Down Expand Up @@ -287,25 +285,6 @@ fun SettingsScreen(
modifier = Modifier.padding(horizontal = 16.dp),
)

OpenCodeListItem(
title = "Composer Dictation",
subtitle = "Speak into the composer. Off until you turn this on.",
style = OpenCodeListItemStyle.Card,
startDecorator = StartDecorator.Icon(OpenCodeIcons.Mic, "Composer Dictation"),
accessory =
OpenCodeListItemAccessory.Toggle(
checked = composerDictation,
onCheckedChange = { enabled ->
logSettingsToggle(
ProductAnalytics.Action.SETTINGS_TOGGLE_COMPOSER_DICTATION,
enabled,
)
onComposerDictationChange(enabled)
},
),
modifier = Modifier.padding(horizontal = 16.dp),
)

themeLoadError?.let { error ->
OpenCodeInlineNotice(
message = error,
Expand Down Expand Up @@ -673,8 +652,6 @@ private fun SettingsScreenLightPreview() {
followUpDelivery = FollowUpDelivery.Steer,
onFollowUpDeliveryChange = {},
supportsFollowUpDelivery = true,
composerDictation = SessionChatDisplayPreferences.composerDictation,
onComposerDictationChange = {},
textMateEnabled = false,
onTextMateEnabledChange = {},
productAnalyticsConsented = false,
Expand Down Expand Up @@ -713,8 +690,6 @@ private fun SettingsScreenDarkPreview() {
followUpDelivery = FollowUpDelivery.Steer,
onFollowUpDeliveryChange = {},
supportsFollowUpDelivery = true,
composerDictation = SessionChatDisplayPreferences.composerDictation,
onComposerDictationChange = {},
textMateEnabled = false,
onTextMateEnabledChange = {},
productAnalyticsConsented = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ class SettingsViewModel
SessionChatDisplayPreferences.updateFollowUpDelivery(value)
}

fun setComposerDictation(enabled: Boolean) {
SessionChatDisplayPreferences.updateComposerDictation(enabled)
}

fun supportsFollowUpDelivery(): Boolean = activeConnectionManager.currentCapabilities().supportsFollowUpDelivery

fun setTextMateEnabled(enabled: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ class FeedbackViewModelTest {
fun dictationInsert_appendsTranscriptToTheMessage() =
runTest(dispatcher) {
val viewModel = viewModel()
viewModel.dictationEnabled = { true }
viewModel.open(FeedbackScreen.Settings)
viewModel.updateMessage("Crash")

Expand All @@ -363,7 +362,6 @@ class FeedbackViewModelTest {
@Test
fun dictation_morphsTheSheetIntoListening() {
val viewModel = viewModel()
viewModel.dictationEnabled = { true }
viewModel.open(FeedbackScreen.Settings)
assertEquals("Report a problem", viewModel.state.value.sheetTitle)
assertFalse(viewModel.state.value.dictationTakesOverCompose)
Expand All @@ -382,7 +380,6 @@ class FeedbackViewModelTest {
@Test
fun dictationUnavailable_takesOverWithoutTheListeningTitle() {
val viewModel = viewModel()
viewModel.dictationEnabled = { true }
viewModel.open(FeedbackScreen.Settings)

viewModel.beginDictationUnavailable(ComposerDictationPhase.PermissionDenied, "Microphone access is off")
Expand All @@ -394,7 +391,6 @@ class FeedbackViewModelTest {
@Test
fun dictationStopped_keepsTheListeningTitle() {
val viewModel = viewModel()
viewModel.dictationEnabled = { true }
viewModel.open(FeedbackScreen.Settings)
viewModel.beginDictation(languageLabel = "English", onDevice = true)

Expand All @@ -405,18 +401,6 @@ class FeedbackViewModelTest {
assertTrue(viewModel.state.value.dictationTakesOverCompose)
}

@Test
fun dictation_staysOffWhenTheSettingIsOff() {
val viewModel = viewModel()
viewModel.dictationEnabled = { false }
viewModel.open(FeedbackScreen.Settings)

viewModel.beginDictation(languageLabel = "English", onDevice = true)

assertFalse(viewModel.state.value.composerDictationEnabled)
assertNull(viewModel.state.value.dictation)
}

@Test
fun dismissAfterSent_startsAFreshDraftNextTime() =
runTest(dispatcher) {
Expand Down Expand Up @@ -464,7 +448,6 @@ class FeedbackViewModelTest {
renderer = renderer,
).also { viewModel ->
viewModel.nowMs = { now }
viewModel.dictationEnabled = { false }
}

private class MemoryCooldownStore : FeedbackCooldownStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5896,7 +5896,6 @@ class SessionChatViewModelTest {
private fun TestScope.dictationViewModel(): SessionChatViewModel {
val viewModel = createViewModel(FakeMessageRepository())
viewModel.dictationFinishDelayMs = 0
SessionChatDisplayPreferences.updateComposerDictation(true)
advanceUntilIdle()
return viewModel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ enum ProductAnalytics {
static let settingsOpenRecentWindowPicker = "settings_open_recent_window_picker"
static let settingsToggleCollapseConsecutiveToolCalls = "settings_toggle_collapse_consecutive_tool_calls"
static let settingsToggleChipTimeline = "settings_toggle_chip_timeline"
static let settingsToggleComposerDictation = "settings_toggle_composer_dictation"
static let settingsClearSessionCache = "settings_clear_session_cache"
static let settingsOpenPrivacyPolicy = "settings_open_privacy_policy"
static let settingsToggleProductAnalytics = "settings_toggle_product_analytics"
Expand Down
Loading