Repository navigation
feat: open protected conversation files in the app (open-protected-file) - #70
Merged
Merged
Conversation
Projects with authenticated conversation files serve them from
files.gleap.io/af/<id> (files.us.gleap.ai in the US), readable only with the
session's file session. Safari does not have it, so a protected file could
not be opened or saved from the app.
- session-update announces capabilities.openProtectedFile; the Messenger sends
open-protected-file {url, name} only to SDKs that announce it.
- GleapProtectedFiles downloads the file with X-File-Session as the only
credential (no cookies, no cache, no redirect), only from the files host of
the configured API region (or the local API's own origin), keeps it under
Caches/gleap-files and shows it in QuickLook over the widget, whose share
button saves it. The file is deleted when QuickLook closes, with the next
download and on clearIdentity; a download on its way for another user is
dropped.
- Without a valid file session the file waits for the renewal and opens with
the next session update.
- open-url, tapped links and window.open to a protected file go the same way
instead of to Safari (403). open-url with blob: is ignored: as an app link it
closed the widget.
- Links QuickLook and UniformTypeIdentifiers (Package.swift, podspec).
Tests: GleapProtectedFilesTests, including a page in a real WKWebView posting
open-protected-file through the bridge and QuickLook appearing over the widget
in a window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xcodebuild -quiet prints only the names of failing tests, so a CI failure showed no message, log or attachment. test.sh now writes a result bundle (build/TestResults.xcresult, TEST_RESULT_BUNDLE to override) and CI uploads it as an artifact when the tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
testTheMessengersMessageOpensTheFileInQuickLook failed in CI (run
44128972531, iPhone 16e / iOS 26.2): one 30 s deadline covered WebKit
starting its processes for the test page, the download and the presentation.
On a freshly erased iPhone 16e / iOS 26.2 simulator WebKit alone takes 30 to
40 s; the old test failed there the same way ("QuickLook is shown over the
widget", 176 of 177 passed) and the run then hung until xcodebuild collected
diagnostics, because the file presented after the test had ended.
- Step 1 waits for the file request (proves the page's message went through
WebKit's bridge to the SDK), deadline 180 s.
- Step 2 waits for QuickLook to be the widget's presented view controller,
deadline 30 s (about 1 s here). The SwiftPM test host connects no window
scene, so UIKit never finishes a presentation's transition there; the test
checks what UIKit takes, as before, and says so.
- Closing waits for the dismissal's completion, then checks the file is gone.
- Teardown removes the widget from the window, so a download still on its way
presents nothing after the test.
- The link spy's openExternalLink takes a non-optional URL (Xcode 26 warned).
No production code changed. Locally: 177 of 177 on an erased iPhone 16e /
iOS 26.2 simulator (Xcode 27.1); the old test fails 1 of 177 there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LucaB01
approved these changes
Nov 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
Projects with authenticated conversation files serve new files from
https://files.gleap.io/af/<id>(files.us.gleap.aiin the US). Only the session's short-lived file session (X-File-Session) can read them. The SDK already holds and renews it (GleapSessionHelper), but nothing in the app could open such a file:open-urlwith an/af/URL went toSFSafariViewControllerwithout the header → 403;open-urlwith ablob:URL was handled as a deep link →[Gleap close]closed the Messenger.What
session-updateannouncescapabilities.openProtectedFile: true(next toadoptSession). The Messenger sends the newopen-protected-file{ url, name }only to SDKs that announce it, so older SDKs keep today's behaviour.GleapProtectedFiles(new, internal), owned by the widget'sGleapFrameManagerViewController:files.gleap.ioorfiles.us.gleap.aifor the US API, no port/userinfo,/af/<id>or/files/af/<id>; or the local API's own origin in development). The file session is never sent anywhere else;X-File-Sessionas the only header; no cookies, no URL cache, no redirect followed;Caches/gleap-files/<uuid>/<name>. The name is the attachment's name, else the server's suggested name; the extension comes from the MIME type (UTType) when the name has none, so QuickLook knows the type;clearIdentity. A download that finishes after a logout or a user change is dropped;refreshFileAccessIfNeededand opens with the nextsession-update.open-url, tapped links, other main-frame navigations andwindow.openthat point to a protected file take the same path instead of Safari.open-urlwithblob:is ignored instead of closing the widget.QuickLookandUniformTypeIdentifiers(Package.swift + podspec).Apps without protected files see no change: no
/af/URLs exist for them. The only addition they get is the new capability flag, which the Messenger ignores unless a file is protected.Tests (iPhone 16 Pro simulator)
GleapProtectedFilesTests(11 tests): region/host rules, request headers (token only), file names, waiting for the renewed file session (real identify round trip with stubs), other URLs never get the token, a 403 shows nothing and keeps nothing, logout drops files,open-urlrouting (blob:ignored,/af/opens in the app, other links still go to the app'sopenExternalLink:), ablob:link does not close the widget, the capability flag.WKWebViewwith the SDK's bridge, postsopen-protected-file. The test checks that QuickLook appears over the widget in a window with the downloaded file (right name and bytes), and that closing it deletes the file.pod lib lint Gleap.podspec --allow-warningspasses.Not verified: the live Messenger and the real files host (the tests use stubbed HTTP and a test page), and saving through the share sheet by hand. On-screen QuickLook can't be checked in unit tests either: the SwiftPM test host has no window scene, so UIKit accepts the presentation (that is what the end-to-end test checks) but never finishes its transition.
CI: the end-to-end test failed once in CI (run 44128972531). It had a single 30 s deadline, and WebKit's cold start on the CI simulator alone takes 30–40 s. It now waits for each step with its own deadline, and its teardown leaves nothing presented for the next test. Reproduced and verified on an erased iPhone 16e / iOS 26.2 simulator: the old test fails 1 of 177, the new one passes 177 of 177.
.github/scripts/test.shnow writesbuild/TestResults.xcresult, and CI uploads it when the tests fail; before,-quietshowed only the failing test's name.Rollout
🤖 Generated with Claude Code