Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Restore outline state after a document leaves its path (#6169)

Nick Gomeza7349f3b5107
diff --git a/.changeset/fast-falcons-flow.md b/.changeset/fast-falcons-flow.md
new file mode 100644
index 000000000..1f191f3a5
--- /dev/null
+++ b/.changeset/fast-falcons-flow.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Clear stale outline headings and show the moved-page message when a document leaves its previous path.
diff --git a/packages/app/src/components/OutlinePanel.tsx b/packages/app/src/components/OutlinePanel.tsx
index 0dd58344c..f5056688e 100644
--- a/packages/app/src/components/OutlinePanel.tsx
+++ b/packages/app/src/components/OutlinePanel.tsx
@@ -9,7 +9,7 @@ import type { HeadingEntry } from '@inkeep/open-knowledge-core/utils/slug';
import { t } from '@lingui/core/macro';
import { Trans, useLingui } from '@lingui/react/macro';
import { useQuery, useQueryClient } from '@tanstack/react-query';
-import { useEffect } from 'react';
+import { useEffect, useSyncExternalStore } from 'react';
import { usePageList } from '@/components/PageListContext';
import { isKnownPageDocName } from '@/components/page-membership';
import {
@@ -110,8 +110,12 @@ function OutlinePanelInner({
const queryClient = useQueryClient();
const { activeProvider, activeDocName } = useDocumentContext();
const isKnownPage = isKnownPageDocName(pages, docName);
- const hadResult = queryClient.getQueryState(['page-headings', docName]) !== undefined;
- const isUnresolvable = !loading && pageListError === null && !isKnownPage && hadResult;
+ const queryCache = queryClient.getQueryCache();
+ const hasHeadingsQuery = useSyncExternalStore(
+ queryCache.subscribe,
+ () => queryClient.getQueryState(['page-headings', docName]) !== undefined,
+ );
+ const isUnresolvable = !loading && pageListError === null && !isKnownPage && hasHeadingsQuery;
const {
data: headings = [],
isLoading,
diff --git a/packages/app/tests/foundation/outline-panel.browser.test.tsx b/packages/app/tests/foundation/outline-panel.browser.test.tsx
index c45945662..2e8dcf70d 100644
--- a/packages/app/tests/foundation/outline-panel.browser.test.tsx
+++ b/packages/app/tests/foundation/outline-panel.browser.test.tsx
@@ -5,7 +5,6 @@ import { OutlinePanel } from '@/components/OutlinePanel';
import { PageListProvider } from '@/components/PageListContext';
import { __resetPageListCacheForTests, getPageListCache } from '@/editor/page-list-cache';
import { emitDocumentsChanged } from '@/lib/documents-events';
-import { expectKnownBug } from '../../../../test-support/known-bug.vitest.test-helper';
import { stubApiRoutes } from './api-routes.test-helper';
import { renderWithI18n } from './render-with-i18n.test-helper';
@@ -76,14 +75,7 @@ describe('OutlinePanel under the production compiler', () => {
expect(headingCount(view)).toBe('3');
});
- test('a document that leaves the page list after a successful load stops serving its headings and says it moved', {
- tags: ['known-bug'],
- meta: {
- issue: 'https://github.com/inkeep/agents-private/issues/5611',
- owner: 'get-main-green',
- until: '2026-12-31',
- },
- }, async () => {
+ test('a document that leaves the page list after a successful load stops serving its headings and says it moved', async () => {
const view = renderOutline();
await view.findByRole('button', { name: 'Liveblocks' });
@@ -96,14 +88,9 @@ describe('OutlinePanel under the production compiler', () => {
{ timeout: 5_000 },
);
- await expectKnownBug(/expected undefined to be 'This page is no longer at this path\.'/, () => {
- expect(view.queryByRole('status')?.textContent).toBe('This page is no longer at this path.');
- });
- await expectKnownBug(
- /expected \[ 'Liveblocks', 'What is it', …\(1\) \] to deeply equal \[\]/,
- () => {
- expect(outlineHeadings(view)).toEqual([]);
- },
- );
+ expect
+ .soft(view.queryByRole('status')?.textContent)
+ .toBe('This page is no longer at this path.');
+ expect.soft(outlineHeadings(view)).toEqual([]);
});
});