Skip to content

Commit 6a40eb3

Browse files
t3dotggclaude
andcommitted
fix(server): keep branch rename consistent and satisfy knip
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent f2ef012 commit 6a40eb3

3 files changed

Lines changed: 56 additions & 22 deletions

File tree

‎apps/server/src/orchestration-v2/TemporaryBranchRename.ts‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,30 @@ const make = Effect.gen(function* () {
9797
newBranch: generated.branch,
9898
...(settings.branchNamingMode === "custom" ? { exactName: true } : {}),
9999
});
100-
yield* threads.dispatch({
101-
type: "thread.metadata.update",
102-
commandId: CommandId.make(`${input.commandId}:branch-rename`),
103-
threadId: input.threadId,
104-
branch: renamed.branch,
105-
worktreePath: cwd,
106-
});
100+
// The update is rejected if the thread moved to another worktree during
101+
// generation. Any failed update puts the old name back, so the thread
102+
// never points at a branch that no longer exists.
103+
yield* threads
104+
.dispatch({
105+
type: "thread.metadata.update",
106+
commandId: CommandId.make(`${input.commandId}:branch-rename`),
107+
threadId: input.threadId,
108+
branch: renamed.branch,
109+
worktreePath: cwd,
110+
expectedWorktreePath: cwd,
111+
})
112+
.pipe(
113+
Effect.tapError(() =>
114+
git
115+
.renameBranch({
116+
cwd,
117+
oldBranch: renamed.branch,
118+
newBranch: oldBranch,
119+
exactName: true,
120+
})
121+
.pipe(Effect.ignore),
122+
),
123+
);
107124
}).pipe(
108125
Effect.catchCause((cause) =>
109126
Effect.logWarning("Thread worktree branch rename failed", {

‎apps/server/src/orchestration-v2/testkit/ProviderTurnStartMemory.fixture.mjs‎

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,35 @@ const [Effect, Layer, FileSystem] = await Promise.all([
1313
load("FileSystem"),
1414
]);
1515
const app = (file) => import(NodeURL.pathToFileURL(root + "/apps/server/src/" + file + ".ts"));
16-
const [Start, Projection, Run, Sessions, Policy, Id, Sink, Handoff, Git, Project, Auth] =
17-
await Promise.all([
18-
app("orchestration-v2/ProviderTurnStartService"),
19-
app("orchestration-v2/ProjectionStore"),
20-
app("orchestration-v2/RunExecutionService"),
21-
app("orchestration-v2/ProviderSessionManager"),
22-
app("orchestration-v2/RuntimePolicy"),
23-
app("orchestration-v2/IdAllocator"),
24-
app("orchestration-v2/EventSink"),
25-
app("orchestration-v2/ContextHandoffService"),
26-
app("git/GitWorkflowService"),
27-
app("project/ProjectService"),
28-
app("provider/Services/ProviderAuthService"),
29-
]);
16+
const [
17+
Start,
18+
Projection,
19+
Run,
20+
Sessions,
21+
Policy,
22+
Id,
23+
Sink,
24+
Handoff,
25+
Git,
26+
Project,
27+
Auth,
28+
Settings,
29+
BranchRename,
30+
] = await Promise.all([
31+
app("orchestration-v2/ProviderTurnStartService"),
32+
app("orchestration-v2/ProjectionStore"),
33+
app("orchestration-v2/RunExecutionService"),
34+
app("orchestration-v2/ProviderSessionManager"),
35+
app("orchestration-v2/RuntimePolicy"),
36+
app("orchestration-v2/IdAllocator"),
37+
app("orchestration-v2/EventSink"),
38+
app("orchestration-v2/ContextHandoffService"),
39+
app("git/GitWorkflowService"),
40+
app("project/ProjectService"),
41+
app("provider/Services/ProviderAuthService"),
42+
app("serverSettings"),
43+
app("orchestration-v2/TemporaryBranchRename"),
44+
]);
3045
let current;
3146
let fullReads = 0;
3247
const liveRuns = [];
@@ -49,6 +64,8 @@ const dependencies = Layer.mergeAll(
4964
Layer.mock(Git.GitWorkflowService)({}),
5065
Layer.mock(Project.ProjectService)({}),
5166
Layer.mock(Auth.ProviderAuthService)({}),
67+
Layer.mock(Settings.ServerSettingsService)({}),
68+
Layer.mock(BranchRename.TemporaryBranchRename)({ rename: () => Effect.void }),
5269
Layer.mock(Projection.ProjectionStoreV2)({
5370
getThreadProjection: () =>
5471
Effect.sync(() => {

‎apps/server/src/provider/ClaudeModelCatalog.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export function isClaudeCatalogUltracodeEffort(effort: string | null | undefined
215215
return effort === "ultracode";
216216
}
217217

218-
export function resolveClaudeCatalogContextWindow(
218+
function resolveClaudeCatalogContextWindow(
219219
catalog: ClaudeModelCatalog,
220220
modelSelection: ModelSelection | undefined,
221221
): string | undefined {

0 commit comments

Comments
 (0)