Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
PRD-7636 Preserve settings during permission prompts (#3059)
mike-inkeep78c73e2fabd2
diff --git a/.changeset/preserve-overlays-during-follow.md b/.changeset/preserve-overlays-during-follow.mdnew file mode 100644index 000000000..588e1e904--- /dev/null+++ b/.changeset/preserve-overlays-during-follow.md@@ -0,0 +1,7 @@+---+'@inkeep/open-knowledge': patch+---++Keep dialogs and menus open while following an agent's file edits.++Follow-the-agent no longer navigates away from a settings dialog or menu that you opened. Following resumes on a later agent update after you dismiss the overlay.diff --git a/packages/app/src/components/acp/ThreadView.dom.test.tsx b/packages/app/src/components/acp/ThreadView.dom.test.tsxindex 6f71d4a03..cc078a49d 100644--- a/packages/app/src/components/acp/ThreadView.dom.test.tsx+++ b/packages/app/src/components/acp/ThreadView.dom.test.tsx@@ -11,6 +11,7 @@ import {} from '@testing-library/react';import userEvent from '@testing-library/user-event';import { afterEach, describe, expect, test, vi } from 'vitest';+import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@/components/ui/dialog';import { TooltipProvider } from '@/components/ui/tooltip';import { MAX_TOTAL_ATTACHMENT_BYTES } from '@/lib/acp/image-attachment';import type {@@ -184,6 +185,7 @@ afterEach(() => {authenticateResult = Promise.resolve();model = null;threadState = { info: undefined, events: [], lastSeq: 5, replayThroughSeq: 5 };+ window.location.hash = '';});describe('ThreadView agent settings', () => {@@ -666,6 +668,58 @@ describe('ThreadView inline diff', () => {});describe('ThreadView permissions', () => {+ test('moves focus from the composer to the primary permission when no overlay is open', () => {+ model = makeModel();+ const runningInfo = makeInfo({ status: 'running' });+ const awaitingInfo = makeInfo({ status: 'awaiting_permission' });+ const { rerender } = render(<ThreadView info={runningInfo} />);+ screen.getByTestId('agent-thread-composer').focus();++ model = makeModel({ items: [permission()] });+ rerender(<ThreadView info={awaitingInfo} />);++ expect(document.activeElement).toBe(screen.getByTestId('agent-thread-permission-allow'));+ });++ test('defers follow-the-agent navigation until settings closes', () => {+ model = makeModel();+ window.location.hash = '#settings';+ let dialogOpen = true;+ const view = () => (+ <>+ {dialogOpen ? (+ <Dialog open>+ <DialogContent>+ <DialogTitle>Settings</DialogTitle>+ <DialogDescription>Project preferences</DialogDescription>+ </DialogContent>+ </Dialog>+ ) : null}+ <ThreadView info={makeInfo({ status: 'awaiting_permission' })} />+ </>+ );+ const { rerender } = render(view());+ screen.getByRole('dialog');++ model = makeModel({+ items: [+ toolCall({ toolKind: 'edit', rawInput: { docName: 'notes/today' } }),+ permission({ toolCallId: 'c1' }),+ ],+ });+ threadState = { info: undefined, events: [], lastSeq: 6, replayThroughSeq: 6 };+ rerender(view());++ screen.getByTestId('agent-thread-permission');+ expect(window.location.hash).toBe('#settings');++ dialogOpen = false;+ threadState = { info: undefined, events: [], lastSeq: 7, replayThroughSeq: 7 };+ rerender(view());++ expect(window.location.hash).toBe('#/notes/today');+ });+test('stacks three-plus options top-to-bottom with the primary grant emphasized', () => {model = makeModel({items: [diff --git a/packages/app/src/components/acp/ThreadView.tsx b/packages/app/src/components/acp/ThreadView.tsxindex 9b1b741c3..c82874158 100644--- a/packages/app/src/components/acp/ThreadView.tsx+++ b/packages/app/src/components/acp/ThreadView.tsx@@ -143,6 +143,7 @@ import {import { describeToolCall, type ToolCallGlyph } from '@/lib/acp/tool-call-display';import { docNameFromHash, hashFromDocName } from '@/lib/doc-hash';import { dispatchExternalLinkClick } from '@/lib/external-link';+import { isOverlayLayerOpen } from '@/lib/overlay-layers';import { useWorkspace } from '@/lib/use-workspace';import { cn } from '@/lib/utils';import { AgentMarkdown } from './AgentMarkdown';@@ -531,6 +532,7 @@ export function ThreadView({if (initialSeqRef.current === null || lastSeq === null || lastSeq <= initialSeqRef.current) {return;}+ if (isOverlayLayerOpen()) return;const currentDoc = docNameFromHash(window.location.hash);const decision = decideFollowNavigation(followTarget, currentDoc, followNavRef.current);followNavRef.current = decision.state;