Skip to content
Open
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: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Shared workspace environment — copy to .env and fill in. Never commit .env.

# Convex dev deployment URL for the mobile client (see apps/mobile/.env.example).
# The DeviceProof harness (apps/mobile/src/device-proof) uses this URL to run the
# 3-request photo upload against the real dev deployment when set; when unset it
# falls back to a deterministic in-memory fake transport (rows are labeled with
# which transport produced them). No credentials belong in this file.
EXPO_PUBLIC_CONVEX_URL=
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ dist/
.expo/
*.tsbuildinfo

# Expo prebuild output (Continuous Native Generation — regenerate with
# `npx expo prebuild -p ios --no-install`; not committed per Expo convention)
apps/mobile/ios/
apps/mobile/android/

# Env files (real values only; .env.example files are committed)
.env
.env.local
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Convex dev deployment URL — shown by `npx convex dev` after `npx convex login`.
# Example: https://reliable-panther-823.convex.cloud
# The DeviceProof harness (src/device-proof) runs the 3-request photo upload
# against the real dev deployment when this is set; when unset it falls back to
# a deterministic in-memory fake transport. Never commit this file or real URLs.
EXPO_PUBLIC_CONVEX_URL=
68 changes: 61 additions & 7 deletions apps/mobile/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,81 @@
import { ConvexProvider, ConvexReactClient } from "convex/react"
import { useMemo } from "react"
import { StyleSheet, View } from "react-native"
import { useCallback, useMemo, useState } from "react"
import { Pressable, StyleSheet, Text as RNText, View } from "react-native"

import { Text } from "@journal/ui"

import { getConvexClientUrl } from "./src/lib/convex"
import DeviceProofScreen from "./src/device-proof/DeviceProofScreen"
import { CONVEX_URL_ENV_KEY } from "./src/lib/convex"

type Screen = "home" | "device-proof"

export default function App() {
const client = useMemo(() => new ConvexReactClient(getConvexClientUrl()), [])
const [screen, setScreen] = useState<Screen>("home")

return (
<ConvexProvider client={client}>
<View style={styles.container}>
// The Convex client needs EXPO_PUBLIC_CONVEX_URL; when it is unset the app
// must still boot so the DeviceProof harness can run on the fake transport.
const convexUrl = useMemo(() => {
const raw = process.env[CONVEX_URL_ENV_KEY]?.trim()
return raw === undefined || raw === "" ? null : raw
}, [])
const client = useMemo(() => (convexUrl === null ? null : new ConvexReactClient(convexUrl)), [convexUrl])

const openDeviceProof = useCallback(() => setScreen("device-proof"), [])
const backToHome = useCallback(() => setScreen("home"), [])

const content =
screen === "device-proof" ? (
<DeviceProofScreen onBack={backToHome} />
) : (
<View style={styles.home}>
<Text>Shared Child Journal</Text>
<RNText style={styles.note}>
{convexUrl === null
? `${CONVEX_URL_ENV_KEY} is not set — the device-proof harness runs on the fake transport.`
: "Open the debug harness to exercise the device-proof checklist."}
</RNText>
<Pressable style={styles.button} onPress={openDeviceProof}>
<RNText style={styles.buttonText}>Device proof checklist</RNText>
</Pressable>
</View>
)

if (client === null) {
return <View style={styles.container}>{content}</View>
}
return (
<ConvexProvider client={client}>
<View style={styles.container}>{content}</View>
</ConvexProvider>
)
}

const styles = StyleSheet.create({
button: {
backgroundColor: "#0969da",
borderRadius: 6,
marginTop: 12,
paddingHorizontal: 16,
paddingVertical: 10,
},
buttonText: {
color: "#ffffff",
fontSize: 14,
fontWeight: "600",
},
container: {
flex: 1,
},
home: {
alignItems: "center",
flex: 1,
justifyContent: "center",
padding: 16,
},
note: {
color: "#57606a",
fontSize: 12,
marginTop: 8,
textAlign: "center",
},
})
27 changes: 25 additions & 2 deletions apps/mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@
"slug": "shared-child-journal",
"version": "0.1.0",
"scheme": "sharedchildjournal",
"platforms": ["ios", "android"],
"newArchEnabled": true
"platforms": [
"ios",
"android"
],
"newArchEnabled": true,
"plugins": [
[
"expo-audio",
{
"microphonePermission": "Allow Shared Child Journal to access your microphone so you can dictate journal entries."
}
],
[
"expo-image-picker",
{
"photosPermission": "Allow Shared Child Journal to attach pictures to journal entries."
}
]
],
"ios": {
"infoPlist": {
"NSSpeechRecognitionUsageDescription": "Shared Child Journal transcribes your dictated entries on-device."
},
"bundleIdentifier": "com.anonymous.shared-child-journal"
}
}
}
9 changes: 7 additions & 2 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
"scripts": {
"typecheck": "tsc -p tsconfig.json --noEmit",
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios"
"android": "expo run:android",
"ios": "expo run:ios"
},
"dependencies": {
"@journal/spike-voice-photo": "workspace:*",
"@journal/ui": "workspace:*",
"@react-native-ai/apple": "0.12.0",
"convex": "^1.46.0",
"effect": "4.0.0-rc.115",
"expo": "~57.0.23",
"expo-audio": "57.0.5",
"expo-file-system": "57.0.7",
"expo-image-picker": "57.0.18",
"react": "19.2.3",
"react-native": "0.86.3"
},
Expand Down
223 changes: 223 additions & 0 deletions apps/mobile/src/device-proof/DeviceProofScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import { useCallback, useState } from 'react'
import { Pressable, ScrollView, StyleSheet, Text as RNText, View } from 'react-native'
import { RecordingPresets, useAudioRecorder } from 'expo-audio'

