Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(docs): put Docs behind the docs_v1 feature flag (MUL-9645) (#10970)
Bohan Jiange6507d78471b
diff --git a/.env.example b/.env.exampleindex b07e27e006..15839005d8 100644--- a/.env.example+++ b/.env.example@@ -224,6 +224,11 @@ MULTICA_FEATURE_FLAGS_FILE=# and search through the server again:# FF_LOCAL_SEARCH_INDEX=off+# Docs (MUL-8370) stays off until it launches: its API answers 403, Web and+# Desktop hide its entry points, and agent briefs leave out `multica doc`.+# Turn it on for a deployment that is testing it:+# FF_DOCS_V1=true+# Workspace subscription Checkout/Portal/entitlement proxying is fail-closed;# enable it only after multica-cloud billing.subscriptions is configured:# FF_BILLING_WORKSPACE_SUBSCRIPTIONS=truediff --git a/e2e/docs.spec.ts b/e2e/docs.spec.tsindex 952de167bb..68502afe7f 100644--- a/e2e/docs.spec.ts+++ b/e2e/docs.spec.ts@@ -1,4 +1,5 @@import { test, expect, type FileChooser } from "@playwright/test";+// Docs sits behind the docs_v1 flag: run the server with FF_DOCS_V1=true.import { TestApiClient } from "./fixtures";let api: TestApiClient;diff --git a/packages/core/feature-flags/index.ts b/packages/core/feature-flags/index.tsindex 4683dcb667..ce64dc85e0 100644--- a/packages/core/feature-flags/index.ts+++ b/packages/core/feature-flags/index.ts@@ -20,6 +20,7 @@ export { ChainProvider } from "./chain-provider";export {BILLING_WORKSPACE_SUBSCRIPTIONS_FLAG,COMPOSIO_MCP_APPS_FLAG,+ DOCS_V1_FLAG,PLUGINS_V1_FLAG,} from "./keys";export {diff --git a/packages/core/feature-flags/keys.ts b/packages/core/feature-flags/keys.tsindex db0dd7123d..ba566c24af 100644--- a/packages/core/feature-flags/keys.ts+++ b/packages/core/feature-flags/keys.ts@@ -1,4 +1,5 @@export const COMPOSIO_MCP_APPS_FLAG = "composio_mcp_apps";export const PLUGINS_V1_FLAG = "plugins_v1";+export const DOCS_V1_FLAG = "docs_v1";export const BILLING_WORKSPACE_SUBSCRIPTIONS_FLAG ="billing_workspace_subscriptions";diff --git a/packages/views/docs/components/doc-history-page.tsx b/packages/views/docs/components/doc-history-page.tsxindex 16c214524e..237209d0ca 100644--- a/packages/views/docs/components/doc-history-page.tsx+++ b/packages/views/docs/components/doc-history-page.tsx@@ -16,7 +16,16 @@ import { ReadonlyContent } from "../../editor";import { BreadcrumbHeader } from "../../layout/breadcrumb-header";import { useNavigation } from "../../navigation";import { useT } from "../../i18n";+import { DocsGate } from "./docs-gate";export function DocHistoryPage({ docId }: { docId: string }) {+ return (+ <DocsGate>+ <DocHistoryPageContent docId={docId} />+ </DocsGate>+ );+}++function DocHistoryPageContent({ docId }: { docId: string }) {const { t } = useT("docs");const wsId = useWorkspaceId();const p = useWorkspacePaths();diff --git a/packages/views/docs/components/doc-mention-card.tsx b/packages/views/docs/components/doc-mention-card.tsxindex 9c172deceb..e8e936ddd4 100644--- a/packages/views/docs/components/doc-mention-card.tsx+++ b/packages/views/docs/components/doc-mention-card.tsx@@ -3,7 +3,9 @@import { useQuery } from "@tanstack/react-query";import { FileText } from "@multica/ui/icons";import { cn } from "@multica/ui/lib/utils";+import { useFeatureEnabled } from "@multica/core/config";import { docTreeOptions } from "@multica/core/docs";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { useWorkspaceId } from "@multica/core/hooks";import { useWorkspacePaths } from "@multica/core/paths";import { AppLink } from "../../navigation";@@ -26,7 +28,10 @@ export function DocMentionCard({const wsId = useWorkspaceId();const p = useWorkspacePaths();const { t } = useT("docs");- const { data: tree } = useQuery(docTreeOptions(wsId));+ // While docs_v1 is off the chip keeps its saved label instead of asking a+ // server that answers 403.+ const docsEnabled = useFeatureEnabled(DOCS_V1_FLAG, false);+ const { data: tree } = useQuery({ ...docTreeOptions(wsId), enabled: docsEnabled });const doc = tree?.docs.find((d) => d.id === docId);const title = doc? doc.title || t(($) => $.untitled)diff --git a/packages/views/docs/components/doc-page.tsx b/packages/views/docs/components/doc-page.tsxindex 9fbe5e29da..711de37169 100644--- a/packages/views/docs/components/doc-page.tsx+++ b/packages/views/docs/components/doc-page.tsx@@ -41,7 +41,16 @@ import { DocOutline, MIN_OUTLINE_HEADINGS, useDocOutline } from "./doc-outline";import { MoveDialog } from "./move-dialog";import { DeleteDocDialog } from "./doc-tree";import { useCanDeleteDoc } from "./use-can-delete-doc";+import { DocsGate } from "./docs-gate";export function DocPage({ docId }: { docId: string }) {+ return (+ <DocsGate>+ <DocPageContent docId={docId} />+ </DocsGate>+ );+}++function DocPageContent({ docId }: { docId: string }) {const wsId = useWorkspaceId();const { t } = useT("docs");const query = useQuery(docDetailOptions(wsId, docId));diff --git a/packages/views/docs/components/docs-gate.test.tsx b/packages/views/docs/components/docs-gate.test.tsxnew file mode 100644index 0000000000..487d031be1--- /dev/null+++ b/packages/views/docs/components/docs-gate.test.tsx@@ -0,0 +1,24 @@+import { act, screen } from "@testing-library/react";+import { beforeEach, describe, expect, it } from "vitest";+import { configStore } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";+import { renderWithI18n } from "../../test/i18n";+import { DocsGate } from "./docs-gate";++describe("DocsGate", () => {+ beforeEach(() => {+ configStore.getState().setFeatureFlags({});+ });++ it("shows an empty state instead of the page while docs_v1 is off", () => {+ renderWithI18n(<DocsGate><p>doc page</p></DocsGate>);+ expect(screen.queryByText("doc page")).toBeNull();+ expect(screen.getByText("Docs isn't available here")).toBeTruthy();+ });++ it("renders the page once the server config turns docs_v1 on", () => {+ renderWithI18n(<DocsGate><p>doc page</p></DocsGate>);+ act(() => configStore.getState().setFeatureFlags({ [DOCS_V1_FLAG]: true }));+ expect(screen.getByText("doc page")).toBeTruthy();+ });+});diff --git a/packages/views/docs/components/docs-gate.tsx b/packages/views/docs/components/docs-gate.tsxnew file mode 100644index 0000000000..1d5a886b93--- /dev/null+++ b/packages/views/docs/components/docs-gate.tsx@@ -0,0 +1,26 @@+"use client";+import { useFeatureEnabled } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";+import { FileText } from "@multica/ui/icons";+import { CollectionPageState } from "../../layout/collection-page";+import { useT } from "../../i18n";++/**+ * Renders the Docs pages only while the server's docs_v1 flag is on. A+ * typed or restored /docs URL otherwise lands on an empty state instead of a+ * page whose requests the server answers 403 docs_disabled.+ */+export function DocsGate({ children }: { children: React.ReactNode }) {+ const { t } = useT("docs");+ const enabled = useFeatureEnabled(DOCS_V1_FLAG, false);+ if (enabled) return <>{children}</>;+ return (+ <div className="flex h-full min-h-0 flex-col justify-center">+ <CollectionPageState+ icon={FileText}+ title={t(($) => $.unavailable.title)}+ description={t(($) => $.unavailable.description)}+ />+ </div>+ );+}diff --git a/packages/views/docs/components/docs-home-page.tsx b/packages/views/docs/components/docs-home-page.tsxindex e0c49eb1a0..2a41b021ee 100644--- a/packages/views/docs/components/docs-home-page.tsx+++ b/packages/views/docs/components/docs-home-page.tsx@@ -8,11 +8,20 @@ import { Button } from "@multica/ui/components/ui/button";import { PageHeader } from "../../layout/page-header";import { AppLink } from "../../navigation";import { useT } from "../../i18n";+import { DocsGate } from "./docs-gate";export function DocsHomePage({folderId = null,}: {folderId?: string | null;}) {+ return (+ <DocsGate>+ <DocsHomePageContent folderId={folderId} />+ </DocsGate>+ );+}++function DocsHomePageContent({ folderId }: { folderId: string | null }) {const { t } = useT("docs");const wsId = useWorkspaceId();const p = useWorkspacePaths();diff --git a/packages/views/editor/extensions/mention-suggestion.doc-load.test.tsx b/packages/views/editor/extensions/mention-suggestion.doc-load.test.tsxindex 69b2b1247a..9e61399263 100644--- a/packages/views/editor/extensions/mention-suggestion.doc-load.test.tsx+++ b/packages/views/editor/extensions/mention-suggestion.doc-load.test.tsx@@ -6,7 +6,9 @@ import { EditorContent } from "@tiptap/react";import StarterKit from "@tiptap/starter-kit";import { Suggestion } from "@tiptap/suggestion";import { I18nProvider } from "@multica/core/i18n/react";+import { configStore } from "@multica/core/config";import { docKeys } from "@multica/core/docs";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { createMentionSuggestion } from "./mention-suggestion";import { SuggestionTriggerArmingExtension } from "./suggestion-trigger-arming";import enDocs from "../../locales/en/docs.json";@@ -57,6 +59,7 @@ let qc: QueryClient;let editor: Editor | undefined;beforeEach(() => {vi.clearAllMocks();+ configStore.getState().setFeatureFlags({ [DOCS_V1_FLAG]: true });qc = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } });apiMock.listDocTree.mockResolvedValue(tree);apiMock.searchIssues.mockResolvedValue({ issues: [] });diff --git a/packages/views/editor/extensions/mention-suggestion.test.tsx b/packages/views/editor/extensions/mention-suggestion.test.tsxindex 761c5e40a0..6d414ca9c6 100644--- a/packages/views/editor/extensions/mention-suggestion.test.tsx+++ b/packages/views/editor/extensions/mention-suggestion.test.tsx@@ -4,7 +4,9 @@ import { describe, it, expect, vi, beforeEach } from "vitest";import { workspaceKeys } from "@multica/core/workspace/queries";import { issueKeys, PAGINATED_CATEGORIES } from "@multica/core/issues/queries";import { projectKeys } from "@multica/core/projects/queries";+import { configStore } from "@multica/core/config";import { docKeys } from "@multica/core/docs";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { statusCategoryOfKey } from "@multica/core/issues";import { I18nProvider } from "@multica/core/i18n/react";import type { IssueStatusCategory, ListIssuesCache } from "@multica/core/types";@@ -216,6 +218,7 @@ describe("createMentionSuggestion", () => {searchProjectsMock.mockReset();searchProjectsMock.mockResolvedValue({ projects: [], total: 0 });Element.prototype.scrollIntoView = vi.fn();+ configStore.getState().setFeatureFlags({ [DOCS_V1_FLAG]: true });});it("keeps the mention query active across spaces for multi-word search", () => {@@ -530,6 +533,27 @@ describe("createMentionSuggestion", () => {);});+ it("offers no docs and loads no doc tree while docs_v1 is off", () => {+ configStore.getState().setFeatureFlags({});+ const qc = fakeQc({});+ const getQueryData = qc.getQueryData.bind(qc);+ qc.getQueryData = ((key: readonly unknown[]) =>+ JSON.stringify(key) === JSON.stringify(docKeys.tree("ws-1"))+ ? undefined+ : getQueryData(key)) as QueryClient["getQueryData"];++ const items = createMentionSuggestion(qc).items!(itemArgs("")) as MentionItem[];++ expect(items.filter((item) => item.type === "doc")).toEqual([]);+ expect(qc.prefetchQuery).not.toHaveBeenCalled();++ const cached = fakeQc({+ docs: [{ id: "d-runbook", title: "Release runbook", updatedAt: "2026-11-01T00:00:00Z" }],+ });+ const offered = createMentionSuggestion(cached).items!(itemArgs("runbook")) as MentionItem[];+ expect(offered.filter((item) => item.type === "doc")).toEqual([]);+ });+it("shows docs in their own section", () => {render(<I18nWrapper>diff --git a/packages/views/editor/extensions/mention-suggestion.tsx b/packages/views/editor/extensions/mention-suggestion.tsxindex b8da417574..2d00efdc7e 100644--- a/packages/views/editor/extensions/mention-suggestion.tsx+++ b/packages/views/editor/extensions/mention-suggestion.tsx@@ -17,7 +17,9 @@ import { issueStatusCategory } from "@multica/core/issues";import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import { workspaceKeys } from "@multica/core/workspace/queries";import { projectKeys } from "@multica/core/projects/queries";+import { configStore, featureFlagEnabled } from "@multica/core/config";import { docKeys, docTreeOptions } from "@multica/core/docs";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { useAuthStore } from "@multica/core/auth";import { canAssignAgentToIssue } from "@multica/core/permissions";import { isAgentRuntimeBound } from "@multica/core/agents";@@ -779,6 +781,11 @@ function projectToMention(p: {};}+/** Whether the `@` menu offers docs: the server's docs_v1 flag. */+function docsEnabled(): boolean {+ return featureFlagEnabled(configStore.getState().featureFlags, DOCS_V1_FLAG);+}+/*** Docs a mention query offers: title matches (substring or pinyin), or the most* recently updated docs before anything is typed. Untitled docs are skipped —@@ -949,9 +956,13 @@ export function createMentionSuggestion(// Docs come from the workspace doc tree. A session that has not opened// Docs yet loads it on this first `@`; docs join from the next keystroke.- const docTree = qc.getQueryData<DocTree>(docKeys.tree(wsId));- if (!docTree) void qc.prefetchQuery(docTreeOptions(wsId));- const docItems = matchDocMentions(docTree?.docs ?? [], query);+ // None while docs_v1 is off.+ let docItems: MentionItem[] = [];+ if (docsEnabled()) {+ const docTree = qc.getQueryData<DocTree>(docKeys.tree(wsId));+ if (!docTree) void qc.prefetchQuery(docTreeOptions(wsId));+ docItems = matchDocMentions(docTree?.docs ?? [], query);+ }return [...allItem, ...userItems, ...issueItems, ...projectItems, ...docItems];}@@ -960,7 +971,7 @@ export function createMentionSuggestion(// keystroke) predates. Selection survives: MentionList pins it by identity.function withCachedDocs(items: MentionItem[], query: string): MentionItem[] {const wsId = getCurrentWsId();- const docTree = wsId ? qc.getQueryData<DocTree>(docKeys.tree(wsId)) : undefined;+ const docTree = wsId && docsEnabled() ? qc.getQueryData<DocTree>(docKeys.tree(wsId)) : undefined;if (!docTree) return items;const listed = new Set(items.filter((item) => item.type === "doc").map((item) => item.id));const fresh = matchDocMentions(docTree.docs, query).filter((doc) => !listed.has(doc.id));diff --git a/packages/views/layout/app-rail.test.tsx b/packages/views/layout/app-rail.test.tsxindex b7ab1ce369..f77c62b982 100644--- a/packages/views/layout/app-rail.test.tsx+++ b/packages/views/layout/app-rail.test.tsx@@ -2,6 +2,8 @@ import type { ReactNode } from "react";import { act, fireEvent, screen, waitFor, within } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { configStore } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { useRailOrderStore } from "@multica/core/navigation";import {DEFAULT_SIDEBAR_INBOX_SETTINGS,@@ -148,6 +150,7 @@ beforeEach(() => {state.markAllInboxRead.mockReset();state.markAllChatsRead.mockReset();useRailOrderStore.setState({ order: null });+ configStore.getState().setFeatureFlags({ [DOCS_V1_FLAG]: true });useSidebarTreeStore.setState({ inboxSettings: DEFAULT_SIDEBAR_INBOX_SETTINGS });});@@ -175,6 +178,15 @@ describe("AppRail order", () => {expect(railOrder()).toEqual(order);});+ it("leaves Docs out while docs_v1 is off, keeping its saved place", () => {+ const order = ["chat", "docs", "work", "team", "autopilots"] as const;+ useRailOrderStore.getState().setOrder(order);+ configStore.getState().setFeatureFlags({});+ renderRail();+ expect(railOrder()).toEqual(["chat", "work", "team", "autopilots"]);+ expect(useRailOrderStore.getState().order).toEqual(order);+ });+// dnd-kit stops the release's click at the document without cancelling// it, so the link would navigate natively even though React never sees it.it("does not open the space released at the end of a drag", async () => {diff --git a/packages/views/layout/app-rail.tsx b/packages/views/layout/app-rail.tsxindex 4588cd3b8e..6a12bef65e 100644--- a/packages/views/layout/app-rail.tsx+++ b/packages/views/layout/app-rail.tsx@@ -19,6 +19,8 @@ import { useChatStore } from "@multica/core/chat";import { useMarkAllChatSessionsRead } from "@multica/core/chat/mutations";import { chatSessionsOptions } from "@multica/core/chat/queries";import { countUnreadChatMessages } from "@multica/core/chat/unread";+import { useFeatureEnabled } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import {deduplicateInboxItems,inboxListOptions,@@ -366,6 +368,13 @@ export function AppRail({const savedOrder = useRailOrderStore((s) => s.order);const setOrder = useRailOrderStore((s) => s.setOrder);const order = useMemo(() => resolveRailOrder(savedOrder), [savedOrder]);+ // Docs stays in the saved order while docs_v1 is off, so it comes back in+ // place when the flag is turned on; it is only left out of what renders.+ const docsEnabled = useFeatureEnabled(DOCS_V1_FLAG, false);+ const visibleOrder = useMemo(+ () => (docsEnabled ? order : order.filter((id) => id !== "docs")),+ [docsEnabled, order],+ );const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));const { arm: armClickGuard, release: releaseClickGuard } = useDragClickGuard();@@ -442,9 +451,9 @@ export function AppRail({onDragEnd={onDragEnd}onDragCancel={releaseClickGuard}>- <SortableContext items={order} strategy={verticalListSortingStrategy}>+ <SortableContext items={visibleOrder} strategy={verticalListSortingStrategy}><ul className="flex flex-col items-center gap-0.5">- {order.map((id) => (+ {visibleOrder.map((id) => (<SortableRailItem key={id} id={id}><RailSpaceLinkspace={id}diff --git a/packages/views/layout/app-shell-context.tsx b/packages/views/layout/app-shell-context.tsxindex 3a11c4565f..ef613cdba0 100644--- a/packages/views/layout/app-shell-context.tsx+++ b/packages/views/layout/app-shell-context.tsx@@ -2,6 +2,8 @@import { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";import { spaceForPath, type AppSpaceId } from "@multica/core/paths";+import { useFeatureEnabled } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { useSidebarSafe } from "@multica/ui/components/ui/sidebar";import { useNavigation } from "../navigation";@@ -73,7 +75,8 @@ export function AppShellProvider({// Keyed by `${workspaceSlug}/${space}`. The fragment is left out so a// comment deep link is not replayed on every return to the space.const [spaceUrls, setSpaceUrls] = useState<Record<string, string>>({});- const hasPanel = space !== null && PANEL_SPACES.has(space);+ const docsEnabled = useFeatureEnabled(DOCS_V1_FLAG, false);+ const hasPanel = space !== null && PANEL_SPACES.has(space) && (space !== "docs" || docsEnabled);const [listCollapsed, setListCollapsed] = useState(false);const [peekSpace, setPeekSpace] = useState<AppSpaceId | null>(null);const openTimer = useRef<ReturnType<typeof setTimeout> | null>(null);diff --git a/packages/views/locales/en/docs.json b/packages/views/locales/en/docs.jsonindex e29d3bc1f0..f22fb192c3 100644--- a/packages/views/locales/en/docs.json+++ b/packages/views/locales/en/docs.json@@ -57,5 +57,9 @@},"edited": "Edited {{time}}","outline": "Outline",- "link_copied": "Link copied"+ "link_copied": "Link copied",+ "unavailable": {+ "title": "Docs isn't available here",+ "description": "This workspace doesn't have Docs turned on."+ }}diff --git a/packages/views/locales/es/docs.json b/packages/views/locales/es/docs.jsonindex 46981a3dd9..d81faeeec6 100644--- a/packages/views/locales/es/docs.json+++ b/packages/views/locales/es/docs.json@@ -57,5 +57,9 @@},"edited": "Editado {{time}}","outline": "Esquema",- "link_copied": "Enlace copiado"+ "link_copied": "Enlace copiado",+ "unavailable": {+ "title": "Documentos no está disponible",+ "description": "Este espacio de trabajo no tiene Documentos activado."+ }}diff --git a/packages/views/locales/fr/docs.json b/packages/views/locales/fr/docs.jsonindex fd1f81ce7c..f7f48ca405 100644--- a/packages/views/locales/fr/docs.json+++ b/packages/views/locales/fr/docs.json@@ -57,5 +57,9 @@},"edited": "Modifié {{time}}","outline": "Plan",- "link_copied": "Lien copié"+ "link_copied": "Lien copié",+ "unavailable": {+ "title": "Documents n'est pas disponible",+ "description": "Documents n'est pas activé dans cet espace de travail."+ }}diff --git a/packages/views/locales/ja/docs.json b/packages/views/locales/ja/docs.jsonindex 2eb00706d4..073929391b 100644--- a/packages/views/locales/ja/docs.json+++ b/packages/views/locales/ja/docs.json@@ -57,5 +57,9 @@},"edited": "最終編集 {{time}}","outline": "目次",- "link_copied": "リンクをコピーしました"+ "link_copied": "リンクをコピーしました",+ "unavailable": {+ "title": "ドキュメントはまだ利用できません",+ "description": "このワークスペースではドキュメントが有効になっていません。"+ }}diff --git a/packages/views/locales/ko/docs.json b/packages/views/locales/ko/docs.jsonindex 5092a75ecf..9129dd1ab4 100644--- a/packages/views/locales/ko/docs.json+++ b/packages/views/locales/ko/docs.json@@ -57,5 +57,9 @@},"edited": "{{time}} 편집","outline": "개요",- "link_copied": "링크를 복사했습니다"+ "link_copied": "링크를 복사했습니다",+ "unavailable": {+ "title": "문서를 아직 사용할 수 없습니다",+ "description": "이 워크스페이스에서는 문서가 켜져 있지 않습니다."+ }}diff --git a/packages/views/locales/ru/docs.json b/packages/views/locales/ru/docs.jsonindex 1a1a76d59b..47e36cfb44 100644--- a/packages/views/locales/ru/docs.json+++ b/packages/views/locales/ru/docs.json@@ -57,5 +57,9 @@},"edited": "Изменено {{time}}","outline": "Содержание",- "link_copied": "Ссылка скопирована"+ "link_copied": "Ссылка скопирована",+ "unavailable": {+ "title": "Документы недоступны",+ "description": "В этом рабочем пространстве документы не включены."+ }}diff --git a/packages/views/locales/zh-Hans/docs.json b/packages/views/locales/zh-Hans/docs.jsonindex 6e6f4dd959..1aa5ef01b2 100644--- a/packages/views/locales/zh-Hans/docs.json+++ b/packages/views/locales/zh-Hans/docs.json@@ -57,5 +57,9 @@},"edited": "{{time}}编辑","outline": "大纲",- "link_copied": "链接已复制"+ "link_copied": "链接已复制",+ "unavailable": {+ "title": "知识库暂未开放",+ "description": "当前工作区尚未开启知识库。"+ }}diff --git a/packages/views/locales/zh-Hant/docs.json b/packages/views/locales/zh-Hant/docs.jsonindex 6155d05404..3eb99e8a72 100644--- a/packages/views/locales/zh-Hant/docs.json+++ b/packages/views/locales/zh-Hant/docs.json@@ -57,5 +57,9 @@},"edited": "{{time}}編輯","outline": "大綱",- "link_copied": "連結已複製"+ "link_copied": "連結已複製",+ "unavailable": {+ "title": "知識庫暫未開放",+ "description": "目前工作區尚未開啟知識庫。"+ }}diff --git a/packages/views/search/search-command.test.tsx b/packages/views/search/search-command.test.tsxindex 96c19890d1..daf6afe89c 100644--- a/packages/views/search/search-command.test.tsx+++ b/packages/views/search/search-command.test.tsx@@ -13,7 +13,9 @@ import { inboxUnreadSummaryOptions } from "@multica/core/inbox/queries";import { useActiveIssueViewStore } from "@multica/core/issue-views/active-view-store";import { issueViewEverywhereOptions } from "@multica/core/issue-views/queries";import { projectListOptions } from "@multica/core/projects/queries";+import { configStore } from "@multica/core/config";import { docTreeOptions } from "@multica/core/docs";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { I18nProvider } from "@multica/core/i18n/react";import { issueDetailOptions, issueTimelineOptions } from "@multica/core/issues/queries";import { WORKSPACE_PAGES } from "@multica/core/paths";@@ -372,6 +374,7 @@ describe("SearchCommand", () => {apiFns.set("searchIssues", vi.fn(() => Promise.resolve({ issues: [], total: 0 })));apiFns.set("searchProjects", vi.fn(() => Promise.resolve({ projects: [], total: 0 })));apiFns.set("searchDocs", vi.fn(() => Promise.resolve({ docs: [] })));+ configStore.getState().setFeatureFlags({ [DOCS_V1_FLAG]: true });mockPush.mockReset();mockPathname.current = "/ws-test/issues";mockGetShareableUrl.mockReset().mockImplementation((p: string) => `https://app.multica/${p}`);@@ -714,6 +717,23 @@ describe("SearchCommand", () => {expect(mockPush).toHaveBeenCalledWith("/ws-test/docs/doc-runbook");});+ it("offers no Docs page or doc rows while docs_v1 is off", async () => {+ configStore.getState().setFeatureFlags({});+ seed(docTreeOptions("ws-test"), {+ folders: [],+ docs: [{ id: "doc-runbook", title: "Docs runbook", folderId: null }],+ });+ const user = userEvent.setup();+ renderSearch();+ await user.type(input(), "docs");++ // Past the doc search debounce, so a request would have gone out.+ await act(() => new Promise((resolve) => setTimeout(resolve, 400)));+ expect(renderedValues()).not.toContain("page:docs");+ expect(screen.queryByRole("group", { name: "Docs" })).not.toBeInTheDocument();+ expect(api("searchDocs")).not.toHaveBeenCalled();+ });+it("adds server content hits under Docs with an excerpt, without repeating title hits", async () => {seed(docTreeOptions("ws-test"), {folders: [{ id: "folder-eng", title: "Engineering" }],diff --git a/packages/views/search/use-object-search.ts b/packages/views/search/use-object-search.tsindex 44dc2cb36f..3d044da065 100644--- a/packages/views/search/use-object-search.ts+++ b/packages/views/search/use-object-search.ts@@ -5,6 +5,8 @@ import { useQuery } from "@tanstack/react-query";import { autopilotListOptions } from "@multica/core/autopilots/queries";import { docTreeOptions } from "@multica/core/docs";import { chatSessionsOptions } from "@multica/core/chat/queries";+import { useFeatureEnabled } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { useWorkspaceId } from "@multica/core/hooks";import { issueViewEverywhereOptions } from "@multica/core/issue-views/queries";import { BUILTIN_VIEW_KEYS, type BuiltinViewKey } from "@multica/core/issue-views/sidebar-views";@@ -107,7 +109,12 @@ export function useObjectSearch(const { data: autopilots = EMPTY_AUTOPILOTS } = useQuery({ ...autopilotListOptions(wsId), enabled: typing });const { data: chats = EMPTY_CHATS } = useQuery({ ...chatSessionsOptions(wsId), enabled: typing });const { data: skills = EMPTY_SKILLS } = useQuery({ ...skillListOptions(wsId), enabled: typing });- const { data: docTree = EMPTY_DOC_TREE } = useQuery({ ...docTreeOptions(wsId), enabled: typing && !!wsId });+ const docsEnabled = useFeatureEnabled(DOCS_V1_FLAG, false);+ const { data: cachedDocTree = EMPTY_DOC_TREE } = useQuery({+ ...docTreeOptions(wsId),+ enabled: typing && !!wsId && docsEnabled,+ });+ const docTree = docsEnabled ? cachedDocTree : EMPTY_DOC_TREE;const docFolders = useMemo(() => new Map(docTree.folders.map((f) => [f.id, f.title])), [docTree]);const docs = useMemo<PaletteDoc[]>(() => {const folders = docFolders;diff --git a/packages/views/search/use-root-model.ts b/packages/views/search/use-root-model.tsindex 2d1284f684..c3a4aae50d 100644--- a/packages/views/search/use-root-model.ts+++ b/packages/views/search/use-root-model.ts@@ -2,6 +2,8 @@import { useMemo } from "react";import type { CommandBarContext } from "@multica/core/command-bar";+import { useFeatureEnabled } from "@multica/core/config";+import { DOCS_V1_FLAG } from "@multica/core/feature-flags";import { WORKSPACE_PAGES, type WorkspacePageKey } from "@multica/core/paths";import { partitionAggregatedSearchResults } from "@multica/core/search/cancelled-rank";import type { SearchDocResult, SearchIssueResult, SearchProjectResult } from "@multica/core/types";@@ -183,18 +185,19 @@ export function useRootModel(const searching = active && scope !== "commands" && scope !== "people" ? text : "";const server = useServerSearch(searching, { projects: scope === "all" });- const docSearch = useDocSearch(searching, scope === "all");+ const docsEnabled = useFeatureEnabled(DOCS_V1_FLAG, false);+ const docSearch = useDocSearch(searching, scope === "all" && docsEnabled);const objects = useObjectSearch(scope === "issues" || scope === "commands" ? "" : q, active);const recent = useRecentItems(active && !rawQuery.trim());const navPages = useMemo<NavPage[]>(() =>- NAV_PAGE_KEYS.map((key) => ({+ NAV_PAGE_KEYS.filter((key) => key !== "docs" || docsEnabled).map((key) => ({key,label: tNav(($) => $.nav[WORKSPACE_PAGES[key].navKey]),keywords: PAGE_KEYWORDS[key],})),- [tNav],+ [docsEnabled, tNav],);return useMemo<RootModel>(() => {diff --git a/server/cmd/server/router.go b/server/cmd/server/router.goindex 417c410029..706d168afd 100644--- a/server/cmd/server/router.go+++ b/server/cmd/server/router.go@@ -2329,8 +2329,9 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus// Commercial (server/ee) workspace routes; none in an open-source build.extension.MountWorkspaceRoutes(r, h)- // Projects+ // Docs, behind the docs_v1 flag until launch.r.Route("/api/docs", func(r chi.Router) {+ r.Use(h.RequireDocsV1)r.Get("/", h.ListDocTree)r.Post("/", h.CreateDoc)r.Get("/search", h.SearchDocs)@@ -2344,6 +2345,7 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus})})r.Route("/api/doc-folders", func(r chi.Router) {+ r.Use(h.RequireDocsV1)r.Post("/", h.CreateDocFolder)r.Route("/{id}", func(r chi.Router) {r.Patch("/", h.UpdateDocFolder)@@ -2352,6 +2354,7 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus})})+ // Projectsr.Route("/api/projects", func(r chi.Router) {r.Get("/search", h.SearchProjects)// Workspace owner only: every private project, joined or not.diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.goindex 0989f967a7..93d78d5fac 100644--- a/server/internal/daemon/daemon.go+++ b/server/internal/daemon/daemon.go@@ -8339,6 +8339,7 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot iChatSessionID: task.ChatSessionID,ChatChannelType: task.ChatChannelType,ChatChannelDeliversFiles: task.ChatChannelDeliversFiles,+ DocsEnabled: task.DocsEnabled,AutopilotRunID: task.AutopilotRunID,AutopilotID: task.AutopilotID,AutopilotTitle: task.AutopilotTitle,diff --git a/server/internal/daemon/execenv/execenv.go b/server/internal/daemon/execenv/execenv.goindex 193202669a..12185632b7 100644--- a/server/internal/daemon/execenv/execenv.go+++ b/server/internal/daemon/execenv/execenv.go@@ -195,6 +195,10 @@ type TaskContextForEnv struct {// TestBriefByteIdenticalAcrossRunsForEveryKind is what keeps this field out// of the brief.ChatChannelDeliversFiles bool+ // DocsEnabled is the server's docs_v1 flag from the claim. The brief lists+ // `multica doc` and mention://doc only when it is true, so agents are not+ // sent to an API that answers 403 docs_disabled.+ DocsEnabled boolAutopilotRunID string // non-empty for autopilot run_only tasksAutopilotID stringdiff --git a/server/internal/daemon/execenv/runtime_config_kind_test.go b/server/internal/daemon/execenv/runtime_config_kind_test.goindex 6a5e223032..dd3fdf28c8 100644--- a/server/internal/daemon/execenv/runtime_config_kind_test.go+++ b/server/internal/daemon/execenv/runtime_config_kind_test.go@@ -76,6 +76,22 @@ func TestBuildMetaSkillContentBriefContent(t *testing.T) {}}+// TestBuildMetaSkillContentDocsFollowFlag pins that the `multica doc` command+// and the mention://doc form reach the brief only when the server's docs_v1+// flag is on, so a deployment without Docs never points agents at it.+func TestBuildMetaSkillContentDocsFollowFlag(t *testing.T) {+ t.Parallel()++ for _, enabled := range []bool{false, true} {+ out := buildMetaSkillContent("claude", TaskContextForEnv{IssueID: "issue-1", DocsEnabled: enabled})+ for _, line := range []string{"`multica doc list|search|get|create|update`", "mention://doc/<doc-id>"} {+ if got := strings.Contains(out, line); got != enabled {+ t.Errorf("DocsEnabled=%v: brief contains %q = %v\n---\n%s", enabled, line, got, out)+ }+ }+ }+}+// TestBuildMetaSkillContentIssueBodyFormatting pins the shared issue-body// hierarchy rule across every task kind that can author an issue.func TestBuildMetaSkillContentIssueBodyFormatting(t *testing.T) {diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex d33a1813e7..31ba491971 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -277,7 +277,9 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {b.WriteString(duplicateOfCommandLine)b.WriteString("- `multica issue wakeup <create|list|get|update|disable|trigger|delete|runs|events>` — persist an event, condition or time wakeup on this issue, then finish the current run. When the platform can check the fact itself, use one `--until-*` condition so no run starts before it holds; check the rule's `last_error` for missing PR links or snapshots, which are retried automatically. Conditions, PR rules and actor filters: `multica issue wakeup create --help` and the multica-platform issues reference.\n")b.WriteString("- `multica issue children <id> [--output json]` — list a parent's sub-issues grouped by stage.\n")- b.WriteString("- `multica doc list|search|get|create|update` — workspace docs; `doc search <query>` matches titles and content; `doc update` needs `--base-revision` from `multica doc get` (details: `multica doc --help`).\n")+ if ctx.DocsEnabled {+ b.WriteString("- `multica doc list|search|get|create|update` — workspace docs; `doc search <query>` matches titles and content; `doc update` needs `--base-revision` from `multica doc get` (details: `multica doc --help`).\n")+ }b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file` with a file inside your working directory; full flags: `multica issue comment add --help`.\n")b.WriteString("- `multica repo checkout <url> [--ref <branch-or-sha>] [--fresh]` — repository checkout on a dedicated branch; re-running it keeps a checkout that has uncommitted or unpushed work, or is already on this task's branch, and only fetches; a clean, fully pushed checkout on another branch starts over on a new branch. `--fresh` discards uncommitted and untracked files for a new branch; commits stay on the old branch, so push any you still need first.\n\n")b.WriteString("Commits use the user's configured Git identity; keep it unless asked. For a requested override in a managed checkout use `git config --worktree user.name` / `user.email` — plain or `--local` config can leak into a shared cache; never change the global identity.\n\n")@@ -838,7 +840,7 @@ func writeTraecliSkills(b *strings.Builder, skills []SkillContextForEnv) {}// writeMentions emits the @mention side-effects section (compressed).-func writeMentions(b *strings.Builder) {+func writeMentions(b *strings.Builder, docsEnabled bool) {b.WriteString("## Mentions\n\n")b.WriteString("Mention links are **side-effecting actions**:\n\n")b.WriteString("- `[MUL-123](mention://issue/<issue-id>)` — clickable link (no side effect)\n")@@ -846,7 +848,9 @@ func writeMentions(b *strings.Builder) {// agent writes this form (or pastes the project URL, which the reader's// client unfurls into the same chip) a project reference stays dead text.b.WriteString("- `[Project Name](mention://project/<project-id>)` — clickable link (no side effect)\n")- b.WriteString("- `[Doc Title](mention://doc/<doc-id>)` — clickable link (no side effect); read it with `multica doc get <doc-id>`\n")+ if docsEnabled {+ b.WriteString("- `[Doc Title](mention://doc/<doc-id>)` — clickable link (no side effect); read it with `multica doc get <doc-id>`\n")+ }b.WriteString("- `[@Name](mention://member/<user-id>)` — **notifies a human**\n")b.WriteString("- `[@Name](mention://agent/<agent-id>)` — **enqueues a new run for that agent**\n\n")// No prescriptive default here (MUL-6417): the mention syntax hides its@@ -1056,7 +1060,7 @@ func buildMetaSkillContentSlim(provider string, ctx TaskContextForEnv) string {writeSkills(&b, provider, ctx)if kind == kindIssue {- writeMentions(&b)+ writeMentions(&b, ctx.DocsEnabled)writeAttachments(&b)}diff --git a/server/internal/daemon/types.go b/server/internal/daemon/types.goindex 9cb9d8ea67..519aca0129 100644--- a/server/internal/daemon/types.go+++ b/server/internal/daemon/types.go@@ -119,6 +119,7 @@ type Task struct {ProjectResources []ProjectResourceData `json:"project_resources,omitempty"` // project-scoped resources to expose to the agentIsLeaderTask bool `json:"is_leader_task,omitempty"` // true when executing in the squad-leader coordinator roleLeaderRoleResolved bool `json:"leader_role_resolved,omitempty"` // server capability: IsLeaderTask/SquadID authoritatively answer "is this a leader run". Absent on servers predating it — those before #4951 never sent is_leader_task at all, later ones send it without this guarantee — so taskIsSquadLeader falls back to the briefing marker for both (MUL-5811)+ DocsEnabled bool `json:"docs_enabled,omitempty"` // the server's docs_v1 flag. Absent on servers predating it, which reads as false: the brief leaves out the `multica doc` and mention://doc linesPriorSessionID string `json:"prior_session_id,omitempty"` // Claude session ID from a previous task on this issuePriorWorkDir string `json:"prior_work_dir,omitempty"` // work_dir from a previous task on this issuePriorSessionResumeUnavailable bool `json:"prior_session_resume_unavailable,omitempty"` // MUL-5305: server signals a more recent Codex session was withheld (rollout missing) and PriorSessionID (if any) is an older fallback; the run must disclose the continuity gap even if that older session resumes cleanly. Absent/false on old servers.diff --git a/server/internal/featureflags/keys.go b/server/internal/featureflags/keys.goindex bd24aa2122..a8e164d63e 100644--- a/server/internal/featureflags/keys.go+++ b/server/internal/featureflags/keys.go@@ -35,6 +35,13 @@ const (// makes those endpoints answer 404, so clients stop syncing and search// through the server again without a client release.LocalSearchIndex = "local_search_index"+ // DocsV1 gates workspace Docs (MUL-8370) while it is still being tested:+ // the /api/docs and /api/doc-folders APIs, the Web/Desktop entry points,+ // and the doc lines in the agent brief. Off by default so a release can+ // ship the code without launching the feature; FF_DOCS_V1=true turns it on+ // for a deployment. It is a GLOBAL switch. Turning it off leaves existing+ // doc rows untouched — they simply become unreachable until it is back on.+ DocsV1 = "docs_v1"// agentBuilderCompat is no longer a release flag. Keep publishing the key// as enabled so installed desktop clients that still gate the AI creation// entry on this config decision receive the permanently enabled behavior.@@ -59,6 +66,7 @@ var frontendPublicFlags = []string{BillingWorkspaceSubscriptions,ComposioMCPApps,PluginsV1,+ DocsV1,}func BillingWorkspaceSubscriptionsEnabled(ctx context.Context, flags *featureflag.Service) bool {@@ -81,6 +89,10 @@ func LocalSearchIndexEnabled(ctx context.Context, flags *featureflag.Service) boreturn flags.IsEnabled(ctx, LocalSearchIndex, true)}+func DocsV1Enabled(ctx context.Context, flags *featureflag.Service) bool {+ return flags.IsEnabled(ctx, DocsV1, false)+}+func EvaluateFrontendPublicFlags(ctx context.Context, flags *featureflag.Service) map[string]bool {out := make(map[string]bool, len(frontendPublicFlags)+4)for _, key := range frontendPublicFlags {diff --git a/server/internal/handler/agent.go b/server/internal/handler/agent.goindex e80045a547..d7aae520cb 100644--- a/server/internal/handler/agent.go+++ b/server/internal/handler/agent.go@@ -459,6 +459,7 @@ type AgentTaskResponse struct {ParentTaskID *string `json:"parent_task_id,omitempty"`IsLeaderTask bool `json:"is_leader_task,omitempty"`LeaderRoleResolved bool `json:"leader_role_resolved,omitempty"` // claim-only capability, always true here: IsLeaderTask/SquadID authoritatively answer "is this a leader run", so the daemon must not infer the role from briefing text. Servers predating it make no such promise — before #4951 they sent no is_leader_task at all, after it they sent the flag without guaranteeing a briefing — so a daemon seeing no capability keeps the legacy inference. Never rendered into a prompt; see daemon.taskIsSquadLeader (MUL-5811). Mirror field: internal/daemon/types.go, same JSON name+ DocsEnabled bool `json:"docs_enabled,omitempty"` // the docs_v1 flag at claim time. The daemon writes the `multica doc` and mention://doc lines into the agent brief only when true, so agents are not pointed at an API that answers 403 docs_disabled. Mirror field: internal/daemon/types.go, same JSON nameAgent *TaskAgentData `json:"agent,omitempty"`ConnectedApps []ConnectedAppData `json:"connected_apps,omitempty"` // daemon-claim only: per-run app capabilities mounted through runtime MCP overlaysRepos []RepoData `json:"repos,omitempty"`diff --git a/server/internal/handler/daemon.go b/server/internal/handler/daemon.goindex 16ca2ef5c8..8e378bf5d1 100644--- a/server/internal/handler/daemon.go+++ b/server/internal/handler/daemon.go@@ -2951,6 +2951,7 @@ func (h *Handler) buildClaimedTaskResponse(r *http.Request, task *db.AgentTaskQu// not — because its absence is what tells an upgraded daemon it is talking// to a server too old to have answered the question (MUL-5811).resp.LeaderRoleResolved = true+ resp.DocsEnabled = h.docsV1Enabled(r.Context())// Agent-trigger plugin hooks, as tools. A failure here degrades to no// tools rather than failing the claim: a plugin that cannot be listed must// not stop an agent from working on the issue.diff --git a/server/internal/handler/doc.go b/server/internal/handler/doc.goindex b2a7c63673..c3139deb84 100644--- a/server/internal/handler/doc.go+++ b/server/internal/handler/doc.go@@ -11,6 +11,7 @@ import ("github.com/go-chi/chi/v5""github.com/jackc/pgx/v5/pgtype"+ "github.com/multica-ai/multica/server/internal/featureflags""github.com/multica-ai/multica/server/internal/util"db "github.com/multica-ai/multica/server/pkg/db/generated""github.com/multica-ai/multica/server/pkg/protocol"@@ -28,6 +29,22 @@ var (validDocActions = []string{"edit", "restore"})+func (h *Handler) docsV1Enabled(ctx context.Context) bool {+ return featureflags.DocsV1Enabled(ctx, h.FeatureFlags)+}++// RequireDocsV1 answers 403 docs_disabled while the docs_v1 flag is off, so+// the API, the CLI and agents cannot reach Docs before it launches.+func (h *Handler) RequireDocsV1(next http.Handler) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if !h.docsV1Enabled(r.Context()) {+ writeFeatureDisabled(w, "docs_disabled", "Docs is not enabled")+ return+ }+ next.ServeHTTP(w, r)+ })+}+type DocSummaryResponse struct {ID string `json:"id"`WorkspaceID string `json:"workspace_id"`diff --git a/server/internal/handler/featureflag_test.go b/server/internal/handler/featureflag_test.goindex 683f159849..cddd31acb6 100644--- a/server/internal/handler/featureflag_test.go+++ b/server/internal/handler/featureflag_test.go@@ -1,6 +1,10 @@package handlerimport (+ "context"+ "net/http"+ "net/http/httptest"+ "strings""testing""github.com/multica-ai/multica/server/internal/featureflags"@@ -35,3 +39,25 @@ func withFeatureFlag(t *testing.T, h *Handler, key string, enabled bool) {}})}++func TestRequireDocsV1(t *testing.T) {+ for _, enabled := range []bool{false, true} {+ h := &Handler{}+ withFeatureFlag(t, h, featureflags.DocsV1, enabled)+ reached := false+ w := httptest.NewRecorder()+ h.RequireDocsV1(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {+ reached = true+ })).ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/api/docs", nil))+ if reached != enabled {+ t.Fatalf("docs_v1=%v: next handler reached = %v", enabled, reached)+ }+ if !enabled && (w.Code != http.StatusForbidden || !strings.Contains(w.Body.String(), "docs_disabled")) {+ t.Fatalf("docs_v1=false: want 403 docs_disabled, got %d %s", w.Code, w.Body.String())+ }+ }+ // No flag service at all (tests, misconfigured boot) must fail closed.+ if (&Handler{}).docsV1Enabled(context.Background()) {+ t.Fatal("docs_v1 must default to off")+ }+}diff --git a/server/internal/handler/squad_briefing_claim_test.go b/server/internal/handler/squad_briefing_claim_test.goindex 35207fa67e..2788d0acfe 100644--- a/server/internal/handler/squad_briefing_claim_test.go+++ b/server/internal/handler/squad_briefing_claim_test.go@@ -9,6 +9,7 @@ import ("strings""testing"+ "github.com/multica-ai/multica/server/internal/featureflags""github.com/multica-ai/multica/server/internal/testutil""github.com/multica-ai/multica/server/pkg/protocol")@@ -223,6 +224,27 @@ func TestClaim_NonLeaderTask_NoBriefing(t *testing.T) {}}+// TestClaim_DocsEnabledFollowsFlag pins docs_enabled on the claim: the daemon+// writes `multica doc` into the agent brief only when the server says so.+func TestClaim_DocsEnabledFollowsFlag(t *testing.T) {+ if testHandler == nil || testPool == nil {+ t.Skip("database not available")+ }+ for _, enabled := range []bool{false, true} {+ t.Run(fmt.Sprintf("docs_v1=%v", enabled), func(t *testing.T) {+ withFeatureFlag(t, testHandler, featureflags.DocsV1, enabled)+ ctx := context.Background()+ fx := newSquadBriefingClaimFixture(t, ctx, fmt.Sprintf("Docs flag %v", enabled))+ enqueueClaimTask(t, ctx, fx, false /*isLeader*/, true /*withSquadID*/)++ _, _, _, raw := claimAgentInstructionsForTest(t, fx.RuntimeID)+ if got := strings.Contains(raw, `"docs_enabled":true`); got != enabled {+ t.Fatalf("docs_enabled in claim = %v, want %v: %s", got, enabled, raw)+ }+ })+ }+}+// TestClaim_LeaderTaskWithDanglingSquadID_NoBriefing is the load-bearing// contract for dropping the FK on agent_task_queue.squad_id (migration 127):// when a squad is hard-deleted AFTER a leader task was enqueued, the task row