@kitlangton/ghui 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/package.json +2 -1
- package/src/App.tsx +983 -238
- package/src/domain.ts +77 -10
- package/src/services/CommandRunner.ts +8 -1
- package/src/services/GitHubService.ts +291 -193
- package/src/ui/DetailsPane.tsx +26 -25
- package/src/ui/FooterHints.tsx +62 -6
- package/src/ui/PullRequestDiffPane.tsx +160 -49
- package/src/ui/PullRequestList.tsx +28 -10
- package/src/ui/colors.ts +41 -0
- package/src/ui/commentEditor.ts +126 -0
- package/src/ui/diff.ts +229 -16
- package/src/ui/modals.tsx +236 -9
- package/src/ui/primitives.tsx +2 -2
package/src/domain.ts
CHANGED
|
@@ -1,10 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { Schema } from "effect"
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const LoadStatus = Schema.Literals(["loading", "ready", "error"])
|
|
4
|
+
export type LoadStatus = Schema.Schema.Type<typeof LoadStatus>
|
|
5
|
+
|
|
6
|
+
export const PullRequestState = Schema.Literals(["open", "closed", "merged"])
|
|
7
|
+
export type PullRequestState = Schema.Schema.Type<typeof PullRequestState>
|
|
8
|
+
|
|
9
|
+
export const PullRequestQueueMode = Schema.Literals(["authored", "review", "assigned", "mentioned"])
|
|
10
|
+
export type PullRequestQueueMode = Schema.Schema.Type<typeof PullRequestQueueMode>
|
|
11
|
+
export const pullRequestQueueModes = PullRequestQueueMode.literals
|
|
12
|
+
|
|
13
|
+
export const pullRequestQueueLabels = {
|
|
14
|
+
authored: "authored",
|
|
15
|
+
review: "review requested",
|
|
16
|
+
assigned: "assigned",
|
|
17
|
+
mentioned: "mentioned",
|
|
18
|
+
} as const satisfies Record<PullRequestQueueMode, string>
|
|
19
|
+
|
|
20
|
+
export const pullRequestQueueSearchQualifier = (mode: PullRequestQueueMode, author: string) => {
|
|
21
|
+
const qualifiers = {
|
|
22
|
+
authored: `author:${author}`,
|
|
23
|
+
review: "review-requested:@me",
|
|
24
|
+
assigned: "assignee:@me",
|
|
25
|
+
mentioned: "mentions:@me",
|
|
26
|
+
} as const satisfies Record<PullRequestQueueMode, string>
|
|
27
|
+
return qualifiers[mode]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const CheckConclusion = Schema.Literals(["success", "failure", "neutral", "skipped", "cancelled", "timed_out"])
|
|
31
|
+
export type CheckConclusion = Schema.Schema.Type<typeof CheckConclusion>
|
|
32
|
+
|
|
33
|
+
export const CheckRunStatus = Schema.Literals(["completed", "in_progress", "queued", "pending"])
|
|
34
|
+
export type CheckRunStatus = Schema.Schema.Type<typeof CheckRunStatus>
|
|
35
|
+
|
|
36
|
+
export const CheckRollupStatus = Schema.Literals(["passing", "pending", "failing", "none"])
|
|
37
|
+
export type CheckRollupStatus = Schema.Schema.Type<typeof CheckRollupStatus>
|
|
38
|
+
|
|
39
|
+
export const ReviewStatus = Schema.Literals(["draft", "approved", "changes", "review", "none"])
|
|
40
|
+
export type ReviewStatus = Schema.Schema.Type<typeof ReviewStatus>
|
|
41
|
+
|
|
42
|
+
export const Mergeable = Schema.Literals(["mergeable", "conflicting", "unknown"])
|
|
43
|
+
export type Mergeable = Schema.Schema.Type<typeof Mergeable>
|
|
44
|
+
|
|
45
|
+
export const DiffCommentSide = Schema.Literals(["LEFT", "RIGHT"])
|
|
46
|
+
export type DiffCommentSide = Schema.Schema.Type<typeof DiffCommentSide>
|
|
47
|
+
|
|
48
|
+
export const PullRequestMergeAction = Schema.Literals(["squash", "auto", "admin", "disable-auto"])
|
|
49
|
+
export type PullRequestMergeAction = Schema.Schema.Type<typeof PullRequestMergeAction>
|
|
4
50
|
|
|
5
51
|
export interface CheckItem {
|
|
6
52
|
readonly name: string
|
|
7
|
-
readonly status:
|
|
53
|
+
readonly status: CheckRunStatus
|
|
8
54
|
readonly conclusion: CheckConclusion | null
|
|
9
55
|
}
|
|
10
56
|
|
|
@@ -13,8 +59,31 @@ export interface PullRequestLabel {
|
|
|
13
59
|
readonly color: string | null
|
|
14
60
|
}
|
|
15
61
|
|
|
62
|
+
export interface CreatePullRequestCommentInput {
|
|
63
|
+
readonly repository: string
|
|
64
|
+
readonly number: number
|
|
65
|
+
readonly commitId: string
|
|
66
|
+
readonly path: string
|
|
67
|
+
readonly line: number
|
|
68
|
+
readonly side: DiffCommentSide
|
|
69
|
+
readonly body: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PullRequestReviewComment {
|
|
73
|
+
readonly id: string
|
|
74
|
+
readonly path: string
|
|
75
|
+
readonly line: number
|
|
76
|
+
readonly side: DiffCommentSide
|
|
77
|
+
readonly author: string
|
|
78
|
+
readonly body: string
|
|
79
|
+
readonly createdAt: Date | null
|
|
80
|
+
readonly url: string | null
|
|
81
|
+
}
|
|
82
|
+
|
|
16
83
|
export interface PullRequestItem {
|
|
17
84
|
readonly repository: string
|
|
85
|
+
readonly author: string
|
|
86
|
+
readonly headRefOid: string
|
|
18
87
|
readonly number: number
|
|
19
88
|
readonly title: string
|
|
20
89
|
readonly body: string
|
|
@@ -23,8 +92,8 @@ export interface PullRequestItem {
|
|
|
23
92
|
readonly deletions: number
|
|
24
93
|
readonly changedFiles: number
|
|
25
94
|
readonly state: PullRequestState
|
|
26
|
-
readonly reviewStatus:
|
|
27
|
-
readonly checkStatus:
|
|
95
|
+
readonly reviewStatus: ReviewStatus
|
|
96
|
+
readonly checkStatus: CheckRollupStatus
|
|
28
97
|
readonly checkSummary: string | null
|
|
29
98
|
readonly checks: readonly CheckItem[]
|
|
30
99
|
readonly autoMergeEnabled: boolean
|
|
@@ -40,11 +109,9 @@ export interface PullRequestMergeInfo {
|
|
|
40
109
|
readonly title: string
|
|
41
110
|
readonly state: PullRequestState
|
|
42
111
|
readonly isDraft: boolean
|
|
43
|
-
readonly mergeable:
|
|
44
|
-
readonly reviewStatus:
|
|
45
|
-
readonly checkStatus:
|
|
112
|
+
readonly mergeable: Mergeable
|
|
113
|
+
readonly reviewStatus: ReviewStatus
|
|
114
|
+
readonly checkStatus: CheckRollupStatus
|
|
46
115
|
readonly checkSummary: string | null
|
|
47
116
|
readonly autoMergeEnabled: boolean
|
|
48
117
|
}
|
|
49
|
-
|
|
50
|
-
export type PullRequestMergeAction = "squash" | "auto" | "admin" | "disable-auto"
|
|
@@ -28,6 +28,8 @@ const readStream = async (stream: ReadableStream | null | undefined) => {
|
|
|
28
28
|
export class CommandRunner extends Context.Service<CommandRunner, {
|
|
29
29
|
readonly run: (command: string, args: readonly string[]) => Effect.Effect<CommandResult, CommandError>
|
|
30
30
|
readonly runJson: <A>(command: string, args: readonly string[]) => Effect.Effect<A, CommandError | JsonParseError>
|
|
31
|
+
readonly runSchema: <S extends Schema.Top>(schema: S, command: string, args: readonly string[]) =>
|
|
32
|
+
Effect.Effect<S["Type"], CommandError | JsonParseError | Schema.SchemaError, S["DecodingServices"]>
|
|
31
33
|
}>()("ghui/CommandRunner") {
|
|
32
34
|
static readonly layer = Layer.effect(
|
|
33
35
|
CommandRunner,
|
|
@@ -70,7 +72,12 @@ export class CommandRunner extends Context.Service<CommandRunner, {
|
|
|
70
72
|
})
|
|
71
73
|
})
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
const runSchema = Effect.fn("CommandRunner.runSchema")(function*<S extends Schema.Top>(schema: S, command: string, args: readonly string[]) {
|
|
76
|
+
const value = yield* runJson<unknown>(command, args)
|
|
77
|
+
return yield* Schema.decodeUnknownEffect(schema)(value)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return CommandRunner.of({ run, runJson, runSchema })
|
|
74
81
|
}),
|
|
75
82
|
)
|
|
76
83
|
}
|