experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(build): add --standalone flag to embed real frontend in iOS builds

build-ios.sh always replaced dist/index.html with a bootstrap redirect
to the HMR dev server. The e2e test built with this script but never ran
a dev server, so the webview loaded a dead redirect — no frontend, no
IPC commands, and ensure_database_initialized() was never called. This
caused Phase 3 dedup to silently never run.

Add --standalone flag that skips the bootstrap replacement and embeds the
real bundled frontend. The e2e test now uses --standalone so the app
loads its actual UI, invokes Rust IPC commands naturally, and DB
initialization (including dedup migration) happens via the normal lazy
path.

Reverts the eager DB init from d3f23354 — lazy init on first DB access
is the correct design since the Share Extension also needs it.

+36 -18
+25 -14
backend/tauri-mobile/build-ios.sh
··· 16 16 # Parse flags 17 17 FORCE_REBUILD=false 18 18 NO_CACHE=false 19 + STANDALONE=false 19 20 while [ $# -gt 0 ]; do 20 21 case "$1" in 21 22 --force|-f) ··· 24 25 --no-cache) 25 26 NO_CACHE=true 26 27 ;; 28 + --standalone) 29 + STANDALONE=true 30 + ;; 27 31 *) 28 32 echo "Unknown option: $1" 29 - echo "Usage: $0 [--force|-f] [--no-cache]" 33 + echo "Usage: $0 [--force|-f] [--no-cache] [--standalone]" 30 34 exit 1 31 35 ;; 32 36 esac ··· 57 61 npm run build 58 62 cd "$TAURI_DIR" 59 63 60 - # Replace dist/index.html with bootstrap redirect BEFORE cargo build 61 - # so Tauri's custom-protocol embeds the redirect, not the real app. 62 - # The actual app will be served by the vite HMR dev server. 63 - # DEV_PORT env var is set by dev-ios-sim.sh with the actual port. 64 - echo "Creating bootstrap HTML for dev server mode..." 65 - cp "$SCRIPT_DIR/dev-bootstrap.html" "$SCRIPT_DIR/dist/index.html" 66 - mkdir -p "$TAURI_DIR/gen/apple/assets" 67 - cp "$SCRIPT_DIR/dev-bootstrap.html" "$TAURI_DIR/gen/apple/assets/index.html" 68 - if [ -n "$DEV_PORT" ]; then 69 - sed -i.bak "s/__DEV_PORT__/$DEV_PORT/g" "$SCRIPT_DIR/dist/index.html" 70 - rm -f "$SCRIPT_DIR/dist/index.html.bak" 71 - sed -i.bak "s/__DEV_PORT__/$DEV_PORT/g" "$TAURI_DIR/gen/apple/assets/index.html" 72 - rm -f "$TAURI_DIR/gen/apple/assets/index.html.bak" 64 + if [ "$STANDALONE" = true ]; then 65 + # Standalone mode: embed the real bundled frontend (no dev server needed) 66 + echo "Embedding bundled frontend for standalone mode..." 67 + mkdir -p "$TAURI_DIR/gen/apple/assets" 68 + cp "$SCRIPT_DIR/dist/index.html" "$TAURI_DIR/gen/apple/assets/index.html" 69 + else 70 + # Dev mode: replace dist/index.html with bootstrap redirect BEFORE cargo build 71 + # so Tauri's custom-protocol embeds the redirect, not the real app. 72 + # The actual app will be served by the vite HMR dev server. 73 + # DEV_PORT env var is set by dev-ios-sim.sh with the actual port. 74 + echo "Creating bootstrap HTML for dev server mode..." 75 + cp "$SCRIPT_DIR/dev-bootstrap.html" "$SCRIPT_DIR/dist/index.html" 76 + mkdir -p "$TAURI_DIR/gen/apple/assets" 77 + cp "$SCRIPT_DIR/dev-bootstrap.html" "$TAURI_DIR/gen/apple/assets/index.html" 78 + if [ -n "$DEV_PORT" ]; then 79 + sed -i.bak "s/__DEV_PORT__/$DEV_PORT/g" "$SCRIPT_DIR/dist/index.html" 80 + rm -f "$SCRIPT_DIR/dist/index.html.bak" 81 + sed -i.bak "s/__DEV_PORT__/$DEV_PORT/g" "$TAURI_DIR/gen/apple/assets/index.html" 82 + rm -f "$TAURI_DIR/gen/apple/assets/index.html.bak" 83 + fi 73 84 fi 74 85 75 86 echo "Building Rust for iOS simulator (debug)..."
+8 -1
backend/tauri-mobile/src-tauri/src/lib.rs
··· 4918 4918 tauri::Builder::default() 4919 4919 .plugin(tauri_plugin_opener::init()) 4920 4920 .setup(move |_app| { 4921 + // Eagerly initialize database on app start (runs migrations including dedup) 4922 + // This ensures one-time migrations run even if the frontend hasn't loaded yet 4923 + match ensure_database_initialized() { 4924 + Ok(()) => println!("[Rust] Database initialized on startup"), 4925 + Err(e) => println!("[Rust] WARNING: Database init on startup failed: {}", e), 4926 + } 4927 + 4921 4928 if auto_sync_on_launch { 4922 4929 println!("[Rust] PEEK_AUTO_SYNC enabled - triggering sync on launch"); 4923 4930 // Spawn async task to sync after app is ready 4924 4931 tauri::async_runtime::spawn(async move { 4925 - // Small delay to ensure database is fully initialized 4932 + // Small delay to let app UI settle before syncing 4926 4933 std::thread::sleep(std::time::Duration::from_secs(2)); 4927 4934 4928 4935 // Check if sync is configured before attempting
+3 -3
scripts/e2e-full-sync-test.sh
··· 192 192 cd "$PROJECT_DIR" 193 193 yarn build 194 194 echo " Desktop build complete" 195 - yarn mobile:ios:build --force 195 + yarn mobile:ios:build --force --standalone 196 196 echo " iOS Rust library build complete" 197 197 198 198 # --- Step 2: Find and wipe iOS simulator data --- ··· 1207 1207 echo " The dedup migration runs in ensure_database_initialized() on startup." 1208 1208 echo " Polling iOS database for dedup_cleanup_v1 flag..." 1209 1209 1210 - IOS_POLL_TIMEOUT=120 1210 + IOS_POLL_TIMEOUT=30 1211 1211 IOS_POLL_INTERVAL=3 1212 1212 IOS_POLL_ELAPSED=0 1213 1213 ··· 1217 1217 echo " iOS dedup flag detected!" 1218 1218 break 1219 1219 fi 1220 - echo " ... waiting for iOS app restart (${IOS_POLL_ELAPSED}s elapsed)" 1220 + echo " ... waiting for iOS dedup (${IOS_POLL_ELAPSED}s elapsed)" 1221 1221 sleep "$IOS_POLL_INTERVAL" 1222 1222 IOS_POLL_ELAPSED=$(($IOS_POLL_ELAPSED + $IOS_POLL_INTERVAL)) 1223 1223 done