Initial import of streamline

This commit is contained in:
2026-11-16 17:26:44 -08:00
commit 8e4aec1855
1221 changed files with 274256 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
// Real export components, deterministic local API fixture. No production traffic.
import React, { useState } from "react";
import { createRoot } from "react-dom/client";
import { EddyExportBadge } from "../../src/components/EddyExportPanel";
import StatsStrip from "../../src/components/StatsStrip";
import { applyClusterSnapshot } from "../../src/lib/clusterStore";
import type { ClusterNode } from "../../src/types";
import RelayDialog from "../../src/components/RelayDialog";
import { setLang } from "../../src/lib/i18n";
import type { Feature } from "../../src/types";
import type { EddyExport } from "@bbbug/shared/eddy_export";
import "../../src/styles.css";
setLang("zh");
const feature = { id: "eddy-export-fixture", title: "给收藏列表增加排序入口", platform: "ios", status: "completed", branchName: "feature/collection-sort", repoKey: "tiktok-ios", mrUrl: "https://mr.invalid/123", executorNodeId: "fei-ios-01.shiro0.icu" } as Feature;
const record: EddyExport = { id: "11111111-2222-4333-8444-555555555555", featureId: feature.id, nodeId: "fei-ios-01.shiro0.icu", commit: "1234567890abcdef1234567890abcdef12345678", branch: feature.branchName!, phase: "ready", createdAt: Date.now(), updatedAt: Date.now(), expiresAt: Date.now() + 7 * 86400_000, error: null,
result: { baselineId: "tiktokm-fixture", commit: "1234567890abcdef1234567890abcdef12345678", eddyVersion: "v2.8", devicesimSha256: "a".repeat(64), artifacts: { app: { file: "baseline-tiktokm-fixture.zip", bytes: 782000000, sha256: "b".repeat(64) }, source: { file: "baseline-tiktokm-fixture-source.zip", bytes: 418000000, sha256: "c".repeat(64) } } } };
let jobs: EddyExport[] = [], serviceEnabled = true, creates = 0;
// Two satellites: the executor and a peer. Each mode sets which is up and what the job is doing.
const sat = (id: string, live: boolean, fixInFlight: number): ClusterNode => ({ id, baseUrl: "", platform: "ios", status: live ? "online" : "offline", live,
lastSeenAt: Date.now(), evalInFlight: 0, evalCapacity: 3, fixInFlight, fixCapacity: 1, createdAt: 0, clusters: ["default"] } as ClusterNode);
const fleet = (home: [boolean, number], peer: [boolean, number]) =>
applyClusterSnapshot({ nodes: [sat("fei-ios-01.shiro0.icu", ...home), sat("fei-ios-02.shiro0.icu", ...peer)], eval: { inFlight: 0, capacity: 6 }, fix: { inFlight: home[1] + peer[1], capacity: 2 } });
fleet([true, 0], [true, 0]);
window.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
const url = String(input);
if (url.endsWith("/handover")) return new Response("# Local relay fixture\n");
if (url.endsWith("/lab-runs/running")) return Response.json({ runs: [] });
if (url.endsWith("/eddy-exports/running")) return Response.json({ exports: jobs.filter(j => ["building", "packaging", "verifying", "uploading"].includes(j.phase))
.map(j => ({ id: j.id, featureId: j.featureId, title: feature.title, nodeId: j.nodeId, phase: j.phase })) });
if (!url.endsWith("/eddy-exports")) throw new Error("Fixture refuses network: " + url);
if (init?.method === "POST") { creates++; jobs = [{ ...record, phase: "queued", result: null, expiresAt: null }]; return Response.json({ export: jobs[0] }); }
return Response.json({ enabled: serviceEnabled, exports: jobs });
}) as typeof fetch;
function Fixture() {
const [version, setVersion] = useState(0);
const [open, setOpen] = useState(false);
const [platform, setPlatform] = useState<"ios" | "android">("ios");
const mode = (phase: string) => {
serviceEnabled = phase !== "disabled";
const [state, where] = phase.split(":");
// queued:busy — executor running another task; queued:offline — executor gone; queued:moved — rerouted to a busy peer.
fleet(where === "offline" ? [false, 0] : [true, where === "busy" ? 1 : state === "building" ? 1 : 0], [true, where === "moved" ? 1 : 0]);
jobs = ["empty", "disabled"].includes(state) ? [] : [{ ...record, phase: state as EddyExport["phase"], nodeId: where === "moved" ? "fei-ios-02.shiro0.icu" : record.nodeId,
error: state === "failed" ? "卫星机执行中断或失去连接,可重试导出" : null }];
setVersion(v => v + 1);
};
return <main style={{ maxWidth: 780, height: "100vh", overflow: "auto", margin: "0 auto", padding: 24 }}>
<p>本地界面验证 · 示例数据 · 不连接线上</p>
<div style={{ display: "flex", gap: 8, flexWrap: "wrap", marginBottom: 24 }}>{["empty", "queued", "queued:busy", "queued:offline", "queued:moved", "building", "ready", "failed", "expired", "disabled"].map(s => <button key={s} onClick={() => mode(s)}>{s}</button>)}</div>
<button onClick={() => setPlatform(p => p === "ios" ? "android" : "ios")}>切换平台</button>
<h2>{feature.title}</h2><p>Feature · {platform} · 已完成</p>
{platform === "ios" && jobs[0] && <EddyExportBadge job={jobs[0]} />}
<button onClick={() => setOpen(true)}>接力到本地</button>
{open && <RelayDialog key={version + platform} item={{ ...feature, kind: "feature", platform }} onClose={() => setOpen(false)} onChanged={() => setVersion(v => v + 1)} />}
<output>创建请求:{creates}</output>
<div style={{ width: 300, marginTop: 24 }}><StatsStrip key={version} running={[]} queued={[]} evaluating={[]} awaitingEval={[]} onOpenTask={() => {}} onOpenFeature={() => setOpen(true)} /></div>
</main>;
}
createRoot(document.getElementById("root")!).render(<Fixture />);