Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): link .md paths in agent + user messages (PRD-7710) (#3658)

Abraham8e008efa0469
diff --git a/.changeset/acp-clickable-doc-paths.md b/.changeset/acp-clickable-doc-paths.md
new file mode 100644
index 000000000..85e8b113d
--- /dev/null
+++ b/.changeset/acp-clickable-doc-paths.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+An `.md` or `.mdx` path in a transcript message ("Written to public/open-knowledge/reports/foo/REPORT.md (458 lines)") is now a link that opens the doc in the editor. Works on both agent and user messages, whether the path is bare, backticked, or `@`-mentioned, and covers `.changeset/*` and other dot-segment content that lives in the tracked page set. A three-try resolver classifies each candidate — absolute path with a `contentDir` prefix, repo-root-relative composed onto `contentDir` (the case where the agent quotes `public/open-knowledge/…` and `contentDir` sits inside a repo), longest-suffix match against the tracked page set — and only links a path the workspace actually has (ambiguous suffix matches deliberately stay plain text). The resolver lives in module scope so Streamdown's per-block parser can read it at fire time; ThreadView derives it once above the transcript and provides its ready-shape through a small context so every mounted `AgentMarkdown` remounts exactly once when the workspace + page list arrive, without every message bubble firing its own `/api/workspace` fetch. The `components.a` override keeps Streamdown's own link classes on external links so they still read as links, and drops the redundant `aria-label` on doc links so voice control matches on the visible path (WCAG 2.5.3).
diff --git a/packages/app/src/components/acp/AgentMarkdown.dom.test.tsx b/packages/app/src/components/acp/AgentMarkdown.dom.test.tsx
index d9c8d1966..4c210be18 100644
--- a/packages/app/src/components/acp/AgentMarkdown.dom.test.tsx
+++ b/packages/app/src/components/acp/AgentMarkdown.dom.test.tsx
@@ -8,7 +8,10 @@
import { cleanup, render, waitFor } from '@testing-library/react';
import { afterEach, describe, expect, test } from 'vitest';
+import type { Workspace } from '@/lib/workspace-paths';
import { AgentMarkdown } from './AgentMarkdown';
+import { buildDocPathResolver, setDocPathResolver } from './doc-path-links';
+import { DocPathResolverReadyContext } from './doc-path-links-context';
describe('AgentMarkdown', () => {
afterEach(cleanup);
@@ -103,3 +106,119 @@ describe('single newlines', () => {
expect(strike.container.querySelector('del')).not.toBeNull();
});
});
+
+// The doc-path-links block. `AgentMarkdown` reads a `DocPathResolverReady`
+// context to decide whether to key its Streamdown for the resolver-available
+// render, so we wrap the render tree in the provider and populate the
+// module-scoped `currentResolver` directly (ThreadView owns those writes in
+// production). This isolates the feature under test without pulling in a
+// PageList provider tree.
+const workspace: Workspace = {
+ contentDir: '/Users/abraham/repo/public/open-knowledge',
+ pathSeparator: '/',
+};
+const pages = new Set(['reports/foo/REPORT', 'notes/haiku']);
+
+function renderWithResolver(text: string) {
+ const resolver = buildDocPathResolver({ workspace, pages });
+ setDocPathResolver(resolver);
+ return render(
+ <DocPathResolverReadyContext value={resolver !== null}>
+ <AgentMarkdown text={text} />
+ </DocPathResolverReadyContext>,
+ );
+}
+
+describe('AgentMarkdown doc-path links', () => {
+ afterEach(() => {
+ cleanup();
+ setDocPathResolver(null);
+ });
+
+ test('a repo-root-relative .md path in prose renders as an in-app hash link', () => {
+ const { container } = renderWithResolver(
+ 'Written to public/open-knowledge/reports/foo/REPORT.md (458 lines)',
+ );
+ const link = container.querySelector('a[data-testid="agent-thread-doc-link"]');
+ expect(link).not.toBeNull();
+ expect(link?.getAttribute('href')).toBe('#/reports/foo/REPORT');
+ // No target=_blank — in-app hash router, not external.
+ expect(link?.getAttribute('target')).toBeNull();
+ expect(link?.textContent).toContain('public/open-knowledge/reports/foo/REPORT.md');
+ });
+
+ test('a backticked path resolves too — the mono styling survives the wrap', () => {
+ const { container } = renderWithResolver('see `notes/haiku.md` for the poem');
+ const link = container.querySelector('a[data-testid="agent-thread-doc-link"]');
+ expect(link).not.toBeNull();
+ expect(link?.getAttribute('href')).toBe('#/notes/haiku');
+ expect(link?.querySelector('code')?.textContent).toBe('notes/haiku.md');
+ });
+
+ test('an unresolvable path stays plain text — no link, no create-on-open trap', () => {
+ const { container } = renderWithResolver('wrote reports/DOES-NOT-EXIST.md just now');
+ expect(container.querySelector('a[data-testid="agent-thread-doc-link"]')).toBeNull();
+ expect(container.textContent).toContain('reports/DOES-NOT-EXIST.md');
+ });
+
+ test('paths become links when the resolver flips null → ready — the cold-page-load path', async () => {
+ // Every other test in this suite mounts with the resolver already ready.
+ // The `key` on Streamdown exists specifically for the transition case —
+ // Streamdown caches its per-Block processor at first mount and never
+ // re-parses when a later render passes a different plugin closure, so a
+ // regression that swapped the key values or dropped context propagation
+ // would leave every message rendered during the cold-page-load window
+ // showing dead paths for the entire session.
+ setDocPathResolver(null);
+ const text = 'see reports/foo/REPORT.md please';
+ const { container, rerender } = render(
+ <DocPathResolverReadyContext value={false}>
+ <AgentMarkdown text={text} />
+ </DocPathResolverReadyContext>,
+ );
+ expect(container.querySelector('a[data-testid="agent-thread-doc-link"]')).toBeNull();
+
+ const resolver = buildDocPathResolver({ workspace, pages });
+ setDocPathResolver(resolver);
+ rerender(
+ <DocPathResolverReadyContext value={resolver !== null}>
+ <AgentMarkdown text={text} />
+ </DocPathResolverReadyContext>,
+ );
+ const link = container.querySelector('a[data-testid="agent-thread-doc-link"]');
+ expect(link).not.toBeNull();
+ expect(link?.getAttribute('href')).toBe('#/reports/foo/REPORT');
+ });
+
+ test('an .mdx path renders as an in-app link — the docs site is a Fumadocs .mdx tree', () => {
+ // The mocked page set in renderWithResolver only includes .md docs, so
+ // build a fresh render with a page set that has an .mdx target.
+ const resolver = buildDocPathResolver({
+ workspace,
+ pages: new Set(['docs/intro']),
+ });
+ setDocPathResolver(resolver);
+ const { container } = render(
+ <DocPathResolverReadyContext value={resolver !== null}>
+ <AgentMarkdown text={'open docs/intro.mdx for the setup steps'} />
+ </DocPathResolverReadyContext>,
+ );
+ const link = container.querySelector('a[data-testid="agent-thread-doc-link"]');
+ expect(link).not.toBeNull();
+ expect(link?.getAttribute('href')).toBe('#/docs/intro');
+ expect(link?.textContent).toBe('docs/intro.mdx');
+ });
+
+ test('an external link keeps target=_blank + Streamdown link styling', () => {
+ const { container } = renderWithResolver('see [docs](https://example.com/x)');
+ const link = container.querySelector('a[href="https://example.com/x"]');
+ expect(link).not.toBeNull();
+ expect(link?.getAttribute('target')).toBe('_blank');
+ expect(link?.getAttribute('rel')).toContain('noreferrer');
+ // Overriding components.a replaces Streamdown's MarkdownA — the external
+ // branch has to keep the same class list so external links stay visible.
+ expect(link?.getAttribute('class')).toContain('underline');
+ expect(link?.getAttribute('class')).toContain('text-primary');
+ expect(link?.getAttribute('data-streamdown')).toBe('link');
+ });
+});
diff --git a/packages/app/src/components/acp/AgentMarkdown.tsx b/packages/app/src/components/acp/AgentMarkdown.tsx
index 3f36ad5f6..5763941ef 100644
--- a/packages/app/src/components/acp/AgentMarkdown.tsx
+++ b/packages/app/src/components/acp/AgentMarkdown.tsx
@@ -7,22 +7,97 @@
* changes the text.
*/
-import type { ReactNode } from 'react';
+import { useLingui } from '@lingui/react/macro';
+import { type ReactNode, use } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
-import { defaultRemarkPlugins, Streamdown } from 'streamdown';
+import { type Components, defaultRemarkPlugins, Streamdown } from 'streamdown';
import { codeHighlighter } from '@/lib/acp/code-highlighter';
import { remarkHardBreaks } from '@/lib/acp/remark-hard-breaks';
+import { remarkDocPathLinks } from './doc-path-links';
+import { DocPathResolverReadyContext } from './doc-path-links-context';
+
+/** Anchor override. Two cases:
+ * - `#/<docName>` hash → in-app link (no `target=_blank`), Lingui'd `title`.
+ * - Anything else → keep Streamdown's own `MarkdownA` classes so external
+ * links still read as links (color + underline + `wrap-anywhere` for long
+ * URLs in the narrow transcript). Overriding `components.a` REPLACES
+ * `MarkdownA` — a bare `<a>` with no class list would leave every ordinary
+ * external link colourless and un-underlined under Tailwind's preflight
+ * (`a { color: inherit; text-decoration: inherit }`).
+ *
+ * Streamdown's Components index-signature widens prop types to a records
+ * shape, so we take the raw record and narrow href back out ourselves. */
+function AgentAnchor(props: { href?: string; children?: ReactNode }): ReactNode {
+ const { t } = useLingui();
+ const { href, children } = props;
+ if (href?.startsWith('#/')) {
+ const docName = decodeDocNameFromHash(href);
+ return (
+ <a
+ href={href}
+ data-testid="agent-thread-doc-link"
+ title={t`Open ${docName}`}
+ className="text-primary underline underline-offset-2 decoration-primary/40 hover:decoration-primary"
+ >
+ {children}
+ </a>
+ );
+ }
+ return (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ data-streamdown="link"
+ className="wrap-anywhere font-medium text-primary underline"
+ >
+ {children}
+ </a>
+ );
+}
+
+/** `#/<docName>[#anchor]` → `<docName>`. Mirrors `docNameFromHash`'s shape
+ * without pulling in its stricter validation — the href we're reading was
+ * built by `hashFromDocName` in the same render pass. */
+function decodeDocNameFromHash(hash: string): string {
+ const withoutPrefix = hash.slice(2);
+ const anchorAt = withoutPrefix.indexOf('#');
+ return anchorAt === -1 ? withoutPrefix : withoutPrefix.slice(0, anchorAt);
+}
export function AgentMarkdown({ text }: { text: string }): ReactNode {
+ // Reads the resolver-ready flag from context so ThreadView can derive
+ // workspace + page list ONCE above the transcript instead of per message
+ // bubble (which fires `/api/workspace` per bubble on web hosts).
+ const resolverReady = use(DocPathResolverReadyContext);
return (
<ErrorBoundary
resetKeys={[text]}
fallbackRender={() => <span className="whitespace-pre-wrap">{text}</span>}
onError={(error) => {
- console.warn('[AgentMarkdown] markdown render failed, falling back to plain text', error);
+ console.error('[AgentMarkdown] markdown render failed, falling back to plain text', error);
}}
>
<Streamdown
+ // Key on resolver-availability so every mounted Streamdown remounts
+ // exactly once when the resolver becomes ready. Streamdown's Block
+ // memoizes its unified processor at first mount and never re-parses
+ // when a later render passes a different plugin closure, so a mount
+ // that happened before workspace + page list arrived (the transcript
+ // on cold page load) would leave those older messages' paths
+ // unlinked forever. Text is stable across the null → ready transition
+ // (workspace + pages arrive on the first tick; transcript-render
+ // lands after), so the remount is imperceptible.
+ //
+ // Residual race, deliberately not solved: a doc the agent creates
+ // mid-thread reaches `pageList.pages` via the CC1 `files` push
+ // (300ms coalesce + a `/api/documents` fetch). A short agent message
+ // that finishes streaming inside that window keeps its own path as
+ // dead text for the rest of the session — the resolver-availability
+ // shape never flips again. Keying on a page-set version would fix
+ // this but remounts every message on every doc-create burst; the
+ // trade isn't worth it for the tail case.
+ key={resolverReady ? 'with-resolver' : 'no-resolver'}
// The `pre code>span` rule restores per-line block display in code
// blocks: Streamdown bundles it into the line-number counter classes,
// so `lineNumbers={false}` alone collapses multi-line code onto one
@@ -57,7 +132,16 @@ export function AgentMarkdown({ text }: { text: string }): ReactNode {
// silently dropped remark-gfm with it — tables and strikethrough stopped
// rendering in agent output, nowhere near the line that caused it.
// `defaultRemarkPlugins` is a RECORD keyed by name, not a list.
- remarkPlugins={[...Object.values(defaultRemarkPlugins), remarkHardBreaks]}
+ remarkPlugins={[
+ ...Object.values(defaultRemarkPlugins),
+ remarkHardBreaks,
+ // Pre-called (unlike `remarkHardBreaks`, which is a standard
+ // `() => Transformer` Plugin passed by reference). The extra factory
+ // layer keeps Streamdown's per-Block processor cache from freezing a
+ // stale resolver closure — see doc-path-links.ts.
+ remarkDocPathLinks(),
+ ]}
+ components={{ a: AgentAnchor } as Components}
lineNumbers={false}
controls={{ code: { copy: true, download: false }, table: false, mermaid: false }}
// Shiki-backed syntax highlighting via the in-house curated-grammar
diff --git a/packages/app/src/components/acp/ThreadView.tsx b/packages/app/src/components/acp/ThreadView.tsx
index 3977b5501..14477ac4d 100644
--- a/packages/app/src/components/acp/ThreadView.tsx
+++ b/packages/app/src/components/acp/ThreadView.tsx
@@ -151,6 +151,8 @@ import { dispatchExternalLinkClick } from '@/lib/external-link';
import { useWorkspace } from '@/lib/use-workspace';
import { cn } from '@/lib/utils';
import { AgentMarkdown } from './AgentMarkdown';
+import { buildDocPathResolver, setDocPathResolver } from './doc-path-links';
+import { DocPathResolverReadyContext } from './doc-path-links-context';
import {
decideFollowNavigation,
type FollowNavState,
@@ -505,7 +507,30 @@ export function ThreadView({
// file would open a blank create-on-open tab. `pageListFollowOptions`
// arms the predicate only when the page-list snapshot is authoritative;
// the exact loading/error rules live at the helper (unit-tested there).
- const followOptions = pageListFollowOptions(useOptionalPageList());
+ // Extract `pageList` once and drive both follow-file (page-existence
+ // check) and the doc-path-link resolver from the same snapshot — avoids
+ // two independent `useOptionalPageList` sites racing to consume it, and
+ // avoids per-message `useWorkspace` calls that would each fire a
+ // `/api/workspace` fetch on web hosts.
+ const pageList = useOptionalPageList();
+ const followOptions = pageListFollowOptions(pageList);
+ // Trust the last-known `pages` set even when the provider surfaces an
+ // `error` from a background refetch: `PageListProvider.refetch` fires on
+ // window focus / visibilitychange / CC1 `files` push and, on failure, sets
+ // an error string WITHOUT clearing `serverPages`. Gating on `error === null`
+ // here would flip the resolver null on a transient blip, remount every
+ // Streamdown twice (drop → restore), and strip every doc link across the
+ // transcript for the paint window between them.
+ const pages =
+ pageList !== null && !pageList.loading && pageList.pages.size > 0 ? pageList.pages : null;
+ const docPathResolver = pages === null ? null : buildDocPathResolver({ workspace, pages });
+ // Push into the module-scoped resolver DURING render so Streamdown's parse
+ // (which happens synchronously inside its Block) sees the current value. A
+ // `useEffect` write lands after the parse, leaving the first render of a
+ // stable-text agent message unlinked. The write is idempotent (every
+ // ThreadView derives from the same workspace + page list).
+ setDocPathResolver(docPathResolver);
+ const resolverReady = docPathResolver !== null;
const transcriptFollowTarget =
model !== null ? latestFollowTarget(model.items, workspace, followOptions) : null;
@@ -1039,200 +1064,204 @@ export function ThreadView({
void ingestFiles(files);
}}
>
- <ThreadHeader info={info} followFile={followFile} onToggleFollow={toggleFollow} />
- {model !== null && model.plan.length > 0 ? <PlanChecklist plan={model.plan} /> : null}
- {authPrompt !== null || model === null || visibleItems.length === 0 ? (
- // No messages yet: the empty state centers itself via `h-full`, which needs
- // a plain definite-height block host. The scroller's managed flex layout
- // won't provide one, so only real transcripts go through the scroller.
- <div
- className="min-h-0 flex-1 overflow-y-auto px-3 py-2 subtle-scrollbar scroll-fade-mask"
- data-testid="agent-thread-transcript"
- >
- {authPrompt !== null ? (
- <div className="flex min-h-full items-center justify-center">
- <ThreadAuthPrompt
- failure={authPrompt}
- agent={info.agent}
- agentName={agentDisplayName(info.agent.name)}
- signingIn={signingIn}
- signInOutput={info.signInOutput}
- showRetry={canRetry}
- retryPending={retryPending}
- onRetry={retryThread}
- onAuthenticate={authenticateThread}
- />
- </div>
- ) : (
- <ThreadEmptyState status={status} archived={archived} agent={info.agent} />
- )}
- </div>
- ) : (
- // autoScroll = stick-to-bottom that yields to reader intent; last-anchor
- // reopens archived/resumed threads at the final turn. The bridge lifts the
- // scroller's imperative API up so send/resume can jump to the live edge.
- <MessageScrollerProvider autoScroll defaultScrollPosition="last-anchor">
- <ScrollToEndBridge apiRef={scrollApiRef} />
- <MessageScroller className="min-h-0 flex-1">
- <MessageScrollerViewport
- // Overrides the primitive's hardcoded "Messages" — this focusable
- // region is one agent's transcript, and its name must translate.
- aria-label={t`Agent transcript`}
- className="px-3 py-2 subtle-scrollbar scroll-fade-mask"
- data-testid="agent-thread-transcript"
- >
- <MessageScrollerContent className="gap-2 [&>[data-tool-call]+[data-tool-call]]:-mt-1">
- {visibleItems.map((item, index) => {
- const id = transcriptItemId(item, index);
- return (
- <MessageScrollerItem
- key={id}
- messageId={id}
- // Each item hosts its own flex column so per-message alignment
- // (the user bubble's ml-auto hug-and-right) survives the wrapper
- // the scroller requires for anchoring/measurement.
- className="flex flex-col"
- // A new user turn is the anchor the scroller peeks above.
- scrollAnchor={item.kind === 'message' && item.role === 'user'}
- // Re-hosts the adjacent-tool-call spacing selector on the wrapper.
- data-tool-call={item.kind === 'tool_call' ? '' : undefined}
- >
- <ThreadItem
- item={item}
- threadId={info.threadId}
- agent={info.agent}
- // Thread liveness, not turn liveness: the server keeps an
- // unanswered request answerable until its timeout even after
- // the prompt settles (and some agents ask outside a turn) —
- // only a dead thread makes answering impossible.
- actionable={!archived && status !== 'exited' && status !== 'error'}
- streaming={turnActive && index === visibleItems.length - 1}
- terminals={model.terminals}
- permissionsByToolCall={model.permissionsByToolCall}
- showRetry={index === retryNoticeIndex}
- retryPending={retryPending}
- onRetry={retryThread}
- showRestore={index === restoreNoticeIndex}
- onRestore={() => restoreFailedPromptToComposer(index)}
+ <DocPathResolverReadyContext value={resolverReady}>
+ <ThreadHeader info={info} followFile={followFile} onToggleFollow={toggleFollow} />
+ {model !== null && model.plan.length > 0 ? <PlanChecklist plan={model.plan} /> : null}
+ {authPrompt !== null || model === null || visibleItems.length === 0 ? (
+ // No messages yet: the empty state centers itself via `h-full`, which needs
+ // a plain definite-height block host. The scroller's managed flex layout
+ // won't provide one, so only real transcripts go through the scroller.
+ <div
+ className="min-h-0 flex-1 overflow-y-auto px-3 py-2 subtle-scrollbar scroll-fade-mask"
+ data-testid="agent-thread-transcript"
+ >
+ {authPrompt !== null ? (
+ <div className="flex min-h-full items-center justify-center">
+ <ThreadAuthPrompt
+ failure={authPrompt}
+ agent={info.agent}
+ agentName={agentDisplayName(info.agent.name)}
+ signingIn={signingIn}
+ signInOutput={info.signInOutput}
+ showRetry={canRetry}
+ retryPending={retryPending}
+ onRetry={retryThread}
+ onAuthenticate={authenticateThread}
+ />
+ </div>
+ ) : (
+ <ThreadEmptyState status={status} archived={archived} agent={info.agent} />
+ )}
+ </div>
+ ) : (
+ // autoScroll = stick-to-bottom that yields to reader intent; last-anchor
+ // reopens archived/resumed threads at the final turn. The bridge lifts the
+ // scroller's imperative API up so send/resume can jump to the live edge.
+ <MessageScrollerProvider autoScroll defaultScrollPosition="last-anchor">
+ <ScrollToEndBridge apiRef={scrollApiRef} />
+ <MessageScroller className="min-h-0 flex-1">
+ <MessageScrollerViewport
+ // Overrides the primitive's hardcoded "Messages" — this focusable
+ // region is one agent's transcript, and its name must translate.
+ aria-label={t`Agent transcript`}
+ className="px-3 py-2 subtle-scrollbar scroll-fade-mask"
+ data-testid="agent-thread-transcript"
+ >
+ <MessageScrollerContent className="gap-2 [&>[data-tool-call]+[data-tool-call]]:-mt-1">
+ {visibleItems.map((item, index) => {
+ const id = transcriptItemId(item, index);
+ return (
+ <MessageScrollerItem
+ key={id}
+ messageId={id}
+ // Each item hosts its own flex column so per-message alignment
+ // (the user bubble's ml-auto hug-and-right) survives the wrapper
+ // the scroller requires for anchoring/measurement.
+ className="flex flex-col"
+ // A new user turn is the anchor the scroller peeks above.
+ scrollAnchor={item.kind === 'message' && item.role === 'user'}
+ // Re-hosts the adjacent-tool-call spacing selector on the wrapper.
+ data-tool-call={item.kind === 'tool_call' ? '' : undefined}
+ >
+ <ThreadItem
+ item={item}
+ threadId={info.threadId}
+ agent={info.agent}
+ // Thread liveness, not turn liveness: the server keeps an
+ // unanswered request answerable until its timeout even after
+ // the prompt settles (and some agents ask outside a turn) —
+ // only a dead thread makes answering impossible.
+ actionable={!archived && status !== 'exited' && status !== 'error'}
+ streaming={turnActive && index === visibleItems.length - 1}
+ terminals={model.terminals}
+ permissionsByToolCall={model.permissionsByToolCall}
+ showRetry={index === retryNoticeIndex}
+ retryPending={retryPending}
+ onRetry={retryThread}
+ showRestore={index === restoreNoticeIndex}
+ onRestore={() => restoreFailedPromptToComposer(index)}
+ />
+ </MessageScrollerItem>
+ );
+ })}
+ {turnActive ? (
+ status === 'awaiting_permission' ? (
+ <div
+ className="flex items-center gap-2 px-1 py-1 text-muted-foreground text-sm shimmer"
+ data-testid="agent-thread-awaiting-permission"
+ >
+ <span>{t`Waiting for your approval`}</span>
+ </div>
+ ) : (
+ <WorkingAvatar
+ status={workingStatusText(activeToolKind(model.items), thinkingLine)}
+ className="px-1 py-1"
+ testId="agent-thread-working"
/>
- </MessageScrollerItem>
- );
- })}
- {turnActive ? (
- status === 'awaiting_permission' ? (
+ )
+ ) : status === 'installing' || status === 'spawning' ? (
+ // A resume respawning its agent: the optimistic message echo is
+ // already in the transcript above — show that the agent is on
+ // its way rather than a silent gap until the turn opens.
<div
- className="flex items-center gap-2 px-1 py-1 text-muted-foreground text-sm shimmer"
- data-testid="agent-thread-awaiting-permission"
+ className="flex items-center gap-2 px-1 py-1 text-muted-foreground text-sm"
+ data-testid="agent-thread-starting"
>
- <span>{t`Waiting for your approval`}</span>
- </div>
- ) : (
- <WorkingAvatar
- status={workingStatusText(activeToolKind(model.items), thinkingLine)}
- className="px-1 py-1"
- testId="agent-thread-working"
- />
- )
- ) : status === 'installing' || status === 'spawning' ? (
- // A resume respawning its agent: the optimistic message echo is
- // already in the transcript above — show that the agent is on
- // its way rather than a silent gap until the turn opens.
- <div
- className="flex items-center gap-2 px-1 py-1 text-muted-foreground text-sm"
- data-testid="agent-thread-starting"
- >
- <Spinner className="size-3.5" aria-hidden="true" />
- {/* `shimmer` sets `color: transparent`, which a container
+ <Spinner className="size-3.5" aria-hidden="true" />
+ {/* `shimmer` sets `color: transparent`, which a container
would inherit into the spinner's currentColor stroke —
keep it scoped to the text. */}
- <span className="shimmer">{t`Starting the agent…`}</span>
- </div>
- ) : null}
- </MessageScrollerContent>
- </MessageScrollerViewport>
- <MessageScrollerButton direction="end" />
- </MessageScroller>
- </MessageScrollerProvider>
- )}
- {info.steer !== undefined && !archived ? (
- <div
- className="flex items-center gap-2 border-t bg-muted/40 px-3 py-1.5 text-muted-foreground text-xs"
- data-testid="agent-thread-steer-pending"
- >
- <Spinner className="size-3.5 shrink-0" aria-hidden="true" />
- <span className="shrink-0">{t`Steering — waiting for the current run to stop…`}</span>
- <span className="min-w-0 flex-1 truncate text-foreground/80">{info.steer.content}</span>
- </div>
- ) : null}
- {cancelStalled && turnActive ? (
- <div
- className="flex items-center gap-2 border-amber-500/30 border-t bg-amber-500/5 px-3 py-1.5 text-amber-700 text-xs dark:text-amber-400"
- data-testid="agent-thread-cancel-stalled"
- >
- <span className="flex-1">
- {t`The agent isn't stopping. Force stop closes this chat and quits the agent.`}
- </span>
- <Button
- type="button"
- size="sm"
- variant="destructive"
- className="h-6 text-xs"
- onClick={() => client.closeThread(info.threadId)}
- data-testid="agent-thread-force-stop"
+ <span className="shimmer">{t`Starting the agent…`}</span>
+ </div>
+ ) : null}
+ </MessageScrollerContent>
+ </MessageScrollerViewport>
+ <MessageScrollerButton direction="end" />
+ </MessageScroller>
+ </MessageScrollerProvider>
+ )}
+ {info.steer !== undefined && !archived ? (
+ <div
+ className="flex items-center gap-2 border-t bg-muted/40 px-3 py-1.5 text-muted-foreground text-xs"
+ data-testid="agent-thread-steer-pending"
>
- {t`Force stop`}
- </Button>
- </div>
- ) : null}
- {archived && resumeError !== null ? (
- <div
- className="flex items-center gap-2 border-amber-500/30 border-t bg-amber-500/5 px-3 py-1.5 text-amber-700 text-xs dark:text-amber-400"
- data-testid="agent-thread-resume-failed"
- >
- <span className="flex-1">
- {resumeError.code === 'resume-unsupported'
- ? t`${info.agent.name} can't continue this chat — the transcript is kept, but the agent session is gone.`
- : t`Couldn't resume this chat: ${resumeError.message}`}
- </span>
- <Button
- type="button"
- size="sm"
- variant="outline"
- className="h-6 shrink-0 text-xs"
- onClick={startFreshThread}
- data-testid="agent-thread-resume-fallback-new"
+ <Spinner className="size-3.5 shrink-0" aria-hidden="true" />
+ <span className="shrink-0">{t`Steering — waiting for the current run to stop…`}</span>
+ <span className="min-w-0 flex-1 truncate text-foreground/80">
+ {info.steer.content}
+ </span>
+ </div>
+ ) : null}
+ {cancelStalled && turnActive ? (
+ <div
+ className="flex items-center gap-2 border-amber-500/30 border-t bg-amber-500/5 px-3 py-1.5 text-amber-700 text-xs dark:text-amber-400"
+ data-testid="agent-thread-cancel-stalled"
>
- {t`New chat with ${info.agent.name}`}
- </Button>
- </div>
- ) : null}
- <ThreadComposer
- info={info}
- composerRef={composerRef}
- onSubmit={submit}
- canPrompt={canPrompt}
- canQueue={canQueue}
- turnActive={turnActive}
- cancelPending={cancelPending}
- onCancel={requestCancel}
- onSteer={requestSteer}
- status={status}
- archived={archived}
- resumePending={resumePending}
- usage={model?.tokenUsage ?? null}
- selectedCommentCount={selectedCommentCount}
- selectedCommentDocs={selectedCommentDocs}
- hasQueuedComments={hasQueuedComments}
- onAttachComments={() => setCommentsAttached(true)}
- onDismissComments={() => setCommentsAttached(false)}
- pendingAttachments={pendingAttachments}
- pendingUploads={pendingUploads}
- imagesAccepted={imagesAccepted}
- onIngestImageFiles={ingestFiles}
- onIngestAllFiles={ingestFiles}
- onRemovePendingAttachment={removePendingAttachment}
- />
- {dragActive ? <ChatPanelDropOverlay onDismiss={() => setDragActive(false)} /> : null}
+ <span className="flex-1">
+ {t`The agent isn't stopping. Force stop closes this chat and quits the agent.`}
+ </span>
+ <Button
+ type="button"
+ size="sm"
+ variant="destructive"
+ className="h-6 text-xs"
+ onClick={() => client.closeThread(info.threadId)}
+ data-testid="agent-thread-force-stop"
+ >
+ {t`Force stop`}
+ </Button>
+ </div>
+ ) : null}
+ {archived && resumeError !== null ? (
+ <div
+ className="flex items-center gap-2 border-amber-500/30 border-t bg-amber-500/5 px-3 py-1.5 text-amber-700 text-xs dark:text-amber-400"
+ data-testid="agent-thread-resume-failed"
+ >
+ <span className="flex-1">
+ {resumeError.code === 'resume-unsupported'
+ ? t`${info.agent.name} can't continue this chat — the transcript is kept, but the agent session is gone.`
+ : t`Couldn't resume this chat: ${resumeError.message}`}
+ </span>
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ className="h-6 shrink-0 text-xs"
+ onClick={startFreshThread}
+ data-testid="agent-thread-resume-fallback-new"
+ >
+ {t`New chat with ${info.agent.name}`}
+ </Button>
+ </div>
+ ) : null}
+ <ThreadComposer
+ info={info}
+ composerRef={composerRef}
+ onSubmit={submit}
+ canPrompt={canPrompt}
+ canQueue={canQueue}
+ turnActive={turnActive}
+ cancelPending={cancelPending}
+ onCancel={requestCancel}
+ onSteer={requestSteer}
+ status={status}
+ archived={archived}
+ resumePending={resumePending}
+ usage={model?.tokenUsage ?? null}
+ selectedCommentCount={selectedCommentCount}
+ selectedCommentDocs={selectedCommentDocs}
+ hasQueuedComments={hasQueuedComments}
+ onAttachComments={() => setCommentsAttached(true)}
+ onDismissComments={() => setCommentsAttached(false)}
+ pendingAttachments={pendingAttachments}
+ pendingUploads={pendingUploads}
+ imagesAccepted={imagesAccepted}
+ onIngestImageFiles={ingestFiles}
+ onIngestAllFiles={ingestFiles}
+ onRemovePendingAttachment={removePendingAttachment}
+ />
+ {dragActive ? <ChatPanelDropOverlay onDismiss={() => setDragActive(false)} /> : null}
+ </DocPathResolverReadyContext>
</div>
</ImagePreviewContext.Provider>
);
diff --git a/packages/app/src/components/acp/doc-path-links-context.ts b/packages/app/src/components/acp/doc-path-links-context.ts
new file mode 100644
index 000000000..f52839a2b
--- /dev/null
+++ b/packages/app/src/components/acp/doc-path-links-context.ts
@@ -0,0 +1,15 @@
+import { createContext } from 'react';
+
+/**
+ * True when the module-scoped `currentResolver` in `doc-path-links` has been
+ * populated (workspace + page list resolved). `AgentMarkdown` reads this to
+ * key its Streamdown so every mounted instance re-parses once when the
+ * resolver flips null → ready. Provided by `ThreadView` — one derivation
+ * above the transcript instead of one `useWorkspace()` per message bubble
+ * (which would fire `/api/workspace` per message on web hosts).
+ *
+ * Default `false`: renders outside a ThreadView (test harnesses,
+ * standalone AgentMarkdown mounts) get the no-resolver key, matching the
+ * behavior when the resolver is not yet available.
+ */
+export const DocPathResolverReadyContext = createContext(false);
diff --git a/packages/app/src/components/acp/doc-path-links.test.ts b/packages/app/src/components/acp/doc-path-links.test.ts
new file mode 100644
index 000000000..ac07c325e
--- /dev/null
+++ b/packages/app/src/components/acp/doc-path-links.test.ts
@@ -0,0 +1,350 @@
+import { describe, expect, test } from 'vitest';
+import type { Workspace } from '@/lib/workspace-paths';
+import { buildDocPathResolver, remarkDocPathLinks, setDocPathResolver } from './doc-path-links';
+
+const workspace: Workspace = {
+ contentDir: '/Users/abraham/repo/public/open-knowledge',
+ pathSeparator: '/',
+};
+
+const windowsWorkspace: Workspace = {
+ contentDir: 'C:\\Users\\abraham\\repo\\public\\open-knowledge',
+ pathSeparator: '\\',
+};
+
+describe('buildDocPathResolver', () => {
+ test('null when the workspace is unknown', () => {
+ expect(
+ buildDocPathResolver({ workspace: null, pages: new Set(['reports/foo/REPORT']) }),
+ ).toBeNull();
+ });
+
+ test('null when the page set is empty (page list not authoritative yet)', () => {
+ expect(buildDocPathResolver({ workspace, pages: new Set() })).toBeNull();
+ });
+
+ test('try 1: absolute path with contentDir prefix resolves to docName', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(resolve).not.toBeNull();
+ expect(resolve?.('/Users/abraham/repo/public/open-knowledge/reports/foo/REPORT.md')).toBe(
+ 'reports/foo/REPORT',
+ );
+ });
+
+ test('try 2: repo-root-relative path composes onto contentDir', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ // Mike's canonical example: agent writes `public/open-knowledge/reports/…`
+ // and contentDir *is* `.../public/open-knowledge`.
+ expect(resolve?.('public/open-knowledge/reports/foo/REPORT.md')).toBe('reports/foo/REPORT');
+ });
+
+ test('try 3a: bare-tail path resolves via exact match against the page set', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(resolve?.('reports/foo/REPORT.md')).toBe('reports/foo/REPORT');
+ });
+
+ test('.mdx path resolves via exact match — Fumadocs trees are common under docs/', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['docs/intro']),
+ });
+ expect(resolve?.('docs/intro.mdx')).toBe('docs/intro');
+ });
+
+ test('try 3b: suffix-match resolves an in-subtree tail', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['some/deep/place/notes', 'reports/foo/REPORT']),
+ });
+ // `place/notes.md` isn't a doc on its own, but exactly one page ends
+ // with `/place/notes` — that's the unambiguous target.
+ expect(resolve?.('place/notes.md')).toBe('some/deep/place/notes');
+ });
+
+ test('try 3 rejects ambiguous suffix matches — two candidates → no link', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['a/foo/README', 'b/foo/README']),
+ });
+ // Two docs end in `/foo/README`; the resolver refuses rather than guess.
+ expect(resolve?.('foo/README.md')).toBeNull();
+ // The bare basename is also ambiguous.
+ expect(resolve?.('README.md')).toBeNull();
+ });
+
+ test('missing doc → null even when the path parses cleanly', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(resolve?.('reports/foo/DOES-NOT-EXIST.md')).toBeNull();
+ expect(
+ resolve?.('/Users/abraham/repo/public/open-knowledge/reports/foo/DOES-NOT-EXIST.md'),
+ ).toBeNull();
+ });
+
+ test('non-markdown paths never link — the editor cannot open them', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(resolve?.('reports/foo/REPORT.ts')).toBeNull();
+ expect(resolve?.('reports/foo/REPORT.txt')).toBeNull();
+ expect(resolve?.('reports/foo/README')).toBeNull(); // no extension
+ });
+
+ test('a leading @ is stripped before resolution — agents mention paths that way', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(resolve?.('@reports/foo/REPORT.md')).toBe('reports/foo/REPORT');
+ });
+
+ test('trailing #anchor is stripped before resolution', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(resolve?.('reports/foo/REPORT.md#somewhere')).toBe('reports/foo/REPORT');
+ });
+
+ test('dot-segment paths link when they are in the tracked page set (.changeset/, .github/, …)', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['.changeset/some-fix', '.github/CONTRIBUTING']),
+ });
+ // A `.changeset/*` doc is user-authored content, not agent plumbing.
+ // Legacy follow-the-file's `sanitizeDocName` refuses all dot-segments;
+ // this resolver gates on the tracked page set instead, so tracked
+ // dot-segment content links normally.
+ expect(resolve?.('.changeset/some-fix.md')).toBe('.changeset/some-fix');
+ expect(resolve?.('@.changeset/some-fix.md')).toBe('.changeset/some-fix');
+ expect(resolve?.('.github/CONTRIBUTING.md')).toBe('.github/CONTRIBUTING');
+ });
+
+ test('Windows-style separators normalize to forward slashes', () => {
+ const resolve = buildDocPathResolver({
+ workspace: windowsWorkspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+ expect(
+ resolve?.('C:\\Users\\abraham\\repo\\public\\open-knowledge\\reports\\foo\\REPORT.md'),
+ ).toBe('reports/foo/REPORT');
+ });
+});
+
+interface MdastNode {
+ type: string;
+ value?: string;
+ url?: string;
+ title?: string | null;
+ children?: MdastNode[];
+}
+
+function makeTree(children: MdastNode[]): MdastNode {
+ return { type: 'root', children };
+}
+
+describe('remarkDocPathLinks', () => {
+ const resolve = buildDocPathResolver({
+ workspace,
+ pages: new Set(['reports/foo/REPORT']),
+ });
+
+ test('null resolver is a no-op — no walk, no allocations', () => {
+ const tree = makeTree([
+ { type: 'paragraph', children: [{ type: 'text', value: 'see reports/foo/REPORT.md ok' }] },
+ ]);
+ setDocPathResolver(null);
+ remarkDocPathLinks()()(tree);
+ // Identity preserved.
+ expect(tree.children?.[0]?.children?.[0]).toEqual({
+ type: 'text',
+ value: 'see reports/foo/REPORT.md ok',
+ });
+ });
+
+ test('a leading @ in a text node is matched and linked — the visible link text keeps the @', () => {
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'text', value: 'see @reports/foo/REPORT.md for details' }],
+ },
+ ]);
+ setDocPathResolver(resolve);
+ remarkDocPathLinks()()(tree);
+ const kids = tree.children?.[0]?.children ?? [];
+ expect(kids).toHaveLength(3);
+ expect(kids[1]).toMatchObject({
+ type: 'link',
+ url: '#/reports/foo/REPORT',
+ children: [{ type: 'text', value: '@reports/foo/REPORT.md' }],
+ });
+ });
+
+ test('splits a text node around a matched .mdx path — three code paths handle mdx (regex, stripMarkdownExt, plugin walk)', () => {
+ const resolveForMdx = buildDocPathResolver({
+ workspace,
+ pages: new Set(['docs/intro']),
+ });
+ setDocPathResolver(resolveForMdx);
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'text', value: 'edited docs/intro.mdx successfully' }],
+ },
+ ]);
+ remarkDocPathLinks()()(tree);
+ const kids = tree.children?.[0]?.children ?? [];
+ expect(kids).toHaveLength(3);
+ expect(kids[1]).toMatchObject({
+ type: 'link',
+ url: '#/docs/intro',
+ children: [{ type: 'text', value: 'docs/intro.mdx' }],
+ });
+ });
+
+ test('splits a text node around a matched path and wraps it in a link', () => {
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'text', value: 'Written to reports/foo/REPORT.md (458 lines)' }],
+ },
+ ]);
+ setDocPathResolver(resolve);
+ remarkDocPathLinks()()(tree);
+ const kids = tree.children?.[0]?.children ?? [];
+ expect(kids).toHaveLength(3);
+ expect(kids[0]).toEqual({ type: 'text', value: 'Written to ' });
+ expect(kids[1]).toMatchObject({
+ type: 'link',
+ url: '#/reports/foo/REPORT',
+ children: [{ type: 'text', value: 'reports/foo/REPORT.md' }],
+ });
+ expect(kids[2]).toEqual({ type: 'text', value: ' (458 lines)' });
+ });
+
+ test('wraps a whole-value inlineCode path in a link so backticked paths click through', () => {
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [
+ { type: 'text', value: 'see ' },
+ { type: 'inlineCode', value: 'reports/foo/REPORT.md' },
+ ],
+ },
+ ]);
+ setDocPathResolver(resolve);
+ remarkDocPathLinks()()(tree);
+ const kids = tree.children?.[0]?.children ?? [];
+ expect(kids).toHaveLength(2);
+ expect(kids[1]).toMatchObject({
+ type: 'link',
+ url: '#/reports/foo/REPORT',
+ children: [{ type: 'inlineCode', value: 'reports/foo/REPORT.md' }],
+ });
+ });
+
+ test('leaves inlineCode alone when its value does not resolve', () => {
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'inlineCode', value: 'const x = 1;' }],
+ },
+ ]);
+ setDocPathResolver(resolve);
+ remarkDocPathLinks()()(tree);
+ expect(tree.children?.[0]?.children?.[0]).toEqual({
+ type: 'inlineCode',
+ value: 'const x = 1;',
+ });
+ });
+
+ test('leaves existing links alone — no double-wrap, no linking inside', () => {
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [
+ {
+ type: 'link',
+ url: 'https://example.com',
+ children: [{ type: 'text', value: 'reports/foo/REPORT.md' }],
+ },
+ ],
+ },
+ ]);
+ setDocPathResolver(resolve);
+ remarkDocPathLinks()()(tree);
+ const kids = tree.children?.[0]?.children ?? [];
+ expect(kids).toHaveLength(1);
+ expect(kids[0]?.url).toBe('https://example.com');
+ // The link's own child text stays as text, NOT a nested link (mdast forbids that).
+ expect(kids[0]?.children?.[0]).toEqual({
+ type: 'text',
+ value: 'reports/foo/REPORT.md',
+ });
+ });
+
+ test('ambiguous paths stay plain text — the resolver returned null', () => {
+ const ambiguous = buildDocPathResolver({
+ workspace,
+ pages: new Set(['a/foo/README', 'b/foo/README']),
+ });
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'text', value: 'see foo/README.md for details' }],
+ },
+ ]);
+ setDocPathResolver(ambiguous);
+ remarkDocPathLinks()()(tree);
+ expect(tree.children?.[0]?.children).toEqual([
+ { type: 'text', value: 'see foo/README.md for details' },
+ ]);
+ });
+
+ test('half-arrived path mid-stream (no extension yet) does not match', () => {
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'text', value: 'writing to reports/foo/REPOR' }],
+ },
+ ]);
+ setDocPathResolver(resolve);
+ remarkDocPathLinks()()(tree);
+ expect(tree.children?.[0]?.children).toEqual([
+ { type: 'text', value: 'writing to reports/foo/REPOR' },
+ ]);
+ });
+
+ test('handles multiple matches in a single text node', () => {
+ const resolveMany = buildDocPathResolver({
+ workspace,
+ pages: new Set(['a/one', 'b/two']),
+ });
+ const tree = makeTree([
+ {
+ type: 'paragraph',
+ children: [{ type: 'text', value: 'moved a/one.md into b/two.md' }],
+ },
+ ]);
+ setDocPathResolver(resolveMany);
+ remarkDocPathLinks()()(tree);
+ const kids = tree.children?.[0]?.children ?? [];
+ expect(kids).toHaveLength(4);
+ expect(kids[0]).toEqual({ type: 'text', value: 'moved ' });
+ expect(kids[1]?.url).toBe('#/a/one');
+ expect(kids[2]).toEqual({ type: 'text', value: ' into ' });
+ expect(kids[3]?.url).toBe('#/b/two');
+ });
+});
diff --git a/packages/app/src/components/acp/doc-path-links.ts b/packages/app/src/components/acp/doc-path-links.ts
new file mode 100644
index 000000000..1300d6928
--- /dev/null
+++ b/packages/app/src/components/acp/doc-path-links.ts
@@ -0,0 +1,278 @@
+/**
+ * Turn `.md` / `.mdx` paths that appear in agent prose into in-app links to
+ * the docs they name. The resolver classifies a candidate string against
+ * three shapes, in order, and only returns a docName the workspace's page
+ * list actually contains — an unresolvable path stays plain text so we
+ * never route the user to a create-on-open blank tab (the same trap the
+ * follow-the-file predicate arms against).
+ *
+ * The three shapes agents write:
+ *
+ * 1. Absolute path with a `contentDir` prefix — the OK MCP echoes these
+ * back verbatim (e.g. `/Users/…/public/open-knowledge/reports/foo/REPORT.md`).
+ * 2. Repo-root-relative (e.g. `public/open-knowledge/reports/foo/REPORT.md`)
+ * when `contentDir` sits inside a repo — the most common case in
+ * practice.
+ * 3. Bare or nested-suffix path (e.g. `reports/foo/REPORT.md` or `REPORT.md`)
+ * resolved by longest-suffix match against the known page set. Ambiguity
+ * wins nothing: two docs ending the same way → no link, so we never
+ * route to the wrong one.
+ *
+ * The companion remark plugin walks a parsed mdast tree, replacing matched
+ * paths in `text` nodes with `link` nodes and wrapping `inlineCode` nodes
+ * whose entire value resolves so backticked paths (which agents also write)
+ * become clickable while keeping their mono styling. Fenced code blocks and
+ * anything already inside a `link` are left alone by construction.
+ */
+
+import { docNameFromAbsolutePath } from '@/components/acp/follow-file';
+import { hashFromDocName } from '@/lib/doc-hash';
+import type { Workspace } from '@/lib/workspace-paths';
+
+export type DocPathResolver = (candidate: string) => string | null;
+
+/**
+ * Path chars conservative enough that a false positive in ordinary prose is
+ * unlikely: alphanumerics, `.`, `_`, `-`, `/`, `@`. No spaces (typical for source
+ * paths agents quote) and no shell metacharacters. `\b` after the extension
+ * so a period inside a longer word (`file.mdx.txt`) doesn't match a phantom
+ * suffix. Streaming-safe: a half-arrived path simply doesn't match yet — the
+ * `\b` ensures we won't match on `foo.m` mid-stream.
+ */
+const DOC_PATH_REGEX = /(?<![A-Za-z0-9_./@-])[A-Za-z0-9_./@-]+\.(?:md|mdx)\b/g;
+
+export interface BuildDocPathResolverInput {
+ readonly workspace: Workspace | null;
+ /**
+ * The known-doc set the resolver gates existence on. Pass an empty set
+ * when the page list isn't authoritative yet — the returned resolver
+ * refuses everything rather than routing to a stale target.
+ */
+ readonly pages: ReadonlySet<string>;
+}
+
+export function buildDocPathResolver(input: BuildDocPathResolverInput): DocPathResolver | null {
+ const { workspace, pages } = input;
+ if (workspace === null || pages.size === 0) return null;
+
+ return (candidate: string): string | null => {
+ // Strip a trailing `#anchor` if present — we route to the doc, not a
+ // specific heading (the anchor would need a separate settled-scroll pass
+ // that follow-file doesn't do either). Anchor-text characters
+ // (alphanumerics, `-`) overlap the regex char class, but `#` is not —
+ // regex-matched candidates stop before `#` by construction. This
+ // explicit strip handles the `inlineCode` path, where the full node
+ // value (including any `#anchor`) arrives unfiltered.
+ const hashIdx = candidate.indexOf('#');
+ const path = (hashIdx === -1 ? candidate : candidate.slice(0, hashIdx)).replace(/^@/, '');
+ if (path === '') return null;
+
+ // Try 1: absolute path with contentDir prefix.
+ const asAbsolute = docNameFromAbsolutePath(path, workspace);
+ if (asAbsolute !== null && pages.has(asAbsolute)) return asAbsolute;
+
+ // Try 2: repo-root-relative or any path that becomes absolute when joined
+ // to the workspace's parent — the common case where `contentDir` is
+ // `<repo>/public/open-knowledge` and the agent quotes
+ // `public/open-knowledge/reports/…`. Compose the path onto the workspace's
+ // contentDir and re-run the absolute resolver; the composed string starts
+ // with contentDir by construction, so it always classifies as "inside".
+ //
+ // Priority note: this runs before Try 3's exact `pages.has(stripped)`, so a
+ // composed hit outranks an exact page-set match if `contentDir`'s last
+ // segment repeats inside the tree (e.g. contentDir ends in `docs` and a
+ // page named `docs/intro` is quoted as `docs/intro.md`). In practice the
+ // composed lookup falls back through `docNameFromAbsolutePath`'s
+ // strict-prefix check, so this only matters for the narrow case where
+ // both resolve — and when they do, the composed result equals the exact
+ // match anyway (same page, same docName).
+ const composed = joinWorkspaceRelative(workspace, path);
+ if (composed !== null) {
+ const composedDoc = docNameFromAbsolutePath(composed, workspace);
+ if (composedDoc !== null && pages.has(composedDoc)) return composedDoc;
+ }
+
+ // Try 3: longest-suffix match against the page set. Strip the extension
+ // (docNames are extension-less) and look for exactly one docName that
+ // ends with `/${stripped}` (subfolder-tail) or equals `stripped` (bare).
+ // Ambiguity — two candidates — deliberately returns null: we would rather
+ // leave a path plain than route the user to the wrong file. `pages.has()`
+ // is the sole existence + validity gate — a doc in the tracked set is
+ // user-content regardless of its dot-segment prefix (`.changeset/foo`,
+ // `.github/foo`), which is why the sanitizer from follow-the-file (built
+ // for autonomous navigation, not user-clicked links) is not applied here.
+ const stripped = stripMarkdownExt(path);
+ if (stripped === null) return null;
+ if (pages.has(stripped)) return stripped;
+ const suffix = `/${stripped}`;
+ let match: string | null = null;
+ for (const doc of pages) {
+ if (doc === stripped || doc.endsWith(suffix)) {
+ if (match !== null) return null;
+ match = doc;
+ }
+ }
+ return match;
+ };
+}
+
+/**
+ * Build an absolute-looking path from a relative one by joining against the
+ * workspace's contentDir path segments — the repo-root-relative shape (Try 2
+ * in the resolver). Handles the case where `contentDir` is `<repo>/public/…`
+ * and the agent writes `public/…`, and the general case where the relative
+ * path is a strict suffix of what contentDir already contains.
+ *
+ * Null when there's no obvious composition (e.g. paths that don't share any
+ * segments with contentDir); the resolver's suffix-match path handles those.
+ */
+function joinWorkspaceRelative(workspace: Workspace, relative: string): string | null {
+ if (relative.startsWith('/') || relative.startsWith('\\')) return null;
+ const sep = workspace.pathSeparator;
+ const normalize = (p: string): string => (sep === '\\' ? p.replaceAll('\\', '/') : p);
+ const contentDir = normalize(workspace.contentDir).replace(/\/$/, '');
+ const normalizedRel = normalize(relative);
+ const contentSegments = contentDir.split('/');
+ const relFirstSegment = normalizedRel.split('/')[0];
+ if (relFirstSegment === undefined || relFirstSegment === '') return null;
+ for (let i = contentSegments.length - 1; i >= 0; i -= 1) {
+ if (contentSegments[i] === relFirstSegment) {
+ const prefix = contentSegments.slice(0, i).join('/');
+ return prefix === '' ? `/${normalizedRel}` : `${prefix}/${normalizedRel}`;
+ }
+ }
+ return null;
+}
+
+function stripMarkdownExt(path: string): string | null {
+ const match = /\.(?:md|mdx)$/i.exec(path);
+ if (match === null) return null;
+ return path.slice(0, -match[0].length);
+}
+
+interface MdastNode {
+ type: string;
+ value?: string;
+ url?: string;
+ title?: string | null;
+ children?: MdastNode[];
+}
+
+/**
+ * Module-scoped current resolver — the plugin reads this at fire time rather
+ * than closing over a per-render argument. Streamdown's incremental parser
+ * caches transformers by identity across renders, so a plugin that closes
+ * over an early null-resolver render sticks with that null across the rest
+ * of the session (verified empirically: the closure argument is non-null at
+ * factory-call time on the render that produces the plugin, but the same
+ * transformer fires under the SAME cached processor and sees null).
+ *
+ * A singleton is a real design compromise (all AgentMarkdown instances share
+ * one resolver), but all of them derive it from the same workspace + page
+ * list, so the target value is the same everywhere. ThreadView owns the
+ * writes; AgentMarkdown instances only READ (via a React context for the
+ * ready-shape they key on).
+ */
+let currentResolver: DocPathResolver | null = null;
+
+export function setDocPathResolver(resolver: DocPathResolver | null): void {
+ currentResolver = resolver;
+}
+
+/**
+ * Remark plugin that rewrites matched `.md` / `.mdx` paths in `text` and
+ * whole-value `inlineCode` nodes into `link` nodes pointing at the OK hash
+ * router. Skips anything inside an existing `link` (double-linking would
+ * produce invalid mdast) and never descends into `code` (fenced code blocks
+ * are hands-off — they carry their content in `value`, not `children`, and
+ * a walk over `children` misses them by construction, same as
+ * `remark-hard-breaks`). A null `currentResolver` short-circuits the walk
+ * (no allocations) so AgentMarkdown pays nothing before the workspace and
+ * page list resolve.
+ */
+export function remarkDocPathLinks() {
+ // Unified's `remarkPlugins` accepts Plugin factories (`() => Transformer`),
+ // not raw Transformers. Curry through an extra layer so unified sees a
+ // Plugin at registration time and stores the Transformer in the chain.
+ return () =>
+ (tree: MdastNode): void => {
+ const resolver = currentResolver;
+ if (resolver === null) return;
+ try {
+ rewriteNode(tree, resolver);
+ } catch (err) {
+ // Never let this plugin take down markdown rendering. AgentMarkdown's
+ // ErrorBoundary otherwise catches and falls back to plain text — the
+ // whole message goes unstyled — for what is at worst a partial-linking
+ // outcome (rewriteNode mutates `node.children = next` in place as it
+ // descends, so a mid-walk throw leaves some subtrees rewritten and
+ // some not — not an untouched tree).
+ console.warn('[remarkDocPathLinks] rewrite failed, partial rewrites may remain', err);
+ }
+ };
+}
+
+function rewriteNode(node: MdastNode | undefined, resolver: DocPathResolver): void {
+ if (node === undefined || node === null) return;
+ const children = node.children;
+ if (children === undefined) return;
+ const next: MdastNode[] = [];
+ for (const child of children) {
+ if (child === undefined || child === null) continue;
+ if (child.type === 'link') {
+ next.push(child);
+ continue;
+ }
+ if (child.type === 'text' && typeof child.value === 'string') {
+ next.push(...splitTextByPaths(child.value, resolver));
+ continue;
+ }
+ if (child.type === 'inlineCode' && typeof child.value === 'string') {
+ const doc = resolver(child.value.trim());
+ if (doc === null) {
+ next.push(child);
+ } else {
+ next.push({
+ type: 'link',
+ url: hashFromDocName(doc),
+ title: null,
+ children: [child],
+ });
+ }
+ continue;
+ }
+ rewriteNode(child, resolver);
+ next.push(child);
+ }
+ node.children = next;
+}
+
+function splitTextByPaths(value: string, resolver: DocPathResolver): MdastNode[] {
+ const out: MdastNode[] = [];
+ let cursor = 0;
+ const regex = new RegExp(DOC_PATH_REGEX.source, DOC_PATH_REGEX.flags);
+ let match: RegExpExecArray | null = regex.exec(value);
+ while (match !== null) {
+ const [candidate] = match;
+ const start = match.index;
+ const doc = resolver(candidate);
+ if (doc !== null) {
+ if (start > cursor) {
+ out.push({ type: 'text', value: value.slice(cursor, start) });
+ }
+ out.push({
+ type: 'link',
+ url: hashFromDocName(doc),
+ title: null,
+ children: [{ type: 'text', value: candidate }],
+ });
+ cursor = start + candidate.length;
+ }
+ match = regex.exec(value);
+ }
+ if (cursor === 0) return [{ type: 'text', value }];
+ if (cursor < value.length) {
+ out.push({ type: 'text', value: value.slice(cursor) });
+ }
+ return out;
+}
diff --git a/packages/app/src/locales/ar/messages.json b/packages/app/src/locales/ar/messages.json
index 0f99f6d04..5fccedbf0 100644
--- a/packages/app/src/locales/ar/messages.json
+++ b/packages/app/src/locales/ar/messages.json
@@ -4155,6 +4155,7 @@
"mPy9lS": [
"نظّم مواصفاتي الحالية في فهرس مترابط مجمَّع حسب المجال، وأشِر إلى أي منها انحرف عن الكود الحالي."
],
+ "mPzgTS": ["فتح ", ["docName"]],
"mR3Bly": [
"تشمل ملفات الإعداد: <0>.ok/</0>، وإعدادات MCP لأدوات الذكاء الاصطناعي (<1>.mcp.json</1> وملفات كل أداة)، ومهارات المشروع.<2/><3>مشترك</3> يودعها في git، فيحصل كل من يستنسخ المستودع على الإعداد نفسه. <4/><5>أنا فقط</5> يبقيها خارج git (عبر <6>.git/info/exclude</6>)."
],
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index d5265b5ef..3eb258034 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -8754,6 +8754,10 @@ msgstr "فتح {basename}"
msgid "Open {displayName} Desktop"
msgstr "فتح {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "فتح {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "فتح {keyName} في المتصفح"
diff --git a/packages/app/src/locales/bn/messages.json b/packages/app/src/locales/bn/messages.json
index 84252b8d9..0705f0c68 100644
--- a/packages/app/src/locales/bn/messages.json
+++ b/packages/app/src/locales/bn/messages.json
@@ -3567,6 +3567,7 @@
"mPy9lS": [
"আমার বিদ্যমান স্পেকগুলো এলাকা অনুযায়ী গোষ্ঠীবদ্ধ একটি যুক্ত সূচিতে সাজান, এবং যেগুলো বর্তমান কোডের সঙ্গে মিল হারিয়েছে সেগুলো চিহ্নিত করুন।"
],
+ "mPzgTS": [["docName"], " খুলুন"],
"mR3Bly": [
"সেটআপ ফাইলের মধ্যে আছে: <0>.ok/</0>, AI-টুল MCP কনফিগ (<1>.mcp.json</1> ও প্রতি-টুল ফাইল), প্রকল্প স্কিল।<2/><3>ভাগ করা</3> সেগুলো git-এ কমিট করে, তাই যে-ই রিপোজিটরিটি ক্লোন করুক একই সেটআপ পায়। <4/><5>শুধু আমার</5> সেগুলো git-এর বাইরে রাখে (<6>.git/info/exclude</6>-এর মাধ্যমে)।"
],
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index 36a6207b9..8f4fa264e 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -8750,6 +8750,10 @@ msgstr "{basename} খুলুন"
msgid "Open {displayName} Desktop"
msgstr "{displayName} Desktop খুলুন"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "{docName} খুলুন"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "{keyName} ব্রাউজারে খুলুন"
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index aed929023..e51c30e04 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -3667,6 +3667,7 @@
"mPy9lS": [
"Organize my existing specs into a linked index grouped by area, and flag any that have drifted out of sync with the current code."
],
+ "mPzgTS": ["Open ", ["docName"]],
"mR3Bly": [
"Setup files include: <0>.ok/</0>, AI-tool MCP configs (<1>.mcp.json</1> and per-tool files), project skills.<2/><3>Shared</3> commits them to git, so anyone who clones the repo gets the same setup. <4/><5>Only me</5> keeps them out of git (via <6>.git/info/exclude</6>)."
],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 5b8bd5af3..f6996db6b 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -8754,6 +8754,10 @@ msgstr "Open {basename}"
msgid "Open {displayName} Desktop"
msgstr "Open {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "Open {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "Open {keyName} in browser"
diff --git a/packages/app/src/locales/es/messages.json b/packages/app/src/locales/es/messages.json
index ea733005c..be7ebcb5f 100644
--- a/packages/app/src/locales/es/messages.json
+++ b/packages/app/src/locales/es/messages.json
@@ -4247,6 +4247,7 @@
"mPy9lS": [
"Organiza mis especificaciones existentes en un índice enlazado y agrupado por área, y señala las que se hayan desincronizado del código actual."
],
+ "mPzgTS": ["Abrir ", ["docName"]],
"mR3Bly": [
"Los archivos de configuración incluyen: <0>.ok/</0>, las configuraciones MCP de las herramientas de IA (<1>.mcp.json</1> y los archivos de cada herramienta) y las habilidades del proyecto.<2/><3>Compartido</3> los guarda en git, así que quien clone el repositorio tendrá la misma configuración. <4/><5>Solo yo</5> los mantiene fuera de git (mediante <6>.git/info/exclude</6>)."
],
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index bb7ed4455..530d2414d 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -8754,6 +8754,10 @@ msgstr "Abrir {basename}"
msgid "Open {displayName} Desktop"
msgstr "Abrir {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "Abrir {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "Abrir {keyName} en el navegador"
diff --git a/packages/app/src/locales/fr/messages.json b/packages/app/src/locales/fr/messages.json
index 63ddeca8b..70072af86 100644
--- a/packages/app/src/locales/fr/messages.json
+++ b/packages/app/src/locales/fr/messages.json
@@ -4282,6 +4282,7 @@
"mPy9lS": [
"Organise mes spécifications existantes en un index lié, groupé par domaine, et signale celles qui ont divergé du code actuel."
],
+ "mPzgTS": ["Ouvrir ", ["docName"]],
"mR3Bly": [
"Les fichiers de configuration comprennent : <0>.ok/</0>, les configurations MCP des outils IA (<1>.mcp.json</1> et les fichiers propres à chaque outil), les compétences du projet.<2/><3>Partagé</3> les valide dans git, donc toute personne qui clone le dépôt obtient la même configuration. <4/><5>Moi uniquement</5> les tient à l'écart de git (via <6>.git/info/exclude</6>)."
],
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 5e77c40f3..62421df2d 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -8754,6 +8754,10 @@ msgstr "Ouvrir {basename}"
msgid "Open {displayName} Desktop"
msgstr "Ouvrir {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "Ouvrir {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "Ouvrir {keyName} dans le navigateur"
diff --git a/packages/app/src/locales/hi/messages.json b/packages/app/src/locales/hi/messages.json
index 36cb1e19e..a536b33c8 100644
--- a/packages/app/src/locales/hi/messages.json
+++ b/packages/app/src/locales/hi/messages.json
@@ -3558,6 +3558,7 @@
"mPy9lS": [
"मेरी मौजूदा स्पेक को क्षेत्र के अनुसार समूहित एक जुड़ी हुई अनुक्रमणिका में व्यवस्थित करें, और जो मौजूदा कोड से तालमेल खो चुकी हों उन्हें चिह्नित करें।"
],
+ "mPzgTS": [["docName"], " खोलें"],
"mR3Bly": [
"सेटअप फ़ाइलों में शामिल हैं: <0>.ok/</0>, AI-टूल MCP कॉन्फ़िग (<1>.mcp.json</1> और प्रति-टूल फ़ाइलें), प्रोजेक्ट स्किल।<2/><3>साझा</3> उन्हें git में कमिट करता है, इसलिए जो भी रिपॉज़िटरी क्लोन करता है उसे वही सेटअप मिलता है। <4/><5>केवल मेरे लिए</5> उन्हें git से बाहर रखता है (<6>.git/info/exclude</6> के ज़रिए)।"
],
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index c05805543..04290ec60 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -8750,6 +8750,10 @@ msgstr "{basename} खोलें"
msgid "Open {displayName} Desktop"
msgstr "{displayName} Desktop खोलें"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "{docName} खोलें"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "{keyName} को ब्राउज़र में खोलें"
diff --git a/packages/app/src/locales/id/messages.json b/packages/app/src/locales/id/messages.json
index bfc2f858e..b1fbc133a 100644
--- a/packages/app/src/locales/id/messages.json
+++ b/packages/app/src/locales/id/messages.json
@@ -3712,6 +3712,7 @@
"mPy9lS": [
"Tata spesifikasi saya yang sudah ada menjadi indeks tertaut yang dikelompokkan per bidang, dan tandai mana saja yang sudah tidak selaras dengan kode saat ini."
],
+ "mPzgTS": ["Buka ", ["docName"]],
"mR3Bly": [
"Berkas penyiapan mencakup: <0>.ok/</0>, konfigurasi MCP alat AI (<1>.mcp.json</1> dan berkas tiap alat), keterampilan proyek.<2/><3>Dibagikan</3> melakukan commit ke git, jadi siapa pun yang mengkloning repo mendapat penyiapan yang sama. <4/><5>Hanya saya</5> menahannya keluar dari git (lewat <6>.git/info/exclude</6>)."
],
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index 9edc45322..a17d4e8d7 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -8750,6 +8750,10 @@ msgstr "Buka {basename}"
msgid "Open {displayName} Desktop"
msgstr "Buka {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "Buka {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "Buka {keyName} di peramban"
diff --git a/packages/app/src/locales/ko/messages.json b/packages/app/src/locales/ko/messages.json
index 49cccafdc..38bdfb1e8 100644
--- a/packages/app/src/locales/ko/messages.json
+++ b/packages/app/src/locales/ko/messages.json
@@ -3544,6 +3544,7 @@
"mPy9lS": [
"기존 사양을 영역별로 그룹화한 연결된 색인으로 정리하고, 현재 코드와 동기화되지 않은 항목을 표시합니다."
],
+ "mPzgTS": [["docName"], " 열기"],
"mR3Bly": [
"설정 파일에는 <0>.ok/</0>, AI 도구 MCP 구성(<1>.mcp.json</1> 및 도구별 파일), 프로젝트 스킬이 포함됩니다.<2/><3>공유</3>는 이를 git에 커밋하므로 리포지토리를 클론하는 누구나 동일한 설정을 받습니다. <4/><5>나만 보기</5>는 <6>.git/info/exclude</6>를 통해 git에서 제외합니다."
],
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 505f36120..5749a8dea 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -8754,6 +8754,10 @@ msgstr "{basename} 열기"
msgid "Open {displayName} Desktop"
msgstr "{displayName} Desktop 열기"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "{docName} 열기"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "브라우저에서 {keyName} 열기"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index d0ac7d630..5b8906847 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -3667,6 +3667,7 @@
"mPy9lS": [
"Ōŕĝàńĩźē ḿŷ ēxĩśţĩńĝ śƥēćś ĩńţō à ĺĩńķēď ĩńďēx ĝŕōũƥēď ƀŷ àŕēà, àńď ƒĺàĝ àńŷ ţĥàţ ĥàvē ďŕĩƒţēď ōũţ ōƒ śŷńć ŵĩţĥ ţĥē ćũŕŕēńţ ćōďē."
],
+ "mPzgTS": ["Ōƥēń ", ["docName"]],
"mR3Bly": [
"Śēţũƥ ƒĩĺēś ĩńćĺũďē: <0>.ōķ/</0>, ÀĨ-ţōōĺ ḾĆƤ ćōńƒĩĝś (<1>.ḿćƥ.Ĵśōń</1> àńď ƥēŕ-ţōōĺ ƒĩĺēś), ƥŕōĴēćţ śķĩĺĺś.<2/><3>Śĥàŕēď</3> ćōḿḿĩţś ţĥēḿ ţō ĝĩţ, śō àńŷōńē ŵĥō ćĺōńēś ţĥē ŕēƥō ĝēţś ţĥē śàḿē śēţũƥ. <4/><5>Ōńĺŷ ḿē</5> ķēēƥś ţĥēḿ ōũţ ōƒ ĝĩţ (vĩà <6>.ĝĩţ/ĩńƒō/ēxćĺũďē</6>)."
],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 6e1718a84..aebdc9f95 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -8750,6 +8750,10 @@ msgstr ""
msgid "Open {displayName} Desktop"
msgstr ""
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr ""
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr ""
diff --git a/packages/app/src/locales/pt-BR/messages.json b/packages/app/src/locales/pt-BR/messages.json
index 85515e6e7..1c4442f17 100644
--- a/packages/app/src/locales/pt-BR/messages.json
+++ b/packages/app/src/locales/pt-BR/messages.json
@@ -4161,6 +4161,7 @@
"mPy9lS": [
"Organize minhas especificações existentes em um índice interligado e agrupado por área, e sinalize as que se desencontraram do código atual."
],
+ "mPzgTS": ["Abrir ", ["docName"]],
"mR3Bly": [
"Os arquivos de configuração incluem: <0>.ok/</0>, as configurações MCP das ferramentas de IA (<1>.mcp.json</1> e os arquivos de cada ferramenta) e as habilidades do projeto.<2/><3>Compartilhado</3> faz commit deles no git, então quem clonar o repositório recebe a mesma configuração. <4/><5>Somente eu</5> mantém tudo fora do git (via <6>.git/info/exclude</6>)."
],
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index fbc82ec4c..d3934ecc2 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -8750,6 +8750,10 @@ msgstr "Abrir {basename}"
msgid "Open {displayName} Desktop"
msgstr "Abrir {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "Abrir {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "Abrir {keyName} no navegador"
diff --git a/packages/app/src/locales/ur/messages.json b/packages/app/src/locales/ur/messages.json
index b840a502c..6797621bb 100644
--- a/packages/app/src/locales/ur/messages.json
+++ b/packages/app/src/locales/ur/messages.json
@@ -3761,6 +3761,7 @@
"mPy9lS": [
"میری موجودہ اسپیکس کو شعبے کے لحاظ سے گروپ شدہ ایک مربوط اشاریے میں منظم کریں، اور ان میں سے کسی کو نشان زد کریں جو موجودہ کوڈ سے ہم آہنگ نہ رہی ہو۔"
],
+ "mPzgTS": [["docName"], " کھولیں"],
"mR3Bly": [
"سیٹ اپ کی فائلوں میں شامل ہیں: <0>.ok/</0>، AI ٹولز کی MCP کنفیگز (<1>.mcp.json</1> اور ہر ٹول کی فائلیں)، اور پروجیکٹ کی مہارتیں۔<2/><3>مشترک</3> انہیں git میں کمٹ کرتا ہے، تاکہ جو بھی ریپو کلون کرے اسے وہی سیٹ اپ ملے۔ <4/><5>صرف میں</5> انہیں git سے باہر رکھتا ہے (<6>.git/info/exclude</6> کے ذریعے)۔"
],
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 2c3d18bfd..6aa0c0944 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -8754,6 +8754,10 @@ msgstr "{basename} کھولیں"
msgid "Open {displayName} Desktop"
msgstr "{displayName} Desktop کھولیں"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "{docName} کھولیں"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "{keyName} براؤزر میں کھولیں"
diff --git a/packages/app/src/locales/zh-Hans/messages.json b/packages/app/src/locales/zh-Hans/messages.json
index 9c1765dd6..942b87d4f 100644
--- a/packages/app/src/locales/zh-Hans/messages.json
+++ b/packages/app/src/locales/zh-Hans/messages.json
@@ -3261,6 +3261,7 @@
"mHf8mp": ["删除架构文件 ", ["file"]],
"mLAjyL": ["让你使用的 AI 工具能够读取和更新你的项目。勾选即刻生效;取消勾选则移除。"],
"mPy9lS": ["把我现有的规格整理成一个按领域分组的链接索引,并标出与当前代码脱节的部分。"],
+ "mPzgTS": ["打开 ", ["docName"]],
"mR3Bly": [
"配置文件包括:<0>.ok/</0>、AI 工具的 MCP 配置(<1>.mcp.json</1> 及各工具自己的文件)、项目技能。<2/><3>共享</3>会把它们提交到 git,因此克隆这个仓库的人都会得到相同的配置。<4/><5>仅自己</5>会把它们排除在 git 之外(通过 <6>.git/info/exclude</6>)。"
],
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index ddafc59d9..2c04c51ff 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -8754,6 +8754,10 @@ msgstr "打开 {basename}"
msgid "Open {displayName} Desktop"
msgstr "打开 {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "打开 {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "在浏览器中打开 {keyName}"
diff --git a/packages/app/src/locales/zh-Hant/messages.json b/packages/app/src/locales/zh-Hant/messages.json
index 80d96945d..807b919fa 100644
--- a/packages/app/src/locales/zh-Hant/messages.json
+++ b/packages/app/src/locales/zh-Hant/messages.json
@@ -3289,6 +3289,7 @@
"mHf8mp": ["刪除結構描述檔案 ", ["file"]],
"mLAjyL": ["讓你用的 AI 工具能夠讀取和更新你的專案。勾選就會立刻設定好;取消勾選則會移除。"],
"mPy9lS": ["把我現有的規格整理成一個依領域分組的連結索引,並標出和目前程式碼已經脫節的部分。"],
+ "mPzgTS": ["開啟 ", ["docName"]],
"mR3Bly": [
"設定檔案包括:<0>.ok/</0>、AI 工具的 MCP 設定(<1>.mcp.json</1> 以及各工具自己的檔案)、專案技能。<2/><3>已分享</3>會把它們提交到 git,所以複製這個儲存庫的人都會得到相同的設定。<4/><5>僅自己</5>會把它們排除在 git 之外(透過 <6>.git/info/exclude</6>)。"
],
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index 99dc36a91..fbde014a4 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -8754,6 +8754,10 @@ msgstr "開啟 {basename}"
msgid "Open {displayName} Desktop"
msgstr "開啟 {displayName} Desktop"
+#: src/components/acp/AgentMarkdown.tsx
+msgid "Open {docName}"
+msgstr "開啟 {docName}"
+
#: src/components/PropertyWidgets.tsx
msgid "Open {keyName} in browser"
msgstr "在瀏覽器中開啟 {keyName}"