From c739e877f57fae5ade4f663abadb15aa85bb2bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Sun, 15 Nov 2026 15:58:52 +0500 Subject: [PATCH 1/2] PEP-114: a page opened before the site was updated asks to be reloaded Co-Authored-By: Claude Fable 5.2 --- apps/web/app/(app)/layout.tsx | 3 ++ apps/web/app/api/health/route.ts | 4 +- apps/web/components/VersionWatch.tsx | 47 +++++++++++++++++++ apps/web/lib/boot.ts | 9 ++++ .../pep-114-stale-page-banner/proposal.md | 8 ++++ .../specs/web-workspace/spec.md | 12 +++++ .../pep-114-stale-page-banner/tasks.md | 2 + 7 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 apps/web/components/VersionWatch.tsx create mode 100644 apps/web/lib/boot.ts create mode 100644 openspec/changes/pep-114-stale-page-banner/proposal.md create mode 100644 openspec/changes/pep-114-stale-page-banner/specs/web-workspace/spec.md create mode 100644 openspec/changes/pep-114-stale-page-banner/tasks.md diff --git a/apps/web/app/(app)/layout.tsx b/apps/web/app/(app)/layout.tsx index 737eb899..d4631177 100644 --- a/apps/web/app/(app)/layout.tsx +++ b/apps/web/app/(app)/layout.tsx @@ -7,6 +7,8 @@ import { Sidebar } from "@/components/Sidebar"; import { AttentionBadge } from "@/components/AttentionBadge"; import { CommandPalette } from "@/components/CommandPalette"; import { UsageStrip } from "@/components/Accounting"; +import { VersionWatch } from "@/components/VersionWatch"; +import { bootId } from "@/lib/boot"; export const dynamic = "force-dynamic"; @@ -23,6 +25,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
+ {children}
diff --git a/apps/web/app/api/health/route.ts b/apps/web/app/api/health/route.ts index eee4e025..9af75027 100644 --- a/apps/web/app/api/health/route.ts +++ b/apps/web/app/api/health/route.ts @@ -1,4 +1,5 @@ import { healthReport } from "@peppa/core"; +import { bootId } from "@/lib/boot"; import { db } from "@/lib/db"; export const dynamic = "force-dynamic"; @@ -9,5 +10,6 @@ export async function GET() { version: process.env.NEXT_PUBLIC_PEPPA_VERSION, commit: process.env.NEXT_PUBLIC_PEPPA_COMMIT || null, }); - return Response.json(r, { status: r.ok ? 200 : 503, headers: { "Cache-Control": "no-store" } }); + // PEP-114: `boot` changes when the web process restarts — open pages compare it with their own. + return Response.json({ ...r, boot: bootId() }, { status: r.ok ? 200 : 503, headers: { "Cache-Control": "no-store" } }); } diff --git a/apps/web/components/VersionWatch.tsx b/apps/web/components/VersionWatch.tsx new file mode 100644 index 00000000..a412ea7b --- /dev/null +++ b/apps/web/components/VersionWatch.tsx @@ -0,0 +1,47 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { RefreshCw } from "lucide-react"; + +/** + * PEP-114: a page opened before the site was updated may press buttons the new server doesn't + * know — nothing happens and nothing is said. This watches the server's boot id (once a minute + * and when the tab comes back) and asks to reload when it changed. Never reloads by itself: the + * person may be in the middle of typing. + */ +export function VersionWatch({ boot }: { boot: string }) { + const [stale, setStale] = useState(false); + + useEffect(() => { + let alive = true; + const check = async () => { + try { + const r = await fetch("/api/health", { cache: "no-store" }); + const now = ((await r.json()) as { boot?: string }).boot; + if (alive && now && now !== boot) setStale(true); + } catch { + /* offline or restarting: the next check will tell */ + } + }; + const t = setInterval(check, 60_000); + const onVisible = () => document.visibilityState === "visible" && void check(); + document.addEventListener("visibilitychange", onVisible); + window.addEventListener("focus", onVisible); + return () => { + alive = false; + clearInterval(t); + document.removeEventListener("visibilitychange", onVisible); + window.removeEventListener("focus", onVisible); + }; + }, [boot]); + + if (!stale) return null; + return ( +
+ Peppa FACTORY обновилась. Обновите страницу — иначе кнопки на ней могут не сработать. + +
+ ); +} diff --git a/apps/web/lib/boot.ts b/apps/web/lib/boot.ts new file mode 100644 index 00000000..71dc1985 --- /dev/null +++ b/apps/web/lib/boot.ts @@ -0,0 +1,9 @@ +// PEP-114: one id per start of the web process (shared by pages and route handlers through +// globalThis). A page keeps the id it was rendered with; when /api/health reports another one, +// the server was restarted with new code and the page's buttons may no longer be known to it. +const g = globalThis as typeof globalThis & { __peppaBoot?: string }; + +export function bootId(): string { + g.__peppaBoot ??= `${process.env.NEXT_PUBLIC_PEPPA_COMMIT ?? "dev"}-${Date.now().toString(36)}`; + return g.__peppaBoot; +} diff --git a/openspec/changes/pep-114-stale-page-banner/proposal.md b/openspec/changes/pep-114-stale-page-banner/proposal.md new file mode 100644 index 00000000..0c2fb10a --- /dev/null +++ b/openspec/changes/pep-114-stale-page-banner/proposal.md @@ -0,0 +1,8 @@ +# Proposal: PEP-114 — открытая страница просит обновиться после обновления сайта + +## Why +PM нажала «Оставить комментарий» на странице, открытой до перезапуска веба: ничего не произошло и ошибки не было. + +## What Changes +- `lib/boot.ts`: id запуска веб-процесса (`globalThis`), `/api/health` отдаёт его в поле `boot`. +- `VersionWatch` в layout: раз в минуту и при возврате на вкладку сверяет `boot`; при расхождении — плашка «Peppa FACTORY обновилась. Обновите страницу» с кнопкой. Сама страницу не перезагружает (человек может печатать). diff --git a/openspec/changes/pep-114-stale-page-banner/specs/web-workspace/spec.md b/openspec/changes/pep-114-stale-page-banner/specs/web-workspace/spec.md new file mode 100644 index 00000000..152bd218 --- /dev/null +++ b/openspec/changes/pep-114-stale-page-banner/specs/web-workspace/spec.md @@ -0,0 +1,12 @@ +## ADDED Requirements + +### Requirement: Устаревшая страница сообщает о себе +Веб SHALL показывать на странице, открытой до перезапуска сервера, просьбу обновить её. + +#### Scenario: Сайт обновили при открытой странице +- **WHEN** веб перезапущен, а вкладка пользователя открыта раньше +- **THEN** в течение минуты (или при возврате на вкладку) наверху появляется плашка с кнопкой «Обновить страницу» + +#### Scenario: Сайт не менялся +- **WHEN** сервер тот же +- **THEN** плашки нет diff --git a/openspec/changes/pep-114-stale-page-banner/tasks.md b/openspec/changes/pep-114-stale-page-banner/tasks.md new file mode 100644 index 00000000..90d74136 --- /dev/null +++ b/openspec/changes/pep-114-stale-page-banner/tasks.md @@ -0,0 +1,2 @@ +- [x] 1.1 boot id, поле в /api/health, VersionWatch +- [x] 1.2 проверка в браузере (тот же запуск — плашки нет; другой — есть) From 6d18a39acbd031ba5850081b593afc9adeb24d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Sun, 15 Nov 2026 15:42:37 +0500 Subject: [PATCH 2/2] =?UTF-8?q?PEP-111:=20=C2=AB=D0=92=D0=B0=D1=88=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=C2=BB=20=E2=80=94=20?= =?UTF-8?q?where=20the=20result=20runs=20and=20what=20to=20do=20next;=20re?= =?UTF-8?q?leases=20in=20plain=20words?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.2 --- apps/web/app/(app)/p/[key]/page.tsx | 9 ++- apps/web/components/ProductCard.tsx | 76 +++++++++++++++++++ apps/web/components/ProgressOverview.tsx | 5 ++ .../changes/pep-111-your-product/proposal.md | 19 +++++ .../specs/web-workspace/spec.md | 16 ++++ .../changes/pep-111-your-product/tasks.md | 3 + packages/core/src/chats.ts | 10 ++- packages/core/src/index.ts | 1 + packages/core/src/product.ts | 51 +++++++++++++ packages/core/src/progress.ts | 6 +- packages/runner/src/autonomy.ts | 13 +++- packages/runner/src/deploy.ts | 8 +- packages/testkit/test/autonomy-levels.test.ts | 1 + .../testkit/test/platform-release.test.ts | 2 +- packages/testkit/test/product.test.ts | 69 +++++++++++++++++ 15 files changed, 279 insertions(+), 10 deletions(-) create mode 100644 apps/web/components/ProductCard.tsx create mode 100644 openspec/changes/pep-111-your-product/proposal.md create mode 100644 openspec/changes/pep-111-your-product/specs/web-workspace/spec.md create mode 100644 openspec/changes/pep-111-your-product/tasks.md create mode 100644 packages/core/src/product.ts create mode 100644 packages/testkit/test/product.test.ts diff --git a/apps/web/app/(app)/p/[key]/page.tsx b/apps/web/app/(app)/p/[key]/page.tsx index 8ba79fa6..beacefec 100644 --- a/apps/web/app/(app)/p/[key]/page.tsx +++ b/apps/web/app/(app)/p/[key]/page.tsx @@ -1,8 +1,9 @@ import { Fragment } from "react"; +import { ProductCard } from "@/components/ProductCard"; import { notFound } from "next/navigation"; import { ExternalLink, Plus, Rocket, SquareTerminal } from "lucide-react"; import { columnOf, currentReleases, describeRepo, isPlatform, listReleases, bugsinkWebhookBase, openPulls, platformReleaseCandidate, platformReleaseOffers, ownPendingLogins, readAgentsMd, repoOverview, type Release } from "@peppa/runner"; -import { discussionUnread, ensureProjectChat, listHosts, DEFAULT_RUNNER_SETTINGS, DEFAULT_AGENT_SETTINGS, getProjectAgentSettings, getSystemAgentSettings, getProjectRunnerSettings, getSystemRunnerSettings, blockedLabel, blockersMap, epicProgress, progressLabel, taskProgress, getProjectBudget, listJournal, listProjectSecrets, projectMetrics, type ActorChannel, type ActorKind, getAutonomy, getIncidentSettings, getReviewSettings, isSuperadmin, listEpics, listErrorSources, listIncidents, listMembers, listPools, listSpecs, taskAgentNames, getIntakeSettings, intakePendingTasks, projectAgentWarning, memoryStats, readMemory, projectPool, sharedPool, ownPool, poolOverview, repoAudience, repoVisibilityLabel } from "@peppa/core"; +import { userProjectIds, projectProduct, discussionUnread, ensureProjectChat, listHosts, DEFAULT_RUNNER_SETTINGS, DEFAULT_AGENT_SETTINGS, getProjectAgentSettings, getSystemAgentSettings, getProjectRunnerSettings, getSystemRunnerSettings, blockedLabel, blockersMap, epicProgress, progressLabel, taskProgress, getProjectBudget, listJournal, listProjectSecrets, projectMetrics, type ActorChannel, type ActorKind, getAutonomy, getIncidentSettings, getReviewSettings, isSuperadmin, listEpics, listErrorSources, listIncidents, listMembers, listPools, listSpecs, taskAgentNames, getIntakeSettings, intakePendingTasks, projectAgentWarning, memoryStats, readMemory, projectPool, sharedPool, ownPool, poolOverview, repoAudience, repoVisibilityLabel } from "@peppa/core"; import { LiveRefresh } from "@/components/LiveRefresh"; import { PanelSection } from "@/components/ActivityAside"; import { Board, type Card } from "@/components/Board"; @@ -145,6 +146,9 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr const [code, pulls] = await Promise.all([tab === "code" ? repoOverview(db, p) : null, tab === "pulls" ? openPulls(db, p) : null]); const specs = tab === "specs" ? listSpecs(p) : []; const agentsMd = tab === "agents" ? await readAgentsMd(db, p) : null; + const product = await projectProduct(db, p.id); + // The chat belongs to the project's people; a superadmin looking at someone else's project has none. + const canChat = (await userProjectIds(db, user.id)).includes(p.id); const discussionNew = (await discussionUnread(db, user.id)).get((await ensureProjectChat(db, p.id)).id) ?? 0; const memory = tab === "specs" ? readMemory(p.workspacePath) : ""; // PEP-47 metrics, PEP-48 journal, PEP-43 default budget. @@ -461,6 +465,7 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr

)} + {tab === "board" && }