Repository navigation
feat(ios): Add a native iOS client on the public MCP API - #3544
Conversation
SwiftUI app under apps/ios with a JuniorKit package for API models, Markdown, transcript building, and display rules. Tokens, fonts, and icons come from the dashboard sources. Scripts share one compile cache per machine and use one throwaway simulator at a time. Co-Authored-By: Claude <[email protected]>
Match web line heights, header and dock geometry, settings, and run and plan rows. Fix upload scoping, archive timestamps, stale tool previews, duplicate thread cards, overlapping loads, and read positions. Store the personal token in the Keychain. Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Read positions count only after the page settles and keep the New line in place; versions polls compare one Conversation's tokens. Ambient messages show once handled. Section labels apply at the top level only. Stale pages, undo rollbacks, fork targets, Keychain status, simulator signing, swipe back on deep links, and the stale-lock takeover are fixed. Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Show Connect when the dashboard rejects the token. It opens the dashboard's API Tokens page, where the viewer signs in with Google and copies a token, and takes the pasted token. Read the signing team and bundle ID from an ignored Local.xcconfig, and add scripts/device.sh to build, install, and open the app on an iPhone.
The repo type-checks every TypeScript file in a project, and this dev script needs no project of its own.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
21 screenshot changes — 21 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots3 more changed screenshots in Frameshift. |
Read and write through Junior's MCP server (/api/mcp) instead of the dashboard's /api routes, which the app cannot write to with a token. Sign in with its OAuth flow: PKCE, Google sign-in and consent in a browser sheet, the redirect on a loopback listener, and tokens in the Keychain. The client ID is the URL of oauth-client.json. What MCP does not offer opens on the web: answering a Review item and changing an Automation. Transcripts show user and assistant messages.
Swift crashed type-checking the sign-in callbacks that captured non-Sendable state; keep that state on the main actor instead. The mock server now serves Junior's MCP tools and OAuth endpoints over the dashboard's mock data, for UI tests and screenshots. JuniorKit decodes tool results captured from it.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 5 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d171494. Configure here.
| signOut() | ||
| throw JuniorAPIError.signedOut | ||
| } | ||
| } |
There was a problem hiding this comment.
Cancelled refresh spends single-use token
High Severity
refreshedToken runs the token exchange in an unstructured Task and only the owner saves the result. If that owner is cancelled at await task.value — a SwiftUI .task disappearing, a search debounce restart — defer clears refreshing and the new tokens are discarded. Waiters may use the new access token once without persisting it. The next call then refreshes with the already-spent single-use refresh token, gets invalid_grant, and signOut() drops the session.
Reviewed by Cursor Bugbot for commit d171494. Configure here.
| } catch JuniorAPIError.tool { | ||
| // The cursor stopped working (the transcript was replaced); start over. | ||
| cursor = nil | ||
| await open(app) |
There was a problem hiding this comment.
Cursor recovery keeps old transcript
Medium Severity
When getConversation rejects a cursor because the transcript was replaced, refresh clears cursor and calls open, but open still mergeMessages into the existing array. Old rows whose seq values are absent from the new page stay on screen, so the transcript can mix pre- and post-replacement messages.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d171494. Configure here.
| .task(id: [query, scope, state]) { | ||
| if loaded { try? await Task.sleep(for: .milliseconds(250)) } | ||
| await load() | ||
| } |
There was a problem hiding this comment.
Stale automation search can win
Medium Severity
The automations .task swallows debounce cancellation and always calls load(), and load applies whatever response arrives last. HomeModel and InboxModel drop out-of-order successes with a ticket; this screen does not, so a slower older query, scope, or state can replace the list the user is looking at.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d171494. Configure here.
| error = nil | ||
| } catch let error as JuniorAPIError { | ||
| self.error = error | ||
| } catch {} |
There was a problem hiding this comment.
Stale search errors clobber fresh lists
Medium Severity
Success handling in HomeModel.load and InboxModel.load ignores older tickets, but the JuniorAPIError branch always writes error. A failed in-flight search or 15s refresh that started earlier can set error after a newer load already succeeded, so the list keeps the new rows while refreshFailed shows “Could not refresh.”
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d171494. Configure here.
| actionError = (error as? JuniorAPIError)?.localizedDescription ?? "Message failed to send. Try again." | ||
| return false | ||
| } | ||
| } |
There was a problem hiding this comment.
Sends never refresh the home list
Medium Severity
send, stop, and cancelQueued update the open conversation but never call app.didWrite(). Pin, archive, unfollow, and NewConversationComposer do, which is what bumps conversationsVersion so Home reloads. After sending or stopping, the stacked home list can keep a stale status (no “Working…”, still active) until the 15s tick.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d171494. Configure here.
#3544 left two lint errors on `main`: - `AGENTS.md` grew past the core doc length limit. This drops the clause "one simulator at a time, build before boot, and delete the device after", because `sim.sh` enforces it and `apps/ios/README.md` already says it. - The iOS mock server used `Array#forEach` twice. Both are now `for…of` loops that do the same thing. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3Af7dacf3ebf6bfba61b9dfd4c --> -- [View Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3Af7dacf3ebf6bfba61b9dfd4c) [[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Af7dacf3ebf6bfba61b9dfd4c/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
Stacked on #3544. Nothing in CI builds or tests `apps/ios` yet. This adds an iOS workflow that runs when `apps/ios` changes. - **`test / build`**: `swift test` for JuniorKit, then an unsigned Release build for device. That is the configuration that the TestFlight lane in the next PR signs. - **`test / ui and screenshots`**: builds the dashboard, starts the mock MCP server, and runs `NavigationUITests` through `sim.sh`. Then it saves 10 screenshots of the main screens (Conversations in dark and light, a Conversation and its details, Inbox, a Review item, Automations, an Automation, the drawer, Settings) and uploads them as the `ios-screenshots` artifact. The mock server start and the screenshot list are in `apps/ios/scripts/start-mock-server.sh` and `screenshots.sh`, so you can run the same steps locally to compare screens before and after a change. Each `sim.sh` run uses one temporary simulator and deletes it after. Frameshift is not used yet. Its publish step finds its PR comment by one fixed marker and always sets the `Frameshift` status. An iOS publish step would replace or delete the dashboard's report. Also, Frameshift reads the "before" images only for the exact base commit, so it needs a baseline from every push to `main`. Screenshots: this changes only CI, not what users see, so no screenshot test applies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
The implements a real PKCE OAuth flow for the iOS app using the existing custom schema callback. This is technically possible to be cloned by imposter apps; the alternative is to host a `apple-app-site-association` file on the server identifying legal clients with a regular HTTPS call back URL, but this change does not represent a regression in security posture. We can consider the site association file in a later PR. # Slop Junior now knows the iOS app's OAuth client, so sign-in no longer depends on a hosted Client ID Metadata Document. The app's `client_id` was a raw GitHub URL on the PR branch of #3544. GitHub deleted that branch after the merge, so the URL returned 404, and every sign-in to a real Junior failed with "The client ID is not a valid client metadata document URL." A raw GitHub URL also proves nothing about who owns the client, because anyone can host a file on that host. The change follows how the Seer Apple apps sign in to Sentry: the server knows the client, and the redirect uses the app's own URL scheme. - `JUNIOR_IOS_CLIENT` in `client-metadata.ts` has the ID `https://junior.sentry.dev/clients/ios` and the redirect `junior-ios://oauth/callback`. `resolveMcpClient` returns it without a fetch. The ID stays an HTTPS URL, so it passes the existing client ID rules, and the consent page shows `junior.sentry.dev`. Nothing is served at that URL, and the app sends this ID, so it must not change. - Only this client may use a custom-scheme redirect, and only that exact URI. Other CIMD clients still need `https:` or loopback `http:`, because any app can claim a URL scheme. `redirectUriMatches` now takes the client, so it can apply this rule. - The app gets the redirect from `ASWebAuthenticationSession`, which gives a scheme redirect only to the app that opened the sheet. The `LoopbackReceiver` NWListener and `oauth-client.json` are deleted. The mock server also accepts the new redirect. A server that runs an older Junior rejects the new client ID. So the app can sign in to prod only after a release with this change. Prod also needs a release with #2951 (`turnActive`), because the app cannot read `searchConversations` results from 0.310.0. We could also keep a CIMD document at the new URL, so that older servers still accept the app. We did not, because prod is the only known server for the app. No screenshot test applies: the sign-in screen does not change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: andrew <[email protected]>


