Reduce idle work and disk churn with native resource diagnostics #2679
Mergedjuliusmarmingemerged 15 commits into
main fromrefs/pull/2679/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- apps/web/src/hooks/serverSettingsWriteQueue.ts lines 9 to 30OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +10,21 @@10+ readonly updateSettings: (patch: ServerSettingsPatch) => Promise<ServerSettings>;11+ readonly applySettings: (settings: ServerSettings) => void;12+ readonly onError: (error: unknown) => void;13+}): ServerSettingsWriteQueue {14+ let queue: Promise<void> = Promise.resolve();15+16+ return {17+ enqueue: (patch) => {18+ queue = queue19+ .catch(() => undefined)20+ .then(async () => {21+ const settings = await input.updateSettings(patch);22+ input.applySettings(settings);23+ })24+ .catch(input.onError);25+ },26+ reset: () => {27+ queue = Promise.resolve();28+ },29+ drain: () => queue,30+ };
- packages/shared/src/serverSettings.ts line 186Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -80,3 +101,20 @@101+ profile: "custom" as const,102+ baseProfile: getBackgroundActivityBaseProfile(current.backgroundActivity),103+ overrides: {104+ ...current.backgroundActivity.overrides,105+ ...(automaticGitFetchInterval !== undefined ? { automaticGitFetchInterval } : {}),106+ ...(providerHealthRefreshInterval !== undefined107+ ? { providerHealthRefreshInterval }108+ : {}),109+ },110+ }111+ : undefined;80112 const next = deepMerge(current, patchForMerge);81- const nextWithReplacements = {113+ const nextWithReplacementsBase = {82114 ...next,115+ ...(backgroundActivity !== undefined116+ ? { backgroundActivity: deepMerge(current.backgroundActivity, backgroundActivity) }117+ : {}),118+ ...(backgroundActivityPatch !== undefined119+ ? { backgroundActivity: backgroundActivityPatch }120+ : {}),apps/web/src/components/settings/SourceControlSettings.tsx line 82Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -70,3 +75,8 @@70757176 const SOURCE_CONTROL_SKELETON_ROWS = ["primary", "secondary"] as const;7277 const GIT_FETCH_INTERVAL_STEP_SECONDS = 5;78+type BackgroundActivityOverridePatch = Partial<{79+ [K in keyof BackgroundActivitySettings["overrides"]]:80+ | BackgroundActivitySettings["overrides"][K]81+ | undefined;82+}>;
- apps/server/src/vcs/VcsStatusBroadcaster.ts line 281OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -270,3 +272,10 @@270272 return activeInterval;271273 }272274275+ const shouldRun = yield* backgroundPolicy.shouldRunScopeWork({276+ type: "vcs-status",277+ cwd,278+ });279+ if (!shouldRun) {280+ return activeInterval;281+ }apps/server/src/background/BackgroundPolicy.ts line 219OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +199,21 @@199+ updatedAt: now,200+ expiresAt,201+ };202+ yield* Ref.update(leasesRef, (leases) => {203+ const next = new Map(leases);204+ next.set(`${rpcClientId}:${input.clientId}`, lease);205+ return next;206+ });207+ yield* publishSnapshot;208+ });209+210+ const removeRpcClient: BackgroundPolicyShape["removeRpcClient"] = (rpcClientId) =>211+ Ref.update(leasesRef, (leases) => {212+ const next = new Map(leases);213+ for (const key of next.keys()) {214+ if (key.startsWith(`${rpcClientId}:`)) {215+ next.delete(key);216+ }217+ }218+ return next;219+ }).pipe(Effect.andThen(publishSnapshot), Effect.asVoid);apps/web/src/components/settings/SettingsPanels.tsx line 737Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -481,0 +664,21 @@664+ </DialogDescription>665+ </DialogHeader>666+ <DialogPanel className="space-y-0 px-6 pb-5">667+ <div className="overflow-hidden rounded-xl border bg-card text-card-foreground">668+ <div className="flex flex-col gap-3 border-b px-4 py-3 sm:flex-row sm:items-center sm:justify-between">669+ <div className="min-w-0 space-y-1">670+ <div className="text-sm font-medium">Shared policy</div>671+ <p className="text-xs leading-relaxed text-muted-foreground">672+ Controls whether background work may run after a subscribed interval fires.673+ </p>674+ </div>675+ <Select676+ value={activeProfile}677+ onValueChange={(value) => {678+ if (679+ value === "balanced" ||680+ value === "performance" ||681+ value === "battery-saver"682+ ) {683+ updateSettings(backgroundActivityProfileSettings(value));684+ }
t3dotgg(GitHub profile, opens in a new tab) changed the title
t3dotgg(GitHub profile, opens in a new tab) changed the title
- @@ -0,0 +657,21 @@657+ if (previous.sampleIntervalMs !== next.sampleIntervalMs) {658+ yield* writeCommand(current.handle.value, {659+ version: RESOURCE_MONITOR_PROTOCOL_VERSION,660+ type: "setSampleInterval",661+ sampleIntervalMs: next.sampleIntervalMs,662+ });663+ }664+ const wasStreaming = previous.liveSubscriberCount > 0;665+ const isStreaming = next.liveSubscriberCount > 0;666+ if (wasStreaming !== isStreaming) {667+ yield* writeCommand(current.handle.value, {668+ version: RESOURCE_MONITOR_PROTOCOL_VERSION,669+ type: "setStreaming",670+ enabled: isStreaming,671+ });672+ }673+ }674+ if (previous.sampleIntervalMs !== next.sampleIntervalMs) {675+ yield* publishHealth;676+ }677+ });
- apps/desktop/src/backend/DesktopBackendManager.ts line 332OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -274,4 +325,8 @@274325 Effect.forkScoped,275326 );276327277- return describeProcessExit(yield* Effect.result(handle.exitCode));328+ const exit = describeProcessExit(yield* Effect.result(handle.exitCode));329+ yield* Effect.forEach(outputFibers, Fiber.await, {330+ concurrency: "unbounded",331+ discard: true,332+ }).pipe(Effect.timeout(DEFAULT_BACKEND_OUTPUT_DRAIN_TIMEOUT), Effect.ignore);
- apps/desktop/src/backend/DesktopBackendManager.ts line 938Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -475,7 +536,12 @@475536 ),476537 );477538 }),478- onReadinessFailure: (error) =>479- logBackendManagerWarning("backend readiness check failed during bootstrap", {480- error: error.message,481- }),539+ onReadinessFailure: Effect.fn("desktop.backendManager.onReadinessFailure")(540+ function* (error) {541+ yield* logBackendManagerWarning("backend readiness check failed during bootstrap", {542+ error: error.message,543+ });544+ yield* backendOutputLog.persistFailure({545+ details: error.message,546+ });547+ },apps/server/src/background/BackgroundPolicy.ts line 155Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +73,21 @@73+ return lease.scopes.some((leaseScope) => scopeKey(leaseScope) === key);74+}75+76+function hasThermalPressure(hostPower: HostPowerSnapshot): boolean {77+ return hostPower.thermalState === "serious" || hostPower.thermalState === "critical";78+}79+80+function isHostConstrained(81+ hostPower: HostPowerSnapshot,82+ settings: ResolvedBackgroundActivitySettings,83+): boolean {84+ if (hostPower.stale) return false;85+ if (86+ (settings.pauseWhenHostLocked && hostPower.locked === "true") ||87+ hasThermalPressure(hostPower)88+ ) {89+ return true;90+ }91+ if (settings.pauseWhenHostLowPower && hostPower.lowPowerMode === "true") return true;92+ return settings.pauseWhenOnBattery && hostPower.onBattery === "true";93+}
- apps/server/src/resourceTelemetry/ResourceMonitorBinary.ts lines 205 to 210Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +157,21 @@157+ ),158+ path.resolve(159+ import.meta.dirname,160+ "../../../../native/resource-monitor/target/debug",161+ executableName,162+ ),163+ ].filter((candidate): candidate is string => Boolean(candidate));164+165+ const resolve: ResourceMonitorBinaryShape["resolve"] = Effect.gen(function* () {166+ for (const candidate of candidates) {167+ const exists = yield* fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false));168+ if (!exists) continue;169+170+ if (platform !== "win32") {171+ const stat = yield* fileSystem.stat(candidate).pipe(Effect.option);172+ if (Option.isSome(stat) && (stat.value.mode & 0o111) === 0) {173+ return yield* new ResourceMonitorBinaryNotExecutable({174+ path: candidate,175+ mode: stat.value.mode,176+ });177+ }apps/desktop/src/telemetry/DesktopTelemetryPublisher.ts line 234OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +214,21 @@214+ Queue.take(sampleTriggers),215+ Effect.sleep(sampleInterval(currentPower, demand)),216+ );217+ yield* sampleOnce;218+ }219+ }).pipe(Effect.forkScoped);220+221+ const handleControl: DesktopTelemetryPublisherShape["handleControl"] = (message) => {222+ switch (message.type) {223+ case "setDiagnosticsDemand":224+ return Ref.getAndSet(diagnosticsDemand, message.enabled).pipe(225+ Effect.flatMap((previous) =>226+ previous === message.enabled227+ ? Effect.void228+ : Queue.offer(sampleTriggers, undefined).pipe(Effect.asVoid),229+ ),230+ );231+ }232+ };233+234+ const snapshots = Stream.concat(
juliusmarminge changed the title
- apps/server/src/provider/Layers/EventNdjsonLogger.ts line 592Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -270,9 +547,15 @@270- undefined,547+ { flush, schedule },271548 {272- threadWriters: new Map<string, ThreadWriter>(),273- failedSegments: new Set<string>(),549+ ...state,550+ pending,551+ pendingBytes,552+ flushScheduled: state.flushScheduled || schedule,274553 },275554 ] as const;276- }),277- );278- });555+ });556+557+ if (action.flush) {558+ yield* flush(false, false);559+ } else if (action.schedule) {560+ yield* scheduleFlush();561+ }apps/server/src/provider/Layers/EventNdjsonLogger.ts line 435Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -163,3 +386,19 @@386+ })387+ : { failures: [] };388+389+ return [390+ {391+ attributions: Array.from(attributionByStream, ([stream, value]) => ({392+ stream,393+ ...value,394+ })),395+ failures: [...failures, ...retention.failures],163396 },164- close() {165- return Scope.close(scope, Exit.void);397+ {398+ pending: [],399+ pendingBytes: 0,400+ sinks,401+ failedSegments,402+ flushScheduled: input.timerFired ? false : input.state.flushScheduled,403+ closed: input.close,404+ lastRetentionAt: retentionDue ? input.now : input.state.lastRetentionAt,
- apps/server/src/diagnostics/ProcessDiagnostics.ts line 87Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -503,11 +93,10 @@503- const descendant = buildDescendantEntries(filteredRows, process.pid).some(504- (entry) => entry.pid === pid,505- );506- return descendant507- ? Effect.void508- : Effect.fail(509- new ProcessDiagnosticsNotDescendantError({510- pid,511- serverPid: process.pid,512- }),513- );93+ );94+ return {95+ serverPid: process.pid,96+ readAt: snapshot.readAt,97+ processCount: processes.length,98+ totalRssBytes: processes.reduce((total, entry) => total + entry.rssBytes, 0),99+ totalCpuPercent: processes.reduce((total, entry) => total + entry.cpuPercent, 0),100+ processes,101+ error: Option.map(snapshot.health.native.lastError, (message) => ({ message })),102+ };
- apps/server/src/provider/Layers/EventNdjsonLogger.ts lines 168 to 169OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -62,8 +165,5 @@62165 return normalized ?? GLOBAL_THREAD_SEGMENT;63166 }6416765-function formatLoggerMessage(message: unknown): string {66- if (Array.isArray(message)) {67- return message.map((part) => (typeof part === "string" ? part : String(part))).join(" ");68- }69- return typeof message === "string" ? message : String(message);168+function resolveStreamLabel(stream: EventNdjsonStream): string {169+ return stream === "native" ? "NTIVE" : "CANON";
- @@ -1574,4 +1588,21 @@1588+ resourceTelemetry.readHistory(input),1589+ {1590+ "rpc.aggregate": "server",1591+ },1592+ ),1593+ [WS_METHODS.serverRetryResourceTelemetry]: (_input) =>1594+ observeRpcEffect(WS_METHODS.serverRetryResourceTelemetry, resourceTelemetry.retry, {1595+ "rpc.aggregate": "server",1596+ }),15741597 [WS_METHODS.serverSignalProcess]: (input) =>15751598 observeRpcEffect(WS_METHODS.serverSignalProcess, processDiagnostics.signal(input), {15761599 "rpc.aggregate": "server",15771600 }),1601+ [WS_METHODS.serverReportClientActivity]: (input, metadata) =>1602+ observeRpcEffect(1603+ WS_METHODS.serverReportClientActivity,1604+ backgroundPolicy.reportClientActivity(1605+ currentSessionId,1606+ RpcClientId.make(metadata.client.id),1607+ input,1608+ ),
- apps/server/src/background/BackgroundPolicy.ts line 58Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +25,21 @@25+26+export interface BackgroundPolicyShape {27+ readonly reportClientActivity: (28+ sessionId: AuthSessionId,29+ rpcClientId: RpcClientId,30+ input: ClientActivityReportInput,31+ ) => Effect.Effect<void>;32+ readonly removeRpcClient: (rpcClientId: RpcClientId) => Effect.Effect<void>;33+ readonly reportHostPowerState: (snapshot: HostPowerSnapshot) => Effect.Effect<void>;34+ readonly snapshot: Effect.Effect<BackgroundPolicySnapshot>;35+ readonly streamChanges: Stream.Stream<BackgroundPolicySnapshot>;36+ readonly hasDemand: (scope: BackgroundScope) => Effect.Effect<boolean>;37+ readonly shouldRunScopeWork: (scope: BackgroundScope) => Effect.Effect<boolean>;38+ readonly shouldRunOpportunisticWork: Effect.Effect<boolean>;39+}40+41+export class BackgroundPolicy extends Context.Service<BackgroundPolicy, BackgroundPolicyShape>()(42+ "t3/background/BackgroundPolicy",43+) {}44+45+const DEFAULT_LEASE_TTL_MS = 45_000;@@ -0,0 +572,21 @@572+ next_sample_at = current573+ .sample_interval574+ .map(|interval| Instant::now() + interval);575+ } else {576+ write_error(577+ &mut writer,578+ "not-configured",579+ "configure must be sent before changing the sample interval",580+ true,581+ )?;582+ }583+ }584+ Command::SetStreaming { enabled, .. } => {585+ streaming_enabled = enabled;586+ }587+ Command::SampleNow { request_id, .. } => {588+ if let Some(current) = config.as_ref() {589+ let event = collector.sample(current, Some(request_id));590+ history.record(&event);591+ write_event(&mut writer, &event)?;592+ next_sample_at = currentapps/server/src/background/BackgroundPolicy.ts line 200OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +180,21 @@180+ MAX_LEASE_TTL_MS,181+ );182+ const now = yield* DateTime.now;183+ const expiresAt = DateTime.add(now, { milliseconds: ttlMs });184+ const lease: ClientActivityLease = {185+ sessionId,186+ rpcClientId,187+ clientId: input.clientId,188+ clientKind: input.clientKind,189+ visible: input.visible,190+ focused: input.focused,191+ recentlyInteracted: input.recentlyInteracted,192+ ...(input.appState !== undefined ? { appState: input.appState } : {}),193+ ...(input.lowPowerMode !== undefined ? { lowPowerMode: input.lowPowerMode } : {}),194+ ...(input.batteryState !== undefined ? { batteryState: input.batteryState } : {}),195+ ...(input.networkType !== undefined ? { networkType: input.networkType } : {}),196+ scopes: input.scopes,197+ updatedAt: now,198+ expiresAt,199+ };200+ yield* Ref.update(leasesRef, (leases) => {apps/server/src/provider/makeManagedServerProvider.ts lines 159 to 160OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -134,3 +146,15 @@134146 return yield* applySnapshot(nextSettings, { forceRefresh: true });135147 });136148149+ const hasProviderStatusDemand = Effect.gen(function* () {150+ const state = yield* Ref.get(snapshotStateRef);151+ const instanceId = state.snapshot.instanceId;152+ const [genericDemand, instanceDemand] = yield* Effect.all([153+ backgroundPolicy.shouldRunScopeWork({ type: "provider-status" }),154+ backgroundPolicy.shouldRunScopeWork({ type: "provider-status", instanceId }),155+ ]);156+ return genericDemand || instanceDemand;157+ });158+159+ const getRefreshInterval = input.refreshInterval160+ ? Effect.succeed(input.refreshInterval)apps/server/src/vcs/VcsStatusBroadcaster.ts line 399OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -394,3 +396,4 @@394396 return activeInterval;395397 }396398399+ const shouldRun = yield* backgroundPolicy.shouldRunScopeWork({apps/web/src/components/settings/SettingsPanels.tsx line 240Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -135,0 +225,21 @@225+ ? "advanced"226+ : settings.backgroundActivity.profile;227+}228+229+function resetBackgroundActivitySettings() {230+ return {231+ backgroundActivity: DEFAULT_UNIFIED_SETTINGS.backgroundActivity,232+ };233+}234+235+function backgroundActivityProfileSettings(profile: BackgroundActivityProfile) {236+ return {237+ backgroundActivity: {238+ schemaVersion: 1 as const,239+ profile,240+ overrides: {},241+ },242+ };243+}244+245+function backgroundActivityOverrideSettings(@@ -135,0 +229,21 @@229+function resetBackgroundActivitySettings() {230+ return {231+ backgroundActivity: DEFAULT_UNIFIED_SETTINGS.backgroundActivity,232+ };233+}234+235+function backgroundActivityProfileSettings(profile: BackgroundActivityProfile) {236+ return {237+ backgroundActivity: {238+ schemaVersion: 1 as const,239+ profile,240+ overrides: {},241+ },242+ };243+}244+245+function backgroundActivityOverrideSettings(246+ current: BackgroundActivitySettings,247+ overrides: BackgroundActivityOverridePatch,248+) {249+ const nextOverrides: BackgroundActivityOverridePatch = {apps/server/src/diagnostics/ProcessDiagnostics.ts line 75OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -389,18 +73,3 @@389- new ProcessDiagnosticsQueryTimeoutError({390- command: input.command,391- argCount: input.args.length,392- cwd,393- timeoutMillis: PROCESS_QUERY_TIMEOUT_MS,394- }),395- ),396- onSome: Effect.succeed,397- }),398- ),399- Effect.mapError((cause) =>400- isProcessDiagnosticsError(cause)401- ? cause402- : new ProcessDiagnosticsQueryFailedError({403- command: input.command,404- argCount: input.args.length,405- cwd,406- cause,73+export const make = Effect.fn("makeProcessDiagnostics")(function* () {74+ const telemetry = yield* ResourceTelemetry.ResourceTelemetry;75+ const read: ProcessDiagnosticsShape["read"] = telemetry.latest.pipe(apps/server/src/resourceTelemetry/ResourceMonitorBinary.ts line 200Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +147,21 @@147+ import.meta.dirname,148+ "../../../native/resource-monitor/target",149+ rustTarget,150+ "release",151+ executableName,152+ ),153+ path.resolve(154+ import.meta.dirname,155+ "../../../../native/resource-monitor/target/release",156+ executableName,157+ ),158+ path.resolve(159+ import.meta.dirname,160+ "../../../../native/resource-monitor/target/debug",161+ executableName,162+ ),163+ ].filter((candidate): candidate is string => Boolean(candidate));164+165+ const resolve: ResourceMonitorBinaryShape["resolve"] = Effect.gen(function* () {166+ for (const candidate of candidates) {167+ const exists = yield* fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false));apps/server/src/resourceTelemetry/NativeTelemetryClient.ts line 601Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +484,21 @@484+ expectedVersion: RESOURCE_MONITOR_PROTOCOL_VERSION,485+ receivedVersion: version,486+ }),487+ );488+ }489+ return decodeMonitorEvent(value).pipe(490+ Effect.mapError((cause) => new NativeTelemetryDecodeFailed({ cause })),491+ );492+ },493+ ),494+ Stream.runForEach((event) => processEvent(event, helloDeferred)),495+ Effect.mapError((cause) =>496+ isProtocolMismatch(cause) || isDecodeFailed(cause) || isCommandFailed(cause)497+ ? cause498+ : new NativeTelemetryDecodeFailed({ cause }),499+ ),500+ Effect.forkScoped,501+ );502+ yield* handle.stderr.pipe(Stream.runDrain, Effect.ignore, Effect.forkScoped);503+504+ const hello = yield* Deferred.await(helloDeferred).pipe(apps/server/src/resourceTelemetry/Model.ts line 374Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +345,21 @@345+ processCount: processes.length,346+ currentCpuPercent: processes.reduce((total, process) => total + process.cpuPercent, 0),347+ cpuTimeMs: counters.cpuTimeMs,348+ currentRssBytes: processes.reduce((total, process) => total + process.residentBytes, 0),349+ peakRssBytes: processes.reduce((total, process) => total + process.peakResidentBytes, 0),350+ ioReadBytes: counters.ioReadBytes,351+ ioWriteBytes: counters.ioWriteBytes,352+ ioReadBytesPerSecond: processes.reduce(353+ (total, process) => total + process.ioReadBytesPerSecond,354+ 0,355+ ),356+ ioWriteBytesPerSecond: processes.reduce(357+ (total, process) => total + process.ioWriteBytesPerSecond,358+ 0,359+ ),360+ processStarts: counters.processStarts,361+ processExits: counters.processExits,362+ };363+}364+365+export function mergeProcesses(input: MergeProcessesInput): MergeProcessesResult {apps/server/src/resourceTelemetry/Model.ts line 296Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +267,21 @@267+function incrementCounters(counters: GroupCounters, update: Partial<GroupCounters>): GroupCounters {268+ return {269+ cpuTimeMs: counters.cpuTimeMs + (update.cpuTimeMs ?? 0),270+ ioReadBytes: counters.ioReadBytes + (update.ioReadBytes ?? 0),271+ ioWriteBytes: counters.ioWriteBytes + (update.ioWriteBytes ?? 0),272+ processStarts: counters.processStarts + (update.processStarts ?? 0),273+ processExits: counters.processExits + (update.processExits ?? 0),274+ };275+}276+277+function applyLifecycleCounters(input: {278+ readonly counters: TelemetryCounters;279+ readonly deltas: ReadonlyArray<ProcessDelta>;280+ readonly current: ReadonlyMap<string, ProcessState>;281+ readonly previous: ReadonlyMap<string, ProcessState>;282+}): TelemetryCounters {283+ let backend = input.counters.backend;284+ let electron = input.counters.electron;285+ let monitor = input.counters.monitor;286+ let allT3 = input.counters.allT3;287+ for (const processDelta of input.deltas) {apps/server/src/provider/Layers/EventNdjsonLogger.ts line 411Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -160,4 +364,18 @@364+ count: current.count + 1,365+ logicalWriteBytes: current.logicalWriteBytes + record.bytes,366+ });367+ }368+ } catch (cause) {369+ failedSegments.add(threadSegment);370+ failures.push({ filePath, cause });371+ }372+ }160373161- return {162- writeMessage(message: string) {163- return Effect.log(message).pipe(Effect.provide(loggerLayer));374+ const retentionDue =375+ input.now - input.state.lastRetentionAt >= input.options.retentionCheckIntervalMs;376+ const retention = retentionDue377+ ? enforceRetention({378+ directory: input.directory,379+ maxTotalBytes: input.options.maxTotalBytes,380+ maxAgeMs: input.options.maxAgeMs,381+ activeFilePaths: new Set(packages/client-runtime/src/rpc/client.ts line 264OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -255,0 +244,21 @@244+ ).pipe(Stream.drain);245+ }246+ if (hasOnlyExpectedFailures && options?.onExpectedFailure !== undefined) {247+ const handled = Stream.fromEffect(248+ options.onExpectedFailure(cause),249+ ).pipe(Stream.drain);250+ if (options.retryExpectedFailureAfter === undefined) {251+ return handled;252+ }253+ return handled.pipe(254+ Stream.concat(255+ Stream.fromEffect(256+ Effect.sleep(options.retryExpectedFailureAfter),257+ ).pipe(Stream.drain),258+ ),259+ Stream.concat(subscribeToSession()),260+ );261+ }262+ return Stream.failCause(cause);263+ }),264+ Stream.ensuring(completeObservation),
- packages/client-runtime/src/state/vcs.ts line 107OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -105,20 +105,3 @@105105 Stream.map((connection) => (connection.phase === "connected" ? connection.generation : null)),106106 Stream.changes,107- Stream.switchMap((generation) =>108- generation === null109- ? Stream.empty110- : Stream.tick(VCS_REFS_REVALIDATE_INTERVAL).pipe(111- Stream.mapEffect(112- () =>113- refresh().pipe(114- Effect.map(Option.some),115- Effect.catch((error) =>116- Effect.logWarning("Could not refresh Git refs.").pipe(117- Effect.annotateLogs({118- environmentId,119- cwd: input.cwd,120- ...safeErrorLogAttributes(error),121- }),122- Effect.as(Option.none<VcsListRefsResult>()),123- ),124- ),107+ Stream.mapEffect(@@ -0,0 +632,21 @@632+ Effect.catchCause((cause) =>633+ Cause.hasInterruptsOnly(cause)634+ ? Effect.void635+ : Ref.update(state, (current) => ({636+ ...current,637+ status: "unavailable" as const,638+ hello: Option.none(),639+ lastError: Option.some(Cause.pretty(cause)),640+ })).pipe(641+ Effect.andThen(publishHealth),642+ Effect.andThen(643+ Effect.logWarning("Resource monitor supervisor failed", {644+ cause: Cause.pretty(cause),645+ }),646+ ),647+ ),648+ ),649+ Effect.forkScoped,650+ );651+652+ const applyCollectionControl = Effect.fn(native/resource-monitor/src/main.rs line 562Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +366,21 @@366+ } else {367+ IoSemantics::Storage368+ }369+}370+371+fn unix_time_ms() -> u64 {372+ SystemTime::now()373+ .duration_since(UNIX_EPOCH)374+ .unwrap_or_default()375+ .as_millis() as u64376+}377+378+fn clamp_sample_interval(sample_interval_ms: u64) -> Option<Duration> {379+ (sample_interval_ms > 0).then(|| {380+ Duration::from_millis(381+ sample_interval_ms.clamp(MIN_SAMPLE_INTERVAL_MS, MAX_SAMPLE_INTERVAL_MS),382+ )383+ })384+}385+386+fn spawn_input_reader() -> Receiver<Input> {apps/server/src/vcs/VcsStatusBroadcaster.ts line 399OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -394,3 +396,4 @@394396 return activeInterval;395397 }396398399+ const shouldRun = yield* backgroundPolicy.shouldRunScopeWork({apps/server/src/resourceTelemetry/ResourceTelemetryHistory.ts line 152OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +132,21 @@132+ samples.length === 0 ? 0 : Math.max(...samples.map((sample) => sample.cpuPercent)),133+ maxRssBytes: samples.length === 0 ? 0 : Math.max(...samples.map((sample) => sample.rssBytes)),134+ ioReadBytes: samples.reduce((total, sample) => total + sample.ioReadBytes, 0),135+ ioWriteBytes: samples.reduce((total, sample) => total + sample.ioWriteBytes, 0),136+ maxProcessCount:137+ samples.length === 0 ? 0 : Math.max(...samples.map((sample) => sample.processCount)),138+ });139+ }140+ return buckets;141+}142+143+export function buildResourceTelemetryHistory(144+ input: BuildResourceTelemetryHistoryInput,145+): ResourceTelemetryHistory {146+ const readAtMs = DateTime.toEpochMillis(input.readAt);147+ const { windowMs, bucketMs } = normalizeResourceTelemetryHistoryInput(input);148+ const windowStartMs = readAtMs - windowMs;149+ const snapshots = input.snapshots150+ .filter((snapshot) => snapshot.sampledAtUnixMs >= windowStartMs)151+ .toSorted((left, right) => left.sampledAtUnixMs - right.sampledAtUnixMs);152+ const electronRootPids = Option.match(input.desktopSnapshot, {native/resource-monitor/src/main.rs line 387OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +367,21 @@367+ IoSemantics::Storage368+ }369+}370+371+fn unix_time_ms() -> u64 {372+ SystemTime::now()373+ .duration_since(UNIX_EPOCH)374+ .unwrap_or_default()375+ .as_millis() as u64376+}377+378+fn clamp_sample_interval(sample_interval_ms: u64) -> Option<Duration> {379+ (sample_interval_ms > 0).then(|| {380+ Duration::from_millis(381+ sample_interval_ms.clamp(MIN_SAMPLE_INTERVAL_MS, MAX_SAMPLE_INTERVAL_MS),382+ )383+ })384+}385+386+fn spawn_input_reader() -> Receiver<Input> {387+ let (sender, receiver) = mpsc::channel();
- apps/server/src/diagnostics/ProcessDiagnostics.ts line 126Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -568 +111,21 @@111+ signal: input.signal,112+ signaled: false,113+ message: Option.some("Refusing to signal the T3 server process."),114+ };115+ }116+ const current = yield* telemetry.latest;117+ const selected = current.processes.find(118+ (entry) =>119+ entry.identity.pid === input.pid && entry.identity.startTimeMs === input.startTimeMs,568120 );121+ if (!selected) {122+ return {123+ pid: input.pid,124+ signal: input.signal,125+ signaled: false,126+ message: Option.some(127+ `Process ${input.pid} no longer matches the selected process identity.`,128+ ),129+ };130+ }131+ if (!canSignalCategory(selected.category)) {apps/desktop/src/app/DesktopObservability.ts lines 447 to 450OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -379,10 +440,11 @@379- component: "desktop-backend-child",380- runId,381- instanceId: id,382- stream: streamName,383- text: textDecoder.decode(chunk),384- },385- });386- },387- ),388- }) satisfies DesktopBackendOutputLogShape,440+ yield* Ref.update(441+ sessionRef,442+ Option.map((session) => appendBoundedOutputChunk(session, streamName, chunk)),443+ );444+ }),445+ persistFailure: Effect.fn("desktop.observability.backendOutput.persistFailure")(446+ function* ({ details }) {447+ const session = yield* Ref.modify(sessionRef, (current) => [448+ current,449+ Option.map(current, (value) => ({ ...value, chunks: [], byteLength: 0 })),450+ ]);packages/shared/src/serverSettings.ts line 138Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -120,4 +125,12 @@120125 patch: ServerSettingsPatch,121126 ): ServerSettings {122127 const selectionPatch = patch.textGenerationModelSelection;123- const { automaticGitFetchInterval, ...patchForMerge } = patch;128+ const {129+ automaticGitFetchInterval,130+ providerHealthRefreshInterval,131+ backgroundActivityProfile,132+ backgroundActivity,133+ ...patchForMerge134+ } = patch;135+ const backgroundActivityPatch =136+ backgroundActivityProfile !== undefinedapps/server/src/resourceTelemetry/Model.ts lines 147 to 147OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +127,21 @@127+ const metric = metricsByPid.get(process.pid);128+ if (!metric) return undefined;129+ return Math.abs(metric.creationTimeMs - process.startTimeMs) <= ELECTRON_IDENTITY_TOLERANCE_MS130+ ? metric131+ : undefined;132+}133+134+function syntheticNativeSample(135+ metric: DesktopElectronProcessMetric,136+ sampledAtMs: number,137+): ResourceMonitorProcessSample {138+ return {139+ pid: metric.pid,140+ ppid: 0,141+ startTimeMs: metric.creationTimeMs,142+ runTimeMs: Math.max(0, sampledAtMs - metric.creationTimeMs),143+ name: metric.name ?? metric.serviceName ?? metric.type,144+ command: metric.name ?? metric.serviceName ?? metric.type,145+ status: "Running",146+ cpuPercent: metric.cpuPercent,147+ cpuTimeMs: Math.max(0, Math.round((metric.cumulativeCpuSeconds ?? 0) * 1_000)),apps/server/src/resourceTelemetry/Model.ts line 505Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +436,21 @@436+ const ioReadDelta = previous437+ ? delta({438+ current: process.ioReadBytes,439+ previous: previous.process.ioReadBytes,440+ elapsedMs,441+ })442+ : 0;443+ const ioWriteDelta = previous444+ ? delta({445+ current: process.ioWriteBytes,446+ previous: previous.process.ioWriteBytes,447+ elapsedMs,448+ })449+ : 0;450+ const electronMetric = matchElectronMetric(process, metricsByPid);451+ const category: ResourceTelemetryProcessCategory =452+ process.pid === input.serverPid453+ ? "server"454+ : Option.contains(input.sidecarPid, process.pid)455+ ? "resource-monitor"456+ : explicitElectronRootPids.has(process.pid)native/resource-monitor/src/main.rs line 324OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +304,21 @@304+ SnapshotEvent {305+ version: PROTOCOL_VERSION,306+ event_type: "snapshot",307+ sequence: self.sequence,308+ sampled_at_unix_ms: unix_time_ms(),309+ collection_duration_micros: collection_started.elapsed().as_micros() as u64,310+ scanned_process_count: self.system.processes().len(),311+ retained_process_count: processes.len(),312+ inaccessible_process_count: 0,313+ request_id,314+ processes,315+ }316+ }317+}318+319+fn process_refresh_kind() -> ProcessRefreshKind {320+ ProcessRefreshKind::nothing()321+ .with_memory()322+ .with_cpu()323+ .with_disk_usage()324+ .with_cmd(UpdateKind::OnlyIfNotSet)apps/server/src/provider/Layers/EventNdjsonLogger.ts line 37OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -19,10 +19,19 @@1919 import * as Scope from "effect/Scope";2020 import * as SynchronizedRef from "effect/SynchronizedRef";21212222 import { toSafeThreadAttachmentSegment } from "../../attachmentStore.ts";23+import type { ResourceAttributionShape } from "../../resourceTelemetry/ResourceAttribution.ts";232424-const DEFAULT_MAX_BYTES = 10 * 1024 * 1024;25+const MEBIBYTE = 1024 * 1024;26+const DAY_MS = 24 * 60 * 60 * 1_000;27+const DEFAULT_MAX_BYTES = 10 * MEBIBYTE;2528 const DEFAULT_MAX_FILES = 10;26-const DEFAULT_BATCH_WINDOW_MS = 200;29+const DEFAULT_BATCH_WINDOW_MS = 1_000;30+const DEFAULT_MAX_TOTAL_BYTES = 512 * MEBIBYTE;31+const DEFAULT_MAX_AGE_MS = 14 * DAY_MS;32+const DEFAULT_RETENTION_CHECK_INTERVAL_MS = 5 * 60 * 1_000;33+const DEFAULT_MAX_BUFFERED_BYTES = MEBIBYTE;34+const DEFAULT_MAX_BUFFERED_RECORDS = 512;2735 const GLOBAL_THREAD_SEGMENT = "_global";2836 const LOG_SCOPE = "provider-observability";37+const PROVIDER_LOG_FILE_PATTERN = /\.log(?:\.\d+)?$/u;apps/server/src/background/BackgroundPolicy.ts line 307Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +218,21 @@218+219+ const hasDemand: BackgroundPolicyShape["hasDemand"] = (scope) =>220+ Effect.map(snapshot, (current) => current.activeScopeKeys.includes(scopeKey(scope)));221+222+ const shouldRunScopeWork: BackgroundPolicyShape["shouldRunScopeWork"] = (scope) =>223+ Effect.gen(function* () {224+ const [current, settings] = yield* Effect.all([snapshot, backgroundActivitySettings]);225+ if (isHostConstrained(current.hostPower, settings)) {226+ return false;227+ }228+ return current.leases.some((lease) =>229+ leaseMayRunScopedWork(lease, scope, current.updatedAt, settings),230+ );231+ });232+233+ const shouldRunOpportunisticWork = Effect.map(234+ snapshot,235+ (current) => current.shouldRunOpportunisticWork,236+ );237+238+ yield* Stream.runForEach(hostPowerMonitor.streamChanges, () => publishSnapshot).pipe(apps/server/src/resourceTelemetry/DesktopTelemetryReceiver.ts lines 362 to 366OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +346,21 @@346+ lastError: Option.some(error.message),347+ }),348+ ),349+ ),350+ Effect.forkScoped,351+ );352+353+ yield* Effect.forever(354+ Effect.sleep(STALE_CHECK_INTERVAL).pipe(355+ Effect.andThen(356+ Effect.gen(function* () {357+ const current = yield* Ref.get(latest);358+ if (Option.isNone(current) || current.value.power.stale) return;359+ const now = yield* DateTime.now;360+ if (DateTime.toEpochMillis(now) - current.value.sampledAtUnixMs < STALE_AFTER_MS)361+ return;362+ const staleSnapshot: DesktopHostTelemetrySnapshot = {363+ ...current.value,364+ power: { ...current.value.power, stale: true },365+ };366+ yield* Ref.set(latest, Option.some(staleSnapshot));apps/server/src/resourceTelemetry/ResourceTelemetryHistory.ts lines 149 to 151OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +131,21 @@131+ maxCpuPercent:132+ samples.length === 0 ? 0 : Math.max(...samples.map((sample) => sample.cpuPercent)),133+ maxRssBytes: samples.length === 0 ? 0 : Math.max(...samples.map((sample) => sample.rssBytes)),134+ ioReadBytes: samples.reduce((total, sample) => total + sample.ioReadBytes, 0),135+ ioWriteBytes: samples.reduce((total, sample) => total + sample.ioWriteBytes, 0),136+ maxProcessCount:137+ samples.length === 0 ? 0 : Math.max(...samples.map((sample) => sample.processCount)),138+ });139+ }140+ return buckets;141+}142+143+export function buildResourceTelemetryHistory(144+ input: BuildResourceTelemetryHistoryInput,145+): ResourceTelemetryHistory {146+ const readAtMs = DateTime.toEpochMillis(input.readAt);147+ const { windowMs, bucketMs } = normalizeResourceTelemetryHistoryInput(input);148+ const windowStartMs = readAtMs - windowMs;149+ const snapshots = input.snapshots150+ .filter((snapshot) => snapshot.sampledAtUnixMs >= windowStartMs)151+ .toSorted((left, right) => left.sampledAtUnixMs - right.sampledAtUnixMs);apps/server/src/resourceTelemetry/NativeTelemetryClient.ts lines 364 to 370OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +350,21 @@350+ case "hello":351+ return Ref.update(state, (current) => ({352+ ...current,353+ status: "starting" as const,354+ hello: Option.some(event),355+ lastError: Option.none(),356+ })).pipe(357+ Effect.andThen(publishHealth),358+ Effect.andThen(Deferred.succeed(helloDeferred, event)),359+ Effect.asVoid,360+ );361+ case "snapshot":362+ return Effect.gen(function* () {363+ const sampledAt = DateTime.makeUnsafe(event.sampledAtUnixMs);364+ yield* Ref.update(state, (current) => ({365+ ...current,366+ status: "healthy" as const,367+ lastSampleAt: Option.some(sampledAt),368+ lastError: Option.none(),369+ }));370+ yield* PubSub.publish(snapshots, event);apps/server/src/provider/Layers/EventNdjsonLogger.ts line 128Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -53,0 +109,21 @@109+110+interface ResolvedOptions {111+ readonly maxBytes: number;112+ readonly maxFiles: number;113+ readonly batchWindowMs: number;114+ readonly maxTotalBytes: number;115+ readonly maxAgeMs: number;116+ readonly retentionCheckIntervalMs: number;117+ readonly maxBufferedBytes: number;118+ readonly maxBufferedRecords: number;119+ readonly attribution: ResourceAttributionShape | undefined;120+}121+122+interface PendingRecord {123+ readonly stream: EventNdjsonStream;124+ readonly threadSegment: string;125+ readonly line: string;126+ readonly bytes: number;127+}128+129+interface StoreState {
- @@ -0,0 +942,21 @@942+ />943+ <TooltipPopup side="top">Refresh telemetry snapshot</TooltipPopup>944+ </Tooltip>945+ </div>946+ }947+ >948+ <div className="overflow-hidden rounded-2xl border border-border/70 bg-card shadow-[0_1px_1px_rgb(0_0_0/0.03),0_8px_30px_rgb(0_0_0/0.035)]">949+ <div className="flex flex-col gap-3 border-b border-border/60 bg-linear-to-r from-muted/45 via-muted/20 to-transparent px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-5">950+ <div>951+ <div className="text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70">952+ T3 system footprint953+ </div>954+ <p className="mt-1 max-w-xl text-xs leading-relaxed text-muted-foreground">955+ Live native counters for the server, providers, terminals, desktop processes, and956+ the monitor itself.957+ </p>958+ </div>959+ <div className="flex items-center gap-2 text-[10px] text-muted-foreground/65">960+ <span className="size-1.5 rounded-full bg-emerald-500" />961+ Sampling every 5 seconds962+ </div>
- @@ -0,0 +226,21 @@226+ previous === message.enabled227+ ? Effect.void228+ : Queue.offer(sampleTriggers, undefined).pipe(Effect.asVoid),229+ ),230+ );231+ }232+ };233+234+ const snapshots = Stream.concat(235+ Stream.unwrap(236+ Ref.get(latest).pipe(237+ Effect.map(238+ Option.match({239+ onNone: () => Stream.empty,240+ onSome: Stream.make,241+ }),242+ ),243+ ),244+ ),245+ Stream.fromPubSub(changes),246+ );
- apps/server/src/background/BackgroundPolicy.ts lines 141 to 155Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +73,21 @@73+ return lease.scopes.some((leaseScope) => scopeKey(leaseScope) === key);74+}75+76+function hasThermalPressure(hostPower: HostPowerSnapshot): boolean {77+ return hostPower.thermalState === "serious" || hostPower.thermalState === "critical";78+}79+80+function isHostConstrained(81+ hostPower: HostPowerSnapshot,82+ settings: ResolvedBackgroundActivitySettings,83+): boolean {84+ if (hostPower.stale) return false;85+ if (86+ (settings.pauseWhenHostLocked && hostPower.locked === "true") ||87+ hasThermalPressure(hostPower)88+ ) {89+ return true;90+ }91+ if (settings.pauseWhenHostLowPower && hostPower.lowPowerMode === "true") return true;92+ return settings.pauseWhenOnBattery && hostPower.onBattery === "true";93+}packages/shared/src/backgroundActivitySettings.ts lines 83 to 83OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +63,21 @@63+export function getBackgroundActivityPresetSettings(64+ profile: BackgroundActivityProfile,65+): ResolvedBackgroundActivitySettings {66+ return PRESET_SETTINGS[profile];67+}68+69+export function getBackgroundActivityBaseProfile(70+ backgroundActivity: BackgroundActivitySettings,71+): BackgroundActivityProfile {72+ if (backgroundActivity.profile === "custom") {73+ return backgroundActivity.baseProfile ?? DEFAULT_BACKGROUND_ACTIVITY_PROFILE;74+ }75+ return backgroundActivity.profile;76+}77+78+export function resolveBackgroundActivitySettings(79+ backgroundActivity: BackgroundActivitySettings,80+): ResolvedBackgroundActivitySettings {81+ const baseProfile = getBackgroundActivityBaseProfile(backgroundActivity);82+ const preset = PRESET_SETTINGS[baseProfile];83+ const { overrides } = backgroundActivity;apps/server/src/resourceTelemetry/ResourceTelemetry.ts line 314OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +294,21 @@294+ ? nativeHealth.restartCount295+ : current.lastNativeRestartCount,296+ });297+ if (input.publish !== false) {298+ yield* PubSub.publish(changes, snapshot);299+ }300+ return snapshot;301+ }),302+ );303+304+ const ingestNative = (snapshot: ResourceMonitorSnapshotEvent) =>305+ rebuild({ nativeSnapshot: snapshot, updatePrevious: true });306+ const ingestDesktop = (snapshot: DesktopHostTelemetrySnapshot) =>307+ Effect.gen(function* () {308+ yield* nativeClient.setExternalProcesses([{ pid: snapshot.electronPid }]).pipe(Effect.ignore);309+ yield* nativeClient.setHostPowerState(snapshot.power).pipe(Effect.ignore);310+ const live = (yield* Ref.get(liveState)).retainCount > 0;311+ return yield* rebuild({ desktopSnapshot: snapshot, updatePrevious: false, publish: live });312+ });313+314+ yield* desktopReceiver.changes.pipe(apps/server/src/resourceTelemetry/ResourceTelemetryHistory.ts line 170Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +142,21 @@142+143+export function buildResourceTelemetryHistory(144+ input: BuildResourceTelemetryHistoryInput,145+): ResourceTelemetryHistory {146+ const readAtMs = DateTime.toEpochMillis(input.readAt);147+ const { windowMs, bucketMs } = normalizeResourceTelemetryHistoryInput(input);148+ const windowStartMs = readAtMs - windowMs;149+ const snapshots = input.snapshots150+ .filter((snapshot) => snapshot.sampledAtUnixMs >= windowStartMs)151+ .toSorted((left, right) => left.sampledAtUnixMs - right.sampledAtUnixMs);152+ const electronRootPids = Option.match(input.desktopSnapshot, {153+ onNone: () => new Set<number>(),154+ onSome: (snapshot) => new Set([snapshot.electronPid]),155+ });156+ const desktopIdentity = Option.map(input.desktopSnapshot, (snapshot) => ({157+ ...snapshot,158+ electronProcesses: [],159+ }));160+ const aggregateSamples: AggregateSample[] = [];161+ const processSamples: ProcessSample[] = [];162+ let previous: ReadonlyMap<string, ProcessState> = new Map();
Sign in to join this conversation.



Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
db92ffbb-f25e-4d12-94a9-61f4c23ece27You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.