Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): show frontmatter in read-only skill viewer (#2676)

Andrew Mikofalvy0c3186f41876
diff --git a/.changeset/readonly-skill-frontmatter-viewer.md b/.changeset/readonly-skill-frontmatter-viewer.md
new file mode 100644
index 000000000..6d6d8bdda
--- /dev/null
+++ b/.changeset/readonly-skill-frontmatter-viewer.md
@@ -0,0 +1,10 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Show a read-only Properties panel when viewing a read-only skill file's markdown
+(for example the built-in `open-knowledge` skill's SKILL.md). Previously the
+frontmatter was stripped and hidden in the read-only viewer, so a managed skill's
+`name`, `description`, and other metadata were invisible; the editable skill panel
+already showed them. The read-only viewer now renders the same "Properties"
+section above the body, in read-only mode.
diff --git a/packages/app/src/components/ReadonlyPropertyPanel.dom.test.tsx b/packages/app/src/components/ReadonlyPropertyPanel.dom.test.tsx
new file mode 100644
index 000000000..4a0a32c38
--- /dev/null
+++ b/packages/app/src/components/ReadonlyPropertyPanel.dom.test.tsx
@@ -0,0 +1,65 @@
+/**
+ * RTL tests for the read-only frontmatter viewer used by the read-only
+ * skill-file markdown viewer. Asserts the rendered surface: the "Properties"
+ * disclosure, each frontmatter key + value, the no-frontmatter empty render,
+ * and that complex values fall back to the read-only preview.
+ */
+
+import { describe, expect, mock, test } from 'bun:test';
+import { render, screen } from '@testing-library/react';
+import * as linguiShim from '../../tests/lingui-macro-shim';
+
+mock.module('@lingui/react/macro', () => linguiShim);
+
+const { ReadonlyPropertyPanel } = await import('./ReadonlyPropertyPanel');
+
+describe('ReadonlyPropertyPanel', () => {
+ test('renders a Properties row per frontmatter key with its value', () => {
+ const { container } = render(
+ <ReadonlyPropertyPanel
+ text={'---\nname: my-skill\ndescription: does a thing\n---\n\n# Body\n'}
+ />,
+ );
+ expect(screen.getByTestId('readonly-property-panel')).toBeTruthy();
+ // Both keys render as visible labels.
+ expect(screen.getByText('name')).toBeTruthy();
+ expect(screen.getByText('description')).toBeTruthy();
+ // Each value is scoped to its key so duplicate testids stay unambiguous.
+ const nameValue = container.querySelector(
+ '[data-testid="readonly-property-value"][data-key="name"]',
+ );
+ expect(nameValue?.textContent).toBe('my-skill');
+ const descValue = container.querySelector(
+ '[data-testid="readonly-property-value"][data-key="description"]',
+ );
+ expect(descValue?.textContent).toBe('does a thing');
+ });
+
+ test('renders nothing when the file has no frontmatter', () => {
+ const { container } = render(
+ <ReadonlyPropertyPanel text={'# Just a body\n\nNo YAML here.\n'} />,
+ );
+ expect(screen.queryByTestId('readonly-property-panel')).toBeNull();
+ expect(container.firstChild).toBeNull();
+ });
+
+ test('renders scalar values as read-only text (no editable inputs)', () => {
+ const { container } = render(
+ <ReadonlyPropertyPanel text={'---\nname: foo\n---\n\n# Body\n'} />,
+ );
+ // Read-only: the value is plain text, not an input the user could type into.
+ expect(container.querySelector('input')).toBeNull();
+ expect(container.querySelector('textarea')).toBeNull();
+ expect(screen.getByTestId('readonly-property-value').textContent).toBe('foo');
+ });
+
+ test('nested-object values fall back to the read-only complex preview', () => {
+ render(
+ <ReadonlyPropertyPanel
+ text={'---\nname: foo\nmetadata:\n version: 1\n stage: beta\n---\n\n# Body\n'}
+ />,
+ );
+ // Complex values reuse the editable panel's read-only ComplexValueWidget.
+ expect(screen.getByTestId('complex-value-widget')).toBeTruthy();
+ });
+});
diff --git a/packages/app/src/components/ReadonlyPropertyPanel.tsx b/packages/app/src/components/ReadonlyPropertyPanel.tsx
new file mode 100644
index 000000000..7d46a7a37
--- /dev/null
+++ b/packages/app/src/components/ReadonlyPropertyPanel.tsx
@@ -0,0 +1,112 @@
+/**
+ * Read-only frontmatter viewer for markdown surfaces that have no CRDT provider
+ * — the read-only skill-file viewer (`SkillMarkdownViewer`), where the bytes are
+ * a static string, not a live `Y.Text`.
+ *
+ * The editable document panel (`PropertyPanel`) binds `bindFrontmatterDoc(provider)`
+ * for two-way edits; a read-only viewer has no provider to bind, and its scalar
+ * widgets are `<input>`-based editors with no display-only mode. So this renders
+ * the same "Properties" disclosure chrome (`PropertyDisclosure`, so the two
+ * surfaces don't drift on a restyle) with static rows parsed once from the raw
+ * text via the same `readFmRegion*` helpers the editable panel reads at mount.
+ *
+ * Nested objects / arrays-of-objects reuse the editable panel's own
+ * `ComplexValueWidget`, which is already a read-only preview.
+ */
+import {
+ type FrontmatterValue,
+ inferType,
+ readFmKeys,
+ readFmRegionWithError,
+} from '@inkeep/open-knowledge-core';
+import { Trans } from '@lingui/react/macro';
+import { PropertyDisclosure } from '@/components/PropertyDisclosure';
+import { ComplexValueWidget, isComplexValue, TYPE_ICON } from '@/components/PropertyWidgets';
+
+/**
+ * Renders the frontmatter of a raw markdown string as a read-only Properties
+ * panel. `text` is the full file source (frontmatter region + body) — the same
+ * shape `PropertyPanel.readInitialSnapshot` reads from the provider. Returns
+ * `null` when the file has no frontmatter, so a body-only doc pays no layout.
+ */
+export function ReadonlyPropertyPanel({ text }: { text: string }) {
+ const { map } = readFmRegionWithError(text);
+ // Prefer the YAML source order; fall back to `Object.keys(map)` when the
+ // region is malformed (mirrors `PropertyPanel`'s degraded render).
+ const orderedKeys = readFmKeys(text);
+ const renderKeys = orderedKeys.length > 0 ? orderedKeys : Object.keys(map);
+ if (renderKeys.length === 0) return null;
+
+ return (
+ <PropertyDisclosure
+ title={<Trans>Properties</Trans>}
+ testId="readonly-property-panel"
+ className="pt-4 pb-4"
+ >
+ {renderKeys.map((key, idx) => {
+ const value = map[key];
+ if (value === undefined) return null;
+ return (
+ // Position-aware key: yaml@2 admits duplicate keys, so the same name
+ // can appear twice; the source-order index disambiguates the rows.
+ // biome-ignore lint/suspicious/noArrayIndexKey: position-aware key for dup-name rows (matches PropertyPanel).
+ <ReadonlyRow key={`${key}-${idx}`} keyName={key} value={value} />
+ );
+ })}
+ </PropertyDisclosure>
+ );
+}
+
+/**
+ * One read-only frontmatter row — static type icon, key name, and a
+ * non-editable value. Column layout mirrors `SkillProperties`' identity rows
+ * (icon `size-7` + key `w-32` + value) so a read-only skill file lines up with
+ * the editable skill panel a user sees elsewhere.
+ */
+function ReadonlyRow({ keyName, value }: { keyName: string; value: FrontmatterValue }) {
+ const Icon = TYPE_ICON[inferType(value)];
+ return (
+ <div
+ className="group flex items-start gap-1 py-0.5"
+ data-testid="readonly-property-row"
+ data-key={keyName}
+ >
+ <span
+ aria-hidden
+ className="flex size-7 shrink-0 items-center justify-center rounded text-muted-foreground"
+ >
+ <Icon className="size-3.5" />
+ </span>
+ <span className="flex h-7 w-32 shrink-0 items-center truncate px-2 text-sm text-muted-foreground">
+ {keyName}
+ </span>
+ <div className="min-w-0 flex-1">
+ <ReadonlyValue keyName={keyName} value={value} />
+ </div>
+ </div>
+ );
+}
+
+/**
+ * Read-only value display. Complex shapes (nested object / array of objects)
+ * reuse the editable panel's `ComplexValueWidget` (already read-only); arrays of
+ * scalars join to a comma list; everything else stringifies. An empty value
+ * renders a height-preserving blank so the row still shows its key.
+ */
+function ReadonlyValue({ keyName, value }: { keyName: string; value: FrontmatterValue }) {
+ if (isComplexValue(value)) {
+ return <ComplexValueWidget keyName={keyName} value={value} />;
+ }
+ const display = Array.isArray(value)
+ ? value.filter((entry): entry is string => typeof entry === 'string').join(', ')
+ : String(value);
+ return (
+ <div
+ className="flex min-h-7 items-center px-2 py-1 text-sm break-words"
+ data-testid="readonly-property-value"
+ data-key={keyName}
+ >
+ {display}
+ </div>
+ );
+}
diff --git a/packages/app/src/components/SkillMarkdownViewer.tsx b/packages/app/src/components/SkillMarkdownViewer.tsx
index 3c9598a35..003ef792e 100644
--- a/packages/app/src/components/SkillMarkdownViewer.tsx
+++ b/packages/app/src/components/SkillMarkdownViewer.tsx
@@ -21,6 +21,7 @@ import { stripFrontmatter } from '@inkeep/open-knowledge-core';
import { EditorContent, useEditor } from '@tiptap/react';
import { useLayoutEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
+import { ReadonlyPropertyPanel } from '@/components/ReadonlyPropertyPanel';
import { sharedExtensions } from '@/editor/extensions/shared.ts';
import { getSharedMarkdownManager } from '@/editor/utils/md-singleton';
@@ -88,6 +89,12 @@ export function SkillMarkdownViewer({ fileName, text }: { fileName: string; text
data-skill-markdown-viewer-state="loaded"
>
<div className="editor-doc-scroll min-h-0 flex-1 overflow-auto">
+ {/* Frontmatter shows as a read-only Properties panel above the body —
+ the editable skill/document panel isn't reachable here (no CRDT
+ provider), so the file's metadata would otherwise be invisible.
+ `text` still carries the YAML region; the panel parses it and the
+ editor below renders the frontmatter-stripped body. */}
+ <ReadonlyPropertyPanel text={text} />
{/* Mirror the editor's content-column grid so prose width + side rails
match the real editor layout. */}
<div className="tiptap-editor">
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 3d6720cfb..a765f733c 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -5990,6 +5990,7 @@ msgid "Project-level pages with no outgoing graph edges."
msgstr "Project-level pages with no outgoing graph edges."
#: src/components/PropertyPanel.tsx
+#: src/components/ReadonlyPropertyPanel.tsx
#: src/components/TemplateProperties.tsx
msgid "Properties"
msgstr "Properties"
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 1835b6c34..8ace8ef82 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -5985,6 +5985,7 @@ msgid "Project-level pages with no outgoing graph edges."
msgstr ""
#: src/components/PropertyPanel.tsx
+#: src/components/ReadonlyPropertyPanel.tsx
#: src/components/TemplateProperties.tsx
msgid "Properties"
msgstr ""