Skip to content

Commit ca28ccd

Browse files
committed
The web navigation variant: Info.plist's OpenBotNavigation (tabs by default, web in a DebugWebNav configuration) drops the tab bar for the web app's own sidebar and history
With `web` the injected object says navigation: "web". There is no tab bar, and the web view runs from under the status bar to the bottom edge. No slide stack, no edge recogniser and no openbot:back: back is always WebKit's own gesture over the page's history. The debug state says navmode=. Tests: WebNavUITests (a journey, the lock and the tour for the recording), in a webnav job, which=webnav in the video workflow, and pushes to this branch run the test workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xYtaUjbkB1hwLtK4TEzhq
1 parent 8618335 commit ca28ccd

11 files changed

Lines changed: 299 additions & 19 deletions

File tree

‎.github/workflows/ios-shell-video.yml‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
- demo
2727
- real
2828
- swipe
29+
- webnav
2930
- selfhosted
3031
default: both
3132
warm_up:
@@ -91,13 +92,14 @@ jobs:
9192
with:
9293
path: DerivedData-Debug
9394
# which=swipe builds DebugSlide (the slide back on) into the same folder: its own cache.
94-
key: ios-shell-video-dd-${{ inputs.which == 'swipe' && 'DebugSlide' || 'Debug' }}-${{ steps.dd-key.outputs.tree }}
95-
restore-keys: ios-shell-video-dd-${{ inputs.which == 'swipe' && 'DebugSlide' || 'Debug' }}-
95+
key: ios-shell-video-dd-${{ inputs.which == 'swipe' && 'DebugSlide' || (inputs.which == 'webnav' && 'DebugWebNav' || 'Debug') }}-${{ steps.dd-key.outputs.tree }}
96+
restore-keys: ios-shell-video-dd-${{ inputs.which == 'swipe' && 'DebugSlide' || (inputs.which == 'webnav' && 'DebugWebNav' || 'Debug') }}-
9697

9798
- name: Build the Debug app and its UI tests
9899
env:
99100
# which=swipe records the slide back: the DebugSlide configuration (Info.plist's OpenBotSlideBack on).
100-
BUILD_CONFIG: ${{ inputs.which == 'swipe' && 'DebugSlide' || 'Debug' }}
101+
# which=webnav records the web navigation: the DebugWebNav configuration (no tab bar).
102+
BUILD_CONFIG: ${{ inputs.which == 'swipe' && 'DebugSlide' || (inputs.which == 'webnav' && 'DebugWebNav' || 'Debug') }}
101103
run: |
102104
set -o pipefail
103105
xcodebuild build-for-testing -project ios-shell/OpenBotShell.xcodeproj -scheme OpenBotShell \
@@ -233,6 +235,11 @@ jobs:
233235
test_id=OpenBotShellUITests/SlideBackUITests/testSlideAcrossTabs
234236
export TEST_RUNNER_OPENBOT_SHELL_EXPECT_SLIDE=1
235237
fi
238+
if [ "$WHICH" = "webnav" ]; then
239+
# The web navigation, no tab bar: sign-in, Home, the drawer, a conversation, typing, Bots, Settings, sign-out.
240+
test_id=OpenBotShellUITests/WebNavUITests/testWebNavTour
241+
export TEST_RUNNER_OPENBOT_SHELL_EXPECT_WEBNAV=1
242+
fi
236243
if [ "$WHICH" = "selfhosted" ]; then
237244
# The self-hosted OpenBot: mock stack C on 3014, someone else signed in.
238245
test_id=OpenBotShellUITests/SelfHostedUITests/testSelfHostedSignInAndBackToCloud
@@ -277,7 +284,7 @@ jobs:
277284
[ -f artifacts/video/demo-tour.mp4 ] || exit 0
278285
# The swipe and self-hosted clips are kept whole: their marks are seconds apart and
279286
# simctl's variable frame rate made the cut miss the swipe once.
280-
if [ "$WHICH" != "swipe" ] && [ "$WHICH" != "selfhosted" ]; then
287+
if [ "$WHICH" != "swipe" ] && [ "$WHICH" != "selfhosted" ] && [ "$WHICH" != "webnav" ]; then
281288
python3 ios-shell/ci/trim_video.py artifacts/video/demo-tour.mp4 xcodebuild-demo.log "$STARTED" || true
282289
fi
283290
ls -la artifacts/video
@@ -316,7 +323,7 @@ jobs:
316323
317324
real:
318325
name: Record the real-backend journey (private)
319-
if: github.repository == 'CopilotKit/OpenBot' && inputs.which != 'demo' && inputs.which != 'swipe' && inputs.which != 'selfhosted'
326+
if: github.repository == 'CopilotKit/OpenBot' && inputs.which != 'demo' && inputs.which != 'swipe' && inputs.which != 'selfhosted' && inputs.which != 'webnav'
320327
runs-on: macos-latest
321328
timeout-minutes: 13
322329
permissions:

