Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Keep the caret after text typed right after Enter (#7633)
Dimitri POSTOLOV49b1ca93219d
diff --git a/.changeset/new-block-caret-after-typed-marker.md b/.changeset/new-block-caret-after-typed-marker.mdnew file mode 100644index 000000000..294c86fe5--- /dev/null+++ b/.changeset/new-block-caret-after-typed-marker.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge-app': patch+---++Typing right after Enter keeps the caret after the first character, so a fast `* ` or `- ` turns into a bullet instead of landing before the marker.diff --git a/knip.config.ts b/knip.config.tsindex fac2580fe..e04bf5228 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -157,15 +157,11 @@ 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/editor/extensions/chunk-wrapper-decoration.ts b/packages/app/src/editor/extensions/chunk-wrapper-decoration.tsindex 07b751d0b..2a93b003e 100644--- a/packages/app/src/editor/extensions/chunk-wrapper-decoration.ts+++ b/packages/app/src/editor/extensions/chunk-wrapper-decoration.ts@@ -12,6 +12,10 @@ export const chunkWrapperDecorationKey = new PluginKey('chunkWrapperDecoration')export const OK_CHUNK_WRAPPER_CLASS = 'ok-chunk-wrapper';+const CHUNK_WRAPPER_ATTRS = { class: OK_CHUNK_WRAPPER_CLASS };++const SELECTION_BLOCK_ATTRS = { ...CHUNK_WRAPPER_ATTRS, 'data-ok-selection-block': '' };+let firstEmitFired = false;export function __resetFirstEmitForTesting(): void {@@ -35,15 +39,15 @@ export function chunkWrapperDecorationPlugin(): Plugin {key: chunkWrapperDecorationKey,props: {decorations(state) {+ const selectionStartIndex = state.selection.$from.index(0);+ const selectionEndIndex = state.selection.$to.index(0);const decos: Decoration[] = [];- state.doc.forEach((node, pos) => {+ state.doc.forEach((node, pos, index) => {if (node.isInline) return;if (node.type.name === 'jsxComponent') return;- decos.push(- Decoration.node(pos, pos + node.nodeSize, {- class: OK_CHUNK_WRAPPER_CLASS,- }),- );+ const holdsSelection = index === selectionStartIndex || index === selectionEndIndex;+ const attrs = holdsSelection ? SELECTION_BLOCK_ATTRS : CHUNK_WRAPPER_ATTRS;+ decos.push(Decoration.node(pos, pos + node.nodeSize, attrs));});if (decos.length === 0) return null;if (!firstEmitFired) {diff --git a/packages/app/src/globals.css b/packages/app/src/globals.cssindex 6df9d4a27..6ac13ef93 100644--- a/packages/app/src/globals.css+++ b/packages/app/src/globals.css@@ -624,22 +624,31 @@ body[style*="pointer-events: none"] .corner-card-column .floating-card-surface {animation-delay: 60ms;}-/* Reduced motion — keep opacity/color transition for comprehension, remove movement.- Static terracotta left accent bar fades in and out, no transform, no background tint. */+/* Reduced motion — keep a color fade for comprehension, remove movement.+ Static terracotta left accent bar fades in, no transform, no background tint.+ The fade is an animation, not a transition: these blocks keep `transition`+ for the `.ok-chunk-wrapper` content-visibility deferral, and a `transition`+ here would replace it while the flash lasts. */+@keyframes ok-agent-flash-bar {+ from {+ box-shadow: none;+ }+ to {+ box-shadow: inset 3px 0 0 var(--color-agent);+ }+}@media (prefers-reduced-motion: reduce) {[data-agent-flash-state="editing"][data-agent-flash-position="append"].ProseMirror> *:nth-last-child(-n + 3 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {- animation: none;+ animation: ok-agent-flash-bar 2s ease forwards;box-shadow: inset 3px 0 0 var(--color-agent);- transition: box-shadow 2s ease;}[data-agent-flash-state="editing"][data-agent-flash-position="prepend"].ProseMirror> *:nth-child(-n + 3) {- animation: none;+ animation: ok-agent-flash-bar 2s ease forwards;box-shadow: inset 3px 0 0 var(--color-agent);- transition: box-shadow 2s ease;}}@@ -5933,17 +5942,21 @@ html [data-editor-file-list-slot] [data-slot="sidebar-inner"] {}}-.dark- [data-agent-flash-state="editing"][data-agent-flash-position="append"]- .ProseMirror- > *:nth-last-child(-n + 3 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {- animation-name: agent-flash-dark;-}-.dark- [data-agent-flash-state="editing"][data-agent-flash-position="prepend"]- .ProseMirror- > *:nth-child(-n + 3) {- animation-name: agent-flash-dark;+/* Full motion only: under reduced motion the agent flash is the accent-bar+ fade in both themes. */+@media (prefers-reduced-motion: no-preference) {+ .dark+ [data-agent-flash-state="editing"][data-agent-flash-position="append"]+ .ProseMirror+ > *:nth-last-child(-n + 3 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {+ animation-name: agent-flash-dark;+ }+ .dark+ [data-agent-flash-state="editing"][data-agent-flash-position="prepend"]+ .ProseMirror+ > *:nth-child(-n + 3) {+ animation-name: agent-flash-dark;+ }}.dark [data-presence-badge="agent"][data-presence-mode="editing"] {@@ -6401,19 +6414,41 @@ html [data-editor-file-list-slot] [data-slot="sidebar-inner"] {result and reading a caret out of it.What actually protects this site is the selection pin: a click places the- caret in the block, and cv:auto keeps a selection-containing element- relevant to the user, so the clicked wrapper cannot acquire the lock that- would make the CHECK reachable. That is Chromium behavior, not ours, and it- is pinned by `tests/stress/cv-auto-paint-lock-click.e2e.ts` — which fails if- a future Chromium drops it.+ caret in the block, so the clicked wrapper cannot acquire the lock that+ would make the CHECK reachable. Two things hold the pin. Chromium keeps a+ selection-containing cv:auto element relevant to the user, and the+ `data-ok-selection-block` rule below makes the wrapper that holds the caret+ `visible`. `tests/stress/cv-auto-paint-lock-click.e2e.ts` pins the clicked+ wrapper staying unlocked, so it fails only if both are lost.Do not replace `auto` with `hidden` here without the same deferred-lock +visibility pair `.ok-mode-hidden` carries — an undeferred paint lock overhit-testable editor content trips Blink's display-lock CHECK (see the- `.ok-mode-hidden` comment above). */+ `.ok-mode-hidden` comment above).++ Chromium's pin does not cover typing into a block made in the same frame+ as its caret. Enter creates a new wrapper and moves the caret into it; the+ wrapper locks at its first style recalc and unlocks only at the next+ rendering update. A key typed before that update is inserted without+ layout, so Chromium leaves the caret before the typed character and keeps+ the placeholder `<br>`. The decoration therefore marks the top-level block+ holding each selection end with `data-ok-selection-block`, which stays+ `visible`. A block the caret leaves takes `auto` back through the+ `.ok-mode-hidden` deferring transition, because a caret that moves back in+ during the same frame (ArrowUp right after Enter) would otherwise land at+ the start of a locked line. Any other rule that sets `transition` on a+ top-level block replaces this deferral, which is why the reduced-motion+ agent flash fades with an animation. Pinned by+ `tests/stress/new-block-caret.e2e.ts`. */.ProseMirror .ok-chunk-wrapper {content-visibility: auto;contain-intrinsic-size: 0 var(--ok-cv-h, 80px);+ transition: content-visibility 0s 32ms allow-discrete;+}++.ProseMirror .ok-chunk-wrapper[data-ok-selection-block] {+ content-visibility: visible;+ transition: none;}/* Code-block wrapper needs an unclipped paint area — the block's chromediff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex 4549c74b3..a50b00123 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,4 +1,3 @@-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 4fc2c11f9..6fcdc23f2 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,4 +1,3 @@-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 9f2f6feb6..40b5cdfd6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,4 +1,3 @@-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 2a085742b..93666af70 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,4 +1,3 @@-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 878d5196b..867598d34 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,4 +1,3 @@-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 4ada3cf26..0970ac12f 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,4 +1,3 @@-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 cbe2b705f..b632185e1 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,4 +1,3 @@-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 89bc9b4d9..c530ce4ba 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,4 +1,3 @@-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 a78aeb0e4..d3767adc9 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,4 +1,3 @@-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 e7cc69c3f..b076f955c 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,4 +1,3 @@-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 9ddcd0730..7935e35f8 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,4 +1,3 @@-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/agent-flash-reduced-motion.e2e.ts b/packages/app/tests/stress/agent-flash-reduced-motion.e2e.tsnew file mode 100644index 000000000..036f8968d--- /dev/null+++ b/packages/app/tests/stress/agent-flash-reduced-motion.e2e.ts@@ -0,0 +1,99 @@+import { randomUUID } from 'node:crypto';+import type { Page } from '@playwright/test';+import { expect, test, waitForActiveProviderSynced } from './_helpers';++const EDITOR = '.ProseMirror:not(.composer-prosemirror)';+const FIRST_LINE = 'First line';+const AGENT_LINE = 'The agent added this line.';+const PEAK_MS = 160;+const LATE_MS = 1900;++interface FlashFrame {+ transform: string;+ background: string;+ barAlpha: number;+}++interface FlashReading {+ reducedMotion: boolean;+ dark: boolean;+ flashState: string | null;+ animationCount: number;+ peak: FlashFrame;+ late: FlashFrame;+}++function readFlashedBlock(page: Page): Promise<FlashReading> {+ return page.evaluate(+ ({ editorSelector, agentLine, peakMs, lateMs }) => {+ const root = document.querySelector(editorSelector);+ if (!root) throw new Error('editor not found');+ const block = Array.from(root.children).find((el) => el.textContent?.includes(agentLine));+ if (!block) throw new Error('agent block not found');+ const animations = block.getAnimations();+ for (const animation of animations) animation.pause();+ const barAlpha = (boxShadow: string): number => {+ if (!boxShadow.includes('inset')) return 0;+ const channels = boxShadow.match(/rgba?\(([^)]+)\)/)?.[1].split(',') ?? [];+ if (channels.length === 3) return 1;+ if (channels.length === 4) return Number(channels[3]);+ throw new Error(`cannot read the accent bar color from box-shadow "${boxShadow}"`);+ };+ const frameAt = (ms: number) => {+ for (const animation of animations) animation.currentTime = ms;+ const style = getComputedStyle(block);+ return {+ transform: style.transform,+ background: style.backgroundColor,+ barAlpha: barAlpha(style.boxShadow),+ };+ };+ return {+ reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,+ dark: document.documentElement.classList.contains('dark'),+ flashState:+ root.closest('[data-agent-flash-state]')?.getAttribute('data-agent-flash-state') ?? null,+ animationCount: animations.length,+ peak: frameAt(peakMs),+ late: frameAt(lateMs),+ };+ },+ { editorSelector: EDITOR, agentLine: AGENT_LINE, peakMs: PEAK_MS, lateMs: LATE_MS },+ );+}++for (const theme of ['light', 'dark'] as const) {+ test(`under reduced motion, an agent flash in the ${theme} theme shows only the accent bar`, async ({+ page,+ api,+ }) => {+ await page.emulateMedia({ colorScheme: theme, reducedMotion: 'reduce' });+ await page.addInitScript((value) => window.localStorage.setItem('ok-theme-v1', value), theme);+ const docName = `agent-flash-${theme}-${randomUUID()}`;+ await api.seedDocs([{ name: docName, markdown: `${FIRST_LINE}\n` }]);+ await page.goto(`/#/${docName}`);+ await waitForActiveProviderSynced(page);+ await expect(page.locator(EDITOR)).toContainText(FIRST_LINE);++ await api.writeAsAgent(docName, `${FIRST_LINE}\n\n${AGENT_LINE}\n`, {+ agentId: 'flash-theme',+ agentName: 'FlashTheme',+ });+ await expect(page.locator(EDITOR)).toContainText(AGENT_LINE);+ await expect(page.locator(`.tiptap-editor:has(${EDITOR})`)).toHaveAttribute(+ 'data-agent-flash-state',+ 'editing',+ );++ const reading = await readFlashedBlock(page);++ expect(reading).toMatchObject({+ reducedMotion: true,+ dark: theme === 'dark',+ flashState: 'editing',+ });+ expect(reading.animationCount).toBeGreaterThan(0);+ expect(reading.peak).toMatchObject({ transform: 'none', background: 'rgba(0, 0, 0, 0)' });+ expect(reading.late.barAlpha).toBeGreaterThan(0.9);+ });+}diff --git a/packages/app/tests/stress/cv-auto-paint-lock-click.e2e.ts b/packages/app/tests/stress/cv-auto-paint-lock-click.e2e.tsindex a9e6f3d1b..f83d106fb 100644--- a/packages/app/tests/stress/cv-auto-paint-lock-click.e2e.ts+++ b/packages/app/tests/stress/cv-auto-paint-lock-click.e2e.ts@@ -218,11 +218,11 @@ test('PRD-8158: a clicked .ok-chunk-wrapper stays out of the cv:auto paint lock').toBeGreaterThan(0);expect(after.events.filter((e) => e.marker === targetMarker && e.skipped).length,- `the clicked block "${targetMarker}" entered a cv:auto paint lock. Chromium no longer keeps a ` +- 'selection-containing element relevant, which is the property that currently keeps this site ' +- "safe: a click's hit test resolves to a descendant, and a wrapper that can lock afterwards " +- 'reopens the display-lock CHECK. Harden .ok-chunk-wrapper with the same deferral trio ' +- '.ok-mode-hidden carries.',+ `the clicked block "${targetMarker}" entered a cv:auto paint lock. Neither Chromium's selection ` ++ 'pin nor the data-ok-selection-block rule in globals.css kept the selection-containing wrapper ' ++ "relevant: a click's hit test resolves to a descendant, and a wrapper that can lock afterwards " ++ 'reopens the display-lock CHECK. Restore the data-ok-selection-block rule, or harden ' ++ '.ok-chunk-wrapper with the same deferral trio .ok-mode-hidden carries.',).toBe(0);});diff --git a/packages/app/tests/stress/new-block-caret.e2e.ts b/packages/app/tests/stress/new-block-caret.e2e.tsnew file mode 100644index 000000000..8ce6acad1--- /dev/null+++ b/packages/app/tests/stress/new-block-caret.e2e.ts@@ -0,0 +1,213 @@+import { randomUUID } from 'node:crypto';+import type { Page } from '@playwright/test';+import {+ type ApiHelpers,+ expect,+ placeCaretAtEndOfText,+ test,+ waitForActiveProviderSynced,+} from './_helpers';++const EDITOR = '.ProseMirror:not(.composer-prosemirror)';+const FIRST_LINE = 'Start here:';+const LONG_LINE = 'abcdefghijklmnopqrstuvwxyz0123456789';+const AGENT_LINE = 'The agent added this line.';++type Gap = 'same-task' | 'after-frame';++interface CaretReading {+ frameRanBeforeInput: boolean;+ flashStateAtInput: string | null;+ caretInNewEmptyBlock: boolean;+ parentOffset: number;+ parentText: string;+}++async function openFreshDoc(page: Page, api: ApiHelpers): Promise<string> {+ const docName = `new-block-caret-${randomUUID()}`;+ await api.seedDocs([{ name: docName, markdown: `${FIRST_LINE}\n` }]);+ await page.goto(`/#/${docName}`);+ await waitForActiveProviderSynced(page);+ await expect(page.locator(EDITOR)).toContainText(FIRST_LINE);+ await placeCaretAtEndOfText(page, FIRST_LINE);+ return docName;+}++async function pressEnterThen(+ page: Page,+ gap: Gap,+ input: 'type-marker' | 'move-up',+): Promise<CaretReading> {+ return page.evaluate(+ async ({ gap, input, longLine }) => {+ const editor = window.__activeEditor;+ if (!editor) throw new Error('window.__activeEditor not set');+ const view = editor.view;+ const nextFrame = (): Promise<void> =>+ new Promise((resolve) => requestAnimationFrame(() => setTimeout(resolve, 0)));+ let frameRan = false;+ requestAnimationFrame(() => {+ frameRan = true;+ });+ const blocksBefore = view.state.doc.childCount;+ const indexBefore = view.state.selection.$from.index(0);+ view.dom.dispatchEvent(+ new KeyboardEvent('keydown', {+ key: 'Enter',+ code: 'Enter',+ bubbles: true,+ cancelable: true,+ }),+ );+ const afterEnter = view.state.selection.$from;+ const caretInNewEmptyBlock =+ view.state.doc.childCount === blocksBefore + 1 &&+ afterEnter.index(0) === indexBefore + 1 &&+ afterEnter.parent.content.size === 0;+ if (input === 'move-up') editor.commands.insertContent(longLine);+ if (gap === 'after-frame') await nextFrame();+ const frameRanBeforeInput = frameRan;+ const flashStateAtInput =+ view.dom.closest('[data-agent-flash-state]')?.getAttribute('data-agent-flash-state') ??+ null;+ if (input === 'type-marker') {+ // oxlint-disable-next-line typescript/no-deprecated -- execCommand is the only way to run Chromium's native insertText, the command a keypress runs, in the same task as Enter+ document.execCommand('insertText', false, '*');+ await Promise.resolve();+ } else {+ document.getSelection()?.modify('move', 'backward', 'line');+ await nextFrame();+ }+ const { $from } = view.state.selection;+ return {+ frameRanBeforeInput,+ flashStateAtInput,+ caretInNewEmptyBlock,+ parentOffset: $from.parentOffset,+ parentText: $from.parent.textContent,+ };+ },+ { gap, input, longLine: LONG_LINE },+ );+}++const readSource = (page: Page): Promise<string> =>+ page.evaluate(() => window.__activeProvider?.document?.getText('source')?.toString() ?? '');++test.describe('typing into a block made in the same frame as its caret', () => {+ test('a marker typed before the next frame keeps the caret after it, so "* " becomes a bullet', async ({+ page,+ api,+ }) => {+ await openFreshDoc(page, api);++ const reading = await pressEnterThen(page, 'same-task', 'type-marker');++ expect(reading.frameRanBeforeInput).toBe(false);+ expect(reading.caretInNewEmptyBlock).toBe(true);+ expect({ offset: reading.parentOffset, text: reading.parentText }).toEqual({+ offset: 1,+ text: '*',+ });++ await page.keyboard.type(' Milk');+ await expect(page.locator(EDITOR).locator('ul > li')).toHaveText(['Milk']);+ await expect.poll(() => readSource(page)).toMatch(/^Start here:\n\n[*-] Milk\n?$/);+ });++ test('control: the same marker typed after a frame keeps the caret after it', async ({+ page,+ api,+ }) => {+ await openFreshDoc(page, api);++ const reading = await pressEnterThen(page, 'after-frame', 'type-marker');++ expect(reading.frameRanBeforeInput).toBe(true);+ expect(reading.caretInNewEmptyBlock).toBe(true);+ expect({ offset: reading.parentOffset, text: reading.parentText }).toEqual({+ offset: 1,+ text: '*',+ });+ });++ test('moving up before the next frame keeps the caret column in the block it just left', async ({+ page,+ api,+ }) => {+ await openFreshDoc(page, api);++ const reading = await pressEnterThen(page, 'same-task', 'move-up');++ expect(reading.frameRanBeforeInput).toBe(false);+ expect(reading.caretInNewEmptyBlock).toBe(true);+ expect({ offset: reading.parentOffset, text: reading.parentText }).toEqual({+ offset: FIRST_LINE.length,+ text: FIRST_LINE,+ });+ });++ test('moving up before the next frame keeps the caret column while a reduced-motion agent flash is on', async ({+ page,+ api,+ }) => {+ await page.emulateMedia({ reducedMotion: 'reduce' });+ const docName = await openFreshDoc(page, api);+ await api.writeAsAgent(docName, `${FIRST_LINE}\n\n${AGENT_LINE}\n`, {+ agentId: 'flash-probe',+ agentName: 'FlashProbe',+ });+ await expect(page.locator(EDITOR)).toContainText(AGENT_LINE);+ await expect(page.locator(`.tiptap-editor:has(${EDITOR})`)).toHaveAttribute(+ 'data-agent-flash-state',+ 'editing',+ );+ await placeCaretAtEndOfText(page, FIRST_LINE);++ const reading = await pressEnterThen(page, 'same-task', 'move-up');++ expect(reading.flashStateAtInput).toBe('editing');+ expect(reading.frameRanBeforeInput).toBe(false);+ expect(reading.caretInNewEmptyBlock).toBe(true);+ expect({ offset: reading.parentOffset, text: reading.parentText }).toEqual({+ offset: FIRST_LINE.length,+ text: FIRST_LINE,+ });+ });+});++test('a selection across blocks keeps content-visibility auto on the blocks between its ends', async ({+ page,+ api,+}) => {+ const lines = ['Line zero', 'Line one', 'Line two', 'Line three', 'Line four', 'Line five'];+ const docName = `selection-blocks-${randomUUID()}`;+ await api.seedDocs([{ name: docName, markdown: `${lines.join('\n\n')}\n` }]);+ await page.goto(`/#/${docName}`);+ await waitForActiveProviderSynced(page);+ await expect(page.locator(EDITOR)).toContainText('Line five');+ const selectionEnds = await page.evaluate(() => {+ const editor = window.__activeEditor;+ if (!editor) throw new Error('window.__activeEditor not set');+ const ends: number[] = [];+ editor.state.doc.forEach((node, pos) => {+ ends.push(pos + node.nodeSize - 1);+ });+ editor.chain().focus().setTextSelection({ from: ends[1], to: ends[4] }).run();+ const { $from, $to } = editor.state.selection;+ return { from: $from.index(0), to: $to.index(0) };+ });+ expect(selectionEnds).toEqual({ from: 1, to: 4 });++ const blockVisibility = (): Promise<string[]> =>+ page.evaluate((editorSelector) => {+ const root = document.querySelector(editorSelector);+ if (!root) throw new Error('editor not found');+ return Array.from(root.children)+ .filter((el) => el.classList.contains('ok-chunk-wrapper'))+ .map((el) => getComputedStyle(el).contentVisibility);+ }, EDITOR);+ await expect+ .poll(blockVisibility)+ .toEqual(['auto', 'visible', 'auto', 'auto', 'visible', 'auto']);+});diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex 2a597ec3d..f4cc8a286 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,4 +1,3 @@-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 ffd8fce06..e7e63f43d 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,4 +1,3 @@-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 fb0ba5a7c..fc267cbea 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,4 +1,3 @@-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 ae8cb390b..861003fb4 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,4 +1,3 @@-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 8be632ba4..4d3250d3a 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,4 +1,3 @@-export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');