Prettier had never been run in --check mode here before, so this had drifted across most files (markdown tables, long option() chains, line wrapping). Purely formatting, no logic changes - needed so a CI format:check gate can actually pass. Adds .prettierignore for pnpm-lock.yaml specifically: prettier's YAML formatter rewrites every quoted key (single -> double quotes) producing an ~8700-line diff of pure noise on a file pnpm itself owns the formatting of. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
interface RunHandle {
|
|
runId: string;
|
|
scriptId: string;
|
|
controller: AbortController;
|
|
pid?: number;
|
|
}
|
|
|
|
declare global {
|
|
var __triggershellRunHandles: Map<string, RunHandle> | undefined;
|
|
}
|
|
|
|
/** In-memory only - live run handles cannot survive a process restart; see `reconcileOrphanedRuns`.
|
|
* Anchored on `globalThis` - see the comment in `runner/events.ts` for why a plain module-level
|
|
* singleton isn't safe here (Next compiles Route Handlers through a separate module graph from
|
|
* what `server.ts` requires directly). */
|
|
const handles: Map<string, RunHandle> =
|
|
globalThis.__triggershellRunHandles ?? new Map();
|
|
globalThis.__triggershellRunHandles = handles;
|
|
|
|
export function registerRun(handle: RunHandle) {
|
|
handles.set(handle.runId, handle);
|
|
}
|
|
|
|
export function unregisterRun(runId: string) {
|
|
handles.delete(runId);
|
|
}
|
|
|
|
export function getRunHandle(runId: string): RunHandle | undefined {
|
|
return handles.get(runId);
|
|
}
|
|
|
|
export function isRunLive(runId: string): boolean {
|
|
return handles.has(runId);
|
|
}
|
|
|
|
/** Requests cancellation; returns false if the run isn't tracked (already finished or not this process). */
|
|
export function cancelRun(runId: string): boolean {
|
|
const handle = handles.get(runId);
|
|
if (!handle) return false;
|
|
handle.controller.abort();
|
|
return true;
|
|
}
|
|
|
|
export function killAllRuns() {
|
|
for (const handle of handles.values()) {
|
|
handle.controller.abort();
|
|
}
|
|
}
|