Repository navigation
feat: saved connections and the native connection switcher (#152) - #173
Merged
Merged
Conversation
Claude-Session: https://claude.ai/code/session_01QSeKYnW1Xf6HDSWz1eGAqv Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYnW1Xf6HDSWz1eGAqv Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYnW1Xf6HDSWz1eGAqv Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYnW1Xf6HDSWz1eGAqv Co-authored-by: Claude <noreply@anthropic.com>
Contributor
Author
|
repo:mobile#1 · os-justin · session_01QSeKYnW1Xf6HDSWz1eGAqv Seat verdict: ACCEPT with four questions for the maintainer. Head-sha: 维护者速读
待你裁的问题(dev 的推荐在前,席位同意):
席位核对
|
This was referenced Nov 2, 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.
Fixes #152
Clause-②: no
Metadata-protocol: none
维护者速读
@preeternal/react-native-cookie-manager7.0.0,必须重新出商店包或开发包;移除时只清该主机自己的 Cookie,与其他主机共享的 Cookie 一律不动;回滚即 revert 本 PR 并重新出包,但升级时旧的单服务器键已删除,回滚到旧版本的用户需要重新输入一次地址。lib/connections/cookies.ts(判定哪些 Cookie 属于本主机,风险最高);components/shell/ConsoleWebView.tsx的switch分支(切换时在目标主机重建 WebView);lib/server-url.ts的loadConnections(升级迁移只跑一次)。npx jest __tests__/components/ConsoleScreen.test.tsx,预期 7 条全过,其中有「切换后在目标主机的上次路由重建 WebView」与「移除当前连接:先请 Console 注销推送,再切走,最后清 Cookie」。What changes
lib/connections/model.ts). The singleserverUrlbecomes an ordered list in SecureStore (objectstack_connections, a versioned JSON document). Each record holdskind(cloudorserver),label,host, brand colour and initial,lastRoute,addedAt, plusserverUrl: a host alone loses the scheme and a base path, which the WebView needs. One connection is current. Saving dedupes by host; removing the current one makes the first remaining one current.stores/server-store.tspublishes the list and keepsserverUrlas the current connection's, so the start screen and push routing read it as before.lib/server-url.ts). The first launch that finds no document turns the oldobjectstack_server_urlvalue into the first, current connection (labelled with its host; that build kept no branding), writes the document, then deletes the old key. Its value is read by exactly one migration. A failed write keeps the old key for the next launch. A fresh install writes nothing.components/shell/ConnectionSwitcher.tsx, screen 8). The sheet lists each connection with its initial on the brand colour, the label, a kind badge (Cloud / Private) and the host, and checks the current one. Tapping a row switches to it. A left swipe reveals Remove, and screen readers get the same action on the row. "Add an organization or company server" goes back to the address step (/server-config?add=1, the address starting empty), so a connection is still saved only from the probe-and-confirm step, the same step connect links and the scanner use. "App settings" opens the system settings page for the app.switchevent inlib/shell/console-load.tsemits the existingrecreateeffect, so the WebView is re-created on the chosen host at that connection'slastRoute. The old host's held route and last route are dropped, and the held push token is kept.documentRefis still bumped only in that effect.app/console.tsxdrops itskey={serverUrl}remount, so there is one remount path. The bridge handler is built for the current connection's origin, so a page of the host left behind gets no answer. The Console'srouteChangedis recorded as the current connection'slastRoute.lib/connections/sign-out.ts), in this order:objectstack-native:connectionRemoved(cancelable,detail.waitUntil). The Console unregisters this install's push token under its own session, and the shell waits up to 10 s for the injected script'sconnectionRemovedDoneanswer.Any answer other than "handled and resolved" records the host in
pushLeftRegistered, and a later save of that host clears the record. The shell calls no API.showConnectionSwitcher()is added as a method, theconnectionRemovedshell event is added, and both are announced as capabilities. Adding them changes no protocol version.resetServer()now forgets the current connection, and the next saved one becomes current.switcher.*strings, andcommon.close, are in all ten bundles;shell.changeServeris removed from all ten.@preeternal/react-native-cookie-manager7.0.0, pinned exactly. Its Expo config plugin is registered inapp.config.ts. It is a New Architecture TurboModule, which Expo SDK 55 / React Native 0.83 requires. It is not in Expo'sbundledNativeModules.json, which lists no cookie module at all. Its codegen spec usesCodegenTypes.EventEmitter, which RN 0.83 exports, and it pulls no extra npm dependencies: the lockfile adds only this package. On Android it compiles againstandroidx.webkit1.16.0 (GET_COOKIE_INFOneeds at least 1.6.0); react-native-webview asks for 1.14.0, and Gradle resolves the higher one.docs/HYBRID-SHELL.mddocuments the connection model, switching, removal and cookie scoping, both bridge additions, the load state, the Console-side integration and the new known limits.Tests
__tests__/lib/connections/model.test.ts: add, dedupe by host, remove, current-connection rules, last route, storage form.__tests__/lib/server-url.test.ts: upgrade with a saved URL, fresh install, interrupted migration, failed write, garbage value.__tests__/lib/server-store.test.ts.__tests__/lib/connections/cookies.test.ts: the plan, plus a stand-in cookie store that behaves like the module on iOS and on Android.__tests__/lib/connections/sign-out.test.ts: the order of the steps.console-load.test.ts: theswitchevent.ConnectionSwitcher.test.tsx: rows, badges, current check, select, swipe-revealed Remove, the screen-reader action, the lock while a removal runs, add, settings, backdrop, Arabic right-to-left. The swipe gesture itself is native and stubbed.ConsoleScreen.test.tsx: wired end to end through the store. A switch remounts the WebView on the right host and route, the route is remembered, the offline action opens the sheet, add saves nothing, and the three removal cases run in their order.ConsoleWebView.test.tsx: switching, the origin gate after a switch, the removal ask's answers, the timeout and a re-create.beforeAllwarm-up.Acceptance notes
lib/shell/console-load.ts. The ruled remount path is the machine'srecreate, but itsrecreateevent starts the new WebView at the old host's held route or last route. The real producer of the remount is the machine, so the fix is there: aswitchevent that emits the samerecreateeffect. No second remount or readiness mechanism was added.clearByName(url, name)deletes, one cookie at a time, every cookie of that name whose domain matches the host, including a parent-domain cookie (.objectos.ai), on every path. So the shell chooses the names itself. A name is cleared only when every cookie under it is the host's own: host-only, or a domain cookie for exactly this host that no other saved connection falls under. Shared cookies are left and counted.sharedCookiesEnabled, react-native-webview copies the WebKit store intoHTTPCookieStorageon every change, and copiesHTTPCookieStorageback into the WebKit store whenever a WebView is created. Both stores are cleared, or the cookie comes back.WKWebsiteDataStore.removeData(ofTypes:for:). Its records are grouped by registrable domain, so it would sign out every*.objectos.aienvironment at once.CookieManagerand no delete call. The module overwrites each cookie with an expired one, throughGET_COOKIE_INFO. On a WebView provider without it, the shell clears nothing and records the outcome asunscoped.clearAllis never called.Domain(OS_COOKIE_DOMAIN) are shared by design, and so are cookies that differ only by port. Separating those would need a data store per connection, and react-native-webview 13.16 does not expose one.resetServer(). Its meaning had to be chosen for a list: it now forgets the current connection and opens the picker, and it still clears no cookies, as before. This is in the report's open questions.common.close.BottomSheet's backdrop label usedcommon.close, a key no bundle had. The switcher is the sheet's first user, so the key is added to all ten bundles.showConnectionSwitcher()whenhas(...)is true, and aconnectionRemovedlistener that unregisters the push token throughdetail.waitUntil.Verification
Head
1996fb4. Every command was run in the worktree, through the shared verify lock.Gates: exit codes
Ablations: mutated, red, restored to the HEAD blob
Generated by Claude Code