import { Text } from '@journal/ui'

import {
BOGUS_LOCALE,
checkConvexUpload,
checkLocaleMatrix,
checkPhotoPick,
checkPrepare,
checkRecordAndTranscribe,
checkTurboModuleProbe,
PROOF_LOCALES,
} from './checks'
import type { EvidenceClass, EvidenceRow, EvidenceStatus } from './evidence'
import { nextRowId, toRow, type EvidenceEntry, type EvidenceLog } from './evidence'

/**
* DeviceProof debug screen — the on-device vehicle for the PR #8 10-item
* device-proof checklist. Runs checks (a)-(f) and logs timestamped evidence
* rows on-screen, each labeled simulator / fake / hardware-only-blocked so a
* reviewer can tell mechanically-produced evidence from hardware-pending
* evidence at a glance.
*/

const STATUS_STYLES: Record<EvidenceStatus, { color: string; tag: string }> = {
pass: { color: '#1a7f37', tag: 'PASS' },
fail: { color: '#cf222e', tag: 'FAIL' },
skipped: { color: '#9a6700', tag: 'SKIP' },
info: { color: '#0969da', tag: 'INFO' },
}

const CLASS_TAGS: Record<EvidenceClass, string> = {
simulator: '[simulator]',
fake: '[fake]',
'hardware-only-blocked': '[hardware-only-blocked]',
}

interface DeviceProofScreenProps {
readonly onBack: () => void
}

