Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): keep conflict controls visible below the Ask AI composer (#2399)

miles-kt-inkeepc0f1ea1d141e
diff --git a/.changeset/conflict-controls-under-ask-ai.md b/.changeset/conflict-controls-under-ask-ai.md
new file mode 100644
index 000000000..c412e8fc6
--- /dev/null
+++ b/.changeset/conflict-controls-under-ask-ai.md
@@ -0,0 +1,11 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Fix the merge-conflict controls (Exit merge / Undo / Save resolution) being
+covered by the floating Ask AI composer, which made conflicts impossible to
+confirm without first collapsing the composer. The conflict footer now
+publishes its height and the composer anchors above it, so the controls stay
+visible and clickable with Ask AI stacked on top of them. The conflict diff
+also reserves scroll room under the composer, so the last hunks' Accept and
+Reject buttons can always scroll clear.
diff --git a/packages/app/src/components/BottomComposer.dom.test.tsx b/packages/app/src/components/BottomComposer.dom.test.tsx
index 25668e8df..4a3e12dfa 100644
--- a/packages/app/src/components/BottomComposer.dom.test.tsx
+++ b/packages/app/src/components/BottomComposer.dom.test.tsx
@@ -997,6 +997,16 @@ describe('BottomComposer (dismiss / reopen)', () => {
});
});
+describe('BottomComposer (conflict footer stacking)', () => {
+ test('the wrapper anchors its bottom to --conflict-footer-height, not a hard bottom-0', async () => {
+ await renderComposer('notes');
+
+ const wrapper = screen.getByTestId('bottom-composer');
+ expect(wrapper.className).toContain('bottom-[var(--conflict-footer-height,0px)]');
+ expect(wrapper.className).not.toMatch(/(?:^|\s)bottom-0(?:\s|$)/);
+ });
+});
+
describe('BottomComposer (failure + defensive guards)', () => {
test('an unsuccessful ({ok:false}) dispatch still clears the field and adds no bespoke toast', async () => {
dispatchImpl = () => Promise.resolve({ ok: false });
diff --git a/packages/app/src/components/BottomComposer.tsx b/packages/app/src/components/BottomComposer.tsx
index 87695623c..892036646 100644
--- a/packages/app/src/components/BottomComposer.tsx
+++ b/packages/app/src/components/BottomComposer.tsx
@@ -610,7 +610,7 @@ export function BottomComposer({
return (
<div
- className="pointer-events-none absolute inset-x-0 bottom-0 z-20 editor-content-aligned bg-gradient-to-t from-background from-65% via-background to-transparent pt-10 pb-2"
+ className="pointer-events-none absolute inset-x-0 bottom-[var(--conflict-footer-height,0px)] z-20 editor-content-aligned bg-gradient-to-t from-background from-65% via-background to-transparent pt-10 pb-2"
data-testid="bottom-composer"
>
{card}
diff --git a/packages/app/src/components/DiffView.dom.test.tsx b/packages/app/src/components/DiffView.dom.test.tsx
index 8e7ec2b96..ff4c0fe99 100644
--- a/packages/app/src/components/DiffView.dom.test.tsx
+++ b/packages/app/src/components/DiffView.dom.test.tsx
@@ -71,3 +71,32 @@ describe('DiffView oursOverride (FR3)', () => {
await screen.findByText('All hunks resolved');
});
});
+
+describe('DiffView conflict footer height contract', () => {
+ afterEach(() => {
+ cleanup();
+ });
+
+ test('conflictMode publishes --conflict-footer-height on the document root while mounted', () => {
+ const { unmount } = render(
+ <DiffView
+ oldContent="# Base\ntheirs\n"
+ newContent="# Base\nours\n"
+ layout="unified"
+ conflictMode
+ />,
+ );
+
+ const value = document.documentElement.style.getPropertyValue('--conflict-footer-height');
+ expect(value).toBe('0px');
+
+ unmount();
+ expect(document.documentElement.style.getPropertyValue('--conflict-footer-height')).toBe('');
+ });
+
+ test('non-conflict renders never publish --conflict-footer-height', () => {
+ render(<DiffView oldContent="# Base\ntheirs\n" newContent="# Base\nours\n" layout="unified" />);
+
+ expect(document.documentElement.style.getPropertyValue('--conflict-footer-height')).toBe('');
+ });
+});
diff --git a/packages/app/src/components/DiffView.tsx b/packages/app/src/components/DiffView.tsx
index 324dd38b3..6b09a2ff4 100644
--- a/packages/app/src/components/DiffView.tsx
+++ b/packages/app/src/components/DiffView.tsx
@@ -10,6 +10,7 @@ import { basicSetup } from 'codemirror';
import { useTheme } from 'next-themes';
import { useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
+import { useConflictFooterHeightVar } from '@/hooks/use-conflict-footer-height';
import { Button } from './ui/button';
const darkTheme = basicDarkInit({
@@ -105,6 +106,7 @@ export function DiffView({
const onAbortRef = useRef(onAbort);
const [chunksRemaining, setChunksRemaining] = useState<number | null>(null);
const [mergeControls, setMergeControls] = useState<MergeControlPortal[]>([]);
+ const conflictFooterRef = useConflictFooterHeightVar(conflictMode === true);
useEffect(() => {
onResolveRef.current = onResolve;
onAbortRef.current = onAbort;
@@ -269,7 +271,10 @@ export function DiffView({
),
)}
{conflictMode && (
- <div className="flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0">
+ <div
+ ref={conflictFooterRef}
+ className="flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0"
+ >
<span
className={`text-xs ${allResolved ? 'text-emerald-600 dark:text-emerald-400' : 'text-muted-foreground'}`}
>
diff --git a/packages/app/src/components/DiffViewBoundary.dom.test.tsx b/packages/app/src/components/DiffViewBoundary.dom.test.tsx
index 7cdc0894b..c25c27b86 100644
--- a/packages/app/src/components/DiffViewBoundary.dom.test.tsx
+++ b/packages/app/src/components/DiffViewBoundary.dom.test.tsx
@@ -403,6 +403,28 @@ describe('DiffViewBoundary (Tier-3 mount)', () => {
expect(screen.queryByRole('button', { name: /accept their deletion/i })).toBeNull();
});
+ test('delete-modify publishes --conflict-footer-height while mounted, removes on unmount', async () => {
+ globalThis.fetch = strategyFetch('delete-modify') as typeof fetch;
+ const { unmount } = render(<DiffViewBoundary docName="foo" provider={makeProvider('x\n')} />);
+
+ await screen.findByRole('button', { name: /keep file deleted/i });
+ expect(document.documentElement.style.getPropertyValue('--conflict-footer-height')).toBe('0px');
+
+ unmount();
+ expect(document.documentElement.style.getPropertyValue('--conflict-footer-height')).toBe('');
+ });
+
+ test('modify-delete publishes --conflict-footer-height while mounted, removes on unmount', async () => {
+ globalThis.fetch = strategyFetch('modify-delete') as typeof fetch;
+ const { unmount } = render(<DiffViewBoundary docName="foo" provider={makeProvider('x\n')} />);
+
+ await screen.findByRole('button', { name: /accept their deletion/i });
+ expect(document.documentElement.style.getPropertyValue('--conflict-footer-height')).toBe('0px');
+
+ unmount();
+ expect(document.documentElement.style.getPropertyValue('--conflict-footer-height')).toBe('');
+ });
+
test('delete-modify: "Keep deletion" dispatches strategy: delete', async () => {
globalThis.fetch = strategyFetch('delete-modify') as typeof fetch;
render(<DiffViewBoundary docName="foo" provider={makeProvider('x\n')} />);
diff --git a/packages/app/src/components/DiffViewBoundary.tsx b/packages/app/src/components/DiffViewBoundary.tsx
index 5a95e4ca5..d7ebc3a22 100644
--- a/packages/app/src/components/DiffViewBoundary.tsx
+++ b/packages/app/src/components/DiffViewBoundary.tsx
@@ -3,6 +3,7 @@ import { Trans, useLingui } from '@lingui/react/macro';
import { useEffect, useState } from 'react';
import { toast } from 'sonner';
import { Button } from '@/components/ui/button';
+import { useConflictFooterHeightVar } from '@/hooks/use-conflict-footer-height';
import { useConflicts } from '@/hooks/use-conflicts';
import { filePathToDocName } from '@/lib/doc-hash';
import { DiffView } from './DiffView';
@@ -92,6 +93,9 @@ export function DiffViewBoundary({ docName }: DiffViewBoundaryProps) {
const [sides, setSides] = useState<ConflictSides | null>(null);
const [fetchFailed, setFetchFailed] = useState(false);
const [isResolving, setIsResolving] = useState(false);
+ const duUdFooterRef = useConflictFooterHeightVar(
+ sides?.kind === 'delete-modify' || sides?.kind === 'modify-delete',
+ );
useEffect(() => {
console.warn(JSON.stringify({ event: 'editor-area-swap-to-diffview', 'doc.name': docName }));
@@ -163,7 +167,10 @@ export function DiffViewBoundary({ docName }: DiffViewBoundaryProps) {
<div className="min-h-0 flex-1">
<DiffView oldContent="" newContent={sides.theirs} layout="unified" previewMode />
</div>
- <div className="flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4">
+ <div
+ ref={duUdFooterRef}
+ className="flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4"
+ >
<p className="text-sm text-muted-foreground">
<Trans>
You deleted <span className="font-medium text-foreground">{filePath}</span> locally,
@@ -204,7 +211,10 @@ export function DiffViewBoundary({ docName }: DiffViewBoundaryProps) {
<div className="min-h-0 flex-1">
<DiffView oldContent="" newContent={sides.ours} layout="unified" previewMode />
</div>
- <div className="flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4">
+ <div
+ ref={duUdFooterRef}
+ className="flex flex-shrink-0 flex-wrap items-center justify-between gap-x-6 gap-y-3 border-t px-6 py-4"
+ >
<p className="text-sm text-muted-foreground">
<Trans>
You modified <span className="font-medium text-foreground">{filePath}</span> locally,
diff --git a/packages/app/src/globals.css b/packages/app/src/globals.css
index a91e88605..8e4e74244 100644
--- a/packages/app/src/globals.css
+++ b/packages/app/src/globals.css
@@ -818,18 +818,33 @@
padding-bottom: var(--ask-composer-height, 0px);
}
+/* Conflict-mode DiffView scroller: same composer inset so the last hunks (and
+ their inline Accept/Reject controls) can scroll clear of the floating
+ composer. The content-side padding rule lives next to the
+ `.source-editor .cm-content` restore rule AFTER the `.cm-editor .cm-content`
+ padding reset (equal specificity — source order decides; see the comment
+ there). The conflict footer itself needs no inset — the composer anchors
+ above it via `--conflict-footer-height` (see use-conflict-footer-height.ts). */
+.diff-view {
+ scroll-padding-bottom: var(--ask-composer-height, 0px);
+}
+
/* Ease the inset + composer entrance so collapsing/expanding glides instead of a
hard jump cut. The per-frame scroll re-clamp in BottomComposer keeps the bottom
- pinned while the padding transition plays. Reduced-motion users get the instant
- change. */
+ pinned while the padding transition plays. `bottom` is included because the
+ composer's anchor tracks `--conflict-footer-height`, which flips between 0 and
+ the conflict footer's height when conflict mode mounts/unmounts. Reduced-motion
+ users get the instant change. */
@media (prefers-reduced-motion: no-preference) {
- .editor-doc-scroll :is(.ProseMirror, .cm-content) {
+ .editor-doc-scroll :is(.ProseMirror, .cm-content),
+ .diff-view .cm-content {
transition: padding-bottom 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
[data-testid="bottom-composer"] {
transition:
opacity 200ms ease,
- transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
+ transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
+ bottom 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
@starting-style {
[data-testid="bottom-composer"] {
@@ -2081,14 +2096,15 @@
padding: 0;
}
-/* Restore the floating Ask AI composer's bottom inset for full-page source mode.
- The `padding: 0` reset above ties on specificity with the shared
- `.editor-doc-scroll :is(.ProseMirror, .cm-content)` inset rule and, being later,
- zeroes it — so source mode's last lines sit under the composer while WYSIWYG
- clears. Scoped to `.source-editor` (not `.cm-editor`) so nested code-block CM
- inside the WYSIWYG body is never padded; declared after the reset so it wins the
- tie. */
-.source-editor .cm-content {
+/* Restore the floating Ask AI composer's bottom inset for full-page source mode
+ and the conflict-mode diff view. The `padding: 0` reset above ties on
+ specificity with the shared `.editor-doc-scroll :is(.ProseMirror, .cm-content)`
+ inset rule and, being later, zeroes it — so those surfaces' last lines would
+ sit under the composer while WYSIWYG clears. Scoped to `.source-editor` /
+ `.diff-view` (not `.cm-editor`) so nested code-block CM inside the WYSIWYG
+ body is never padded; declared after the reset so it wins the tie. */
+.source-editor .cm-content,
+.diff-view .cm-content {
padding-bottom: var(--ask-composer-height, 0px);
}
diff --git a/packages/app/src/hooks/use-conflict-footer-height.dom.test.tsx b/packages/app/src/hooks/use-conflict-footer-height.dom.test.tsx
new file mode 100644
index 000000000..bd797114f
--- /dev/null
+++ b/packages/app/src/hooks/use-conflict-footer-height.dom.test.tsx
@@ -0,0 +1,38 @@
+import { afterEach, describe, expect, test } from 'bun:test';
+import { cleanup, render } from '@testing-library/react';
+import { useConflictFooterHeightVar } from './use-conflict-footer-height';
+
+function Footer({ enabled = true }: { enabled?: boolean }) {
+ const ref = useConflictFooterHeightVar(enabled);
+ return <div ref={ref} />;
+}
+
+function getVar() {
+ return document.documentElement.style.getPropertyValue('--conflict-footer-height');
+}
+
+describe('useConflictFooterHeightVar ownership', () => {
+ afterEach(() => {
+ cleanup();
+ document.documentElement.style.removeProperty('--conflict-footer-height');
+ });
+
+ test('publishes while enabled and removes on unmount', () => {
+ const { unmount } = render(<Footer />);
+ expect(getVar()).toBe('0px'); // jsdom: offsetHeight=0
+ unmount();
+ expect(getVar()).toBe('');
+ });
+
+ test('a stale instance unmounting after a newer publisher does not clear the var', () => {
+ const first = render(<Footer />);
+ render(<Footer />);
+ first.unmount();
+ expect(getVar()).toBe('0px');
+ });
+
+ test('disabled instances neither publish nor claim ownership', () => {
+ render(<Footer enabled={false} />);
+ expect(getVar()).toBe('');
+ });
+});
diff --git a/packages/app/src/hooks/use-conflict-footer-height.ts b/packages/app/src/hooks/use-conflict-footer-height.ts
new file mode 100644
index 000000000..e09e6c422
--- /dev/null
+++ b/packages/app/src/hooks/use-conflict-footer-height.ts
@@ -0,0 +1,36 @@
+import { useEffect, useRef } from 'react';
+
+let activePublisher: object | null = null;
+
+export function useConflictFooterHeightVar(enabled: boolean) {
+ const footerRef = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => {
+ if (!enabled) return;
+ const footer = footerRef.current;
+ if (!footer) return;
+ const token = {};
+ activePublisher = token;
+ const root = document.documentElement;
+ let last: string | null = null;
+ const apply = () => {
+ if (activePublisher !== token) return;
+ const next = `${footer.offsetHeight}px`;
+ if (next === last) return;
+ last = next;
+ root.style.setProperty('--conflict-footer-height', next);
+ };
+ apply();
+ const observer = new ResizeObserver(apply);
+ observer.observe(footer);
+ return () => {
+ observer.disconnect();
+ if (activePublisher === token) {
+ activePublisher = null;
+ root.style.removeProperty('--conflict-footer-height');
+ }
+ };
+ }, [enabled]);
+
+ return footerRef;
+}