Make terminal log stream live-only by default

This commit is contained in:
npc0-hue
2026-08-25 09:42:24 +08:00
parent 199fa8b41d
commit 725b71b6b6
7 changed files with 72 additions and 9 deletions
@@ -69,7 +69,7 @@ afterEach(async () => {
});
describe("ServerManagementTerminalDrawer", () => {
it("shows current-session replay and keeps it on a repeated boundary for the same session", async () => {
it("shows live current-session output and keeps it on a repeated boundary for the same session", async () => {
await renderDrawer();
await emitSession("session-a");
@@ -211,7 +211,7 @@ async function renderDrawer() {
await act(async () => {
root?.render(<ServerManagementTerminalDrawer open serverId="server-1" serverName="SCUM Alpha" pluginId="game.scum" canManage onClose={() => undefined} />);
});
expect(apiMocks.openServerLogEvents).toHaveBeenCalledWith("server-1", { historyLimit: 500 });
expect(apiMocks.openServerLogEvents).toHaveBeenCalledWith("server-1", { historyLimit: 0 });
}
async function emitSession(logSessionId?: string, serverTime = "2026-08-14T00:00:00Z") {
@@ -16,7 +16,8 @@ type TerminalQuickCommand = { label: string; command: string; hint: string };
const terminalJobResultPollMs = 1000;
const terminalJobResultPollAttempts = 30;
const terminalInitialHistoryWindow = 500;
const terminalLiveReplayWindow = 0;
const terminalHistoryWindow = 500;
const maxTerminalLines = 10000;
const terminalQuickCommandCatalog: Record<string, TerminalQuickCommand[]> = {
"game.scum": [
@@ -157,7 +158,7 @@ export function ServerManagementTerminalDrawer({ open, serverId, serverName, plu
useEffect(() => {
if (!open) return undefined;
let ready = false;
const events = platformApiClient.openServerLogEvents(serverId, { historyLimit: terminalInitialHistoryWindow });
const events = platformApiClient.openServerLogEvents(serverId, { historyLimit: terminalLiveReplayWindow });
events.addEventListener("session", (event) => {
const session = parseLogSessionEvent(event);
if (!session) return;
@@ -219,7 +220,7 @@ export function ServerManagementTerminalDrawer({ open, serverId, serverName, plu
setSelectedHistoryStreamId(streamId);
setHistoryLines({ status: "loading" });
try {
const response = await platformApiClient.queryLogStream({ logStreamId: streamId, afterSeq: Math.max(0, stream.latestSeq - terminalInitialHistoryWindow), limit: terminalInitialHistoryWindow });
const response = await platformApiClient.queryLogStream({ logStreamId: streamId, afterSeq: Math.max(0, stream.latestSeq - terminalHistoryWindow), limit: terminalHistoryWindow });
if (historyRequestRef.current !== requestId) return;
setHistoryLines({ status: "ready", data: response.entries.map((entry) => terminalLineFromLog(stream, entry)) });
} catch (error) {