pi-ext
bugabingas pi extensions
owned by bugabinga
Moved Pulse session-start git fingerprint to abortable async execFile; settled reload tax fell 69%, 39 Pulse tests passed
90a0fe55b3ef61ab08973c21058d3b5bc3a79700
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
Browse filesCompare with HEAD
Result: {"status":"keep","pulse_settled_reload_tax_ms":60.967,"elapsed_s":225.2,"win32_start_reload_ms":8945.834,"win32_extension_tax_ms":5459.966,"win32_startup_ms":6991.79,"win32_reload_ms":1954.044,"wsl_start_reload_ms":1602.012,"wsl_extension_tax_ms":721.637}
Changed files (1)
extensions/pulse/index.ts
Modified 10 -import { execFileSync }
from "node:child_process";
10 +import { execFile, execFileSync }
from "node:child_process";
11 11 import { createHash }
from "node:crypto";
12 12 import * as fs
from "node:fs";
13 13 import * as path
from "node:path";
14 +import { promisify }
from "node:util";
14 15 import type { ProviderHeaders }
from "@earendil-works/pi-ai";
16 17 complete
as piComplete,
678 +const execFileAsync
= promisify(execFile);
677 680 function gitFingerprint(cwd
: string)
: string | null {
679 682 return execFileSync(
696 +async function gitFingerprintAsync(
698 + signal
: AbortSignal,
699 +)
: Promise<
string | null> {
701 + const { stdout }
= await execFileAsync(
703 + [
"-C", cwd,
"status",
"--porcelain=v1",
"-z",
"--untracked-files=all"],
704 + { encoding:
"utf-8", windowsHide:
true, signal },
693 712 function mutatesWorkspace(toolName
: string)
: boolean {
694 713 return toolName
=== "edit" || toolName
=== "write";
723 742 export default function (pi
: ExtensionAPI) {
724 743 let generation
= 0;
744 + let fingerprintAbort
: AbortController | undefined;
725 745 const state
: PulseState = {
726 746 config: { documents: [] },
1587 1607 state.lastGitFingerprint
= null;
1588 1608 setTimeout(()
=> {
1589 1609 if (ticket
!== generation)
return;
1590 - state.lastGitFingerprint
= gitFingerprint(state.cwd);
1610 + fingerprintAbort?.
abort();
1611 + const abort
= new AbortController();
1612 + fingerprintAbort
= abort;
1613 + void gitFingerprintAsync(state.cwd, abort.signal).
then((fingerprint)
=> {
1614 + if (ticket
!== generation
|| abort.signal.aborted)
return;
1615 + state.lastGitFingerprint
= fingerprint;
1592 1618 state.isPaused
= false;
1593 1619 state.isChecking
= false;
1602 1628 pi.
on(
"session_shutdown",
async (_event, _ctx)
=> {
1630 + fingerprintAbort?.
abort();
1631 + fingerprintAbort
= undefined;
1604 1632 state.isChecking
= false;