Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(share): offer Sync now on receive miss when auto-sync is on (#2436)

miles-kt-inkeep9719a5c455f9
diff --git a/.changeset/share-receive-miss-sync-now.md b/.changeset/share-receive-miss-sync-now.md
new file mode 100644
index 000000000..0e6383e7c
--- /dev/null
+++ b/.changeset/share-receive-miss-sync-now.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+The share-receive "changed locally" panel no longer offers to enable auto-sync when it is already on. With sync enabled it now offers Sync now instead: the push publishes your local move/rename/delete, and the panel re-checks the branch and pivots to the honest outcome — including the "moved to <new path> — open it there?" redirect when the doc was renamed. With sync off, the Enable auto-sync flow is unchanged, and when the sync engine is unavailable or failing the panel defers to the sync badge rather than offering a dead button.
diff --git a/packages/app/src/components/ShareFreshnessWarning.tsx b/packages/app/src/components/ShareFreshnessWarning.tsx
index c39aa784e..044114c6f 100644
--- a/packages/app/src/components/ShareFreshnessWarning.tsx
+++ b/packages/app/src/components/ShareFreshnessWarning.tsx
@@ -47,9 +47,11 @@ export function shareFreshnessRowVisible(
/**
* "Sync now" mirrors the sync badge's own visibility: it is hidden in the
* states where a manual trigger is meaningless or handled elsewhere (no engine,
- * turned off, needs re-auth, or blocked on a conflict).
+ * turned off, needs re-auth, or blocked on a conflict). Shared with the
+ * share-receive miss surface's changed-locally cell so both Sync-now CTAs
+ * gate on the same engine states.
*/
-function syncNowActionable(status: GitSyncStatus | null): boolean {
+export function syncNowActionable(status: GitSyncStatus | null): boolean {
if (!status) return false;
return (
status.state !== 'dormant' &&
diff --git a/packages/app/src/components/ShareReceiveMissDialog.dom.test.tsx b/packages/app/src/components/ShareReceiveMissDialog.dom.test.tsx
index 6c1df0176..c0d2fcc61 100644
--- a/packages/app/src/components/ShareReceiveMissDialog.dom.test.tsx
+++ b/packages/app/src/components/ShareReceiveMissDialog.dom.test.tsx
@@ -10,6 +10,8 @@
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test';
import type { ShareTargetStatusResponse } from '@inkeep/open-knowledge-core';
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
+import { useSyncExternalStore } from 'react';
+import type { GitSyncStatus } from '@/hooks/use-git-sync-status';
import { missDialogStore } from '@/lib/share/miss-dialog-store';
import { pendingReceiveNavStore } from '@/lib/share/pending-receive-nav-store';
@@ -28,6 +30,50 @@ mock.module('@/lib/config-provider', () => ({
}),
}));
+// The changed-locally cell picks its CTA off the live sync status (Enable
+// auto-sync when off, Sync now when on). Reactive mock so a test can land a
+// sync (lastSyncUtc advance) and observe the re-probe.
+let syncStatus: GitSyncStatus | null = null;
+const syncStatusListeners = new Set<() => void>();
+function setSyncStatus(next: GitSyncStatus | null): void {
+ syncStatus = next;
+ for (const listener of syncStatusListeners) listener();
+}
+mock.module('@/hooks/use-git-sync-status', () => ({
+ useGitSyncStatus: () =>
+ useSyncExternalStore(
+ (onStoreChange: () => void) => {
+ syncStatusListeners.add(onStoreChange);
+ return () => syncStatusListeners.delete(onStoreChange);
+ },
+ () => syncStatus,
+ ),
+ useGitSyncStatusDetailed: () => ({ status: syncStatus, fetchError: null }),
+}));
+
+let syncTriggers: string[] = [];
+let triggerSyncImpl: () => Promise<void> = () => Promise.resolve();
+mock.module('@/lib/trigger-sync', () => ({
+ triggerSync: (op: string) => {
+ syncTriggers.push(op);
+ return triggerSyncImpl();
+ },
+}));
+
+function makeSyncStatus(partial: Partial<GitSyncStatus>): GitSyncStatus {
+ return {
+ state: 'idle',
+ lastSyncUtc: '2026-07-06T00:00:00Z',
+ lastFetchUtc: null,
+ ahead: 0,
+ behind: 0,
+ conflictCount: 0,
+ hasRemote: true,
+ syncEnabled: true,
+ ...partial,
+ };
+}
+
const { ShareReceiveMissDialog } = await import('./ShareReceiveMissDialog');
type FetchTargetStatus = (req: {
@@ -70,6 +116,10 @@ afterEach(() => {
pendingReceiveNavStore.clear();
Reflect.deleteProperty(window, 'okDesktop');
autoSyncWrites = [];
+ syncTriggers = [];
+ triggerSyncImpl = () => Promise.resolve();
+ syncStatus = null;
+ syncStatusListeners.clear();
});
describe('ShareReceiveMissDialog', () => {
@@ -103,10 +153,13 @@ describe('ShareReceiveMissDialog', () => {
test('changed-locally: Enable auto-sync enables in place and dismisses the dialog', async () => {
installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ setSyncStatus(makeSyncStatus({ syncEnabled: false, state: 'disabled' }));
const dialog = await renderArmed();
expect(dialog.getAttribute('data-verdict')).toBe('changed-locally');
expect(dialog.textContent).toContain('has been moved, renamed, or deleted');
+ // Sync is OFF — the enable CTA renders, never the Sync-now one.
+ expect(screen.queryByTestId('share-receive-miss-sync-now')).toBeNull();
// Open the guarded confirm, then confirm inside it (the confirm dialog is the
// OTHER role=dialog — the miss dialog carries the testid). Confirming enables
@@ -124,6 +177,98 @@ describe('ShareReceiveMissDialog', () => {
});
});
+ test('changed-locally with auto-sync ON offers Sync now; a landed sync re-probes to the honest verdict', async () => {
+ // First probe says changed-locally; after the push lands the local rename is
+ // on the branch, so the re-probe reports renamed with the redirect target.
+ const verdicts: ShareTargetStatusResponse[] = [
+ { verdict: 'changed-locally' },
+ { verdict: 'renamed', renamedTo: 'knowledge/new-plan.md' },
+ ];
+ let probeCount = 0;
+ installBridge(() => Promise.resolve(verdicts[Math.min(probeCount++, verdicts.length - 1)]));
+ setSyncStatus(makeSyncStatus({ syncEnabled: true, lastSyncUtc: 't0' }));
+ const dialog = await renderArmed();
+
+ expect(dialog.getAttribute('data-verdict')).toBe('changed-locally');
+ expect(dialog.textContent).toContain("hasn't synced yet");
+ // Sync is already ON — offering to enable it would be nonsense.
+ expect(screen.queryByTestId('share-receive-miss-enable-sync')).toBeNull();
+
+ fireEvent.click(screen.getByTestId('share-receive-miss-sync-now'));
+ expect(syncTriggers).toEqual(['sync']);
+ // In-flight until the push lands.
+ expect((screen.getByTestId('share-receive-miss-sync-now') as HTMLButtonElement).disabled).toBe(
+ true,
+ );
+
+ // The push lands (lastSyncUtc advances over the status channel) → the
+ // verdict is re-probed → the dialog pivots to the renamed cell.
+ setSyncStatus(makeSyncStatus({ syncEnabled: true, lastSyncUtc: 't1' }));
+ await waitFor(() => {
+ expect(dialog.getAttribute('data-verdict')).toBe('renamed');
+ });
+ expect(screen.getByTestId('share-receive-miss-open-renamed')).toBeTruthy();
+ expect(probeCount).toBe(2);
+ });
+
+ test('changed-locally with auto-sync ON but a failing push defers to the sync badge (no sync CTA)', async () => {
+ installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ setSyncStatus(makeSyncStatus({ syncEnabled: true, pushError: 'push failed' }));
+ const dialog = await renderArmed();
+
+ expect(dialog.getAttribute('data-verdict')).toBe('changed-locally');
+ expect(screen.queryByTestId('share-receive-miss-sync-now')).toBeNull();
+ expect(screen.queryByTestId('share-receive-miss-enable-sync')).toBeNull();
+ expect(screen.getByTestId('share-receive-miss-browse')).toBeTruthy();
+ });
+
+ test('changed-locally with auto-sync ON but push permission denied defers to the sync badge (no sync CTA)', async () => {
+ installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ setSyncStatus(
+ makeSyncStatus({
+ syncEnabled: true,
+ pushPermission: { checkStatus: 'denied', deniedReason: 'no-collaborator' },
+ }),
+ );
+ const dialog = await renderArmed();
+
+ expect(dialog.getAttribute('data-verdict')).toBe('changed-locally');
+ expect(screen.queryByTestId('share-receive-miss-sync-now')).toBeNull();
+ expect(screen.queryByTestId('share-receive-miss-enable-sync')).toBeNull();
+ expect(screen.getByTestId('share-receive-miss-browse')).toBeTruthy();
+ });
+
+ test('Sync now recovers to an enabled button when the trigger itself fails', async () => {
+ installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ setSyncStatus(makeSyncStatus({ syncEnabled: true }));
+ triggerSyncImpl = () => Promise.reject(new Error('server down'));
+ const dialog = await renderArmed();
+
+ fireEvent.click(screen.getByTestId('share-receive-miss-sync-now'));
+ expect(syncTriggers).toEqual(['sync']);
+
+ // The rejected trigger drops the in-flight state so the user can retry —
+ // no CC1 status update will ever follow a trigger that never landed.
+ await waitFor(() => {
+ expect(
+ (screen.getByTestId('share-receive-miss-sync-now') as HTMLButtonElement).disabled,
+ ).toBe(false);
+ });
+ // No re-probe happened: the verdict is unchanged.
+ expect(dialog.getAttribute('data-verdict')).toBe('changed-locally');
+ });
+
+ test('changed-locally with an unknown sync state renders neither sync CTA', async () => {
+ installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ // syncStatus stays null (no status response yet / unreachable).
+ const dialog = await renderArmed();
+
+ expect(dialog.getAttribute('data-verdict')).toBe('changed-locally');
+ expect(screen.queryByTestId('share-receive-miss-sync-now')).toBeNull();
+ expect(screen.queryByTestId('share-receive-miss-enable-sync')).toBeNull();
+ expect(screen.getByTestId('share-receive-miss-browse')).toBeTruthy();
+ });
+
test('browse folder navigates to the parent folder and dismisses — never to the dead path', async () => {
installBridge(stubVerdict({ verdict: 'deleted' }));
await renderArmed();
diff --git a/packages/app/src/components/ShareReceiveMissDialog.tsx b/packages/app/src/components/ShareReceiveMissDialog.tsx
index 9a12fded1..61575686e 100644
--- a/packages/app/src/components/ShareReceiveMissDialog.tsx
+++ b/packages/app/src/components/ShareReceiveMissDialog.tsx
@@ -50,7 +50,7 @@ export function ShareReceiveMissDialog() {
}
function ShareReceiveMissDialogInner({ nav }: { nav: PendingReceiveNav }) {
- const state = useShareTargetVerdict(nav);
+ const { state, refetch } = useShareTargetVerdict(nav);
function dismiss(): void {
missDialogStore.dismiss();
@@ -100,6 +100,11 @@ function ShareReceiveMissDialogInner({ nav }: { nav: PendingReceiveNav }) {
onBrowseFolder={browseFolder}
onOpenRenamed={openRenamed}
onEnableAutoSync={dismiss}
+ // A landed Sync now push changes the verdict (the local
+ // delete/rename is now on the branch) — re-probe instead of
+ // dismissing, so the dialog pivots to the honest cell (including
+ // the rename redirect offer).
+ onSyncCompleted={refetch}
/>
</DialogBody>
</DialogContent>
diff --git a/packages/app/src/components/ShareReceiveMissPanel.dom.test.tsx b/packages/app/src/components/ShareReceiveMissPanel.dom.test.tsx
index 0b853f9e2..f893c8634 100644
--- a/packages/app/src/components/ShareReceiveMissPanel.dom.test.tsx
+++ b/packages/app/src/components/ShareReceiveMissPanel.dom.test.tsx
@@ -1,6 +1,7 @@
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test';
import type { ShareTargetStatusResponse } from '@inkeep/open-knowledge-core';
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react';
+import type { GitSyncStatus } from '@/hooks/use-git-sync-status';
import { pendingReceiveNavStore } from '@/lib/share/pending-receive-nav-store';
// The changed-locally cell's "Enable auto-sync" CTA enables in place via the
@@ -19,6 +20,28 @@ mock.module('@/lib/config-provider', () => ({
}),
}));
+// The changed-locally cell picks its CTA off the live sync status: Enable
+// auto-sync when the toggle is off, Sync now when it is already on.
+let syncStatus: GitSyncStatus | null = null;
+mock.module('@/hooks/use-git-sync-status', () => ({
+ useGitSyncStatus: () => syncStatus,
+ useGitSyncStatusDetailed: () => ({ status: syncStatus, fetchError: null }),
+}));
+
+function makeSyncStatus(partial: Partial<GitSyncStatus>): GitSyncStatus {
+ return {
+ state: 'idle',
+ lastSyncUtc: '2026-07-06T00:00:00Z',
+ lastFetchUtc: null,
+ ahead: 0,
+ behind: 0,
+ conflictCount: 0,
+ hasRemote: true,
+ syncEnabled: true,
+ ...partial,
+ };
+}
+
const { ShareReceiveMissPanel } = await import('./ShareReceiveMissPanel');
type FetchTargetStatus = (req: {
@@ -60,6 +83,7 @@ afterEach(() => {
window.location.hash = '';
pendingReceiveNavStore.clear();
autoSyncWrites = [];
+ syncStatus = null;
});
describe('ShareReceiveMissPanel verdict surfaces', () => {
@@ -139,12 +163,14 @@ describe('ShareReceiveMissPanel verdict surfaces', () => {
// Enable auto-sync recovery CTA (the guarded off → on flow).
test('changed-locally verdict shows the local-change message and enables auto-sync in place', async () => {
installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ syncStatus = makeSyncStatus({ syncEnabled: false, state: 'disabled' });
const panel = await renderResolved();
expect(panel.getAttribute('data-verdict')).toBe('changed-locally');
expect(panel.textContent).toContain('has been moved, renamed, or deleted');
expect(panel.textContent).not.toContain('Pull the latest changes');
expect(screen.getByTestId('share-receive-miss-browse')).toBeTruthy();
+ expect(screen.queryByTestId('share-receive-miss-sync-now')).toBeNull();
// The CTA opens the off → on confirmation gate; nothing is written until the
// user confirms, and confirming enables auto-sync in place (no navigation).
@@ -158,6 +184,20 @@ describe('ShareReceiveMissPanel verdict surfaces', () => {
expect(window.location.hash).toBe('#/notes/');
});
+ // With auto-sync already ON, offering to enable it is nonsense — the cell
+ // offers Sync now instead (full trigger/re-probe behavior is covered in the
+ // dialog's dom tests; both shells share the content component).
+ test('changed-locally with auto-sync ON offers Sync now, not Enable auto-sync', async () => {
+ installBridge(stubVerdict({ verdict: 'changed-locally' }));
+ syncStatus = makeSyncStatus({ syncEnabled: true });
+ const panel = await renderResolved();
+
+ expect(panel.getAttribute('data-verdict')).toBe('changed-locally');
+ expect(panel.textContent).toContain("hasn't synced yet");
+ expect(screen.getByTestId('share-receive-miss-sync-now')).toBeTruthy();
+ expect(screen.queryByTestId('share-receive-miss-enable-sync')).toBeNull();
+ });
+
// Fail-open (Pattern B): a transport failure surfaces as `null` from the proxy;
// the panel degrades to today's pull guidance, never a stuck spinner or throw.
test('a failed target-status fetch falls back to pull guidance', async () => {
diff --git a/packages/app/src/components/ShareReceiveMissPanel.tsx b/packages/app/src/components/ShareReceiveMissPanel.tsx
index 4f9a7c84e..b63da9f9a 100644
--- a/packages/app/src/components/ShareReceiveMissPanel.tsx
+++ b/packages/app/src/components/ShareReceiveMissPanel.tsx
@@ -20,7 +20,7 @@ import {
* post-nav miss. Both surfaces share the verdict fetch + rendering.
*/
export function ShareReceiveMissPanel({ nav }: { nav: PendingReceiveNav }) {
- const state = useShareTargetVerdict(nav);
+ const { state, refetch } = useShareTargetVerdict(nav);
const containerRef = useRef<HTMLDivElement>(null);
const branch = nav.branch;
@@ -70,6 +70,9 @@ export function ShareReceiveMissPanel({ nav }: { nav: PendingReceiveNav }) {
// folder so the recovery action clears the surface (same escape as
// Browse folder).
onEnableAutoSync={browseFolder}
+ // A landed Sync now push changes the verdict — re-probe so the panel
+ // pivots to the honest cell rather than keeping stale copy.
+ onSyncCompleted={refetch}
/>
</div>
);
diff --git a/packages/app/src/components/share-receive-miss-content.tsx b/packages/app/src/components/share-receive-miss-content.tsx
index 9397be1f7..d27b52eb0 100644
--- a/packages/app/src/components/share-receive-miss-content.tsx
+++ b/packages/app/src/components/share-receive-miss-content.tsx
@@ -25,14 +25,17 @@ import {
MapPin,
RefreshCw,
} from 'lucide-react';
-import { type ReactNode, useEffect, useState } from 'react';
+import { type ReactNode, useEffect, useRef, useState } from 'react';
import { Button } from '@/components/ui/button';
import {
useEnableSyncWithConfirm,
useSyncEnabledWriter,
} from '@/hooks/use-enable-sync-with-confirm';
+import { type GitSyncStatus, useGitSyncStatus } from '@/hooks/use-git-sync-status';
import type { PendingReceiveNav } from '@/lib/share/pending-receive-nav-store';
+import { triggerSync } from '@/lib/trigger-sync';
import { EnableSyncConfirmDialog } from './EnableSyncConfirmDialog';
+import { syncNowActionable } from './ShareFreshnessWarning';
export type ShareTargetVerdictState =
| { readonly phase: 'pending' }
@@ -47,10 +50,19 @@ export function parentFolderPath(path: string): string {
/**
* Fetch the target-status verdict for a share-receive miss. Fail-open: no
* bridge / no branch / failed fetch → `unknown`.
+ *
+ * `refetch` re-runs the probe for the SAME target — used after a "Sync now"
+ * push lands, when the just-pushed local delete/rename means the honest
+ * verdict has changed (typically to `deleted` or `renamed`).
*/
-export function useShareTargetVerdict(nav: PendingReceiveNav): ShareTargetVerdictState {
+export function useShareTargetVerdict(nav: PendingReceiveNav): {
+ state: ShareTargetVerdictState;
+ refetch: () => void;
+} {
const [state, setState] = useState<ShareTargetVerdictState>({ phase: 'pending' });
+ const [epoch, setEpoch] = useState(0);
const branch = nav.branch;
+ // biome-ignore lint/correctness/useExhaustiveDependencies: epoch is not read in the body — it exists solely to re-run the probe on refetch()
useEffect(() => {
const bridge = window.okDesktop ?? null;
// No desktop bridge (web host) or a branch-less legacy share → skip the
@@ -87,8 +99,14 @@ export function useShareTargetVerdict(nav: PendingReceiveNav): ShareTargetVerdic
return () => {
cancelled = true;
};
- }, [branch, nav.kind, nav.path]);
- return state;
+ }, [branch, nav.kind, nav.path, epoch]);
+ return {
+ state,
+ refetch: () => {
+ setState({ phase: 'pending' });
+ setEpoch((e) => e + 1);
+ },
+ };
}
/**
@@ -122,6 +140,66 @@ function EnableAutoSyncButton({ onEnabled }: { onEnabled?: () => void }) {
);
}
+/**
+ * "Sync now" recovery action for the `changed-locally` cell when auto-sync is
+ * ALREADY on — the counterpart to `EnableAutoSyncButton` (sync off). Mirrors
+ * the share popover's Sync-now: trigger the engine, hold an in-flight state
+ * until the push lands (a `lastSyncUtc` advance over the CC1-refreshed
+ * status), then hand control back via `onSyncCompleted` so the host re-probes
+ * the verdict — the just-pushed local delete/rename means the honest cell is
+ * now `deleted` or `renamed` (with its redirect offer), not this one.
+ */
+function SyncNowButton({
+ status,
+ onSyncCompleted,
+}: {
+ status: GitSyncStatus;
+ onSyncCompleted?: () => void;
+}) {
+ const [pending, setPending] = useState(false);
+ // The `lastSyncUtc` at click time; a later value means a sync completed
+ // since — the "push landed" signal.
+ const lastSyncAtClick = useRef<string | null>(null);
+
+ useEffect(() => {
+ if (!pending) return;
+ if (status.pushError || status.pushErrorCode) {
+ // The manual sync failed — drop the in-flight state so the user can
+ // retry (the sync badge carries the error detail).
+ setPending(false);
+ return;
+ }
+ if ((status.lastSyncUtc ?? null) !== lastSyncAtClick.current) {
+ setPending(false);
+ onSyncCompleted?.();
+ }
+ }, [pending, status, onSyncCompleted]);
+
+ const handleSyncNow = () => {
+ lastSyncAtClick.current = status.lastSyncUtc ?? null;
+ setPending(true);
+ // A trigger that never lands (offline / server down / non-2xx) gets no CC1
+ // status update, so drop out of the in-flight state rather than spin
+ // forever — the user can retry.
+ triggerSync('sync').catch((err) => {
+ console.warn('[receive] miss sync trigger failed', err instanceof Error ? err.message : err);
+ setPending(false);
+ });
+ };
+
+ return pending ? (
+ <Button disabled data-testid="share-receive-miss-sync-now">
+ <RefreshCw className="size-4 animate-spin" aria-hidden="true" />
+ <Trans>Syncing</Trans>
+ </Button>
+ ) : (
+ <Button onClick={handleSyncNow} data-testid="share-receive-miss-sync-now">
+ <RefreshCw className="size-4" aria-hidden="true" />
+ <Trans>Sync now</Trans>
+ </Button>
+ );
+}
+
/**
* Inner content for the miss surface — spinner while pending, else the icon +
* cause-specific message + escape actions. The OUTER container (with its
@@ -137,6 +215,7 @@ export function ShareReceiveMissContent({
onBrowseFolder,
onOpenRenamed,
onEnableAutoSync,
+ onSyncCompleted,
}: {
nav: PendingReceiveNav;
state: ShareTargetVerdictState;
@@ -144,8 +223,14 @@ export function ShareReceiveMissContent({
onOpenRenamed: (renamedTo: string) => void;
/** Called after a successful in-place Enable auto-sync (changed-locally cell) — the shell dismisses or navigates away. */
onEnableAutoSync?: () => void;
+ /** Called after a "Sync now" push lands (changed-locally cell) — the shell re-probes the verdict, which the push has changed. */
+ onSyncCompleted?: () => void;
}) {
const { t } = useLingui();
+ // Sync state feeds only the changed-locally cell (Enable auto-sync vs Sync
+ // now); for every other verdict it is read and unused. Null until the first
+ // status response — neither CTA renders on an unknown sync state.
+ const syncStatus = useGitSyncStatus();
const branch = nav.branch;
const targetNoun = nav.kind === 'folder' ? t`folder` : t`document`;
@@ -216,23 +301,57 @@ export function ShareReceiveMissContent({
// The target is still on origin and in the receiver's committed HEAD, but
// they removed/renamed it in their own working tree without syncing. This is
// NOT "behind — pull": pulling can't reconcile an uncommitted local change.
+ //
+ // The recovery CTA depends on the sync toggle: OFF gets the guarded Enable
+ // auto-sync flow; ON gets Sync now (pushing the local change, after which
+ // the re-probed verdict lands on the honest deleted/renamed cell). A
+ // degraded engine (denied push, active push error, non-actionable state)
+ // or an unknown sync state gets neither — Browse folder stays.
icon = <FilePen className="size-9" aria-hidden="true" />;
- message =
- branch === null ? (
- <Trans>
- This {targetNoun} has been moved, renamed, or deleted in your local copy. Please commit
- your changes or enable auto-sync.
- </Trans>
- ) : (
- <Trans>
- This {targetNoun} has been moved, renamed, or deleted in your local copy of branch{' '}
- <code className="rounded-sm bg-muted px-1 py-0.5 text-foreground/80">{branch}</code>.
- Please commit your changes or enable auto-sync.
- </Trans>
- );
+ const syncOn = syncStatus?.syncEnabled === true;
+ const pushDegraded =
+ syncStatus?.pushPermission?.checkStatus === 'denied' ||
+ Boolean(syncStatus?.pushError || syncStatus?.pushErrorCode);
+ if (syncOn) {
+ message =
+ branch === null ? (
+ <Trans>
+ This {targetNoun} has been moved, renamed, or deleted in your local copy, and that
+ change hasn't synced yet.
+ </Trans>
+ ) : (
+ <Trans>
+ This {targetNoun} has been moved, renamed, or deleted in your local copy of branch{' '}
+ <code className="rounded-sm bg-muted px-1 py-0.5 text-foreground/80">{branch}</code>,
+ and that change hasn't synced yet.
+ </Trans>
+ );
+ } else {
+ message =
+ branch === null ? (
+ <Trans>
+ This {targetNoun} has been moved, renamed, or deleted in your local copy. Please commit
+ your changes or enable auto-sync.
+ </Trans>
+ ) : (
+ <Trans>
+ This {targetNoun} has been moved, renamed, or deleted in your local copy of branch{' '}
+ <code className="rounded-sm bg-muted px-1 py-0.5 text-foreground/80">{branch}</code>.
+ Please commit your changes or enable auto-sync.
+ </Trans>
+ );
+ }
+ let syncAction: ReactNode = null;
+ if (syncStatus?.syncEnabled) {
+ if (syncNowActionable(syncStatus) && !pushDegraded) {
+ syncAction = <SyncNowButton status={syncStatus} onSyncCompleted={onSyncCompleted} />;
+ }
+ } else if (syncStatus !== null) {
+ syncAction = <EnableAutoSyncButton onEnabled={onEnableAutoSync} />;
+ }
actions = (
<>
- <EnableAutoSyncButton onEnabled={onEnableAutoSync} />
+ {syncAction}
{browseFolderButton}
</>
);
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index 334df77dc..ac1def4a7 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -1113,6 +1113,11 @@
"Rq1vFD": ["Tree view options"],
"RrAIZx": ["What config sharing covers"],
"Rx5ReQ": ["Rename ", ["keyName"]],
+ "RyIKxy": [
+ "This ",
+ ["targetNoun"],
+ " has been moved, renamed, or deleted in your local copy, and that change hasn't synced yet."
+ ],
"S33tz3": ["Not connected"],
"S6l5dv": ["Could not start creating a new item"],
"S9Vnum": ["Remove ", ["patternText"]],
@@ -1836,6 +1841,13 @@
"l3s5ri": ["Import"],
"l46MqT": ["Next tab"],
"l6OXqI": ["No installed agents found"],
+ "l6kpzR": [
+ "This ",
+ ["targetNoun"],
+ " has been moved, renamed, or deleted in your local copy of branch <0>",
+ ["branch"],
+ "</0>, and that change hasn't synced yet."
+ ],
"l8G3S9": ["Auto-sync is off — you don't have permission to push to this repo"],
"lAiyU_": ["Only the current document uses <0>#", ["tag"], "</0>."],
"lCC_D5": ["Subscribing..."],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 6712f7db4..7ff1663db 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -6502,6 +6502,7 @@ msgstr "Sync is failing. See the sync status for details."
msgid "Sync is off — your edits will not sync to the remote repository."
msgstr "Sync is off — your edits will not sync to the remote repository."
+#: src/components/share-receive-miss-content.tsx
#: src/components/ShareFreshnessWarning.tsx
#: src/components/SyncStatusBadge.tsx
msgid "Sync now"
@@ -6553,6 +6554,7 @@ msgstr "Synced"
msgid "Synced. The link is up to date."
msgstr "Synced. The link is up to date."
+#: src/components/share-receive-miss-content.tsx
#: src/components/ShareFreshnessWarning.tsx
msgid "Syncing"
msgstr "Syncing"
@@ -6797,10 +6799,18 @@ msgstr "Theme"
msgid "There's no project folder for this window, so a terminal can't start here."
msgstr "There's no project folder for this window, so a terminal can't start here."
+#: src/components/share-receive-miss-content.tsx
+msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy of branch <0>{branch}</0>, and that change hasn't synced yet."
+msgstr "This {targetNoun} has been moved, renamed, or deleted in your local copy of branch <0>{branch}</0>, and that change hasn't synced yet."
+
#: src/components/share-receive-miss-content.tsx
msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy of branch <0>{branch}</0>. Please commit your changes or enable auto-sync."
msgstr "This {targetNoun} has been moved, renamed, or deleted in your local copy of branch <0>{branch}</0>. Please commit your changes or enable auto-sync."
+#: src/components/share-receive-miss-content.tsx
+msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy, and that change hasn't synced yet."
+msgstr "This {targetNoun} has been moved, renamed, or deleted in your local copy, and that change hasn't synced yet."
+
#: src/components/share-receive-miss-content.tsx
msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy. Please commit your changes or enable auto-sync."
msgstr "This {targetNoun} has been moved, renamed, or deleted in your local copy. Please commit your changes or enable auto-sync."
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 64cf8f425..7be9f4e30 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -1113,6 +1113,11 @@
"Rq1vFD": ["Ţŕēē vĩēŵ ōƥţĩōńś"],
"RrAIZx": ["Ŵĥàţ ćōńƒĩĝ śĥàŕĩńĝ ćōvēŕś"],
"Rx5ReQ": ["Ŕēńàḿē ", ["keyName"]],
+ "RyIKxy": [
+ "Ţĥĩś ",
+ ["targetNoun"],
+ " ĥàś ƀēēń ḿōvēď, ŕēńàḿēď, ōŕ ďēĺēţēď ĩń ŷōũŕ ĺōćàĺ ćōƥŷ, àńď ţĥàţ ćĥàńĝē ĥàśń'ţ śŷńćēď ŷēţ."
+ ],
"S33tz3": ["Ńōţ ćōńńēćţēď"],
"S6l5dv": ["Ćōũĺď ńōţ śţàŕţ ćŕēàţĩńĝ à ńēŵ ĩţēḿ"],
"S9Vnum": ["Ŕēḿōvē ", ["patternText"]],
@@ -1836,6 +1841,13 @@
"l3s5ri": ["Ĩḿƥōŕţ"],
"l46MqT": ["Ńēxţ ţàƀ"],
"l6OXqI": ["Ńō ĩńśţàĺĺēď àĝēńţś ƒōũńď"],
+ "l6kpzR": [
+ "Ţĥĩś ",
+ ["targetNoun"],
+ " ĥàś ƀēēń ḿōvēď, ŕēńàḿēď, ōŕ ďēĺēţēď ĩń ŷōũŕ ĺōćàĺ ćōƥŷ ōƒ ƀŕàńćĥ <0>",
+ ["branch"],
+ "</0>, àńď ţĥàţ ćĥàńĝē ĥàśń'ţ śŷńćēď ŷēţ."
+ ],
"l8G3S9": ["Àũţō-śŷńć ĩś ōƒƒ — ŷōũ ďōń'ţ ĥàvē ƥēŕḿĩśśĩōń ţō ƥũśĥ ţō ţĥĩś ŕēƥō"],
"lAiyU_": ["Ōńĺŷ ţĥē ćũŕŕēńţ ďōćũḿēńţ ũśēś <0>#", ["tag"], "</0>."],
"lCC_D5": ["Śũƀśćŕĩƀĩńĝ..."],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 1ed2e1a2f..9eedaeab8 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -6497,6 +6497,7 @@ msgstr ""
msgid "Sync is off — your edits will not sync to the remote repository."
msgstr ""
+#: src/components/share-receive-miss-content.tsx
#: src/components/ShareFreshnessWarning.tsx
#: src/components/SyncStatusBadge.tsx
msgid "Sync now"
@@ -6548,6 +6549,7 @@ msgstr ""
msgid "Synced. The link is up to date."
msgstr ""
+#: src/components/share-receive-miss-content.tsx
#: src/components/ShareFreshnessWarning.tsx
msgid "Syncing"
msgstr ""
@@ -6792,10 +6794,18 @@ msgstr ""
msgid "There's no project folder for this window, so a terminal can't start here."
msgstr ""
+#: src/components/share-receive-miss-content.tsx
+msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy of branch <0>{branch}</0>, and that change hasn't synced yet."
+msgstr ""
+
#: src/components/share-receive-miss-content.tsx
msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy of branch <0>{branch}</0>. Please commit your changes or enable auto-sync."
msgstr ""
+#: src/components/share-receive-miss-content.tsx
+msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy, and that change hasn't synced yet."
+msgstr ""
+
#: src/components/share-receive-miss-content.tsx
msgid "This {targetNoun} has been moved, renamed, or deleted in your local copy. Please commit your changes or enable auto-sync."
msgstr ""
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index c014b1413..8f9d95287 100644
--- a/packages/core/src/bridge/bind-frontmatter-doc.ts
+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts
@@ -1,3 +1,4 @@
+
import type * as Y from 'yjs';
import type { Err, Ok, Result } from '../config/result.ts';
import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';
diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.ts
index 005627195..8bfdb40cd 100644
--- a/packages/core/src/bridge/bridge-invariant.ts
+++ b/packages/core/src/bridge/bridge-invariant.ts
@@ -1,3 +1,4 @@
+
import { fnv1aDigest } from './hash-util.ts';
export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 8890f6739..c18c086d5 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';
const LEADING_BOUNDARY_RE = /^(?:\r?\n)+/;
diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.ts
index b0a80fbd9..864bc7245 100644
--- a/packages/core/src/bridge/merge-three-way.ts
+++ b/packages/core/src/bridge/merge-three-way.ts
@@ -37,6 +37,7 @@ function mergeThreeWayImpl(baseline: string, userText: string, agentText: string
return parts.join('\n');
}
+
export type BridgeMergeContentLossSide = 'user' | 'agent';
export type BridgeMergeContentLossWhich = 'substring' | 'order';
diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.ts
index e67f33b40..592f0b956 100644
--- a/packages/core/src/bridge/normalize.ts
+++ b/packages/core/src/bridge/normalize.ts
@@ -1,3 +1,4 @@
+
const COMMONMARK_ESCAPE_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g;
const TABLE_ALIGN_ROW_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/;
diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.ts
index 83d47404a..a363dfd54 100644
--- a/packages/core/src/markdown/callout-transformer.ts
+++ b/packages/core/src/markdown/callout-transformer.ts
@@ -1,3 +1,4 @@
+
import type { Blockquote, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index 193e286b0..47f0d07e4 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/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.ts
index ece5c02a1..b6299a948 100644
--- a/packages/core/src/markdown/dedent-block-jsx-close.ts
+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts
@@ -1,3 +1,4 @@
+
import { findFencedRegions, isInsideFence } from './fence-regions.ts';
const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;
diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.ts
index 54774764a..acd398aa6 100644
--- a/packages/core/src/markdown/details-accordion-promoter.ts
+++ b/packages/core/src/markdown/details-accordion-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.ts
index c7518d614..fb5ac8e8a 100644
--- a/packages/core/src/markdown/fence-regions.ts
+++ b/packages/core/src/markdown/fence-regions.ts
@@ -1,3 +1,4 @@
+
const FENCE_RE = /^(`{3,}|~{3,})/gm;
export function findFencedRegions(src: string): Array<[number, number]> {
diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.ts
index 00f5771ee..6931623c7 100644
--- a/packages/core/src/markdown/fixtures/index.ts
+++ b/packages/core/src/markdown/fixtures/index.ts
@@ -1,3 +1,4 @@
+
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -8,6 +9,7 @@ function fixturePath(...segments: string[]): string {
return resolve(FIXTURES_DIR, ...segments);
}
+
interface GfmExample {
section: string;
markdown: string;
@@ -17,6 +19,7 @@ export function loadGfmExamples(): GfmExample[] {
return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];
}
+
interface MdxCrashEntry {
id: string;
input: string;
@@ -68,6 +71,7 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {
) as LargeEmbedFixture[];
}
+
export function loadPrd6955Before(): string {
return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');
}
@@ -76,6 +80,7 @@ export function loadPrd6955CorruptedTriplicated(): string {
return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');
}
+
export interface NgPinnedCase {
id: string;
name: string;
@@ -92,6 +97,7 @@ export function loadNgPinnedCases(): NgPinnedCase[] {
) as NgPinnedCase[];
}
+
export function loadLargeRealistic(): string {
return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');
}
diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.ts
index 8b1eb8519..daa3ef82b 100644
--- a/packages/core/src/markdown/fixtures/perf/generate.ts
+++ b/packages/core/src/markdown/fixtures/perf/generate.ts
@@ -1,3 +1,4 @@
+
import { writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -10,6 +11,7 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;
const SEED = 0xf1de1117;
+
function mulberry32(seed: number): () => number {
let a = seed >>> 0;
return () => {
@@ -36,6 +38,7 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {
return items[items.length - 1][0];
}
+
const WORDS = [
'lorem',
'ipsum',
@@ -153,6 +156,7 @@ function mdxBlock(rand: () => number): string {
return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;
}
+
type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';
const MIX: readonly [BlockKind, number][] = [
@@ -191,6 +195,7 @@ function generateDocument(blockCount: number, seed: number): string {
return `${blocks.join('\n\n')}\n`;
}
+
function main(): void {
for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {
const doc = generateDocument(count, SEED);
diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.ts
index 420dc0fe5..32c055c5b 100644
--- a/packages/core/src/markdown/guard-flanking-matrix.ts
+++ b/packages/core/src/markdown/guard-flanking-matrix.ts
@@ -7,6 +7,7 @@ import {
import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';
import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';
+
export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;
export type FlankClass = 'whitespace' | 'punctuation' | 'other';
diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.ts
index 2653473da..283913255 100644
--- a/packages/core/src/markdown/handler-shadow-audit.ts
+++ b/packages/core/src/markdown/handler-shadow-audit.ts
@@ -1,3 +1,4 @@
+
export interface HandlerShadowWitness {
input: string;
expect: 'byte' | 'byte-and-reparse-type';
diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.ts
index f758cf737..7a22e8016 100644
--- a/packages/core/src/markdown/highlight-promoter.ts
+++ b/packages/core/src/markdown/highlight-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';
import type { MdxJsxTextElement } from 'mdast-util-mdx';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.ts
index 78fdfeb02..2f082e6d0 100644
--- a/packages/core/src/markdown/html-to-mdast.ts
+++ b/packages/core/src/markdown/html-to-mdast.ts
@@ -1,3 +1,4 @@
+
import type { Root as HastRoot } from 'hast';
import type { Root as MdastRoot } from 'mdast';
import rehypeParse from 'rehype-parse';
@@ -75,7 +76,8 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRo
throw new HtmlPayloadTooLargeError(html.length, maxBytes);
}
- const processor = unified().use(rehypeParse, { fragment: true });
+ const processor = unified()
+ .use(rehypeParse, { fragment: true });
for (const plugin of cleanupPlugins) {
processor.use(plugin);
diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.ts
index 706fa9afb..994eb6917 100644
--- a/packages/core/src/markdown/image-promoter.ts
+++ b/packages/core/src/markdown/image-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Image, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.ts
index 58a810193..064fa0773 100644
--- a/packages/core/src/markdown/index.ts
+++ b/packages/core/src/markdown/index.ts
@@ -1,3 +1,4 @@
+
import {
type FromProseMirrorOptions,
fromPmMark,
@@ -164,6 +165,7 @@ export class MarkdownManager {
}
}
+
const registry = createRegistry();
function destructureAttrs(
@@ -212,6 +214,7 @@ function destructureAttrs(
return result;
}
+
function hasDirtyDescendant(node: PmNode): boolean {
let found = false;
node.descendants((child) => {
@@ -230,6 +233,7 @@ function effectiveDirty(node: PmNode): boolean {
return node.attrs.sourceDirty || hasDirtyDescendant(node);
}
+
function isEmptyMdastParagraph(node: MdastNodes): boolean {
if (node.type !== 'paragraph') return false;
const children = node.children ?? [];
@@ -298,6 +302,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {
return out;
}
+
import {
AUDIO_EXTENSIONS,
FILE_ATTACHMENT_EXTENSIONS,
@@ -547,6 +552,7 @@ function buildMdastToPmHandlers(
}));
}
+
if (m.emphasis) {
handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({
sourceDelimiter: node.data?.sourceDelimiter ?? '*',
@@ -626,6 +632,7 @@ function buildMdastToPmHandlers(
}));
}
+
if (m.link) {
const sourceLiteralMark = m.sourceLiteral;
handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {
@@ -904,6 +911,7 @@ function buildMdastToPmHandlers(
};
}
+
const blockUnknownHandler = (node: {
type: string;
position?: { start: { offset: number }; end: { offset: number } };
@@ -1029,6 +1037,7 @@ function buildMdastToPmHandlers(
return handlers as RemarkProseMirrorOptions['handlers'];
}
+
function buildPmToMdastHandlers(schema: Schema): {
nodeHandlers: FromProseMirrorOptions<string, string>['nodeHandlers'];
markHandlers: FromProseMirrorOptions<string, string>['markHandlers'];
diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.ts
index a5b511f25..bd79424c7 100644
--- a/packages/core/src/markdown/math-promoter.ts
+++ b/packages/core/src/markdown/math-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Code, Root } from 'mdast';
import type { Math as MdastMath } from 'mdast-util-math';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.ts
index 679c72ef7..f84967798 100644
--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts
+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts
@@ -1,3 +1,4 @@
+
import type { Comment, Element, ElementContent, Properties } from 'hast';
import type { FootnoteDefinition, FootnoteReference } from 'mdast';
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.ts
index 79072375c..153fdc1d8 100644
--- a/packages/core/src/markdown/mdast-to-html.ts
+++ b/packages/core/src/markdown/mdast-to-html.ts
@@ -1,3 +1,4 @@
+
import type { Element, Root as HastRoot } from 'hast';
import type { Root as MdastRoot } from 'mdast';
import { normalizeUri } from 'micromark-util-sanitize-uri';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index 35d74b85e..a58f8c720 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/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.ts
index 1a897fca8..17ed2b829 100644
--- a/packages/core/src/markdown/mermaid-promoter.ts
+++ b/packages/core/src/markdown/mermaid-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Code, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.ts
index 9864b3b60..7e4a9a48b 100644
--- a/packages/core/src/markdown/parse-with-fallback.ts
+++ b/packages/core/src/markdown/parse-with-fallback.ts
@@ -168,6 +168,7 @@ export function parseRecursive(
}
}
+
interface VFilePlace {
offset?: number;
start?: { offset?: number };
@@ -186,6 +187,7 @@ function extractErrorOffset(err: unknown): number | undefined {
return undefined;
}
+
interface Region {
start: number;
end: number;
@@ -209,6 +211,7 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {
return null;
}
+
export interface TagEvent {
kind: 'open' | 'close' | 'self-close';
name: string;
@@ -355,6 +358,7 @@ function findFallbackRegion(src: string, errorOffset: number): Region {
return { start: blockStart, end: blockEnd };
}
+
interface SourceBlock {
src: string;
start: number;
@@ -452,6 +456,7 @@ function tryPerBlockFallback(
};
}
+
function wholeDocRawText(source: string): JSONContent {
return {
type: 'doc',
diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.ts
index e6ab4fd57..43d420187 100644
--- a/packages/core/src/markdown/parser-drop-closure.ts
+++ b/packages/core/src/markdown/parser-drop-closure.ts
@@ -1,3 +1,4 @@
+
export type DroppedTokenAdjudication =
| {
kind: 'format-dof-axis';
diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.ts
index 5d6db7aa8..5b9550e90 100644
--- a/packages/core/src/markdown/pipeline.ts
+++ b/packages/core/src/markdown/pipeline.ts
@@ -1,3 +1,4 @@
+
import {
type FromProseMirrorOptions,
fromProseMirror,
diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.ts
index 248685cfe..4ac5731e7 100644
--- a/packages/core/src/markdown/position-aware-join.ts
+++ b/packages/core/src/markdown/position-aware-join.ts
@@ -1,3 +1,4 @@
+
import type { Join } from 'mdast-util-to-markdown';
import type { Position } from 'unist';
diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.ts
index 50a193a16..240be90e6 100644
--- a/packages/core/src/markdown/position-slice.ts
+++ b/packages/core/src/markdown/position-slice.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Root } from 'mdast';
import { visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
@@ -466,7 +467,8 @@ export function applyPositionSliceToNode(
const first = source[startOff];
if (first !== '[' && first !== '<' && !node.title) {
node.data.sourceStyle = 'gfm-autolink';
- } else if (first === '[') {
+ }
+ else if (first === '[') {
const slice = source.slice(startOff, endOff);
const closeBracketIdx = slice.lastIndexOf('](');
if (closeBracketIdx !== -1) {
diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
index db10fa54b..ca225ce9b 100644
--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
@@ -1,3 +1,4 @@
+
import type { Comment, Element, Root, Text } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
index 34068d103..3a2524a9a 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
@@ -1,3 +1,4 @@
+
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
index 93151d43b..2279a0189 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
@@ -1,3 +1,4 @@
+
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
index 188f02d83..a0f467c42 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
@@ -1,3 +1,4 @@
+
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
index 4ba2c3418..4e8542a21 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
@@ -1,3 +1,4 @@
+
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
index 1a74b1272..a3c96b24a 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
@@ -1,3 +1,4 @@
+
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
index de35e7b79..e95cf43d6 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
@@ -1,3 +1,4 @@
+
import type { Comment, Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
index b4be1b2ea..ffdb4d5b5 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
@@ -1,3 +1,4 @@
+
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
index 3c8d88b7c..e2a96d1a7 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
@@ -1,3 +1,4 @@
+
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.ts
index cf2c9da8e..0389575ac 100644
--- a/packages/core/src/markdown/resolve-image-url.ts
+++ b/packages/core/src/markdown/resolve-image-url.ts
@@ -1,3 +1,4 @@
+
import { isRelativeUrl } from './safe-url.ts';
function isDevDiagnosticContext(): boolean {
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 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/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.ts
index 46cc6a074..542204403 100644
--- a/packages/core/src/markdown/serialize-helpers.ts
+++ b/packages/core/src/markdown/serialize-helpers.ts
@@ -1,3 +1,4 @@
+
import type { Node as PmNode } from '@tiptap/pm/model';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { PropDef, SerializeContext } from '../registry/types.ts';
diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.ts
index be97d4d62..fe73659e6 100644
--- a/packages/core/src/markdown/single-dollar-math-promoter.ts
+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts
@@ -1,3 +1,4 @@
+
import type { PhrasingContent, Root, Text } from 'mdast';
import type { InlineMath } from 'mdast-util-math';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.ts
index 1a2fb5d50..e1161455b 100644
--- a/packages/core/src/markdown/to-markdown-handlers.ts
+++ b/packages/core/src/markdown/to-markdown-handlers.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Parents } from 'mdast';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { Handle, Info, State } from 'mdast-util-to-markdown';
diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.ts
index cd245c38c..c5bfd2386 100644
--- a/packages/core/src/markdown/unknown-mdast-guard.ts
+++ b/packages/core/src/markdown/unknown-mdast-guard.ts
@@ -1,3 +1,4 @@
+
import type { Root as MdastRoot } from 'mdast';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.ts
index a100cad76..1b75ba564 100644
--- a/packages/core/src/markdown/whitespace-char-ref.ts
+++ b/packages/core/src/markdown/whitespace-char-ref.ts
@@ -1,3 +1,4 @@
+
const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([
[0x20, ' '],
[0x09, '\t'],
diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.ts
index 6dad26200..afd9936fe 100644
--- a/packages/core/src/markdown/wiki-link-micromark.ts
+++ b/packages/core/src/markdown/wiki-link-micromark.ts
@@ -17,6 +17,7 @@ declare module 'micromark-util-types' {
}
}
+
const CODE_BANG = 33; // !
const CODE_LBRACKET = 91; // [
const CODE_RBRACKET = 93; // ]
@@ -260,6 +261,7 @@ export function wikiLinkSyntax(): Extension {
};
}
+
function enterWikiLink(this: CompileContext, token: Token) {
this.enter(
{
@@ -385,6 +387,7 @@ export const wikiLinkToMarkdown: {
unsafe: [{ character: '[', inConstruct: ['phrasing'] }],
};
+
const MICROMARK_EXT = wikiLinkSyntax();
export function remarkWikiLink(this: Processor) {