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(notifications): remove the prompt region's body:has rule that lags typing (#8840)

teo11486ca25cea
diff --git a/.agents/rules/web/mobile.md b/.agents/rules/web/mobile.md
index e623af1104..c6cc8eba4e 100644
--- a/.agents/rules/web/mobile.md
+++ b/.agents/rules/web/mobile.md
@@ -64,20 +64,12 @@ read their code, and follow that pattern rather than inventing a new one.
- Overlays are Kobalte or corvu layers or handle Escape: Android Back sends
Escape to the top layer. Own back stacks use `useAndroidBackNavigation`.
- Persistent prompts (`toast.custom` with `persistent`) go to the prompt
- region (`useKeyedPersistentToasts` does it), which hides while a popover,
- dialog, or drawer is open, or while a presented pane carries
- `data-holds-prompts`. Mark a full-frame touch view with it when its last
- controls sit right above the dock, as the email composer, email thread and
- search results do; on desktop, where the prompt sits in the bottom-right
- corner, mark a composer docked at the bottom of its pane (channel and agent
- composers, a call's control bar, desktop only) or the view around it (email
- thread and composer). A composer's typeahead and picker menus (`@`, `:`,
- `/`, skills, snippets, tags, GIFs) open above it and hold prompts while
- open, on every device; give a new one the same attribute on its root, and
- pass `floatWithSelection` its `fullHeight` (content cap plus panel padding)
- so it picks the side with room for its whole list instead of shrinking
- below the caret when its first render is short.
- A prompt in the transient region would cover a sheet's controls.
+ region (`useKeyedPersistentToasts` does it); a prompt in the transient
+ region would cover a sheet's controls.
+- Pass a composer typeahead or picker menu's `floatWithSelection` its
+ `fullHeight` (content cap plus panel padding) so it picks the side with room
+ for its whole list instead of shrinking below the caret when its first
+ render is short.
## Keyboard and focus
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 441eb14c94..ce2c0912d2 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -30,10 +30,6 @@ RSVP scope and the delete confirmation over event details) have a backend-free
browser regression for backdrop taps that must not press what the scrim covers:
`bunx playwright test --config src/components/app/mobile/browser-test/playwright.config.ts`.
-Persistent prompts stepping aside for popovers, dialogs, drawers and
-`data-holds-prompts` surfaces have a backend-free browser regression:
-`bunx playwright test --config src/lib/core/component/Toast/browser-test/playwright.config.ts`.
-
Composer typeahead menus choosing the side with room for their full list
(`floatWithSelection`'s `fullHeight`), above a composer at the bottom of a
phone screen and below one near the top, have a backend-free browser regression:
diff --git a/apps/web/src/lib/core/component/Toast/ToastRegion.tsx b/apps/web/src/lib/core/component/Toast/ToastRegion.tsx
index 3d0ebfcead..96c0563d1e 100644
--- a/apps/web/src/lib/core/component/Toast/ToastRegion.tsx
+++ b/apps/web/src/lib/core/component/Toast/ToastRegion.tsx
@@ -10,11 +10,6 @@ export function ToastRegion() {
{/*
Desktop stack, bottom-right. Persistent prompts get their own region
capped at one visible card. Upload progress sits nearest the corner.
- Prompts step aside while a popover, dialog, drawer, or a surface
- marked data-holds-prompts is open, so they never cover its controls
- (here: composers docked at the bottom of a pane, email threads, the
- email composer, and a composer's typeahead and picker menus); a holder
- in an inert (background) pane does not count.
*/}
<div class="fixed bottom-2 right-2 m-0 p-2 sm:p-4 list-none outline-none pointer-events-none z-toast-region flex flex-col items-end gap-2">
<Toast.Region
@@ -32,7 +27,6 @@ export function ToastRegion() {
limit={1}
pauseOnInteraction={false}
swipeDirection="right"
- class="in-[body:has([role=dialog],[role=alertdialog],[data-holds-prompts]:not([inert],[inert]_*))]:hidden"
>
<Toast.List class="flex flex-col gap-2" />
</Toast.Region>
@@ -54,9 +48,7 @@ export function ToastRegion() {
transient toast is visible — Toast.tsx dismisses the previous one as
soon as a new one is shown. Persistent prompts live in their own
region above that slot, capped at one visible card with the rest
- queued until it is answered. Prompts step aside as on desktop: while a
- drawer, sheet, or dialog is open, or a full-frame view that holds them
- (composer, email thread, search) is presented.
+ queued until it is answered.
*/}
<div
class="fixed left-1/2 -translate-x-1/2 w-full max-w-[420px] px-(--mobile-chrome-gutter) pointer-events-none z-toast-region flex flex-col gap-2"
@@ -79,7 +71,6 @@ export function ToastRegion() {
limit={1}
pauseOnInteraction={false}
swipeDirection="left"
- class="in-[body:has([role=dialog],[role=alertdialog],[data-holds-prompts]:not([inert],[inert]_*))]:hidden"
>
<Toast.List class="flex flex-col gap-2" />
</Toast.Region>
diff --git a/apps/web/src/lib/core/component/Toast/browser-test/index.html b/apps/web/src/lib/core/component/Toast/browser-test/index.html
deleted file mode 100644
index 3cea310857..0000000000
--- a/apps/web/src/lib/core/component/Toast/browser-test/index.html
+++ /dev/null
@@ -1 +0,0 @@
-<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Prompt region regression</title></head><body><div id="root"></div><script type="module" src="/main.tsx"></script></body></html>
diff --git a/apps/web/src/lib/core/component/Toast/browser-test/main.tsx b/apps/web/src/lib/core/component/Toast/browser-test/main.tsx
deleted file mode 100644
index 260c55fd19..0000000000
--- a/apps/web/src/lib/core/component/Toast/browser-test/main.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import { toast } from '@core/component/Toast/Toast';
-import { ToastRegion } from '@core/component/Toast/ToastRegion';
-import { isMobile } from '@core/mobile/isMobile';
-import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { Popover } from '@kobalte/core/popover';
-import { Button, Dialog } from '@ui';
-import { createSignal, onMount, Show } from 'solid-js';
-import { render } from 'solid-js/web';
-import '../../../../../index.css';
-
-document.documentElement.dataset.touchDevice = String(isTouchDevice());
-
-function Fixture() {
- const [dialogOpen, setDialogOpen] = createSignal(false);
- const [fullscreenOpen, setFullscreenOpen] = createSignal(false);
- const [composerOpen, setComposerOpen] = createSignal(false);
- const [composerInBackground, setComposerInBackground] = createSignal(false);
- const [composerInert, setComposerInert] = createSignal(false);
-
- onMount(() => {
- toast.custom(
- {
- title: 'Enable Browser Notifications',
- content: () => <div>Get notified about new messages.</div>,
- actions: [{ label: 'Hide', onClick: () => {} }],
- },
- {
- persistent: true,
- region: isMobile() ? 'mobile-prompt-region' : 'prompt-region',
- }
- );
- });
-
- return (
- <main class="flex min-h-screen flex-col items-start gap-2 bg-page p-4 text-ink">
- <Popover>
- <Popover.Trigger as={Button} variant="outline">
- Open popover
- </Popover.Trigger>
- <Popover.Portal>
- <Popover.Content class="menu-surface p-3">
- <Popover.Title>Event details</Popover.Title>
- <Popover.CloseButton
- as={Button}
- aria-label="Close popover"
- variant="outline"
- >
- Close popover
- </Popover.CloseButton>
- </Popover.Content>
- </Popover.Portal>
- </Popover>
- <Button variant="outline" onClick={() => setDialogOpen(true)}>
- Open dialog
- </Button>
- <Button variant="outline" onClick={() => setFullscreenOpen(true)}>
- Open full-screen dialog
- </Button>
- <Button variant="outline" onClick={() => setComposerOpen((v) => !v)}>
- Toggle composer
- </Button>
- <Button
- variant="outline"
- onClick={() => setComposerInBackground((v) => !v)}
- >
- Toggle composer background
- </Button>
- <Button variant="outline" onClick={() => setComposerInert((v) => !v)}>
- Toggle composer inert
- </Button>
- <Dialog open={dialogOpen()} onOpenChange={setDialogOpen}>
- <Dialog.Title>Delete event</Dialog.Title>
- <Button variant="outline" onClick={() => setDialogOpen(false)}>
- Close dialog
- </Button>
- </Dialog>
- <Dialog
- fullscreen
- open={fullscreenOpen()}
- onOpenChange={setFullscreenOpen}
- >
- <Dialog.Title>Reply composer</Dialog.Title>
- <Button variant="outline" onClick={() => setFullscreenOpen(false)}>
- Close full-screen dialog
- </Button>
- </Dialog>
- <Show when={composerOpen()}>
- <div inert={composerInBackground()}>
- <section
- data-holds-prompts
- inert={composerInert()}
- aria-label="Composer"
- >
- Draft
- </section>
- </div>
- </Show>
- <ToastRegion />
- </main>
- );
-}
-
-const root = document.getElementById('root');
-if (!root) throw new Error('Missing fixture root');
-render(() => <Fixture />, root);
diff --git a/apps/web/src/lib/core/component/Toast/browser-test/playwright.config.ts b/apps/web/src/lib/core/component/Toast/browser-test/playwright.config.ts
deleted file mode 100644
index af8c9cb57d..0000000000
--- a/apps/web/src/lib/core/component/Toast/browser-test/playwright.config.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { fileURLToPath } from 'node:url';
-import { defineConfig, devices } from '@playwright/test';
-
-const directory = fileURLToPath(new URL('.', import.meta.url));
-const webDirectory = fileURLToPath(
- new URL('../../../../../../', import.meta.url)
-);
-const port = Number(process.env.PROMPT_REGION_BROWSER_PORT ?? 3017);
-export default defineConfig({
- testDir: directory,
- testMatch: '*.browser.e2e.ts',
- outputDir: `${directory}/test-results`,
- timeout: 30_000,
- workers: 1,
- reporter: 'line',
- use: {
- launchOptions: {
- executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
- },
- baseURL: `http://127.0.0.1:${port}`,
- trace: 'retain-on-failure',
- screenshot: 'only-on-failure',
- },
- webServer: {
- command: `bunx vite --config src/lib/core/component/Toast/browser-test/vite.config.ts --port ${port}`,
- cwd: webDirectory,
- url: `http://127.0.0.1:${port}`,
- reuseExistingServer: false,
- },
- projects: [
- { name: 'desktop', use: { ...devices['Desktop Chrome'] } },
- {
- name: 'mobile',
- use: { ...devices['iPhone 13'], browserName: 'chromium' },
- },
- ],
-});
diff --git a/apps/web/src/lib/core/component/Toast/browser-test/prompt.browser.e2e.ts b/apps/web/src/lib/core/component/Toast/browser-test/prompt.browser.e2e.ts
deleted file mode 100644
index 83d446faf7..0000000000
--- a/apps/web/src/lib/core/component/Toast/browser-test/prompt.browser.e2e.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { expect, type Page, test } from '@playwright/test';
-
-const prompt = (page: Page) =>
- page.getByText('Enable Browser Notifications', { exact: true });
-
-const press = (page: Page, name: string) =>
- page.getByRole('button', { name, exact: true }).click();
-
-test.beforeEach(async ({ page }) => {
- await page.goto('/');
- await expect(prompt(page)).toBeVisible();
-});
-
-test('steps aside while a popover is open', async ({ page }) => {
- await press(page, 'Open popover');
- await expect(page.getByText('Event details')).toBeVisible();
- await expect(prompt(page)).toBeHidden();
-
- await press(page, 'Close popover');
- await expect(prompt(page)).toBeVisible();
-});
-
-test('steps aside while a dialog or drawer is open', async ({ page }) => {
- await press(page, 'Open dialog');
- await expect(page.getByText('Delete event')).toBeVisible();
- await expect(prompt(page)).toBeHidden();
-
- await press(page, 'Close dialog');
- await expect(prompt(page)).toBeVisible();
-});
-
-test('steps aside while a full-screen dialog is open', async ({ page }) => {
- await press(page, 'Open full-screen dialog');
- await expect(page.getByText('Reply composer')).toBeVisible();
- await expect(prompt(page)).toBeHidden();
-
- await press(page, 'Close full-screen dialog');
- await expect(prompt(page)).toBeVisible();
-});
-
-test('waits for a presented surface that holds prompts', async ({ page }) => {
- await press(page, 'Toggle composer');
- await expect(prompt(page)).toBeHidden();
-
- await press(page, 'Toggle composer background');
- await expect(prompt(page)).toBeVisible();
-
- await press(page, 'Toggle composer background');
- await expect(prompt(page)).toBeHidden();
-
- await press(page, 'Toggle composer inert');
- await expect(prompt(page)).toBeVisible();
-
- await press(page, 'Toggle composer inert');
- await expect(prompt(page)).toBeHidden();
-
- await press(page, 'Toggle composer');
- await expect(prompt(page)).toBeVisible();
-});
diff --git a/apps/web/src/lib/core/component/Toast/browser-test/vite.config.ts b/apps/web/src/lib/core/component/Toast/browser-test/vite.config.ts
deleted file mode 100644
index f8ef8672cf..0000000000
--- a/apps/web/src/lib/core/component/Toast/browser-test/vite.config.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { fileURLToPath } from 'node:url';
-import tailwindcss from '@tailwindcss/vite';
-import { defineConfig } from 'vite';
-import solid from 'vite-plugin-solid';
-import solidSvg from 'vite-plugin-solid-svg';
-import tsconfigPaths from 'vite-tsconfig-paths';
-
-const directory = fileURLToPath(new URL('.', import.meta.url));
-const webDirectory = fileURLToPath(
- new URL('../../../../../../', import.meta.url)
-);
-export default defineConfig({
- root: directory,
- cacheDir: `${directory}/.vite`,
- plugins: [
- tailwindcss(),
- solid(),
- solidSvg({ defaultAsComponent: true }),
- tsconfigPaths({ projects: [`${webDirectory}/tsconfig.json`] }),
- ],
- resolve: {
- dedupe: ['solid-js'],
- alias: { 'loro-crdt': 'loro-crdt/base64' },
- },
- optimizeDeps: { esbuildOptions: { target: 'esnext' } },
- server: { host: '127.0.0.1', strictPort: true },
-});
diff --git a/docs/agent-guide/settings.md b/docs/agent-guide/settings.md
index 6317fcf538..05a38c27a5 100644
--- a/docs/agent-guide/settings.md
+++ b/docs/agent-guide/settings.md
@@ -83,16 +83,7 @@ Notifications**. Select **Enable** to request permission through the native
notification provider; macOS uses its system permission dialog. The web prompt
continues to say **Enable Browser Notifications** and uses browser permissions.
Select **Hide** to dismiss the prompt. It waits in the same region as other
-prompts, one card at a time. It steps aside while a popover, dialog, drawer, or
-sheet is open (the calendar event details, for example). It also waits while an
-email thread or the email composer is open, and on touch devices while search
-results are open, since their last controls sit where the prompt would. On
-desktop it waits while a channel, DM or agent conversation shows its composer at
-the bottom of a pane, and while a call is on screen (its controls, Open chat and
-the chat composer sit in that corner). On every device it also waits while a
-composer's `@`, `:` or `/` menu (or its skills, snippets, tags or GIF picker) is
-open, since those open upward over the prompt. It comes back once none of them
-is on screen, for example after you leave the call view or end the call.
+prompts, one card at a time.
### Notification snoozes
diff --git a/rules/ast-grep/tsx-no-document-has-selector.yml b/rules/ast-grep/tsx-no-document-has-selector.yml
new file mode 100644
index 0000000000..b14032a8d0
--- /dev/null
+++ b/rules/ast-grep/tsx-no-document-has-selector.yml
@@ -0,0 +1,13 @@
+id: tsx-no-document-has-selector
+language: tsx
+severity: error
+message: Don't anchor a :has() selector on html, body or :root.
+note: |-
+ While such a rule is in the stylesheet, Chrome restyles the whole document on
+ every element insertion or removal, which made typing in composers lag by
+ hundreds of milliseconds. Derive the state in JS instead.
+files:
+ - apps/web/**
+rule:
+ kind: string_fragment
+ regex: (^|[^-\w])(html|body|:root):has\(