Official
git
Built-in git UI (JavaScript UI plugin).
The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/git@0.3.1
Permissions in 0.3.1
Files
job.ts1.7 KB
// One piece of background work at a time that the user can stop: a commit message or a pull request being written,
// and the lookup of the branch's pull request. Starting another stops the one before, and stopping interrupts it,
// which aborts its host calls (the host cancels a model's run) and ends its programs.
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
import type * as Scope from "effect/Scope";
export interface Job {
readonly running: boolean;
start(effect: Effect.Effect<void>): Effect.Effect<void>;
readonly stop: Effect.Effect<void>;
}
/** `changed` hears every change of `running`, when the work starts, ends or is stopped. */
export function makeJob(scope: Scope.Scope, changed: (running: boolean) => void): Job {
let current: { fiber?: Fiber.Fiber<void> } | undefined;
const stop = Effect.suspend(() => {
const job = current;
if (!job) return Effect.void;
current = undefined;
changed(false);
return job.fiber ? Fiber.interrupt(job.fiber) : Effect.void;
});
const start = Effect.fn("Git.job")(function* (effect: Effect.Effect<void>) {
yield* stop;
const job: { fiber?: Fiber.Fiber<void> } = {};
current = job;
changed(true);
const ended = Effect.sync(() => {
if (current !== job) return;
current = undefined;
changed(false);
});
const fiber = yield* Effect.forkIn(effect.pipe(Effect.ensuring(ended)), scope, { startImmediately: true });
// Work that ended before forkIn returned has nothing left to interrupt.
if (current === job) job.fiber = fiber;
});
return {
get running() {
return current !== undefined;
},
start,
stop,
};
}
No comments yet.