Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Fix Escape dismissal after replacing all matches (#7597)
Nick Gomeze0c12f0e4a03
diff --git a/.changeset/find-replace-escape-dismissal.md b/.changeset/find-replace-escape-dismissal.mdnew file mode 100644index 000000000..a650342de--- /dev/null+++ b/.changeset/find-replace-escape-dismissal.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge-app': patch+---++Escape closes find and replace after replacing matches, even while a tooltip is fading out.diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex eafc8e15c..9db979676 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -6712,6 +6712,7 @@ The following packages are patched in this repository via pnpm's `patchedDepende| `@lingui/[email protected]` | `patches/@lingui%[email protected]` || `@pierre/[email protected]` | `patches/@pierre%[email protected]` || `@pierre/[email protected]` | `patches/@pierre%[email protected]` |+| `@radix-ui/[email protected]` | `patches/@[email protected]` || `@tiptap/[email protected]` | `patches/@tiptap%[email protected]` || `@tiptap/[email protected]` | `patches/@tiptap%[email protected]` || `@xterm/[email protected]` | `patches/@xterm%[email protected]` |diff --git a/knip.config.ts b/knip.config.tsindex e04bf5228..fac2580fe 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -157,11 +157,15 @@ export default {'src/shadow-fixture-launch.test-helper.mjs',],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: ['yjs'],+ ignoreDependencies: [+ 'yjs',+ ],},'packages/desktop': {entry: [diff --git a/packages/app/src/components/ui/tooltip.dom.test.tsx b/packages/app/src/components/ui/tooltip.dom.test.tsxindex af4269435..7f33aefb9 100644--- a/packages/app/src/components/ui/tooltip.dom.test.tsx+++ b/packages/app/src/components/ui/tooltip.dom.test.tsx@@ -1,4 +1,4 @@-import { cleanup, render, screen } from '@testing-library/react';+import { cleanup, render, screen, waitFor } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { act } from 'react';import { afterEach, describe, expect, test } from 'vitest';@@ -89,6 +89,27 @@ describe('Tooltip runtime contracts', () => {expect(screen.getByRole('tooltip').textContent).toBe('Tooltip body');});+ test('Escape dismisses an open tooltip', async () => {+ const { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } = await import('./tooltip');+ const user = userEvent.setup();++ render(+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <button type="button">Target</button>+ </TooltipTrigger>+ <TooltipContent>Tooltip body</TooltipContent>+ </Tooltip>+ </TooltipProvider>,+ );++ await user.hover(screen.getByRole('button', { name: 'Target' }));+ expect(screen.getByRole('tooltip').textContent).toBe('Tooltip body');+ await user.keyboard('{Escape}');+ await waitFor(() => expect(screen.queryByRole('tooltip')).toBeNull());+ });+test.each([{ arrow: undefined, svgs: 1 },{ arrow: false, svgs: 0 },diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex a50b00123..4549c74b3 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 6fcdc23f2..4fc2c11f9 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 40b5cdfd6..9f2f6feb6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 93666af70..2a085742b 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 867598d34..878d5196b 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 0970ac12f..4ada3cf26 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex b632185e1..cbe2b705f 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,3 +1,4 @@+import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex c530ce4ba..89bc9b4d9 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex d3767adc9..a78aeb0e4 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,3 +1,4 @@+import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex b076f955c..e7cc69c3f 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 7935e35f8..9ddcd0730 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,3 +1,4 @@+import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/stress/find-replace-escape.e2e.ts b/packages/app/tests/stress/find-replace-escape.e2e.tsnew file mode 100644index 000000000..b792df536--- /dev/null+++ b/packages/app/tests/stress/find-replace-escape.e2e.ts@@ -0,0 +1,90 @@+import { randomUUID } from 'node:crypto';+import { expect, test, waitForActiveProviderSynced } from './_helpers';++for (const timing of ['during', 'after']) {+ test(`Escape closes find/replace ${timing} tooltip exit`, async ({ page, api }, testInfo) => {+ const docName = `test-find-escape-${randomUUID()}`;+ await api.seedDocs([{ name: docName, markdown: '# Find\n\nneedle one needle two.' }]);+ await page.goto(`/#/${docName}`);+ await waitForActiveProviderSynced(page);++ const editor = page.locator('.ProseMirror:not(.composer-prosemirror)');+ await expect(editor).toContainText('needle one needle two.');+ await page.keyboard.press(process.platform === 'darwin' ? 'Meta+Alt+F' : 'Control+H');++ const bar = page.getByTestId('find-replace-bar');+ const find = bar.getByRole('textbox', { name: 'Find', exact: true });+ await expect(find).toBeFocused();+ await find.fill('needle');+ await expect(bar).toContainText('1 / 2');+ await bar.getByRole('textbox', { name: 'Replace', exact: true }).fill('marker');++ const replaceAll = bar.getByRole('button', { name: 'Replace all matches' });+ await replaceAll.hover();+ await expect(page.getByRole('tooltip')).toHaveText('Replace all matches');++ const tooltip = page.locator('[data-slot="tooltip-content"]');+ const exit = await tooltip.evaluateHandle((element) => {+ const animations: Animation[] = [];+ const pause = (event: Event) => {+ if (event.target !== element || element.getAttribute('data-state') !== 'closed') return;+ for (const animation of element.getAnimations()) {+ animation.pause();+ animations.push(animation);+ }+ };+ element.addEventListener('animationstart', pause);+ return { element, animations, pause };+ });++ async function finishTooltipExit() {+ await exit.evaluate(({ animations }) => {+ for (const animation of animations) animation.play();+ });+ await expect(tooltip).toHaveCount(0);+ }++ try {+ await replaceAll.click();+ await expect(editor).toContainText('marker one marker two.');+ await expect(replaceAll).toBeDisabled();+ await expect+ .poll(() =>+ exit.evaluate(+ ({ element, animations }, detachedAllowed) =>+ (detachedAllowed && !element.isConnected) ||+ (element.isConnected &&+ element.getAttribute('data-state') === 'closed' &&+ animations.length > 0 &&+ animations.every((animation) => animation.playState === 'paused')),+ timing === 'after',+ ),+ )+ .toBe(true);++ if (timing === 'after') await finishTooltipExit();+ await testInfo.attach('tooltip-before-escape', {+ body: JSON.stringify(+ await exit.evaluate(({ element, animations }) => ({+ connected: element.isConnected,+ state: element.getAttribute('data-state'),+ animations: animations.map((animation) => animation.playState),+ focusedTag: document.activeElement?.tagName,+ })),+ ),+ contentType: 'application/json',+ });+ await page.keyboard.press('Escape');+ if (timing === 'during') await finishTooltipExit();++ await expect(bar).toBeHidden();+ await expect(editor).toBeFocused();+ } finally {+ await exit.evaluate(({ element, animations, pause }) => {+ element.removeEventListener('animationstart', pause);+ for (const animation of animations) animation.play();+ });+ await exit.dispose();+ }+ });+}diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex e7e63f43d..ffd8fce06 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fc267cbea..fb0ba5a7c 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex 861003fb4..ae8cb390b 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/patches/@[email protected] b/patches/@[email protected]new file mode 100644index 000000000..425ae575b--- /dev/null+++ b/patches/@[email protected]@@ -0,0 +1,26 @@+diff --git a/dist/index.js b/dist/index.js+index 2d0d314a00082c458d2f551d715572cd1fa1b5c3..a93a36e2d9d35f7c4545fe77ab7c9fe2c0f53c95 100644+--- a/dist/index.js++++ b/dist/index.js+@@ -373,7 +373,7 @@ var TooltipContentImpl = React.forwardRef(+ onEscapeKeyDown,+ onPointerDownOutside,+ onFocusOutside: (event) => event.preventDefault(),+- onDismiss: onClose,++ onDismiss: context.open ? onClose : void 0,+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(+ PopperPrimitive.Content,+ {+diff --git a/dist/index.mjs b/dist/index.mjs+index 568389bf3ce8123fa6de6d298878b32d613e25cf..1fa56355918e2cdc6f4b9d9ca9e07cc756681eeb 100644+--- a/dist/index.mjs++++ b/dist/index.mjs+@@ -326,7 +326,7 @@ var TooltipContentImpl = React.forwardRef(+ onEscapeKeyDown,+ onPointerDownOutside,+ onFocusOutside: (event) => event.preventDefault(),+- onDismiss: onClose,++ onDismiss: context.open ? onClose : void 0,+ children: /* @__PURE__ */ jsxs(+ PopperPrimitive.Content,+ {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 98d873855..a5f3d3a88 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -151,6 +151,7 @@ patchedDependencies:'@lingui/[email protected]': 126db40cb2224e90abf5f063d3aa005eb1bc84796d77216d5a9e52d5cd28a656'@pierre/[email protected]': c823ecf3ff76ff3c3e71f441f2a7286aa2aae8e91b4d5e5a10554d8441d6c739'@pierre/[email protected]': 86ac804ac75d9f365ee9ef918460463a211ac5201ebc3cf04fc0534c5b3adf88+ '@radix-ui/[email protected]': 782d82d9e8abae7307ad4b4ab18b1680d374a2ff86f4aaa0a7a1528db1406693'@tiptap/[email protected]': 1b9619bc7312665109e19145213057775714cfb21879fb32ab1237fbfbffcdc5'@tiptap/[email protected]': cf143fe8d2092247ec0d3e596841b684f9f84e37d0eff4a1b45eb89f1e791c43'@xterm/[email protected]': 52e724ea4ed73d38923344d68d2e1e8503110de5870507336fe8b096d92d7d90@@ -13711,7 +13712,7 @@ snapshots:'@radix-ui/react-scroll-area': 1.2.10(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.3.0(@types/[email protected])([email protected])'@radix-ui/react-tabs': 1.1.13(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-tooltip': 1.2.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-tooltip': 1.2.8(patch_hash=782d82d9e8abae7307ad4b4ab18b1680d374a2ff86f4aaa0a7a1528db1406693)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.3(@types/[email protected])([email protected])'@radix-ui/react-use-layout-effect': 1.1.2(@types/[email protected])([email protected])@@ -16100,7 +16101,7 @@ snapshots:'@types/react': 19.2.17'@types/react-dom': 19.2.3(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](patch_hash=782d82d9e8abae7307ad4b4ab18b1680d374a2ff86f4aaa0a7a1528db1406693)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.4'@radix-ui/react-compose-refs': 1.1.3(@types/[email protected])([email protected])@@ -22173,7 +22174,7 @@ snapshots:'@radix-ui/react-toggle': 1.1.10(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-toggle-group': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-toolbar': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-tooltip': 1.2.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-tooltip': 1.2.8(patch_hash=782d82d9e8abae7307ad4b4ab18b1680d374a2ff86f4aaa0a7a1528db1406693)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.3(@types/[email protected])([email protected])'@radix-ui/react-use-effect-event': 0.0.3(@types/[email protected])([email protected])diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 90fa22114..5b698cb09 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -297,6 +297,7 @@ patchedDependencies:'@lingui/[email protected]': patches/@lingui%[email protected]'@pierre/[email protected]': patches/@pierre%[email protected]'@pierre/[email protected]': patches/@pierre%[email protected]+ '@radix-ui/[email protected]': patches/@[email protected]'@tiptap/[email protected]': patches/@tiptap%[email protected]'@tiptap/[email protected]': patches/@tiptap%[email protected]'@xterm/[email protected]': patches/@xterm%[email protected]