INTEGRATION.md
D8 — Feedback HTTP Submission · Integration
Wires the existing FeedbackBody "Send" (currently a local sent flag) to a
real HTTP POST, with Sending / Sent / Error(+retry) states.
Files in this draft
| Draft file | Destination |
|---|---|
FeedbackState.kt |
app/src/main/java/com/peachpasswords/feedback/FeedbackState.kt (new) |
FeedbackRepository.kt |
app/src/main/java/com/peachpasswords/feedback/FeedbackRepository.kt (new) |
FeedbackBody.kt |
replaces the private FeedbackBody in ui/settings/SettingsCardBodies.kt (do NOT add as a separate file) |
SettingsViewModel.feedback.snippet.kt |
additions to ui/settings/SettingsViewModel.kt (do NOT add as a separate file) |
New package com.peachpasswords.feedback — create the directory.
Endpoint assumption (mirrors the browser source)
Source of truth: ~/projects/peach-browser/src/background/messages.ts, the
SUBMIT_FEEDBACK case (around line 1081) and FEEDBACK_ENDPOINT (line 127).
- The browser ships
FEEDBACK_ENDPOINT = ""and treats empty as a no-op success (if (!FEEDBACK_ENDPOINT) return { ok: true }). The Android repo mirrors this:FeedbackRepository.FEEDBACK_ENDPOINT = ""andsubmit()returns normally (→Sent) when it's blank. So the full UI flow works today with no live backend. - Payload (exact field names from the browser):
{ category, message, version, browser, source }, POSTed asapplication/json. The browser sendssource: "peach-extension"; this draft sendssource: "peach-android"andbrowser: "android".versionisBuildConfig.VERSION_NAME. - TODO for orchestrator: when a real feedback URL exists, set the
FEEDBACK_ENDPOINTconstant inFeedbackRepository.kt. The browser also runsisAllowedCanaryWebhookUrl()SSRF validation before fetching; that guard was not ported (the Android constant is compile-time, not user-supplied). If the endpoint ever becomes configurable, port that validation too.
HTTP client
No new dependency. The project already bundles OkHttp 4.12.0
(app/build.gradle line 100) and uses it in
sync/ChirpSyncTransport.kt. FeedbackRepository uses OkHttpClient +
Request + RequestBody, and org.json.JSONObject (Android platform, no dep)
for the body. The brief mentioned HttpURLConnection as a fallback "unless the
project already bundles an HTTP client" — it does, so OkHttp is used.
DI wiring
FeedbackRepository is annotated @Singleton with an @Inject constructor()
that takes no arguments, so Hilt constructs it automatically — no @Binds /
@Provides module entry is needed (unlike VaultStorage, which needs a
@Binds only because it's an interface). Just add it to the VM constructor.
In SettingsViewModel.kt, add the parameter to the existing @Inject
constructor:
@HiltViewModel
class SettingsViewModel @Inject constructor(
private val vault: VaultRepository,
private val license: LicenseRepository,
private val feedback: FeedbackRepository, // ← add
@ApplicationContext private val appContext: Context,
) : ViewModel() {
Then paste the _feedbackState flow + sendFeedback() + resetFeedback() from
SettingsViewModel.feedback.snippet.kt into the class body.
Imports to add to SettingsViewModel.kt
MutableStateFlow, StateFlow, asStateFlow, launch are already imported.
Add:
import com.peachpasswords.feedback.FeedbackRepository
import com.peachpasswords.feedback.FeedbackState
Composable wiring (SettingsCardBodies.kt)
-
Call site — change line 78 from:
CardId.Feedback -> FeedbackBody(fg)to:
CardId.Feedback -> FeedbackBody(fg, vm)(
vm: SettingsViewModelis already aCardBodyparameter.) -
Body — replace the whole private
FeedbackBody(fg: Color)(currently lines 581-623, the block under theFeedbackcomment banner) with theFeedbackBody(fg: Color, vm: SettingsViewModel)fromFeedbackBody.kt. It reuses the file's existing private helpers (SubLabel,Pill,Hint) and does NOT useSubtleButton(it inlines a Send/Retry button so it can carry a disabled state) —SubtleButtonis unaffected and still used elsewhere.
Imports to add to SettingsCardBodies.kt
Already present: collectAsState, Row, Alignment, size, LocalContext
(unused here). Add:
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.DisposableEffect
import com.peachpasswords.feedback.FeedbackState
import com.peachpasswords.ui.theme.LocalPeachAccent
(androidx.compose.foundation.layout.size and ...layout.Row and
...Alignment are already imported.)
State → UI mapping (per brief §7)
Sending→ Send button disabled + 16dp accentCircularProgressIndicator; category pills and textarea also disabled.Sent→ the existing "Thank you" glass card (unchanged visual).Error→ inline message inPeachColors.Breachbelow the button; button text becomes "Retry" and re-enables (retry path).Idle→ default form.
State resets to Idle via resetFeedback() in a DisposableEffect when the
card leaves composition.
Risks / assumptions
- Blank-message guard is duplicated: the composable already gates Send on
message.isNotBlank(), andsubmit()also throws on blank (matching the browser'smessage_empty). Harmless; the repo guard protects non-UI callers. - No SSRF/allowlist validation ported (constant URL, not user input). Note above if the endpoint becomes configurable.
version/browser/sourcefield values are best-effort interpretations of the browser payload for the Android platform; confirm with backend if/when the endpoint goes live.- Verify
BuildConfigimport resolves: namespace iscom.peachpasswords, socom.peachpasswords.BuildConfig.VERSION_NAMEis correct.