Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(mobile): loading block (#3243)

Sean Aye2f59a621fcfa
diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsx
index f982d9cc82..c059ce1e5f 100644
--- a/js/app/packages/app/component/Launcher.tsx
+++ b/js/app/packages/app/component/Launcher.tsx
@@ -14,6 +14,7 @@ import type {
HotkeyRegistrationOptions,
ValidHotkey,
} from '@core/hotkey/types';
+import { isMobile } from '@core/mobile/isMobile';
import {
createCanvasFileFromJsonString,
createChat,
@@ -66,49 +67,47 @@ const createBlock = async (spec: {
setCreateMenuOpen(false, false);
- if (!loading) {
- const id = await createFn();
- if (!id) return;
-
- analytics.track('create_entity', {
- entityType: blockName,
- source: 'launcher',
- });
+ // WORKAROUND: On mobile, the navigation interceptor in createMobileSwipeLayout
+ // consumes openWithSplit calls and returns undefined instead of a SplitHandle.
+ // This means we can't show a loading spinner then replace it via split.replace(),
+ // because we never get a handle back. Instead, on mobile we skip the loading state
+ // and navigate directly to the created block after the async creation completes.
+ // If the mobile navigation interceptor is refactored to return handles, this
+ // workaround can be removed and both paths can use the loading-then-replace flow.
+ const showLoadingFirst = loading && !isMobile();
+
+ const split = showLoadingFirst
+ ? openWithSplit(
+ { type: 'component', id: 'loading' },
+ { referredFrom: 'launcher', preferNewSplit: spec.shouldInsert }
+ )
+ : undefined;
+
+ const id = await createFn();
+ if (!id) {
+ split?.goBack();
+ return;
+ }
- const block = { type: blockName, id };
+ analytics.track('create_entity', {
+ entityType: blockName,
+ source: 'launcher',
+ });
- openWithSplit(block, {
+ if (split) {
+ split.replace({
+ next: { type: blockName, id },
+ mergeHistory: true,
referredFrom: 'launcher',
- preferNewSplit: spec.shouldInsert,
});
-
- return;
} else {
- const split = openWithSplit(
- { type: 'component', id: 'loading' },
+ openWithSplit(
+ { type: blockName, id },
{
referredFrom: 'launcher',
preferNewSplit: spec.shouldInsert,
}
);
-
- const id = await createFn();
- if (!id) {
- split?.goBack();
- return;
- }
-
- analytics.track('create_entity', {
- entityType: blockName,
- source: 'launcher',
- });
-
- if (split)
- split.replace({
- next: { type: blockName, id },
- mergeHistory: true,
- referredFrom: 'launcher',
- });
}
};