Refresh git status after branch rename and worktree setup (#2005)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-04-13 14:58:03 -07:00
1 parent 5f7ec73a22
commit 9dcea68bce
4 files changed
+70 -1

No files matched your search

@@ -27,6 +27,10 @@ import {
type ProviderServiceShape,
} from "../../provider/Services/ProviderService.ts";
import { GitCore, type GitCoreShape } from "../../git/Services/GitCore.ts";
import {
GitStatusBroadcaster,
type GitStatusBroadcasterShape,
} from "../../git/Services/GitStatusBroadcaster.ts";
import { TextGeneration, type TextGenerationShape } from "../../git/Services/TextGeneration.ts";
import { RepositoryIdentityResolverLive } from "../../project/Layers/RepositoryIdentityResolver.ts";
import { OrchestrationEngineLive } from "./OrchestrationEngine.ts";
@@ -177,6 +181,24 @@ describe("ProviderCommandReactor", () => {
: "renamed-branch",
}),
);
const refreshStatus = vi.fn((_: string) =>
Effect.succeed({
isRepo: true,
hasOriginRemote: true,
isDefaultBranch: false,
branch: "renamed-branch",
hasWorkingTreeChanges: false,
workingTree: {
files: [],
insertions: 0,
deletions: 0,
},
hasUpstream: true,
aheadCount: 0,
behindCount: 0,
pr: null,
}),
);
const generateBranchName = vi.fn<TextGenerationShape["generateBranchName"]>((_) =>
Effect.fail(
new TextGenerationError({
@@ -225,6 +247,15 @@ describe("ProviderCommandReactor", () => {
Layer.provideMerge(orchestrationLayer),
Layer.provideMerge(Layer.succeed(ProviderService, service)),
Layer.provideMerge(Layer.succeed(GitCore, { renameBranch } as unknown as GitCoreShape)),
Layer.provideMerge(
Layer.succeed(GitStatusBroadcaster, {
getStatus: () => Effect.die("getStatus should not be called in this test"),
refreshLocalStatus: () =>
Effect.die("refreshLocalStatus should not be called in this test"),
refreshStatus,
streamStatus: () => Stream.die("streamStatus should not be called in this test"),
} satisfies GitStatusBroadcasterShape),
),
Layer.provideMerge(
Layer.mock(TextGeneration, {
generateBranchName,
@@ -279,6 +310,7 @@ describe("ProviderCommandReactor", () => {
respondToUserInput,
stopSession,
renameBranch,
refreshStatus,
generateBranchName,
generateThreadTitle,
stateDir,
@@ -513,9 +545,11 @@ describe("ProviderCommandReactor", () => {
);
await waitFor(() => harness.generateBranchName.mock.calls.length === 1);
await waitFor(() => harness.refreshStatus.mock.calls.length === 1);
expect(harness.generateBranchName.mock.calls[0]?.[0]).toMatchObject({
message: "Add a safer reconnect backoff.",
});
expect(harness.refreshStatus.mock.calls[0]?.[0]).toBe("/tmp/provider-project-worktree");
});
it("forwards codex model options through session start and turn send", async () => {
@@ -17,6 +17,7 @@ import { makeDrainableWorker } from "@t3tools/shared/DrainableWorker";
import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts";
import { GitCore } from "../../git/Services/GitCore.ts";
import { GitStatusBroadcaster } from "../../git/Services/GitStatusBroadcaster.ts";
import { increment, orchestrationEventsProcessedTotal } from "../../observability/Metrics.ts";
import { ProviderAdapterRequestError, ProviderServiceError } from "../../provider/Errors.ts";
import { TextGeneration } from "../../git/Services/TextGeneration.ts";
@@ -145,6 +146,7 @@ const make = Effect.gen(function* () {
const orchestrationEngine = yield* OrchestrationEngineService;
const providerService = yield* ProviderService;
const git = yield* GitCore;
const gitStatusBroadcaster = yield* GitStatusBroadcaster;
const textGeneration = yield* TextGeneration;
const serverSettingsService = yield* ServerSettingsService;
const handledTurnStartKeys = yield* Cache.make<string, true>({
@@ -447,6 +449,7 @@ const make = Effect.gen(function* () {
branch: renamed.branch,
worktreePath: cwd,
});
yield* gitStatusBroadcaster.refreshStatus(cwd).pipe(Effect.ignoreCause({ log: true }));
}).pipe(
Effect.catchCause((cause) =>
Effect.logWarning("provider command reactor failed to generate or rename worktree branch", {
+32 -1
View File
@@ -58,6 +58,10 @@ import {
import { GitCore, type GitCoreShape } from "./git/Services/GitCore.ts";
import { GitManager, type GitManagerShape } from "./git/Services/GitManager.ts";
import { GitStatusBroadcasterLive } from "./git/Layers/GitStatusBroadcaster.ts";
import {
GitStatusBroadcaster,
type GitStatusBroadcasterShape,
} from "./git/Services/GitStatusBroadcaster.ts";
import { Keybindings, type KeybindingsShape } from "./keybindings.ts";
import { Open, type OpenShape } from "./open.ts";
import {
@@ -293,6 +297,7 @@ const buildAppUnderTest = (options?: {
open?: Partial<OpenShape>;
gitCore?: Partial<GitCoreShape>;
gitManager?: Partial<GitManagerShape>;
gitStatusBroadcaster?: Partial<GitStatusBroadcasterShape>;
projectSetupScriptRunner?: Partial<ProjectSetupScriptRunnerShape>;
terminalManager?: Partial<TerminalManagerShape>;
orchestrationEngine?: Partial<OrchestrationEngineShape>;
@@ -341,7 +346,11 @@ const buildAppUnderTest = (options?: {
const gitManagerLayer = Layer.mock(GitManager)({
...options?.layers?.gitManager,
});
const gitStatusBroadcasterLayer = GitStatusBroadcasterLive.pipe(Layer.provide(gitManagerLayer));
const gitStatusBroadcasterLayer = options?.layers?.gitStatusBroadcaster
? Layer.mock(GitStatusBroadcaster)({
...options.layers.gitStatusBroadcaster,
})
: GitStatusBroadcasterLive.pipe(Layer.provide(gitManagerLayer));
const servedRoutesLayer = HttpRouter.serve(makeRoutesLayer, {
disableListenLog: true,
@@ -2913,6 +2922,24 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
() =>
Effect.gen(function* () {
const dispatchedCommands: Array<OrchestrationCommand> = [];
const refreshStatus = vi.fn((_: string) =>
Effect.succeed({
isRepo: true,
hasOriginRemote: true,
isDefaultBranch: false,
branch: "t3code/bootstrap-branch",
hasWorkingTreeChanges: false,
workingTree: {
files: [],
insertions: 0,
deletions: 0,
},
hasUpstream: true,
aheadCount: 0,
behindCount: 0,
pr: null,
}),
);
const createWorktree = vi.fn((_: Parameters<GitCoreShape["createWorktree"]>[0]) =>
Effect.succeed({
worktree: {
@@ -2937,6 +2964,9 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
gitCore: {
createWorktree,
},
gitStatusBroadcaster: {
refreshStatus,
},
orchestrationEngine: {
dispatch: (command) =>
Effect.sync(() => {
@@ -3014,6 +3044,7 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
projectCwd: "/tmp/project",
worktreePath: "/tmp/bootstrap-worktree",
});
assert.deepEqual(refreshStatus.mock.calls[0]?.[0], "/tmp/bootstrap-worktree");
const setupActivities = dispatchedCommands.filter(
(command): command is Extract<OrchestrationCommand, { type: "thread.activity.append" }> =>
+1
View File
@@ -464,6 +464,7 @@ const makeWsRpcLayer = (currentSessionId: AuthSessionId) =>
branch: worktree.worktree.branch,
worktreePath: targetWorktreePath,
});
yield* refreshGitStatus(targetWorktreePath);
}
yield* runSetupProgram();