‎.github/workflows/ios-shell.yml‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: iOS shell
22

3-
# Builds the experimental iOS shell in ios-shell/ for the simulator and runs its UI tests in 5
3+
# Builds the experimental iOS shell in ios-shell/ for the simulator and runs its UI tests in 6
44
# parallel jobs, each on its own simulator:
55
# - real: suite 1, against the hosted web app at my.open.bot (a Release build, a fresh install per
66
# test, and the Debug-only session-cookie journey), plus the Release and store build checks;
77
# - flow-a, flow-b: suite 2, ShellFlowUITests in 2 halves, against two mock
88
# stacks of the real built web app (app/workbench/mock-server.ts);
99
# - edges: the hardening tests, the probe site (ios-shell/Probe) and the unit tests;
10+
# - webnav: WebNavUITests on the DebugWebNav configuration (no tab bar, the web app's own
11+
# navigation), on mock stack A;
1012
# - slide: SlideBackUITests on the DebugSlide configuration (the same app with Info.plist's
1113
# OpenBotSlideBack on), on mock stack A; slide_repeat runs them more than once.
1214
#
@@ -24,6 +26,7 @@ on:
2426
branches:
2527
- ios-webview-shell
2628
- ios-webview-shell/**
29+
- ios-shell-web-nav
2730
paths:
2831
- ios-shell/**
2932
- .github/workflows/ios-shell.yml
@@ -71,11 +74,11 @@ jobs:
7174
fail-fast: false
7275
matrix:
7376
# real_backend_only: suite 1 alone. An iPad: everything but the real-backend suites.
74-
shard: ${{ fromJSON(inputs.real_backend_only && '["real"]' || (inputs.device == 'ipad' && '["flow-a","flow-b","edges","slide"]' || '["real","flow-a","flow-b","edges","slide"]')) }}
77+
shard: ${{ fromJSON(inputs.real_backend_only && '["real"]' || (inputs.device == 'ipad' && '["flow-a","flow-b","edges","slide","webnav"]' || '["real","flow-a","flow-b","edges","slide","webnav"]')) }}
7578
env:
7679
SHARD: ${{ matrix.shard }}
7780
# The slide job's app has the slide back on (project.yml's DebugSlide); every other job's has it off.
78-
BUILD_CONFIG: ${{ matrix.shard == 'slide' && 'DebugSlide' || 'Debug' }}
81+
BUILD_CONFIG: ${{ matrix.shard == 'slide' && 'DebugSlide' || (matrix.shard == 'webnav' && 'DebugWebNav' || 'Debug') }}
7982
SLIDE_REPEAT: ${{ inputs.slide_repeat || '1' }}
8083
steps:
8184
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -135,8 +138,8 @@ jobs:
135138
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
136139
with:
137140
path: DerivedData
138-
key: ios-shell-dd-${{ matrix.shard == 'slide' && 'DebugSlide' || 'Debug' }}-${{ steps.dd-key-1.outputs.tree }}
139-
restore-keys: ios-shell-dd-${{ matrix.shard == 'slide' && 'DebugSlide' || 'Debug' }}-
141+
key: ios-shell-dd-${{ matrix.shard == 'slide' && 'DebugSlide' || (matrix.shard == 'webnav' && 'DebugWebNav' || 'Debug') }}-${{ steps.dd-key-1.outputs.tree }}
142+
restore-keys: ios-shell-dd-${{ matrix.shard == 'slide' && 'DebugSlide' || (matrix.shard == 'webnav' && 'DebugWebNav' || 'Debug') }}-
140143

141144
# The app builds while the web app does.
142145
- name: Start the Debug build in the background
@@ -343,6 +346,8 @@ jobs:
343346
edges) only=(-only-testing:$t/HardeningUITests -only-testing:$t/ShellUITests -only-testing:$t/SelfHostedUITests
344347
-only-testing:$t/HandoffConfigTests -only-testing:$t/ShellURLsTests -only-testing:$t/ShellBackTests -only-testing:$t/ServerAddressTests
345348
-skip-testing:$t/ShellUITests/testLoadsHostedWebApp) ;;
349+
webnav) export TEST_RUNNER_OPENBOT_SHELL_EXPECT_WEBNAV=1
350+
only=(-only-testing:$t/WebNavUITests) ;;
346351
slide) export TEST_RUNNER_OPENBOT_SHELL_EXPECT_SLIDE=1
347352
# And the probe in plain mode: with the slide on, plain mode must still show its page.
348353
only=(-only-testing:$t/SlideBackUITests -only-testing:$t/ShellUITests/testProbeSite)

‎ios-shell/OpenBotShell/AppModel.swift‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ final class AppModel: ObservableObject {
130130
}
131131
}
132132

133-
var showsTabBar: Bool { phase == .signedIn && !keyboardVisible }
133+
var showsTabBar: Bool { phase == .signedIn && !keyboardVisible && !webNavigation }
134+
/// Info.plist's OpenBotNavigation is `web`: no tab bar, the web view runs to the bottom edge.
135+
@Published var webNavigation = false
134136
var showsSkeleton: Bool { pageLoading && webVisible && !showsSignInScreen && !showsLock }
135137
var showsWebSignInBar: Bool { phase == .signedOut && signIn == .webFallback }
136138

@@ -152,6 +154,6 @@ final class AppModel: ObservableObject {
152154

153155
/// For UI tests (DEBUG only on screen).
154156
var debugState: String {
155-
"phase=\(phase.rawValue) signIn=\(signIn.rawValue) tab=\(selectedTab.rawValue) nav=\(lastNavigation) commits=\(mainFrameCommits) restarts=\(contentRestarts) skeletons=\(skeletonsShown) cleared=\(siteDataClears) back=\(backMode) slide=\(slideState) server=\(serverHost) lock=\(lockReason) loading=\(pageLoading ? 1 : 0) keyboard=\(keyboardVisible ? 1 : 0) path=\(webPathRoot) dark=\(pageIsDark.map { $0 ? "1" : "0" } ?? "-")"
157+
"phase=\(phase.rawValue) signIn=\(signIn.rawValue) tab=\(selectedTab.rawValue) nav=\(lastNavigation) commits=\(mainFrameCommits) restarts=\(contentRestarts) skeletons=\(skeletonsShown) cleared=\(siteDataClears) back=\(backMode) navmode=\(webNavigation ? "web" : "tabs") slide=\(slideState) server=\(serverHost) lock=\(lockReason) loading=\(pageLoading ? 1 : 0) keyboard=\(keyboardVisible ? 1 : 0) path=\(webPathRoot) dark=\(pageIsDark.map { $0 ? "1" : "0" } ?? "-")"
156158
}
157159
}

‎ios-shell/OpenBotShell/ShellConfig.swift‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ struct ShellConfig {
2121
let testName: String
2222
/// The sign-in sheet keeps no cookies and shares nothing with Safari, and iOS asks no consent.
2323
let ephemeralSignIn: Bool
24+
/// Who navigates: the native tab bar with the web app's per-tab stacks (`tabs`, the default), or
25+
/// the web app's own sidebar and history in a full-height web view (`web`). A shipped setting,
26+
/// Info.plist's `OpenBotNavigation` (project.yml: the build setting OPENBOT_NAVIGATION; `web` in
27+
/// the DebugWebNav configuration); nothing at launch overrides it.
28+
var navigation: Navigation = .fromInfoPlist()
29+
var webNavigation: Bool { navigation == .web }
2430

2531
// DEBUG-only hooks (see README.md).
2632
var plainWebView = false
@@ -50,6 +56,14 @@ struct ShellConfig {
5056
/// session left in a web view that shows the sign-in screen.
5157
var testLateSessionCookie: String?
5258

59+
enum Navigation: String {
60+
case tabs, web
61+
static func fromInfoPlist() -> Navigation {
62+
let value = (Bundle.main.object(forInfoDictionaryKey: "OpenBotNavigation") as? String) ?? ""
63+
return Navigation(rawValue: value.lowercased()) ?? .tabs
64+
}
65+
}
66+
5367
/// Set when the app is built again for another server: the launch's test hooks (a reset, planted
5468
/// cookies, delays) ran once already and must not run again.
5569
static var restarting = false

‎ios-shell/OpenBotShell/ShellContentView.swift‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ struct ShellContentHost: UIViewRepresentable {
1414
var background: UIColor = .systemBackground
1515
let webVisible: Bool
1616
let tabBarVisible: Bool
17+
/// The web navigation: no tab bar, and the web view runs down to the screen's bottom edge (the
18+
/// page keeps its own content clear of the home indicator with env(safe-area-inset-bottom)).
19+
var fillsToBottom = false
1720
let selected: ShellTab
1821
let isDark: Bool?
1922
let onSelect: (ShellTab) -> Void
@@ -34,6 +37,7 @@ struct ShellContentHost: UIViewRepresentable {
3437
view.onLayout = onLayout
3538

3639
view.setWebVisible(webVisible)
40+
view.fillsToBottom = fillsToBottom
3741
view.setTabBarVisible(tabBarVisible)
3842
view.select(selected)
3943
view.setDark(isDark)
@@ -53,6 +57,9 @@ final class ShellContentView: UIView, UITabBarDelegate {
5357
private var keyboardObservers: [NSObjectProtocol] = []
5458

5559
private var tabBarVisible = false
60+
var fillsToBottom = false {
61+
didSet { if fillsToBottom != oldValue { setNeedsLayout() } }
62+
}
5663
private var lastReported: (CGFloat, CGRect)?
5764

5865
init(webView: WKWebView, slideStack: SlideBackStack? = nil) {
@@ -146,7 +153,7 @@ final class ShellContentView: UIView, UITabBarDelegate {
146153
if keyboardOverlap > 0 {
147154
webBottom = bounds.height - keyboardOverlap
148155
} else {
149-
webBottom = bounds.height - (showBar ? barHeight : bottomInset)
156+
webBottom = bounds.height - (showBar ? barHeight : (fillsToBottom ? 0 : bottomInset))
150157
}
151158
let webFrame = CGRect(x: 0, y: 0, width: bounds.width, height: max(webBottom, 0))
152159
if let stack = slideStack {

‎ios-shell/OpenBotShell/ShellController.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ final class ShellController: NSObject, WebControllerDelegate {
5858
phaseWatch = model.$phase.sink { [weak web = self.web] phase in web?.signedIn = phase == .signedIn }
5959
if config.plainWebView { model.phase = .plain }
6060
model.serverHost = ServerAddress.display(config.baseURL)
61+
model.webNavigation = config.webNavigation
6162
model.selfHosted = config.isSelfHosted
6263
diagnostics.log("launch", [
6364
"baseURL": Diagnostics.redact(config.baseURL),

‎ios-shell/OpenBotShell/ShellView.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct ShellView: View {
9090
background: model.chromeBackground,
9191
webVisible: model.webVisible,
9292
tabBarVisible: model.showsTabBar,
93+
fillsToBottom: model.webNavigation,
9394
selected: model.selectedTab,
9495
isDark: model.pageIsDark,
9596
onSelect: { tab in shell.selectTab(tab) },

‎ios-shell/OpenBotShell/WebController.swift‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ final class WebController: NSObject, WKNavigationDelegate, WKUIDelegate, WKScrip
114114
webView.uiDelegate = self
115115
hideKeyboardAccessory(when: "init")
116116
installKeyboardDragDismiss()
117-
installBackSwipe()
117+
// The web navigation has no stacks to send `openbot:back` to: WebKit's own back gesture only.
118+
if !config.webNavigation { installBackSwipe() }
118119
// Also sees the page's own route changes, which no navigation delegate call reports.
119120
urlObservation = webView.observe(\.url, options: [.new]) { [weak self] webView, _ in
120121
let url = webView.url
@@ -128,10 +129,12 @@ final class WebController: NSObject, WKNavigationDelegate, WKUIDelegate, WKScrip
128129
static func shellMarkerScript(config: ShellConfig) -> String {
129130
let origin = config.baseURL.absoluteString
130131
let version = jsString(config.version)
132+
// `navigation: "web"`: the web app's own sidebar and history, no tab bar (absent: the tab bar).
133+
let navigation = config.webNavigation ? ", navigation: \"web\"" : ""
131134
return """
132135
(function () {
133136
if (location.origin !== \(jsString(origin))) return;
134-
window.__OPENBOT_NATIVE_SHELL__ = Object.freeze({ platform: "ios", version: \(version), bridge: 1 });
137+
window.__OPENBOT_NATIVE_SHELL__ = Object.freeze({ platform: "ios", version: \(version), bridge: 1\(navigation) });
135138
})();
136139
"""
137140
}
@@ -358,7 +361,7 @@ final class WebController: NSObject, WKNavigationDelegate, WKUIDelegate, WKScrip
358361
private(set) lazy var slideStack: SlideBackStack? = {
359362
// Not in DEBUG's plain mode: there SwiftUI holds the bare web view, and a push would take it
360363
// off the screen.
361-
guard WebController.slideBack, !config.plainWebView else { return nil }
364+
guard WebController.slideBack, !config.plainWebView, !config.webNavigation else { return nil }
362365
let stack = SlideBackStack(webView: webView, diagnostics: diagnostics)
363366
stack.sendBack = { [weak self] in self?.sendBack() }
364367
return stack
@@ -368,7 +371,8 @@ final class WebController: NSObject, WKNavigationDelegate, WKUIDelegate, WKScrip
368371
/// that keeps no stacks, the shell's own edge swipe sending `openbot:back` for one that does.
369372
func updateBack(canGoBack: Bool?, depth: Int? = nil, tab: String? = nil) {
370373
slideStack?.route(tab: tab, depth: depth, canGoBack: canGoBack)
371-
let mode = ShellBack.decide(canGoBack: canGoBack)
374+
// The web navigation's page keeps real history: always WebKit's own back gesture.
375+
let mode = config.webNavigation ? ShellBack.webHistory : ShellBack.decide(canGoBack: canGoBack)
372376
guard mode != backMode else { return }
373377
backMode = mode
374378
webView.allowsBackForwardNavigationGestures = mode.usesWebKitGesture

0 commit comments

Comments
 (0)