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.3
Permissions in 0.3.3
Files
main.ts2.1 KB
// Register the source-control command and views synchronously, then follow event streams.
// Repository effects follow the view lifecycle; render modules remain pure.
import * as Effect from "effect/Effect";
import * as Stream from "effect/Stream";
import { App, Commands, Events, Views, runPlugin } from "divergence/effect";
import { Git } from "./controller.ts";
import { runFinished } from "./status.ts";
import { renderRail, renderPanel } from "./views/panel.tsx";
const program = Effect.gen(function* () {
const git = yield* Git;
const commands = yield* Commands;
const views = yield* Views;
const app = yield* App;
// Opened by its key, the panel's message box takes the keyboard (the
// rail's button only shows it).
yield* commands.register(
"git.toggle",
Effect.gen(function* () {
const opening = (yield* app.state).shared?.rightPanel !== "git";
yield* git.toggle;
if (opening) yield* views.focus("git-message");
}),
);
git.views.push(
yield* views.add("rail", { slot: "rail", render: (ctx) => {
ctx.run(git.show(ctx.app.workspaceId));
return renderRail(ctx, git);
}, on: ["app_state"], order: 20 }),
);
git.views.push(
yield* views.add("right", { slot: "right", render: (ctx) => renderPanel(ctx, git), on: ["app_state"], order: 20, title: "Source Control" }),
);
const events = yield* Events;
const refreshOn = <A>(stream: Stream.Stream<A>) =>
stream.pipe(
Stream.runForEach(() => Effect.forkScoped(git.refresh(), { startImmediately: true })),
Effect.forkScoped({ startImmediately: true }),
);
yield* refreshOn(events.stream("git_changed").pipe(Stream.filter((event) => event.workspaceId === git.state.workspaceId)));
// Every streamed word is an agent event: only finished runs are asked
// for (an older runtime sends them all, which `runFinished` sorts out).
yield* refreshOn(events.stream("agent", { kinds: ["run_finished"] }).pipe(Stream.filter((event) => runFinished(event.kind))));
yield* refreshOn(events.stream("workspaces_changed"));
});
export default runPlugin(Git.layer, program);
No comments yet.