@@ -2,6 +2,7 @@ import { CommandId, ThreadId, type ChatAttachment, type ProjectId } from "@t3too |
2 | 2 | import { isTemporaryWorktreeBranch } from "@t3tools/shared/git"; |
3 | 3 | import { resolveProjectSettings } from "@t3tools/shared/projectSettings"; |
4 | 4 | import * as Context from "effect/Context"; |
| 5 | +import * as Duration from "effect/Duration"; |
5 | 6 | import * as Effect from "effect/Effect"; |
6 | 7 | import * as Layer from "effect/Layer"; |
7 | 8 | import * as Ref from "effect/Ref"; |
@@ -27,7 +28,6 @@ type NamingInput = { |
27 | 28 | readonly message: { |
28 | 29 | readonly text: string; |
29 | 30 | readonly attachments: ReadonlyArray<ChatAttachment>; |
30 | | - readonly context?: string; |
31 | 31 | }; |
32 | 32 | }; |
33 | 33 |
|
@@ -83,7 +83,6 @@ const make = Effect.gen(function* () { |
83 | 83 | cwd, |
84 | 84 | message: input.message.text, |
85 | 85 | attachments: input.message.attachments, |
86 | | - ...(input.message.context ? { context: input.message.context } : {}), |
87 | 86 | modelSelection, |
88 | 87 | }); |
89 | 88 | const sharing = (branch: string) => |
@@ -150,9 +149,29 @@ const make = Effect.gen(function* () { |
150 | 149 | newBranch: oldBranch, |
151 | 150 | exactName: true, |
152 | 151 | }); |
153 | | - for (const thread of yield* sharing(renamed.branch)) { |
154 | | - yield* update(thread.id, renamed.branch, oldBranch, "branch-rollback"); |
155 | | - } |
| 152 | + // Git is already restored; retry only metadata reads and guarded writes. |
| 153 | + yield* Effect.gen(function* () { |
| 154 | + const visited = new Set<ThreadId>(); |
| 155 | + while (true) { |
| 156 | + const remaining = yield* sharing(renamed.branch); |
| 157 | + if (remaining.length === 0) break; |
| 158 | + for (const thread of remaining) { |
| 159 | + if (visited.has(thread.id)) |
| 160 | + return yield* new BranchMetadataPublicationStalled({ threadId: thread.id }); |
| 161 | + visited.add(thread.id); |
| 162 | + yield* update(thread.id, renamed.branch, oldBranch, "branch-rollback"); |
| 163 | + } |
| 164 | + } |
| 165 | + }).pipe( |
| 166 | + Effect.retry({ |
| 167 | + while: (error) => error._tag !== "BranchMetadataPublicationStalled", |
| 168 | + schedule: Schedule.exponential("100 millis").pipe( |
| 169 | + Schedule.modifyDelay(({ duration }) => |
| 170 | + Effect.succeed(Math.min(Duration.toMillis(duration), 5000)), |
| 171 | + ), |
| 172 | + ), |
| 173 | + }), |
| 174 | + ); |
156 | 175 | return yield* Effect.failCause(cause); |
157 | 176 | }), |
158 | 177 | ), |
|