* fix(security): fail closed on biometric init error H-03: setting isAuthenticated: true on initialization failure was a security bypass — any crash during biometric setup granted full access. Fail closed instead; user sees auth prompt on next open. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(security): use Crypto.randomUUID for connection IDs H-04: Math.random() is not cryptographically random. Connection IDs are used as SecureStore key suffixes; switch to expo-crypto randomUUID for a secure source. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(deps): pin expo-crypto to ~15.0.9 15.0.10 does not exist on npm; ~15.0.9 is the latest stable in the 15.x series compatible with Expo SDK 54. * feat: add OpenCode Connect coming-soon waitlist card Adds a discoverable 'OpenCode Connect — Coming Soon' card to the add-connection quick-connect screen. Users can enter their email and tap 'Join Waitlist' to send a pre-filled mailto. No backend required. * fix(cua): detect actual screen dimensions and fix JSON parsing - Get real screen size via `wm size` instead of hardcoding 1080x2400; emulator is 1080x1920 so y-coordinates were systematically off - Extract first JSON object via regex when model returns multiple objects - Use AZURE_OPENAI_MODEL env var for deployment name (defaults gpt-5.4) - Add AZURE_DEV_AI_* path for Azure AI Foundry endpoints Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(security): SHA-pin upload-google-play and sanitize notification bodies M-02: Pin r0adkll/upload-google-play to commit SHA e738b9d (v1.1.5) to prevent supply-chain hijack via tag mutation. M-03: Sanitize all push notification bodies — strip control chars, truncate to 200 chars. Prevents server-supplied strings (error messages, file paths from permission patterns, session titles) from leaking unbounded text into the OS notification drawer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(privacy): add telemetry consent gate for Sentry crash reporting Sentry was always-on, violating F-Droid anti-feature policy and user trust norms. Now gated behind explicit opt-in: - First-launch consent modal (TelemetryConsentModal) shows once on fresh install; user can Allow or Decline. - Consent state persisted in expo-secure-store (survives restarts). - Settings > Privacy section: crash reporting toggle + privacy policy link. - initSentry() called only after consent granted — not on app start. Closes #3 (partial) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(config): add real icons and complete iOS/Android app.json config - Add 1024×1024 app icon, 432×432 adaptive icon foreground, 200×200 splash - iOS: push notification entitlement (aps-environment: production), speech/ microphone/camera/photo usage descriptions for future features, disable ITSAppUsesNonExemptEncryption - Android: adaptive icon with dark background (#0F172A), versionCode: 1 - expo-notifications plugin wired in app.json Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(dist): add iOS CI workflow, README rewrite, CONTRIBUTING, and LICENSE - publish-app-store.yml: EAS Build + TestFlight submission; runs on tag/release/ workflow_dispatch; bumps ios.buildNumber from github.run_number - README: full rewrite — features, install badges, connection guide, contributing - CONTRIBUTING.md: contribution guide for OSS contributors - LICENSE: MIT Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(dist): add store listings, strategy, privacy policy, F-Droid/IzzyOnDroid templates - distribution/strategy.md: monetization strategy (free client + opencode Cloud) - distribution/play-listing.md: Google Play store copy (name, description, tags) - distribution/app-store-listing.md: App Store listing copy - distribution/privacy-policy.{md,html}: GDPR-compliant privacy policy - distribution/PLAY_CONSOLE_SETUP.md: Play Console setup runbook - distribution/ios-enrollment-runbook.md: Apple Developer Program enrollment steps - distribution/SIGNING-KEY-FINGERPRINTS.md: keystore fingerprint for reproducible builds - distribution/fdroid-submission/: F-Droid metadata template - distribution/izzyondroid-submission/: IzzyOnDroid submission template - distribution/whatsnew/: Play Store release notes (en-US) - distribution/whatsnew-ios/: TestFlight release notes - distribution/play-graphics/: Play Store screenshot placeholders - distribution/app-store-graphics/: App Store screenshot placeholders Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(telemetry): handle SecureStore failure + Android back button - add .catch() on loadTelemetryConsent() so SecureStore rejection shows the consent modal instead of blocking startup forever - add onRequestClose={onDecline} to Modal so Android back button records the decline rather than silently dismissing - fix catch block in telemetry.ts to not clobber _resolved when SecureStore read fails mid-session Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ci): run gradlew clean to prevent stale modules.json duplicate Sentry Gradle plugin writes modules.json to src/main/assets; cached build intermediates contain an old copy → mergeReleaseAssets fails with 'Duplicate resources'. Running clean before assembleRelease clears the intermediate state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ci): remove android build output cache causing duplicate modules.json Caching android/app/build/intermediates and android/app/.cxx causes two issues: 1. Stale modules.json in intermediates → Duplicate resources error 2. .cxx CMake artifacts reference absolute paths → ninja clean fails Keeping only Gradle distribution cache (~/.gradle) which is safe. Expo prebuild regenerates android sources fresh each run anyway. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
326 lines
9.6 KiB
TypeScript
326 lines
9.6 KiB
TypeScript
import { useCallback, useState } from "react"
|
|
import {
|
|
View,
|
|
Text,
|
|
ScrollView,
|
|
TouchableOpacity,
|
|
Switch,
|
|
StyleSheet,
|
|
useColorScheme,
|
|
Linking,
|
|
Alert,
|
|
} from "react-native"
|
|
import { Ionicons } from "@expo/vector-icons"
|
|
import { useAuth } from "../../src/stores/auth"
|
|
import { useSettings } from "../../src/stores/settings"
|
|
import {
|
|
categories,
|
|
categoryMeta,
|
|
setup as setupNotifications,
|
|
granted as notificationsGranted,
|
|
} from "../../src/lib/notifications"
|
|
import type { Category } from "../../src/lib/notifications"
|
|
import { hasTelemetryConsent, setTelemetryConsent } from "../../src/lib/telemetry"
|
|
|
|
function SettingRow({
|
|
icon,
|
|
label,
|
|
description,
|
|
isDark,
|
|
right,
|
|
onPress,
|
|
}: {
|
|
icon: keyof typeof Ionicons.glyphMap
|
|
label: string
|
|
description?: string
|
|
isDark: boolean
|
|
right?: React.ReactNode
|
|
onPress?: () => void
|
|
}) {
|
|
const content = (
|
|
<View style={[styles.settingRow, isDark && styles.settingRowDark]}>
|
|
<View style={[styles.settingIcon, isDark && styles.settingIconDark]}>
|
|
<Ionicons name={icon} size={22} color={isDark ? "#ffffff" : "#0a0a0a"} />
|
|
</View>
|
|
<View style={styles.settingContent}>
|
|
<Text style={[styles.settingLabel, isDark && styles.textDark]}>{label}</Text>
|
|
{description && <Text style={[styles.settingDescription, isDark && styles.metaDark]}>{description}</Text>}
|
|
</View>
|
|
{right}
|
|
</View>
|
|
)
|
|
|
|
if (onPress) {
|
|
return <TouchableOpacity onPress={onPress}>{content}</TouchableOpacity>
|
|
}
|
|
|
|
return content
|
|
}
|
|
|
|
function SettingSection({ title, children, isDark }: { title: string; children: React.ReactNode; isDark: boolean }) {
|
|
return (
|
|
<View style={styles.section}>
|
|
<Text style={[styles.sectionTitle, isDark && styles.sectionTitleDark]}>{title}</Text>
|
|
<View style={[styles.sectionContent, isDark && styles.sectionContentDark]}>{children}</View>
|
|
</View>
|
|
)
|
|
}
|
|
|
|
export default function SettingsScreen() {
|
|
const colorScheme = useColorScheme()
|
|
const isDark = colorScheme === "dark"
|
|
|
|
const { settings, hasBiometrics, updateSettings, lock } = useAuth()
|
|
const { notifications, setNotification } = useSettings()
|
|
const [osGranted, setOsGranted] = useState<boolean | null>(null)
|
|
|
|
// Telemetry consent: hasTelemetryConsent() returns null (unknown), true, or false.
|
|
// We initialise local state from in-memory value; updates call setTelemetryConsent().
|
|
const [crashReporting, setCrashReporting] = useState<boolean>(hasTelemetryConsent() ?? false)
|
|
|
|
const handleCrashReportingToggle = useCallback(async (value: boolean) => {
|
|
setCrashReporting(value)
|
|
await setTelemetryConsent(value)
|
|
}, [])
|
|
|
|
// Check OS permission state on first toggle attempt
|
|
const handleToggle = useCallback(
|
|
async (category: Category, enabled: boolean) => {
|
|
if (enabled) {
|
|
const ok = await setupNotifications()
|
|
setOsGranted(ok)
|
|
if (!ok) {
|
|
Alert.alert(
|
|
"Notifications Disabled",
|
|
"Enable notifications for OpenCode in your device settings to receive alerts.",
|
|
)
|
|
return
|
|
}
|
|
}
|
|
setNotification(category, enabled)
|
|
},
|
|
[setNotification],
|
|
)
|
|
|
|
// Lazy-check OS permission for status display
|
|
if (osGranted === null) {
|
|
notificationsGranted()
|
|
.then(setOsGranted)
|
|
.catch(() => setOsGranted(false))
|
|
}
|
|
|
|
return (
|
|
<ScrollView style={[styles.container, isDark && styles.containerDark]} contentContainerStyle={styles.content}>
|
|
<SettingSection title="Security" isDark={isDark}>
|
|
<SettingRow
|
|
icon="finger-print"
|
|
label="Require Biometric to Open"
|
|
description={
|
|
hasBiometrics ? "Use Face ID or Touch ID to unlock the app" : "Biometric authentication not available"
|
|
}
|
|
isDark={isDark}
|
|
right={
|
|
<Switch
|
|
value={settings.requireBiometric}
|
|
onValueChange={(value) => updateSettings({ requireBiometric: value })}
|
|
disabled={!hasBiometrics}
|
|
trackColor={{ false: "#767577", true: "#22c55e" }}
|
|
/>
|
|
}
|
|
/>
|
|
<SettingRow
|
|
icon="lock-closed"
|
|
label="Require Biometric to Send"
|
|
description="Authenticate before sending messages"
|
|
isDark={isDark}
|
|
right={
|
|
<Switch
|
|
value={settings.requireBiometricForMessages}
|
|
onValueChange={(value) => updateSettings({ requireBiometricForMessages: value })}
|
|
disabled={!hasBiometrics || !settings.requireBiometric}
|
|
trackColor={{ false: "#767577", true: "#22c55e" }}
|
|
/>
|
|
}
|
|
/>
|
|
{settings.requireBiometric && (
|
|
<SettingRow
|
|
icon="exit"
|
|
label="Lock App Now"
|
|
description="Require authentication to reopen"
|
|
isDark={isDark}
|
|
onPress={lock}
|
|
right={<Ionicons name="chevron-forward" size={20} color={isDark ? "#666666" : "#999999"} />}
|
|
/>
|
|
)}
|
|
</SettingSection>
|
|
|
|
<SettingSection title="Notifications" isDark={isDark}>
|
|
{categories.map((category) => {
|
|
const meta = categoryMeta[category]
|
|
return (
|
|
<SettingRow
|
|
key={category}
|
|
icon={meta.icon as keyof typeof Ionicons.glyphMap}
|
|
label={meta.label}
|
|
description={meta.description}
|
|
isDark={isDark}
|
|
right={
|
|
<Switch
|
|
value={notifications[category]}
|
|
onValueChange={(value) => handleToggle(category, value)}
|
|
trackColor={{ false: "#767577", true: "#22c55e" }}
|
|
/>
|
|
}
|
|
/>
|
|
)
|
|
})}
|
|
{osGranted === false && (
|
|
<View style={[styles.settingRow, isDark && styles.settingRowDark]}>
|
|
<Text style={[styles.settingDescription, { color: "#ef4444", paddingLeft: 48 }]}>
|
|
Notifications are disabled at the system level. Enable them in Settings to receive alerts.
|
|
</Text>
|
|
</View>
|
|
)}
|
|
</SettingSection>
|
|
|
|
<SettingSection title="Privacy" isDark={isDark}>
|
|
<SettingRow
|
|
icon="shield-checkmark"
|
|
label="Crash Reporting"
|
|
description="Share anonymous crash reports via Sentry to help improve OpenCode. No code or prompts are included."
|
|
isDark={isDark}
|
|
right={
|
|
<Switch
|
|
value={crashReporting}
|
|
onValueChange={handleCrashReportingToggle}
|
|
trackColor={{ false: "#767577", true: "#22c55e" }}
|
|
/>
|
|
}
|
|
/>
|
|
<SettingRow
|
|
icon="document-text"
|
|
label="Privacy Policy"
|
|
description="What data we collect and how"
|
|
isDark={isDark}
|
|
onPress={() => Linking.openURL("https://www.vibebrowser.app/opencode-mobile/privacy")}
|
|
right={<Ionicons name="open-outline" size={20} color={isDark ? "#666666" : "#999999"} />}
|
|
/>
|
|
</SettingSection>
|
|
|
|
<SettingSection title="About" isDark={isDark}>
|
|
<SettingRow icon="information-circle" label="Version" description="1.0.0" isDark={isDark} />
|
|
<SettingRow
|
|
icon="logo-github"
|
|
label="GitHub"
|
|
description="View source code"
|
|
isDark={isDark}
|
|
onPress={() => Linking.openURL("https://github.com/anomalyco/opencode")}
|
|
right={<Ionicons name="open-outline" size={20} color={isDark ? "#666666" : "#999999"} />}
|
|
/>
|
|
<SettingRow
|
|
icon="document-text"
|
|
label="Documentation"
|
|
description="Learn how to use OpenCode"
|
|
isDark={isDark}
|
|
onPress={() => Linking.openURL("https://opencode.ai/docs")}
|
|
right={<Ionicons name="open-outline" size={20} color={isDark ? "#666666" : "#999999"} />}
|
|
/>
|
|
</SettingSection>
|
|
|
|
<View style={styles.footer}>
|
|
<Text style={[styles.footerText, isDark && styles.metaDark]}>OpenCode Mobile</Text>
|
|
<Text style={[styles.footerText, isDark && styles.metaDark]}>
|
|
Connect to your AI coding assistant from anywhere
|
|
</Text>
|
|
</View>
|
|
</ScrollView>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
backgroundColor: "#f5f5f5",
|
|
},
|
|
containerDark: {
|
|
backgroundColor: "#0a0a0a",
|
|
},
|
|
content: {
|
|
paddingBottom: 32,
|
|
},
|
|
section: {
|
|
marginTop: 24,
|
|
},
|
|
sectionTitle: {
|
|
fontSize: 13,
|
|
fontWeight: "600",
|
|
color: "#666666",
|
|
marginLeft: 16,
|
|
marginBottom: 8,
|
|
textTransform: "uppercase",
|
|
},
|
|
sectionTitleDark: {
|
|
color: "#888888",
|
|
},
|
|
sectionContent: {
|
|
backgroundColor: "#ffffff",
|
|
borderTopWidth: 1,
|
|
borderBottomWidth: 1,
|
|
borderColor: "#e5e5e5",
|
|
},
|
|
sectionContentDark: {
|
|
backgroundColor: "#1a1a1a",
|
|
borderColor: "#2a2a2a",
|
|
},
|
|
settingRow: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
paddingVertical: 12,
|
|
paddingHorizontal: 16,
|
|
borderBottomWidth: 1,
|
|
borderBottomColor: "#e5e5e5",
|
|
},
|
|
settingRowDark: {
|
|
borderBottomColor: "#2a2a2a",
|
|
},
|
|
settingIcon: {
|
|
width: 36,
|
|
height: 36,
|
|
borderRadius: 8,
|
|
backgroundColor: "#f5f5f5",
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
marginRight: 12,
|
|
},
|
|
settingIconDark: {
|
|
backgroundColor: "#2a2a2a",
|
|
},
|
|
settingContent: {
|
|
flex: 1,
|
|
},
|
|
settingLabel: {
|
|
fontSize: 16,
|
|
color: "#0a0a0a",
|
|
},
|
|
textDark: {
|
|
color: "#ffffff",
|
|
},
|
|
settingDescription: {
|
|
fontSize: 13,
|
|
color: "#666666",
|
|
marginTop: 2,
|
|
},
|
|
metaDark: {
|
|
color: "#888888",
|
|
},
|
|
footer: {
|
|
alignItems: "center",
|
|
padding: 32,
|
|
},
|
|
footerText: {
|
|
fontSize: 13,
|
|
color: "#999999",
|
|
textAlign: "center",
|
|
},
|
|
})
|