[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
51
components/terminal/useServerStats.test.ts
Normal file
51
components/terminal/useServerStats.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
|
||||
test("server stats retry can restart polling after give-up", () => {
|
||||
const source = readFileSync(new URL("../../application/state/useServerStats.ts", import.meta.url), "utf8");
|
||||
const reconcileStart = source.indexOf("function reconcileSharedServerStatsSession");
|
||||
const shouldRestartCheck = source.indexOf("const shouldRestartPolling", reconcileStart);
|
||||
const givenUpCheck = source.indexOf("if (session.givenUp) return;", shouldRestartCheck);
|
||||
const markPollingActive = source.indexOf("session.pollingActive = true", shouldRestartCheck);
|
||||
|
||||
assert.notEqual(reconcileStart, -1);
|
||||
assert.notEqual(shouldRestartCheck, -1);
|
||||
assert.notEqual(givenUpCheck, -1);
|
||||
assert.notEqual(markPollingActive, -1);
|
||||
assert.ok(givenUpCheck < markPollingActive);
|
||||
});
|
||||
|
||||
test("server stats stale requests do not block a fresh visible fetch", () => {
|
||||
const source = readFileSync(new URL("../../application/state/useServerStats.ts", import.meta.url), "utf8");
|
||||
|
||||
assert.match(source, /inflightGeneration: number \| null/);
|
||||
assert.match(source, /session\.inflight && session\.inflightGeneration === session\.fetchGeneration/);
|
||||
assert.match(source, /session\.inflightGeneration = generation/);
|
||||
});
|
||||
|
||||
test("server stats polling does not stop when its terminal is in the background", () => {
|
||||
const source = readFileSync(new URL("../../application/state/useServerStats.ts", import.meta.url), "utf8");
|
||||
|
||||
assert.doesNotMatch(source, /isVisible/);
|
||||
assert.doesNotMatch(source, /getVisibleServerStatsClients/);
|
||||
assert.doesNotMatch(source, /resuming from hidden/);
|
||||
});
|
||||
|
||||
test("server stats keep last snapshot when all consumers pause", () => {
|
||||
const source = readFileSync(new URL("../../application/state/useServerStats.ts", import.meta.url), "utf8");
|
||||
const reconcileStart = source.indexOf("function reconcileSharedServerStatsSession");
|
||||
const idleBranch = source.indexOf("if (activeClients.length === 0)", reconcileStart);
|
||||
const nextFunction = source.indexOf("\nfunction ", reconcileStart + 1);
|
||||
const idleBody = source.slice(idleBranch, nextFunction === -1 ? undefined : nextFunction);
|
||||
|
||||
assert.notEqual(reconcileStart, -1);
|
||||
assert.notEqual(idleBranch, -1);
|
||||
// Pausing must not wipe lastUpdated stats (Overview tab-switch empty flash).
|
||||
assert.match(idleBody, /clearServerStatsTimers\(session\)/);
|
||||
assert.doesNotMatch(idleBody, /resetServerStatsSession\(session\)/);
|
||||
assert.doesNotMatch(idleBody, /createInitialState/);
|
||||
// But give-up must clear so resume can auto-retry after hard failure.
|
||||
assert.match(idleBody, /session\.givenUp = false/);
|
||||
assert.match(idleBody, /session\.consecutiveFailures = 0/);
|
||||
});
|
||||
Reference in New Issue
Block a user