GeezerVison is showing github.com — #721 Add in-app feedback on iOS and Android (#722) · opencode-mobile/opencode-mobile@063eb09
File treeExpand file treeCollapse file tree Open diff view settings debug/java/dev/opencode/mobile/di main/java/dev/opencode/mobile release/java/dev/opencode/mobile test/java/dev/opencode/mobile
OpenCode Mobile.xcodeproj
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: android/app/build.gradle.kts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -151,6 +151,7 @@ android { | 151 | 151 | sourceSets { | 152 | 152 | getByName("test") { | 153 | 153 | resources.srcDir("../../shared/sse-recovery") | | 154 | + resources.srcDir("../../shared/feedback") | 154 | 155 | } | 155 | 156 | } | 156 | 157 | } | @@ -223,4 +224,5 @@ dependencies { | 223 | 224 | releaseImplementation(libs.firebase.crashlytics) | 224 | 225 | releaseImplementation(libs.firebase.analytics) | 225 | 226 | releaseImplementation(libs.firebase.config) | | 227 | + releaseImplementation(libs.firebase.appcheck.playintegrity) | 226 | 228 | } |
Collapse file Copy file name to clipboard +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package dev.opencode.mobile.di | | 2 | + | | 3 | +import dagger.Module | | 4 | +import dagger.Provides | | 5 | +import dagger.hilt.InstallIn | | 6 | +import dagger.hilt.components.SingletonComponent | | 7 | +import dev.opencode.mobile.domain.feedback.FeedbackSubmitter | | 8 | +import dev.opencode.mobile.domain.feedback.ShareFeedbackSubmitter | | 9 | +import javax.inject.Singleton | | 10 | + | | 11 | +/** | | 12 | + * Debug half of the feedback submitter seam (#721). Debug builds stay Firebase-free: | | 13 | + * every report goes to the share sheet. The release source set has the Firebase REST one. | | 14 | + */ | | 15 | +@Module | | 16 | +@InstallIn(SingletonComponent::class) | | 17 | +object FeedbackSubmitterModule { | | 18 | + @Provides | | 19 | + @Singleton | | 20 | + fun provideFeedbackSubmitter(): FeedbackSubmitter = ShareFeedbackSubmitter() | | 21 | +} |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/Navigation.kt +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,6 +47,7 @@ import androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecorator | 47 | 47 | import androidx.navigation3.ui.NavDisplay | 48 | 48 | import dev.opencode.mobile.domain.app.AppVersion | 49 | 49 | import dev.opencode.mobile.domain.connection.ConnectionProfile | | 50 | +import dev.opencode.mobile.domain.feedback.FeedbackScreen | 50 | 51 | import dev.opencode.mobile.domain.preferences.AnalyticsConsentPreferences | 51 | 52 | import dev.opencode.mobile.domain.preferences.DeveloperToolsPreferences | 52 | 53 | import dev.opencode.mobile.domain.preferences.HomeDisplayPreferences | @@ -74,6 +75,7 @@ import dev.opencode.mobile.ui.componentgallery.components.DialogGalleryScreen | 74 | 75 | import dev.opencode.mobile.ui.componentgallery.components.DictationCardGalleryScreen | 75 | 76 | import dev.opencode.mobile.ui.componentgallery.components.DiffStatGalleryScreen | 76 | 77 | import dev.opencode.mobile.ui.componentgallery.components.EmptyStateGalleryScreen | | 78 | +import dev.opencode.mobile.ui.componentgallery.components.FeedbackComposerGalleryScreen | 77 | 79 | import dev.opencode.mobile.ui.componentgallery.components.FileTabsGalleryScreen | 78 | 80 | import dev.opencode.mobile.ui.componentgallery.components.FilterTabsGalleryScreen | 79 | 81 | import dev.opencode.mobile.ui.componentgallery.components.HunkNavigationPillGalleryScreen | @@ -130,6 +132,8 @@ import dev.opencode.mobile.ui.components.openCodeDetailLeading | 130 | 132 | import dev.opencode.mobile.ui.connection.ConnectionSetupMode | 131 | 133 | import dev.opencode.mobile.ui.connection.ConnectionSetupScreen | 132 | 134 | import dev.opencode.mobile.ui.connection.ConnectionSetupViewModel | | 135 | +import dev.opencode.mobile.ui.feedback.FeedbackSheet | | 136 | +import dev.opencode.mobile.ui.feedback.rememberFeedbackSheetState | 133 | 137 | import dev.opencode.mobile.ui.icons.OpenCodeIcons | 134 | 138 | import dev.opencode.mobile.ui.keyboard.KeyboardShortcutAction | 135 | 139 | import dev.opencode.mobile.ui.keyboard.KeyboardShortcutHandler | @@ -482,8 +486,15 @@ fun MainNavigation() { | 482 | 486 | backStack.add(detail.route) | 483 | 487 | } | 484 | 488 | } | | 489 | + val feedbackSheet = rememberFeedbackSheetState() | | 490 | + FeedbackSheet( | | 491 | + sheetState = feedbackSheet, | | 492 | + screen = FeedbackScreen.Settings, | | 493 | + captureScreen = false, | | 494 | + ) | 485 | 495 | val settings: @Composable () -> Unit = { | 486 | 496 | SettingsScreen( | | 497 | + onSendFeedbackClick = feedbackSheet::open, | 487 | 498 | onComponentGalleryClick = { | 488 | 499 | openSettingsDetail(SettingsDetail.ComponentGallery) | 489 | 500 | }, | @@ -769,6 +780,8 @@ fun MainNavigation() { | 769 | 780 | SessionComposerGalleryScreen() | 770 | 781 | ComponentGalleryEntryId.DictationCard -> | 771 | 782 | DictationCardGalleryScreen() | | 783 | + ComponentGalleryEntryId.FeedbackComposer -> | | 784 | + FeedbackComposerGalleryScreen() | 772 | 785 | ComponentGalleryEntryId.RenderedMarkdown -> | 773 | 786 | RenderedMarkdownGalleryScreen() | 774 | 787 | ComponentGalleryEntryId.MessageList -> Unit | |
Collapse file Copy file name to clipboard +62Lines changed: 62 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package dev.opencode.mobile.data.local | | 2 | + | | 3 | +import android.content.Context | | 4 | +import android.content.SharedPreferences | | 5 | +import androidx.security.crypto.EncryptedSharedPreferences | | 6 | +import androidx.security.crypto.MasterKey | | 7 | +import dagger.hilt.android.qualifiers.ApplicationContext | | 8 | +import dev.opencode.mobile.domain.diagnostic.DiagnosticLog | | 9 | +import dev.opencode.mobile.domain.diagnostic.DiagnosticLogArea | | 10 | +import dev.opencode.mobile.domain.feedback.FeedbackIdentityStore | | 11 | +import javax.inject.Inject | | 12 | +import javax.inject.Singleton | | 13 | + | | 14 | +/** | | 15 | + * The feedback anonymous user's refresh token, in Keystore-backed encrypted preferences | | 16 | + * like the connection credentials ([EncryptedSecureCredentialStore]). | | 17 | + */ | | 18 | +@Singleton | | 19 | +class EncryptedFeedbackIdentityStore | | 20 | + @Inject | | 21 | + constructor( | | 22 | + @param:ApplicationContext private val context: Context, | | 23 | + ) : FeedbackIdentityStore { | | 24 | + @Volatile | | 25 | + private var cachedPreferences: SharedPreferences? = null | | 26 | + | | 27 | + private fun preferences(): SharedPreferences? { | | 28 | + cachedPreferences?.let { return it } | | 29 | + val built = | | 30 | + runCatching { | | 31 | + EncryptedSharedPreferences.create( | | 32 | + context, | | 33 | + PREFS_NAME, | | 34 | + MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build(), | | 35 | + EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | | 36 | + EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, | | 37 | + ) | | 38 | + }.getOrElse { error -> | | 39 | + DiagnosticLog.warning( | | 40 | + DiagnosticLogArea.Connection, | | 41 | + "Unable to open encrypted feedback identity store", | | 42 | + error, | | 43 | + ) | | 44 | + null | | 45 | + } | | 46 | + cachedPreferences = built | | 47 | + return built | | 48 | + } | | 49 | + | | 50 | + override fun readRefreshToken(): String? = preferences()?.getString(KEY_REFRESH_TOKEN, null)?.takeIf { it.isNotEmpty() } | | 51 | + | | 52 | + override fun writeRefreshToken(token: String?) { | | 53 | + val editor = preferences()?.edit() ?: return | | 54 | + if (token.isNullOrEmpty()) editor.remove(KEY_REFRESH_TOKEN) else editor.putString(KEY_REFRESH_TOKEN, token) | | 55 | + editor.apply() | | 56 | + } | | 57 | + | | 58 | + private companion object { | | 59 | + const val PREFS_NAME = "secure_feedback_identity" | | 60 | + const val KEY_REFRESH_TOKEN = "feedback.refreshToken" | | 61 | + } | | 62 | + } |
Collapse file Copy file name to clipboard +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package dev.opencode.mobile.di | | 2 | + | | 3 | +import dagger.Binds | | 4 | +import dagger.Module | | 5 | +import dagger.hilt.InstallIn | | 6 | +import dagger.hilt.components.SingletonComponent | | 7 | +import dev.opencode.mobile.data.local.EncryptedFeedbackIdentityStore | | 8 | +import dev.opencode.mobile.domain.feedback.DeviceFeedbackMetadataSource | | 9 | +import dev.opencode.mobile.domain.feedback.FeedbackAttachmentRenderer | | 10 | +import dev.opencode.mobile.domain.feedback.FeedbackCooldownStore | | 11 | +import dev.opencode.mobile.domain.feedback.FeedbackIdentityStore | | 12 | +import dev.opencode.mobile.domain.feedback.FeedbackMetadataSource | | 13 | +import dev.opencode.mobile.domain.feedback.SharedPreferencesFeedbackCooldownStore | | 14 | +import dev.opencode.mobile.ui.feedback.DeviceFeedbackAttachmentRenderer | | 15 | + | | 16 | +/** In-app feedback (#721). The build-type `FeedbackSubmitterModule` binds the submitter. */ | | 17 | +@Module | | 18 | +@InstallIn(SingletonComponent::class) | | 19 | +abstract class FeedbackModule { | | 20 | + @Binds | | 21 | + abstract fun bindFeedbackMetadataSource(impl: DeviceFeedbackMetadataSource): FeedbackMetadataSource | | 22 | + | | 23 | + @Binds | | 24 | + abstract fun bindFeedbackCooldownStore(impl: SharedPreferencesFeedbackCooldownStore): FeedbackCooldownStore | | 25 | + | | 26 | + @Binds | | 27 | + abstract fun bindFeedbackAttachmentRenderer(impl: DeviceFeedbackAttachmentRenderer): FeedbackAttachmentRenderer | | 28 | + | | 29 | + @Binds | | 30 | + abstract fun bindFeedbackIdentityStore(impl: EncryptedFeedbackIdentityStore): FeedbackIdentityStore | | 31 | +} |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/domain/connection/ConnectionProbeService.kt +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,10 +26,12 @@ class ConnectionProbeService( | 26 | 26 | * | 27 | 27 | * Throws [ServerProbeError] when no health endpoint is usable. | 28 | 28 | */ | 29 | | - override suspend fun probe(connection: ServerConnection): ServerProtocol { | | 29 | + override suspend fun probe(connection: ServerConnection): ServerProtocol = probeServer(connection).protocol | | 30 | + | | 31 | + override suspend fun probeServer(connection: ServerConnection): DetectedServer { | 30 | 32 | val client = clientFactory(connection) | 31 | 33 | try { | 32 | | - return detector.detect( | | 34 | + return detector.detectServer( | 33 | 35 | fetchGlobalHealth = { client.fetchHealth("global/health") }, | 34 | 36 | fetchApiInfo = { client.fetchHealth("api/info") }, | 35 | 37 | fetchApiHealth = { client.fetchHealth("api/health") }, | |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/domain/connection/ConnectionProbing.kt +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,4 +4,7 @@ import dev.opencode.mobile.network.ServerConnection | 4 | 4 |
| 5 | 5 | fun interface ConnectionProbing { | 6 | 6 | suspend fun probe(connection: ServerConnection): ServerProtocol | | 7 | + | | 8 | + /** [probe] plus the reported server version. Probes that only know the protocol omit it. */ | | 9 | + suspend fun probeServer(connection: ServerConnection): DetectedServer = DetectedServer(probe(connection)) | 7 | 10 | } |
Collapse file Copy file name to clipboardExpand all lines: android/app/src/main/java/dev/opencode/mobile/domain/connection/ServerProtocolDetector.kt +27-9Lines changed: 27 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,14 @@ class ServerProtocolDetector( | 19 | 19 | fetchGlobalHealth: suspend () -> HealthDto, | 20 | 20 | fetchApiInfo: suspend () -> HealthDto, | 21 | 21 | fetchApiHealth: suspend () -> HealthDto, | 22 | | - ): ServerProtocol { | | 22 | + ): ServerProtocol = detectServer(fetchGlobalHealth, fetchApiInfo, fetchApiHealth).protocol | | 23 | + | | 24 | + /** [detect] plus the health payload's server version, when the server reports one. */ | | 25 | + suspend fun detectServer( | | 26 | + fetchGlobalHealth: suspend () -> HealthDto, | | 27 | + fetchApiInfo: suspend () -> HealthDto, | | 28 | + fetchApiHealth: suspend () -> HealthDto, | | 29 | + ): DetectedServer { | 23 | 30 | val (globalHealth, apiInfo, apiHealth, lastError) = | 24 | 31 | coroutineScope { | 25 | 32 | val global = | @@ -57,21 +64,26 @@ class ServerProtocolDetector( | 57 | 64 | ServerProtocolProbeErrors.unresolved(globalHealth, lastError), | 58 | 65 | ) | 59 | 66 |
| 60 | | - when { | 61 | | - globalHealth?.healthy == true -> adapter.requireHealthy(globalHealth) | 62 | | - else -> { | 63 | | - val payload = ServerProtocolClassifier.v2Health(apiInfo, apiHealth) | 64 | | - if (payload?.pid != null && payload.healthy == false) { | 65 | | - throw ServerProbeError.Unhealthy(payload.version) | | 67 | + val version = | | 68 | + when { | | 69 | + globalHealth?.healthy == true -> { | | 70 | + adapter.requireHealthy(globalHealth) | | 71 | + globalHealth.version | | 72 | + } | | 73 | + else -> { | | 74 | + val payload = ServerProtocolClassifier.v2Health(apiInfo, apiHealth) | | 75 | + if (payload?.pid != null && payload.healthy == false) { | | 76 | + throw ServerProbeError.Unhealthy(payload.version) | | 77 | + } | | 78 | + payload?.version | 66 | 79 | } | 67 | 80 | } | 68 | | - } | 69 | 81 |
| 70 | 82 | DiagnosticLog.info( | 71 | 83 | DiagnosticLogArea.Connection, | 72 | 84 | "protocol=${protocol.wireValue}", | 73 | 85 | ) | 74 | | - return protocol | | 86 | + return DetectedServer(protocol = protocol, version = version?.trim()?.takeIf { it.isNotEmpty() }) | 75 | 87 | } | 76 | 88 |
| 77 | 89 | private suspend fun probe( | @@ -108,3 +120,9 @@ class ServerProtocolDetector( | 108 | 120 | val lastError: Throwable?, | 109 | 121 | ) | 110 | 122 | } | | 123 | + | | 124 | +/** A probed server: its protocol and the version its health endpoint reported. */ | | 125 | +data class DetectedServer( | | 126 | + val protocol: ServerProtocol, | | 127 | + val version: String? = null, | | 128 | +) |
|