@agimon-ai/doompi-git 0.0.1-alpha.4 → 0.0.1-alpha.40
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 +33 -1
- package/dist/apiContracts.cjs +387 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +382 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/extensions/pi.cjs +105 -1
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.mts +6 -2
- package/dist/extensions/pi.d.mts.map +1 -0
- package/dist/extensions/pi.mjs +100 -1
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/extensions/server.cjs +1828 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +1820 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +2619 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/gitDependencies-CtVubYvU.mjs +22 -0
- package/dist/gitDependencies-CtVubYvU.mjs.map +1 -0
- package/dist/gitDependencies-Dqsz2HjK.cjs +33 -0
- package/dist/gitDependencies-Dqsz2HjK.cjs.map +1 -0
- package/dist/index-D79MSCee.d.mts +145 -0
- package/dist/index-D79MSCee.d.mts.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.mts +2 -5
- package/dist/index.mjs +2 -1
- package/dist/runWorktree-BE795LxL.cjs +374 -0
- package/dist/runWorktree-BE795LxL.cjs.map +1 -0
- package/dist/runWorktree-SPzJvIBt.mjs +303 -0
- package/dist/runWorktree-SPzJvIBt.mjs.map +1 -0
- package/dist/worktreeOperations-BYmVU0UV.cjs +1350 -0
- package/dist/worktreeOperations-BYmVU0UV.cjs.map +1 -0
- package/dist/worktreeOperations-BrWG2muV.mjs +1194 -0
- package/dist/worktreeOperations-BrWG2muV.mjs.map +1 -0
- package/llms.txt +4 -0
- package/package.json +56 -41
- package/src/prompts/doompi-use-git/SKILL.md +26 -3
- package/dist/_virtual/_rolldown/runtime.cjs +0 -1
- package/dist/adapters/channel/worktreeChannel.cjs +0 -2
- package/dist/adapters/channel/worktreeChannel.cjs.map +0 -1
- package/dist/adapters/channel/worktreeChannel.d.cts +0 -40
- package/dist/adapters/channel/worktreeChannel.d.cts.map +0 -1
- package/dist/adapters/channel/worktreeChannel.d.mts +0 -40
- package/dist/adapters/channel/worktreeChannel.d.mts.map +0 -1
- package/dist/adapters/channel/worktreeChannel.mjs +0 -2
- package/dist/adapters/channel/worktreeChannel.mjs.map +0 -1
- package/dist/adapters/filesystem/atomicJson.cjs +0 -2
- package/dist/adapters/filesystem/atomicJson.cjs.map +0 -1
- package/dist/adapters/filesystem/atomicJson.mjs +0 -2
- package/dist/adapters/filesystem/atomicJson.mjs.map +0 -1
- package/dist/adapters/filesystem/paths.cjs +0 -2
- package/dist/adapters/filesystem/paths.cjs.map +0 -1
- package/dist/adapters/filesystem/paths.mjs +0 -2
- package/dist/adapters/filesystem/paths.mjs.map +0 -1
- package/dist/adapters/hub/hubClient.cjs +0 -2
- package/dist/adapters/hub/hubClient.cjs.map +0 -1
- package/dist/adapters/hub/hubClient.d.cts +0 -1
- package/dist/adapters/hub/hubClient.d.mts +0 -1
- package/dist/adapters/hub/hubClient.mjs +0 -2
- package/dist/adapters/hub/hubClient.mjs.map +0 -1
- package/dist/adapters/pi/extension.cjs +0 -2
- package/dist/adapters/pi/extension.cjs.map +0 -1
- package/dist/adapters/pi/extension.d.cts +0 -9
- package/dist/adapters/pi/extension.d.cts.map +0 -1
- package/dist/adapters/pi/extension.d.mts +0 -9
- package/dist/adapters/pi/extension.d.mts.map +0 -1
- package/dist/adapters/pi/extension.mjs +0 -2
- package/dist/adapters/pi/extension.mjs.map +0 -1
- package/dist/adapters/pi/extensions/runWorktreeTool.cjs +0 -15
- package/dist/adapters/pi/extensions/runWorktreeTool.cjs.map +0 -1
- package/dist/adapters/pi/extensions/runWorktreeTool.mjs +0 -15
- package/dist/adapters/pi/extensions/runWorktreeTool.mjs.map +0 -1
- package/dist/adapters/web/worktreesChannel.cjs +0 -2
- package/dist/adapters/web/worktreesChannel.cjs.map +0 -1
- package/dist/adapters/web/worktreesChannel.d.cts +0 -21
- package/dist/adapters/web/worktreesChannel.d.cts.map +0 -1
- package/dist/adapters/web/worktreesChannel.d.mts +0 -21
- package/dist/adapters/web/worktreesChannel.d.mts.map +0 -1
- package/dist/adapters/web/worktreesChannel.mjs +0 -2
- package/dist/adapters/web/worktreesChannel.mjs.map +0 -1
- package/dist/adapters/worktree/dependencyInstall.cjs +0 -2
- package/dist/adapters/worktree/dependencyInstall.cjs.map +0 -1
- package/dist/adapters/worktree/dependencyInstall.mjs +0 -2
- package/dist/adapters/worktree/dependencyInstall.mjs.map +0 -1
- package/dist/adapters/worktree/gitCli.cjs +0 -4
- package/dist/adapters/worktree/gitCli.cjs.map +0 -1
- package/dist/adapters/worktree/gitCli.mjs +0 -4
- package/dist/adapters/worktree/gitCli.mjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.cjs +0 -2
- package/dist/adapters/worktree/repositoryIdentity.cjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.mjs +0 -2
- package/dist/adapters/worktree/repositoryIdentity.mjs.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.cjs +0 -2
- package/dist/adapters/worktree/worktreeOperations.cjs.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.d.cts +0 -32
- package/dist/adapters/worktree/worktreeOperations.d.cts.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.d.mts +0 -32
- package/dist/adapters/worktree/worktreeOperations.d.mts.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.mjs +0 -2
- package/dist/adapters/worktree/worktreeOperations.mjs.map +0 -1
- package/dist/adapters/worktree/worktreeRegistry.cjs +0 -2
- package/dist/adapters/worktree/worktreeRegistry.cjs.map +0 -1
- package/dist/adapters/worktree/worktreeRegistry.mjs +0 -2
- package/dist/adapters/worktree/worktreeRegistry.mjs.map +0 -1
- package/dist/commands/doomGitCommand.cjs +0 -2
- package/dist/commands/doomGitCommand.cjs.map +0 -1
- package/dist/commands/doomGitCommand.mjs +0 -2
- package/dist/commands/doomGitCommand.mjs.map +0 -1
- package/dist/container/index.cjs +0 -2
- package/dist/container/index.cjs.map +0 -1
- package/dist/container/index.d.cts +0 -6
- package/dist/container/index.d.cts.map +0 -1
- package/dist/container/index.d.mts +0 -6
- package/dist/container/index.d.mts.map +0 -1
- package/dist/container/index.mjs +0 -2
- package/dist/container/index.mjs.map +0 -1
- package/dist/extensions/pi.d.cts +0 -2
- package/dist/hubApi.cjs +0 -2
- package/dist/hubApi.cjs.map +0 -1
- package/dist/hubApi.d.cts +0 -6
- package/dist/hubApi.d.cts.map +0 -1
- package/dist/hubApi.d.mts +0 -6
- package/dist/hubApi.d.mts.map +0 -1
- package/dist/hubApi.mjs +0 -2
- package/dist/hubApi.mjs.map +0 -1
- package/dist/index.d.cts +0 -5
- package/dist/schemas/runWorktreeTool.cjs +0 -2
- package/dist/schemas/runWorktreeTool.cjs.map +0 -1
- package/dist/schemas/runWorktreeTool.mjs +0 -2
- package/dist/schemas/runWorktreeTool.mjs.map +0 -1
- package/dist/services/extensionService.cjs +0 -2
- package/dist/services/extensionService.cjs.map +0 -1
- package/dist/services/extensionService.d.cts +0 -8
- package/dist/services/extensionService.d.cts.map +0 -1
- package/dist/services/extensionService.d.mts +0 -8
- package/dist/services/extensionService.d.mts.map +0 -1
- package/dist/services/extensionService.mjs +0 -2
- package/dist/services/extensionService.mjs.map +0 -1
- package/dist/services/support/errors.cjs +0 -2
- package/dist/services/support/errors.cjs.map +0 -1
- package/dist/services/support/errors.mjs +0 -2
- package/dist/services/support/errors.mjs.map +0 -1
- package/dist/services/worktreeNaming.cjs +0 -2
- package/dist/services/worktreeNaming.cjs.map +0 -1
- package/dist/services/worktreeNaming.d.cts +0 -27
- package/dist/services/worktreeNaming.d.cts.map +0 -1
- package/dist/services/worktreeNaming.d.mts +0 -27
- package/dist/services/worktreeNaming.d.mts.map +0 -1
- package/dist/services/worktreeNaming.mjs +0 -2
- package/dist/services/worktreeNaming.mjs.map +0 -1
- package/dist/types/extension.d.cts +0 -17
- package/dist/types/extension.d.cts.map +0 -1
- package/dist/types/extension.d.mts +0 -17
- package/dist/types/extension.d.mts.map +0 -1
- package/dist/types/webWorktrees.cjs +0 -2
- package/dist/types/webWorktrees.cjs.map +0 -1
- package/dist/types/webWorktrees.mjs +0 -2
- package/dist/types/webWorktrees.mjs.map +0 -1
- package/dist/types/worktreeRegistry.d.cts +0 -41
- package/dist/types/worktreeRegistry.d.cts.map +0 -1
- package/dist/types/worktreeRegistry.d.mts +0 -41
- package/dist/types/worktreeRegistry.d.mts.map +0 -1
- package/dist/webHub.cjs +0 -1
- package/dist/webHub.d.cts +0 -2
- package/dist/webHub.d.mts +0 -2
- package/dist/webHub.mjs +0 -1
- package/src/exports/webClient.ts +0 -1
- package/src/types/webWorktrees.ts +0 -55
- package/src/types/worktreeRegistry.ts +0 -69
- package/src/web/components/RunWorktreeToolMessage.tsx +0 -37
- package/src/web/components/WorktreesActivitySection.tsx +0 -64
- package/src/web/components/WorktreesPanel.tsx +0 -125
- package/src/web/components/toolRenderers.ts +0 -7
- package/src/web/index.ts +0 -30
- package/src/web/stores/worktreesActivityStore.ts +0 -124
- package/src/web/tsconfig.json +0 -22
|
@@ -0,0 +1,2619 @@
|
|
|
1
|
+
import { apiResponse, createApiClient, defineActivityGroup, defineApiRoutes, defineChannelFile, defineFill, defineGlobalStore, defineRepositorySettingsPanel, defineSessionStore, defineToolRenderer, defineWebLifecycle, defineWebPlugin, sessionApiAddress } from "@agimon-ai/doompi-core/web";
|
|
2
|
+
import { AlertIcon, BranchIcon, Button, ChevronDownIcon, ChevronRightIcon, CloseIcon, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DiffView, Dot, DropdownMenuItem, EmptyState, Input, Label, MessageIcon, MessageItem, MessageItemBody, MessageItemHeader, OptionRow, RadioGroup, RadioGroupCard, ReviewCommentDraft, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, ShieldIcon, Spinner, StatusBadge, buildReviewPrompt, reviewCommentAnchor, toolTone } from "@agimon-ai/doompi-web-components";
|
|
3
|
+
import { createElement, useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { sealedTransport } from "@agimon-ai/doompi-web-security/browser";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useStore } from "@tanstack/react-store";
|
|
7
|
+
//#region src/types/apiRoutes.ts
|
|
8
|
+
/**
|
|
9
|
+
* The routes the page calls, as data.
|
|
10
|
+
*
|
|
11
|
+
* No scope and no base path: the build reads both off
|
|
12
|
+
* `src/extensions/(backend)/api/git/`, which mounts at global scope and so
|
|
13
|
+
* answers workspace and session requests too. Each route answers only where it
|
|
14
|
+
* belongs (auth on a workspace mount, the review on a session mount), so a
|
|
15
|
+
* client accessor on the wrong scope gets a 404 rather than a second way in.
|
|
16
|
+
*
|
|
17
|
+
* Only what the browser calls is listed. The worktree routes stay HTTP for
|
|
18
|
+
* other callers, but the dock drives worktrees over its channel.
|
|
19
|
+
*/
|
|
20
|
+
var apiRoutes_default = defineApiRoutes({
|
|
21
|
+
/** Workspace: the new-session dialog's branch list. */
|
|
22
|
+
branches: {
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: "/branches",
|
|
25
|
+
response: apiResponse()
|
|
26
|
+
},
|
|
27
|
+
/** Workspace: a top-level worktree session on an existing or new branch. */
|
|
28
|
+
createSession: {
|
|
29
|
+
method: "POST",
|
|
30
|
+
path: "/sessions",
|
|
31
|
+
response: apiResponse()
|
|
32
|
+
},
|
|
33
|
+
/** Workspace: that workspace's saved remote auth, never the token itself. */
|
|
34
|
+
auth: {
|
|
35
|
+
method: "GET",
|
|
36
|
+
path: "/auth",
|
|
37
|
+
query: ["repositoryId"],
|
|
38
|
+
response: apiResponse()
|
|
39
|
+
},
|
|
40
|
+
/** Workspace: replaces that workspace's remote auth. Passkey step-up gated for remote devices. */
|
|
41
|
+
saveAuth: {
|
|
42
|
+
method: "PUT",
|
|
43
|
+
path: "/auth",
|
|
44
|
+
query: ["repositoryId"],
|
|
45
|
+
response: apiResponse()
|
|
46
|
+
},
|
|
47
|
+
/** Session: the files this session's checkout changed against its base. */
|
|
48
|
+
review: {
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: "/review",
|
|
51
|
+
response: apiResponse()
|
|
52
|
+
},
|
|
53
|
+
/** Session: one changed file's hunks. */
|
|
54
|
+
reviewFile: {
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: "/review/file",
|
|
57
|
+
query: ["path"],
|
|
58
|
+
response: apiResponse()
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const api = createApiClient(apiRoutes_default, {
|
|
62
|
+
scopes: [
|
|
63
|
+
"global",
|
|
64
|
+
"workspace",
|
|
65
|
+
"session"
|
|
66
|
+
],
|
|
67
|
+
basePath: "git",
|
|
68
|
+
transport: (input, init) => sealedTransport.fetch(input, init),
|
|
69
|
+
sessionAddress: sessionApiAddress
|
|
70
|
+
});
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/extensions/workspaces/(frontend)/_lib/newSessionForm.ts
|
|
73
|
+
const MAX_LISTED = 200;
|
|
74
|
+
/** Local branches first, then remote-only ones, filtered by a case-insensitive substring. */
|
|
75
|
+
function branchOptions(branches, query) {
|
|
76
|
+
const needle = query.trim().toLowerCase();
|
|
77
|
+
const matches = (text) => needle === "" || text.toLowerCase().includes(needle);
|
|
78
|
+
const local = branches.local.filter((branch) => matches(branch.name)).map((branch) => ({
|
|
79
|
+
key: `local:${branch.name}`,
|
|
80
|
+
name: branch.name,
|
|
81
|
+
current: branch.name === branches.current,
|
|
82
|
+
...branch.checkedOutAt === void 0 ? {} : { busyAt: branch.checkedOutAt }
|
|
83
|
+
}));
|
|
84
|
+
const remote = branches.remote.filter((branch) => matches(`${branch.remote}/${branch.name}`)).map((branch) => ({
|
|
85
|
+
key: `remote:${branch.remote}/${branch.name}`,
|
|
86
|
+
name: branch.name,
|
|
87
|
+
remote: branch.remote,
|
|
88
|
+
current: false
|
|
89
|
+
}));
|
|
90
|
+
return [...local, ...remote].slice(0, MAX_LISTED);
|
|
91
|
+
}
|
|
92
|
+
/** Every base a new branch can start from: the default first, then remote-tracking names, then local branches. */
|
|
93
|
+
function baseOptions(branches) {
|
|
94
|
+
return [.../* @__PURE__ */ new Set([
|
|
95
|
+
...branches.defaultBase === void 0 ? [] : [branches.defaultBase],
|
|
96
|
+
...branches.remote.map((branch) => `${branch.remote}/${branch.name}`),
|
|
97
|
+
...branches.local.map((branch) => branch.name)
|
|
98
|
+
])];
|
|
99
|
+
}
|
|
100
|
+
/** Why the form cannot be submitted yet, or undefined when it can. */
|
|
101
|
+
function formProblem$1(state) {
|
|
102
|
+
if (state.mode === "existing") {
|
|
103
|
+
if (state.selected === void 0) return "Pick a branch.";
|
|
104
|
+
if (state.selected.busyAt !== void 0) return `That branch is checked out at ${state.selected.busyAt}.`;
|
|
105
|
+
}
|
|
106
|
+
if (state.mode === "new" && state.newBranch.trim() === "") return "Name the new branch.";
|
|
107
|
+
}
|
|
108
|
+
/** The worktree create request for the form, or undefined in plain mode. */
|
|
109
|
+
function createRequest(state) {
|
|
110
|
+
const name = state.name.trim();
|
|
111
|
+
const named = name === "" ? {} : { name };
|
|
112
|
+
if (state.mode === "existing" && state.selected !== void 0) return {
|
|
113
|
+
mode: "existing-branch",
|
|
114
|
+
branch: state.selected.name,
|
|
115
|
+
...state.selected.remote === void 0 ? {} : { remote: state.selected.remote },
|
|
116
|
+
...named
|
|
117
|
+
};
|
|
118
|
+
if (state.mode === "new") {
|
|
119
|
+
const baseRef = state.baseRef.trim();
|
|
120
|
+
return {
|
|
121
|
+
mode: "new-branch",
|
|
122
|
+
branch: state.newBranch.trim(),
|
|
123
|
+
...baseRef === "" ? {} : { baseRef },
|
|
124
|
+
...named
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/extensions/workspaces/(frontend)/fill/_components/GitNewSessionDialog.tsx
|
|
130
|
+
const MODES = [
|
|
131
|
+
{
|
|
132
|
+
mode: "existing",
|
|
133
|
+
label: "existing branch"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
mode: "new",
|
|
137
|
+
label: "new branch"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
mode: "plain",
|
|
141
|
+
label: "no branch"
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
function errorOf$1(body, status) {
|
|
145
|
+
return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : `The cockpit answered ${String(status)}.`;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The new-session dialog when git is installed: a worktree on an existing or a
|
|
149
|
+
* new branch, or a plain session in the workspace root. A worktree session
|
|
150
|
+
* starts at the top level of the rail, with no parent.
|
|
151
|
+
*/
|
|
152
|
+
function GitNewSessionDialog({ newSession }) {
|
|
153
|
+
const [branches, setBranches] = useState(null);
|
|
154
|
+
const [loadError, setLoadError] = useState("");
|
|
155
|
+
const [form, setForm] = useState({
|
|
156
|
+
mode: "existing",
|
|
157
|
+
newBranch: "",
|
|
158
|
+
baseRef: "",
|
|
159
|
+
name: ""
|
|
160
|
+
});
|
|
161
|
+
const [query, setQuery] = useState("");
|
|
162
|
+
const [error, setError] = useState("");
|
|
163
|
+
const [busy, setBusy] = useState(false);
|
|
164
|
+
const workspaceId = newSession?.workspaceId;
|
|
165
|
+
const request = newSession?.requestWithStepUp;
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (workspaceId === void 0 || request === void 0) return;
|
|
168
|
+
let stale = false;
|
|
169
|
+
const url = api.workspace(workspaceId).branches.url();
|
|
170
|
+
request(url).then(async (response) => {
|
|
171
|
+
const body = await response.json().catch(() => void 0);
|
|
172
|
+
if (stale) return;
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
setLoadError(errorOf$1(body, response.status));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const loaded = body;
|
|
178
|
+
setBranches(loaded);
|
|
179
|
+
setForm((current) => ({
|
|
180
|
+
...current,
|
|
181
|
+
baseRef: loaded.defaultBase ?? ""
|
|
182
|
+
}));
|
|
183
|
+
}).catch(() => {
|
|
184
|
+
if (!stale) setLoadError("The branches could not be loaded.");
|
|
185
|
+
});
|
|
186
|
+
return () => {
|
|
187
|
+
stale = true;
|
|
188
|
+
};
|
|
189
|
+
}, [workspaceId, request]);
|
|
190
|
+
if (newSession === void 0) return null;
|
|
191
|
+
const gitReady = branches?.repository === true && loadError === "";
|
|
192
|
+
const mode = gitReady || branches === null ? form.mode : "plain";
|
|
193
|
+
const state = {
|
|
194
|
+
...form,
|
|
195
|
+
mode
|
|
196
|
+
};
|
|
197
|
+
const problem = formProblem$1(state);
|
|
198
|
+
const options = branches === null ? [] : branchOptions(branches, query);
|
|
199
|
+
const bases = branches === null ? [] : baseOptions(branches);
|
|
200
|
+
const update = (patch) => setForm((current) => ({
|
|
201
|
+
...current,
|
|
202
|
+
...patch
|
|
203
|
+
}));
|
|
204
|
+
const submit = async () => {
|
|
205
|
+
if (busy || problem !== void 0) return;
|
|
206
|
+
setBusy(true);
|
|
207
|
+
setError("");
|
|
208
|
+
const body = createRequest(state);
|
|
209
|
+
let failure;
|
|
210
|
+
if (body === void 0) failure = await newSession.createPlain(state.name);
|
|
211
|
+
else try {
|
|
212
|
+
const response = await newSession.requestWithStepUp(api.workspace(newSession.workspaceId).createSession.url(), {
|
|
213
|
+
method: "POST",
|
|
214
|
+
headers: { "Content-Type": "application/json" },
|
|
215
|
+
body: JSON.stringify(body)
|
|
216
|
+
});
|
|
217
|
+
const answer = await response.json().catch(() => void 0);
|
|
218
|
+
failure = response.ok ? await newSession.openCreated(answer.sessionId) : errorOf$1(answer, response.status);
|
|
219
|
+
} catch {
|
|
220
|
+
failure = "The cockpit is unreachable.";
|
|
221
|
+
}
|
|
222
|
+
if (failure === void 0) return;
|
|
223
|
+
setError(failure);
|
|
224
|
+
setBusy(false);
|
|
225
|
+
};
|
|
226
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
227
|
+
open: true,
|
|
228
|
+
onOpenChange: (next) => !next && !busy && newSession.close(),
|
|
229
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
230
|
+
width: "md",
|
|
231
|
+
"data-testid": "new-session-dialog",
|
|
232
|
+
"aria-describedby": void 0,
|
|
233
|
+
children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "new session" }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [
|
|
234
|
+
/* @__PURE__ */ jsx("p", {
|
|
235
|
+
className: "truncate text-xs text-doom-faint",
|
|
236
|
+
title: newSession.workspaceRoot,
|
|
237
|
+
children: newSession.workspaceRoot
|
|
238
|
+
}),
|
|
239
|
+
gitReady ? /* @__PURE__ */ jsx("div", {
|
|
240
|
+
role: "radiogroup",
|
|
241
|
+
"aria-label": "session kind",
|
|
242
|
+
className: "flex gap-1",
|
|
243
|
+
children: MODES.map((entry) => /* @__PURE__ */ jsx(Button, {
|
|
244
|
+
role: "radio",
|
|
245
|
+
"aria-checked": mode === entry.mode,
|
|
246
|
+
variant: mode === entry.mode ? "outline" : "ghost",
|
|
247
|
+
size: "sm",
|
|
248
|
+
"data-testid": `git-new-session-mode-${entry.mode}`,
|
|
249
|
+
disabled: busy,
|
|
250
|
+
className: mode === entry.mode ? "border-doom-blue/60 text-doom-hi" : void 0,
|
|
251
|
+
onClick: () => update({ mode: entry.mode }),
|
|
252
|
+
children: entry.label
|
|
253
|
+
}, entry.mode))
|
|
254
|
+
}) : branches === null && loadError === "" ? /* @__PURE__ */ jsx("p", {
|
|
255
|
+
className: "text-xs text-doom-faint",
|
|
256
|
+
children: "reading branches…"
|
|
257
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
258
|
+
"data-testid": "git-new-session-plain-note",
|
|
259
|
+
className: "text-xs text-doom-faint",
|
|
260
|
+
children: loadError || "This workspace is not a git checkout, so the session starts in its folder."
|
|
261
|
+
}),
|
|
262
|
+
mode === "existing" && gitReady ? /* @__PURE__ */ jsxs("div", {
|
|
263
|
+
className: "flex flex-col gap-1",
|
|
264
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
265
|
+
"data-testid": "git-new-session-branch-search",
|
|
266
|
+
"aria-label": "find a branch",
|
|
267
|
+
value: query,
|
|
268
|
+
autoFocus: true,
|
|
269
|
+
disabled: busy,
|
|
270
|
+
onChange: (event) => setQuery(event.target.value),
|
|
271
|
+
placeholder: "find a branch"
|
|
272
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
273
|
+
role: "listbox",
|
|
274
|
+
"aria-label": "branches",
|
|
275
|
+
className: "max-h-48 overflow-y-auto rounded border border-doom-border bg-doom-deep p-1",
|
|
276
|
+
children: [options.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
277
|
+
className: "px-2 py-1 text-2xs text-doom-faint",
|
|
278
|
+
children: "no matching branches"
|
|
279
|
+
}) : null, options.map((option) => /* @__PURE__ */ jsxs(OptionRow, {
|
|
280
|
+
density: "compact",
|
|
281
|
+
active: form.selected?.key === option.key,
|
|
282
|
+
disabled: option.busyAt !== void 0 || busy,
|
|
283
|
+
"data-testid": "git-new-session-branch-option",
|
|
284
|
+
"data-branch": option.name,
|
|
285
|
+
"data-remote": option.remote,
|
|
286
|
+
onClick: () => update({ selected: option }),
|
|
287
|
+
className: `w-full px-2.5 py-1 text-sm ${option.busyAt !== void 0 ? "opacity-50" : ""}`,
|
|
288
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
289
|
+
className: "min-w-0 flex-1 truncate",
|
|
290
|
+
children: option.remote === void 0 ? option.name : `${option.remote}/${option.name}`
|
|
291
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
292
|
+
className: "shrink-0 text-2xs text-doom-faint",
|
|
293
|
+
children: option.current && option.busyAt !== void 0 ? "current · checked out" : option.current ? "current" : option.busyAt !== void 0 ? "checked out" : option.remote !== void 0 ? "remote" : ""
|
|
294
|
+
})]
|
|
295
|
+
}, option.key))]
|
|
296
|
+
})]
|
|
297
|
+
}) : null,
|
|
298
|
+
mode === "new" && gitReady ? /* @__PURE__ */ jsxs("div", {
|
|
299
|
+
className: "flex flex-col gap-2",
|
|
300
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
301
|
+
htmlFor: "git-new-session-new-branch",
|
|
302
|
+
className: "flex flex-col gap-1",
|
|
303
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
304
|
+
className: "text-xs text-doom-faint",
|
|
305
|
+
children: "new branch"
|
|
306
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
307
|
+
id: "git-new-session-new-branch",
|
|
308
|
+
"data-testid": "git-new-session-new-branch",
|
|
309
|
+
value: form.newBranch,
|
|
310
|
+
autoFocus: true,
|
|
311
|
+
disabled: busy,
|
|
312
|
+
onChange: (event) => update({ newBranch: event.target.value }),
|
|
313
|
+
placeholder: "feature/my-change"
|
|
314
|
+
})]
|
|
315
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
316
|
+
className: "flex flex-col gap-1",
|
|
317
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
318
|
+
className: "text-xs text-doom-faint",
|
|
319
|
+
children: "from"
|
|
320
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
321
|
+
value: form.baseRef,
|
|
322
|
+
onValueChange: (baseRef) => update({ baseRef }),
|
|
323
|
+
disabled: busy,
|
|
324
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
325
|
+
"data-testid": "git-new-session-base",
|
|
326
|
+
"aria-label": "base branch",
|
|
327
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "base branch" })
|
|
328
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: bases.map((base) => /* @__PURE__ */ jsx(SelectItem, {
|
|
329
|
+
value: base,
|
|
330
|
+
children: base === branches?.current ? `${base} (current)` : base
|
|
331
|
+
}, base)) })]
|
|
332
|
+
})]
|
|
333
|
+
})]
|
|
334
|
+
}) : null,
|
|
335
|
+
/* @__PURE__ */ jsxs("label", {
|
|
336
|
+
htmlFor: "new-session-name",
|
|
337
|
+
className: "flex flex-col gap-1",
|
|
338
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
339
|
+
className: "text-xs text-doom-faint",
|
|
340
|
+
children: [
|
|
341
|
+
"name",
|
|
342
|
+
" ",
|
|
343
|
+
/* @__PURE__ */ jsxs("span", {
|
|
344
|
+
className: "text-doom-faint",
|
|
345
|
+
children: [
|
|
346
|
+
"(optional",
|
|
347
|
+
mode === "plain" ? "" : "; defaults to the branch",
|
|
348
|
+
")"
|
|
349
|
+
]
|
|
350
|
+
})
|
|
351
|
+
]
|
|
352
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
353
|
+
id: "new-session-name",
|
|
354
|
+
"data-testid": "new-session-name",
|
|
355
|
+
value: form.name,
|
|
356
|
+
autoFocus: mode === "plain",
|
|
357
|
+
disabled: busy,
|
|
358
|
+
onChange: (event) => update({ name: event.target.value }),
|
|
359
|
+
onKeyDown: (event) => {
|
|
360
|
+
if (event.key === "Enter") submit();
|
|
361
|
+
},
|
|
362
|
+
placeholder: "session name"
|
|
363
|
+
})]
|
|
364
|
+
}),
|
|
365
|
+
error ? /* @__PURE__ */ jsx("pre", {
|
|
366
|
+
"data-testid": "new-session-error",
|
|
367
|
+
className: "max-h-28 overflow-y-auto rounded border border-doom-edge-red bg-doom-tint-red/40 px-2.5 py-2 text-xs whitespace-pre-wrap text-doom-red",
|
|
368
|
+
children: error
|
|
369
|
+
}) : null,
|
|
370
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
371
|
+
variant: "outline",
|
|
372
|
+
"data-testid": "new-session-cancel",
|
|
373
|
+
disabled: busy,
|
|
374
|
+
onClick: () => newSession.close(),
|
|
375
|
+
children: "cancel"
|
|
376
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
377
|
+
variant: "primary",
|
|
378
|
+
"data-testid": "new-session-create",
|
|
379
|
+
title: problem,
|
|
380
|
+
disabled: busy || problem !== void 0,
|
|
381
|
+
onClick: () => void submit(),
|
|
382
|
+
children: busy ? mode === "plain" ? "creating…" : "creating worktree…" : "create"
|
|
383
|
+
})] })
|
|
384
|
+
] })]
|
|
385
|
+
})
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/extensions/workspaces/(frontend)/fill/GitNewSession.new-session.web.tsx
|
|
390
|
+
var GitNewSession_new_session_web_default = defineFill({ component: GitNewSessionDialog });
|
|
391
|
+
function formFromView(view) {
|
|
392
|
+
return {
|
|
393
|
+
method: view.method,
|
|
394
|
+
keyPath: view.ssh?.keyPath ?? "",
|
|
395
|
+
host: view.https?.host ?? "github.com",
|
|
396
|
+
username: view.https?.username ?? "",
|
|
397
|
+
token: ""
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const HOST_PATTERN = /^[a-z0-9.-]{1,253}(:\d{1,5})?$/u;
|
|
401
|
+
/** Whether a value holds an ASCII control character; a newline in a credential field could add a line to git's credential protocol. */
|
|
402
|
+
function hasControl(value) {
|
|
403
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
404
|
+
const code = value.charCodeAt(index);
|
|
405
|
+
if (code < 32 || code === 127) return true;
|
|
406
|
+
}
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
/** Whether the saved token can stay: only when one exists and the host has not moved. */
|
|
410
|
+
function keepsToken(form, saved) {
|
|
411
|
+
return saved.https?.hasToken === true && saved.https.host === form.host.trim().toLowerCase();
|
|
412
|
+
}
|
|
413
|
+
/** The first thing wrong with the form, in words, or undefined when it can be saved. */
|
|
414
|
+
function formProblem(form, saved) {
|
|
415
|
+
if (form.method === "ssh") {
|
|
416
|
+
const keyPath = form.keyPath.trim();
|
|
417
|
+
if (keyPath === "") return void 0;
|
|
418
|
+
if (hasControl(keyPath)) return "The key path has a control character in it.";
|
|
419
|
+
if (!keyPath.startsWith("/") && !keyPath.startsWith("~/")) return "Give the key as an absolute path or one under ~/.";
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (form.method === "https") {
|
|
423
|
+
const host = form.host.trim().toLowerCase();
|
|
424
|
+
if (!HOST_PATTERN.test(host)) return "The host should look like github.com, with an optional :port.";
|
|
425
|
+
if (form.username.trim() === "") return "A username is required.";
|
|
426
|
+
if (hasControl(form.username) || hasControl(form.token)) return "Remove the control character from the username or token.";
|
|
427
|
+
if (form.token === "" && !keepsToken(form, saved)) return saved.https?.hasToken === true ? "The host changed, so enter the token for the new host." : "A token is required.";
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/** What a save sends. The token goes only when the reader typed one. */
|
|
431
|
+
function saveRequestOf(form) {
|
|
432
|
+
if (form.method === "ssh") {
|
|
433
|
+
const keyPath = form.keyPath.trim();
|
|
434
|
+
return keyPath === "" ? { method: "ssh" } : {
|
|
435
|
+
method: "ssh",
|
|
436
|
+
keyPath
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
if (form.method === "https") return {
|
|
440
|
+
method: "https",
|
|
441
|
+
host: form.host.trim().toLowerCase(),
|
|
442
|
+
username: form.username.trim(),
|
|
443
|
+
...form.token === "" ? {} : { token: form.token }
|
|
444
|
+
};
|
|
445
|
+
return { method: "none" };
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/extensions/workspaces/(frontend)/repository-settings-panel/_components/GitAuthForm.tsx
|
|
449
|
+
/**
|
|
450
|
+
* A workspace's git remote panel body: how doompi-git reaches the remote when
|
|
451
|
+
* you pull, push or rebase from this workspace's sessions in the cockpit.
|
|
452
|
+
*
|
|
453
|
+
* DESIGN PATTERNS:
|
|
454
|
+
* - Per workspace. Worktree sessions use the setup of the workspace they
|
|
455
|
+
* belong to. A workspace with nothing set uses this machine's own git.
|
|
456
|
+
* - Three choices as cards, the way the theme picker offers them: this
|
|
457
|
+
* machine's own git, an SSH key, or an HTTPS token.
|
|
458
|
+
* - The token is write-only. The field is never prefilled; a saved token shows
|
|
459
|
+
* as a badge, and leaving the field empty keeps it.
|
|
460
|
+
* - Form state is the reader's until they save. The owner remounts the form
|
|
461
|
+
* after a save so it starts again from what the server now holds.
|
|
462
|
+
*
|
|
463
|
+
* AVOID:
|
|
464
|
+
* - Echoing a token back. The view the server sends has none to echo.
|
|
465
|
+
*/
|
|
466
|
+
const METHODS = [
|
|
467
|
+
{
|
|
468
|
+
method: "none",
|
|
469
|
+
title: "this machine's git",
|
|
470
|
+
detail: "use whatever git on this machine already does: your credential helper, ssh config and agent"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
method: "ssh",
|
|
474
|
+
title: "SSH key",
|
|
475
|
+
detail: "a key file on this machine, or your ssh-agent"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
method: "https",
|
|
479
|
+
title: "HTTPS token",
|
|
480
|
+
detail: "a username and personal access token for one host"
|
|
481
|
+
}
|
|
482
|
+
];
|
|
483
|
+
function GitAuthForm({ saved, saving, saveError, savedNotice = false, onSave }) {
|
|
484
|
+
const [form, setForm] = useState(() => formFromView(saved));
|
|
485
|
+
const update = (patch) => setForm((current) => ({
|
|
486
|
+
...current,
|
|
487
|
+
...patch
|
|
488
|
+
}));
|
|
489
|
+
const problem = formProblem(form, saved);
|
|
490
|
+
const tokenSaved = saved.https?.hasToken === true && saved.https.host === form.host.trim().toLowerCase();
|
|
491
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
492
|
+
"data-testid": "git-auth-form",
|
|
493
|
+
className: "flex w-full min-w-0 flex-col gap-4",
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ jsx(RadioGroup, {
|
|
496
|
+
"aria-label": "how git reaches your remote",
|
|
497
|
+
value: form.method,
|
|
498
|
+
onValueChange: (value) => update({ method: value }),
|
|
499
|
+
className: "grid grid-cols-1 gap-2 sm:grid-cols-3",
|
|
500
|
+
children: METHODS.map((choice) => /* @__PURE__ */ jsx(RadioGroupCard, {
|
|
501
|
+
value: choice.method,
|
|
502
|
+
"data-testid": `git-auth-method-${choice.method}`,
|
|
503
|
+
className: "p-3",
|
|
504
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
505
|
+
className: "flex flex-col gap-1",
|
|
506
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
507
|
+
className: "text-sm font-bold text-doom-hi",
|
|
508
|
+
children: choice.title
|
|
509
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
510
|
+
className: "text-2xs text-doom-dim",
|
|
511
|
+
children: choice.detail
|
|
512
|
+
})]
|
|
513
|
+
})
|
|
514
|
+
}, choice.method))
|
|
515
|
+
}),
|
|
516
|
+
form.method === "ssh" ? /* @__PURE__ */ jsxs("div", {
|
|
517
|
+
className: "flex flex-col gap-1.5 rounded-lg border border-doom-border bg-doom-panel p-3",
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ jsx(Label, {
|
|
520
|
+
htmlFor: "git-auth-key-path",
|
|
521
|
+
className: "text-xs text-doom-hi",
|
|
522
|
+
children: "key path"
|
|
523
|
+
}),
|
|
524
|
+
/* @__PURE__ */ jsx(Input, {
|
|
525
|
+
id: "git-auth-key-path",
|
|
526
|
+
"data-testid": "git-auth-key-path",
|
|
527
|
+
size: "sm",
|
|
528
|
+
value: form.keyPath,
|
|
529
|
+
placeholder: "~/.ssh/id_ed25519",
|
|
530
|
+
spellCheck: false,
|
|
531
|
+
onChange: (event) => update({ keyPath: event.target.value })
|
|
532
|
+
}),
|
|
533
|
+
/* @__PURE__ */ jsxs("p", {
|
|
534
|
+
className: "text-2xs text-doom-faint",
|
|
535
|
+
children: [
|
|
536
|
+
"Leave it blank to use your ssh config and ssh-agent. A key with a passphrase works only through ssh-agent. An unknown host is refused: run ",
|
|
537
|
+
/* @__PURE__ */ jsx("code", {
|
|
538
|
+
className: "text-doom-dim",
|
|
539
|
+
children: "ssh -T git@github.com"
|
|
540
|
+
}),
|
|
541
|
+
" once in a terminal to trust it."
|
|
542
|
+
]
|
|
543
|
+
})
|
|
544
|
+
]
|
|
545
|
+
}) : null,
|
|
546
|
+
form.method === "https" ? /* @__PURE__ */ jsxs("div", {
|
|
547
|
+
className: "grid grid-cols-1 gap-3 rounded-lg border border-doom-border bg-doom-panel p-3 sm:grid-cols-2",
|
|
548
|
+
children: [
|
|
549
|
+
/* @__PURE__ */ jsxs("div", {
|
|
550
|
+
className: "flex flex-col gap-1.5",
|
|
551
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
552
|
+
htmlFor: "git-auth-host",
|
|
553
|
+
className: "text-xs text-doom-hi",
|
|
554
|
+
children: "host"
|
|
555
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
556
|
+
id: "git-auth-host",
|
|
557
|
+
"data-testid": "git-auth-host",
|
|
558
|
+
size: "sm",
|
|
559
|
+
value: form.host,
|
|
560
|
+
spellCheck: false,
|
|
561
|
+
onChange: (event) => update({ host: event.target.value })
|
|
562
|
+
})]
|
|
563
|
+
}),
|
|
564
|
+
/* @__PURE__ */ jsxs("div", {
|
|
565
|
+
className: "flex flex-col gap-1.5",
|
|
566
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
567
|
+
htmlFor: "git-auth-username",
|
|
568
|
+
className: "text-xs text-doom-hi",
|
|
569
|
+
children: "username"
|
|
570
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
571
|
+
id: "git-auth-username",
|
|
572
|
+
"data-testid": "git-auth-username",
|
|
573
|
+
size: "sm",
|
|
574
|
+
value: form.username,
|
|
575
|
+
autoComplete: "username",
|
|
576
|
+
spellCheck: false,
|
|
577
|
+
onChange: (event) => update({ username: event.target.value })
|
|
578
|
+
})]
|
|
579
|
+
}),
|
|
580
|
+
/* @__PURE__ */ jsxs("div", {
|
|
581
|
+
className: "flex flex-col gap-1.5 sm:col-span-2",
|
|
582
|
+
children: [
|
|
583
|
+
/* @__PURE__ */ jsxs("span", {
|
|
584
|
+
className: "flex items-center gap-2",
|
|
585
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
586
|
+
htmlFor: "git-auth-token",
|
|
587
|
+
className: "text-xs text-doom-hi",
|
|
588
|
+
children: "token"
|
|
589
|
+
}), tokenSaved ? /* @__PURE__ */ jsx(StatusBadge, {
|
|
590
|
+
tone: "ok",
|
|
591
|
+
size: "xs",
|
|
592
|
+
"data-testid": "git-auth-token-saved",
|
|
593
|
+
children: "token saved"
|
|
594
|
+
}) : null]
|
|
595
|
+
}),
|
|
596
|
+
/* @__PURE__ */ jsx(Input, {
|
|
597
|
+
id: "git-auth-token",
|
|
598
|
+
"data-testid": "git-auth-token",
|
|
599
|
+
size: "sm",
|
|
600
|
+
type: "password",
|
|
601
|
+
value: form.token,
|
|
602
|
+
autoComplete: "new-password",
|
|
603
|
+
placeholder: tokenSaved ? "leave blank to keep the saved token" : "personal access token",
|
|
604
|
+
onChange: (event) => update({ token: event.target.value })
|
|
605
|
+
}),
|
|
606
|
+
/* @__PURE__ */ jsxs("p", {
|
|
607
|
+
className: "text-2xs text-doom-faint",
|
|
608
|
+
children: [
|
|
609
|
+
"Sent only to ",
|
|
610
|
+
form.host.trim() === "" ? "this host" : form.host.trim(),
|
|
611
|
+
". A remote on any other host keeps using this machine's own git credentials."
|
|
612
|
+
]
|
|
613
|
+
})
|
|
614
|
+
]
|
|
615
|
+
})
|
|
616
|
+
]
|
|
617
|
+
}) : null,
|
|
618
|
+
/* @__PURE__ */ jsxs("div", {
|
|
619
|
+
className: "flex flex-wrap items-center gap-2",
|
|
620
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
621
|
+
variant: "primary",
|
|
622
|
+
size: "sm",
|
|
623
|
+
"data-testid": "git-auth-save",
|
|
624
|
+
disabled: problem !== void 0 || saving,
|
|
625
|
+
loading: saving,
|
|
626
|
+
loadingLabel: "saving",
|
|
627
|
+
onClick: () => onSave(saveRequestOf(form)),
|
|
628
|
+
children: "save"
|
|
629
|
+
}), problem !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
630
|
+
"data-testid": "git-auth-problem",
|
|
631
|
+
className: "text-2xs text-doom-yellow",
|
|
632
|
+
children: problem
|
|
633
|
+
}) : saveError !== void 0 ? /* @__PURE__ */ jsxs("span", {
|
|
634
|
+
role: "alert",
|
|
635
|
+
"data-testid": "git-auth-error",
|
|
636
|
+
className: "flex items-center gap-1 text-2xs text-doom-red",
|
|
637
|
+
children: [/* @__PURE__ */ jsx(AlertIcon, {
|
|
638
|
+
"aria-hidden": true,
|
|
639
|
+
className: "h-3 w-3"
|
|
640
|
+
}), saveError]
|
|
641
|
+
}) : savedNotice ? /* @__PURE__ */ jsx("span", {
|
|
642
|
+
"data-testid": "git-auth-saved",
|
|
643
|
+
className: "text-2xs text-doom-green",
|
|
644
|
+
children: "saved"
|
|
645
|
+
}) : null]
|
|
646
|
+
}),
|
|
647
|
+
/* @__PURE__ */ jsxs("p", {
|
|
648
|
+
className: "flex items-start gap-1.5 text-2xs text-doom-faint",
|
|
649
|
+
children: [/* @__PURE__ */ jsx(ShieldIcon, {
|
|
650
|
+
"aria-hidden": true,
|
|
651
|
+
className: "mt-px h-3 w-3 shrink-0"
|
|
652
|
+
}), /* @__PURE__ */ jsx("span", { children: "Used only when you pull, push or rebase from this workspace's sessions in the cockpit, worktrees included. The agent's own git commands never see these credentials. Stored outside the repository in ~/.pi/.doom/git/credentials.json, readable only by you, and never in the system keychain." })]
|
|
653
|
+
})
|
|
654
|
+
]
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/extensions/workspaces/(frontend)/repository-settings-panel/_components/GitAuthPanel.tsx
|
|
659
|
+
/**
|
|
660
|
+
* A workspace's git remote panel: loads that workspace's saved auth and saves a
|
|
661
|
+
* new one. Lives under settings, in the repository section the host scopes.
|
|
662
|
+
*
|
|
663
|
+
* DESIGN PATTERNS:
|
|
664
|
+
* - Per workspace. The host hands the selected repository; its opaque id is
|
|
665
|
+
* the only thing sent, and the hub resolves it to an admitted root. A
|
|
666
|
+
* browser never names a path.
|
|
667
|
+
* - Reads through the host's sealed request and writes through its step-up
|
|
668
|
+
* request, so a remote device proves itself with a passkey before it can
|
|
669
|
+
* change credentials. The URLs come from the generated client.
|
|
670
|
+
* - After a save the form remounts from what the server returned, which is how
|
|
671
|
+
* the token field empties and the "token saved" badge appears.
|
|
672
|
+
*/
|
|
673
|
+
function isAuthView(value) {
|
|
674
|
+
return typeof value === "object" && value !== null && [
|
|
675
|
+
"none",
|
|
676
|
+
"ssh",
|
|
677
|
+
"https"
|
|
678
|
+
].includes(String(value.method));
|
|
679
|
+
}
|
|
680
|
+
function errorOf(body, status) {
|
|
681
|
+
return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : `The cockpit answered ${String(status)}.`;
|
|
682
|
+
}
|
|
683
|
+
function GitAuthPanel({ repository, request, requestWithStepUp }) {
|
|
684
|
+
const repositoryId = repository?.id;
|
|
685
|
+
const [loaded, setLoaded] = useState();
|
|
686
|
+
const [loadError, setLoadError] = useState();
|
|
687
|
+
const [saving, setSaving] = useState(false);
|
|
688
|
+
const [saveError, setSaveError] = useState();
|
|
689
|
+
const [savedNotice, setSavedNotice] = useState(false);
|
|
690
|
+
const [generation, setGeneration] = useState(0);
|
|
691
|
+
useEffect(() => {
|
|
692
|
+
if (repositoryId === void 0) return;
|
|
693
|
+
let stale = false;
|
|
694
|
+
request(api.workspace(repositoryId).auth.url({ query: { repositoryId } })).then(async (response) => {
|
|
695
|
+
const body = await response.json().catch(() => void 0);
|
|
696
|
+
if (stale) return;
|
|
697
|
+
if (response.ok && isAuthView(body)) setLoaded({
|
|
698
|
+
repositoryId,
|
|
699
|
+
saved: body
|
|
700
|
+
});
|
|
701
|
+
else setLoadError({
|
|
702
|
+
repositoryId,
|
|
703
|
+
error: errorOf(body, response.status)
|
|
704
|
+
});
|
|
705
|
+
}).catch(() => {
|
|
706
|
+
if (!stale) setLoadError({
|
|
707
|
+
repositoryId,
|
|
708
|
+
error: "The cockpit is unreachable."
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
return () => {
|
|
712
|
+
stale = true;
|
|
713
|
+
};
|
|
714
|
+
}, [repositoryId, request]);
|
|
715
|
+
if (repository === null || repositoryId === void 0) return /* @__PURE__ */ jsx(EmptyState, {
|
|
716
|
+
"data-testid": "git-auth-no-repository",
|
|
717
|
+
className: "py-6",
|
|
718
|
+
title: "pick a repository",
|
|
719
|
+
description: "git remote auth is set per workspace; choose one above."
|
|
720
|
+
});
|
|
721
|
+
const save = async (next) => {
|
|
722
|
+
setSaving(true);
|
|
723
|
+
setSaveError(void 0);
|
|
724
|
+
setSavedNotice(false);
|
|
725
|
+
try {
|
|
726
|
+
const response = await requestWithStepUp(api.workspace(repositoryId).saveAuth.url({ query: { repositoryId } }), {
|
|
727
|
+
method: "PUT",
|
|
728
|
+
headers: { "Content-Type": "application/json" },
|
|
729
|
+
body: JSON.stringify(next)
|
|
730
|
+
});
|
|
731
|
+
const body = await response.json().catch(() => void 0);
|
|
732
|
+
if (response.ok && isAuthView(body)) {
|
|
733
|
+
setLoaded({
|
|
734
|
+
repositoryId,
|
|
735
|
+
saved: body
|
|
736
|
+
});
|
|
737
|
+
setGeneration((current) => current + 1);
|
|
738
|
+
setSavedNotice(true);
|
|
739
|
+
} else setSaveError(errorOf(body, response.status));
|
|
740
|
+
} catch {
|
|
741
|
+
setSaveError("The cockpit is unreachable.");
|
|
742
|
+
} finally {
|
|
743
|
+
setSaving(false);
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
if (loadError?.repositoryId === repositoryId) return /* @__PURE__ */ jsx("p", {
|
|
747
|
+
role: "alert",
|
|
748
|
+
"data-testid": "git-auth-load-error",
|
|
749
|
+
className: "text-xs text-doom-red",
|
|
750
|
+
children: loadError.error
|
|
751
|
+
});
|
|
752
|
+
if (loaded?.repositoryId !== repositoryId) return /* @__PURE__ */ jsxs("span", {
|
|
753
|
+
"data-testid": "git-auth-loading",
|
|
754
|
+
className: "flex items-center gap-2",
|
|
755
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
756
|
+
className: "h-3 w-3 text-doom-faint",
|
|
757
|
+
label: "loading git settings"
|
|
758
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
759
|
+
className: "text-xs text-doom-dim",
|
|
760
|
+
children: "loading…"
|
|
761
|
+
})]
|
|
762
|
+
});
|
|
763
|
+
return /* @__PURE__ */ jsx(GitAuthForm, {
|
|
764
|
+
saved: loaded.saved,
|
|
765
|
+
saving,
|
|
766
|
+
savedNotice,
|
|
767
|
+
onSave: (next) => void save(next),
|
|
768
|
+
...saveError === void 0 ? {} : { saveError }
|
|
769
|
+
}, `${repositoryId}-${String(generation)}`);
|
|
770
|
+
}
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region src/extensions/workspaces/(frontend)/repository-settings-panel/git.web.tsx
|
|
773
|
+
var git_web_default$1 = defineRepositorySettingsPanel({
|
|
774
|
+
label: "git remote",
|
|
775
|
+
detail: "how this workspace's sessions reach the remote when you pull, push or rebase from the cockpit",
|
|
776
|
+
order: 50,
|
|
777
|
+
component: GitAuthPanel
|
|
778
|
+
});
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/types/gitReview.ts
|
|
781
|
+
/**
|
|
782
|
+
* The cockpit's view of what this session changed against its base: the counts
|
|
783
|
+
* the '# diff' group shows, what the review tab lists and draws, and the manual
|
|
784
|
+
* sync that sits beside them.
|
|
785
|
+
*
|
|
786
|
+
* DESIGN PATTERNS:
|
|
787
|
+
* - Declarations only, shared by the hub and the page.
|
|
788
|
+
* - Its own channel, apart from worktrees. Worktrees are repository
|
|
789
|
+
* management; the diff is this session's code change.
|
|
790
|
+
* - A diff row carries one line number whose file follows from its marker: the
|
|
791
|
+
* new file's for context and additions, the old file's for removals. It is
|
|
792
|
+
* the same shape the shared DiffView draws.
|
|
793
|
+
*
|
|
794
|
+
* AVOID:
|
|
795
|
+
* - Behaviour or node builtins. Browser code imports this file.
|
|
796
|
+
*/
|
|
797
|
+
/** The session channel carrying this checkout's changes and the sync around them. */
|
|
798
|
+
const GIT_CHANGES_TYPE = "git_changes";
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/gitChangesStore.ts
|
|
801
|
+
/**
|
|
802
|
+
* This session's code change against its base, and the manual sync beside it.
|
|
803
|
+
*
|
|
804
|
+
* DESIGN PATTERNS:
|
|
805
|
+
* - Its own session store and hub channel, apart from worktrees. Worktrees are
|
|
806
|
+
* repository management; this is the session's diff.
|
|
807
|
+
* - The hub is authoritative: it computes the counts, runs pull, push and
|
|
808
|
+
* rebase one at a time, and reports pending, errors and a paused rebase here.
|
|
809
|
+
* - The sender lives in a store rather than a module variable, because a web
|
|
810
|
+
* plugin keeps no mutable module state and the page may reconnect.
|
|
811
|
+
*
|
|
812
|
+
* AVOID:
|
|
813
|
+
* - `sendSessionFrame` for a sync command. That frame is bound for the agent
|
|
814
|
+
* and never reaches a channel's `receive`.
|
|
815
|
+
*/
|
|
816
|
+
const gitChanges = defineSessionStore({
|
|
817
|
+
changes: void 0,
|
|
818
|
+
pending: void 0,
|
|
819
|
+
error: void 0,
|
|
820
|
+
errorTarget: void 0
|
|
821
|
+
});
|
|
822
|
+
/** The page's hub socket sender; undefined before start and after dispose, when a command is dropped. */
|
|
823
|
+
const changesSender = defineGlobalStore(void 0);
|
|
824
|
+
/** Binds the page's hub socket for sync commands. The plugin host calls this once per page. */
|
|
825
|
+
function startGitChangesRuntime(runtime) {
|
|
826
|
+
const send = (frame) => {
|
|
827
|
+
runtime.sendHubFrame(frame);
|
|
828
|
+
};
|
|
829
|
+
changesSender.update(() => send);
|
|
830
|
+
return () => {
|
|
831
|
+
changesSender.update((current) => current === send ? void 0 : current);
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
/** Whether a sync command is running for this session. */
|
|
835
|
+
const gitChangesActivitySource = {
|
|
836
|
+
subscribe(listener) {
|
|
837
|
+
const subscription = gitChanges.store.subscribe(listener);
|
|
838
|
+
return () => subscription.unsubscribe();
|
|
839
|
+
},
|
|
840
|
+
isActive(sessionId) {
|
|
841
|
+
return gitChanges.select(gitChanges.store.state, sessionId).pending !== void 0;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
function isRecord$2(value) {
|
|
845
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
846
|
+
}
|
|
847
|
+
function optionalText$1(value) {
|
|
848
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
849
|
+
}
|
|
850
|
+
function count(value) {
|
|
851
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
852
|
+
}
|
|
853
|
+
/** The page never trusts a frame's shape: a malformed field drops, the rest still renders. */
|
|
854
|
+
const MAX_CONFLICTS = 100;
|
|
855
|
+
function optionalChanges(value) {
|
|
856
|
+
if (!isRecord$2(value)) return void 0;
|
|
857
|
+
const added = count(value.added);
|
|
858
|
+
const removed = count(value.removed);
|
|
859
|
+
const files = count(value.files);
|
|
860
|
+
if (added === void 0 || removed === void 0 || files === void 0) return void 0;
|
|
861
|
+
const branch = optionalText$1(value.branch);
|
|
862
|
+
const base = optionalText$1(value.base);
|
|
863
|
+
const upstream = isRecord$2(value.upstream) ? value.upstream : void 0;
|
|
864
|
+
const ahead = count(upstream?.ahead);
|
|
865
|
+
const behind = count(upstream?.behind);
|
|
866
|
+
const upstreamRef = optionalText$1(upstream?.ref);
|
|
867
|
+
const conflicts = isRecord$2(value.rebase) && Array.isArray(value.rebase.conflicts) ? value.rebase.conflicts.filter((file) => typeof file === "string").slice(0, MAX_CONFLICTS) : void 0;
|
|
868
|
+
return {
|
|
869
|
+
added,
|
|
870
|
+
removed,
|
|
871
|
+
files,
|
|
872
|
+
...branch === void 0 ? {} : { branch },
|
|
873
|
+
...base === void 0 ? {} : { base },
|
|
874
|
+
...value.truncated === true ? { truncated: true } : {},
|
|
875
|
+
...upstreamRef === void 0 || ahead === void 0 || behind === void 0 ? {} : { upstream: {
|
|
876
|
+
ref: upstreamRef,
|
|
877
|
+
ahead,
|
|
878
|
+
behind
|
|
879
|
+
} },
|
|
880
|
+
...conflicts === void 0 ? {} : { rebase: { conflicts } }
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function optionalErrorTarget$1(value) {
|
|
884
|
+
if (!isRecord$2(value)) return void 0;
|
|
885
|
+
if (value.action === "pull" || value.action === "rebase" || value.action === "abort-rebase") return { action: value.action };
|
|
886
|
+
if (value.action === "push") return value.forceRequired === true ? {
|
|
887
|
+
action: "push",
|
|
888
|
+
forceRequired: true
|
|
889
|
+
} : { action: "push" };
|
|
890
|
+
}
|
|
891
|
+
/** The session data channel: 'git_changes' payloads into the store. */
|
|
892
|
+
const gitChangesChannel = gitChanges.channel({
|
|
893
|
+
channel: GIT_CHANGES_TYPE,
|
|
894
|
+
parse(input) {
|
|
895
|
+
if (!isRecord$2(input)) return null;
|
|
896
|
+
return {
|
|
897
|
+
changes: optionalChanges(input.changes),
|
|
898
|
+
pending: optionalText$1(input.pending),
|
|
899
|
+
error: optionalText$1(input.error),
|
|
900
|
+
errorTarget: optionalErrorTarget$1(input.errorTarget)
|
|
901
|
+
};
|
|
902
|
+
},
|
|
903
|
+
reduce(_current, next) {
|
|
904
|
+
return next;
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
/**
|
|
908
|
+
* Asks the hub to pull, push, rebase or abort a paused rebase. `force` is only
|
|
909
|
+
* ever sent after the reader confirmed a lease force for a rejected push.
|
|
910
|
+
*/
|
|
911
|
+
function requestGitSync(sessionId, action, force = false) {
|
|
912
|
+
const payload = action === "push" && force ? {
|
|
913
|
+
action: "push",
|
|
914
|
+
force: true
|
|
915
|
+
} : { action };
|
|
916
|
+
changesSender.store.state?.({
|
|
917
|
+
type: GIT_CHANGES_TYPE,
|
|
918
|
+
sessionId,
|
|
919
|
+
payload
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewApi.ts
|
|
924
|
+
/**
|
|
925
|
+
* The review tab's half of the session API: the changed-file list and one
|
|
926
|
+
* file's hunks.
|
|
927
|
+
*
|
|
928
|
+
* The generated client owns the URL and the sealed transport, so nothing here
|
|
929
|
+
* spells a route or reaches for `fetch`. What travels is file contents, which a
|
|
930
|
+
* tunnel's relay must never see in the clear.
|
|
931
|
+
*/
|
|
932
|
+
const UNREACHABLE = "The session is unreachable.";
|
|
933
|
+
function isRecord$1(value) {
|
|
934
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
935
|
+
}
|
|
936
|
+
/** The message a reader is shown: the route's own words, or why there were none. */
|
|
937
|
+
function messageOf(result) {
|
|
938
|
+
if (result.status === 0) return UNREACHABLE;
|
|
939
|
+
return result.error === "" ? `The session answered ${String(result.status)}.` : result.error;
|
|
940
|
+
}
|
|
941
|
+
async function fetchReviewSummary(sessionId, signal) {
|
|
942
|
+
const result = await api.session(sessionId).review(signal === void 0 ? {} : { signal });
|
|
943
|
+
if (!result.ok) return {
|
|
944
|
+
ok: false,
|
|
945
|
+
error: messageOf(result)
|
|
946
|
+
};
|
|
947
|
+
if (!isRecord$1(result.data) || !Array.isArray(result.data.files)) return {
|
|
948
|
+
ok: false,
|
|
949
|
+
error: "The session answered with no file list."
|
|
950
|
+
};
|
|
951
|
+
return {
|
|
952
|
+
ok: true,
|
|
953
|
+
summary: result.data
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
async function fetchReviewFile(sessionId, path, signal) {
|
|
957
|
+
const result = await api.session(sessionId).reviewFile({
|
|
958
|
+
query: { path },
|
|
959
|
+
...signal === void 0 ? {} : { signal }
|
|
960
|
+
});
|
|
961
|
+
if (!result.ok) return {
|
|
962
|
+
ok: false,
|
|
963
|
+
error: messageOf(result)
|
|
964
|
+
};
|
|
965
|
+
if (!isRecord$1(result.data) || !Array.isArray(result.data.hunks)) return {
|
|
966
|
+
ok: false,
|
|
967
|
+
error: "The session answered with no diff."
|
|
968
|
+
};
|
|
969
|
+
return {
|
|
970
|
+
ok: true,
|
|
971
|
+
diff: result.data
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewStore.ts
|
|
976
|
+
const gitReview = defineSessionStore({ comments: [] });
|
|
977
|
+
function addReviewComment(sessionId, comment) {
|
|
978
|
+
const id = globalThis.crypto.randomUUID();
|
|
979
|
+
gitReview.update(sessionId, (current) => ({ comments: [...current.comments, {
|
|
980
|
+
...comment,
|
|
981
|
+
id
|
|
982
|
+
}] }));
|
|
983
|
+
}
|
|
984
|
+
function removeReviewComment(sessionId, id) {
|
|
985
|
+
gitReview.update(sessionId, (current) => ({ comments: current.comments.filter((comment) => comment.id !== id) }));
|
|
986
|
+
}
|
|
987
|
+
function clearReviewComments(sessionId) {
|
|
988
|
+
gitReview.update(sessionId, () => ({ comments: [] }));
|
|
989
|
+
}
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewView.ts
|
|
992
|
+
/**
|
|
993
|
+
* Pure wording for what the review tab sends the agent, and the one send.
|
|
994
|
+
*
|
|
995
|
+
* Both messages go as `enqueue_automatic`: the host stores it and starts a turn
|
|
996
|
+
* at once when the agent is idle, or after the current one. A `prompt` frame
|
|
997
|
+
* instead fails while a turn runs, and a review lost to that is the worst kind
|
|
998
|
+
* of lost work.
|
|
999
|
+
*/
|
|
1000
|
+
/** The opening line of a review, naming what was reviewed. */
|
|
1001
|
+
function reviewHeading(count, branch, base) {
|
|
1002
|
+
return `I reviewed ${branch === void 0 ? "this checkout" : `branch ${branch}`} (${base === void 0 ? "its uncommitted changes" : `its changes against ${base}`}) and left ${count === 1 ? "one review comment" : `${String(count)} review comments`}. ${count === 1 ? "Please address it." : "Please address them all."}`;
|
|
1003
|
+
}
|
|
1004
|
+
/** What "ask agent to resolve" sends: the files, and the steps that finish a paused rebase. */
|
|
1005
|
+
function conflictPrompt(branch, conflicts) {
|
|
1006
|
+
const files = conflicts.length === 0 ? "- (git reports no unmerged paths yet)" : conflicts.map((file) => `- ${file}`).join("\n");
|
|
1007
|
+
return [
|
|
1008
|
+
`A rebase of ${branch ?? "this checkout"} stopped on conflicts in:`,
|
|
1009
|
+
"",
|
|
1010
|
+
files,
|
|
1011
|
+
"",
|
|
1012
|
+
"Please resolve them:",
|
|
1013
|
+
"1. Fix the conflict markers in each file, keeping the intent of both sides.",
|
|
1014
|
+
"2. `git add` each resolved file.",
|
|
1015
|
+
"3. Run `GIT_EDITOR=true git rebase --continue`, and repeat if it stops again.",
|
|
1016
|
+
"",
|
|
1017
|
+
"Do not push. I will push from the cockpit once the rebase is done."
|
|
1018
|
+
].join("\n");
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Hands one message to the session's queue. Returns the reason it failed, or
|
|
1022
|
+
* undefined once the host took it. The sender throws when the session is not
|
|
1023
|
+
* connected, which is the only failure a caller can still act on.
|
|
1024
|
+
*/
|
|
1025
|
+
function deliverToAgent(send, sessionId, message) {
|
|
1026
|
+
try {
|
|
1027
|
+
send(sessionId, {
|
|
1028
|
+
type: "enqueue_automatic",
|
|
1029
|
+
message
|
|
1030
|
+
});
|
|
1031
|
+
return;
|
|
1032
|
+
} catch (error) {
|
|
1033
|
+
return error instanceof Error ? error.message : "The session did not take the message.";
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewTree.ts
|
|
1038
|
+
function buildTree(files) {
|
|
1039
|
+
const root = {
|
|
1040
|
+
path: "",
|
|
1041
|
+
dirs: /* @__PURE__ */ new Map(),
|
|
1042
|
+
files: []
|
|
1043
|
+
};
|
|
1044
|
+
for (const file of files) {
|
|
1045
|
+
const parts = file.path.split("/");
|
|
1046
|
+
parts.pop();
|
|
1047
|
+
let dir = root;
|
|
1048
|
+
for (const part of parts) {
|
|
1049
|
+
let next = dir.dirs.get(part);
|
|
1050
|
+
if (next === void 0) {
|
|
1051
|
+
next = {
|
|
1052
|
+
path: dir.path === "" ? part : `${dir.path}/${part}`,
|
|
1053
|
+
dirs: /* @__PURE__ */ new Map(),
|
|
1054
|
+
files: []
|
|
1055
|
+
};
|
|
1056
|
+
dir.dirs.set(part, next);
|
|
1057
|
+
}
|
|
1058
|
+
dir = next;
|
|
1059
|
+
}
|
|
1060
|
+
dir.files.push(file);
|
|
1061
|
+
}
|
|
1062
|
+
return root;
|
|
1063
|
+
}
|
|
1064
|
+
/** Folders first, then files, each alphabetical; single-child folder chains render as one row. */
|
|
1065
|
+
function flattenTree(files, isOpen) {
|
|
1066
|
+
const rows = [];
|
|
1067
|
+
const walk = (dir, depth) => {
|
|
1068
|
+
for (const [segment, child] of [...dir.dirs].sort(([left], [right]) => left.localeCompare(right))) {
|
|
1069
|
+
let name = segment;
|
|
1070
|
+
let node = child;
|
|
1071
|
+
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
1072
|
+
const [[nextName, next]] = [...node.dirs];
|
|
1073
|
+
name = `${name}/${nextName}`;
|
|
1074
|
+
node = next;
|
|
1075
|
+
}
|
|
1076
|
+
const open = isOpen(node.path);
|
|
1077
|
+
rows.push({
|
|
1078
|
+
kind: "dir",
|
|
1079
|
+
path: node.path,
|
|
1080
|
+
name,
|
|
1081
|
+
depth,
|
|
1082
|
+
open
|
|
1083
|
+
});
|
|
1084
|
+
if (open) walk(node, depth + 1);
|
|
1085
|
+
}
|
|
1086
|
+
for (const file of [...dir.files].sort((left, right) => left.path.localeCompare(right.path))) rows.push({
|
|
1087
|
+
kind: "file",
|
|
1088
|
+
file,
|
|
1089
|
+
depth
|
|
1090
|
+
});
|
|
1091
|
+
};
|
|
1092
|
+
walk(buildTree(files), 0);
|
|
1093
|
+
return rows;
|
|
1094
|
+
}
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewBrowser.tsx
|
|
1097
|
+
/**
|
|
1098
|
+
* The review tab's file list: every changed file as a folder tree (the VS Code
|
|
1099
|
+
* explorer shape), with its status, its line counts and its comments.
|
|
1100
|
+
*
|
|
1101
|
+
* DESIGN PATTERNS:
|
|
1102
|
+
* - Picking a row scrolls the diff pane to that file; the list never opens a
|
|
1103
|
+
* tab of its own. One tab holds the whole review.
|
|
1104
|
+
* - Rows show only the file name, so a long path never truncates away the part
|
|
1105
|
+
* that tells files apart. Folders say the rest; the full path is the tooltip.
|
|
1106
|
+
* - Folder chains with a single child collapse into one row (`src/web/lib`),
|
|
1107
|
+
* like VS Code's compact folders, so deep trees stay shallow.
|
|
1108
|
+
* - Folders fold on click; a search shows every match with its folders open.
|
|
1109
|
+
* - Each row is a button, reachable with Tab; arrow keys move and pick in one
|
|
1110
|
+
* step across the visible files, so the diff follows the cursor.
|
|
1111
|
+
*
|
|
1112
|
+
* AVOID:
|
|
1113
|
+
* - Colour classes outside the token set.
|
|
1114
|
+
*/
|
|
1115
|
+
const STATUS_MARK = {
|
|
1116
|
+
added: {
|
|
1117
|
+
letter: "A",
|
|
1118
|
+
tone: "text-doom-green",
|
|
1119
|
+
label: "added"
|
|
1120
|
+
},
|
|
1121
|
+
modified: {
|
|
1122
|
+
letter: "M",
|
|
1123
|
+
tone: "text-doom-yellow",
|
|
1124
|
+
label: "modified"
|
|
1125
|
+
},
|
|
1126
|
+
deleted: {
|
|
1127
|
+
letter: "D",
|
|
1128
|
+
tone: "text-doom-red",
|
|
1129
|
+
label: "deleted"
|
|
1130
|
+
},
|
|
1131
|
+
untracked: {
|
|
1132
|
+
letter: "U",
|
|
1133
|
+
tone: "text-doom-blue",
|
|
1134
|
+
label: "untracked"
|
|
1135
|
+
},
|
|
1136
|
+
conflicted: {
|
|
1137
|
+
letter: "C",
|
|
1138
|
+
tone: "text-doom-red",
|
|
1139
|
+
label: "conflicted"
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
const baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
|
|
1143
|
+
/** Left padding per depth level; tight so deep files keep room for their names. */
|
|
1144
|
+
const indent = (depth) => ({ paddingLeft: `${String(.75 + depth * .5)}rem` });
|
|
1145
|
+
function GitReviewBrowser({ files, activePath, commentCounts, onPick }) {
|
|
1146
|
+
const [query, setQuery] = useState("");
|
|
1147
|
+
const [collapsed, setCollapsed] = useState(/* @__PURE__ */ new Set());
|
|
1148
|
+
const needle = query.trim().toLocaleLowerCase();
|
|
1149
|
+
const shown = needle === "" ? files : files.filter((file) => file.path.toLocaleLowerCase().includes(needle));
|
|
1150
|
+
const rows = flattenTree(shown, (dirPath) => needle !== "" || !collapsed.has(dirPath));
|
|
1151
|
+
const ordered = rows.flatMap((row) => row.kind === "file" ? [row.file] : []);
|
|
1152
|
+
const listRef = useRef(null);
|
|
1153
|
+
useEffect(() => {
|
|
1154
|
+
if (activePath === void 0) return;
|
|
1155
|
+
(listRef.current?.querySelector(`[data-path="${CSS.escape(activePath)}"]`))?.scrollIntoView({ block: "nearest" });
|
|
1156
|
+
}, [activePath]);
|
|
1157
|
+
const toggle = (dirPath) => {
|
|
1158
|
+
setCollapsed((prev) => {
|
|
1159
|
+
const next = new Set(prev);
|
|
1160
|
+
if (!next.delete(dirPath)) next.add(dirPath);
|
|
1161
|
+
return next;
|
|
1162
|
+
});
|
|
1163
|
+
};
|
|
1164
|
+
const allDirs = () => new Set(flattenTree(files, () => true).flatMap((row) => row.kind === "dir" ? [row.path] : []));
|
|
1165
|
+
/** Arrow keys pick the neighbouring row and move focus with it, so the diff follows the cursor. */
|
|
1166
|
+
const onKeyDown = (event) => {
|
|
1167
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
1168
|
+
if (ordered.length === 0) return;
|
|
1169
|
+
event.preventDefault();
|
|
1170
|
+
const current = ordered.findIndex((file) => file.path === activePath);
|
|
1171
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
1172
|
+
const next = current === -1 ? 0 : (current + step + ordered.length) % ordered.length;
|
|
1173
|
+
const file = ordered[next];
|
|
1174
|
+
if (file === void 0) return;
|
|
1175
|
+
onPick(file.path);
|
|
1176
|
+
event.currentTarget.closest("[data-git-review-list]")?.querySelectorAll("[data-git-review-row]")[next]?.focus();
|
|
1177
|
+
};
|
|
1178
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
1179
|
+
"data-testid": "git-review-browser",
|
|
1180
|
+
"aria-label": "changed files",
|
|
1181
|
+
className: "flex min-h-0 w-64 shrink-0 flex-col border-r border-doom-border-soft",
|
|
1182
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1183
|
+
className: "flex shrink-0 flex-col gap-1 px-3 pt-2.5 pb-1.5",
|
|
1184
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
1185
|
+
"data-testid": "git-review-search",
|
|
1186
|
+
"aria-label": "search changed file paths",
|
|
1187
|
+
size: "sm",
|
|
1188
|
+
value: query,
|
|
1189
|
+
placeholder: "search paths…",
|
|
1190
|
+
onChange: (event) => setQuery(event.target.value)
|
|
1191
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1192
|
+
className: "flex items-center justify-between gap-2",
|
|
1193
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1194
|
+
className: "text-2xs text-doom-faint",
|
|
1195
|
+
children: needle === "" ? `${String(files.length)} changed` : `${String(shown.length)} of ${String(files.length)} match`
|
|
1196
|
+
}), needle === "" ? /* @__PURE__ */ jsx(Button, {
|
|
1197
|
+
variant: "link",
|
|
1198
|
+
size: "xs",
|
|
1199
|
+
"data-testid": "git-review-fold-all",
|
|
1200
|
+
className: "h-auto px-0",
|
|
1201
|
+
onClick: () => setCollapsed(collapsed.size === 0 ? allDirs() : /* @__PURE__ */ new Set()),
|
|
1202
|
+
children: collapsed.size === 0 ? "collapse all" : "expand all"
|
|
1203
|
+
}) : null]
|
|
1204
|
+
})]
|
|
1205
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1206
|
+
ref: listRef,
|
|
1207
|
+
"data-git-review-list": true,
|
|
1208
|
+
className: "min-h-0 flex-1 overflow-y-auto pb-2",
|
|
1209
|
+
children: [rows.map((row) => {
|
|
1210
|
+
if (row.kind === "dir") {
|
|
1211
|
+
const Chevron = row.open ? ChevronDownIcon : ChevronRightIcon;
|
|
1212
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
1213
|
+
variant: "ghost",
|
|
1214
|
+
size: "card",
|
|
1215
|
+
"aria-expanded": row.open,
|
|
1216
|
+
"data-testid": `git-review-browser-dir-${row.path}`,
|
|
1217
|
+
title: row.path,
|
|
1218
|
+
onClick: () => toggle(row.path),
|
|
1219
|
+
style: indent(row.depth),
|
|
1220
|
+
className: "min-w-0 flex-row items-center gap-1 rounded-none border-l-2 border-transparent py-1 pr-3 hover:bg-doom-panel/60",
|
|
1221
|
+
children: [/* @__PURE__ */ jsx(Chevron, {
|
|
1222
|
+
"aria-hidden": true,
|
|
1223
|
+
className: "h-3 w-3 shrink-0 text-doom-faint"
|
|
1224
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1225
|
+
className: "min-w-0 flex-1 truncate text-xs text-doom-dim",
|
|
1226
|
+
children: row.name
|
|
1227
|
+
})]
|
|
1228
|
+
}, `dir:${row.path}`);
|
|
1229
|
+
}
|
|
1230
|
+
const { file } = row;
|
|
1231
|
+
const mark = STATUS_MARK[file.status];
|
|
1232
|
+
const comments = commentCounts[file.path] ?? 0;
|
|
1233
|
+
const active = file.path === activePath;
|
|
1234
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
1235
|
+
variant: "ghost",
|
|
1236
|
+
size: "card",
|
|
1237
|
+
"data-git-review-row": true,
|
|
1238
|
+
"data-path": file.path,
|
|
1239
|
+
"aria-current": active ? "true" : void 0,
|
|
1240
|
+
"data-testid": `git-review-browser-file-${file.path}`,
|
|
1241
|
+
title: `${file.path} (${mark.label})`,
|
|
1242
|
+
onClick: () => onPick(file.path),
|
|
1243
|
+
onKeyDown,
|
|
1244
|
+
style: indent(row.depth),
|
|
1245
|
+
className: `min-w-0 flex-row items-center gap-1.5 rounded-none border-l-2 py-1 pr-3 ${active ? "border-doom-blue bg-doom-panel" : "border-transparent hover:bg-doom-panel/60"}`,
|
|
1246
|
+
children: [
|
|
1247
|
+
/* @__PURE__ */ jsx("span", {
|
|
1248
|
+
"aria-label": mark.label,
|
|
1249
|
+
className: `w-3 shrink-0 text-center text-2xs font-bold ${mark.tone}`,
|
|
1250
|
+
children: mark.letter
|
|
1251
|
+
}),
|
|
1252
|
+
/* @__PURE__ */ jsx("span", {
|
|
1253
|
+
className: `min-w-0 flex-1 truncate text-xs text-doom-hi ${active ? "font-bold" : ""} ${file.status === "deleted" ? "line-through opacity-70" : ""}`,
|
|
1254
|
+
children: baseName(file.path)
|
|
1255
|
+
}),
|
|
1256
|
+
comments === 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
1257
|
+
className: "flex shrink-0 items-center gap-0.5 text-2xs text-doom-blue",
|
|
1258
|
+
title: `${String(comments)} comments`,
|
|
1259
|
+
children: [/* @__PURE__ */ jsx(MessageIcon, {
|
|
1260
|
+
"aria-hidden": true,
|
|
1261
|
+
className: "h-2.5 w-2.5"
|
|
1262
|
+
}), comments]
|
|
1263
|
+
}),
|
|
1264
|
+
file.binary ? /* @__PURE__ */ jsx("span", {
|
|
1265
|
+
className: "shrink-0 text-2xs text-doom-faint",
|
|
1266
|
+
children: "binary"
|
|
1267
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
1268
|
+
className: "shrink-0 text-2xs",
|
|
1269
|
+
children: [
|
|
1270
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1271
|
+
className: "text-doom-green",
|
|
1272
|
+
children: ["+", file.added]
|
|
1273
|
+
}),
|
|
1274
|
+
" ",
|
|
1275
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1276
|
+
className: "text-doom-red",
|
|
1277
|
+
children: ["-", file.removed]
|
|
1278
|
+
})
|
|
1279
|
+
]
|
|
1280
|
+
})
|
|
1281
|
+
]
|
|
1282
|
+
}, file.path);
|
|
1283
|
+
}), ordered.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1284
|
+
className: "px-3 py-2 text-2xs text-doom-faint",
|
|
1285
|
+
children: "no path matches"
|
|
1286
|
+
}) : null]
|
|
1287
|
+
})]
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
//#endregion
|
|
1291
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_components/GitSyncBar.tsx
|
|
1292
|
+
/**
|
|
1293
|
+
* The review tab's header: what is being reviewed, and the manual sync that
|
|
1294
|
+
* goes with it.
|
|
1295
|
+
*
|
|
1296
|
+
* DESIGN PATTERNS:
|
|
1297
|
+
* - Everything here is a report or a request. The hub runs the git, one
|
|
1298
|
+
* command per session, and answers on the channel: pending while it runs,
|
|
1299
|
+
* an error target when it fails, a paused rebase when it stops on conflicts.
|
|
1300
|
+
* - A push the remote rejects is not an error to shrug at: the strip asks
|
|
1301
|
+
* before forcing, and the force it sends is a lease, which git refuses if
|
|
1302
|
+
* the remote holds commits this branch never fetched and integrated.
|
|
1303
|
+
* - A paused rebase blocks the sync buttons. The two ways out are named on the
|
|
1304
|
+
* banner, and abort says what it throws away.
|
|
1305
|
+
*
|
|
1306
|
+
* AVOID:
|
|
1307
|
+
* - Colour classes outside the token set.
|
|
1308
|
+
*/
|
|
1309
|
+
function GitSyncBar({ changes, mergeBase, pending, error, errorTarget, onSync, onForcePush, onAskAgent, onDismissError }) {
|
|
1310
|
+
const busy = pending !== void 0;
|
|
1311
|
+
const paused = changes?.rebase !== void 0;
|
|
1312
|
+
const forceRequired = errorTarget?.action === "push" && "forceRequired" in errorTarget && errorTarget.forceRequired === true;
|
|
1313
|
+
const syncError = error !== void 0 && !forceRequired ? error : void 0;
|
|
1314
|
+
const upstream = changes?.upstream;
|
|
1315
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1316
|
+
"data-testid": "git-sync-bar",
|
|
1317
|
+
className: "flex shrink-0 flex-col gap-2 border-b border-doom-border-soft px-3 py-2.5 sm:px-[26px]",
|
|
1318
|
+
children: [
|
|
1319
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1320
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5",
|
|
1321
|
+
children: [
|
|
1322
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1323
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
1324
|
+
children: [
|
|
1325
|
+
/* @__PURE__ */ jsx(BranchIcon, {
|
|
1326
|
+
"aria-hidden": true,
|
|
1327
|
+
className: "h-3.5 w-3.5 shrink-0 text-doom-faint"
|
|
1328
|
+
}),
|
|
1329
|
+
/* @__PURE__ */ jsx("span", {
|
|
1330
|
+
"data-testid": "git-review-branch",
|
|
1331
|
+
className: "truncate text-sm font-bold text-doom-hi",
|
|
1332
|
+
children: changes?.branch ?? "detached HEAD"
|
|
1333
|
+
}),
|
|
1334
|
+
/* @__PURE__ */ jsx("span", {
|
|
1335
|
+
className: "shrink-0 text-xs text-doom-faint",
|
|
1336
|
+
children: changes?.base === void 0 ? "uncommitted changes" : `vs ${changes.base}`
|
|
1337
|
+
}),
|
|
1338
|
+
mergeBase === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
1339
|
+
className: "shrink-0 text-2xs text-doom-faint",
|
|
1340
|
+
children: ["from ", mergeBase]
|
|
1341
|
+
})
|
|
1342
|
+
]
|
|
1343
|
+
}),
|
|
1344
|
+
changes === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
1345
|
+
"data-testid": "git-review-totals",
|
|
1346
|
+
className: "flex shrink-0 items-center gap-1.5 text-xs",
|
|
1347
|
+
children: [
|
|
1348
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1349
|
+
className: "font-bold text-doom-green",
|
|
1350
|
+
children: ["+", changes.added]
|
|
1351
|
+
}),
|
|
1352
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1353
|
+
className: "font-bold text-doom-red",
|
|
1354
|
+
children: ["-", changes.removed]
|
|
1355
|
+
}),
|
|
1356
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1357
|
+
className: "text-doom-faint",
|
|
1358
|
+
children: [
|
|
1359
|
+
changes.files,
|
|
1360
|
+
changes.truncated ? "+" : "",
|
|
1361
|
+
" ",
|
|
1362
|
+
changes.files === 1 ? "file" : "files"
|
|
1363
|
+
]
|
|
1364
|
+
})
|
|
1365
|
+
]
|
|
1366
|
+
}),
|
|
1367
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
|
|
1368
|
+
upstream === void 0 ? /* @__PURE__ */ jsx("span", {
|
|
1369
|
+
className: "shrink-0 text-2xs text-doom-faint",
|
|
1370
|
+
children: "no upstream yet"
|
|
1371
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
1372
|
+
className: "shrink-0 text-2xs text-doom-faint",
|
|
1373
|
+
title: upstream.ref,
|
|
1374
|
+
children: [
|
|
1375
|
+
"↑",
|
|
1376
|
+
upstream.ahead,
|
|
1377
|
+
" ↓",
|
|
1378
|
+
upstream.behind,
|
|
1379
|
+
" ",
|
|
1380
|
+
upstream.ref
|
|
1381
|
+
]
|
|
1382
|
+
}),
|
|
1383
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1384
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
1385
|
+
children: [
|
|
1386
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1387
|
+
size: "xs",
|
|
1388
|
+
"data-testid": "git-sync-pull",
|
|
1389
|
+
disabled: busy || paused || upstream === void 0,
|
|
1390
|
+
title: upstream === void 0 ? "push once to set an upstream" : `fetch, then rebase onto ${upstream.ref}`,
|
|
1391
|
+
onClick: () => onSync("pull"),
|
|
1392
|
+
children: "pull"
|
|
1393
|
+
}),
|
|
1394
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1395
|
+
size: "xs",
|
|
1396
|
+
"data-testid": "git-sync-push",
|
|
1397
|
+
disabled: busy || paused || changes?.branch === void 0,
|
|
1398
|
+
title: upstream === void 0 ? "push and set the upstream" : `push to ${upstream.ref}`,
|
|
1399
|
+
onClick: () => onSync("push"),
|
|
1400
|
+
children: "push"
|
|
1401
|
+
}),
|
|
1402
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1403
|
+
size: "xs",
|
|
1404
|
+
"data-testid": "git-sync-rebase",
|
|
1405
|
+
disabled: busy || paused || changes?.base === void 0,
|
|
1406
|
+
title: changes?.base === void 0 ? "no base branch to rebase onto" : `fetch, then rebase onto ${changes.base}`,
|
|
1407
|
+
onClick: () => onSync("rebase"),
|
|
1408
|
+
children: "rebase"
|
|
1409
|
+
})
|
|
1410
|
+
]
|
|
1411
|
+
})
|
|
1412
|
+
]
|
|
1413
|
+
}),
|
|
1414
|
+
pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
1415
|
+
"data-testid": "git-sync-pending",
|
|
1416
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
1417
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
1418
|
+
className: "h-3 w-3 shrink-0 text-doom-faint",
|
|
1419
|
+
label: pending
|
|
1420
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1421
|
+
className: "min-w-0 truncate text-xs text-doom-dim",
|
|
1422
|
+
children: pending
|
|
1423
|
+
})]
|
|
1424
|
+
}),
|
|
1425
|
+
syncError === void 0 ? null : /* @__PURE__ */ jsxs("div", {
|
|
1426
|
+
role: "alert",
|
|
1427
|
+
"data-testid": "git-sync-error",
|
|
1428
|
+
className: "flex min-w-0 items-start gap-1.5 text-2xs text-doom-red",
|
|
1429
|
+
children: [
|
|
1430
|
+
/* @__PURE__ */ jsx(AlertIcon, {
|
|
1431
|
+
"aria-hidden": true,
|
|
1432
|
+
className: "mt-px h-3 w-3 shrink-0"
|
|
1433
|
+
}),
|
|
1434
|
+
/* @__PURE__ */ jsx("span", {
|
|
1435
|
+
className: "min-w-0 flex-1",
|
|
1436
|
+
children: syncError
|
|
1437
|
+
}),
|
|
1438
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1439
|
+
variant: "ghost",
|
|
1440
|
+
size: "xs",
|
|
1441
|
+
className: "h-auto min-h-0 px-1 py-0 text-2xs",
|
|
1442
|
+
onClick: onDismissError,
|
|
1443
|
+
children: "dismiss"
|
|
1444
|
+
})
|
|
1445
|
+
]
|
|
1446
|
+
}),
|
|
1447
|
+
forceRequired ? /* @__PURE__ */ jsxs("div", {
|
|
1448
|
+
"data-testid": "git-push-force-confirm",
|
|
1449
|
+
className: "flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-doom-edge-yellow bg-doom-tint-yellow px-2.5 py-2",
|
|
1450
|
+
children: [
|
|
1451
|
+
/* @__PURE__ */ jsx("span", {
|
|
1452
|
+
className: "min-w-0 flex-1 text-xs text-doom-hi",
|
|
1453
|
+
children: "The remote branch has commits yours replaced, usually after a rebase. Force push with lease? It is refused if the remote holds commits you never fetched and integrated."
|
|
1454
|
+
}),
|
|
1455
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1456
|
+
variant: "danger-outline",
|
|
1457
|
+
size: "xs",
|
|
1458
|
+
"data-testid": "git-push-force",
|
|
1459
|
+
disabled: busy,
|
|
1460
|
+
onClick: onForcePush,
|
|
1461
|
+
children: "force push"
|
|
1462
|
+
}),
|
|
1463
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1464
|
+
variant: "ghost",
|
|
1465
|
+
size: "xs",
|
|
1466
|
+
"data-testid": "git-push-force-cancel",
|
|
1467
|
+
onClick: onDismissError,
|
|
1468
|
+
children: "cancel"
|
|
1469
|
+
})
|
|
1470
|
+
]
|
|
1471
|
+
}) : null,
|
|
1472
|
+
changes?.rebase === void 0 ? null : /* @__PURE__ */ jsxs("div", {
|
|
1473
|
+
"data-testid": "git-rebase-banner",
|
|
1474
|
+
className: "flex min-w-0 flex-col gap-1.5 rounded-md border border-doom-edge-red bg-doom-tint-red px-2.5 py-2",
|
|
1475
|
+
children: [
|
|
1476
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1477
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
1478
|
+
children: [/* @__PURE__ */ jsx(StatusBadge, {
|
|
1479
|
+
tone: "error",
|
|
1480
|
+
size: "xs",
|
|
1481
|
+
children: "rebase paused"
|
|
1482
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1483
|
+
className: "text-xs text-doom-hi",
|
|
1484
|
+
children: changes.rebase.conflicts.length === 0 ? "git stopped the rebase" : `conflicts in ${String(changes.rebase.conflicts.length)} ${changes.rebase.conflicts.length === 1 ? "file" : "files"}`
|
|
1485
|
+
})]
|
|
1486
|
+
}),
|
|
1487
|
+
changes.rebase.conflicts.length === 0 ? null : /* @__PURE__ */ jsx("ul", {
|
|
1488
|
+
className: "flex flex-col gap-0.5 pl-1",
|
|
1489
|
+
children: changes.rebase.conflicts.map((file) => /* @__PURE__ */ jsx("li", {
|
|
1490
|
+
className: "truncate font-mono text-2xs text-doom-dim",
|
|
1491
|
+
children: file
|
|
1492
|
+
}, file))
|
|
1493
|
+
}),
|
|
1494
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1495
|
+
className: "flex flex-wrap items-center gap-1.5",
|
|
1496
|
+
children: [
|
|
1497
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1498
|
+
variant: "primary",
|
|
1499
|
+
size: "xs",
|
|
1500
|
+
"data-testid": "git-rebase-ask-agent",
|
|
1501
|
+
disabled: busy,
|
|
1502
|
+
onClick: onAskAgent,
|
|
1503
|
+
children: "ask agent to resolve"
|
|
1504
|
+
}),
|
|
1505
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1506
|
+
variant: "danger-outline",
|
|
1507
|
+
size: "xs",
|
|
1508
|
+
"data-testid": "git-rebase-abort",
|
|
1509
|
+
disabled: busy,
|
|
1510
|
+
onClick: () => onSync("abort-rebase"),
|
|
1511
|
+
children: "abort rebase"
|
|
1512
|
+
}),
|
|
1513
|
+
/* @__PURE__ */ jsx("span", {
|
|
1514
|
+
className: "text-2xs text-doom-faint",
|
|
1515
|
+
children: "abort discards any conflict resolution in progress"
|
|
1516
|
+
})
|
|
1517
|
+
]
|
|
1518
|
+
})
|
|
1519
|
+
]
|
|
1520
|
+
})
|
|
1521
|
+
]
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
const NO_FILES = [];
|
|
1525
|
+
/** Stable, URL-safe element id for one file's section. */
|
|
1526
|
+
function sectionId(index) {
|
|
1527
|
+
return `git-review-file-${String(index)}`;
|
|
1528
|
+
}
|
|
1529
|
+
function sideOf(row) {
|
|
1530
|
+
return row.marker === "-" ? "old" : "new";
|
|
1531
|
+
}
|
|
1532
|
+
function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddComment, onRemoveComment, onSendReview, onDiscard, sendError, initialDraft }) {
|
|
1533
|
+
const entries = summary.state === "ready" ? summary.summary.files : NO_FILES;
|
|
1534
|
+
const [openOverride, setOpenOverride] = useState({});
|
|
1535
|
+
const [picked, setPicked] = useState();
|
|
1536
|
+
const activePath = picked ?? entries[0]?.path;
|
|
1537
|
+
const [draft, setDraft] = useState(initialDraft);
|
|
1538
|
+
useEffect(() => {
|
|
1539
|
+
for (const file of entries.slice(0, 20)) if (files[file.path] === void 0) onLoadFile(file.path);
|
|
1540
|
+
}, [
|
|
1541
|
+
entries,
|
|
1542
|
+
files,
|
|
1543
|
+
onLoadFile
|
|
1544
|
+
]);
|
|
1545
|
+
const commentCounts = {};
|
|
1546
|
+
for (const comment of comments) commentCounts[comment.path] = (commentCounts[comment.path] ?? 0) + 1;
|
|
1547
|
+
const isOpen = (path, index) => openOverride[path] ?? index < 20;
|
|
1548
|
+
const open = (path) => {
|
|
1549
|
+
setOpenOverride((current) => current[path] === true ? current : {
|
|
1550
|
+
...current,
|
|
1551
|
+
[path]: true
|
|
1552
|
+
});
|
|
1553
|
+
if (files[path] === void 0) onLoadFile(path);
|
|
1554
|
+
};
|
|
1555
|
+
const pick = (path) => {
|
|
1556
|
+
setPicked(path);
|
|
1557
|
+
open(path);
|
|
1558
|
+
const index = entries.findIndex((file) => file.path === path);
|
|
1559
|
+
globalThis.document?.getElementById(sectionId(index))?.scrollIntoView({ block: "start" });
|
|
1560
|
+
};
|
|
1561
|
+
const toggle = (path, index) => {
|
|
1562
|
+
if (isOpen(path, index)) setOpenOverride((current) => ({
|
|
1563
|
+
...current,
|
|
1564
|
+
[path]: false
|
|
1565
|
+
}));
|
|
1566
|
+
else open(path);
|
|
1567
|
+
};
|
|
1568
|
+
const submitDraft = (body) => {
|
|
1569
|
+
if (draft === void 0) return;
|
|
1570
|
+
onAddComment({
|
|
1571
|
+
path: draft.path,
|
|
1572
|
+
relPath: draft.path,
|
|
1573
|
+
side: draft.selection.side,
|
|
1574
|
+
startLine: draft.selection.startLine,
|
|
1575
|
+
endLine: draft.selection.endLine,
|
|
1576
|
+
snippet: draft.selection.snippet,
|
|
1577
|
+
body: body.trim()
|
|
1578
|
+
});
|
|
1579
|
+
setDraft(void 0);
|
|
1580
|
+
};
|
|
1581
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1582
|
+
"data-testid": "git-review-panel",
|
|
1583
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
1584
|
+
children: [
|
|
1585
|
+
/* @__PURE__ */ jsx(GitSyncBar, {
|
|
1586
|
+
...sync,
|
|
1587
|
+
...summary.state === "ready" && summary.summary.mergeBase !== void 0 ? { mergeBase: summary.summary.mergeBase } : {}
|
|
1588
|
+
}),
|
|
1589
|
+
summary.state === "loading" ? /* @__PURE__ */ jsxs("div", {
|
|
1590
|
+
"data-testid": "git-review-loading",
|
|
1591
|
+
className: "flex flex-1 items-start gap-2 px-4 py-6",
|
|
1592
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
1593
|
+
className: "h-3 w-3 text-doom-faint",
|
|
1594
|
+
label: "reading changes"
|
|
1595
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1596
|
+
className: "text-xs text-doom-dim",
|
|
1597
|
+
children: "reading changes…"
|
|
1598
|
+
})]
|
|
1599
|
+
}) : summary.state === "error" ? /* @__PURE__ */ jsx("p", {
|
|
1600
|
+
role: "alert",
|
|
1601
|
+
"data-testid": "git-review-error",
|
|
1602
|
+
className: "flex-1 px-4 py-6 text-xs text-doom-red",
|
|
1603
|
+
children: summary.error
|
|
1604
|
+
}) : !summary.summary.repository ? /* @__PURE__ */ jsx(EmptyState, {
|
|
1605
|
+
"data-testid": "git-review-no-repository",
|
|
1606
|
+
className: "px-4 py-8",
|
|
1607
|
+
title: "not a git checkout",
|
|
1608
|
+
description: "this session's folder is not inside a git repository, so there is nothing to review."
|
|
1609
|
+
}) : entries.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
1610
|
+
"data-testid": "git-review-empty",
|
|
1611
|
+
className: "px-4 py-8",
|
|
1612
|
+
title: "no changes",
|
|
1613
|
+
description: summary.summary.base === void 0 ? "nothing uncommitted in this checkout." : `nothing differs from ${summary.summary.base}, committed or not.`
|
|
1614
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
1615
|
+
className: "flex min-h-0 flex-1",
|
|
1616
|
+
children: [/* @__PURE__ */ jsx(GitReviewBrowser, {
|
|
1617
|
+
files: entries,
|
|
1618
|
+
commentCounts,
|
|
1619
|
+
onPick: pick,
|
|
1620
|
+
...activePath === void 0 ? {} : { activePath }
|
|
1621
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1622
|
+
"data-testid": "git-review-diffs",
|
|
1623
|
+
className: "min-h-0 min-w-0 flex-1 overflow-y-auto",
|
|
1624
|
+
children: [summary.summary.truncated ? /* @__PURE__ */ jsx("p", {
|
|
1625
|
+
className: "px-4 pt-2 text-2xs text-doom-faint",
|
|
1626
|
+
children: "more files changed than the review lists; the rest are left out."
|
|
1627
|
+
}) : null, entries.map((file, index) => /* @__PURE__ */ jsx(FileSection, {
|
|
1628
|
+
id: sectionId(index),
|
|
1629
|
+
entry: file,
|
|
1630
|
+
state: files[file.path],
|
|
1631
|
+
collapsed: !isOpen(file.path, index),
|
|
1632
|
+
comments: comments.filter((comment) => comment.path === file.path),
|
|
1633
|
+
draft: draft?.path === file.path ? draft.selection : void 0,
|
|
1634
|
+
onToggle: () => toggle(file.path, index),
|
|
1635
|
+
onSelect: (selection) => {
|
|
1636
|
+
setPicked(file.path);
|
|
1637
|
+
setDraft({
|
|
1638
|
+
path: file.path,
|
|
1639
|
+
selection
|
|
1640
|
+
});
|
|
1641
|
+
},
|
|
1642
|
+
onSubmitDraft: submitDraft,
|
|
1643
|
+
onCancelDraft: () => setDraft(void 0),
|
|
1644
|
+
onRemoveComment,
|
|
1645
|
+
onRetry: () => onLoadFile(file.path)
|
|
1646
|
+
}, file.path))]
|
|
1647
|
+
})]
|
|
1648
|
+
}),
|
|
1649
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1650
|
+
"data-testid": "git-review-footer",
|
|
1651
|
+
className: "flex shrink-0 flex-wrap items-center gap-2 border-t border-doom-border-soft bg-doom-panel px-3 py-2 sm:px-[26px]",
|
|
1652
|
+
children: [
|
|
1653
|
+
/* @__PURE__ */ jsx(MessageIcon, {
|
|
1654
|
+
"aria-hidden": true,
|
|
1655
|
+
className: "h-3 w-3 text-doom-faint"
|
|
1656
|
+
}),
|
|
1657
|
+
/* @__PURE__ */ jsx("span", {
|
|
1658
|
+
"data-testid": "git-review-comment-count",
|
|
1659
|
+
className: "text-xs text-doom-dim",
|
|
1660
|
+
children: comments.length === 0 ? "no comments yet: select lines or click a line number" : `${String(comments.length)} ${comments.length === 1 ? "comment" : "comments"}`
|
|
1661
|
+
}),
|
|
1662
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
|
|
1663
|
+
sendError === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
1664
|
+
role: "alert",
|
|
1665
|
+
"data-testid": "git-review-send-error",
|
|
1666
|
+
className: "min-w-0 truncate text-2xs text-doom-red",
|
|
1667
|
+
children: sendError
|
|
1668
|
+
}),
|
|
1669
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1670
|
+
variant: "ghost",
|
|
1671
|
+
size: "xs",
|
|
1672
|
+
"data-testid": "git-review-discard",
|
|
1673
|
+
disabled: comments.length === 0,
|
|
1674
|
+
onClick: onDiscard,
|
|
1675
|
+
children: "discard"
|
|
1676
|
+
}),
|
|
1677
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1678
|
+
variant: "primary",
|
|
1679
|
+
size: "sm",
|
|
1680
|
+
"data-testid": "git-review-send",
|
|
1681
|
+
disabled: comments.length === 0,
|
|
1682
|
+
onClick: onSendReview,
|
|
1683
|
+
children: "send review"
|
|
1684
|
+
})
|
|
1685
|
+
]
|
|
1686
|
+
})
|
|
1687
|
+
]
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
const STATUS_WORD = {
|
|
1691
|
+
added: "added",
|
|
1692
|
+
modified: "modified",
|
|
1693
|
+
deleted: "deleted",
|
|
1694
|
+
untracked: "new, untracked",
|
|
1695
|
+
conflicted: "conflicted"
|
|
1696
|
+
};
|
|
1697
|
+
/** One file: a pinned header, then its diff with comments drawn under the lines they are about. */
|
|
1698
|
+
function FileSection({ id, entry, state, collapsed, comments, draft, onToggle, onSelect, onSubmitDraft, onCancelDraft, onRemoveComment, onRetry }) {
|
|
1699
|
+
const renderAfterRow = (row) => {
|
|
1700
|
+
const side = sideOf(row);
|
|
1701
|
+
const here = comments.filter((comment) => (comment.side ?? "new") === side && (comment.endLine ?? comment.startLine) === row.line);
|
|
1702
|
+
const drafting = draft !== void 0 && draft.side === side && draft.endLine === row.line;
|
|
1703
|
+
if (here.length === 0 && !drafting) return null;
|
|
1704
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1705
|
+
className: "flex flex-col gap-1.5 border-y border-doom-border-soft bg-doom-bg px-2 py-1.5 whitespace-normal",
|
|
1706
|
+
children: [here.map((comment) => /* @__PURE__ */ jsxs("div", {
|
|
1707
|
+
"data-testid": `git-review-comment-${comment.id}`,
|
|
1708
|
+
className: "flex min-w-0 items-start gap-2 rounded-md border border-doom-border-soft bg-doom-panel px-2 py-1.5",
|
|
1709
|
+
children: [
|
|
1710
|
+
/* @__PURE__ */ jsx(MessageIcon, {
|
|
1711
|
+
"aria-hidden": true,
|
|
1712
|
+
className: "mt-0.5 h-3 w-3 shrink-0 text-doom-blue"
|
|
1713
|
+
}),
|
|
1714
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1715
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
1716
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1717
|
+
className: "text-2xs text-doom-faint",
|
|
1718
|
+
children: reviewCommentAnchor(comment)
|
|
1719
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1720
|
+
className: "text-xs whitespace-pre-wrap text-doom-hi",
|
|
1721
|
+
children: comment.body
|
|
1722
|
+
})]
|
|
1723
|
+
}),
|
|
1724
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1725
|
+
variant: "ghost",
|
|
1726
|
+
size: "icon",
|
|
1727
|
+
"aria-label": "remove comment",
|
|
1728
|
+
title: "remove comment",
|
|
1729
|
+
onClick: () => onRemoveComment(comment.id),
|
|
1730
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { className: "h-3 w-3" })
|
|
1731
|
+
})
|
|
1732
|
+
]
|
|
1733
|
+
}, comment.id)), drafting ? /* @__PURE__ */ jsx("div", {
|
|
1734
|
+
className: "rounded-md border border-doom-border bg-doom-panel",
|
|
1735
|
+
children: /* @__PURE__ */ jsx(ReviewCommentDraft, {
|
|
1736
|
+
snippet: draft.snippet,
|
|
1737
|
+
startLine: draft.startLine,
|
|
1738
|
+
endLine: draft.endLine,
|
|
1739
|
+
side: draft.side,
|
|
1740
|
+
testIdPrefix: "git-review-comment",
|
|
1741
|
+
onSubmit: onSubmitDraft,
|
|
1742
|
+
onCancel: onCancelDraft
|
|
1743
|
+
})
|
|
1744
|
+
}) : null]
|
|
1745
|
+
});
|
|
1746
|
+
};
|
|
1747
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
1748
|
+
id,
|
|
1749
|
+
"data-testid": `git-review-file-${entry.path}`,
|
|
1750
|
+
className: "border-b border-doom-border-soft",
|
|
1751
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
1752
|
+
variant: "ghost",
|
|
1753
|
+
size: "card",
|
|
1754
|
+
"aria-expanded": !collapsed,
|
|
1755
|
+
onClick: onToggle,
|
|
1756
|
+
className: "sticky top-0 z-10 flex-row items-center gap-1.5 rounded-none border-b border-doom-border-soft bg-doom-rail px-3 py-1.5 hover:bg-doom-panel sm:px-4",
|
|
1757
|
+
children: [
|
|
1758
|
+
collapsed ? /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
1759
|
+
"aria-hidden": true,
|
|
1760
|
+
className: "h-3 w-3 shrink-0 text-doom-faint"
|
|
1761
|
+
}) : /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
1762
|
+
"aria-hidden": true,
|
|
1763
|
+
className: "h-3 w-3 shrink-0 text-doom-faint"
|
|
1764
|
+
}),
|
|
1765
|
+
/* @__PURE__ */ jsx("span", {
|
|
1766
|
+
className: "min-w-0 flex-1 truncate font-mono text-xs font-bold text-doom-hi",
|
|
1767
|
+
children: entry.path
|
|
1768
|
+
}),
|
|
1769
|
+
/* @__PURE__ */ jsx("span", {
|
|
1770
|
+
className: "shrink-0 text-2xs text-doom-faint",
|
|
1771
|
+
children: STATUS_WORD[entry.status]
|
|
1772
|
+
}),
|
|
1773
|
+
comments.length === 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
1774
|
+
className: "flex shrink-0 items-center gap-0.5 text-2xs text-doom-blue",
|
|
1775
|
+
children: [/* @__PURE__ */ jsx(MessageIcon, {
|
|
1776
|
+
"aria-hidden": true,
|
|
1777
|
+
className: "h-2.5 w-2.5"
|
|
1778
|
+
}), comments.length]
|
|
1779
|
+
}),
|
|
1780
|
+
entry.binary ? null : /* @__PURE__ */ jsxs("span", {
|
|
1781
|
+
className: "shrink-0 text-2xs",
|
|
1782
|
+
children: [
|
|
1783
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1784
|
+
className: "text-doom-green",
|
|
1785
|
+
children: ["+", entry.added]
|
|
1786
|
+
}),
|
|
1787
|
+
" ",
|
|
1788
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1789
|
+
className: "text-doom-red",
|
|
1790
|
+
children: ["-", entry.removed]
|
|
1791
|
+
})
|
|
1792
|
+
]
|
|
1793
|
+
})
|
|
1794
|
+
]
|
|
1795
|
+
}), collapsed ? null : state === void 0 || state.state === "loading" ? /* @__PURE__ */ jsxs("div", {
|
|
1796
|
+
className: "flex items-center gap-2 px-4 py-3",
|
|
1797
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
1798
|
+
className: "h-3 w-3 text-doom-faint",
|
|
1799
|
+
label: `loading ${entry.path}`
|
|
1800
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1801
|
+
className: "text-2xs text-doom-faint",
|
|
1802
|
+
children: "loading diff…"
|
|
1803
|
+
})]
|
|
1804
|
+
}) : state.state === "error" ? /* @__PURE__ */ jsxs("div", {
|
|
1805
|
+
className: "flex items-center gap-2 px-4 py-3",
|
|
1806
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1807
|
+
role: "alert",
|
|
1808
|
+
className: "text-2xs text-doom-red",
|
|
1809
|
+
children: state.error
|
|
1810
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1811
|
+
variant: "ghost",
|
|
1812
|
+
size: "xs",
|
|
1813
|
+
onClick: onRetry,
|
|
1814
|
+
children: "retry"
|
|
1815
|
+
})]
|
|
1816
|
+
}) : state.diff.binary ? /* @__PURE__ */ jsx("p", {
|
|
1817
|
+
className: "px-4 py-3 text-2xs text-doom-faint",
|
|
1818
|
+
children: "binary file, not drawn"
|
|
1819
|
+
}) : state.diff.tooLarge ? /* @__PURE__ */ jsx("p", {
|
|
1820
|
+
className: "px-4 py-3 text-2xs text-doom-faint",
|
|
1821
|
+
children: "this diff is too large to draw here"
|
|
1822
|
+
}) : /* @__PURE__ */ jsx(DiffView, {
|
|
1823
|
+
hunks: state.diff.hunks,
|
|
1824
|
+
testId: `git-review-diff-${id}`,
|
|
1825
|
+
onSelect,
|
|
1826
|
+
renderAfterRow,
|
|
1827
|
+
className: "py-1"
|
|
1828
|
+
})]
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
//#endregion
|
|
1832
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewPanel.tsx
|
|
1833
|
+
/**
|
|
1834
|
+
* The review tab: this session's changes against its base, the comments on
|
|
1835
|
+
* them, and the manual sync beside them.
|
|
1836
|
+
*
|
|
1837
|
+
* DESIGN PATTERNS:
|
|
1838
|
+
* - Opened from the '# diff' group as a transient tab, one per session.
|
|
1839
|
+
* - The hub's channel says when something changed (counts, base, a paused
|
|
1840
|
+
* rebase); the panel refetches the file list then, and each file's hunks
|
|
1841
|
+
* when it is opened. Nothing polls.
|
|
1842
|
+
* - Comments live in a session store and are cleared only after the host took
|
|
1843
|
+
* the message. Both messages go as `enqueue_automatic`, which queues behind a
|
|
1844
|
+
* running turn instead of failing.
|
|
1845
|
+
*
|
|
1846
|
+
* AVOID:
|
|
1847
|
+
* - Sending sync as a session frame. Sync is a channel command; the hub runs
|
|
1848
|
+
* it with the configured auth, one command per session.
|
|
1849
|
+
*/
|
|
1850
|
+
const REVIEW_TAB_ID = "git-review";
|
|
1851
|
+
function reviewTab() {
|
|
1852
|
+
return {
|
|
1853
|
+
id: REVIEW_TAB_ID,
|
|
1854
|
+
label: "review",
|
|
1855
|
+
panel: GitReviewPanel
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
function GitReviewPanel({ sessionId, sendSessionFrame }) {
|
|
1859
|
+
const activity = useStore(gitChanges.store, (state) => gitChanges.select(state, sessionId));
|
|
1860
|
+
const comments = useStore(gitReview.store, (state) => gitReview.select(state, sessionId).comments);
|
|
1861
|
+
const [summary, setSummary] = useState({ state: "loading" });
|
|
1862
|
+
const [files, setFiles] = useState({});
|
|
1863
|
+
const [sendError, setSendError] = useState();
|
|
1864
|
+
const [dismissedError, setDismissedError] = useState();
|
|
1865
|
+
const changes = activity.changes;
|
|
1866
|
+
const fingerprint = JSON.stringify([
|
|
1867
|
+
changes?.branch,
|
|
1868
|
+
changes?.base,
|
|
1869
|
+
changes?.added,
|
|
1870
|
+
changes?.removed,
|
|
1871
|
+
changes?.files,
|
|
1872
|
+
changes?.rebase?.conflicts.length
|
|
1873
|
+
]);
|
|
1874
|
+
useEffect(() => {
|
|
1875
|
+
if (sessionId === null) return;
|
|
1876
|
+
const controller = new AbortController();
|
|
1877
|
+
fetchReviewSummary(sessionId, controller.signal).then((result) => {
|
|
1878
|
+
if (controller.signal.aborted) return;
|
|
1879
|
+
setSummary(result.ok ? {
|
|
1880
|
+
state: "ready",
|
|
1881
|
+
summary: result.summary
|
|
1882
|
+
} : {
|
|
1883
|
+
state: "error",
|
|
1884
|
+
error: result.error
|
|
1885
|
+
});
|
|
1886
|
+
setFiles({});
|
|
1887
|
+
}).catch((error) => {
|
|
1888
|
+
if (controller.signal.aborted) return;
|
|
1889
|
+
setSummary({
|
|
1890
|
+
state: "error",
|
|
1891
|
+
error: error instanceof Error ? error.message : "The changes could not be read."
|
|
1892
|
+
});
|
|
1893
|
+
});
|
|
1894
|
+
return () => controller.abort();
|
|
1895
|
+
}, [sessionId, fingerprint]);
|
|
1896
|
+
const loadFile = useCallback((path) => {
|
|
1897
|
+
if (sessionId === null) return;
|
|
1898
|
+
setFiles((current) => ({
|
|
1899
|
+
...current,
|
|
1900
|
+
[path]: { state: "loading" }
|
|
1901
|
+
}));
|
|
1902
|
+
const settle = (state) => setFiles((current) => ({
|
|
1903
|
+
...current,
|
|
1904
|
+
[path]: state
|
|
1905
|
+
}));
|
|
1906
|
+
fetchReviewFile(sessionId, path).then((result) => settle(result.ok ? {
|
|
1907
|
+
state: "ready",
|
|
1908
|
+
diff: result.diff
|
|
1909
|
+
} : {
|
|
1910
|
+
state: "error",
|
|
1911
|
+
error: result.error
|
|
1912
|
+
})).catch((error) => settle({
|
|
1913
|
+
state: "error",
|
|
1914
|
+
error: error instanceof Error ? error.message : "The diff could not be read."
|
|
1915
|
+
}));
|
|
1916
|
+
}, [sessionId]);
|
|
1917
|
+
if (sessionId === null) return null;
|
|
1918
|
+
const branch = summary.state === "ready" ? summary.summary.branch : changes?.branch;
|
|
1919
|
+
const base = summary.state === "ready" ? summary.summary.base : changes?.base;
|
|
1920
|
+
const error = activity.error === dismissedError ? void 0 : activity.error;
|
|
1921
|
+
const send = (message, onSent) => {
|
|
1922
|
+
const failure = deliverToAgent(sendSessionFrame, sessionId, message);
|
|
1923
|
+
setSendError(failure);
|
|
1924
|
+
if (failure === void 0) onSent?.();
|
|
1925
|
+
};
|
|
1926
|
+
return /* @__PURE__ */ jsx(GitReviewView, {
|
|
1927
|
+
sync: {
|
|
1928
|
+
...changes === void 0 ? {} : { changes },
|
|
1929
|
+
...activity.pending === void 0 ? {} : { pending: activity.pending },
|
|
1930
|
+
...error === void 0 ? {} : { error },
|
|
1931
|
+
...activity.errorTarget === void 0 || error === void 0 ? {} : { errorTarget: activity.errorTarget },
|
|
1932
|
+
onSync: (action) => requestGitSync(sessionId, action),
|
|
1933
|
+
onForcePush: () => requestGitSync(sessionId, "push", true),
|
|
1934
|
+
onAskAgent: () => send(conflictPrompt(branch, changes?.rebase?.conflicts ?? [])),
|
|
1935
|
+
onDismissError: () => setDismissedError(activity.error)
|
|
1936
|
+
},
|
|
1937
|
+
summary,
|
|
1938
|
+
files,
|
|
1939
|
+
comments,
|
|
1940
|
+
onLoadFile: loadFile,
|
|
1941
|
+
onAddComment: (comment) => addReviewComment(sessionId, comment),
|
|
1942
|
+
onRemoveComment: (id) => removeReviewComment(sessionId, id),
|
|
1943
|
+
onSendReview: () => send(buildReviewPrompt(comments, reviewHeading(comments.length, branch, base)), () => clearReviewComments(sessionId)),
|
|
1944
|
+
onDiscard: () => clearReviewComments(sessionId),
|
|
1945
|
+
...sendError === void 0 ? {} : { sendError }
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
//#endregion
|
|
1949
|
+
//#region src/extensions/workspaces/sessions/(frontend)/activity-group/diff.web.ts
|
|
1950
|
+
var diff_web_default = defineActivityGroup({
|
|
1951
|
+
keys: "g d",
|
|
1952
|
+
activeSource: gitChangesActivitySource,
|
|
1953
|
+
marksBackgroundWork: false,
|
|
1954
|
+
transientTab: reviewTab,
|
|
1955
|
+
order: 28
|
|
1956
|
+
});
|
|
1957
|
+
//#endregion
|
|
1958
|
+
//#region src/types/webWorktrees.ts
|
|
1959
|
+
/**
|
|
1960
|
+
* The cockpit's view of this session's worktrees.
|
|
1961
|
+
*
|
|
1962
|
+
* DESIGN PATTERNS:
|
|
1963
|
+
* - Declarations only. The channel frame type is a constant so the hub and the
|
|
1964
|
+
* page cannot drift apart on a string.
|
|
1965
|
+
* - A view is the subset of a record the dock needs, not the record. The
|
|
1966
|
+
* registry may hold paths and provenance the page has no business rendering.
|
|
1967
|
+
*
|
|
1968
|
+
* AVOID:
|
|
1969
|
+
* - Adding behaviour here. This file is imported by browser code, so it must
|
|
1970
|
+
* stay free of node builtins.
|
|
1971
|
+
*/
|
|
1972
|
+
/** The data channel carrying one session's worktrees to the page. */
|
|
1973
|
+
const GIT_WORKTREES_TYPE = "git_worktrees";
|
|
1974
|
+
//#endregion
|
|
1975
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/worktreesActivityStore.ts
|
|
1976
|
+
/**
|
|
1977
|
+
* The dock's view of this session's worktrees, and the commands it sends.
|
|
1978
|
+
*
|
|
1979
|
+
* DESIGN PATTERNS:
|
|
1980
|
+
* - Session-scoped store fed by one hub channel. The hub is authoritative; the
|
|
1981
|
+
* page never reads a registry and never guesses.
|
|
1982
|
+
* - Actions are channel frames, not prompts. The hub half owns the tool's
|
|
1983
|
+
* operations, so the panel names the work and the hub performs it; a
|
|
1984
|
+
* worktree made from the dock is the same object the tool makes, without
|
|
1985
|
+
* spending a turn of the conversation to ask for it.
|
|
1986
|
+
* - The sender lives in a store rather than a module variable, because a web
|
|
1987
|
+
* plugin keeps no mutable module state and the page may reconnect.
|
|
1988
|
+
*
|
|
1989
|
+
* AVOID:
|
|
1990
|
+
* - Calling the hub package API from here. A dock slot gets no sealed request
|
|
1991
|
+
* transport, and raw fetch breaks the remote cockpit.
|
|
1992
|
+
* - `sendSessionFrame` for a command. It envelopes the frame as a session
|
|
1993
|
+
* command bound for the agent, which never reaches a channel's `receive`.
|
|
1994
|
+
*/
|
|
1995
|
+
const worktreeActivity = defineSessionStore({
|
|
1996
|
+
worktrees: [],
|
|
1997
|
+
pending: void 0,
|
|
1998
|
+
error: void 0,
|
|
1999
|
+
errorTarget: void 0
|
|
2000
|
+
});
|
|
2001
|
+
/** Captures the clicked card, so a focus change cannot retarget an open dialog. */
|
|
2002
|
+
const worktreeCreateDialog = defineGlobalStore(null);
|
|
2003
|
+
/**
|
|
2004
|
+
* The page's hub socket sender, held for as long as the plugin runs.
|
|
2005
|
+
*
|
|
2006
|
+
* Undefined before `startWorktreeRuntime` and after it disposes; a command
|
|
2007
|
+
* sent in that window is dropped rather than queued, because a queue would
|
|
2008
|
+
* replay a worktree create against a socket that has since changed sessions.
|
|
2009
|
+
*/
|
|
2010
|
+
const worktreeSender = defineGlobalStore(void 0);
|
|
2011
|
+
/** Binds the page's hub socket. The plugin host calls this once per page. */
|
|
2012
|
+
function startWorktreeRuntime(runtime) {
|
|
2013
|
+
const send = (frame) => {
|
|
2014
|
+
runtime.sendHubFrame(frame);
|
|
2015
|
+
};
|
|
2016
|
+
worktreeSender.update(() => send);
|
|
2017
|
+
return () => {
|
|
2018
|
+
worktreeSender.update((current) => current === send ? void 0 : current);
|
|
2019
|
+
worktreeCreateDialog.update(() => null);
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Whether this session has worktree work in flight.
|
|
2024
|
+
*
|
|
2025
|
+
* A standing worktree is state, not work: it sits there until someone closes
|
|
2026
|
+
* it, so counting it would leave the session reading as busy forever, with a
|
|
2027
|
+
* "background work is still running" notice under a conversation where
|
|
2028
|
+
* nothing is running. Only a create or close actually in progress counts.
|
|
2029
|
+
*
|
|
2030
|
+
* The group stays visible either way. Declaring an active source at all is
|
|
2031
|
+
* what keeps it in the dock; this answers how it is drawn, not whether it is
|
|
2032
|
+
* there.
|
|
2033
|
+
*/
|
|
2034
|
+
const worktreeActivitySource = {
|
|
2035
|
+
subscribe(listener) {
|
|
2036
|
+
const subscription = worktreeActivity.store.subscribe(listener);
|
|
2037
|
+
return () => subscription.unsubscribe();
|
|
2038
|
+
},
|
|
2039
|
+
isActive(sessionId) {
|
|
2040
|
+
return worktreeActivity.select(worktreeActivity.store.state, sessionId).pending !== void 0;
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
function isRecord(value) {
|
|
2044
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2045
|
+
}
|
|
2046
|
+
function optionalText(value) {
|
|
2047
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
2048
|
+
}
|
|
2049
|
+
function optionalErrorTarget(value) {
|
|
2050
|
+
if (!isRecord(value)) return void 0;
|
|
2051
|
+
if (value.action === "create") return { action: "create" };
|
|
2052
|
+
if (value.action === "close" && typeof value.id === "string" && value.id !== "") return {
|
|
2053
|
+
action: "close",
|
|
2054
|
+
id: value.id
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
/** The plugin's session data channel: 'git_worktrees' payloads into the store. */
|
|
2058
|
+
const worktreesChannel = worktreeActivity.channel({
|
|
2059
|
+
channel: GIT_WORKTREES_TYPE,
|
|
2060
|
+
parse(input) {
|
|
2061
|
+
if (!isRecord(input) || !Array.isArray(input.worktrees)) return null;
|
|
2062
|
+
return {
|
|
2063
|
+
worktrees: input.worktrees.filter(isRecord),
|
|
2064
|
+
pending: optionalText(input.pending),
|
|
2065
|
+
error: optionalText(input.error),
|
|
2066
|
+
errorTarget: optionalErrorTarget(input.errorTarget)
|
|
2067
|
+
};
|
|
2068
|
+
},
|
|
2069
|
+
reduce(_current, next) {
|
|
2070
|
+
return next;
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
/** Sends one command to the session's worktrees channel. */
|
|
2074
|
+
function command(sessionId, payload) {
|
|
2075
|
+
worktreeSender.store.state?.({
|
|
2076
|
+
type: GIT_WORKTREES_TYPE,
|
|
2077
|
+
sessionId,
|
|
2078
|
+
payload
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
/** Asks the hub for a worktree. The hub answers on the same channel. */
|
|
2082
|
+
function requestWorktreeCreate(sessionId, branch, baseRef, reservationId) {
|
|
2083
|
+
const trimmedBase = baseRef.trim();
|
|
2084
|
+
command(sessionId, {
|
|
2085
|
+
action: "create",
|
|
2086
|
+
branch: branch.trim(),
|
|
2087
|
+
...trimmedBase === "" ? {} : { baseRef: trimmedBase },
|
|
2088
|
+
...reservationId === void 0 ? {} : { reservationId }
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
/** Asks the hub to close one worktree. Refusal on a dirty tree stays the hub's call. */
|
|
2092
|
+
function requestWorktreeClose(sessionId, id) {
|
|
2093
|
+
command(sessionId, {
|
|
2094
|
+
action: "close",
|
|
2095
|
+
id
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
//#endregion
|
|
2099
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_components/WorktreesPanel.tsx
|
|
2100
|
+
/**
|
|
2101
|
+
* The '# git' group's tab: this session's worktrees, and the form that makes one.
|
|
2102
|
+
*
|
|
2103
|
+
* DESIGN PATTERNS:
|
|
2104
|
+
* - Lives in the activity dock, opened by the group's name. A worktree is work
|
|
2105
|
+
* in progress belonging to the session that started it, so it sits beside
|
|
2106
|
+
* agents, runners and workflows rather than in a settings screen.
|
|
2107
|
+
* - Header, form, then cards, the same rhythm the runners and workflows panels
|
|
2108
|
+
* use. A worktree row is a card because it carries three facts and two
|
|
2109
|
+
* actions, which a single line cannot hold without becoming a puzzle.
|
|
2110
|
+
* - Local form state is never reset by a data refresh. Direct lifecycle events
|
|
2111
|
+
* update the list without discarding a half-typed branch name.
|
|
2112
|
+
* - Acts through the plugin's own hub channel, so a worktree made here and one
|
|
2113
|
+
* made by the tool take exactly the same path.
|
|
2114
|
+
* - Creating waits on the cockpit starting a session, so the hub reports each
|
|
2115
|
+
* phase on that channel and the header shows it turning. A button that looks
|
|
2116
|
+
* idle for two minutes reads as broken.
|
|
2117
|
+
*
|
|
2118
|
+
* AVOID:
|
|
2119
|
+
* - Deriving form state from refreshed store data instead of the user's input.
|
|
2120
|
+
* - Colour classes outside the token set. `doom-error`, `doom-line` and
|
|
2121
|
+
* `doom-bright` are not tokens: they compile to nothing and the row silently
|
|
2122
|
+
* loses its border.
|
|
2123
|
+
*/
|
|
2124
|
+
const WORKTREES_TAB_ID = "git-worktrees";
|
|
2125
|
+
function worktreesTab() {
|
|
2126
|
+
return {
|
|
2127
|
+
id: WORKTREES_TAB_ID,
|
|
2128
|
+
label: "worktrees",
|
|
2129
|
+
panel: WorktreesPanel
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
function WorktreesPanel({ sessionId, sessionReservationId }) {
|
|
2133
|
+
const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
|
|
2134
|
+
const [branch, setBranch] = useState("");
|
|
2135
|
+
const [baseRef, setBaseRef] = useState("");
|
|
2136
|
+
const busy = session.pending !== void 0;
|
|
2137
|
+
const canCreate = sessionId !== null && branch.trim() !== "" && !busy;
|
|
2138
|
+
const createError = session.errorTarget?.action === "create" ? session.error : void 0;
|
|
2139
|
+
const closeErrorId = session.errorTarget?.action === "close" ? session.errorTarget.id : void 0;
|
|
2140
|
+
const panelError = session.error !== void 0 && (session.errorTarget === void 0 || closeErrorId !== void 0 && !session.worktrees.some((worktree) => worktree.id === closeErrorId));
|
|
2141
|
+
const create = () => {
|
|
2142
|
+
if (sessionId === null || !canCreate) return;
|
|
2143
|
+
requestWorktreeCreate(sessionId, branch, baseRef, sessionReservationId);
|
|
2144
|
+
if (sessionReservationId === void 0) {
|
|
2145
|
+
setBranch("");
|
|
2146
|
+
setBaseRef("");
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2150
|
+
"data-testid": "git-worktrees-panel",
|
|
2151
|
+
className: "flex min-h-0 flex-1 flex-col overflow-auto",
|
|
2152
|
+
children: [
|
|
2153
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2154
|
+
className: "flex min-h-11 shrink-0 items-center gap-2.5 border-b border-doom-border-soft px-3 sm:px-[26px]",
|
|
2155
|
+
children: [
|
|
2156
|
+
/* @__PURE__ */ jsx("span", {
|
|
2157
|
+
className: "text-sm font-bold text-doom-hi",
|
|
2158
|
+
children: "worktrees"
|
|
2159
|
+
}),
|
|
2160
|
+
/* @__PURE__ */ jsx("span", {
|
|
2161
|
+
"data-testid": "git-worktrees-count",
|
|
2162
|
+
className: "text-xs text-doom-faint",
|
|
2163
|
+
children: session.worktrees.length === 0 ? "none yet" : `${String(session.worktrees.length)} open`
|
|
2164
|
+
}),
|
|
2165
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
|
|
2166
|
+
session.pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
2167
|
+
"data-testid": "git-worktree-pending",
|
|
2168
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
2169
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
2170
|
+
className: "h-3 w-3 shrink-0 text-doom-faint",
|
|
2171
|
+
label: session.pending
|
|
2172
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2173
|
+
className: "min-w-0 truncate text-xs text-doom-dim",
|
|
2174
|
+
children: session.pending
|
|
2175
|
+
})]
|
|
2176
|
+
})
|
|
2177
|
+
]
|
|
2178
|
+
}),
|
|
2179
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2180
|
+
className: "flex shrink-0 flex-col gap-1.5 border-b border-doom-border-soft px-3 py-2.5 sm:px-[26px]",
|
|
2181
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2182
|
+
className: "flex items-center gap-2",
|
|
2183
|
+
children: [
|
|
2184
|
+
/* @__PURE__ */ jsx(Input, {
|
|
2185
|
+
"data-testid": "git-worktree-branch",
|
|
2186
|
+
"aria-label": "Branch",
|
|
2187
|
+
size: "sm",
|
|
2188
|
+
className: "min-w-0 flex-1",
|
|
2189
|
+
placeholder: "wt/fix-auth",
|
|
2190
|
+
value: branch,
|
|
2191
|
+
onChange: (event) => setBranch(event.target.value),
|
|
2192
|
+
onKeyDown: (event) => {
|
|
2193
|
+
if (event.key === "Enter") create();
|
|
2194
|
+
}
|
|
2195
|
+
}),
|
|
2196
|
+
/* @__PURE__ */ jsx(Input, {
|
|
2197
|
+
"data-testid": "git-worktree-base",
|
|
2198
|
+
"aria-label": "Base ref",
|
|
2199
|
+
size: "sm",
|
|
2200
|
+
placeholder: "base (current)",
|
|
2201
|
+
value: baseRef,
|
|
2202
|
+
onChange: (event) => setBaseRef(event.target.value),
|
|
2203
|
+
className: "w-32 shrink-0"
|
|
2204
|
+
}),
|
|
2205
|
+
/* @__PURE__ */ jsx(Button, {
|
|
2206
|
+
"data-testid": "git-worktree-create",
|
|
2207
|
+
size: "sm",
|
|
2208
|
+
disabled: !canCreate,
|
|
2209
|
+
onClick: create,
|
|
2210
|
+
children: "Create"
|
|
2211
|
+
})
|
|
2212
|
+
]
|
|
2213
|
+
}), createError === void 0 ? /* @__PURE__ */ jsx("p", {
|
|
2214
|
+
className: "text-2xs text-doom-faint",
|
|
2215
|
+
children: "Creates the worktree outside the repository and starts a session nested under this one."
|
|
2216
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
2217
|
+
role: "alert",
|
|
2218
|
+
"data-testid": "git-worktree-error",
|
|
2219
|
+
className: "text-2xs text-doom-red",
|
|
2220
|
+
children: createError
|
|
2221
|
+
})]
|
|
2222
|
+
}),
|
|
2223
|
+
panelError ? /* @__PURE__ */ jsx("p", {
|
|
2224
|
+
role: "alert",
|
|
2225
|
+
"data-testid": "git-worktree-error",
|
|
2226
|
+
className: "px-3 pt-2 text-2xs text-doom-red sm:px-[26px]",
|
|
2227
|
+
children: session.error
|
|
2228
|
+
}) : null,
|
|
2229
|
+
session.worktrees.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
2230
|
+
"data-testid": "git-worktrees-empty",
|
|
2231
|
+
className: "px-4 py-8",
|
|
2232
|
+
title: "no worktrees yet",
|
|
2233
|
+
description: "a worktree is its own checkout on its own branch, with its own session nested under this one."
|
|
2234
|
+
}) : /* @__PURE__ */ jsx("ul", {
|
|
2235
|
+
"data-testid": "git-worktrees-list",
|
|
2236
|
+
className: "flex flex-col gap-2.5 px-3 py-3 sm:px-[26px]",
|
|
2237
|
+
children: session.worktrees.map((worktree) => /* @__PURE__ */ jsx(WorktreeCard, {
|
|
2238
|
+
worktree,
|
|
2239
|
+
sessionId,
|
|
2240
|
+
busy,
|
|
2241
|
+
error: closeErrorId === worktree.id ? session.error : void 0
|
|
2242
|
+
}, worktree.id))
|
|
2243
|
+
})
|
|
2244
|
+
]
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2247
|
+
/** One worktree: what it is, where it is, and the one thing you can do to it. */
|
|
2248
|
+
function WorktreeCard({ worktree, sessionId, busy, error }) {
|
|
2249
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
2250
|
+
"data-testid": `git-worktree-${worktree.id}`,
|
|
2251
|
+
className: "flex min-w-0 flex-col gap-1.5 rounded-md border border-doom-border-soft bg-doom-panel p-2.5",
|
|
2252
|
+
children: [
|
|
2253
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2254
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
2255
|
+
children: [
|
|
2256
|
+
/* @__PURE__ */ jsx(Dot, { tone: worktree.orphaned ? "red" : worktree.sessionId === null ? "muted" : "blue" }),
|
|
2257
|
+
/* @__PURE__ */ jsx("span", {
|
|
2258
|
+
className: "min-w-0 flex-1 truncate text-sm font-bold text-doom-hi",
|
|
2259
|
+
children: worktree.branch
|
|
2260
|
+
}),
|
|
2261
|
+
worktree.orphaned ? /* @__PURE__ */ jsx(StatusBadge, {
|
|
2262
|
+
tone: "error",
|
|
2263
|
+
size: "xs",
|
|
2264
|
+
children: "orphaned"
|
|
2265
|
+
}) : null,
|
|
2266
|
+
worktree.unowned ? /* @__PURE__ */ jsx(StatusBadge, {
|
|
2267
|
+
tone: "info",
|
|
2268
|
+
size: "xs",
|
|
2269
|
+
children: "unowned"
|
|
2270
|
+
}) : null
|
|
2271
|
+
]
|
|
2272
|
+
}),
|
|
2273
|
+
/* @__PURE__ */ jsx("span", {
|
|
2274
|
+
className: "min-w-0 truncate text-2xs text-doom-faint",
|
|
2275
|
+
children: worktree.path
|
|
2276
|
+
}),
|
|
2277
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2278
|
+
className: "flex items-center gap-1.5 pt-0.5",
|
|
2279
|
+
children: [/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }), sessionId === null ? null : /* @__PURE__ */ jsx(Button, {
|
|
2280
|
+
variant: "danger-outline",
|
|
2281
|
+
size: "xs",
|
|
2282
|
+
disabled: busy,
|
|
2283
|
+
"data-testid": `git-worktree-close-${worktree.id}`,
|
|
2284
|
+
className: "px-2 text-2xs font-bold",
|
|
2285
|
+
onClick: () => requestWorktreeClose(sessionId, worktree.id),
|
|
2286
|
+
children: "close"
|
|
2287
|
+
})]
|
|
2288
|
+
}),
|
|
2289
|
+
error === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
2290
|
+
role: "alert",
|
|
2291
|
+
"data-testid": "git-worktree-error",
|
|
2292
|
+
className: "text-2xs text-doom-red",
|
|
2293
|
+
children: error
|
|
2294
|
+
})
|
|
2295
|
+
]
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
//#endregion
|
|
2299
|
+
//#region src/extensions/workspaces/sessions/(frontend)/activity-group/git.web.ts
|
|
2300
|
+
var git_web_default = defineActivityGroup({
|
|
2301
|
+
keys: "g w",
|
|
2302
|
+
activeSource: worktreeActivitySource,
|
|
2303
|
+
marksBackgroundWork: false,
|
|
2304
|
+
transientTab: worktreesTab,
|
|
2305
|
+
order: 30
|
|
2306
|
+
});
|
|
2307
|
+
//#endregion
|
|
2308
|
+
//#region src/extensions/workspaces/sessions/(frontend)/channel/gitChanges.web.ts
|
|
2309
|
+
var gitChanges_web_default = defineChannelFile(gitChangesChannel);
|
|
2310
|
+
//#endregion
|
|
2311
|
+
//#region src/extensions/workspaces/sessions/(frontend)/channel/gitWorktrees.web.ts
|
|
2312
|
+
var gitWorktrees_web_default = defineChannelFile(worktreesChannel);
|
|
2313
|
+
//#endregion
|
|
2314
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/_components/DiffActivitySection.tsx
|
|
2315
|
+
/**
|
|
2316
|
+
* The '# diff' group's body: this session's code change against its base.
|
|
2317
|
+
*
|
|
2318
|
+
* DESIGN PATTERNS:
|
|
2319
|
+
* - One lane, `+A -R`. Files, base, upstream and a paused rebase live in the
|
|
2320
|
+
* review tab's header, which this lane and the group's name both open.
|
|
2321
|
+
* - Stays clickable at zero, because the review tab is also where pull, push
|
|
2322
|
+
* and rebase live.
|
|
2323
|
+
* - Separate from '# git': worktrees are repository management, this is the
|
|
2324
|
+
* session's own change.
|
|
2325
|
+
*
|
|
2326
|
+
* AVOID:
|
|
2327
|
+
* - Doing work here. This section reports and opens the tab.
|
|
2328
|
+
*/
|
|
2329
|
+
function DiffActivitySection({ sessionId, openTransientTab }) {
|
|
2330
|
+
const session = useStore(gitChanges.store, (state) => gitChanges.select(state, sessionId));
|
|
2331
|
+
const changes = session.changes;
|
|
2332
|
+
if (sessionId === null || changes === void 0) return /* @__PURE__ */ jsx("p", {
|
|
2333
|
+
"data-testid": "activity-summary-diff",
|
|
2334
|
+
className: "px-2 text-xs text-doom-faint",
|
|
2335
|
+
children: "idle"
|
|
2336
|
+
});
|
|
2337
|
+
const zero = changes.added === 0 && changes.removed === 0;
|
|
2338
|
+
const against = changes.base === void 0 ? "uncommitted" : `vs ${changes.base}`;
|
|
2339
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2340
|
+
className: "flex min-w-0 items-center gap-2 px-1",
|
|
2341
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
2342
|
+
variant: "ghost",
|
|
2343
|
+
size: "xs",
|
|
2344
|
+
"data-testid": "activity-diff-changes",
|
|
2345
|
+
"aria-label": `review changes: ${String(changes.added)} added, ${String(changes.removed)} removed ${against}`,
|
|
2346
|
+
title: `${String(changes.files)} ${changes.files === 1 ? "file" : "files"} ${against}`,
|
|
2347
|
+
className: `gap-1.5 px-1 text-xs font-bold ${zero ? "text-doom-faint" : ""}`,
|
|
2348
|
+
onClick: () => openTransientTab(reviewTab()),
|
|
2349
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
2350
|
+
className: zero ? "" : "text-doom-green",
|
|
2351
|
+
children: ["+", changes.added]
|
|
2352
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2353
|
+
className: zero ? "" : "text-doom-red",
|
|
2354
|
+
children: ["-", changes.removed]
|
|
2355
|
+
})]
|
|
2356
|
+
}), session.pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
2357
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
2358
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
2359
|
+
className: "h-3 w-3 shrink-0 text-doom-faint",
|
|
2360
|
+
label: session.pending
|
|
2361
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2362
|
+
className: "min-w-0 truncate text-xs text-doom-dim",
|
|
2363
|
+
children: session.pending
|
|
2364
|
+
})]
|
|
2365
|
+
})]
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
//#endregion
|
|
2369
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/Diff.activity.diff.web.tsx
|
|
2370
|
+
var Diff_activity_diff_web_default = defineFill({ component: DiffActivitySection });
|
|
2371
|
+
//#endregion
|
|
2372
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreeCreateDialog.tsx
|
|
2373
|
+
function WorktreeSessionMenu({ sessionId, sessionReservationId }) {
|
|
2374
|
+
return /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
2375
|
+
disabled: sessionId === null,
|
|
2376
|
+
"data-testid": `session-worktree-${sessionReservationId ?? sessionId}`,
|
|
2377
|
+
onSelect: () => {
|
|
2378
|
+
if (sessionId !== null) worktreeCreateDialog.update(() => ({
|
|
2379
|
+
sessionId,
|
|
2380
|
+
...sessionReservationId === void 0 ? {} : { reservationId: sessionReservationId }
|
|
2381
|
+
}));
|
|
2382
|
+
},
|
|
2383
|
+
children: "create worktree session…"
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
function WorktreeCreateOverlay(props) {
|
|
2387
|
+
const target = useStore(worktreeCreateDialog.store);
|
|
2388
|
+
const { holdSessionChannels } = props;
|
|
2389
|
+
useEffect(() => {
|
|
2390
|
+
if (target === null) return;
|
|
2391
|
+
return holdSessionChannels?.(target.sessionId, (frame) => {
|
|
2392
|
+
if (frame.type !== worktreesChannel.channel) return;
|
|
2393
|
+
const payload = worktreesChannel.parse(frame.payload);
|
|
2394
|
+
if (payload !== null) worktreesChannel.apply(target.sessionId, payload);
|
|
2395
|
+
});
|
|
2396
|
+
}, [target, holdSessionChannels]);
|
|
2397
|
+
if (target === null) return null;
|
|
2398
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
2399
|
+
open: true,
|
|
2400
|
+
onOpenChange: (open) => {
|
|
2401
|
+
if (!open) worktreeCreateDialog.update(() => null);
|
|
2402
|
+
},
|
|
2403
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
2404
|
+
width: "lg",
|
|
2405
|
+
"data-testid": "session-worktree-dialog",
|
|
2406
|
+
children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "create worktree session" }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [/* @__PURE__ */ jsx(DialogDescription, { children: "Creates a separate checkout and a new session. Existing sessions stay in their current directories." }), /* @__PURE__ */ createElement(WorktreesPanel, {
|
|
2407
|
+
...props,
|
|
2408
|
+
key: `${target.sessionId}:${target.reservationId ?? ""}`,
|
|
2409
|
+
sessionId: target.sessionId,
|
|
2410
|
+
sessionReservationId: target.reservationId
|
|
2411
|
+
})] })]
|
|
2412
|
+
})
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
//#endregion
|
|
2416
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/Worktree.session-menu.web.tsx
|
|
2417
|
+
var Worktree_session_menu_web_default = defineFill({ component: WorktreeSessionMenu });
|
|
2418
|
+
//#endregion
|
|
2419
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/WorktreeCreate.overlay.web.tsx
|
|
2420
|
+
var WorktreeCreate_overlay_web_default = defineFill({ component: WorktreeCreateOverlay });
|
|
2421
|
+
//#endregion
|
|
2422
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreesActivitySection.tsx
|
|
2423
|
+
/**
|
|
2424
|
+
* The '# git' group's body in the activity dock.
|
|
2425
|
+
*
|
|
2426
|
+
* DESIGN PATTERNS:
|
|
2427
|
+
* - One line per worktree, the same rule the runners rail follows: enough to
|
|
2428
|
+
* notice it, not enough to work with it. The group's own name opens the tab
|
|
2429
|
+
* that has room.
|
|
2430
|
+
* - Idle still shows the launcher. A repository with no worktrees is the state
|
|
2431
|
+
* where someone most wants to make one.
|
|
2432
|
+
*
|
|
2433
|
+
* AVOID:
|
|
2434
|
+
* - Doing work here. This section reports and launches; the panel and the tool
|
|
2435
|
+
* own everything else.
|
|
2436
|
+
*/
|
|
2437
|
+
function WorktreesActivitySection({ sessionId, openTransientTab }) {
|
|
2438
|
+
const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
|
|
2439
|
+
if (session.worktrees.length === 0 && session.pending === void 0) return /* @__PURE__ */ jsxs("div", {
|
|
2440
|
+
className: "flex items-center gap-2 px-1",
|
|
2441
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
2442
|
+
"data-testid": "activity-summary-git",
|
|
2443
|
+
className: "px-1 text-xs text-doom-faint",
|
|
2444
|
+
children: "idle"
|
|
2445
|
+
}), sessionId === null ? null : /* @__PURE__ */ jsx(Button, {
|
|
2446
|
+
variant: "link",
|
|
2447
|
+
size: "xs",
|
|
2448
|
+
"data-testid": "activity-git-create",
|
|
2449
|
+
className: "px-0",
|
|
2450
|
+
onClick: () => openTransientTab(worktreesTab()),
|
|
2451
|
+
children: "create a worktree"
|
|
2452
|
+
})]
|
|
2453
|
+
});
|
|
2454
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2455
|
+
"data-testid": "activity-git-worktrees",
|
|
2456
|
+
className: "flex flex-col gap-0.5",
|
|
2457
|
+
children: [session.pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
2458
|
+
className: "flex min-w-0 items-center gap-1.5 px-1",
|
|
2459
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
2460
|
+
className: "h-3 w-3 shrink-0 text-doom-faint",
|
|
2461
|
+
label: session.pending
|
|
2462
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2463
|
+
className: "min-w-0 truncate text-xs text-doom-dim",
|
|
2464
|
+
children: session.pending
|
|
2465
|
+
})]
|
|
2466
|
+
}), session.worktrees.map((worktree) => /* @__PURE__ */ jsx(Button, {
|
|
2467
|
+
variant: "ghost",
|
|
2468
|
+
size: "card",
|
|
2469
|
+
"data-testid": `activity-git-worktree-${worktree.id}`,
|
|
2470
|
+
className: "min-w-0 gap-1.5 px-1",
|
|
2471
|
+
onClick: () => openTransientTab(worktreesTab()),
|
|
2472
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2473
|
+
className: "flex w-full min-w-0 items-center gap-1.5",
|
|
2474
|
+
children: [
|
|
2475
|
+
/* @__PURE__ */ jsx(Dot, { tone: worktree.orphaned ? "red" : worktree.sessionId === null ? "muted" : "blue" }),
|
|
2476
|
+
/* @__PURE__ */ jsx("span", {
|
|
2477
|
+
className: "min-w-0 flex-1 truncate text-left text-xs font-bold text-doom-hi",
|
|
2478
|
+
children: worktree.branch
|
|
2479
|
+
}),
|
|
2480
|
+
worktree.orphaned ? /* @__PURE__ */ jsx(StatusBadge, {
|
|
2481
|
+
tone: "error",
|
|
2482
|
+
size: "xs",
|
|
2483
|
+
children: "orphaned"
|
|
2484
|
+
}) : null,
|
|
2485
|
+
worktree.unowned ? /* @__PURE__ */ jsx(StatusBadge, {
|
|
2486
|
+
tone: "info",
|
|
2487
|
+
size: "xs",
|
|
2488
|
+
children: "unowned"
|
|
2489
|
+
}) : null
|
|
2490
|
+
]
|
|
2491
|
+
})
|
|
2492
|
+
}, worktree.id))]
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
//#endregion
|
|
2496
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/Worktrees.activity.git.web.tsx
|
|
2497
|
+
var Worktrees_activity_git_web_default = defineFill({ component: WorktreesActivitySection });
|
|
2498
|
+
//#endregion
|
|
2499
|
+
//#region src/extensions/workspaces/sessions/(frontend)/lifecycle/_lib/start.web.ts
|
|
2500
|
+
/** Binds both hub channels' senders: worktrees, and this session's diff and sync. */
|
|
2501
|
+
function startGitRuntime(runtime) {
|
|
2502
|
+
const stopWorktrees = startWorktreeRuntime(runtime);
|
|
2503
|
+
const stopChanges = startGitChangesRuntime(runtime);
|
|
2504
|
+
return () => {
|
|
2505
|
+
stopChanges();
|
|
2506
|
+
stopWorktrees();
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
//#endregion
|
|
2510
|
+
//#region src/extensions/workspaces/sessions/(frontend)/lifecycle/start.web.ts
|
|
2511
|
+
var start_web_default = defineWebLifecycle(startGitRuntime);
|
|
2512
|
+
//#endregion
|
|
2513
|
+
//#region src/extensions/workspaces/sessions/(frontend)/tool/_components/RunWorktreeToolMessage.tsx
|
|
2514
|
+
const ACTION_LABEL = {
|
|
2515
|
+
spawn_worktree: "Create worktree",
|
|
2516
|
+
close_worktree: "Close worktree",
|
|
2517
|
+
list: "List worktrees",
|
|
2518
|
+
status: "Worktree status",
|
|
2519
|
+
merge: "Merge worktree",
|
|
2520
|
+
prune: "Prune worktrees",
|
|
2521
|
+
send: "Message worktree",
|
|
2522
|
+
messages: "Read worktree messages"
|
|
2523
|
+
};
|
|
2524
|
+
/**
|
|
2525
|
+
* The timeline item for `run_worktree`.
|
|
2526
|
+
*
|
|
2527
|
+
* DESIGN PATTERNS:
|
|
2528
|
+
* - Built on MessageItem, like every other tool renderer in the cockpit. That
|
|
2529
|
+
* is what gives it the shared collapse toggle and the RUNNING/OK/ERROR badge
|
|
2530
|
+
* rather than a hand-rolled ellipsis that never resolves.
|
|
2531
|
+
* - The action and its subject go in the heading because that is what a reader
|
|
2532
|
+
* scanning a transcript needs: "close_worktree a1b2c3d4" answers the question
|
|
2533
|
+
* the raw JSON arguments make them decode.
|
|
2534
|
+
* - A create takes as long as the cockpit needs to start a session, and the
|
|
2535
|
+
* tool streams each phase into `output`, so the body is where the wait is
|
|
2536
|
+
* visible.
|
|
2537
|
+
*/
|
|
2538
|
+
function RunWorktreeToolMessage({ args, output, running, isError }) {
|
|
2539
|
+
const action = typeof args.action === "string" ? args.action : "";
|
|
2540
|
+
const subject = typeof args.branch === "string" ? args.branch : typeof args.id === "string" ? args.id : "";
|
|
2541
|
+
return /* @__PURE__ */ jsxs(MessageItem, {
|
|
2542
|
+
tone: toolTone({
|
|
2543
|
+
running,
|
|
2544
|
+
isError
|
|
2545
|
+
}),
|
|
2546
|
+
expandable: output !== "",
|
|
2547
|
+
children: [/* @__PURE__ */ jsx(MessageItemHeader, {
|
|
2548
|
+
title: ACTION_LABEL[action] ?? "Worktree",
|
|
2549
|
+
children: subject === "" ? null : /* @__PURE__ */ jsx("span", {
|
|
2550
|
+
className: "min-w-0 truncate text-doom-dim",
|
|
2551
|
+
children: subject
|
|
2552
|
+
})
|
|
2553
|
+
}), output === "" ? null : /* @__PURE__ */ jsx(MessageItemBody, { children: /* @__PURE__ */ jsx("pre", {
|
|
2554
|
+
className: `whitespace-pre-wrap text-xs ${isError ? "text-doom-red" : "text-doom-dim"}`,
|
|
2555
|
+
children: output
|
|
2556
|
+
}) })]
|
|
2557
|
+
});
|
|
2558
|
+
}
|
|
2559
|
+
//#endregion
|
|
2560
|
+
//#region src/extensions/workspaces/sessions/(frontend)/tool/runWorktree.web.tsx
|
|
2561
|
+
var runWorktree_web_default = defineToolRenderer({ message: RunWorktreeToolMessage });
|
|
2562
|
+
//#endregion
|
|
2563
|
+
//#region generated/web.ts
|
|
2564
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
2565
|
+
...identity,
|
|
2566
|
+
...value
|
|
2567
|
+
};
|
|
2568
|
+
const webPlugin = defineWebPlugin({
|
|
2569
|
+
id: "git",
|
|
2570
|
+
workspace: {
|
|
2571
|
+
get fills() {
|
|
2572
|
+
return [via({
|
|
2573
|
+
slot: "new-session",
|
|
2574
|
+
id: "git-new-session"
|
|
2575
|
+
}, GitNewSession_new_session_web_default)];
|
|
2576
|
+
},
|
|
2577
|
+
get repositorySettingsPanel() {
|
|
2578
|
+
return git_web_default$1;
|
|
2579
|
+
}
|
|
2580
|
+
},
|
|
2581
|
+
session: {
|
|
2582
|
+
get activityGroups() {
|
|
2583
|
+
return [via({ name: "diff" }, diff_web_default), via({ name: "git" }, git_web_default)];
|
|
2584
|
+
},
|
|
2585
|
+
get channels() {
|
|
2586
|
+
return [via({ channel: "git_changes" }, gitChanges_web_default), via({ channel: "git_worktrees" }, gitWorktrees_web_default)];
|
|
2587
|
+
},
|
|
2588
|
+
get fills() {
|
|
2589
|
+
return [
|
|
2590
|
+
via({
|
|
2591
|
+
slot: "activity.diff",
|
|
2592
|
+
id: "diff"
|
|
2593
|
+
}, Diff_activity_diff_web_default),
|
|
2594
|
+
via({
|
|
2595
|
+
slot: "session-menu",
|
|
2596
|
+
id: "worktree"
|
|
2597
|
+
}, Worktree_session_menu_web_default),
|
|
2598
|
+
via({
|
|
2599
|
+
slot: "overlay",
|
|
2600
|
+
id: "worktree-create"
|
|
2601
|
+
}, WorktreeCreate_overlay_web_default),
|
|
2602
|
+
via({
|
|
2603
|
+
slot: "activity.git",
|
|
2604
|
+
id: "worktrees"
|
|
2605
|
+
}, Worktrees_activity_git_web_default)
|
|
2606
|
+
];
|
|
2607
|
+
},
|
|
2608
|
+
get start() {
|
|
2609
|
+
return start_web_default;
|
|
2610
|
+
},
|
|
2611
|
+
get toolRenderers() {
|
|
2612
|
+
return [via({ tools: ["run_worktree"] }, runWorktree_web_default)];
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2616
|
+
//#endregion
|
|
2617
|
+
export { webPlugin };
|
|
2618
|
+
|
|
2619
|
+
//# sourceMappingURL=web.mjs.map
|