PEP-273: ссылки веба без предзагрузки — обёртка @/components/Link

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
peppa-bot 2026-11-26 20:34:02 +00:00
parent 96fa6151ab
commit f6ae77efe1
44 changed files with 87 additions and 43 deletions

View File

@ -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";

View File

@ -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";

View File

@ -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,

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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 {

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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 {

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -0,0 +1,9 @@
// PEP-273: every link of the console goes through here. Next prefetches each visible <Link> 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<typeof NextLink>) {
return <NextLink prefetch={prefetch} {...props} />;
}

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -1,6 +1,6 @@
// PEP-218: the project's tab «Баги» — errors of its own Bugsink projects (`<KEY>-web` /
// `<KEY>-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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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

View File

@ -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\}/);
});
});