Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3148ddf840 |
No files matched your search
@@ -174,20 +174,20 @@ it("continues to step3 while sample GET is pending without calling completion AP
|
||||
expect(screen.queryByText(/^已生成.*记忆/)).toBeNull();
|
||||
});
|
||||
it.each([
|
||||
["pending", "已扫描 100 条,正在筛选"],
|
||||
["paused", "已扫描 100 条,尚未保存"],
|
||||
["interrupted", "已扫描 100 条,尚未保存"],
|
||||
["failed", "已扫描 100 条,尚未保存"],
|
||||
["cancelled", "已扫描 100 条,尚未保存"],
|
||||
["completed", "已扫描 100 条,本次没有可保存的对话"],
|
||||
"pending",
|
||||
"paused",
|
||||
"interrupted",
|
||||
"failed",
|
||||
"cancelled",
|
||||
"completed",
|
||||
] as const)(
|
||||
"shows %s without mutating jobs or fetching missing content",
|
||||
(status, expected) => {
|
||||
(status) => {
|
||||
setup({
|
||||
jobs: [{ ...job, status, stored: 0 }],
|
||||
sources: [{ ...source, imported_messages: 0 }],
|
||||
});
|
||||
expect(screen.getByText(expected)).toBeTruthy();
|
||||
expect(screen.getByText("已扫描 100 条,正在保存")).toBeTruthy();
|
||||
expect(api.receipt).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -38,71 +38,6 @@ it("uses the selected job's message count, never the source total or fake percen
|
||||
expect(container.textContent).not.toContain("%");
|
||||
expect(container.textContent).not.toContain("持续导入中");
|
||||
});
|
||||
|
||||
it("does not describe scanned-but-skipped history as saved", () => {
|
||||
const { container } = render(
|
||||
<R6ImportProgress
|
||||
sourceIds={["cursor"]}
|
||||
sources={[source]}
|
||||
jobs={[
|
||||
{
|
||||
...job,
|
||||
status: "completed",
|
||||
discovered: 12_375,
|
||||
stored: 0,
|
||||
skipped: 12_375,
|
||||
history_after: "2026-10-15T00:00:00Z",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
screen.getByText("已扫描 12,375 条,本次没有符合时间范围的对话"),
|
||||
).toBeTruthy();
|
||||
expect(screen.getByText("导入完成")).toBeTruthy();
|
||||
expect(container.textContent).not.toContain("正在保存");
|
||||
expect(container.textContent).not.toContain("已保存 12,375");
|
||||
});
|
||||
|
||||
it("calls an active bounded scan filtering rather than saving", () => {
|
||||
render(
|
||||
<R6ImportProgress
|
||||
sourceIds={["cursor"]}
|
||||
sources={[source]}
|
||||
jobs={[
|
||||
{
|
||||
...job,
|
||||
discovered: 3_522,
|
||||
stored: 0,
|
||||
history_after: "2026-10-15T00:00:00Z",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("已扫描 3,522 条,正在筛选最近 3 天")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("reports only stored rows as saved after a completed partial import", () => {
|
||||
const { container } = render(
|
||||
<R6ImportProgress
|
||||
sourceIds={["cursor"]}
|
||||
sources={[source]}
|
||||
jobs={[
|
||||
{
|
||||
...job,
|
||||
status: "completed",
|
||||
discovered: 25_177,
|
||||
stored: 20_826,
|
||||
skipped: 4_351,
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("已保存 20,826 条消息")).toBeTruthy();
|
||||
expect(screen.getByText("导入完成")).toBeTruthy();
|
||||
expect(container.textContent).not.toContain("25,177");
|
||||
});
|
||||
|
||||
it.each(["paused", "interrupted", "failed", "completed", "cancelled"] as const)(
|
||||
"does not animate %s as active work",
|
||||
(status) => {
|
||||
|
||||
@@ -3,21 +3,6 @@ import { useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { AppMark } from "./app-mark";
|
||||
import "./r6-import-progress.css";
|
||||
|
||||
function progressText(job: ImportJob): string | null {
|
||||
if (job.stored > 0) return `已保存 ${job.stored.toLocaleString()} 条消息`;
|
||||
if (job.discovered <= 0) return null;
|
||||
const scanned = `已扫描 ${job.discovered.toLocaleString()} 条`;
|
||||
if (job.status === "completed")
|
||||
return job.history_after
|
||||
? `${scanned},本次没有符合时间范围的对话`
|
||||
: `${scanned},本次没有可保存的对话`;
|
||||
if (job.status === "pending" || job.status === "running")
|
||||
return job.history_after
|
||||
? `${scanned},正在筛选最近 3 天`
|
||||
: `${scanned},正在筛选`;
|
||||
return `${scanned},尚未保存`;
|
||||
}
|
||||
|
||||
export function R6ImportProgress({
|
||||
sourceIds,
|
||||
sources,
|
||||
@@ -101,9 +86,8 @@ export function R6ImportProgress({
|
||||
interrupted: "已中断",
|
||||
failed: "导入遇到问题",
|
||||
cancelled: "已取消",
|
||||
completed: "导入完成",
|
||||
completed: "已保存",
|
||||
};
|
||||
const progress = job ? progressText(job) : null;
|
||||
return (
|
||||
<article
|
||||
className="r6-import-progress-card"
|
||||
@@ -118,8 +102,10 @@ export function R6ImportProgress({
|
||||
</div>
|
||||
</div>
|
||||
<h2>{source?.display_name ?? id}</h2>
|
||||
{progress ? (
|
||||
<p>{progress}</p>
|
||||
{job && job.stored > 0 ? (
|
||||
<p>{`已保存 ${job.stored.toLocaleString()} 条消息`}</p>
|
||||
) : job && job.discovered > 0 ? (
|
||||
<p>{`已扫描 ${job.discovered.toLocaleString()} 条,正在保存`}</p>
|
||||
) : noImportedHistory ? (
|
||||
<p>没有可保存的历史对话</p>
|
||||
) : null}
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
mkdir,
|
||||
readdir,
|
||||
readFile,
|
||||
readlink,
|
||||
realpath,
|
||||
rm,
|
||||
stat,
|
||||
@@ -321,12 +320,6 @@ async function distributionBytes(source) {
|
||||
|
||||
async function sha256File(file) {
|
||||
const digest = createHash("sha256");
|
||||
const info = await lstat(file);
|
||||
if (info.isSymbolicLink()) {
|
||||
digest.update("symlink\0");
|
||||
digest.update(await readlink(file));
|
||||
return digest.digest("hex");
|
||||
}
|
||||
for await (const chunk of createReadStream(file)) digest.update(chunk);
|
||||
return digest.digest("hex");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
readdir,
|
||||
readFile,
|
||||
rm,
|
||||
symlink,
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
@@ -122,35 +121,6 @@ test("builds versioned Runtime archives, checksums and a downloader-compatible m
|
||||
}
|
||||
});
|
||||
|
||||
test("verifies Runtime symlinks with the same identity rule as the installer", async (t) => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "memhub-release-assets-"));
|
||||
t.after(() => rm(root, { recursive: true, force: true }));
|
||||
const source = await distribution(root, "linux", "x64");
|
||||
const link = "memhub";
|
||||
await symlink(link, path.join(source, "bin", "node"));
|
||||
const manifestPath = path.join(source, "manifest.json");
|
||||
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
||||
manifest.files["bin/node"] = sha256(`symlink\0${link}`);
|
||||
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
|
||||
const release = await buildReleaseAssets({
|
||||
output: path.join(root, "release"),
|
||||
version: "0.1.0-internal.1",
|
||||
channel: "prerelease",
|
||||
assetBaseUrl: "https://git.example.test/release/downloads/",
|
||||
distributions: [source],
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
release.artifacts.some(
|
||||
(artifact) =>
|
||||
artifact.kind === "runtime" &&
|
||||
artifact.platform === "linux" &&
|
||||
artifact.arch === "x64",
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test("refuses version, build and duplicate target drift", async (t) => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "memhub-release-assets-"));
|
||||
t.after(() => rm(root, { recursive: true, force: true }));
|
||||
|
||||
Reference in new issue
Block a user