chore(frontend): introduce prettier + eslint and prune unused code
Backend CI / Backend (push) Has been cancelled
Frontend CI / Frontend (push) Failing after 1m39s

- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports)
- Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier
- Add root scripts: format, format:check, lint, lint:fix
- Reformat 257 files across admin-web, ops-web, desktop-client, packages
- Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters
- Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex
- Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-01 20:39:09 +08:00
parent 21c7892ee4
commit 162abdc97c
258 changed files with 42261 additions and 37556 deletions
+78 -79
View File
@@ -1,25 +1,25 @@
interface LeaseSnapshot {
activeLeaseId: string | null;
activeTaskId: string | null;
activeTaskIds: string[];
activeCount: number;
attemptId: string | null;
startedAt: number | null;
leaseExpiresAt: number | null;
lastExtendedAt: number | null;
lastReleasedAt: number | null;
lastOutcome: "leased" | "extended" | "completed" | "failed" | "cleared" | null;
activeLeaseId: string | null
activeTaskId: string | null
activeTaskIds: string[]
activeCount: number
attemptId: string | null
startedAt: number | null
leaseExpiresAt: number | null
lastExtendedAt: number | null
lastReleasedAt: number | null
lastOutcome: 'leased' | 'extended' | 'completed' | 'failed' | 'cleared' | null
}
interface ActiveLeaseState {
taskId: string;
attemptId: string | null;
leaseExpiresAt: number | null;
startedAt: number;
lastExtendedAt: number | null;
taskId: string
attemptId: string | null
leaseExpiresAt: number | null
startedAt: number
lastExtendedAt: number | null
}
const activeLeases = new Map<string, ActiveLeaseState>();
const activeLeases = new Map<string, ActiveLeaseState>()
const leaseState: LeaseSnapshot = {
activeLeaseId: null,
activeTaskId: null,
@@ -31,38 +31,40 @@ const leaseState: LeaseSnapshot = {
lastExtendedAt: null,
lastReleasedAt: null,
lastOutcome: null,
};
function normalizeLeaseExpiresAt(value: number | string | null | undefined): number | null {
if (typeof value === "number") {
return Number.isFinite(value) ? value : null;
}
if (typeof value !== "string" || !value.trim()) {
return null;
}
const timestamp = Date.parse(value);
return Number.isNaN(timestamp) ? null : timestamp;
}
export function setActiveLease(input: {
taskId: string;
attemptId?: string | null;
leaseExpiresAt?: number | string | null;
} | null): void {
function normalizeLeaseExpiresAt(value: number | string | null | undefined): number | null {
if (typeof value === 'number') {
return Number.isFinite(value) ? value : null
}
if (typeof value !== 'string' || !value.trim()) {
return null
}
const timestamp = Date.parse(value)
return Number.isNaN(timestamp) ? null : timestamp
}
export function setActiveLease(
input: {
taskId: string
attemptId?: string | null
leaseExpiresAt?: number | string | null
} | null,
): void {
if (!input) {
activeLeases.clear();
leaseState.activeLeaseId = null;
leaseState.activeTaskId = null;
leaseState.activeTaskIds = [];
leaseState.activeCount = 0;
leaseState.attemptId = null;
leaseState.startedAt = null;
leaseState.leaseExpiresAt = null;
leaseState.lastOutcome = "cleared";
leaseState.lastReleasedAt = Date.now();
return;
activeLeases.clear()
leaseState.activeLeaseId = null
leaseState.activeTaskId = null
leaseState.activeTaskIds = []
leaseState.activeCount = 0
leaseState.attemptId = null
leaseState.startedAt = null
leaseState.leaseExpiresAt = null
leaseState.lastOutcome = 'cleared'
leaseState.lastReleasedAt = Date.now()
return
}
const normalized: ActiveLeaseState = {
@@ -71,65 +73,62 @@ export function setActiveLease(input: {
leaseExpiresAt: normalizeLeaseExpiresAt(input.leaseExpiresAt),
startedAt: Date.now(),
lastExtendedAt: null,
};
}
activeLeases.set(normalized.taskId, normalized);
syncLeaseSnapshot();
leaseState.lastOutcome = "leased";
activeLeases.set(normalized.taskId, normalized)
syncLeaseSnapshot()
leaseState.lastOutcome = 'leased'
}
export function noteLeaseExtended(
leaseExpiresAt?: number | string | null,
taskId?: string,
): void {
export function noteLeaseExtended(leaseExpiresAt?: number | string | null, taskId?: string): void {
if (taskId) {
const active = activeLeases.get(taskId);
const active = activeLeases.get(taskId)
if (active) {
active.leaseExpiresAt = normalizeLeaseExpiresAt(leaseExpiresAt) ?? active.leaseExpiresAt;
active.lastExtendedAt = Date.now();
activeLeases.set(taskId, active);
active.leaseExpiresAt = normalizeLeaseExpiresAt(leaseExpiresAt) ?? active.leaseExpiresAt
active.lastExtendedAt = Date.now()
activeLeases.set(taskId, active)
}
} else {
const first = activeLeases.values().next().value as ActiveLeaseState | undefined;
const first = activeLeases.values().next().value as ActiveLeaseState | undefined
if (first) {
first.leaseExpiresAt = normalizeLeaseExpiresAt(leaseExpiresAt) ?? first.leaseExpiresAt;
first.lastExtendedAt = Date.now();
activeLeases.set(first.taskId, first);
first.leaseExpiresAt = normalizeLeaseExpiresAt(leaseExpiresAt) ?? first.leaseExpiresAt
first.lastExtendedAt = Date.now()
activeLeases.set(first.taskId, first)
}
}
syncLeaseSnapshot();
leaseState.lastExtendedAt = Date.now();
leaseState.lastOutcome = "extended";
syncLeaseSnapshot()
leaseState.lastExtendedAt = Date.now()
leaseState.lastOutcome = 'extended'
}
export function noteLeaseReleased(
reason: Exclude<LeaseSnapshot["lastOutcome"], "leased" | "extended" | null>,
reason: Exclude<LeaseSnapshot['lastOutcome'], 'leased' | 'extended' | null>,
taskId?: string,
): void {
if (taskId) {
activeLeases.delete(taskId);
activeLeases.delete(taskId)
} else {
activeLeases.clear();
activeLeases.clear()
}
syncLeaseSnapshot();
leaseState.lastReleasedAt = Date.now();
leaseState.lastOutcome = reason;
syncLeaseSnapshot()
leaseState.lastReleasedAt = Date.now()
leaseState.lastOutcome = reason
}
export function getLeaseManagerSnapshot(): LeaseSnapshot {
return { ...leaseState };
return { ...leaseState }
}
function syncLeaseSnapshot(): void {
const first = activeLeases.values().next().value as ActiveLeaseState | undefined;
const first = activeLeases.values().next().value as ActiveLeaseState | undefined
leaseState.activeTaskIds = [...activeLeases.keys()];
leaseState.activeCount = activeLeases.size;
leaseState.activeLeaseId = first?.taskId ?? null;
leaseState.activeTaskId = first?.taskId ?? null;
leaseState.attemptId = first?.attemptId ?? null;
leaseState.startedAt = first?.startedAt ?? null;
leaseState.leaseExpiresAt = first?.leaseExpiresAt ?? null;
leaseState.activeTaskIds = [...activeLeases.keys()]
leaseState.activeCount = activeLeases.size
leaseState.activeLeaseId = first?.taskId ?? null
leaseState.activeTaskId = first?.taskId ?? null
leaseState.attemptId = first?.attemptId ?? null
leaseState.startedAt = first?.startedAt ?? null
leaseState.leaseExpiresAt = first?.leaseExpiresAt ?? null
}