Merge main into task/pep-98: PEP-128 texts through the dictionary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
43baa7ca4c
@ -3,7 +3,7 @@ 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, sharedRequest } from "@peppa/runner";
|
||||
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 { poolSubscriptions, 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";
|
||||
@ -120,6 +120,11 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr
|
||||
const poolView = pool ? await poolOverview(db, pool.id) : null;
|
||||
// PEP-80: the owner's own subscriptions — a ChatGPT device login in progress, and whether a pool exists already.
|
||||
const mayChoose = isOwner || superadmin;
|
||||
// PEP-128: a pool whose every sign-in failed or is unfinished is as good as no subscription —
|
||||
// the owner gets the connection wizard again, with what went wrong.
|
||||
const poolSubs = pool ? await poolSubscriptions(db, pool.id) : [];
|
||||
const connected = poolSubs.some((s) => s.status === "active" || s.status === "limited");
|
||||
const failedLogins = poolSubs.filter((s) => s.status === "auth_error").map((s) => ({ provider: s.provider, timedOut: /timed out/i.test(s.lastError ?? "") }));
|
||||
const [ownLogins, hasOwnPool] = await Promise.all([mayChoose && pool ? ownPendingLogins(db, pool.id) : Promise.resolve([]), mayChoose ? ownPool(db, user.id).then((x) => !!x) : Promise.resolve(false)]);
|
||||
// Epic filter (PEP-66): only an open epic of this project filters; anything else shows all.
|
||||
const epicFilter = epics.find((e) => String(e.id) === epicParam) ?? null;
|
||||
@ -470,7 +475,9 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr
|
||||
<a href={repo.url} className="text-primary">{repo.fullName}</a> · {t.text(repoVisibilityLabel(repo.private))}
|
||||
</PageHeader>
|
||||
|
||||
{mayChoose && (ownLogins.length > 0 || (!pool && agentWarning)) && <SubscriptionSetup projectId={p.id} back={back} logins={ownLogins} shared={!!shared} requested={!!sharedReq} direct={superadmin} />}
|
||||
{mayChoose && (ownLogins.length > 0 || (agentWarning && !connected)) && (
|
||||
<SubscriptionSetup projectId={p.id} back={back} logins={ownLogins} shared={!!shared} requested={!!sharedReq} direct={superadmin} failed={failedLogins} />
|
||||
)}
|
||||
{agentWarning && !(mayChoose && (ownLogins.length > 0 || !pool)) && (
|
||||
<p role="alert" className="mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-warn/40 bg-warn/10 px-4 py-3 text-sm">
|
||||
<span className="font-medium">{t("Агенты не запустятся:")}</span> {t.text(agentWarning)}.
|
||||
|
||||
@ -14,7 +14,7 @@ const num = "grid size-5.5 shrink-0 place-items-center rounded-full bg-primary/1
|
||||
* PEP-82: connecting the owner's own subscription without a terminal, in plain steps, right on
|
||||
* the project page — «Подключить Claude» / «Подключить ChatGPT», then the link and the code.
|
||||
*/
|
||||
export async function SubscriptionSetup({ projectId, back, logins, shared = false, requested = false, direct = false }: { projectId: number; back: string; logins: OwnLogin[]; shared?: boolean; /** The owner already asked for the factory's subscription. */ requested?: boolean; /** A superadmin switches without a request. */ direct?: boolean }) {
|
||||
export async function SubscriptionSetup({ projectId, back, logins, shared = false, requested = false, direct = false, failed = [] }: { projectId: number; back: string; logins: OwnLogin[]; shared?: boolean; /** The owner already asked for the factory's subscription. */ requested?: boolean; /** A superadmin switches without a request. */ direct?: boolean; /** PEP-128: earlier sign-ins that did not finish. */ failed?: Array<{ provider: string; timedOut: boolean }> }) {
|
||||
const t = await getT();
|
||||
if (logins.length) {
|
||||
return (
|
||||
@ -118,6 +118,14 @@ export async function SubscriptionSetup({ projectId, back, logins, shared = fals
|
||||
return (
|
||||
<section className="mb-4 flex flex-col gap-3 rounded-lg border border-warn/50 bg-warn/10 px-4 py-4 text-sm" aria-label={t("Подключение подписки")}>
|
||||
<h2 className="m-0 text-base font-semibold">{shared ? t("Выберите, на чём будут работать агенты") : t("Подключите подписку — и агенты начнут работать")}</h2>
|
||||
{failed.length > 0 && (
|
||||
<p className="m-0 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2">
|
||||
<b>{t("Прошлое подключение не завершилось.")}</b>{" "}
|
||||
{failed.some((f) => f.timedOut)
|
||||
? t("Время на вход вышло (на него даётся 15 минут). Ничего страшного — нажмите кнопку ниже и пройдите шаги ещё раз, код будет новый.")
|
||||
: t("Вход не удался. Нажмите кнопку ниже и пройдите шаги ещё раз.")}
|
||||
</p>
|
||||
)}
|
||||
<div className={shared ? "grid gap-3 md:grid-cols-2" : "flex flex-col gap-3"}>
|
||||
<div className="flex flex-col gap-2 rounded-lg border bg-card px-4 py-3">
|
||||
{shared && <span className="font-medium">{t("Своя подписка")}</span>}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
# Proposal: PEP-128 — после неудачного входа мастер подключения показывается снова
|
||||
|
||||
## Why
|
||||
У проекта вход в ChatGPT истёк (15 минут). Пул у проекта остался, рабочей подписки в нём нет, а мастер подключения показывался только проектам без пула — владелец не видел, как повторить.
|
||||
|
||||
## What Changes
|
||||
- Страница проекта: мастер показывается, когда есть предупреждение «агенты не запустятся» и в пуле нет ни одной подключённой подписки (active/limited); при лимите всех подписок мастер не показывается.
|
||||
- В мастере — причина: «Прошлое подключение не завершилось. Время на вход вышло…» (или «вход не удался»).
|
||||
- `connectOwnSubscription`: неудавшиеся (`auth_error`) входы этого пользователя и этого провайдера удаляются перед новой попыткой.
|
||||
@ -0,0 +1,12 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Повтор после неудачного входа в подписку
|
||||
Веб SHALL снова предлагать подключить подписку, когда прошлый вход не завершился, и объяснять почему.
|
||||
|
||||
#### Scenario: Вход истёк по времени
|
||||
- **WHEN** вход в ChatGPT не завершён за 15 минут и других подписок у проекта нет
|
||||
- **THEN** на странице проекта снова мастер подключения с пометкой «время на вход вышло», а новая попытка удаляет неудавшуюся запись
|
||||
|
||||
#### Scenario: Все подписки в лимите
|
||||
- **WHEN** подписки проекта подключены, но упёрлись в лимит
|
||||
- **THEN** мастер подключения не показывается
|
||||
@ -0,0 +1,3 @@
|
||||
- [x] 1.1 мастер при пуле без подключённых подписок, причина неудачи
|
||||
- [x] 1.2 уборка неудавшихся входов при повторе; тест
|
||||
- [x] 1.3 проверка в браузере на копии базы
|
||||
@ -109,6 +109,13 @@ export async function connectOwnSubscription(db: Db, user: User, project: Projec
|
||||
if (!pool) throw new PeppaError(m("Своей подписки ещё нет — подключите Claude или ChatGPT"));
|
||||
} else {
|
||||
if (kind !== "codex_login" && kind !== "claude_login" && !secret.trim()) throw new PeppaError(kind === "claude" ? m("Вставьте токен: выполните `claude setup-token` на своём компьютере и скопируйте результат") : m("Вставьте ключ OpenAI API"));
|
||||
// PEP-128: a sign-in of this user that failed earlier (timed out, refused) is dropped before
|
||||
// the new attempt, so the pool does not fill with dead entries.
|
||||
const provider = kind === "claude_login" || kind === "claude" ? "claude" : "codex";
|
||||
if (pool) {
|
||||
const stale = (await poolSubscriptions(db, pool.id)).filter((s) => s.status === "auth_error" && s.provider === provider && s.createdBy === user.id);
|
||||
for (const s of stale) await removeSubscription(db, s.id);
|
||||
}
|
||||
const taken = new Set((await listSubscriptions(db)).map((s) => s.name));
|
||||
const base = `${OWN_NAMES[kind]} — ${user.login}`;
|
||||
let name = base;
|
||||
|
||||
@ -337,4 +337,8 @@ export const merge: Dict = {
|
||||
"ответ не по форме": "the reply was malformed",
|
||||
"у проекта не подключена подписка Claude — «⋯ Настройки проекта → Подписки»": "the project has no Claude subscription connected — “⋯ Project settings → Subscriptions”",
|
||||
"Не смог уточнить постановку ({why}). Описание стори не менял — комментарий увидит агент, когда возьмётся за стори.": "Couldn't refine the story ({why}). The description is unchanged — the agent will see the comment when it picks up the story.",
|
||||
// PEP-128
|
||||
"Прошлое подключение не завершилось.": "The previous connection didn't finish.",
|
||||
"Время на вход вышло (на него даётся 15 минут). Ничего страшного — нажмите кнопку ниже и пройдите шаги ещё раз, код будет новый.": "Time for signing in ran out (you get 15 minutes). No problem — click the button below and go through the steps again; you'll get a new code.",
|
||||
"Вход не удался. Нажмите кнопку ниже и пройдите шаги ещё раз.": "Sign-in failed. Click the button below and go through the steps again.",
|
||||
};
|
||||
|
||||
@ -329,6 +329,21 @@ describe("PEP-76: владелец выбирает подписку проек
|
||||
}
|
||||
});
|
||||
|
||||
test("PEP-128: a failed sign-in is dropped by the next attempt; the project is told it has no working subscription", async () => {
|
||||
const owner = await core.registerEgovUser(db, { iin: "850505400128", name: "ПОВТОРОВ ВХОД" });
|
||||
const p = await core.createProject(db, { slug: "mock-p128", key: "MPRT", name: "P128", giteaOwner: "x", workspacePath: "/tmp/mock-p128", ownerId: owner.id });
|
||||
const first = await runner.connectOwnSubscription(db, owner, p, "codex_login");
|
||||
// The sign-in was never finished: after 15 minutes the watchdog marks it failed.
|
||||
await core.updateSubscription(db, first.subscriptionId!, { status: "auth_error", lastError: "Error logging in: device auth timed out after 15 minutes" });
|
||||
const pool = (await core.ownPool(db, owner.id))!;
|
||||
assert.deepEqual((await core.poolSubscriptions(db, pool.id)).map((x) => x.status), ["auth_error"]);
|
||||
assert.match((await core.projectAgentWarning(db, p.id))!, /нет рабочей подписки/, "the page shows the wizard again");
|
||||
const second = await runner.connectOwnSubscription(db, owner, p, "codex_login");
|
||||
const subs = await core.poolSubscriptions(db, pool.id);
|
||||
assert.deepEqual(subs.map((x) => [x.id, x.status]), [[second.subscriptionId, "pending"]], "the dead entry is gone, the new attempt waits");
|
||||
await runner.cancelLogin(db, second.subscriptionId!).catch(() => {});
|
||||
});
|
||||
|
||||
test("PEP-82: вход в Claude по ссылке и коду на странице проекта, без терминала", async () => {
|
||||
const owner = await core.registerEgovUser(db, { iin: "850505400038", name: "ССЫЛКИН ВХОД" });
|
||||
const stranger = await core.registerEgovUser(db, { iin: "850505400048", name: "ПОСТОРОННИЙ ВХОД" });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user