feat: drill-down filters on overview and outdated agent version highlight
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:-SAC)?$/i;
|
||||
const DEFAULT_LAG_THRESHOLD = 3;
|
||||
|
||||
export interface ParsedAgentVersion {
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
}
|
||||
|
||||
export function parseAgentVersion(raw: string | null | undefined): ParsedAgentVersion | null {
|
||||
if (!raw) return null;
|
||||
const match = raw.trim().match(VERSION_RE);
|
||||
if (!match) return null;
|
||||
return {
|
||||
major: Number(match[1]),
|
||||
minor: Number(match[2]),
|
||||
patch: Number(match[3]),
|
||||
};
|
||||
}
|
||||
|
||||
function compareVersions(a: ParsedAgentVersion, b: ParsedAgentVersion): number {
|
||||
if (a.major !== b.major) return a.major - b.major;
|
||||
if (a.minor !== b.minor) return a.minor - b.minor;
|
||||
return a.patch - b.patch;
|
||||
}
|
||||
|
||||
function agentVersionLag(host: ParsedAgentVersion, latest: ParsedAgentVersion): number | null {
|
||||
if (compareVersions(host, latest) > 0) return 0;
|
||||
if (host.major !== latest.major || host.minor !== latest.minor) return null;
|
||||
return latest.patch - host.patch;
|
||||
}
|
||||
|
||||
export function isAgentVersionOutdated(
|
||||
hostVersion: string | null | undefined,
|
||||
latestVersion: string | null | undefined,
|
||||
lagThreshold = DEFAULT_LAG_THRESHOLD,
|
||||
): boolean {
|
||||
const host = parseAgentVersion(hostVersion);
|
||||
const latest = parseAgentVersion(latestVersion);
|
||||
if (!host || !latest || compareVersions(host, latest) >= 0) return false;
|
||||
const lag = agentVersionLag(host, latest);
|
||||
if (lag === null) return true;
|
||||
return lag >= lagThreshold;
|
||||
}
|
||||
Reference in New Issue
Block a user