release-2.9.1 (#1557)

* fix(sso): send the PKCE verifier for GitHub login (#1534)

* fix(remote-desktop): clip cursor overflow without disabling zoom (#1535)

* test(remote-desktop): preserve sessions beyond one hour (#1536)

* fix(hosts): expose controls for overflowing editor tabs (#1537)

* fix(hosts): expose controls for overflowing editor tabs

* test(hosts): mock resize observation in admin panel tests

* fix(status): skip TCP probes while host sessions are active (#1538)

* fix(database): batch session activity persistence (#1539)

* docs(api): describe cookie and API key authentication (#1540)

* fix(snippets): repair missing note column on SQLite upgrades (#1541)

* fix(docker): retain stored SSH credential association (#1543)

* fix(file-manager): render transfer toasts without plugin hooks (#1546)

* feat(hosts): keep compact row actions inline (#1547)

* fix(auth): allow retrying unavailable second-factor interfaces (#1549)

* fix(auth): reject unresolved legacy identity provisioning (#1550)

* fix(desktop): ship the plugin SDK inside Mac App Store builds (#1551)

* fix(tmux): pass full session info to the terminal's session picker (#1552)

The tmux.sessions service reduced detected sessions to bare names, but the
picker reads session.name, so every entry rendered blank and selecting one
sent an empty name, which created a new session instead of attaching.

* fix(ssh): read force keyboard-interactive as a boolean when resolving hosts (#1553)

The column holds the text "true"/"false", and the resolver passed it
through as-is. The string "false" is truthy, so the password provider
treated every saved host as forced keyboard-interactive and left the
password out. Jump hops are built straight from the resolved host, so a
password hop whose server doesn't offer keyboard-interactive failed with
"All configured authentication methods failed".

* fix(database): batch database saves for bulk host writes (#1554)

* fix(database): yield to the event loop between database saves

Each SQLite save serializes and encrypts the whole database into new
buffers, which V8 only releases once the event loop turns. Boot
migrations and bulk host import write plugin settings per host and per
key in an awaited loop, so hundreds of full copies piled up and the
container ran out of memory.

* fix(database): save once per bulk host write instead of once per row

On SQLite every repository write force-saves the whole database. Boot
plugin data migrations, host defaults materialization and the bulk
host routes write one row per host per setting, so they serialized and
encrypted the full database hundreds of times in a row.

DatabaseSaveTrigger.batched wraps a function so force saves made while
it runs collapse into a single save when it finishes. Nested scopes fold
into the outer one, and work that outlives its scope saves normally.

* feat(hosts): add instance-wide predefined tag suggestions (#1548)

* feat(hosts): add shared predefined tag suggestions

* style(hosts): format tag catalog routes

* test(database): advance fake timers past the save yield (#1555)

* fix(i18n): complete Simplified Chinese core and plugin translations (#1542)

* fix(i18n): complete Chinese onboarding and navigation labels

* fix(i18n): translate remaining Chinese core and plugin interfaces

* fix(i18n): translate host editor tab overflow controls

* fix(i18n): use consistent Chinese fleet terminology

* fix(i18n): localize hardcoded controls and plugin views

* fix(i18n): translate built-in homepage widget catalog

* test(homepage): follow translated timezone placeholder

* fix(i18n): translate plugin-provided homepage widgets

* fix(i18n): localize feature settings section titles

* fix: 2.8 oidc accounts unable to sign in after upgrading (#1381)

* fix: plugins losing the saved ssh login when copying a host (#1391)

* fix: fleets, proxmox and automations not getting the host sudo password

* fix: host imports running a defaults pass and metrics restart per host (#1384)

* fix: high cpu from status probes and full database saves on every sample (#1300)

* fix: user data export freezing the server (#1393)

* fix: op:// secret references rejected as ssh keys on credentials (#1394)

* fix: slow file deletes from the trash lookups on every delete (#1390)

* fix: add openapi docs and error handling to host tag routes

* test: compare download stream buffers directly so it stops timing out

* chore: drop em dash from host row comment

* chore: update release notes for 2.9.1

* fix: restore space to add host tags and redesign predefined tags editor

* fix: host key silently accepted when the host is missing from the database (#1397)

* fix: clearer host login failed status label and fix its translations (#1396)

* chore: add host key and status label fixes to release notes

* fix: sso and ldap provider dialogs overflowing the screen and using mismatched toggles

* chore: increment ver

* fix(audit): store plugin entries with no acting user as a null user_id (#1556)

Plugin audit entries written outside a request used the literal "system"
as user_id. That column references users.id, so the insert was refused
(Postgres logs it as an FK violation) and the entry was silently dropped.
Write null instead and keep "system" / plugin:<id> in username.

* chore: add sso/ldap dialog and audit log fixes to release notes

* fix: tunnels and host settings missing from shared hosts on desktop

* fix: remote desktop logins missing from shared hosts on desktop

* fix: simplify host status to online/offline and keep it live without a refresh

* chore: sync Crowdin translations for 2.9.1

---------

Co-authored-by: ZacharyZcR <zacharyzcr1984@gmail.com>
This commit is contained in:
Luke GustafsonandZacharyZcR authored and GitHub committed 2026-10-04 15:11:41 -05:00
1 parent 5786eaccbb
commit 6b708106e1
912 files changed
+14220 -2200

No files matched your search

+85 -189
View File
@@ -9,7 +9,8 @@ import React, {
useSyncExternalStore,
useState,
} from "react";
import { getAllServerStatuses, getSSHHosts } from "@/main-axios";
import { getAllServerStatuses } from "@/main-axios";
import { invalidateServerStatusCache } from "./hosts-request-cache";
import {
ServerStatusStore,
type ServerStatusEntry,
@@ -19,17 +20,26 @@ import { runAdaptivePolling } from "./adaptive-polling";
interface ServerStatusContextType {
statuses: Map<number, ServerStatusEntry>;
isLoading: boolean;
initialLoadComplete: boolean;
refreshStatuses: () => Promise<void>;
/** "unknown" until the host has been checked. */
getStatus: (hostId: number) => StatusValue;
}
/** Stable for the provider lifetime — fine-grained hooks only need this. */
/** Stable for the provider lifetime. Fine-grained hooks only need this. */
const StatusStoreContext = createContext<ServerStatusStore | null>(null);
const ServerStatusContext = createContext<ServerStatusContextType | null>(null);
const POLL_INTERVAL = 30000;
/** The mounted provider's store, for code outside React (plugin host lists). */
let activeStore: ServerStatusStore | null = null;
/** A host's live status outside React. "unknown" with no provider mounted. */
export function getLiveHostStatus(hostId: number): StatusValue {
return activeStore?.getStatus(hostId) ?? "unknown";
}
/** The backend keeps statuses in memory, so reading them often is cheap. */
const POLL_INTERVAL = 15_000;
export function ServerStatusProvider({
children,
@@ -47,121 +57,48 @@ export function ServerStatusProvider({
// Bumps only full-context consumers (dashboard, folder counts, etc.).
const [version, setVersion] = useState(0);
const mountedRef = useRef(true);
const refreshInFlightRef = useRef<Promise<boolean | void> | null>(null);
const refreshInFlightRef = useRef<Promise<void> | null>(null);
useEffect(() => store.subscribeAll(() => setVersion((v) => v + 1)), [store]);
useEffect(() => {
return store.subscribeAll(() => {
setVersion((v) => v + 1);
});
activeStore = store;
return () => {
if (activeStore === store) activeStore = null;
};
}, [store]);
useEffect(() => {
return store.subscribeMeta(() => {
setVersion((v) => v + 1);
});
}, [store]);
const fetchEnabledHosts = useCallback(async () => {
if (!isAuthenticated) {
store.setEnabledHostIds(new Set());
return new Set<number>();
}
try {
const hosts = await getSSHHosts({ includeStatus: false });
const enabled = new Set<number>();
hosts.forEach((host) => {
if (host.statusCheckEnabled !== false) enabled.add(host.id);
});
store.setEnabledHostIds(enabled);
return enabled;
} catch {
return store.getEnabledHostIds();
}
}, [isAuthenticated, store]);
const refreshStatusesImpl = useCallback(
async (rethrow = false) => {
if (!mountedRef.current || !isAuthenticated) return;
if (
typeof document !== "undefined" &&
document.visibilityState === "hidden"
) {
return;
}
if (refreshInFlightRef.current) {
return refreshInFlightRef.current;
}
const showLoading = !store.getInitialLoadComplete();
if (showLoading) store.setLoading(true);
const run = (async () => {
try {
const data = await getAllServerStatuses();
if (!mountedRef.current) return;
const newStatuses = new Map<number, ServerStatusEntry>();
const now = new Date().toISOString();
if (data && typeof data === "object") {
Object.entries(data).forEach(([idStr, statusData]) => {
const id = parseInt(idStr, 10);
if (!isNaN(id)) {
const status =
statusData?.status === "online" ||
statusData?.status === "reachable"
? statusData.status
: "offline";
newStatuses.set(id, {
status,
lastChecked: statusData?.lastChecked || now,
...(statusData?.reason === "host_key_changed"
? { reason: statusData.reason }
: {}),
});
}
});
}
const previousStatuses = store.getStatuses();
const changed =
previousStatuses.size !== newStatuses.size ||
[...newStatuses].some(
([id, entry]) =>
previousStatuses.get(id)?.status !== entry.status ||
previousStatuses.get(id)?.reason !== entry.reason,
);
store.applyStatuses(newStatuses);
return changed;
} catch (error) {
if (mountedRef.current) {
store.markDegraded(store.getEnabledHostIds());
}
if (rethrow) throw error;
return false;
} finally {
if (mountedRef.current) {
if (showLoading) store.setLoading(false);
store.setInitialLoadComplete(true);
}
}
})();
refreshInFlightRef.current = run.finally(() => {
refreshInFlightRef.current = null;
});
return refreshInFlightRef.current;
},
[isAuthenticated, store],
);
const refreshStatuses = useCallback(async () => {
await refreshStatusesImpl();
}, [refreshStatusesImpl]);
if (!mountedRef.current || !isAuthenticated) return;
if (refreshInFlightRef.current) return refreshInFlightRef.current;
const run = (async () => {
try {
const data = await getAllServerStatuses();
if (!mountedRef.current || !data || typeof data !== "object") return;
const next = new Map<number, ServerStatusEntry>();
const now = new Date().toISOString();
for (const [idStr, entry] of Object.entries(data)) {
const id = parseInt(idStr, 10);
if (isNaN(id)) continue;
next.set(id, {
status: entry?.status === "online" ? "online" : "offline",
lastChecked: entry?.lastChecked || now,
});
}
store.applyStatuses(next);
} catch {
// Keep the last known statuses rather than flipping every host.
} finally {
if (mountedRef.current) store.setInitialLoadComplete(true);
}
})();
refreshInFlightRef.current = run.finally(() => {
refreshInFlightRef.current = null;
});
return refreshInFlightRef.current;
}, [isAuthenticated, store]);
const getStatus = useCallback(
(hostId: number): StatusValue => store.getStatus(hostId),
@@ -170,35 +107,31 @@ export function ServerStatusProvider({
useEffect(() => {
mountedRef.current = true;
if (!isAuthenticated) {
store.clear();
return () => {
mountedRef.current = false;
};
}
let stopPolling: (() => void) | null = null;
const init = async () => {
await fetchEnabledHosts();
if (!mountedRef.current) return;
stopPolling = runAdaptivePolling(
() => refreshStatusesImpl(true),
{
minIntervalMs: POLL_INTERVAL,
maxIntervalMs: 120_000,
stablePollsPerStep: 3,
},
{ enabled: () => isAuthenticated },
);
};
void init();
const stopPolling = runAdaptivePolling(refreshStatuses, {
minIntervalMs: POLL_INTERVAL,
maxIntervalMs: POLL_INTERVAL,
});
const onFocus = () => void refreshStatuses();
window.addEventListener("focus", onFocus);
return () => {
mountedRef.current = false;
stopPolling?.();
stopPolling();
window.removeEventListener("focus", onFocus);
};
}, [fetchEnabledHosts, isAuthenticated, refreshStatusesImpl]);
}, [isAuthenticated, refreshStatuses, store]);
useEffect(() => {
const handleHostsChanged = async () => {
await fetchEnabledHosts();
await refreshStatuses();
const handleHostsChanged = () => {
invalidateServerStatusCache();
void refreshStatuses();
};
window.addEventListener("ssh-hosts:changed", handleHostsChanged);
@@ -208,17 +141,16 @@ export function ServerStatusProvider({
window.removeEventListener("ssh-hosts:changed", handleHostsChanged);
window.removeEventListener("hosts:refresh", handleHostsChanged);
};
}, [fetchEnabledHosts, refreshStatuses]);
}, [refreshStatuses]);
const contextValue = useMemo(
() => ({
statuses: store.getStatuses(),
isLoading: store.getIsLoading(),
initialLoadComplete: store.getInitialLoadComplete(),
refreshStatuses,
getStatus,
}),
// version refreshes statuses/isLoading/initialLoadComplete snapshots
// version refreshes the statuses/initialLoadComplete snapshots
// eslint-disable-next-line react-hooks/exhaustive-deps
[version, refreshStatuses, getStatus],
);
@@ -252,85 +184,49 @@ export function useServerStatus() {
/**
* Subscribe to a single host's status. Only re-renders when that host's
* status value changes (or its enabled flag flips). Does not re-render when
* other hosts update.
* status changes. Null when status checks are off for the host.
*/
export function useHostStatus(
hostId: number,
statusCheckEnabled: boolean = true,
): StatusValue | null {
const store = useStatusStore();
const snapshot = useSyncExternalStore(
const status = useSyncExternalStore(
(onChange) => store.subscribeHost(hostId, onChange),
() => store.getHostSnapshot(hostId),
() => store.getHostSnapshot(hostId),
() => store.getStatus(hostId),
() => store.getStatus(hostId),
);
if (!statusCheckEnabled) {
return null;
}
return snapshot.split(":", 1)[0] as StatusValue;
}
export function useHostStatusReason(
hostId: number,
statusCheckEnabled: boolean = true,
): ServerStatusEntry["reason"] | null {
const store = useStatusStore();
const snapshot = useSyncExternalStore(
(onChange) => store.subscribeHost(hostId, onChange),
() => store.getHostSnapshot(hostId),
() => store.getHostSnapshot(hostId),
);
if (!statusCheckEnabled) return null;
return snapshot.endsWith(":host_key_changed")
? "host_key_changed"
: undefined;
return statusCheckEnabled ? status : null;
}
/** Meta flags without depending on the full status map. */
export function useServerStatusMeta(): {
initialLoadComplete: boolean;
isLoading: boolean;
} {
export function useServerStatusMeta(): { initialLoadComplete: boolean } {
const store = useStatusStore();
useSyncExternalStore(
(onChange) => store.subscribeMeta(onChange),
() => store.getMetaSnapshot(),
() => store.getMetaSnapshot(),
);
return {
initialLoadComplete: store.getInitialLoadComplete(),
isLoading: store.getIsLoading(),
};
return { initialLoadComplete: store.getInitialLoadComplete() };
}
const noStatus = () => "";
const noStatus = (): StatusValue => "unknown";
/**
* One host's status for plugin views, which can render outside the app shell
* (a standalone window). Null there, and while the host has not been checked.
*/
export function useOptionalHostStatusEntry(hostId: number | undefined): {
status: StatusValue;
reason?: "host_key_changed";
} | null {
export function useOptionalHostStatusEntry(
hostId: number | undefined,
): { status: "online" | "offline" } | null {
const store = useContext(StatusStoreContext);
const snapshot = useSyncExternalStore(
const status = useSyncExternalStore(
(onChange) =>
store && hostId !== undefined
? store.subscribeHost(hostId, onChange)
: () => {},
() => (store && hostId !== undefined ? store.getHostSnapshot(hostId) : ""),
() => (store && hostId !== undefined ? store.getStatus(hostId) : "unknown"),
noStatus,
);
if (!snapshot) return null;
const [status] = snapshot.split(":", 1);
if (!status) return null;
return snapshot.endsWith(":host_key_changed")
? { status: status as StatusValue, reason: "host_key_changed" }
: { status: status as StatusValue };
return status === "unknown" ? null : { status };
}
+12 -87
View File
@@ -1,9 +1,8 @@
export type StatusValue = "online" | "reachable" | "offline" | "degraded";
export type StatusValue = "online" | "offline" | "unknown";
export interface ServerStatusEntry {
status: StatusValue;
status: "online" | "offline";
lastChecked: string;
reason?: "host_key_changed";
}
type Listener = () => void;
@@ -14,44 +13,26 @@ type Listener = () => void;
*/
export class ServerStatusStore {
private statuses = new Map<number, ServerStatusEntry>();
private enabledHostIds = new Set<number>();
private initialLoadComplete = false;
private isLoading = false;
private readonly hostListeners = new Map<number, Set<Listener>>();
private readonly allListeners = new Set<Listener>();
private readonly metaListeners = new Set<Listener>();
/** "unknown" until the host has been checked. */
getStatus(hostId: number): StatusValue {
if (!this.enabledHostIds.has(hostId)) {
return "offline";
}
return this.statuses.get(hostId)?.status || "degraded";
return this.statuses.get(hostId)?.status ?? "unknown";
}
getStatuses(): Map<number, ServerStatusEntry> {
return this.statuses;
}
getEnabledHostIds(): Set<number> {
return this.enabledHostIds;
}
getInitialLoadComplete(): boolean {
return this.initialLoadComplete;
}
getIsLoading(): boolean {
return this.isLoading;
}
/** Snapshot string for a host — used as useSyncExternalStore getSnapshot. */
getHostSnapshot(hostId: number): string {
const status = this.getStatus(hostId);
return `${status}:${this.statuses.get(hostId)?.reason ?? ""}`;
}
getMetaSnapshot(): string {
return `${this.initialLoadComplete ? 1 : 0}:${this.isLoading ? 1 : 0}:${this.enabledHostIds.size}`;
return this.initialLoadComplete ? "1" : "0";
}
subscribeHost(hostId: number, listener: Listener): () => void {
@@ -83,28 +64,6 @@ export class ServerStatusStore {
};
}
setEnabledHostIds(next: Set<number>): void {
if (setsEqual(this.enabledHostIds, next)) return;
const prev = this.enabledHostIds;
this.enabledHostIds = next;
this.emitMeta();
// Hosts that entered/left the enabled set need a status re-read.
for (const id of next) {
if (!prev.has(id)) this.emitHost(id);
}
for (const id of prev) {
if (!next.has(id)) this.emitHost(id);
}
this.emitAll();
}
setLoading(loading: boolean): void {
if (this.isLoading === loading) return;
this.isLoading = loading;
this.emitMeta();
this.emitAll();
}
setInitialLoadComplete(complete: boolean): void {
if (this.initialLoadComplete === complete) return;
this.initialLoadComplete = complete;
@@ -120,50 +79,24 @@ export class ServerStatusStore {
const changedIds: number[] = [];
for (const [id, entry] of next) {
const prev = this.statuses.get(id);
if (
!prev ||
prev.status !== entry.status ||
prev.reason !== entry.reason
) {
changedIds.push(id);
}
if (this.statuses.get(id)?.status !== entry.status) changedIds.push(id);
}
for (const id of this.statuses.keys()) {
if (!next.has(id)) {
changedIds.push(id);
}
}
if (changedIds.length === 0) {
// Still refresh lastChecked silently without notifying.
this.statuses = next;
return;
if (!next.has(id)) changedIds.push(id);
}
this.statuses = next;
if (changedIds.length === 0) return;
for (const id of changedIds) {
this.emitHost(id);
}
this.emitAll();
}
markDegraded(enabledIds: Iterable<number>): void {
const next = new Map(this.statuses);
let changed = false;
const now = new Date().toISOString();
for (const id of enabledIds) {
const existing = next.get(id);
if (existing?.status === "degraded") continue;
changed = true;
next.set(id, {
status: "degraded",
lastChecked: existing?.lastChecked || now,
});
}
if (changed) {
this.applyStatuses(next);
}
/** Forgets everything, on sign out. */
clear(): void {
this.applyStatuses(new Map());
this.setInitialLoadComplete(false);
}
private emitHost(hostId: number): void {
@@ -180,11 +113,3 @@ export class ServerStatusStore {
for (const listener of this.metaListeners) listener();
}
}
function setsEqual(a: Set<number>, b: Set<number>): boolean {
if (a.size !== b.size) return false;
for (const id of a) {
if (!b.has(id)) return false;
}
return true;
}