Files
00821700de chore: remove dead code (59 unused files + ~125 unused exports) (#1835)
* chore: remove dead/unreferenced files across ui, vscode

Remove 59 unused source files (components, hooks, lib utils, stores,
barrels, and orphaned vscode github modules) that are not imported by
any entry-reachable code. Also drop a stale test mock for the removed
execCommands module.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* refactor: remove unused exported symbols (types, functions, consts, hooks)

Remove exported symbols whose identifier is referenced nowhere in the
repository (verified via repo-wide search), across ui types/contracts,
lib utilities, sync layer, stores, and components. Also drop the few
imports/private helpers orphaned by these removals.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* refactor: remove more unused exports (desktop, shortcuts, worktree, vscode)

Continue removing repo-wide unreferenced exported functions, consts and
types across lib/desktop, shortcuts, worktreeSessionCreator, sync, and
vscode gitService, with cascading orphaned helpers/imports cleaned up.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>

* chore: add dead-code cleanup tooling

* refactor: checkpoint dead-code cleanup

* refactor: remove dead-code suppressions

---------

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-06-26 19:27:53 +03:00

89 lines
2.0 KiB
TypeScript

const STREAM_PERF_STORAGE_KEY = 'openchamber_stream_perf';
type PerfCounter = {
count: number;
total: number;
max: number;
last: number;
};
type StreamPerfState = {
counters: Map<string, PerfCounter>;
startedAt: number;
lastUpdatedAt: number;
};
declare global {
interface Window {
__openchamberVsCodeStreamPerfState__?: StreamPerfState;
}
}
const vscodeStreamPerfEnabled = (): boolean => {
try {
return window.localStorage.getItem(STREAM_PERF_STORAGE_KEY) === '1';
} catch {
return false;
}
};
const nowMs = (): number => {
if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
return performance.now();
}
return Date.now();
};
const ensurePerfState = (): StreamPerfState | null => {
if (!vscodeStreamPerfEnabled()) {
return null;
}
if (!window.__openchamberVsCodeStreamPerfState__) {
const startedAt = Date.now();
window.__openchamberVsCodeStreamPerfState__ = {
counters: new Map<string, PerfCounter>(),
startedAt,
lastUpdatedAt: startedAt,
};
}
return window.__openchamberVsCodeStreamPerfState__;
};
const updateCounter = (metric: string, amount: number): void => {
const state = ensurePerfState();
if (!state) {
return;
}
const bucket = state.counters.get(metric) ?? { count: 0, total: 0, max: 0, last: 0 };
bucket.count += 1;
bucket.total += amount;
bucket.max = Math.max(bucket.max, amount);
bucket.last = amount;
state.counters.set(metric, bucket);
state.lastUpdatedAt = Date.now();
};
export const vscodeStreamPerfCount = (metric: string, count = 1): void => {
updateCounter(metric, count);
};
export const vscodeStreamPerfObserve = (metric: string, value: number): void => {
updateCounter(metric, value);
};
export const vscodeStreamPerfMeasure = <T>(metric: string, fn: () => T): T => {
if (!vscodeStreamPerfEnabled()) {
return fn();
}
const start = nowMs();
try {
return fn();
} finally {
updateCounter(metric, nowMs() - start);
}
};