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(sharing): open list-item share dialogs in app context (#8061)

dev-rb5ff2e84e9f2a
diff --git a/apps/web/src/components/app/AppProviders.tsx b/apps/web/src/components/app/AppProviders.tsx
index 079e63c411..4d21ed201f 100644
--- a/apps/web/src/components/app/AppProviders.tsx
+++ b/apps/web/src/components/app/AppProviders.tsx
@@ -29,6 +29,7 @@ import {
useReopenTrackedEntitiesOnReconnect,
} from '@service-connection/client';
import { ws as connectionGatewayWebsocket } from '@service-connection/websocket';
+import { ImperativeDialogHost } from '@ui';
import type { ParentProps } from 'solid-js';
function ConfiguredGlobalAppStateProvider(props: ParentProps) {
@@ -101,6 +102,8 @@ export function AppProviders(props: ParentProps) {
<MutationUndoProvider>
<SearchProvider>
<IncomingMeetingInvitationsProvider>
+ {/* Ownerless dialogs inherit app state, not a transient menu owner. */}
+ <ImperativeDialogHost />
{props.children}
</IncomingMeetingInvitationsProvider>
</SearchProvider>
diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsx
index ce59f95b1b..6d988465d3 100644
--- a/apps/web/src/components/app/Layout.tsx
+++ b/apps/web/src/components/app/Layout.tsx
@@ -54,7 +54,7 @@ import { useUserInfoQuery } from '@queries/auth/user-info';
import { queryClient } from '@queries/client';
import { useLocation, useNavigate } from '@solidjs/router';
import { type as osType } from '@tauri-apps/plugin-os';
-import { cn, ImperativeDialogHost } from '@ui';
+import { cn } from '@ui';
import {
createEffect,
createMemo,
@@ -170,7 +170,6 @@ export function RootFrame(props: ParentProps) {
<Show when={hasOverlayTitleBar}>
<DesktopTitleBar />
</Show>
- <ImperativeDialogHost />
<BundleUpdateProgressBar />
<Show when={paywallOpen()}>
<Suspense>
diff --git a/apps/web/src/lib/core/component/TopBar/shareModal.test.tsx b/apps/web/src/lib/core/component/TopBar/shareModal.test.tsx
index 48663a6b14..de26e7b731 100644
--- a/apps/web/src/lib/core/component/TopBar/shareModal.test.tsx
+++ b/apps/web/src/lib/core/component/TopBar/shareModal.test.tsx
@@ -1,23 +1,96 @@
+import { AppProviders } from '@components/app/AppProviders';
+import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
+import { createBlockOrchestrator } from '@core/orchestrator';
import { render, screen } from '@solidjs/testing-library';
import { ImperativeDialogHost } from '@ui';
import { createSignal, Show } from 'solid-js';
import { describe, expect, it, vi } from 'vitest';
import { Permissions } from '../SharePermissions';
-import { useShareModal } from './shareModal';
+import { openShareModal, useShareModal } from './shareModal';
+
+let observedOrchestrator:
+ | ReturnType<typeof useGlobalBlockOrchestrator>
+ | undefined;
+
+vi.mock('@app/features/meetings/incoming-meeting-invitations', () => ({
+ IncomingMeetingInvitationsProvider: (props: { children: unknown }) =>
+ props.children,
+}));
+vi.mock(
+ '@app/features/notifications/PendingNotificationNavigationEffect',
+ () => ({
+ usePendingNotificationNavigationEffect: () => {},
+ })
+);
+vi.mock('@app/features/soup/search/context', () => ({
+ SearchProvider: (props: { children: unknown }) => props.children,
+}));
+vi.mock('@app/lib/queries/calendar/graphql/use-calendar-cache', () => ({
+ useCalendarCache: () => {},
+}));
+vi.mock('@app/lib/queries/invalidate-on-reconnect', () => ({
+ useInvalidateQueriesOnReconnect: () => {},
+}));
+vi.mock('@app/lib/queries/soup/backfill', () => ({
+ useSoupBackfills: () => {},
+}));
+vi.mock('@app/lib/tauri/notification', () => ({
+ MacOSNotificationUpdateRequiredError: class extends Error {},
+}));
+vi.mock('@app/signal/splitLayout', () => ({
+ globalSplitManager: () => undefined,
+}));
+vi.mock('@components/app/useReactiveFavicon', () => ({
+ useReactiveFavicon: () => {},
+}));
+vi.mock('@core/component/AI/signal/globalAttachments', () => ({
+ useGlobalAttachableHistory: () => {},
+}));
+vi.mock('@core/context/team', () => ({
+ TeamContextProvider: (props: { children: unknown }) => props.children,
+}));
+vi.mock('@core/context/user', () => ({ useUserId: () => () => 'test-user' }));
+vi.mock('@core/orchestrator', () => ({
+ createBlockOrchestrator: vi.fn(() => ({})),
+}));
+vi.mock('@notifications', () => ({
+ createNotificationSource: () => ({}),
+ useNotificationUpdates: () => {},
+ usePlatformNotificationState: () => 'not-supported',
+}));
+vi.mock('@notifications/notification-platform', () => ({
+ maybeHandlePlatformNotification: () => {},
+}));
+vi.mock('@queries/chat', () => ({ useChatRenameWebsocketSync: () => {} }));
+vi.mock('@queries/sync/use-query-sync', () => ({ useQuerySync: () => {} }));
+vi.mock('@queries/undo', () => ({
+ MutationUndoProvider: (props: { children: unknown }) => props.children,
+}));
+vi.mock('@service-connection/client', () => ({
+ useRefreshTrackedEntitiesOnFocus: () => {},
+ useReopenTrackedEntitiesOnReconnect: () => {},
+}));
+vi.mock('@service-connection/websocket', () => ({ ws: {} }));
vi.mock('./ShareButton', () => ({
ShareModal: (props: {
+ id: string;
name: string;
onOpenChange: (open: boolean) => void;
- }) => (
- <button
- type="button"
- data-testid="share-modal"
- onClick={() => props.onOpenChange(false)}
- >
- {props.name}
- </button>
- ),
+ }) => {
+ if (props.id === 'regression-doc') {
+ observedOrchestrator = useGlobalBlockOrchestrator();
+ }
+ return (
+ <button
+ type="button"
+ data-testid="share-modal"
+ onClick={() => props.onOpenChange(false)}
+ >
+ {props.name}
+ </button>
+ );
+ },
}));
vi.mock('@queries/storage/document-metadata', () => ({
useDocumentAccessLevelQuery: vi.fn(),
@@ -91,4 +164,67 @@ describe('useShareModal', () => {
await Promise.resolve();
expect(onClose).toHaveBeenCalledOnce();
});
+
+ it('keeps an app-owned share dialog across menu disposal and clears it on app disposal', async () => {
+ const [showMenu, setShowMenu] = createSignal(true);
+ const [showApp, setShowApp] = createSignal(true);
+ const orchestratorFactory = vi.mocked(createBlockOrchestrator);
+ const firstCall = orchestratorFactory.mock.calls.length;
+
+ function Menu() {
+ return (
+ <button
+ type="button"
+ data-testid="open-share"
+ onClick={() =>
+ openShareModal({
+ id: 'regression-doc',
+ blockAlias: 'md',
+ itemType: 'document',
+ name: 'Regression',
+ userPermissions: Permissions.OWNER,
+ })
+ }
+ >
+ Share
+ </button>
+ );
+ }
+
+ const view = render(() => (
+ <Show when={showApp()}>
+ <AppProviders>
+ <Show when={showMenu()}>
+ <Menu />
+ </Show>
+ </AppProviders>
+ </Show>
+ ));
+
+ screen.getByTestId('open-share').click();
+ expect((await screen.findByTestId('share-modal')).textContent).toBe(
+ 'Regression'
+ );
+ const firstOrchestrator = orchestratorFactory.mock.results[firstCall].value;
+ expect(observedOrchestrator).toBe(firstOrchestrator);
+
+ setShowMenu(false);
+ expect(screen.queryByTestId('open-share')).toBeNull();
+ expect(screen.getByTestId('share-modal').textContent).toBe('Regression');
+
+ setShowApp(false);
+ await vi.waitFor(() =>
+ expect(screen.queryByTestId('share-modal')).toBeNull()
+ );
+
+ setShowMenu(true);
+ setShowApp(true);
+ screen.getByTestId('open-share').click();
+ await screen.findByTestId('share-modal');
+ const nextOrchestrator =
+ orchestratorFactory.mock.results[firstCall + 1].value;
+ expect(nextOrchestrator).not.toBe(firstOrchestrator);
+ expect(observedOrchestrator).toBe(nextOrchestrator);
+ view.unmount();
+ });
});
diff --git a/apps/web/src/routes/shells.tsx b/apps/web/src/routes/shells.tsx
index d7d8e53c5d..3a4dbee48a 100644
--- a/apps/web/src/routes/shells.tsx
+++ b/apps/web/src/routes/shells.tsx
@@ -3,6 +3,7 @@ import { dismissBootShell } from '@components/app/boot-shell';
import { AppChrome, PageContent } from '@components/app/Layout';
import { SplitLayout } from '@components/app/split-layout/SplitLayout';
import { useIsAuthenticated } from '@core/auth';
+import { ImperativeDialogHost } from '@ui';
import { type JSX, onCleanup, onMount, type ParentProps, Show } from 'solid-js';
import { LIKELY_NEXT_VIEWS } from './lazy-route-views';
@@ -16,6 +17,7 @@ export function AuthShell(): JSX.Element {
useDismissBootShell();
return (
<PageContent>
+ <ImperativeDialogHost />
<SplitRouter.Outlet />
</PageContent>
);
@@ -25,6 +27,7 @@ function FocusedPage(props: ParentProps) {
useDismissBootShell();
return (
<div class="min-h-0 flex-1 overflow-y-auto bg-page text-ink">
+ <ImperativeDialogHost />
{props.children}
</div>
);
@@ -70,6 +73,7 @@ export function withMeetingShell(Page: () => JSX.Element) {
useDismissBootShell();
return (
<PageContent>
+ <ImperativeDialogHost />
<Page />
</PageContent>
);
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 74eb0a7826..436028f8d8 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -26,6 +26,15 @@ outline surface and border with semibold text, without inverted colors. Disabled
and pending primary actions retain the strong variant. Mobile confirmation drawers
use the same action hierarchy.
+## List-item sharing
+
+Right-click a shareable list row and choose **Share**. The sharing dialog must
+remain open after the context menu closes, with recipient selection and the
+optional message available. Dismiss it with Cancel, then reopen Share on the
+same row and confirm focus enters the recipient selector again. Opening or
+cancelling the dialog does not change access; do not submit shares on real dev
+data unless authorized.
+
## User cards
Avatar and user-mention cards open on hover on pointer devices and as a bottom