mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-23 05:10:09 +00:00
144 lines
5.8 KiB
TypeScript
144 lines
5.8 KiB
TypeScript
import * as Effect from "effect/Effect";
|
|
import * as Schema from "effect/Schema";
|
|
|
|
import {
|
|
IsoDateTime,
|
|
NonNegativeInt,
|
|
PositiveInt,
|
|
ProjectId,
|
|
TrimmedNonEmptyString,
|
|
} from "./baseSchemas.ts";
|
|
import {
|
|
PullRequestActor,
|
|
PullRequestChecksState,
|
|
PullRequestMergeability,
|
|
PullRequestReviewDecision,
|
|
PullRequestState,
|
|
} from "./pullRequest.ts";
|
|
|
|
export const ThreadLinkedPullRequest = Schema.Struct({
|
|
projectId: ProjectId,
|
|
repository: TrimmedNonEmptyString,
|
|
number: PositiveInt,
|
|
url: TrimmedNonEmptyString,
|
|
});
|
|
export type ThreadLinkedPullRequest = typeof ThreadLinkedPullRequest.Type;
|
|
|
|
/** stack-dismissed hides an unlinked native member and prevents sync from re-adding it. */
|
|
export const ThreadPullRequestLinkSource = Schema.Literals([
|
|
"manual",
|
|
"created",
|
|
"agent",
|
|
"stack",
|
|
"stack-dismissed",
|
|
]);
|
|
export type ThreadPullRequestLinkSource = typeof ThreadPullRequestLinkSource.Type;
|
|
|
|
export const ThreadPullRequestSnapshot = Schema.Struct({
|
|
state: PullRequestState,
|
|
title: TrimmedNonEmptyString,
|
|
headBranch: TrimmedNonEmptyString,
|
|
baseBranch: TrimmedNonEmptyString,
|
|
isDraft: Schema.Boolean,
|
|
updatedAt: Schema.NullOr(IsoDateTime),
|
|
syncedAt: IsoDateTime,
|
|
closedAt: Schema.optional(Schema.NullOr(Schema.String)),
|
|
mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
|
|
author: Schema.optional(Schema.NullOr(PullRequestActor)),
|
|
additions: Schema.optional(NonNegativeInt),
|
|
deletions: Schema.optional(NonNegativeInt),
|
|
changedFiles: Schema.optional(NonNegativeInt),
|
|
reviewDecision: Schema.optional(Schema.NullOr(PullRequestReviewDecision)),
|
|
checksState: Schema.optional(Schema.NullOr(PullRequestChecksState)),
|
|
mergeability: Schema.optional(PullRequestMergeability),
|
|
rebaseRequired: Schema.optional(Schema.Boolean),
|
|
});
|
|
export type ThreadPullRequestSnapshot = typeof ThreadPullRequestSnapshot.Type;
|
|
|
|
export const ThreadPullRequestStackLayer = Schema.Struct({
|
|
number: PositiveInt,
|
|
headBranch: TrimmedNonEmptyString,
|
|
state: PullRequestState,
|
|
});
|
|
export type ThreadPullRequestStackLayer = typeof ThreadPullRequestStackLayer.Type;
|
|
|
|
/** Layers run bottom to top. */
|
|
export const ThreadPullRequestStack = Schema.Struct({
|
|
kind: Schema.Literal("native"),
|
|
id: TrimmedNonEmptyString,
|
|
number: PositiveInt,
|
|
url: TrimmedNonEmptyString,
|
|
base: TrimmedNonEmptyString,
|
|
layers: Schema.Array(ThreadPullRequestStackLayer),
|
|
});
|
|
export type ThreadPullRequestStack = typeof ThreadPullRequestStack.Type;
|
|
|
|
export const ThreadPullRequestKey = Schema.Struct({
|
|
host: TrimmedNonEmptyString,
|
|
repository: TrimmedNonEmptyString,
|
|
number: PositiveInt,
|
|
});
|
|
export type ThreadPullRequestKey = typeof ThreadPullRequestKey.Type;
|
|
|
|
export const ThreadPullRequestWatch = Schema.Struct({
|
|
startedAt: IsoDateTime,
|
|
headSha: Schema.NullOr(TrimmedNonEmptyString),
|
|
failedChecks: Schema.Array(TrimmedNonEmptyString),
|
|
passed: Schema.Boolean,
|
|
passedChecks: Schema.Array(TrimmedNonEmptyString).pipe(
|
|
Schema.withDecodingDefault(Effect.succeed([])),
|
|
),
|
|
/** Checks still pending when required ones passed early, owed one wake once all settle. */
|
|
owedChecks: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
|
|
/** Approval holds keyed by workflow run URL, or check name when no run URL is known. */
|
|
awaitingApproval: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
|
|
/** The agent was told checks await approval on this head, so later ones stay quiet. */
|
|
approvalAnnounced: Schema.optional(Schema.Boolean),
|
|
remarksThrough: IsoDateTime,
|
|
/** Reported remarks at remarksThrough, so late arrivals at that timestamp still count. */
|
|
remarkIds: Schema.Array(TrimmedNonEmptyString),
|
|
conflicting: Schema.Boolean,
|
|
rebaseRequired: Schema.optional(Schema.Boolean),
|
|
/** Last removal seen; null after an empty read, absent before the first read. */
|
|
mergeQueueRemovalId: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
|
/** Consecutive comment-only wakes; limited to prevent bot loops. */
|
|
wakes: NonNegativeInt,
|
|
/**
|
|
* What is already on the pull request is recorded, not reported: conflicts on the first read, and
|
|
* checks on the first read that can be trusted to show them (one with a head and a full check read).
|
|
*/
|
|
awaitingBaseline: Schema.optional(Schema.Literals(["all", "checks"])),
|
|
/**
|
|
* When the head was first read without any check, until a check shows up or the agent is told
|
|
* none did. Null once either happened; absent on watches saved before it existed.
|
|
*/
|
|
checksAwaitedSince: Schema.optional(Schema.NullOr(IsoDateTime)),
|
|
/**
|
|
* Whether the host was still running checks on the head at the last read. Only then does the
|
|
* watch keep its thread waiting; absent on watches not read since it existed.
|
|
*/
|
|
checksPending: Schema.optional(Schema.Boolean),
|
|
/** How long the watch holds its thread. Absent means until every check finished. */
|
|
until: Schema.optional(Schema.Literal("merged")),
|
|
});
|
|
export type ThreadPullRequestWatch = typeof ThreadPullRequestWatch.Type;
|
|
|
|
/** `merged` also ends when the PR closes or the agent unwatches it. */
|
|
export const PullRequestWatchUntil = Schema.Literals(["checks", "merged"]);
|
|
export type PullRequestWatchUntil = typeof PullRequestWatchUntil.Type;
|
|
|
|
export const ThreadPullRequestLink = Schema.Struct({
|
|
...ThreadPullRequestKey.fields,
|
|
url: TrimmedNonEmptyString,
|
|
/** An actual browser or clone URL; older agent display URLs may be synthesized. */
|
|
repositoryWebUrl: Schema.optional(TrimmedNonEmptyString),
|
|
source: ThreadPullRequestLinkSource,
|
|
linkedAt: IsoDateTime,
|
|
snapshot: Schema.NullOr(ThreadPullRequestSnapshot),
|
|
stack: Schema.NullOr(ThreadPullRequestStack),
|
|
watch: Schema.optional(ThreadPullRequestWatch),
|
|
/** Resume from the ended watch to avoid duplicate notifications. */
|
|
endedWatch: Schema.optional(ThreadPullRequestWatch),
|
|
});
|
|
export type ThreadPullRequestLink = typeof ThreadPullRequestLink.Type;
|