diff --git a/apps/web/app/(app)/chats/[chat]/page.tsx b/apps/web/app/(app)/chats/[chat]/page.tsx index c867f609..a58cc650 100644 --- a/apps/web/app/(app)/chats/[chat]/page.tsx +++ b/apps/web/app/(app)/chats/[chat]/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { ArrowLeft, Bot, Link2, MessagesSquare, Send, Unlink, User as UserIcon } from "lucide-react"; import { ANALYST_NAME, analystPending, attachmentsByMessage, chatStatusLine, isSuperadmin, chatGroupBotName, chatMessagesView, chatTtlMs, discussionMessages, discussionUnread, getSetting, listChats, markDiscussionRead, markThreadRead, masterFeed, projectThreadList, splitForDisplay, syncChats, threadTitle, THREAD_KEY, type AttachmentView, type ChatMessageView, type Question } from "@peppa/core"; diff --git a/apps/web/app/(app)/chats/page.tsx b/apps/web/app/(app)/chats/page.tsx index e883b82b..169bf6fd 100644 --- a/apps/web/app/(app)/chats/page.tsx +++ b/apps/web/app/(app)/chats/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { ArrowRight, MessagesSquare } from "lucide-react"; import { chatOverview, isRoleName, syncChats } from "@peppa/core"; import { LiveRefresh } from "@/components/LiveRefresh"; diff --git a/apps/web/app/(app)/connections/page.tsx b/apps/web/app/(app)/connections/page.tsx index 4ec50ced..d2ea161e 100644 --- a/apps/web/app/(app)/connections/page.tsx +++ b/apps/web/app/(app)/connections/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { ExternalLink, PlugZap, Search } from "lucide-react"; import { CATALOG_KIND_TEXT, diff --git a/apps/web/app/(app)/dashboard/delays/page.tsx b/apps/web/app/(app)/dashboard/delays/page.tsx index da5ff69e..d43f136f 100644 --- a/apps/web/app/(app)/dashboard/delays/page.tsx +++ b/apps/web/app/(app)/dashboard/delays/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Hourglass } from "lucide-react"; import { isSuperadmin, platformDelayOverview } from "@peppa/core"; diff --git a/apps/web/app/(app)/dashboard/page.tsx b/apps/web/app/(app)/dashboard/page.tsx index 7dbc1d93..74d4a491 100644 --- a/apps/web/app/(app)/dashboard/page.tsx +++ b/apps/web/app/(app)/dashboard/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Gauge } from "lucide-react"; import { isSuperadmin, platformDashboard, platformDelayCounts, type DashboardCounts } from "@peppa/core"; diff --git a/apps/web/app/(app)/errors/[id]/page.tsx b/apps/web/app/(app)/errors/[id]/page.tsx index f90a055f..f9e50f84 100644 --- a/apps/web/app/(app)/errors/[id]/page.tsx +++ b/apps/web/app/(app)/errors/[id]/page.tsx @@ -1,7 +1,7 @@ // PEP-218: the card of one production error, read from Bugsink on the server. The superadmin // opens any error, a project's owner or member — errors of that project only (else 404). // «Инженер» and the superadmin see the stack, tags, events and the link to Bugsink. -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Bug, ExternalLink } from "lucide-react"; import { errorDetail, errorScope } from "@peppa/core"; diff --git a/apps/web/app/(app)/feedback/page.tsx b/apps/web/app/(app)/feedback/page.tsx index 878a9409..bfb7aefa 100644 --- a/apps/web/app/(app)/feedback/page.tsx +++ b/apps/web/app/(app)/feedback/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { FEEDBACK_ADMIN_STATUS, FEEDBACK_STATUSES, isFeedbackStatus, isSuperadmin, listAllFeedback, listUserFeedback } from "@peppa/core"; import { AdminFeedbackCard, MyFeedbackCard } from "@/components/Feedback"; import { Empty, Flash, PageHeader, Section } from "@/components/common"; diff --git a/apps/web/app/(app)/gitea/page.tsx b/apps/web/app/(app)/gitea/page.tsx index 28467906..4ce0ab79 100644 --- a/apps/web/app/(app)/gitea/page.tsx +++ b/apps/web/app/(app)/gitea/page.tsx @@ -1,5 +1,5 @@ // glossary-ignore-file: superadmin-only page about the platform's git server — «репозиторий» is the literal object here -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { ExternalLink, GitBranch, Lock } from "lucide-react"; import { giteaServerOverview, isSuperadmin, type GiteaServerRepo } from "@peppa/core"; diff --git a/apps/web/app/(app)/help/connect/page.tsx b/apps/web/app/(app)/help/connect/page.tsx index 6e036997..9da0c884 100644 --- a/apps/web/app/(app)/help/connect/page.tsx +++ b/apps/web/app/(app)/help/connect/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { CONNECT_HELP, featureGateView } from "@peppa/core"; import { FeatureGate } from "@/components/FeatureGate"; import { LiveRefresh } from "@/components/LiveRefresh"; diff --git a/apps/web/app/(app)/help/page.tsx b/apps/web/app/(app)/help/page.tsx index 06f5e073..d7738010 100644 --- a/apps/web/app/(app)/help/page.tsx +++ b/apps/web/app/(app)/help/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import type { ReactNode } from "react"; import { CONNECT_HELP, featureGateView, PRODUCT_HELP } from "@peppa/core"; import { FeatureGate } from "@/components/FeatureGate"; diff --git a/apps/web/app/(app)/help/shortcuts/page.tsx b/apps/web/app/(app)/help/shortcuts/page.tsx index 59b23e77..465ebfd8 100644 --- a/apps/web/app/(app)/help/shortcuts/page.tsx +++ b/apps/web/app/(app)/help/shortcuts/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { ShortcutsList } from "@/components/CommandPalette"; import { PageHeader, Section } from "@/components/common"; import { Workspace } from "@/components/Workspace"; diff --git a/apps/web/app/(app)/observability/[id]/page.tsx b/apps/web/app/(app)/observability/[id]/page.tsx index c0f70dfd..14475975 100644 --- a/apps/web/app/(app)/observability/[id]/page.tsx +++ b/apps/web/app/(app)/observability/[id]/page.tsx @@ -1,5 +1,5 @@ // glossary-ignore-file: the section is for the superadmin only. -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Activity, Pause, Play, Trash2 } from "lucide-react"; import { describeTarget, FEATURES, observeRemindMin, getMonitor, isSuperadmin, monitorChecks, monitorIncidents, monitorView } from "@peppa/core"; diff --git a/apps/web/app/(app)/observability/page.tsx b/apps/web/app/(app)/observability/page.tsx index af674e8b..70354870 100644 --- a/apps/web/app/(app)/observability/page.tsx +++ b/apps/web/app/(app)/observability/page.tsx @@ -1,5 +1,5 @@ // glossary-ignore-file: the section is for the superadmin only. -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Activity, Pause, Play, Plus } from "lucide-react"; import { describeTarget, observeRemindMin, PROVIDER_LABEL, smokeStatus, smokeTimeoutMin, type SmokeRun, type SmokeStatus, egovLoginSummary, errorScope, errorsOverview, FEATURE_NAMES, FEATURES, featureLog, featureStatuses, getLastRetention, isSuperadmin, listErrors, listMonitorViews, requestSummary } from "@peppa/core"; diff --git a/apps/web/app/(app)/p/[key]/accept/page.tsx b/apps/web/app/(app)/p/[key]/accept/page.tsx index 287ba02a..9843ee62 100644 --- a/apps/web/app/(app)/p/[key]/accept/page.tsx +++ b/apps/web/app/(app)/p/[key]/accept/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { acceptAllSummary, acceptScreen, type AcceptItem } from "@peppa/core"; import { acceptAllAction, fixStoryAction } from "@/app/(app)/actions"; diff --git a/apps/web/app/(app)/p/[key]/page.tsx b/apps/web/app/(app)/p/[key]/page.tsx index f3d7271c..8b3d9cdd 100644 --- a/apps/web/app/(app)/p/[key]/page.tsx +++ b/apps/web/app/(app)/p/[key]/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { Fragment } from "react"; import { ProductCard } from "@/components/ProductCard"; import { PublishPanel } from "@/components/PublishPanel"; diff --git a/apps/web/app/(app)/p/[key]/plan/[epic]/page.tsx b/apps/web/app/(app)/p/[key]/plan/[epic]/page.tsx index c67f6864..06e41495 100644 --- a/apps/web/app/(app)/p/[key]/plan/[epic]/page.tsx +++ b/apps/web/app/(app)/p/[key]/plan/[epic]/page.tsx @@ -1,5 +1,5 @@ // PEP-42: plan an epic — the planner proposes stories with dependencies; the PM edits and approves. -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Sparkles } from "lucide-react"; import { getEpic, listTasks } from "@peppa/core"; diff --git a/apps/web/app/(app)/page.tsx b/apps/web/app/(app)/page.tsx index 66014d4d..9898c115 100644 --- a/apps/web/app/(app)/page.tsx +++ b/apps/web/app/(app)/page.tsx @@ -1,6 +1,6 @@ import { Suspense } from "react"; import { redirect } from "next/navigation"; -import Link from "next/link"; +import Link from "@/components/Link"; import { agentTaskSummary, claimWelcome, isSuperadmin, listUserProjects, onboardingChecklist, pendingFeedback, platformDelayCounts, progressOverview, proposedCount, reviewCounts } from "@peppa/core"; import { AdminFeedbackCard } from "@/components/Feedback"; import { AgentTaskSummary } from "@/components/AgentTaskSummary"; diff --git a/apps/web/app/(app)/projects/page.tsx b/apps/web/app/(app)/projects/page.tsx index bdf0f2d2..375301fa 100644 --- a/apps/web/app/(app)/projects/page.tsx +++ b/apps/web/app/(app)/projects/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { Plus } from "lucide-react"; import { analystLinks, isSuperadmin, listOtherProjects, listUserProjects, projectTrashDays } from "@peppa/core"; import { ProjectList } from "@/components/cards"; diff --git a/apps/web/app/(app)/runners/page.tsx b/apps/web/app/(app)/runners/page.tsx index 8037e427..53e4fd19 100644 --- a/apps/web/app/(app)/runners/page.tsx +++ b/apps/web/app/(app)/runners/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { Search, SquareTerminal } from "lucide-react"; import { listUserProjects, runnerStories, listUserSessions, RUNNER_FILTERS, sessionSteps, type RunnerFilter, type SessionView } from "@peppa/core"; import { LiveRefresh } from "@/components/LiveRefresh"; diff --git a/apps/web/app/(app)/sessions/page.tsx b/apps/web/app/(app)/sessions/page.tsx index 95309001..bd8c7204 100644 --- a/apps/web/app/(app)/sessions/page.tsx +++ b/apps/web/app/(app)/sessions/page.tsx @@ -2,7 +2,7 @@ // «Сессии» (PEP-257): one place for the terminals of all live agent sessions of the user's // projects. Left — the list, right — the terminal of the chosen one, open right away: the first // of the list without `?id`, the given one with it (a story links here with its session). -import Link from "next/link"; +import Link from "@/components/Link"; import { SquareTerminal } from "lucide-react"; import { FINISHED_SESSION_STATUSES, listUserSessions, PROVIDER_NAMES, type SessionView } from "@peppa/core"; import { AgentBadge } from "@/components/AgentBadge"; diff --git a/apps/web/app/(app)/t/[key]/page.tsx b/apps/web/app/(app)/t/[key]/page.tsx index 801cc34f..13b5d8a8 100644 --- a/apps/web/app/(app)/t/[key]/page.tsx +++ b/apps/web/app/(app)/t/[key]/page.tsx @@ -2,7 +2,7 @@ // OpenSpec artifacts and the course of work (?tab=). Live updates — PEP-37, agent steps — PEP-33. import { queuePositions } from "@peppa/core"; import { Markdown } from "@/components/Markdown"; -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { Archive, ArchiveRestore, ChevronDown, ChevronRight, CircleCheck, CircleX, GitPullRequest, Hourglass, Lock, Pencil, Play, X } from "lucide-react"; import { diff --git a/apps/web/app/(app)/users/merge/page.tsx b/apps/web/app/(app)/users/merge/page.tsx index 83cb77ba..82b14cfa 100644 --- a/apps/web/app/(app)/users/merge/page.tsx +++ b/apps/web/app/(app)/users/merge/page.tsx @@ -1,5 +1,5 @@ // glossary-ignore-file: the page is for the superadmin only (accounts, repositories, Gitea spaces). -import Link from "next/link"; +import Link from "@/components/Link"; import { notFound } from "next/navigation"; import { isSuperadmin, maskIin, mergePlan, PeppaError } from "@peppa/core"; import { Hidden } from "@/components/cards"; diff --git a/apps/web/app/(app)/users/page.tsx b/apps/web/app/(app)/users/page.tsx index 3f682e28..f4ead79f 100644 --- a/apps/web/app/(app)/users/page.tsx +++ b/apps/web/app/(app)/users/page.tsx @@ -1,5 +1,5 @@ import { notFound } from "next/navigation"; -import Link from "next/link"; +import Link from "@/components/Link"; import { canLogIn, isLocalUser, isSuperadmin, listUsers, maskIin, mergeHints, platformAdmins } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { ago, Flash, PageHeader, Section } from "@/components/common"; diff --git a/apps/web/app/(app)/welcome/page.tsx b/apps/web/app/(app)/welcome/page.tsx index 30a750e3..80ac618e 100644 --- a/apps/web/app/(app)/welcome/page.tsx +++ b/apps/web/app/(app)/welcome/page.tsx @@ -1,5 +1,5 @@ // PEP-92: the welcome page for everyone who signs in — why Peppa, how work goes, where to click. -import Link from "next/link"; +import Link from "@/components/Link"; import { ArrowRight, Check } from "lucide-react"; import { Workspace } from "@/components/Workspace"; import { PageHeader, Section } from "@/components/common"; diff --git a/apps/web/components/Accounting.tsx b/apps/web/components/Accounting.tsx index 7cd8d9d9..1331895b 100644 --- a/apps/web/components/Accounting.tsx +++ b/apps/web/components/Accounting.tsx @@ -1,5 +1,5 @@ // Accounting blocks (PEP-5/43/47/48): the usage strip on top, story budget, project metrics, journal. -import Link from "next/link"; +import Link from "@/components/Link"; import type { ReactNode } from "react"; import { Gauge, Hourglass, Play } from "lucide-react"; import { diff --git a/apps/web/components/ActivityAside.tsx b/apps/web/components/ActivityAside.tsx index 657e3ab1..43857107 100644 --- a/apps/web/components/ActivityAside.tsx +++ b/apps/web/components/ActivityAside.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { ago } from "@/components/common"; import { requireUser, words } from "@/lib/auth"; import { activeSessions, inbox } from "@/lib/queries"; diff --git a/apps/web/components/AgentTaskSummary.tsx b/apps/web/components/AgentTaskSummary.tsx index 73792f14..7d54fb05 100644 --- a/apps/web/components/AgentTaskSummary.tsx +++ b/apps/web/components/AgentTaskSummary.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import type { AgentTaskRow } from "@peppa/core"; import { Badge } from "@/components/ui/badge"; import { getT } from "@/lib/i18n"; diff --git a/apps/web/components/Board.tsx b/apps/web/components/Board.tsx index 1103cf2d..626c25b4 100644 --- a/apps/web/components/Board.tsx +++ b/apps/web/components/Board.tsx @@ -1,7 +1,7 @@ "use client"; import { useWords } from "@/components/Words"; -import Link from "next/link"; +import Link from "@/components/Link"; import { useRouter } from "next/navigation"; import { useEffect, useState, useTransition } from "react"; import { useLiveIsland } from "@/lib/live"; diff --git a/apps/web/components/ChatThreadList.tsx b/apps/web/components/ChatThreadList.tsx index 8be9dfb6..e9b03e91 100644 --- a/apps/web/components/ChatThreadList.tsx +++ b/apps/web/components/ChatThreadList.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { Search, X } from "lucide-react"; import type { ThreadList, ThreadRow } from "@peppa/core"; import { AgentBadge } from "@/components/AgentBadge"; diff --git a/apps/web/components/Errors.tsx b/apps/web/components/Errors.tsx index 1dea4af3..72b33a71 100644 --- a/apps/web/components/Errors.tsx +++ b/apps/web/components/Errors.tsx @@ -1,7 +1,7 @@ // PEP-218: production errors read from Bugsink on the server — summary, filters, rows and the // error card blocks. «Инженер» and the superadmin (`tech`) also see code places, releases, // stacks and tags; «Продакт» — the title, how often, when and the bug task. -import Link from "next/link"; +import Link from "@/components/Link"; import { Bug, TrendingUp } from "lucide-react"; import type { ErrorDetail, ErrorFilter, ErrorRow, ErrorScope, ErrorsOverview, ErrorState } from "@peppa/core"; import { m, type Translator } from "@peppa/shared/i18n"; diff --git a/apps/web/components/Feedback.tsx b/apps/web/components/Feedback.tsx index 17311b22..16ff1330 100644 --- a/apps/web/components/Feedback.tsx +++ b/apps/web/components/Feedback.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { FEEDBACK_ADMIN_STATUS, FEEDBACK_KIND, FEEDBACK_SIZE, FEEDBACK_USER_STATUS, feedbackTitle, type FeedbackView } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { ago, Disclosure } from "@/components/common"; diff --git a/apps/web/components/FeedbackButton.tsx b/apps/web/components/FeedbackButton.tsx index 5dd00c27..df275f31 100644 --- a/apps/web/components/FeedbackButton.tsx +++ b/apps/web/components/FeedbackButton.tsx @@ -1,6 +1,6 @@ "use client"; -import Link from "next/link"; +import Link from "@/components/Link"; import { useCallback, useEffect, useRef, useState } from "react"; import { usePathname } from "next/navigation"; import { CircleCheck, ImagePlus, MessageCircleWarning, X } from "lucide-react"; diff --git a/apps/web/components/Link.tsx b/apps/web/components/Link.tsx new file mode 100644 index 00000000..98ab4900 --- /dev/null +++ b/apps/web/components/Link.tsx @@ -0,0 +1,9 @@ +// PEP-273: every link of the console goes through here. Next prefetches each visible in a +// production build; our pages are dynamic, so the home page alone made ~40 server renders per visit. +// Prefetch only where a link asks for it explicitly (`prefetch`). +import NextLink from "next/link"; +import type { ComponentProps } from "react"; + +export default function Link({ prefetch = false, ...props }: ComponentProps) { + return ; +} diff --git a/apps/web/components/PlatformDelays.tsx b/apps/web/components/PlatformDelays.tsx index de076cec..7235aef8 100644 --- a/apps/web/components/PlatformDelays.tsx +++ b/apps/web/components/PlatformDelays.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { DELAY_REASON_NAMES, type DelayView } from "@peppa/core"; import { delayActionForm } from "@/app/(app)/dashboard/actions"; import { Badge } from "@/components/ui/badge"; diff --git a/apps/web/components/PoolSubscriptions.tsx b/apps/web/components/PoolSubscriptions.tsx index 3ae6723d..0a7dcafd 100644 --- a/apps/web/components/PoolSubscriptions.tsx +++ b/apps/web/components/PoolSubscriptions.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from "react"; -import Link from "next/link"; +import Link from "@/components/Link"; import type { PoolOverview, PoolSubscriptionState } from "@peppa/core"; import { intlLocale, type Locale } from "@peppa/shared/i18n"; import { Badge } from "@/components/ui/badge"; diff --git a/apps/web/components/ProductCard.tsx b/apps/web/components/ProductCard.tsx index 05729726..70e466e0 100644 --- a/apps/web/components/ProductCard.tsx +++ b/apps/web/components/ProductCard.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import { ExternalLink, Hourglass, KeyRound, Rocket, Wrench, X } from "lucide-react"; import type { ProductNeedView, ProductReview, ProjectProduct, PublishMode } from "@peppa/core"; import { Hidden } from "@/components/cards"; diff --git a/apps/web/components/ProgressOverview.tsx b/apps/web/components/ProgressOverview.tsx index 3110dea5..0cd99195 100644 --- a/apps/web/components/ProgressOverview.tsx +++ b/apps/web/components/ProgressOverview.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/components/Link"; import type { ProgressOverview as Overview, ProjectProgress } from "@peppa/core"; import { AgentBadge } from "@/components/AgentBadge"; import { Empty, Key } from "@/components/common"; diff --git a/apps/web/components/ProjectErrors.tsx b/apps/web/components/ProjectErrors.tsx index 154b8791..b2666d1e 100644 --- a/apps/web/components/ProjectErrors.tsx +++ b/apps/web/components/ProjectErrors.tsx @@ -1,6 +1,6 @@ // PEP-218: the project's tab «Баги» — errors of its own Bugsink projects (`-web` / // `-api`), read on the server, in the same view as the superadmin's /observability. -import Link from "next/link"; +import Link from "@/components/Link"; import { errorScope, listErrors } from "@peppa/core"; import { ErrorFilters, errorFilterFrom, ErrorRows, ErrorsDown } from "@/components/Errors"; import { Section } from "@/components/common"; diff --git a/apps/web/components/RunnerConsole.tsx b/apps/web/components/RunnerConsole.tsx index 780ba020..273f37f0 100644 --- a/apps/web/components/RunnerConsole.tsx +++ b/apps/web/components/RunnerConsole.tsx @@ -1,5 +1,5 @@ // Runners console (PEP-38): list rows with status and limit info, and the details panel of the chosen runner. -import Link from "next/link"; +import Link from "@/components/Link"; import { SquareTerminal, X } from "lucide-react"; import { FINISHED_SESSION_STATUSES, PROVIDER_NAMES, type RunnerTaskView, type SessionView, type StepView } from "@peppa/core"; import { RunnerStories } from "@/components/Runners"; diff --git a/apps/web/components/Sidebar.tsx b/apps/web/components/Sidebar.tsx index 78d5d340..a8a259f6 100644 --- a/apps/web/components/Sidebar.tsx +++ b/apps/web/components/Sidebar.tsx @@ -1,6 +1,6 @@ "use client"; -import Link from "next/link"; +import Link from "@/components/Link"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; import { useLive } from "@/lib/live"; diff --git a/apps/web/components/cards.tsx b/apps/web/components/cards.tsx index 2c8ab1b7..5f65a77e 100644 --- a/apps/web/components/cards.tsx +++ b/apps/web/components/cards.tsx @@ -1,5 +1,5 @@ // Domain cards shared by pages: agent questions, runners, project list. -import Link from "next/link"; +import Link from "@/components/Link"; import { BellRing, CircleCheck, CircleHelp, FileCheck, Hourglass, Play, RotateCcw, Send, ShieldQuestion, Square, SquareTerminal } from "lucide-react"; import { pausedProjectIds, messageDetails, questionAuthor, questionDetails, questionIsFreeText, questionState, questionText, questionType, splitForDisplay, trashDaysLeft, type Project, type Question, type SessionView, type StepView } from "@peppa/core"; import { db } from "@/lib/db"; diff --git a/apps/web/components/common.tsx b/apps/web/components/common.tsx index 163aae8c..fea4fa6f 100644 --- a/apps/web/components/common.tsx +++ b/apps/web/components/common.tsx @@ -1,5 +1,5 @@ // Page building blocks of the console (PEP-38): header, sections, empty states, status badges, alerts. -import Link from "next/link"; +import Link from "@/components/Link"; import type { ReactNode } from "react"; import { CircleAlert, CircleCheck } from "lucide-react"; import { Badge } from "@/components/ui/badge"; diff --git a/openspec/changes/pep-273-fast-gitea-no-prefetch/tasks.md b/openspec/changes/pep-273-fast-gitea-no-prefetch/tasks.md index b90a65ce..5b28f310 100644 --- a/openspec/changes/pep-273-fast-gitea-no-prefetch/tasks.md +++ b/openspec/changes/pep-273-fast-gitea-no-prefetch/tasks.md @@ -4,8 +4,8 @@ - [x] 1.3 Мок `/repos/search` и тест `gitea-overview-speed.test.ts` ## 2. Предзагрузка -- [ ] 2.1 `components/Link.tsx` и замена импортов `next/link` -- [ ] 2.2 Тест `no-prefetch.test.ts` +- [x] 2.1 `components/Link.tsx` и замена импортов `next/link` +- [x] 2.2 Тест `no-prefetch.test.ts` ## 3. Завершение - [ ] 3.1 Проверки (lint, typecheck, тесты), память, archive, PR diff --git a/packages/testkit/test/no-prefetch.test.ts b/packages/testkit/test/no-prefetch.test.ts new file mode 100644 index 00000000..78ba88a8 --- /dev/null +++ b/packages/testkit/test/no-prefetch.test.ts @@ -0,0 +1,35 @@ +// PEP-273, spec web-speed «Ссылки не предзагружают страницы»: links of the console go through +// `@/components/Link` (prefetch off by default), never `next/link` directly. +import assert from "node:assert/strict"; +import { readdirSync, readFileSync, statSync } from "node:fs"; +import { join, relative } from "node:path"; +import { describe, test } from "node:test"; + +const WEB = new URL("../../../apps/web/", import.meta.url).pathname; +const WRAPPER = "components/Link.tsx"; + +function files(dir: string, out: string[] = []): string[] { + for (const name of readdirSync(dir)) { + if (name === "node_modules" || name.startsWith(".")) continue; + const p = join(dir, name); + if (statSync(p).isDirectory()) files(p, out); + else if (/\.(tsx?|jsx?)$/.test(name)) out.push(p); + } + return out; +} + +describe("Ссылки не предзагружают страницы", () => { + test("Прямой импорт next/link", () => { + const bad = ["app", "components", "lib"] + .flatMap((d) => files(join(WEB, d))) + .map((p) => relative(WEB, p)) + .filter((p) => p !== WRAPPER && /from\s+["']next\/link["']/.test(readFileSync(join(WEB, p), "utf8"))); + assert.deepEqual(bad, [], `import Link from "@/components/Link" instead of "next/link" in: ${bad.join(", ")}`); + }); + + test("Главная открывается без предзагрузки: обёртка выключает её по умолчанию", () => { + const src = readFileSync(join(WEB, WRAPPER), "utf8"); + assert.match(src, /prefetch\s*=\s*false/); + assert.match(src, /prefetch=\{prefetch\}/); + }); +});