export default function DeviceProofScreen({ onBack }: DeviceProofScreenProps) {
const [rows, setRows] = useState<readonly EvidenceRow[]>([])
const [running, setRunning] = useState(false)
const recorder = useAudioRecorder(RecordingPresets.HIGH_QUALITY)

const append = useCallback((entry: EvidenceEntry) => {
setRows((previous) => [toRow(entry, nextRowId(previous), new Date().toISOString()), ...previous])
}, [])

const runCheck = useCallback(
async (run: (log: EvidenceLog) => Promise<void>) => {
if (running) return
setRunning(true)
try {
await run(append)
} finally {
setRunning(false)
}
},
[append, running],
)

const runAll = useCallback(() => {
void runCheck(async (log) => {
checkTurboModuleProbe(log)
checkLocaleMatrix(log)
await checkPrepare(log)
await checkRecordAndTranscribe(recorder, log)
const picked = await checkPhotoPick(log)
await checkConvexUpload(picked, log)
})
}, [recorder, runCheck])

const buttons: readonly { readonly title: string; readonly run: () => void }[] = [
{
title: 'Run all (a-f)',
run: runAll,
},
{
title: 'a) TurboModule probe',
run: () => void runCheck(async (log) => checkTurboModuleProbe(log)),
},
{
title: 'b) Locale matrix',
run: () => void runCheck(async (log) => checkLocaleMatrix(log)),
},
{
title: "c) prepare('en-US')",
run: () => void runCheck(async (log) => checkPrepare(log)),
},
{
title: 'd) Record ~5s + transcribe',
run: () => void runCheck(async (log) => checkRecordAndTranscribe(recorder, log)),
},
{
title: 'e) Pick photo',
run: () => void runCheck(async (log) => void (await checkPhotoPick(log))),
},
{
title: 'f) Convex upload (no pick)',
run: () => void runCheck(async (log) => checkConvexUpload(null, log)),
},
]

return (
<View style={styles.container}>
<Text>Device proof — PR #8 checklist harness</Text>
<RNText style={styles.hint}>
Checks (a)-(f) with {PROOF_LOCALES.length}+1 locales (incl. bogus {BOGUS_LOCALE}). Rows carry a
class label: [simulator] = mechanically verifiable here, [fake] = deterministic in-memory
double, [hardware-only-blocked] = needs an iOS 26 device / dev-client build.
</RNText>

<View style={styles.buttonGrid}>
{buttons.map((button) => (
<Pressable
key={button.title}
style={[styles.button, running && styles.buttonDisabled]}
disabled={running}
onPress={button.run}
>
<RNText style={styles.buttonText}>{running ? 'Running…' : button.title}</RNText>
</Pressable>
))}
</View>

<Pressable style={[styles.button, styles.backButton]} onPress={onBack}>
<RNText style={styles.buttonText}>← Back to home</RNText>
</Pressable>

<ScrollView style={styles.log}>
{rows.length === 0 ? (
<RNText style={styles.empty}>No evidence rows yet — run a check.</RNText>
) : (
rows.map((row) => (
<View key={row.id} style={styles.row}>
<RNText style={styles.rowHeader}>
#{row.id} · {row.at}
</RNText>
<RNText style={styles.rowLabel}>
<RNText style={{ color: STATUS_STYLES[row.status].color }}>{STATUS_STYLES[row.status].tag}</RNText>
{' '}
<RNText style={styles.classTag}>{CLASS_TAGS[row.evidenceClass]}</RNText>
{' '}
{row.label}
</RNText>
<RNText style={styles.rowDetail}>{row.detail}</RNText>
</View>
))
)}
</ScrollView>
</View>
)
}

const styles = StyleSheet.create({
backButton: {
backgroundColor: '#444c56',
},
button: {
backgroundColor: '#0969da',
borderRadius: 6,
paddingHorizontal: 10,
paddingVertical: 8,
},
buttonDisabled: {
opacity: 0.5,
},
buttonGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 8,
},
buttonText: {
color: '#ffffff',
fontSize: 13,
fontWeight: '600',
},
container: {
flex: 1,
padding: 16,
paddingTop: 48,
},
classTag: {
color: '#57606a',
fontWeight: '700',
},
empty: {
color: '#57606a',
fontSize: 13,
marginTop: 12,
},
hint: {
color: '#57606a',
fontSize: 12,
marginBottom: 12,
},
log: {
flex: 1,
marginTop: 8,
},
row: {
borderBottomColor: '#d0d7de',
borderBottomWidth: StyleSheet.hairlineWidth,
paddingVertical: 6,
},
rowDetail: {
color: '#333b42',
fontSize: 11,
},
rowHeader: {
color: '#8c959f',
fontSize: 10,
},
rowLabel: {
fontSize: 12,
fontWeight: '600',
},
})
Loading
Loading