TenantAtlas/apps/platform/.pnpm-store/v10/files/11/894871f2efeca36e1c046a234b88db75274677c94ad4760eeacebed84511d2710f4fd5aa1d01ff1b955b14f9dbf50f9785b7157255ded45c48e140c94c333e
Ahmed Darrazi 9f74f7a658
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 51s
feat: compress governance operator outcomes
2026-04-19 14:15:11 +02:00

36 lines
1.4 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggerPadding = void 0;
class LoggerPadding {
logger;
constructor({ logger }) {
this.logger = logger;
}
handle(commands) {
// Sometimes there's limited concurrency, so not all commands will spawn straight away.
// Compute the prefix length now, which works for all styles but those with a PID.
let length = commands.reduce((length, command) => {
const content = this.logger.getPrefixContent(command);
return Math.max(length, content?.value.length || 0);
}, 0);
this.logger.setPrefixLength(length);
// The length of prefixes is somewhat stable, except for PIDs, which might change when a
// process spawns (e.g. PIDs might look like 1, 10 or 100), therefore listen to command starts
// and update the prefix length when this happens.
const subs = commands.map((command) => command.timer.subscribe((event) => {
if (!event.endDate) {
const content = this.logger.getPrefixContent(command);
length = Math.max(length, content?.value.length || 0);
this.logger.setPrefixLength(length);
}
}));
return {
commands,
onFinish() {
subs.forEach((sub) => sub.unsubscribe());
},
};
}
}
exports.LoggerPadding = LoggerPadding;