Skip to content

Commit 4c6df35

Browse files
feat(server): jj status, bookmarks, workspaces and remotes routed by vcs kind
Co-authored-by: Лев Федорец <[email protected]>
1 parent 5d116e2 commit 4c6df35

68 files changed

Lines changed: 8715 additions & 485 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ import type * as SourceControlHost from "@t3tools/source-control-core/server/Sou
5353
import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";
5454
import * as TextGeneration from "../textGeneration/TextGeneration.ts";
5555
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
56+
import * as JjVcsDriver from "../vcs/JjVcsDriver.ts";
5657
import * as VcsProcess from "../vcs/VcsProcess.ts";
5758
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
5859
import * as VcsProjectConfig from "../vcs/VcsProjectConfig.ts";
5960
import * as VcsStatusBroadcaster from "../vcs/VcsStatusBroadcaster.ts";
6061
import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
6162
import * as GitWorkflowService from "./GitWorkflowService.ts";
63+
import * as JjWorkflow from "../jj/JjWorkflow.ts";
6264
import * as ForgejoSourceControlProvider from "@t3tools/source-control-forgejo/server/ForgejoSourceControlProvider";
6365
import * as GitLabSourceControlProvider from "@t3tools/source-control-gitlab/server/GitLabSourceControlProvider";
6466
import {
@@ -879,6 +881,25 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
879881
let remoteReads = 0;
880882
const workflowContext = yield* Layer.build(
881883
GitWorkflowService.layer.pipe(
884+
Layer.provide(
885+
Layer.mock(JjVcsDriver.JjVcsDriver)({
886+
capabilities: {
887+
kind: "jj",
888+
supportsWorktrees: false,
889+
supportsBookmarks: true,
890+
supportsAtomicSnapshot: true,
891+
supportsPushDefaultRemote: false,
892+
ignoreClassifier: "git-compatible-fallback",
893+
},
894+
}),
895+
),
896+
Layer.provide(
897+
Layer.mock(JjWorkflow.JjWorkflow)({
898+
invalidateLocalStatus: () => Effect.void,
899+
invalidateRemoteStatus: () => Effect.void,
900+
invalidateStatus: () => Effect.void,
901+
}),
902+
),
882903
Layer.provide(
883904
Layer.succeed(GitManager.GitManager, {
884905
...manager,
@@ -3615,7 +3636,16 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
36153636
}),
36163637
);
36173638

3618-
it.effect("applies a V2-native thread's project settings to generated commit text", () =>
3639+
it.effect.each([
3640+
{
3641+
name: "applies a V2-native thread's project settings to generated commit text",
3642+
withProjectId: false,
3643+
},
3644+
{
3645+
name: "prefers the thread's project settings over the stacked action's project ID",
3646+
withProjectId: true,
3647+
},
3648+
])("$name", ({ withProjectId }) =>
36193649
Effect.gen(function* () {
36203650
const repoDir = yield* makeTempDir("t3code-git-manager-");
36213651
yield* initRepo(repoDir);
@@ -3702,6 +3732,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
37023732
cwd: repoDir,
37033733
action: "commit",
37043734
threadId,
3735+
...(withProjectId ? { projectId: ProjectId.make("project:ignored-action-input") } : {}),
37053736
});
37063737

37073738
expect(generatedModelSelection).toEqual(projectModel);

‎apps/server/src/git/GitManager.ts‎

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,36 @@ function toPullRequestHeadRemoteInfo(pr: {
704704
};
705705
}
706706

707+
export const readProjectSettings = Effect.fnUntraced(function* (input: {
708+
readonly cwd: string;
709+
readonly threadId?: ThreadId | undefined;
710+
readonly projectId?: ProjectId | undefined;
711+
}) {
712+
const serverSettingsService = yield* ServerSettings.ServerSettingsService;
713+
const settings = yield* serverSettingsService.getSettings;
714+
if (!hasProjectSettingsOverrides(settings)) {
715+
return { settings, projectId: input.projectId ?? null };
716+
}
717+
// Source-control helpers also run without orchestration in the CLI and focused tests.
718+
const threads = yield* Effect.serviceOption(ProjectionStore.ProjectionStoreV2);
719+
const projects = yield* Effect.serviceOption(ProjectStore.ProjectStoreV2);
720+
let projectId = input.projectId ?? null;
721+
if (input.projectId === undefined) {
722+
if (input.threadId !== undefined && Option.isSome(threads)) {
723+
projectId = yield* threads.value.getThreadShell(input.threadId).pipe(
724+
Effect.map((thread) => thread?.projectId ?? null),
725+
Effect.orElseSucceed(() => null),
726+
);
727+
} else if (input.threadId === undefined && Option.isSome(projects)) {
728+
projectId = yield* projects.value.findActiveByWorkspaceRoot(input.cwd).pipe(
729+
Effect.map((project) => Option.getOrNull(project)?.projectId ?? null),
730+
Effect.orElseSucceed(() => null),
731+
);
732+
}
733+
}
734+
return { settings: resolveProjectSettings(settings, projectId).settings, projectId };
735+
});
736+
707737
export const make = Effect.gen(function* () {
708738
const gitCore = yield* GitVcsDriver.GitVcsDriver;
709739
const sourceControlProviders = yield* SourceControlProviderRegistry.SourceControlProviderRegistry;
@@ -719,24 +749,15 @@ export const make = Effect.gen(function* () {
719749
const serverSettingsService = yield* ServerSettings.ServerSettingsService;
720750
const threads = yield* ProjectionStore.ProjectionStoreV2;
721751
const projects = yield* ProjectStore.ProjectStoreV2;
722-
const projectSettingsFor = Effect.fnUntraced(function* (input: {
752+
const projectSettingsFor = (input: {
723753
readonly cwd: string;
724754
readonly threadId?: ThreadId | undefined;
725-
}) {
726-
const settings = yield* serverSettingsService.getSettings;
727-
if (!hasProjectSettingsOverrides(settings))
728-
return { settings, projectId: null as ProjectId | null };
729-
const projectId: ProjectId | null = yield* input.threadId !== undefined
730-
? threads.getThreadShell(input.threadId).pipe(
731-
Effect.map((thread) => thread?.projectId ?? null),
732-
Effect.orElseSucceed(() => null),
733-
)
734-
: projects.findActiveByWorkspaceRoot(input.cwd).pipe(
735-
Effect.map((project) => Option.getOrNull(project)?.projectId ?? null),
736-
Effect.orElseSucceed(() => null),
737-
);
738-
return { settings: resolveProjectSettings(settings, projectId).settings, projectId };
739-
});
755+
}) =>
756+
readProjectSettings({ cwd: input.cwd, threadId: input.threadId }).pipe(
757+
Effect.provideService(ServerSettings.ServerSettingsService, serverSettingsService),
758+
Effect.provideService(ProjectionStore.ProjectionStoreV2, threads),
759+
Effect.provideService(ProjectStore.ProjectStoreV2, projects),
760+
);
740761
const readWorktreesDirectory = serverSettingsService.getSettings.pipe(
741762
Effect.map((settings) => settings.worktreesDirectory),
742763
Effect.orElseSucceed(() => ""),

0 commit comments

Comments
 (0)