Stream git hook progress events for stacked git actions #1214
Mergedjuliusmarmingemerged 14 commits into
main fromrefs/pull/1214/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/server/src/git/Layers/GitService.ts line 153OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -41,0 +133,21 @@133+ hookStartByChildKey.set(childKey, { hookName, startedAtMs: Date.now() });134+ if (progress.onHookStarted) {135+ yield* progress.onHookStarted(hookName);136+ }137+ return;138+ }139+140+ if (event === "child_exit") {141+ hookStartByChildKey.delete(childKey);142+ if (progress.onHookFinished) {143+ const code = record.code;144+ yield* progress.onHookFinished({145+ hookName: started?.hookName ?? hookName,146+ exitCode: typeof code === "number" && Number.isInteger(code) ? code : null,147+ durationMs: started ? Math.max(0, Date.now() - started.startedAtMs) : null,148+ });149+ }150+ }151+ });152+153+ const pollTraceFile = Effect.tryPromise({
- apps/server/src/git/Layers/GitCore.ts lines 414 to 428Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -259,0 +396,21 @@396+ eventPath === traceFileName ||397+ eventPath === traceFilePath ||398+ path.resolve(traceDir, eventPath) === traceFilePath;399+ if (!isTargetTraceEvent) {400+ return Effect.void;401+ }402+ return readTraceDelta;403+ }).pipe(Effect.ignoreCause({ log: true }));404+405+ yield* Effect.forkScoped(watchTraceFile);406+407+ yield* Effect.addFinalizer(() =>408+ Effect.gen(function* () {409+ yield* readTraceDelta;410+ const finalLine = lineBuffer.trim();411+ if (finalLine.length > 0) {412+ yield* handleTraceLine(finalLine);413+ }414+ yield* fileSystem.remove(traceFilePath).pipe(Effect.catch(() => Effect.void));415+ }),416+ );
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/git/Layers/GitCore.ts line 390OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -259,0 +370,21 @@370+ }371+ const appended = delta.slice(processedChars);372+ processedChars = delta.length;373+ lineBuffer += appended;374+ let newlineIndex = lineBuffer.indexOf("\n");375+ while (newlineIndex >= 0) {376+ const line = lineBuffer.slice(0, newlineIndex);377+ lineBuffer = lineBuffer.slice(newlineIndex + 1);378+ yield* handleTraceLine(line);379+ newlineIndex = lineBuffer.indexOf("\n");380+ }381+ }),382+ ),383+ );384+ const watchTraceFile = Stream.runForEach(fs.watch(traceFilePath), (event) => {385+ const eventPath = event.path;386+ const isTargetTraceEvent =387+ eventPath === traceFilePath || path.resolve(eventPath) === traceFilePath;388+ if (!isTargetTraceEvent) return Effect.void;389+ return readTraceDelta;390+ }).pipe(Effect.ignoreCause({ log: true }));apps/server/src/git/Layers/GitCore.ts line 435Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -259,0 +389,21 @@389+ return readTraceDelta;390+ }).pipe(Effect.ignoreCause({ log: true }));391+392+ yield* Effect.forkScoped(watchTraceFile);393+394+ yield* Effect.addFinalizer(() =>395+ Effect.gen(function* () {396+ yield* readTraceDelta;397+ const finalLine = lineBuffer.trim();398+ if (finalLine.length > 0) {399+ yield* handleTraceLine(finalLine);400+ }401+ }),402+ );403+404+ return {405+ env: {406+ GIT_TRACE2_EVENT: traceFilePath,407+ },408+ flush: readTraceDelta,409+ };
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/git/Layers/GitCore.ts line 373Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -259,0 +353,21 @@353+ hookStartByChildKey.set(childKey, { hookName, startedAtMs: Date.now() });354+ if (progress.onHookStarted) {355+ yield* progress.onHookStarted(hookName);356+ }357+ return;358+ }359+360+ if (event === "child_exit") {361+ hookStartByChildKey.delete(childKey);362+ if (progress.onHookFinished) {363+ const code = traceRecord.success.code;364+ yield* progress.onHookFinished({365+ hookName: started?.hookName ?? hookName,366+ exitCode: typeof code === "number" && Number.isInteger(code) ? code : null,367+ durationMs: started ? Math.max(0, Date.now() - started.startedAtMs) : null,368+ });369+ }370+ }371+ });372+373+ const deltaMutex = yield* Semaphore.make(1);
juliusmarminge merged this384f350
juliusmarminge closed this
- @@ -259,0 +381,21 @@381+ }382+383+ const appended = contents.slice(processedChars);384+ const combined = remainder + appended;385+ const lines = combined.split("\n");386+ const nextRemainder = lines.pop() ?? "";387+388+ return [389+ lines.map((line) => line.replace(/\r$/, "")),390+ {391+ processedChars: contents.length,392+ remainder: nextRemainder,393+ },394+ ];395+ }).pipe(396+ Effect.flatMap((lines) => Effect.forEach(lines, handleTraceLine, { discard: true })),397+ ),398+ ),399+ ),400+ Effect.ignore({ log: true }),401+ ),
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
Run ID:
e3c94be5-e7f5-4161-b06e-6a2798074a25You 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 and usage tips.