fix(ios): ios local access limit for self-hosted workspace (#15338)

## Summary
- Route iOS nbstore worker token reads through the main-thread
MessagePort and skip Capacitor Auth on `/socket.io` polling so self-host
WebSocket/XHR sync no longer hangs on Connect timeout.
- Harden workspace `flavour:id` routing, DocSyncPeer abort/status
handling, and `resetSync` so local selfhost edits push and Mac browsers
can receive them.
- Soften root-doc readiness waits and session-exchange throttling to
keep mobile selfhost sign-in/sync stable under retries.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

* **New Features**
* Improved workspace switching across local and remote environments,
preserving workspace type and server context.
  * Added support for page navigation with query parameters.
* Added iOS local-network permission messaging for self-hosted
workspaces.
* **Bug Fixes**
* Improved document synchronization, reset handling, prioritized
document refreshes, and retry behavior.
* Prevented authentication headers and refresh attempts for socket
connection requests.
* Improved workspace reopening and routing when multiple workspace types
share an ID.
  * Fixed handling of unlimited data query limits.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: DarkSky <darksky2048@gmail.com>
This commit is contained in:
keepClamDown
2026-08-24 09:33:58 +08:00
committed by GitHub
parent b530198a3b
commit cd6593c659
15 changed files with 448 additions and 78 deletions
+44 -22
View File
@@ -335,15 +335,31 @@ registerNativeImageFilesPicker(async () => {
});
// ------ some apis for native ------
(window as any).getCurrentServerBaseUrl = () => {
const getCurrentServerForNative = () => {
const globalContextService = frameworkProvider.get(GlobalContextService);
const currentServerId = globalContextService.globalContext.serverId.get();
const globalContext = globalContextService.globalContext;
const currentServerId = globalContext.serverId.get();
const currentWorkspaceFlavour = globalContext.workspaceFlavour.get();
const serversService = frameworkProvider.get(ServersService);
const defaultServerService = frameworkProvider.get(DefaultServerService);
const currentServer =
if (currentWorkspaceFlavour && currentWorkspaceFlavour !== 'local') {
const workspaceServer = serversService.server$(
currentWorkspaceFlavour
).value;
if (workspaceServer) {
return workspaceServer;
}
}
return (
(currentServerId ? serversService.server$(currentServerId).value : null) ??
defaultServerService.server;
return currentServer.baseUrl;
defaultServerService.server
);
};
(window as any).getCurrentServerBaseUrl = () => {
return getCurrentServerForNative().baseUrl;
};
(window as any).getCurrentI18nLocale = () => {
return I18n.language;
@@ -365,11 +381,15 @@ registerNativeImageFilesPicker(async () => {
};
(window as any).waitForSelectedSources = async (documentIds: string[]) => {
const globalContextService = frameworkProvider.get(GlobalContextService);
const currentWorkspaceId =
globalContextService.globalContext.workspaceId.get();
const globalContext = globalContextService.globalContext;
const currentWorkspaceId = globalContext.workspaceId.get();
const currentWorkspaceFlavour = globalContext.workspaceFlavour.get();
const workspacesService = frameworkProvider.get(WorkspacesService);
const workspaceRef = currentWorkspaceId
? workspacesService.openByWorkspaceId(currentWorkspaceId)
? workspacesService.openByWorkspaceId(
currentWorkspaceId,
currentWorkspaceFlavour
)
: null;
if (!workspaceRef) {
throw new Error('Current workspace is unavailable');
@@ -408,13 +428,7 @@ registerNativeImageFilesPicker(async () => {
return true;
};
const getCurrentNativeSignInContext = () => {
const globalContextService = frameworkProvider.get(GlobalContextService);
const currentServerId = globalContextService.globalContext.serverId.get();
const serversService = frameworkProvider.get(ServersService);
const defaultServerService = frameworkProvider.get(DefaultServerService);
const currentServer =
(currentServerId ? serversService.server$(currentServerId).value : null) ??
defaultServerService.server;
const currentServer = getCurrentServerForNative();
const authService = currentServer.scope.get(AuthService);
return { authService, currentServer };
};
@@ -531,12 +545,16 @@ const showNativeSignIn = async () => {
};
(window as any).getCurrentDocContentInMarkdown = async () => {
const globalContextService = frameworkProvider.get(GlobalContextService);
const currentWorkspaceId =
globalContextService.globalContext.workspaceId.get();
const currentDocId = globalContextService.globalContext.docId.get();
const globalContext = globalContextService.globalContext;
const currentWorkspaceId = globalContext.workspaceId.get();
const currentWorkspaceFlavour = globalContext.workspaceFlavour.get();
const currentDocId = globalContext.docId.get();
const workspacesService = frameworkProvider.get(WorkspacesService);
const workspaceRef = currentWorkspaceId
? workspacesService.openByWorkspaceId(currentWorkspaceId)
? workspacesService.openByWorkspaceId(
currentWorkspaceId,
currentWorkspaceFlavour
)
: null;
if (!workspaceRef) {
return;
@@ -589,11 +607,15 @@ const showNativeSignIn = async () => {
title: string
) => {
const globalContextService = frameworkProvider.get(GlobalContextService);
const currentWorkspaceId =
globalContextService.globalContext.workspaceId.get();
const globalContext = globalContextService.globalContext;
const currentWorkspaceId = globalContext.workspaceId.get();
const currentWorkspaceFlavour = globalContext.workspaceFlavour.get();
const workspacesService = frameworkProvider.get(WorkspacesService);
const workspaceRef = currentWorkspaceId
? workspacesService.openByWorkspaceId(currentWorkspaceId)
? workspacesService.openByWorkspaceId(
currentWorkspaceId,
currentWorkspaceFlavour
)
: null;
try {