+36
![github-actions[bot]](/assets/img/avatar_default.png)








Julius Marminge
maria-rcks
Bilal Bakr
shivam
Vitalii Yehorov
Jake Leventhal
Claude Opus 5
Alex Southwell
github-actions[bot]
Nicholas Wasmiller
PB
Exotic
Yash Singh
Devin
Theo Browne
Gabriel De Andrade
Dara Adedeji
scratchyone
Dominic Roy
chukfinley
Primož Ajdišek
benthecarman
NaveDanan
aaditagrawal
Aditya Garud
Nick Anisimov
MacKinley Smith
Yordis Prieto
t3-code[bot]
AKolenda
Guillermo Casanova
Otavio Salvador
Shirish Pothi
Ishaan Kothari
Bob Fowler
Anton Bezdenezhnykh
ValeraZSD
Ephraim
Ryan Ilano
Alex
maco
Cursor
Tristan Knight
PR Batch Tester
oliver
kamkm
de34391427
Co-authored-by: maria-rcks <[email protected]> Co-authored-by: Bilal Bakr <[email protected]> Co-authored-by: shivam <[email protected]> Co-authored-by: Vitalii Yehorov <[email protected]> Co-authored-by: Jake Leventhal <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Alex Southwell <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Nicholas Wasmiller <[email protected]> Co-authored-by: PB <[email protected]> Co-authored-by: Exotic <[email protected]> Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Theo Browne <[email protected]> Co-authored-by: Gabriel De Andrade <[email protected]> Co-authored-by: Dara Adedeji <[email protected]> Co-authored-by: scratchyone <[email protected]> Co-authored-by: Dominic Roy <[email protected]> Co-authored-by: chukfinley <[email protected]> Co-authored-by: Primož Ajdišek <[email protected]> Co-authored-by: benthecarman <[email protected]> Co-authored-by: NaveDanan <[email protected]> Co-authored-by: aaditagrawal <[email protected]> Co-authored-by: Aditya Garud <[email protected]> Co-authored-by: Nick Anisimov <[email protected]> Co-authored-by: MacKinley Smith <[email protected]> Co-authored-by: Yordis Prieto <[email protected]> Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: AKolenda <[email protected]> Co-authored-by: Guillermo Casanova <[email protected]> Co-authored-by: Otavio Salvador <[email protected]> Co-authored-by: Shirish Pothi <[email protected]> Co-authored-by: Ishaan Kothari <[email protected]> Co-authored-by: Bob Fowler <[email protected]> Co-authored-by: Anton Bezdenezhnykh <[email protected]> Co-authored-by: ValeraZSD <[email protected]> Co-authored-by: Ephraim <[email protected]> Co-authored-by: Ryan Ilano <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: maco <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Tristan Knight <[email protected]> Co-authored-by: PR Batch Tester <[email protected]> Co-authored-by: oliver <[email protected]> Co-authored-by: kamkm <[email protected]> Signed-off-by: Yordis Prieto <[email protected]>
125 lines
4.5 KiB
TypeScript
125 lines
4.5 KiB
TypeScript
import * as Schema from "effect/Schema";
|
|
|
|
import { IsoDateTime, NonNegativeInt, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
|
|
|
|
/**
|
|
* Live progress for a thread whose first turn is creating a worktree. The
|
|
* server keeps this in memory only; a client that reconnects mid-setup gets a
|
|
* fresh snapshot, and a finished setup is dropped once its turn starts.
|
|
*/
|
|
/** Producers clamp free text to these before publishing so encoding never fails. */
|
|
export const WORKTREE_SETUP_DETAIL_MAX_LENGTH = 200;
|
|
export const WORKTREE_SETUP_TAIL_LINE_MAX_LENGTH = 400;
|
|
export const WORKTREE_SETUP_ERROR_MAX_LENGTH = 1000;
|
|
|
|
export const WorktreeSetupStageId = Schema.Literals([
|
|
"fetch",
|
|
"checkout",
|
|
"submodules",
|
|
"setup-script",
|
|
"agent",
|
|
]);
|
|
export type WorktreeSetupStageId = typeof WorktreeSetupStageId.Type;
|
|
|
|
export const WorktreeSetupStageStatus = Schema.Literals([
|
|
"pending",
|
|
"running",
|
|
"done",
|
|
"skipped",
|
|
"warning",
|
|
"failed",
|
|
]);
|
|
export type WorktreeSetupStageStatus = typeof WorktreeSetupStageStatus.Type;
|
|
|
|
export const WorktreeSetupStage = Schema.Struct({
|
|
id: WorktreeSetupStageId,
|
|
status: WorktreeSetupStageStatus,
|
|
startedAt: Schema.NullOr(IsoDateTime),
|
|
endedAt: Schema.NullOr(IsoDateTime),
|
|
/** Only the checkout stage reports a real percentage, parsed from git's `Updating files` lines. */
|
|
percent: Schema.NullOr(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 100 }))),
|
|
/** Short trailing text for the row: a file count, an exit code, a submodule name. */
|
|
detail: Schema.NullOr(Schema.String.check(Schema.isMaxLength(WORKTREE_SETUP_DETAIL_MAX_LENGTH))),
|
|
/** Last few output lines from the setup script, ANSI stripped, newest last. */
|
|
tail: Schema.Array(Schema.String.check(Schema.isMaxLength(WORKTREE_SETUP_TAIL_LINE_MAX_LENGTH))),
|
|
});
|
|
export type WorktreeSetupStage = typeof WorktreeSetupStage.Type;
|
|
|
|
export const WorktreeSetupPhase = Schema.Literals(["running", "done", "failed", "cancelled"]);
|
|
export type WorktreeSetupPhase = typeof WorktreeSetupPhase.Type;
|
|
|
|
export const WorktreeSetupSnapshot = Schema.Struct({
|
|
threadId: ThreadId,
|
|
phase: WorktreeSetupPhase,
|
|
startedAt: IsoDateTime,
|
|
endedAt: Schema.NullOr(IsoDateTime),
|
|
branch: Schema.NullOr(TrimmedNonEmptyString),
|
|
baseRef: Schema.NullOr(TrimmedNonEmptyString),
|
|
worktreePath: Schema.NullOr(TrimmedNonEmptyString),
|
|
/** Display name plus command of the setup script from t3.json, when one runs. */
|
|
setupScript: Schema.NullOr(
|
|
Schema.Struct({
|
|
name: TrimmedNonEmptyString,
|
|
command: TrimmedNonEmptyString,
|
|
terminalId: TrimmedNonEmptyString,
|
|
}),
|
|
),
|
|
stages: Schema.Array(WorktreeSetupStage),
|
|
/** Human readable reason when phase is failed. */
|
|
error: Schema.NullOr(Schema.String.check(Schema.isMaxLength(WORKTREE_SETUP_ERROR_MAX_LENGTH))),
|
|
sequence: NonNegativeInt,
|
|
});
|
|
export type WorktreeSetupSnapshot = typeof WorktreeSetupSnapshot.Type;
|
|
|
|
/**
|
|
* Thread activity that carries a `WorktreeSetupSnapshot` as its payload. The
|
|
* bootstrap writes it under a fixed id once the thread exists (phase running)
|
|
* and again when the setup settles, so the projection always holds the
|
|
* latest known state: a client attaches the live stream while it says
|
|
* running and renders the outcome from it afterwards, on any device or
|
|
* after a reload.
|
|
*/
|
|
export const WORKTREE_SETUP_ACTIVITY_KIND = "worktree-setup";
|
|
|
|
export const WorktreeSetupSubscribeInput = Schema.Struct({
|
|
threadId: ThreadId,
|
|
});
|
|
export type WorktreeSetupSubscribeInput = typeof WorktreeSetupSubscribeInput.Type;
|
|
|
|
/** Null means no setup is tracked for that thread. Sent first, then after every change. */
|
|
export const WorktreeSetupStreamEvent = Schema.NullOr(WorktreeSetupSnapshot);
|
|
export type WorktreeSetupStreamEvent = typeof WorktreeSetupStreamEvent.Type;
|
|
|
|
export const WorktreeSetupCancelInput = Schema.Struct({
|
|
threadId: ThreadId,
|
|
});
|
|
export type WorktreeSetupCancelInput = typeof WorktreeSetupCancelInput.Type;
|
|
|
|
export const WorktreeSetupCancelResult = Schema.Struct({
|
|
cancelled: Schema.Boolean,
|
|
});
|
|
export type WorktreeSetupCancelResult = typeof WorktreeSetupCancelResult.Type;
|
|
|
|
export const WORKTREE_SETUP_STAGE_ORDER: ReadonlyArray<WorktreeSetupStageId> = [
|
|
"fetch",
|
|
"checkout",
|
|
"submodules",
|
|
"setup-script",
|
|
"agent",
|
|
];
|
|
|
|
export function worktreeSetupStageLabel(id: WorktreeSetupStageId): string {
|
|
switch (id) {
|
|
case "fetch":
|
|
return "Fetch base branch";
|
|
case "checkout":
|
|
return "Check out files";
|
|
case "submodules":
|
|
return "Init submodules";
|
|
case "setup-script":
|
|
return "Run setup script";
|
|
case "agent":
|
|
return "Start agent";
|
|
}
|
|
}
|