Preserve terminal output across log sessions

This commit is contained in:
npc0-hue
2026-08-31 04:59:03 +08:00
parent 4e9a2bfeaa
commit 9691dbcb3d
2 changed files with 9 additions and 8 deletions
@@ -111,7 +111,7 @@ describe("ServerManagementTerminalDrawer", () => {
expect(apiMocks.dispatchSourceRCONCommand).not.toHaveBeenCalled();
});
it("clears generation A on a new session and rejects late generation A events", async () => {
it("keeps visible output on a new session and rejects late generation A events", async () => {
await renderDrawer();
await emitSession("session-a");
await emitStream(logStream("stdout-a", "session-a", "process.stdout"));
@@ -122,14 +122,14 @@ describe("ServerManagementTerminalDrawer", () => {
await emitStream(logStream("stdout-b", "session-b", "process.stdout"));
await emitLog("stdout-b", "session-b", "process.stdout", logEntry(1, "generation B output"));
expect(container?.textContent).not.toContain("generation A output");
expect(container?.textContent).toContain("generation A output");
expect(container?.textContent).not.toContain("late generation A output");
expect(container?.textContent).toContain("generation B output");
expect(container?.textContent).toContain("Run 已切换到新的受管进程输出会话");
expect(apiMocks.openServerLogEvents).toHaveBeenCalledTimes(1);
});
it("clears a stopped session and restores the running session on the same SSE connection", async () => {
it("keeps visible output through a stopped boundary and restores the running session on the same SSE connection", async () => {
await renderDrawer();
await emitSession("session-a");
await emitStream(logStream("stdout-a", "session-a", "process.stdout"));
@@ -137,14 +137,14 @@ describe("ServerManagementTerminalDrawer", () => {
await emitSession();
await emitLog("stdout-a", "session-a", "process.stdout", logEntry(2, "late output after stop"));
expect(container?.textContent).not.toContain("running output before stop");
expect(container?.textContent).toContain("running output before stop");
expect(container?.textContent).not.toContain("late output after stop");
expect(container?.textContent).toContain("当前没有可跟随的受管进程输出");
await emitSession("session-b");
await emitStream(logStream("stdout-b", "session-b", "process.stdout"));
await emitLog("stdout-b", "session-b", "process.stdout", logEntry(1, "running output after recovery"));
expect(container?.textContent).not.toContain("running output before stop");
expect(container?.textContent).toContain("running output before stop");
expect(container?.textContent).toContain("running output after recovery");
expect(apiMocks.openServerLogEvents).toHaveBeenCalledTimes(1);
});