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 — #721 Add in-app feedback on iOS and Android (#722) · opencode-mobile/opencode-mobile@063eb09

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • android
    • app
      • build.gradle.kts
      • src
        • debug/java/dev/opencode/mobile/di
          • FeedbackSubmitterModule.kt
        • main/java/dev/opencode/mobile
          • Navigation.kt
          • data/local
            • EncryptedFeedbackIdentityStore.kt
          • di
            • FeedbackModule.kt
          • domain
            • connection
              • ConnectionProbeService.kt
              • ConnectionProbing.kt
              • ServerProtocolDetector.kt
            • feedback
              • Feedback.kt
              • FeedbackEnvironment.kt
              • FeedbackLogRedactor.kt
              • FeedbackPayloadBuilder.kt
              • FirebaseRestFeedbackSubmitter.kt
          • network
            • ActiveConnectionManager.kt
          • platform
            • SigningCertificate.kt
          • ui
            • componentgallery
              • ComponentGalleryEntry.kt
              • components
                • FeedbackComposerGalleryScreen.kt
            • components
              • chat
                • OpenCodeAttachment.kt
              • input
                • OpenCodeFeedbackComposer.kt
            • feedback
              • FeedbackAttachments.kt
              • FeedbackSheet.kt
              • FeedbackViewModel.kt
            • sessionchat
              • SessionChatScreen.kt
            • settings
              • SettingsScreen.kt
        • release/java/dev/opencode/mobile
          • di
            • FeedbackSubmitterModule.kt
          • domain/observability
            • OpenCodeReleaseObservability.kt
        • test/java/dev/opencode/mobile
          • domain
            • connection
              • ConnectionProbeServiceTest.kt
            • feedback
              • FeedbackLogRedactorTest.kt
              • FeedbackPayloadBuilderTest.kt
              • FirebaseRestFeedbackSubmitterTest.kt
          • network
            • ActiveConnectionManagerProtocolTest.kt
          • ui/feedback
            • FeedbackViewModelTest.kt
    • gradle
      • libs.versions.toml
  • ios/OpenCode Mobile
    • OpenCode Mobile.xcodeproj
      • project.pbxproj
    • OpenCode MobileTests
      • Data/Remote
        • FirebaseFeedbackRESTSubmitterTests.swift
      • Domain
        • Connection
          • ActiveConnectionManagerProtocolTests.swift
          • ConnectionProbeServiceTests.swift
        • Feedback
          • FeedbackAttachmentEncoderTests.swift
          • FeedbackLogRedactorTests.swift
          • FeedbackPayloadBuilderTests.swift
      • UI/Feedback
        • FeedbackViewModelTests.swift
    • OpenCode Mobile
      • ComponentGallery
        • ComponentGalleryDetailView.swift
        • ComponentGalleryEntry.swift
        • Components
          • FeedbackComposerGalleryView.swift
      • Components
        • Chat
          • OpenCodeAttachment.swift
        • Input
          • OpenCodeFeedbackComposer.swift
      • DI
        • AppContainer.swift
      • Data/Remote
        • FirebaseFeedbackRESTSubmitter.swift
        • ProjectsAPIClient.swift
      • Domain
        • Connection
          • ActiveConnectionManager.swift
        • Diagnostic
          • DiagnosticLogBuffer.swift
        • Feedback
          • FeedbackAttachmentEncoder.swift
          • FeedbackGzip.swift
          • FeedbackLogRedactor.swift
          • FeedbackMetadataProvider.swift
          • FeedbackModels.swift
          • FeedbackPayloadBuilder.swift
          • FeedbackStores.swift
        • Observability
          • OpenCodeReleaseObservability.swift
      • OpenCode Mobile.entitlements
      • UI
        • Feedback
          • FeedbackHidePartsView.swift
          • FeedbackLogPreviewView.swift
          • FeedbackScreenCapture.swift
          • FeedbackSheet.swift
          • FeedbackViewModel.swift
        • SessionChat
          • SessionChatView.swift
        • Settings
          • DiagnosticLogsView.swift
          • SettingsView.swift
        • Shared
          • ActivityShareView.swift
  • shared/feedback
    • report.example.json

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

‎android/app/build.gradle.kts‎

Copy file name to clipboardExpand all lines: android/app/build.gradle.kts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ android {
151151
sourceSets {
152152
getByName("test") {
153153
resources.srcDir("../../shared/sse-recovery")
154+
resources.srcDir("../../shared/feedback")
154155
}
155156
}
156157
}
@@ -223,4 +224,5 @@ dependencies {
223224
releaseImplementation(libs.firebase.crashlytics)
224225
releaseImplementation(libs.firebase.analytics)
225226
releaseImplementation(libs.firebase.config)
227+
releaseImplementation(libs.firebase.appcheck.playintegrity)
226228
}
Collapse file

‎android/app/src/debug/java/dev/opencode/mobile/di/FeedbackSubmitterModule.kt‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

