Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8788 chore(views): enforce no store definitions in packages/views with ESLint (#10139)
Jiayuan Zhangae446567abfb
diff --git a/AGENTS.md b/AGENTS.mdindex 97070f8456..a0ecf8eb21 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -15,7 +15,7 @@ Multica is a task management platform where people and agents collaborate on iss| `server/` | Go backend; Chi, sqlc, WebSocket || `packages/core/` | Headless logic, API client, Query hooks, shared Zustand stores. No UI libraries, `react-dom`, `localStorage`, or `process.env`; use `StorageAdapter` for persistence. Lint enforces this outside tests (`packages/core/eslint.config.mjs`). || `packages/ui/` | UI primitives and shared styles. No business logic or `@multica/core` imports. |-| `packages/views/` | Shared web/desktop pages and business components. No store definitions, `next/*`, or `react-router-dom`; use `NavigationAdapter`, `useNavigation()`, and `<AppLink>`. |+| `packages/views/` | Shared web/desktop pages and business components. No store definitions, `next/*`, or `react-router-dom`; use `NavigationAdapter`, `useNavigation()`, and `<AppLink>`. Lint enforces the store rule outside tests (`packages/views/eslint.config.mjs`). || `apps/web/` | Next.js routes/layouts and web-only UI. Framework APIs stay here; shared navigation adapters live in `apps/web/platform/`. || `apps/desktop/` | Electron and desktop-only UI/state. Application navigation goes through `apps/desktop/src/renderer/src/platform/`. || `apps/mobile/` | Independent Expo/React Native client: owns UI, state, hooks, providers, i18n, build, and release. Shares core types and pure utilities, including platform-independent schemas. |diff --git a/packages/core/command-bar/index.ts b/packages/core/command-bar/index.tsindex 6f4cd1b476..61b963e407 100644--- a/packages/core/command-bar/index.ts+++ b/packages/core/command-bar/index.ts@@ -11,3 +11,4 @@ export {type RecentVisitEntry,type RecentVisitType,} from "./recent-store";+export { useSearchStore } from "./search-store";diff --git a/packages/views/search/search-store.ts b/packages/core/command-bar/search-store.tssimilarity index 100%rename from packages/views/search/search-store.tsrename to packages/core/command-bar/search-store.tsdiff --git a/packages/views/eslint.config.mjs b/packages/views/eslint.config.mjsindex 18bb90d8ab..011093e3c9 100644--- a/packages/views/eslint.config.mjs+++ b/packages/views/eslint.config.mjs@@ -1,4 +1,5 @@import reactConfig from "@multica/eslint-config/react";+import { ICON_LIBRARY_IMPORT_PATTERNS } from "@multica/eslint-config/base";import { NO_ROUND_CONTROLS } from "@multica/eslint-config/control-shape";import i18next from "eslint-plugin-i18next";import {@@ -12,6 +13,16 @@ import {// attribute values and plain TS literals are allowed through — the two doors// `eslint-i18n-guard.mjs` pins shut.+// Package boundary (AGENTS.md): views consumes stores but never defines them.+// Tests may build throwaway stores as fixtures.+const STORE_FACTORY_MESSAGE =+ "packages/views must not define stores. Define the store in packages/core and import it here.";+const STORE_FACTORY_IMPORTS = ["zustand", "zustand/vanilla"].map((name) => ({+ name,+ importNames: ["create", "createStore"],+ message: STORE_FACTORY_MESSAGE,+}));+export default [...reactConfig,{@@ -36,6 +47,13 @@ export default [NO_UNTRANSLATED_TOAST,NO_ROUND_CONTROLS,],+ "no-restricted-imports": [+ "error",+ {+ paths: STORE_FACTORY_IMPORTS,+ patterns: ICON_LIBRARY_IMPORT_PATTERNS,+ },+ ],},},];diff --git a/packages/views/layout/global-actions.test.tsx b/packages/views/layout/global-actions.test.tsxindex 25d7043d07..b1d6bd0a22 100644--- a/packages/views/layout/global-actions.test.tsx+++ b/packages/views/layout/global-actions.test.tsx@@ -16,7 +16,7 @@ vi.mock("@multica/core/issues/stores/draft-store", () => ({useIssueDraftStore: (selector: (s: { hasDraft: () => boolean }) => unknown) =>selector({ hasDraft: () => state.hasDraft }),}));-vi.mock("../search/search-store", () => ({+vi.mock("@multica/core/command-bar", () => ({useSearchStore: { getState: () => ({ setOpen: setSearchOpen }) },}));vi.mock("@multica/core/shortcuts", () => ({ useShortcut: () => null }));diff --git a/packages/views/layout/global-actions.tsx b/packages/views/layout/global-actions.tsxindex 5ed46375e4..00250a4484 100644--- a/packages/views/layout/global-actions.tsx+++ b/packages/views/layout/global-actions.tsx@@ -3,13 +3,13 @@import type { ComponentProps } from "react";import { Search, SquarePen } from "@multica/ui/icons";import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";+import { useSearchStore } from "@multica/core/command-bar";import { openCreateIssueWithPreference } from "@multica/core/issues/stores";import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";import { useShortcut } from "@multica/core/shortcuts";import { ShortcutKeycaps } from "../common/shortcut-keycaps";import { useT } from "../i18n";import { useNavigation } from "../navigation";-import { useSearchStore } from "../search/search-store";type TooltipSide = ComponentProps<typeof TooltipHint>["side"];diff --git a/packages/views/layout/global-shortcuts.chat.test.tsx b/packages/views/layout/global-shortcuts.chat.test.tsxindex 54edb5ab8f..5d4216caf1 100644--- a/packages/views/layout/global-shortcuts.chat.test.tsx+++ b/packages/views/layout/global-shortcuts.chat.test.tsx@@ -48,7 +48,7 @@ vi.mock("@multica/ui/components/ui/sidebar", () => ({useSidebar: () => ({ toggleSidebar: h.toggleSidebar }),}));vi.mock("../navigation", () => ({ useNavigation: () => h.navigation }));-vi.mock("../search/search-store", () => ({+vi.mock("@multica/core/command-bar", () => ({useSearchStore: { getState: () => ({ toggle: h.searchToggle }) },}));diff --git a/packages/views/layout/global-shortcuts.tsx b/packages/views/layout/global-shortcuts.tsxindex f83078d030..a57d15c9ad 100644--- a/packages/views/layout/global-shortcuts.tsx+++ b/packages/views/layout/global-shortcuts.tsx@@ -11,6 +11,7 @@ import {type ShortcutActionId,} from "@multica/core/shortcuts";import { useChatStore } from "@multica/core/chat";+import { useSearchStore } from "@multica/core/command-bar";import { useModalStore } from "@multica/core/modals";import { useWorkspacePaths } from "@multica/core/paths";import { isImeComposing } from "@multica/core/utils";@@ -18,7 +19,6 @@ import { isFloatingChatRouteSuppressed } from "../chat/floating-chat-visibility"import { useAppShell } from "./app-shell-context";import { openCreateIssueForPath } from "./global-actions";import { useNavigation } from "../navigation";-import { useSearchStore } from "../search/search-store";const GLOBAL_ACTIONS: readonly ShortcutActionId[] = ["openSearch",diff --git a/packages/views/search/index.ts b/packages/views/search/index.tsindex 29bb634e49..5612dd15f3 100644--- a/packages/views/search/index.ts+++ b/packages/views/search/index.ts@@ -1,2 +1 @@export { SearchCommand } from "./search-command";-export { useSearchStore } from "./search-store";diff --git a/packages/views/search/search-command.test.tsx b/packages/views/search/search-command.test.tsxindex f02a69e234..6eac6a9b54 100644--- a/packages/views/search/search-command.test.tsx+++ b/packages/views/search/search-command.test.tsx@@ -3,7 +3,11 @@ import { fireEvent, render, screen, waitFor, within } from "@testing-library/reaimport userEvent from "@testing-library/user-event";import { beforeEach, describe, expect, it, vi, type Mock } from "vitest";import { buildIssueStatusCatalog } from "@multica/core/issue-statuses/queries";-import { useCommandBarContextStore, type CommandBarContext } from "@multica/core/command-bar";+import {+ useCommandBarContextStore,+ useSearchStore,+ type CommandBarContext,+} from "@multica/core/command-bar";import { inboxUnreadSummaryOptions } from "@multica/core/inbox/queries";import { I18nProvider } from "@multica/core/i18n/react";import { issueDetailOptions, issueTimelineOptions } from "@multica/core/issues/queries";@@ -19,7 +23,6 @@ import { RESOURCES } from "../locales";import enLayout from "../locales/en/layout.json";import zhHansProjects from "../locales/zh-Hans/projects.json";import { SearchCommand } from "./search-command";-import { useSearchStore } from "./search-store";vi.mock("@multica/core/issue-statuses/hooks", () => ({useIssueStatuses: () => buildIssueStatusCatalog([]),diff --git a/packages/views/search/search-command.tsx b/packages/views/search/search-command.tsxindex 31eb59f4ed..255f83ae92 100644--- a/packages/views/search/search-command.tsx+++ b/packages/views/search/search-command.tsx@@ -3,7 +3,11 @@import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";import { ChevronRight, SearchIcon, Sparkles } from "@multica/ui/icons";import { Command as CommandPrimitive } from "cmdk";-import { selectCommandBarContexts, useCommandBarContextStore } from "@multica/core/command-bar";+import {+ selectCommandBarContexts,+ useCommandBarContextStore,+ useSearchStore,+} from "@multica/core/command-bar";import { createShortcutChord } from "@multica/core/shortcuts";import { isImeComposing } from "@multica/core/utils";import {@@ -23,7 +27,6 @@ import { PageView } from "./pages/page-view";import { RootView } from "./root-view";import { useDelegateSubmit } from "./delegate/use-delegate";import { useRootModel } from "./use-root-model";-import { useSearchStore } from "./search-store";import type { DelegateActor, PaletteHostDialog, PaletteStackEntry } from "./types";const ESCAPE = createShortcutChord("Escape");diff --git a/packages/views/search/search-command.visibility.test.tsx b/packages/views/search/search-command.visibility.test.tsxindex 3e732e5131..e1c123e502 100644--- a/packages/views/search/search-command.visibility.test.tsx+++ b/packages/views/search/search-command.visibility.test.tsx@@ -1,13 +1,13 @@import { act, cleanup, render, screen, waitFor } from "@testing-library/react";import { QueryClientProvider, focusManager } from "@tanstack/react-query";import { afterEach, beforeEach, expect, it, vi } from "vitest";+import { useSearchStore } from "@multica/core/command-bar";import { I18nProvider } from "@multica/core/i18n/react";import { buildIssueStatusCatalog } from "@multica/core/issue-statuses/queries";import { useInboxUnreadCount } from "@multica/core/inbox/queries";import { onInboxSummaryInvalidate } from "@multica/core/inbox/ws-updaters";import { createQueryClient } from "@multica/core/query-client";import { SearchCommand } from "./search-command";-import { useSearchStore } from "./search-store";import enSearch from "../locales/en/search.json";import enLayout from "../locales/en/layout.json";import enProjects from "../locales/en/projects.json";diff --git a/packages/views/whats-new/highlight-action.tsx b/packages/views/whats-new/highlight-action.tsxindex 30406f9464..995fefdb81 100644--- a/packages/views/whats-new/highlight-action.tsx+++ b/packages/views/whats-new/highlight-action.tsx@@ -1,12 +1,12 @@"use client";import { ArrowRight, ArrowUpRight } from "@multica/ui/icons";+import { useSearchStore } from "@multica/core/command-bar";import { useWorkspacePaths } from "@multica/core/paths";import { useShortcut } from "@multica/core/shortcuts";import { ShortcutKeycaps } from "../common/shortcut-keycaps";import { useT } from "../i18n";import { useNavigation } from "../navigation";-import { useSearchStore } from "../search/search-store";import type { HighlightAction } from "./releases";/**diff --git a/packages/views/whats-new/whats-new-menu-panel.test.tsx b/packages/views/whats-new/whats-new-menu-panel.test.tsxindex a1b2135409..eed00d7738 100644--- a/packages/views/whats-new/whats-new-menu-panel.test.tsx+++ b/packages/views/whats-new/whats-new-menu-panel.test.tsx@@ -1,12 +1,12 @@import type { ReactNode } from "react";import { act, fireEvent, render, screen } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { useSearchStore } from "@multica/core/command-bar";import { configStore } from "@multica/core/config";import { Command, Globe, Terminal } from "@multica/ui/icons";import type { User } from "@multica/core/types";import enLayout from "../locales/en/layout.json";import { HelpLauncher } from "../layout/help-launcher";-import { useSearchStore } from "../search/search-store";import type { WhatsNewRelease } from "./releases";const mocks = vi.hoisted(() => ({