-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat(ios): add experimental SwiftUI client #5178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
t3dotgg
wants to merge
249
commits into
main
Choose a base branch
from
t3code/rebuild-mobile-app-swift
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89,994
−19
Open
Changes from all commits
Commits
Show all changes
249 commits
Select commit
Hold shift + click to select a range
2e8950f
feat(ios): add native T3 Code app
t3dotgg f7a7b84
feat(ios): harden native connectivity
t3dotgg a284538
feat(ios): rebuild onboarding and device access
t3dotgg 334a63e
feat(ios): ship message-first daily UX
t3dotgg 86b49ed
fix(ios): polish native daily flows
t3dotgg 18024d7
feat(ios): redesign native sidebar
t3dotgg 144c47c
feat(ios): add rich home thread metadata
t3dotgg 164aa1c
feat(ios): render rich markdown messages
t3dotgg 9978bec
feat(ios): rebuild the thread composer
t3dotgg a47d96c
feat(ios): rebuild the home sidebar v2
t3dotgg 238b6db
feat(ios): redesign new task composition
t3dotgg f15dbbe
fix(ios): polish native task surfaces
t3dotgg c9ffa0d
feat(ios): merge threads across environments
t3dotgg 0d8604c
feat(ios): surface per-device connection health
t3dotgg 48334b1
feat(ios): support multi-select agent input
t3dotgg b7a2d95
fix(ios): describe camera attachment access
t3dotgg eafc26e
docs(ios): document native multi-device client
t3dotgg 1c98559
fix(ios): refine native task states
t3dotgg 758b26c
fix(ios): reflect active device health
t3dotgg dd2819b
fix(ios): wait for image attachments
t3dotgg cc30cd6
fix(ios): scope native multi-device routing
t3dotgg 99f822f
docs(ios): clarify passive device refresh
t3dotgg 6e91557
fix(ios): space the new task project prompt
t3dotgg b2a9906
fix(ios): keep settings open while removing servers
t3dotgg b1fd47d
feat(ios): distinguish the native app identity
t3dotgg b9acac5
feat(ios): improve native thread readability
t3dotgg 20eaa23
perf(ios): keep the native home list responsive
t3dotgg 9192905
feat(ios): raise the native app type scale
t3dotgg 0debc4c
fix(ios): restore thread exit gestures
t3dotgg 4d883a3
test(ios): cover large native home collections
t3dotgg 6850011
perf(ios): stream incremental thread updates
t3dotgg bc19ee6
perf(ios): cache native markdown rendering
t3dotgg f8d6831
perf(ios): recycle native transcript rows
t3dotgg db7c3d1
perf(ios): recycle native home rows
t3dotgg 4e776fa
chore(ios): give SwiftUI app a unique identity
t3dotgg 147a8d5
fix(ios): stabilize transcript rendering
t3dotgg 8333f8b
fix(ios): unblock repeated thread navigation
t3dotgg de6c811
feat(ios): use official provider logos
t3dotgg 47c46f3
feat(ios): show harness icons on home
t3dotgg af5c0dd
feat(ios): simplify mobile prompt controls
t3dotgg 68146f0
fix(ios): keep threads anchored above keyboard
t3dotgg 271ad1c
fix(ios): dismiss the keyboard immediately
t3dotgg aa18079
feat(ios): persist thread drafts
t3dotgg 559a4fc
feat(ios): add new task workspace controls
t3dotgg dc5d223
feat(ios): add project browse and clone flows
t3dotgg 3238915
feat(ios): complete native task composition
t3dotgg 7ee8018
fix(ios): preserve composer state during loading
t3dotgg dc6e199
fix(ios): harden native task creation
t3dotgg 91016d4
fix(swift-ios): honor environment task preferences
t3dotgg b480757
fix(swift-ios): stabilize model and composer controls
t3dotgg 93dca0b
feat(swift-ios): simplify the mobile composer
t3dotgg e75060b
feat(swift-ios): add rich workspace previews
t3dotgg 29f3260
fix(swift-ios): make mobile delivery resilient
t3dotgg 05296f0
feat(swift-ios): add native platform integrations
t3dotgg e272a33
feat(swift-ios): add secure T3 Connect foundations
t3dotgg 8792b0f
chore(swift-ios): harden native release workflow
t3dotgg dc5a146
docs(swift-ios): keep native CI guidance accurate
t3dotgg 7be3bdf
feat(swift-ios): finish secure T3 Connect runtime
t3dotgg 17508a0
fix(swift-ios): preserve dependent queued messages
t3dotgg d71c8f4
feat(swift-ios): add native task extensions
t3dotgg b3dde07
docs(swift-ios): format native build guide
t3dotgg 7e29cbb
fix(swift-ios): harden transport and persistence
t3dotgg f42acba
fix(swift-ios): make composer state durable
t3dotgg 5af36a7
fix(swift-ios): harden platform integrations
t3dotgg 59c61f5
fix(swift-ios): close connection lifecycle races
t3dotgg d13ec15
fix(swift-ios): clear stale platform state
t3dotgg adab973
fix(swift-ios): tolerate locked install targets
t3dotgg 5265b15
fix(swift-ios): preserve durable outbox state
t3dotgg e6d73a6
fix(swift-ios): keep aggregate refresh alive
t3dotgg 2a9c161
fix(swift-ios): open the photo library picker
t3dotgg 4a02108
feat(swift-ios): render markdown tables
t3dotgg 2a6b37d
fix(swift-ios): keep markdown tables scrollable
t3dotgg ecb4c58
fix(swift-ios): size markdown table rows to content
t3dotgg 91f99fb
fix(swift-ios): show active work and image previews
t3dotgg 825275b
fix(swift-ios): settle threads from swipe actions
t3dotgg c5a6d9f
feat(swift-ios): add server-backed thread pinning
t3dotgg d046292
fix(swift-ios): tolerate evolving provider catalogs
t3dotgg a747183
feat(swift-ios): hydrate full review diffs
t3dotgg 4f9ad1f
fix(swift-ios): preserve pin and legacy picker state
t3dotgg b6d3ddb
feat(swift-ios): wrap plaintext code blocks
t3dotgg 78bdc3d
fix(swift-ios): keep thread pin controls available
t3dotgg 93269ce
fix(swift-ios): stabilize new task environment defaults
t3dotgg da6033e
fix(swift-ios): isolate development installs
t3dotgg 8f80ebe
fix(swift-ios): restore TestFlight sign-in
t3dotgg d03e10a
fix(swift-ios): preserve SwiftUI home label
t3dotgg aaf4f56
perf(swift-ios): cut hot-path waste in networking, state, and caches
t3dotgg 1c9d80c
perf(swift-ios): lighten streaming UI and close lifecycle gaps
t3dotgg a46d087
fix(swift-ios): address review findings on streaming and caps
t3dotgg 081a227
fix(swift-ios): guard streaming renderer against stale drain unwinds
t3dotgg d318768
fix(swift-ios): reject recycled-cell documents in streaming fallback
t3dotgg cd52714
fix(swift-ios): release idle websocket clients
t3dotgg c84aacc
feat(swift-ios): distinguish development builds
t3dotgg ed2191a
docs: distinguish SwiftUI mobile client
t3dotgg e611291
fix(swift-ios): restore active thread context
t3dotgg ee3a8c3
chore(swift-ios): bump TestFlight build to 4
t3dotgg 3eef4da
chore(swift-ios): bump TestFlight build to 5
t3dotgg 2432413
feat(swift-ios): paginate long thread history
t3dotgg 044377e
chore(swift-ios): bump TestFlight build to 6
t3dotgg 9374afb
feat(swift-ios): add T3 Connect to onboarding
t3dotgg 4ed72c8
chore(swift-ios): bump TestFlight build to 7
t3dotgg a695a06
fix(swift-ios): address native client reliability feedback
t3dotgg b7a5371
fix(swift-ios): harden cloud and platform lifecycle
t3dotgg 29836bd
fix(swift-ios): reject pre-cancelled rpc requests
t3dotgg 1fb4f7e
chore(swift-ios): bump TestFlight build to 8
t3dotgg f1e7ef0
feat(swift-ios): use Clerk authentication components
t3dotgg 3c0fb86
feat(swift-ios): bring Ghostty to the terminal (#5602)
t3dotgg 2599fc2
chore(swift-ios): bump TestFlight build to 9
t3dotgg 4893418
fix(swift-ios): polish T3 Connect sign in
t3dotgg 924a787
fix(swift-ios): unify T3 Connect provider buttons
t3dotgg 7658346
fix(swift-ios): keep code views readable
t3dotgg db5e628
feat(swift-ios): add light mode
t3dotgg 1855ebf
style(swift-ios): preserve native formatting
t3dotgg 193851a
fix(swift-ios): simplify settings
t3dotgg 102e3b9
fix(swift-ios): stabilize image attachments
t3dotgg 20452a4
chore(swift-ios): prepare TestFlight build 12
t3dotgg 579d7b2
fix(swift-ios): stabilize thread opening and photo selection
t3dotgg d5a763a
chore(swift-ios): prepare TestFlight build 13
t3dotgg 9f2b2f4
ci(swift-ios): add native client checks
t3dotgg 33c039b
fix(swift-ios): harden native client architecture
t3dotgg 8aec310
chore(swift-ios): prepare TestFlight build 14
t3dotgg 17dab74
fix(swift-ios): apply theme changes immediately
t3dotgg d9db81d
fix(swift-ios): stabilize photo attachments
t3dotgg 2fe4738
fix(swift-ios): attach photos after picker dismissal
t3dotgg ca11c4a
fix(swift-ios): own photo picker dismissal
t3dotgg c362d70
fix(swift-ios): keep photo picker presentation alive
t3dotgg 3ee57b8
chore(swift-ios): prepare TestFlight build 19
t3dotgg b946c12
feat(swift-ios): show cached project favicons
t3dotgg 7756dbd
fix(swift-ios): keep new tasks on the selected project
t3dotgg b59ff66
feat(swift-ios): show active subagent work
t3dotgg d621aef
fix(swift-ios): simplify background work status
t3dotgg a5ceb8d
fix(ci): repair SwiftUI fixture verification (#5674)
saphid 4833cd7
fix(ios): add compact header menu clearance (#5663)
saphid 2a8f778
fix(ios): preserve project picker scroll during refresh (#5660)
saphid 8a155ec
fix(swift-ios): distinguish monitoring from working
t3dotgg f4c560e
fix(swift-ios): address review findings
t3dotgg 0e0f31b
fix(swift-ios): close auth reentrancy gaps
t3dotgg 17fb389
fix(swift-ios): serialize connect sign-out
t3dotgg a108823
test(swift-ios): make native CI fast and deterministic
t3dotgg 699418f
fix(swift-ios): close remaining review gaps
t3dotgg 9101cfd
fix(swift-ios): keep activation state consistent
t3dotgg 6cad8ce
fix(swift-ios): complete activation recovery
t3dotgg dfa65e1
fix(swift-ios): stop notification launch crashes
t3dotgg 6e41a71
feat(swift-ios): add usage analytics (#5933)
t3dotgg 2902f47
chore(ci): upload SwiftUI build 24 to TestFlight
t3dotgg f6e43ff
Revert "chore(ci): upload SwiftUI build 24 to TestFlight"
t3dotgg c602618
fix(swift-ios): load T3 Connect devices from relay
t3dotgg 4681a51
chore(ci): upload SwiftUI build 25 to TestFlight
t3dotgg f40bb7d
fix(ci): use distribution signing for SwiftUI archive
t3dotgg d6fa5f3
chore(ci): inspect iOS signing certificates
t3dotgg f7d49a7
fix(ci): clean up orphaned iOS certificates
t3dotgg 1f8021d
revert: remove one-use SwiftUI TestFlight job
t3dotgg 2ccdd15
refactor(swift-ios): scope state to each connection
t3dotgg bda3690
feat(swift-ios): add unified connections hub
t3dotgg b5d7acf
chore(swift-ios): bump build number to 26
t3dotgg e014512
test(swift-ios): use environment-scoped provider catalogs (#6130)
saphid d06115d
fix(swift-ios): improve live duration accessibility (#5993)
saphid a19dbb0
fix(swift-ios): keep skills popup clear of the keyboard (#5971)
saphid acc6c62
fix(swift-ios): keep usage refresh truthful (#5992)
saphid 6dcad2e
fix(swift-ios): enable granular text selection (#6110)
saphid e1bbd87
feat(swift-ios): default new tasks to recent project (#5802)
saphid c58f927
fix(swift-ios): restore thread scrolling and back swipe (#6090)
saphid 8d21072
chore(swift-ios): bump build number to 27
t3dotgg 7fce990
fix(swift-ios): remove done badges from thread rows
t3dotgg 91d2738
feat(swift-ios): unify environment management
t3dotgg 0d347a5
chore(swift-ios): bump build number to 28
t3dotgg f2fdcc9
fix(swift-ios): remove done status from thread headers
t3dotgg 423f607
chore(swift-ios): bump build number to 29
t3dotgg ca4908b
fix(swift-ios): restore environment screen layout
t3dotgg 54680d3
fix(swift-ios): tolerate mixed usage servers
t3dotgg fce7740
chore(swift-ios): bump build number to 30
t3dotgg e7bfce1
feat(swift-ios): add recent mobile parity features
t3dotgg 96bfa25
feat(swift-ios): add pull request hub
t3dotgg 551ba70
fix(swift-ios): show reactions on review threads
t3dotgg d6ec156
chore(swift-ios): bump build number to 31
t3dotgg 78ba44d
ci(swift-ios): right-size native test runner to 12 vCPU macOS (#7285)
t3dotgg ebfc189
feat(swift-ios): show build identity in settings (#7355)
saphid efdf1ae
fix(swift-ios): open thread links inside the app (#7343)
saphid a943fe6
fix(swift-ios): grow composer within available viewport (#7299)
saphid 0784ed2
feat(swift-ios): surface recent projects in the project picker (#7370)
saphid 8c7273e
feat(swift-ios): settle thread rows with a full swipe (#7342)
saphid 38895a1
chore(swift-ios): bump build number to 32
t3dotgg ac319f4
fix(swift-ios): keep new tasks in the open project
t3dotgg 01838f7
Revert "fix(swift-ios): keep new tasks in the open project"
t3dotgg 961a3ae
fix(swift-ios): use project group names on home rows
t3dotgg efaec0b
feat(swift-ios): paste images from the composer's native menu (#7607)
mackinleysmith 434a01f
feat(swift-ios): attach images dragged onto the composer (#7701)
mackinleysmith b252d84
fix(swift-ios): keep the command menu above the composer (#7695)
mackinleysmith c227632
chore(swift-ios): bump build number to 33
t3dotgg 4b3dccb
fix(swift-ios): preserve live updates during thread loading (#7206)
saphid efa82a6
fix(swift-ios): clean up settings, environments, and thread actions (…
t3dotgg 82b2dad
chore(swift-ios): bump build number to 34
t3dotgg 9c4647e
fix(swift-ios): prevent lost messages and stale account access (#7974)
t3dotgg 13241a5
fix(swift-ios): make thread settling immediate and smooth
t3dotgg 8015360
fix(swift-ios): restore live updates and paginate pull requests
t3dotgg b961318
chore(swift-ios): bump build number to 36
t3dotgg 0f25803
feat(swift-ios): show pull request status in the inbox
t3dotgg 6512cff
Merge latest main into SwiftUI client branch
t3dotgg cd2b2f8
feat(swift-ios): match recent server and mobile improvements
t3dotgg 557f81c
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg 04dff61
chore(swift-ios): bump build number to 37
t3dotgg a7d2781
fix(swift-ios): keep long composer drafts above the controls
t3dotgg 9c7500a
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg 5653ea1
feat(swift-ios): add linked pull requests and native file links
t3dotgg de040ab
chore(swift-ios): bump build number to 38
t3dotgg 22b22f1
feat(swift-ios): open pull requests from the thread menu
t3dotgg 93285c4
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg cee01c0
fix(swift-ios): show legacy models in favorites
t3dotgg d8b15a3
fix(swift-ios): show cached thread recovery and update server parity
t3dotgg bbfef08
chore(swift-ios): bump build number to 39
t3dotgg a431425
fix(swift-ios): open thread pull requests in browser
t3dotgg b34af15
fix(swift-ios): stabilize thread navigation and scrolling
t3dotgg 1700886
fix(swift-ios): restore self-sizing transcript rows
t3dotgg ecf2339
revert(swift-ios): restore original transcript scrolling
t3dotgg b678379
fix(swift-ios): match thread settlement behavior
t3dotgg c49bcc5
feat(swift-ios): restore permissions and improve model options
t3dotgg 891d622
fix(swift-ios): prevent new task composer clipping
t3dotgg 9d3d8d5
fix(swift-ios): keep thread model choices available
t3dotgg 1a59936
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg db87e6c
feat(ios): add attachments, voice, and server parity
t3dotgg 67d0e7d
docs(swiftui): document native mobile behavior
t3dotgg 14ca1e1
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg 6b7af5f
chore(ios): prepare build 40 for TestFlight
t3dotgg 7734dab
fix(swift-ios): keep caret after command completion (#8428)
mackinleysmith 9a3aef3
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg c759bf7
fix(ios): keep native build tooling compatible with main
t3dotgg 6475a05
fix(ios): resume cached threads after backgrounding
t3dotgg 7f6e659
chore(ios): prepare TestFlight build 41
t3dotgg 55a68b3
Merge remote-tracking branch 'origin/main' into t3code/rebuild-mobile…
t3dotgg e706cdc
fix(ios): scope composer skills to the current workspace
t3dotgg 4d37b0b
feat(ios): add environment-scoped provider setup
t3dotgg 00be9a1
feat(ios): sync icons and improve previews and recovery
t3dotgg a54fb31
feat(ios): sync shared preferences and show tool app icons
t3dotgg acb03c5
chore(ios): prepare beta build 42
t3dotgg b7934d0
fix(ios): preserve unknown image support for saved models
t3dotgg 459cc4e
style: apply the updated formatter to merged code
t3dotgg 2cb106f
perf(swift-ios): parse long responses with fewer scans (#9675)
t3dotgg 9c0debf
perf(swift-ios): speed up large snapshot timestamp parsing (#9683)
t3dotgg e03d9fb
fix(swift-ios): make swipe-to-settle removal smooth (#9680)
t3dotgg f9498b7
fix(swift-ios): keep thread catch-up complete and visible (#9678)
t3dotgg 14dd5a5
fix(swift-ios): use the provisioned development app group
t3dotgg b96b6c0
fix(swift-ios): keep snapshots on their source environment
t3dotgg 27cf5b2
fix(swift-ios): save new attachments before uploading
t3dotgg 4dda339
fix(swift-ios): keep the keyboard open during voice input
t3dotgg 2bf6c8e
chore(swift-ios): prepare TestFlight build 46
t3dotgg 854c822
build(swift-ios): add API-key TestFlight commands
t3dotgg b994054
build(swift-ios): read TestFlight credentials from a private env file
t3dotgg 3e57219
chore(swift-ios): merge latest main
t3dotgg 8dd2e1b
feat(swift-ios): add limits and catch up with mobile changes
t3dotgg fd146b7
chore(swift-ios): merge latest main onboarding changes
t3dotgg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| interface: | ||
| display_name: "Test T3 Mobile" | ||
| short_description: "Test T3 Code on iOS or Android" | ||
| default_prompt: "Use $test-t3-mobile to launch T3 Code against an isolated backend and verify the affected flow on an available simulator or emulator." | ||
| short_description: "Test React Native or SwiftUI T3 clients" | ||
| default_prompt: "Use $test-t3-mobile to select the affected React Native or SwiftUI client, launch it against an isolated backend, and verify the flow on an available simulator or emulator." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: SwiftUI iOS | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "apps/swift-ios/**" | ||
| - "packages/contracts/**" | ||
| - "scripts/generate-swift-wire-fixtures.ts" | ||
| - "scripts/package.json" | ||
| - ".github/workflows/swift-ios.yml" | ||
| - "package.json" | ||
| - "pnpm-lock.yaml" | ||
| - "pnpm-workspace.yaml" | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "apps/swift-ios/**" | ||
| - "packages/contracts/**" | ||
| - "scripts/generate-swift-wire-fixtures.ts" | ||
| - "scripts/package.json" | ||
| - ".github/workflows/swift-ios.yml" | ||
| - "package.json" | ||
| - "pnpm-lock.yaml" | ||
| - "pnpm-workspace.yaml" | ||
|
|
||
| concurrency: | ||
| group: swift-ios-${{ github.event.pull_request.number || github.sha }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Contract fixtures and native tests | ||
| runs-on: blacksmith-12vcpu-macos-26 | ||
| timeout-minutes: 25 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| sparse-checkout: | | ||
| /* | ||
| !/.repos/ | ||
| sparse-checkout-cone-mode: false | ||
|
|
||
| - name: Setup Vite+ | ||
| uses: voidzero-dev/setup-vp@v1 | ||
| with: | ||
| node-version-file: package.json | ||
| cache: true | ||
| run-install: | | ||
| args: | ||
| - --filter=@t3tools/scripts... | ||
|
|
||
| - name: Verify generated wire fixtures | ||
| run: node scripts/generate-swift-wire-fixtures.ts --check | ||
|
|
||
| - name: Test SwiftUI client | ||
| run: apps/swift-ios/Scripts/ci-test.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .derivedData/ | ||
| DerivedData/ | ||
| *.xcuserstate | ||
| xcuserdata/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import ClerkKit | ||
| import Foundation | ||
|
|
||
| public struct T3ConnectAccount: Equatable, Sendable { | ||
| public let id: String | ||
| public let email: String? | ||
| public let imageURL: URL? | ||
| } | ||
|
|
||
| public enum T3ConnectAuthError: LocalizedError, Sendable { | ||
| case noSession | ||
|
|
||
| public var errorDescription: String? { | ||
| switch self { | ||
| case .noSession: | ||
| "Sign in to your T3 account to use T3 Connect." | ||
| } | ||
| } | ||
| } | ||
|
|
||
| enum T3ConnectAuthCallback { | ||
| static let scheme = PlatformRoute.nativeScheme | ||
| static let redirectURL = "\(scheme)://clerk-callback" | ||
| } | ||
|
|
||
| /// Small ClerkKit boundary. Clerk owns encrypted session persistence and the | ||
| /// ASWebAuthenticationSession callback; the app only asks for the relay JWT. | ||
| @MainActor | ||
| public final class T3ConnectClerkSession { | ||
| private let clerk: Clerk | ||
| private let jwtTemplate: String | ||
|
|
||
| public init(configuration: T3ConnectConfiguration) { | ||
| jwtTemplate = configuration.clerkJWTTemplate | ||
| clerk = Clerk.configure( | ||
| publishableKey: configuration.clerkPublishableKey, | ||
| options: .init( | ||
| redirectConfig: .init( | ||
| redirectUrl: T3ConnectAuthCallback.redirectURL, | ||
| callbackUrlScheme: T3ConnectAuthCallback.scheme | ||
| ) | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| var client: Clerk { clerk } | ||
|
|
||
| public var account: T3ConnectAccount? { | ||
| guard let user = clerk.user else { return nil } | ||
| return T3ConnectAccount( | ||
| id: user.id, | ||
| email: user.primaryEmailAddress?.emailAddress, | ||
| imageURL: URL(string: user.imageUrl) | ||
| ) | ||
| } | ||
|
|
||
| public var isLoaded: Bool { clerk.isLoaded } | ||
|
|
||
| public func refresh() async throws { | ||
| _ = try await clerk.refreshClient() | ||
| } | ||
|
|
||
| public func signOut() async throws { | ||
| try await clerk.auth.signOut() | ||
| } | ||
|
|
||
| public func relayToken() async throws -> String { | ||
| let token = try await clerk.auth.getToken( | ||
| .init(template: jwtTemplate, expirationBuffer: 20) | ||
| ) | ||
| guard let token, !token.isEmpty else { throw T3ConnectAuthError.noSession } | ||
| return token | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.