‎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
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecorator
4747
import androidx.navigation3.ui.NavDisplay
4848
import dev.opencode.mobile.domain.app.AppVersion
4949
import dev.opencode.mobile.domain.connection.ConnectionProfile
50+
import dev.opencode.mobile.domain.feedback.FeedbackScreen
5051
import dev.opencode.mobile.domain.preferences.AnalyticsConsentPreferences
5152
import dev.opencode.mobile.domain.preferences.DeveloperToolsPreferences
5253
import dev.opencode.mobile.domain.preferences.HomeDisplayPreferences
@@ -74,6 +75,7 @@ import dev.opencode.mobile.ui.componentgallery.components.DialogGalleryScreen
7475
import dev.opencode.mobile.ui.componentgallery.components.DictationCardGalleryScreen
7576
import dev.opencode.mobile.ui.componentgallery.components.DiffStatGalleryScreen
7677
import dev.opencode.mobile.ui.componentgallery.components.EmptyStateGalleryScreen
78+
import dev.opencode.mobile.ui.componentgallery.components.FeedbackComposerGalleryScreen
7779
import dev.opencode.mobile.ui.componentgallery.components.FileTabsGalleryScreen
7880
import dev.opencode.mobile.ui.componentgallery.components.FilterTabsGalleryScreen
7981
import dev.opencode.mobile.ui.componentgallery.components.HunkNavigationPillGalleryScreen
@@ -130,6 +132,8 @@ import dev.opencode.mobile.ui.components.openCodeDetailLeading
130132
import dev.opencode.mobile.ui.connection.ConnectionSetupMode
131133
import dev.opencode.mobile.ui.connection.ConnectionSetupScreen
132134
import dev.opencode.mobile.ui.connection.ConnectionSetupViewModel
135+
import dev.opencode.mobile.ui.feedback.FeedbackSheet
136+
import dev.opencode.mobile.ui.feedback.rememberFeedbackSheetState
133137
import dev.opencode.mobile.ui.icons.OpenCodeIcons
134138
import dev.opencode.mobile.ui.keyboard.KeyboardShortcutAction
135139
import dev.opencode.mobile.ui.keyboard.KeyboardShortcutHandler
@@ -482,8 +486,15 @@ fun MainNavigation() {
482486
backStack.add(detail.route)
483487
}
484488
}
489+
val feedbackSheet = rememberFeedbackSheetState()
490+
FeedbackSheet(
491+
sheetState = feedbackSheet,
492+
screen = FeedbackScreen.Settings,
493+
captureScreen = false,
494+
)
485495
val settings: @Composable () -> Unit = {
486496
SettingsScreen(
497+
onSendFeedbackClick = feedbackSheet::open,
487498
onComponentGalleryClick = {
488499
openSettingsDetail(SettingsDetail.ComponentGallery)
489500
},
@@ -769,6 +780,8 @@ fun MainNavigation() {
769780
SessionComposerGalleryScreen()
770781
ComponentGalleryEntryId.DictationCard ->
771782
DictationCardGalleryScreen()
783+
ComponentGalleryEntryId.FeedbackComposer ->
784+
FeedbackComposerGalleryScreen()
772785
ComponentGalleryEntryId.RenderedMarkdown ->
773786
RenderedMarkdownGalleryScreen()
774787
ComponentGalleryEntryId.MessageList -> Unit
Collapse file

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

Copy file name to clipboard
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

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

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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

‎android/app/src/main/java/dev/opencode/mobile/domain/connection/ConnectionProbeService.kt‎

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 numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ class ConnectionProbeService(
2626
*
2727
* Throws [ServerProbeError] when no health endpoint is usable.
2828
*/
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 {
3032
val client = clientFactory(connection)
3133
try {
32-
return detector.detect(
34+
return detector.detectServer(
3335
fetchGlobalHealth = { client.fetchHealth("global/health") },
3436
fetchApiInfo = { client.fetchHealth("api/info") },
3537
fetchApiHealth = { client.fetchHealth("api/health") },
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/domain/connection/ConnectionProbing.kt‎

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 numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ import dev.opencode.mobile.network.ServerConnection
44

55
fun interface ConnectionProbing {
66
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))
710
}
Collapse file

‎android/app/src/main/java/dev/opencode/mobile/domain/connection/ServerProtocolDetector.kt‎

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 numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ class ServerProtocolDetector(
1919
fetchGlobalHealth: suspend () -> HealthDto,
2020
fetchApiInfo: suspend () -> HealthDto,
2121
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 {
2330
val (globalHealth, apiInfo, apiHealth, lastError) =
2431
coroutineScope {
2532
val global =
@@ -57,21 +64,26 @@ class ServerProtocolDetector(
5764
ServerProtocolProbeErrors.unresolved(globalHealth, lastError),
5865
)
5966

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
6679
}
6780
}
68-
}
6981

7082
DiagnosticLog.info(
7183
DiagnosticLogArea.Connection,
7284
"protocol=${protocol.wireValue}",
7385
)
74-
return protocol
86+
return DetectedServer(protocol = protocol, version = version?.trim()?.takeIf { it.isNotEmpty() })
7587
}
7688

7789
private suspend fun probe(
@@ -108,3 +120,9 @@ class ServerProtocolDetector(
108120
val lastError: Throwable?,
109121
)
110122
}
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+
)

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.