feat: open channel previews from QR deeplinks#2305
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds channel-preview deep-link contracts, registers native URL schemes and associated domains, installs a native deep-link handler, adds a /preview/channel landing route, extends the scanner to process preview links and start preview sessions, builds channel-specific QR deep links, and threads preview mode through backend queries, validation, and tests. ChangesChannel preview deep-linking and QR support
Sequence Diagram(s)sequenceDiagram
participant OS as Operating System
participant DeepLinkService as src/services/deepLinks.ts
participant Router as Vue Router
participant Scanner as src/pages/scan.vue
OS->>DeepLinkService: appUrlOpen event or launch URL
alt Preview deep-link
DeepLinkService->>Router: navigate /scan?preview=URL
Router->>Scanner: route with preview param
else Console HTTPS
DeepLinkService->>Router: navigate original pathname+search+hash
end
sequenceDiagram
participant Scanner as src/pages/scan.vue
participant Parser as src/services/previewLinks.ts
participant Updater as CapacitorUpdater
participant API as Capgo API
Scanner->>Scanner: check route.query.preview
alt Preview param exists
Scanner->>Parser: parseChannelPreviewDeepLink(url)
Parser-->>Scanner: ChannelPreviewLink
Scanner->>API: getLatest({ preview: true }) for channel
API-->>Scanner: bundle metadata
Scanner->>Updater: download & set(bundle)
Updater-->>Scanner: applied
Scanner->>Updater: startPreviewSession()
else No preview param
Scanner->>Scanner: start barcode scanner
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/services/deepLinks.ts (1)
4-4: ⚡ Quick winUse
~/alias instead of relative import insrc/code.Please switch this import to the project alias to match frontend import conventions.
Suggested fix
-import { parseChannelPreviewDeepLink } from './previewLinks' +import { parseChannelPreviewDeepLink } from '~/services/previewLinks'As per coding guidelines: "Import using
~/alias forsrc/directory in frontend code instead of relative paths".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/services/deepLinks.ts` at line 4, The import in deepLinks.ts currently uses a relative path for parseChannelPreviewDeepLink; update the import to use the project alias for src by replacing the relative import ("./previewLinks") with the alias path ("~/services/previewLinks" or whichever alias maps to the previewLinks module) so parseChannelPreviewDeepLink is imported via the ~/ root import convention consistent with frontend code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@android/app/src/main/AndroidManifest.xml`:
- Around line 28-30: The Android app-link intent filter is missing the staging
host declared by isCapgoConsoleHost(); add a new <data android:scheme="https"
android:host="console.staging.capgo.app" /> entry alongside the existing
console.capgo.app, console.dev.capgo.app, and console.preprod.capgo.app <data>
elements inside the app's intent-filter in AndroidManifest.xml so HTTPS deep
links for console.staging.capgo.app will be handed off to the app.
In `@ios/App/App/App.entitlements`:
- Around line 9-12: Add the missing staging associated-domain entry by inserting
the applinks domain string for staging (applinks:console.staging.capgo.app)
alongside the existing applinks entries (e.g., applinks:console.capgo.app,
applinks:console.dev.capgo.app, applinks:console.preprod.capgo.app) in the
App.entitlements so iOS universal links from staging will open the app; ensure
the new string follows the same XML <string>…</string> pattern as the others.
In `@src/pages/scan.vue`:
- Around line 97-103: The code sets the preview channel via
CapacitorUpdater.next() before confirming the preview will work; defer changing
the channel until after startPreviewSession()/getLatest() and any download
succeed, or if you must change it earlier, capture the original channel (via
CapacitorUpdater.current()/current.bundle.id) and ensure you call
CapacitorUpdater.setChannel()/CapacitorUpdater.next() to restore that original
channel in every error path (catch blocks) and before exiting the fallback
branch; update the logic around startPreviewSession(), getLatest(),
CapacitorUpdater.next(), and the error handlers so the preview channel is only
persisted on successful start and is restored on failure.
---
Nitpick comments:
In `@src/services/deepLinks.ts`:
- Line 4: The import in deepLinks.ts currently uses a relative path for
parseChannelPreviewDeepLink; update the import to use the project alias for src
by replacing the relative import ("./previewLinks") with the alias path
("~/services/previewLinks" or whichever alias maps to the previewLinks module)
so parseChannelPreviewDeepLink is imported via the ~/ root import convention
consistent with frontend code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 64b9922e-537d-44de-85e6-07f50db563b1
📒 Files selected for processing (11)
android/app/src/main/AndroidManifest.xmlios/App/App/App.entitlementsios/App/App/Info.plistsrc/components/BundlePreviewFrame.vuesrc/main.tssrc/pages/app/[app].channel.[channel].preview.vuesrc/pages/preview/channel.vuesrc/pages/scan.vuesrc/route-map.d.tssrc/services/deepLinks.tssrc/services/previewLinks.ts
4e2111a to
e436e42
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/updates.test.ts`:
- Line 587: Change the two new tests from synchronous `it()` to parallel
`it.concurrent()` to follow the repo's parallel-test convention: locate the test
with the description "allows preview requests to fetch a private target channel
when app preview is enabled" and replace `it(` with `it.concurrent(`, and do the
same for the other new test referenced in the comment (around line 646) so both
run concurrently within the same file.
- Around line 618-643: The test flips shared app state by setting allow_preview
to true then later resetting it; wrap the mutable section (the call that sets
allow_preview true, the setup of baseData, the call to postUpdate and assertions
using postUpdate and parseSchema/updateNewScheme) in a try/finally so the final
supabase update that sets allow_preview back to false always runs even if
assertions throw; locate the two supabase.update calls referencing
APP_NAME_UPDATE and move the second one into a finally block, keeping
throwOnError on both updates to surface errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 883969bd-2731-44e8-bd42-df73dc42ebbf
📒 Files selected for processing (10)
capacitor.config.tssrc/pages/scan.vuesupabase/functions/_backend/utils/pg.tssupabase/functions/_backend/utils/plugin_parser.tssupabase/functions/_backend/utils/plugin_validation.tssupabase/functions/_backend/utils/postgres_schema.tssupabase/functions/_backend/utils/types.tssupabase/functions/_backend/utils/update.tstests/test-utils.tstests/updates.test.ts
|
achimala
left a comment
There was a problem hiding this comment.
This branch depends on updater APIs that the app does not actually ship yet. src/pages/scan.vue calls getLatest({ appId, channel }) and startPreviewSession({ appId }), but bun.lock still resolves @capgo/capacitor-updater to 8.45.11.
In 8.45.11, GetLatestOptions only contains channel, Android/iOS getLatest only read that channel, and there is no native startPreviewSession plugin method registered. The local type cast masks this from TypeScript, but the QR flow will run against the installed native plugin: the target app id will be ignored, and devices can fall back to the old current()/next()/setShakeMenu() branch instead of starting a real cross-app preview session.
Please land/release the updater-side preview APIs and bump @capgo/capacitor-updater plus bun.lock here before merging this app-side QR flow. At minimum, this should have a version guard or native smoke test so the scanner cannot silently advertise cross-app previews while the bundled native plugin is still on the old API surface.



What
appIdand channel directly instead of switching the Capgo app channel.preview: trueupdate checks gated byapps.allow_preview.Why
How
getLatest({ appId, channel, preview: true }), downloads that bundle, then starts a preview session with the target app id.allow_preview.Testing
bun run lint:fixbun run typecheckbun run supabase:startbun run supabase:with-env -- bunx vitest run tests/updates.test.ts(40 passed)Not Tested
Summary by CodeRabbit
New Features
Bug Fixes / Behavior