Adds
apps/ios, a native SwiftUI client for Junior. It matches the mobile layout of the dashboard'sclassicshell (Conversations, the Inbox, Automations, Settings, and the navigation drawer, in dark and light themes) and uses only Junior's public API: the MCP server at/api/mcp.Sign-in is the MCP OAuth flow: authorization code with PKCE, Google sign-in and the consent page in a browser sheet, and tokens in the Keychain. Junior registers no clients, so the app's
client_idis the URL ofapps/ios/oauth-client.json, a Client ID Metadata Document. For now that URL is this branch's raw GitHub copy; it needs a stable published URL before release (AppModel.oauthClientID). Junior accepts onlyhttpsand loopback redirect URIs, so the app listens onhttp://127.0.0.1:<port>/callbackfor the one redirect, as desktop MCP clients do.What it does through MCP:
getConversationcursors, and pages history.delivery: interrupt).What MCP does not offer opens the dashboard in an in-app browser: answering a Review item, changing an Automation. Transcripts have user and assistant messages and the Brief, but no tool calls. There is no read position, attachments, or spend.
Logic with no UI (the MCP client and OAuth, tool result models, Markdown, display rules) is in the
JuniorKitSwift package and runs withswift test. Its tests cover PKCE, the refresh path, and decoding of captured tool results. UI tests run againstapps/ios/scripts/mock-server.mjs, which serves a mock of the MCP tools and OAuth endpoints over the dashboard's mock data. The full sign-in flow runs in a UI test. The project has no third-party dependencies, and XcodeGen generates it.apps/ios/README.mdcovers simulators and iPhones.AGENTS.mdgets an iOS section: use only the public MCP server, plus the machine rules (one throwaway simulator under a lock, build before boot, one compilation cache shared across checkouts).Worth a careful look:
Packages/JuniorKit/Sources/JuniorKit/API/MCPClient.swift: refresh tokens are single-use, so concurrent calls share one refresh.Junior/App/BrowserSignIn.swift: the loopback receiver.