copilot-operator 0.1.48 → 0.1.51
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 +582 -574
- package/dist/src/api/operator.controller.js +112 -926
- package/dist/src/api/operator.service.js +217 -2461
- package/dist/src/orchestrator/hold.js +49 -0
- package/dist/src/orchestrator/taskRunner.js +157 -23
- package/dist/src/plan/kerrigan.js +107 -0
- package/dist/src/plan/systemGuide.js +419 -3283
- package/dist/src/session/chatNotice.js +76 -0
- package/dist/src/session/store.js +2 -57
- package/dist/src/session/workspace.js +52 -5
- package/dist/src/session/workspaceGit.js +212 -0
- package/dist/src/transport/chatSession.js +28 -4
- package/dist/src/transport/chatTransport.js +1 -1
- package/dist/src/transport/copilotTransport.js +133 -1
- package/dist/web/404.html +5 -3
- package/dist/web/_next/static/chunks/134-ddd50a7fbb536ec8.js +1 -0
- package/dist/web/_next/static/chunks/190-70555f20dd0da19b.js +1 -0
- package/dist/web/_next/static/chunks/643-e85d221d57900ed7.js +1 -0
- package/dist/web/_next/static/chunks/867-869900ec999e6345.js +1 -0
- package/dist/web/_next/static/chunks/app/appearance/page-cdef33c421397cbe.js +1 -0
- package/dist/web/_next/static/chunks/app/defaults/page-e0a2b8f9a41a94c4.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-b4fc21e26e1bad95.js +1 -0
- package/dist/web/_next/static/chunks/app/level1/page-31b74cae86d960d8.js +1 -0
- package/dist/web/_next/static/chunks/app/page-1075921d44db3e4d.js +1 -0
- package/dist/web/_next/static/chunks/app/presets/page-f8abdd83cdf468f7.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-2a270bb885885821.js +1 -0
- package/dist/web/_next/static/css/8b14cb3cf0051138.css +1 -0
- package/dist/web/_next/static/eqTUTH_SJtBgNgq8Zzy3n/_buildManifest.js +1 -0
- package/dist/web/appearance.html +5 -3
- package/dist/web/appearance.txt +22 -23
- package/dist/web/defaults.html +5 -3
- package/dist/web/defaults.txt +22 -23
- package/dist/web/index.html +5 -3
- package/dist/web/index.txt +22 -23
- package/dist/web/level1.html +5 -3
- package/dist/web/level1.txt +22 -23
- package/dist/web/presets.html +6 -4
- package/dist/web/presets.txt +22 -23
- package/dist/web/system.html +5 -3
- package/dist/web/system.txt +22 -23
- package/package.json +4 -20
- package/dist/src/api/saveToDesktop.js +0 -157
- package/dist/src/plan/brief.js +0 -2003
- package/dist/src/plan/changes.js +0 -217
- package/dist/src/plan/script.js +0 -1014
- package/dist/src/session/debugExport.js +0 -165
- package/dist/src/session/exportRecord.js +0 -277
- package/dist/src/session/metrics.js +0 -95
- package/dist/src/vcs/startChoice.js +0 -367
- package/dist/web/_next/static/chunks/197-f7c33a0114fc3db3.js +0 -1
- package/dist/web/_next/static/chunks/499-751e0be9d4f86e2d.js +0 -1
- package/dist/web/_next/static/chunks/549-a4473e9519a97026.js +0 -1
- package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +0 -1
- package/dist/web/_next/static/chunks/867-b159f25612da5cbc.js +0 -1
- package/dist/web/_next/static/chunks/897-5a34109533c3da50.js +0 -1
- package/dist/web/_next/static/chunks/app/appearance/page-a18019cdc395de3d.js +0 -1
- package/dist/web/_next/static/chunks/app/defaults/page-614be29d185a2947.js +0 -1
- package/dist/web/_next/static/chunks/app/history/page-0bb537407fed5944.js +0 -1
- package/dist/web/_next/static/chunks/app/import/page-8ef75fc08638e75f.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-485ce9395cb17998.js +0 -1
- package/dist/web/_next/static/chunks/app/level1/page-dd3ebf37d29dce4f.js +0 -1
- package/dist/web/_next/static/chunks/app/page-3caf0b02046754a1.js +0 -1
- package/dist/web/_next/static/chunks/app/presets/page-93ab518db67e52a2.js +0 -1
- package/dist/web/_next/static/chunks/app/sessions/page-28376d2e4a9b4738.js +0 -1
- package/dist/web/_next/static/chunks/app/sessions/view/page-835d3533fdc63082.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-227a259e383ca2a0.js +0 -1
- package/dist/web/_next/static/css/ddb518572ea43e30.css +0 -1
- package/dist/web/_next/static/nLLy7-v8M5YRGIMtuTvMJ/_buildManifest.js +0 -1
- package/dist/web/history.html +0 -16
- package/dist/web/history.txt +0 -26
- package/dist/web/import.html +0 -16
- package/dist/web/import.txt +0 -26
- package/dist/web/sessions/view.html +0 -16
- package/dist/web/sessions/view.txt +0 -26
- package/dist/web/sessions.html +0 -16
- package/dist/web/sessions.txt +0 -26
- package/prompts/organisation.bg.md +0 -43
- package/prompts/organisation.en.md +0 -43
- package/prompts/persona.bg.md +0 -17
- package/prompts/persona.en.md +0 -17
- package/prompts/work.bg.md +0 -19
- package/prompts/work.en.md +0 -19
- /package/dist/web/_next/static/{nLLy7-v8M5YRGIMtuTvMJ → eqTUTH_SJtBgNgq8Zzy3n}/_ssgManifest.js +0 -0
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { freeBranchName, git, isAncestor, isValidBranchName, lastFetchedAt } from './git.js';
|
|
2
|
-
import { fetchAsOperator, fetchCommandFor } from './remoteAuth.js';
|
|
3
|
-
import { describeStart, remoteTip, repoDirOf, sessionBranchName } from './taskVcs.js';
|
|
4
|
-
const lines = (s) => s.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
5
|
-
const norm = (dir) => dir.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
|
|
6
|
-
/** A task of the session has run: a start recorded since then is the one its work stands on. */
|
|
7
|
-
export function startIsFixed(session) {
|
|
8
|
-
const ran = session.tasks.some((t) => !!t.startedAt || (t.attempts ?? []).some((a) => !!a.startedAt));
|
|
9
|
-
return !!session.vcsBaseCommit && ran;
|
|
10
|
-
}
|
|
11
|
-
/** The branches of the repository at `dir`, read without touching the network. */
|
|
12
|
-
export async function repoBranches(dir) {
|
|
13
|
-
const empty = (problem) => ({ repoDir: dir, problem, current: null, head: null, local: [], remotes: [] });
|
|
14
|
-
const inside = await git(dir, ['rev-parse', '--is-inside-work-tree']);
|
|
15
|
-
if (!inside.ok || inside.stdout !== 'true')
|
|
16
|
-
return empty(`${dir} is not a git repository.`);
|
|
17
|
-
const current = await git(dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
|
|
18
|
-
const head = await git(dir, ['rev-parse', '--verify', '--quiet', 'HEAD']);
|
|
19
|
-
const refs = await git(dir, ['for-each-ref', '--format=%(objectname) %(refname)', 'refs/heads', 'refs/remotes']);
|
|
20
|
-
const remoteNames = lines((await git(dir, ['remote'])).stdout);
|
|
21
|
-
const local = [];
|
|
22
|
-
const byRemote = new Map(remoteNames.map((r) => [r, []]));
|
|
23
|
-
for (const line of refs.ok ? lines(refs.stdout) : []) {
|
|
24
|
-
const [commit, ref] = [line.slice(0, line.indexOf(' ')), line.slice(line.indexOf(' ') + 1)];
|
|
25
|
-
if (ref.startsWith('refs/heads/'))
|
|
26
|
-
local.push({ name: ref.slice('refs/heads/'.length), commit });
|
|
27
|
-
else if (ref.startsWith('refs/remotes/')) {
|
|
28
|
-
const rest = ref.slice('refs/remotes/'.length);
|
|
29
|
-
const remote = remoteNames.find((r) => rest.startsWith(`${r}/`));
|
|
30
|
-
const name = remote ? rest.slice(remote.length + 1) : '';
|
|
31
|
-
// `origin/HEAD` points at a branch; it is not one.
|
|
32
|
-
if (!remote || !name || name === 'HEAD')
|
|
33
|
-
continue;
|
|
34
|
-
byRemote.get(remote)?.push({ name, commit });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const gitDir = (await git(dir, ['rev-parse', '--absolute-git-dir'])).stdout;
|
|
38
|
-
const fetched = gitDir ? lastFetchedAt(gitDir) : undefined;
|
|
39
|
-
return {
|
|
40
|
-
repoDir: dir,
|
|
41
|
-
current: current.ok && current.stdout ? current.stdout : null,
|
|
42
|
-
head: head.ok && head.stdout ? head.stdout : null,
|
|
43
|
-
local,
|
|
44
|
-
remotes: [...byRemote.entries()].map(([name, branches]) => ({ name, branches })),
|
|
45
|
-
...(fetched ? { lastFetched: fetched } : {}),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/** The remote a branch is most likely wanted from: `origin`, else the first one. */
|
|
49
|
-
export function defaultRemote(repo) {
|
|
50
|
-
return repo.remotes.find((r) => r.name === 'origin')?.name ?? repo.remotes[0]?.name;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* What the start window offers first for a session: its own setting, as one of the choices. A local
|
|
54
|
-
* branch that is not here is offered from the remote when the remote has it, else the branch the
|
|
55
|
-
* repository is on — a start from wherever it happens to be (`head`) is offered as that branch, which
|
|
56
|
-
* is what it would have been.
|
|
57
|
-
*/
|
|
58
|
-
export function defaultChoice(session, repo) {
|
|
59
|
-
const vcs = session.vcs;
|
|
60
|
-
const how = vcs?.startFrom ?? 'head';
|
|
61
|
-
if (how === 'previous-session')
|
|
62
|
-
return { from: 'previous-session' };
|
|
63
|
-
const onBranch = how === 'existing-branch';
|
|
64
|
-
// A branch the session names, as against one assumed (`main`, or wherever the repository is).
|
|
65
|
-
const named = (how === 'head' ? '' : (onBranch ? vcs?.existingBranch : vcs?.baseBranch)?.trim()) ?? '';
|
|
66
|
-
const wanted = named || (how === 'head' ? repo.current ?? '' : 'main');
|
|
67
|
-
const remote = vcs?.baseRemote?.trim();
|
|
68
|
-
const hasRemote = (r, b) => !!repo.remotes.find((x) => x.name === r)?.branches.some((x) => x.name === b);
|
|
69
|
-
if (remote && hasRemote(remote, wanted))
|
|
70
|
-
return { from: 'remote', remote, branch: wanted, ...(onBranch ? { onBranch } : {}) };
|
|
71
|
-
if (wanted && repo.local.some((b) => b.name === wanted))
|
|
72
|
-
return { from: 'local', branch: wanted, ...(onBranch ? { onBranch } : {}) };
|
|
73
|
-
const other = remote && repo.remotes.some((x) => x.name === remote) ? remote : defaultRemote(repo);
|
|
74
|
-
if (other && wanted && hasRemote(other, wanted))
|
|
75
|
-
return { from: 'remote', remote: other, branch: wanted, ...(onBranch ? { onBranch } : {}) };
|
|
76
|
-
/*
|
|
77
|
-
* Named, and neither here nor fetched yet — a branch a colleague pushed after the last fetch: offered from
|
|
78
|
-
* the remote all the same, which the window fetches by name. Offered as the branch the repository is on,
|
|
79
|
-
* it was started from that instead with one press, and the session's own branch was written over.
|
|
80
|
-
*/
|
|
81
|
-
if (named && other)
|
|
82
|
-
return { from: 'remote', remote: other, branch: named, ...(onBranch ? { onBranch } : {}) };
|
|
83
|
-
return { from: 'local', branch: repo.current ?? repo.local[0]?.name ?? wanted };
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The sessions of a run as the start window shows them, in run order, with the branches of each
|
|
87
|
-
* repository they work in.
|
|
88
|
-
*/
|
|
89
|
-
export async function startOptions(sessions) {
|
|
90
|
-
const repos = new Map();
|
|
91
|
-
const out = [];
|
|
92
|
-
const seenRepos = new Set();
|
|
93
|
-
for (const s of sessions) {
|
|
94
|
-
const dir = s.vcs?.enabled ? repoDirOf(s) : '';
|
|
95
|
-
if (!dir) {
|
|
96
|
-
out.push({ id: s.id, name: s.name, vcs: false, previousOffered: false });
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const key = norm(dir);
|
|
100
|
-
if (!repos.has(key))
|
|
101
|
-
repos.set(key, await repoBranches(dir));
|
|
102
|
-
const repo = repos.get(key);
|
|
103
|
-
const earlierHere = seenRepos.has(key);
|
|
104
|
-
seenRepos.add(key);
|
|
105
|
-
const entry = {
|
|
106
|
-
id: s.id,
|
|
107
|
-
name: s.name,
|
|
108
|
-
vcs: true,
|
|
109
|
-
repoDir: repo.repoDir,
|
|
110
|
-
previousOffered: s.vcs?.startFrom === 'previous-session' || earlierHere,
|
|
111
|
-
};
|
|
112
|
-
if (startIsFixed(s)) {
|
|
113
|
-
entry.fixed = s.vcsStart ? describeStart(s.vcsStart) : `it started from ${s.vcsBaseCommit?.slice(0, 8)}`;
|
|
114
|
-
if (!repo.problem) {
|
|
115
|
-
entry.started = await startedOn(s, repo);
|
|
116
|
-
// What "another branch" offers first: the session's own setting, as for a session that has not run.
|
|
117
|
-
entry.choice = defaultChoice(s, repo);
|
|
118
|
-
const carries = carriedOn(s);
|
|
119
|
-
if (carries.length > 0)
|
|
120
|
-
entry.rechooseBlocked = carries.join(', ');
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
if (s.vcsStart)
|
|
125
|
-
entry.prepared = describeStart(s.vcsStart);
|
|
126
|
-
if (!repo.problem)
|
|
127
|
-
entry.choice = defaultChoice(s, repo);
|
|
128
|
-
}
|
|
129
|
-
out.push(entry);
|
|
130
|
-
}
|
|
131
|
-
return { repos: [...repos.values()], sessions: out };
|
|
132
|
-
}
|
|
133
|
-
/** The queued tasks that carry an earlier attempt on, on that attempt's branch: by title, quoted. */
|
|
134
|
-
function carriedOn(s) {
|
|
135
|
-
return s.tasks.filter((t) => t.status === 'queued' && (t.continuing || t.buildsOn)).map((t) => `"${t.title}"`);
|
|
136
|
-
}
|
|
137
|
-
/** Where a session that has run stands: see `StartOptionSession.started`. */
|
|
138
|
-
async function startedOn(s, repo) {
|
|
139
|
-
const dir = repo.repoDir;
|
|
140
|
-
const mode = s.vcs?.startFrom === 'existing-branch' ? 'existing-branch' : s.vcs?.branchMode === 'per-session' ? 'per-session' : 'per-task';
|
|
141
|
-
const branch = mode === 'existing-branch' ? s.vcs?.existingBranch?.trim() : mode === 'per-session' ? sessionBranchName(s) : s.vcsStart?.branch;
|
|
142
|
-
const recorded = s.vcsStart?.commit ?? s.vcsBaseCommit;
|
|
143
|
-
let tipNow = null;
|
|
144
|
-
let remote;
|
|
145
|
-
if (branch) {
|
|
146
|
-
if (mode === 'per-task' && s.vcsStart?.remote && branch.startsWith(`${s.vcsStart.remote}/`)) {
|
|
147
|
-
tipNow = await remoteTip(dir, s.vcsStart.remote, branch.slice(s.vcsStart.remote.length + 1));
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
tipNow = repo.local.find((b) => b.name === branch)?.commit ?? null;
|
|
151
|
-
const r = s.vcs?.baseRemote?.trim() || defaultRemote(repo);
|
|
152
|
-
const theirs = r ? repo.remotes.find((x) => x.name === r)?.branches.find((b) => b.name === branch) : undefined;
|
|
153
|
-
if (r && theirs)
|
|
154
|
-
remote = { name: `${r}/${branch}`, commit: theirs.commit };
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return { mode, ...(branch ? { branch } : {}), ...(recorded ? { recorded } : {}), tipNow, ...(remote ? { remote } : {}) };
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Checks a choice against the repository and works out what it sets. Nothing is written to the session
|
|
161
|
-
* here; for `remote` with `onBranch` the local branch is made, or moved forward, since that is the
|
|
162
|
-
* choice — and only then, after everything else about it has been checked, and never with `dry`, which
|
|
163
|
-
* only says whether it could be done (every session of a run is checked so before any branch moves).
|
|
164
|
-
*/
|
|
165
|
-
export async function applyStartChoice(session, choice, opts = {}) {
|
|
166
|
-
// Nothing to choose without version control; a start that is fixed is kept unless chosen again.
|
|
167
|
-
if (!session.vcs?.enabled)
|
|
168
|
-
return { ok: true };
|
|
169
|
-
if (!startIsFixed(session))
|
|
170
|
-
return await chooseStart(session, choice, opts);
|
|
171
|
-
if (!choice.rechoose)
|
|
172
|
-
return { ok: true };
|
|
173
|
-
/*
|
|
174
|
-
* Chosen again after the session ran (operator's report, 2026-10-13: "the retry remains permanently bound
|
|
175
|
-
* to the session's original branch and commit"). Not while a queued task carries an earlier attempt on:
|
|
176
|
-
* that attempt's work is on its own branch, and the task goes on there.
|
|
177
|
-
*/
|
|
178
|
-
const carries = carriedOn(session);
|
|
179
|
-
if (carries.length > 0) {
|
|
180
|
-
return {
|
|
181
|
-
ok: false,
|
|
182
|
-
problem: `${carries.join(', ')} ${carries.length === 1 ? 'carries' : 'carry'} an earlier attempt on, on its own branch, so where "${session.name}" starts stays as it is. ` +
|
|
183
|
-
'To start it from another branch, queue it with "Fix the prompt and queue it again" instead.',
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
const done = await chooseStart(session, choice, opts);
|
|
187
|
-
if (!done.ok || !done.applied)
|
|
188
|
-
return done;
|
|
189
|
-
const applied = done.applied;
|
|
190
|
-
// A branch carried on is the new one itself; the one branch of a per-session session goes on under a new name.
|
|
191
|
-
const perSession = session.vcs.branchMode === 'per-session' && (applied.vcs.startFrom ?? session.vcs.startFrom) !== 'existing-branch';
|
|
192
|
-
const freshBranch = perSession && !opts.dry ? await freeBranchName(repoDirOf(session), sessionBranchName(session)) : undefined;
|
|
193
|
-
return {
|
|
194
|
-
ok: true,
|
|
195
|
-
applied: {
|
|
196
|
-
...applied,
|
|
197
|
-
clearStart: true,
|
|
198
|
-
restart: freshBranch ? { freshBranch } : {},
|
|
199
|
-
said: `${applied.said} — chosen again after the session had run: the tasks that run next start from it, a task run again included` +
|
|
200
|
-
(freshBranch ? `, on the new branch ${freshBranch} (${sessionBranchName(session)} keeps what was done on it)` : ''),
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
/** `applyStartChoice` for a session whose start is not fixed: see there. */
|
|
205
|
-
async function chooseStart(session, choice, opts) {
|
|
206
|
-
if (!session.vcs?.enabled)
|
|
207
|
-
return { ok: true };
|
|
208
|
-
const dir = repoDirOf(session);
|
|
209
|
-
const before = pointOf(session.vcs);
|
|
210
|
-
if (choice.from === 'previous-session') {
|
|
211
|
-
const vcs = { startFrom: 'previous-session' };
|
|
212
|
-
return { ok: true, applied: { vcs, clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit, said: `"${session.name}" carries on the session before it in this repository` } };
|
|
213
|
-
}
|
|
214
|
-
const name = choice.branch.trim();
|
|
215
|
-
if (!name || !(await isValidBranchName(dir, name)))
|
|
216
|
-
return { ok: false, problem: `"${choice.branch}" is not a branch name git accepts.` };
|
|
217
|
-
if (choice.from === 'local') {
|
|
218
|
-
const tip = (await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}^{commit}`])).stdout;
|
|
219
|
-
if (!tip)
|
|
220
|
-
return { ok: false, problem: `${dir} has no local branch "${name}". Choose one it has, or the remote branch of that name.` };
|
|
221
|
-
const vcs = choice.onBranch
|
|
222
|
-
? { startFrom: 'existing-branch', existingBranch: name, baseRemote: undefined, updateFromRemote: false }
|
|
223
|
-
: { startFrom: 'branch', baseBranch: name, baseRemote: undefined, existingBranch: undefined, updateFromRemote: false };
|
|
224
|
-
return {
|
|
225
|
-
ok: true,
|
|
226
|
-
applied: {
|
|
227
|
-
vcs,
|
|
228
|
-
clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
|
|
229
|
-
said: choice.onBranch
|
|
230
|
-
? `"${session.name}" works on the local branch ${name} itself (${tip.slice(0, 8)}), as it is here`
|
|
231
|
-
: `"${session.name}" starts from the local branch ${name} (${tip.slice(0, 8)}), as it is here`,
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
const remote = choice.remote.trim();
|
|
236
|
-
const remotes = lines((await git(dir, ['remote'])).stdout);
|
|
237
|
-
if (!remotes.includes(remote))
|
|
238
|
-
return { ok: false, problem: `${dir} has no remote called "${remote}"${remotes.length > 0 ? ` (it has: ${remotes.join(', ')})` : ''}.` };
|
|
239
|
-
const theirs = await remoteTip(dir, remote, name);
|
|
240
|
-
if (!theirs)
|
|
241
|
-
return { ok: false, problem: `${remote}/${name} is not known here: it was not fetched. Start again, and it is fetched first.` };
|
|
242
|
-
if (!choice.onBranch) {
|
|
243
|
-
const vcs = { startFrom: 'branch', baseBranch: name, baseRemote: remote, existingBranch: undefined, updateFromRemote: false };
|
|
244
|
-
return {
|
|
245
|
-
ok: true,
|
|
246
|
-
applied: {
|
|
247
|
-
vcs,
|
|
248
|
-
clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
|
|
249
|
-
said: `"${session.name}" starts from the remote branch ${remote}/${name} (${theirs.slice(0, 8)}), as fetched now; the local branch ${name} is not touched`,
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
// Work on the branch itself: the local branch made from the remote one, or brought up to it.
|
|
254
|
-
const ours = (await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}^{commit}`])).stdout;
|
|
255
|
-
let note;
|
|
256
|
-
if (!ours) {
|
|
257
|
-
// By its full name: `origin/x` alone is looked up among tags and local branches first.
|
|
258
|
-
const made = opts.dry ? { ok: true, stdout: '', stderr: '' } : await git(dir, ['branch', '--track', name, `refs/remotes/${remote}/${name}`]);
|
|
259
|
-
if (!made.ok)
|
|
260
|
-
return { ok: false, problem: `the local branch ${name} could not be made from ${remote}/${name}: ${(made.stderr || made.stdout).split(/\r?\n/)[0]}` };
|
|
261
|
-
note = `made the local branch ${name} from ${remote}/${name} (${theirs.slice(0, 8)})`;
|
|
262
|
-
}
|
|
263
|
-
else if (ours === theirs) {
|
|
264
|
-
note = `the local branch ${name} is already where ${remote}/${name} is (${theirs.slice(0, 8)})`;
|
|
265
|
-
}
|
|
266
|
-
else if (await isAncestor(dir, ours, theirs)) {
|
|
267
|
-
const current = (await git(dir, ['symbolic-ref', '--quiet', '--short', 'HEAD'])).stdout;
|
|
268
|
-
if (current === name) {
|
|
269
|
-
const dirty = (await git(dir, ['status', '--porcelain', '--untracked-files=no'])).stdout.trim();
|
|
270
|
-
if (dirty)
|
|
271
|
-
return { ok: false, problem: `${name} is checked out with uncommitted changes, so it cannot be brought up to ${remote}/${name}. Commit or stash them first; nothing was changed.` };
|
|
272
|
-
}
|
|
273
|
-
const moved = opts.dry
|
|
274
|
-
? { ok: true, stdout: '', stderr: '' }
|
|
275
|
-
: current === name
|
|
276
|
-
? await git(dir, ['merge', '--ff-only', '--quiet', theirs])
|
|
277
|
-
: await git(dir, ['update-ref', '-m', `copilot-operator: brought up to ${remote}/${name} in the start window`, `refs/heads/${name}`, theirs, ours]);
|
|
278
|
-
if (!moved.ok)
|
|
279
|
-
return { ok: false, problem: `${name} could not be brought up to ${remote}/${name}: ${(moved.stderr || moved.stdout).split(/\r?\n/)[0]}. Nothing else was changed.` };
|
|
280
|
-
note = `brought the local branch ${name} up to ${remote}/${name}: ${ours.slice(0, 8)} → ${theirs.slice(0, 8)}, fast-forward`;
|
|
281
|
-
}
|
|
282
|
-
else if (await isAncestor(dir, theirs, ours)) {
|
|
283
|
-
note = `the local branch ${name} has commits ${remote}/${name} does not; it was left as it is (${ours.slice(0, 8)}) and the work goes on top of them`;
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
return {
|
|
287
|
-
ok: false,
|
|
288
|
-
problem: `the local branch ${name} (${ours.slice(0, 8)}) and ${remote}/${name} (${theirs.slice(0, 8)}) have each gone their own way, so working on it would mean choosing one of them. ` +
|
|
289
|
-
`Nothing was changed. Start from ${remote}/${name} on a new branch instead, or bring the two together yourself first.`,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
const vcs = { startFrom: 'existing-branch', existingBranch: name, baseRemote: remote, updateFromRemote: false };
|
|
293
|
-
return {
|
|
294
|
-
ok: true,
|
|
295
|
-
applied: {
|
|
296
|
-
vcs,
|
|
297
|
-
clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
|
|
298
|
-
note,
|
|
299
|
-
said: `"${session.name}" works on the branch ${name} itself, from ${remote}/${name} as fetched now`,
|
|
300
|
-
},
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
/** Where a session's settings say it starts: the fields that decide the commit, nothing else. */
|
|
304
|
-
function pointOf(vcs) {
|
|
305
|
-
return JSON.stringify([vcs?.startFrom ?? 'head', vcs?.baseBranch?.trim() || 'main', vcs?.baseRemote?.trim() ?? '', vcs?.existingBranch?.trim() ?? '']);
|
|
306
|
-
}
|
|
307
|
-
function changed(before, after) {
|
|
308
|
-
return before !== pointOf(after);
|
|
309
|
-
}
|
|
310
|
-
/** The fields of an `AppliedChoice` written onto a session's version control: `undefined` removes one. */
|
|
311
|
-
export function withChoice(vcs, patch) {
|
|
312
|
-
const out = { ...vcs };
|
|
313
|
-
for (const [k, v] of Object.entries(patch)) {
|
|
314
|
-
if (v === undefined)
|
|
315
|
-
delete out[k];
|
|
316
|
-
else
|
|
317
|
-
out[k] = v;
|
|
318
|
-
}
|
|
319
|
-
return out;
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* The refspecs that fetch exactly these branches of `remote` into their remote-tracking branches, or
|
|
323
|
-
* why one of the names cannot be fetched.
|
|
324
|
-
*/
|
|
325
|
-
export async function refspecsFor(dir, remote, branches) {
|
|
326
|
-
const refspecs = [];
|
|
327
|
-
for (const b of [...new Set(branches.map((x) => x.trim()).filter(Boolean))]) {
|
|
328
|
-
if (!(await isValidBranchName(dir, b)))
|
|
329
|
-
return { problem: `"${b}" is not a branch name git accepts.` };
|
|
330
|
-
refspecs.push(`+refs/heads/${b}:refs/remotes/${remote}/${b}`);
|
|
331
|
-
}
|
|
332
|
-
return { refspecs };
|
|
333
|
-
}
|
|
334
|
-
/** The branch names a failed fetch said the remote does not have. */
|
|
335
|
-
export function missingOnRemote(detail) {
|
|
336
|
-
return [...detail.matchAll(/couldn't find remote ref (?:refs\/heads\/)?(\S+)/gi)].map((m) => m[1].replace(/[.,;:]+$/, ''));
|
|
337
|
-
}
|
|
338
|
-
/** Where git keeps the repository's records, for `lastFetchedAt`. */
|
|
339
|
-
export async function gitDirOf(dir) {
|
|
340
|
-
const r = await git(dir, ['rev-parse', '--absolute-git-dir']);
|
|
341
|
-
return r.ok && r.stdout ? r.stdout : null;
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Fetches `branches` of `remote` — or the whole remote, pruned, when none are named — for the start
|
|
345
|
-
* window, where the operator is looking: through Git's password window when there is one (`askpass`).
|
|
346
|
-
* Only remote-tracking branches move; no local branch, no checkout.
|
|
347
|
-
*/
|
|
348
|
-
export async function fetchForStart(dir, remote, branches, askpass) {
|
|
349
|
-
const remotes = lines((await git(dir, ['remote'])).stdout);
|
|
350
|
-
if (!remotes.includes(remote))
|
|
351
|
-
return { ok: false, problem: `${dir} has no remote called "${remote}"${remotes.length > 0 ? ` (it has: ${remotes.join(', ')})` : ''}.`, missing: [] };
|
|
352
|
-
const specs = branches && branches.length > 0 ? await refspecsFor(dir, remote, branches) : { refspecs: [] };
|
|
353
|
-
if ('problem' in specs)
|
|
354
|
-
return { ok: false, problem: specs.problem, missing: [] };
|
|
355
|
-
const gitDir = await gitDirOf(dir);
|
|
356
|
-
// Read before fetching: a fetch that fails empties FETCH_HEAD, and with it the time of the last one that worked.
|
|
357
|
-
const lastBefore = gitDir ? lastFetchedAt(gitDir) : undefined;
|
|
358
|
-
const fetched = await fetchAsOperator(dir, remote, { askpass, refspecs: specs.refspecs });
|
|
359
|
-
const missing = fetched.ok ? [] : missingOnRemote(fetched.detail ?? '');
|
|
360
|
-
return {
|
|
361
|
-
ok: fetched.ok,
|
|
362
|
-
fetched,
|
|
363
|
-
missing,
|
|
364
|
-
...(fetched.ok ? {} : { fetchCommand: fetchCommandFor(dir, remote), ...(lastBefore ? { lastFetched: lastBefore } : {}) }),
|
|
365
|
-
repo: await repoBranches(dir),
|
|
366
|
-
};
|
|
367
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[197],{257:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return o}});let n=r(1521);function o(e,t){let r=(0,n.useRef)(null),o=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=o.current;t&&(o.current=null,t())}else e&&(r.current=u(e,n)),t&&(o.current=u(t,n))},[e,t])}function u(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},4251:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"errorOnce",{enumerable:!0,get:function(){return r}});let r=e=>{}},4866:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{DecodeError:function(){return h},MiddlewareNotFoundError:function(){return b},MissingStaticPage:function(){return m},NormalizeError:function(){return y},PageNotFoundError:function(){return g},SP:function(){return p},ST:function(){return d},WEB_VITALS:function(){return r},execOnce:function(){return n},getDisplayName:function(){return l},getLocationOrigin:function(){return a},getURL:function(){return i},isAbsoluteUrl:function(){return u},isResSent:function(){return f},loadGetInitialProps:function(){return s},normalizeRepeatedSlashes:function(){return c},stringifyError:function(){return P}});let r=["CLS","FCP","FID","INP","LCP","TTFB"];function n(e){let t,r=!1;return function(){for(var n=arguments.length,o=Array(n),u=0;u<n;u++)o[u]=arguments[u];return r||(r=!0,t=e(...o)),t}}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,u=e=>o.test(e);function a(){let{protocol:e,hostname:t,port:r}=window.location;return e+"//"+t+(r?":"+r:"")}function i(){let{href:e}=window.location,t=a();return e.substring(t.length)}function l(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function c(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?"?"+t.slice(1).join("?"):"")}async function s(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await s(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error('"'+l(e)+'.getInitialProps()" should resolve to an object. But found "'+n+'" instead.'),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}let p="undefined"!=typeof performance,d=p&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class h extends Error{}class y extends Error{}class g extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message="Cannot find module for page: "+e}}class m extends Error{constructor(e,t){super(),this.message="Failed to load static file for page: "+e+" "+t}}class b extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function P(e){return JSON.stringify({message:e.message,stack:e.stack})}},5700:(e,t)=>{function r(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function n(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function o(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))if(Array.isArray(o))for(let e of o)t.append(r,n(e));else t.set(r,n(o));return t}function u(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(let t of r){for(let r of t.keys())e.delete(r);for(let[r,n]of t.entries())e.append(r,n)}return e}Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{assign:function(){return u},searchParamsToUrlQuery:function(){return r},urlQueryToSearchParams:function(){return o}})},6348:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{formatUrl:function(){return u},formatWithValidation:function(){return i},urlObjectKeys:function(){return a}});let n=r(2371)._(r(5700)),o=/https?|ftp|gopher|file/;function u(e){let{auth:t,hostname:r}=e,u=e.protocol||"",a=e.pathname||"",i=e.hash||"",l=e.query||"",f=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?f=t+e.host:r&&(f=t+(~r.indexOf(":")?"["+r+"]":r),e.port&&(f+=":"+e.port)),l&&"object"==typeof l&&(l=String(n.urlQueryToSearchParams(l)));let c=e.search||l&&"?"+l||"";return u&&!u.endsWith(":")&&(u+=":"),e.slashes||(!u||o.test(u))&&!1!==f?(f="//"+(f||""),a&&"/"!==a[0]&&(a="/"+a)):f||(f=""),i&&"#"!==i[0]&&(i="#"+i),c&&"?"!==c[0]&&(c="?"+c),""+u+f+(a=a.replace(/[?#]/g,encodeURIComponent))+(c=c.replace("#","%23"))+i}let a=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function i(e){return u(e)}},7125:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isLocalURL",{enumerable:!0,get:function(){return u}});let n=r(4866),o=r(2875);function u(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,o.hasBasePath)(r.pathname)}catch(e){return!1}}},8197:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{default:function(){return g},useLinkStatus:function(){return b}});let n=r(2371),o=r(3365),u=n._(r(1521)),a=r(6348),i=r(5722),l=r(257),f=r(4866),c=r(3424);r(4691);let s=r(2557),p=r(7125),d=r(2921);r(4251);let h=r(2418);function y(e){return"string"==typeof e?e:(0,a.formatUrl)(e)}function g(e){var t;let r,n,a,[g,b]=(0,u.useOptimistic)(s.IDLE_LINK_STATUS),P=(0,u.useRef)(null),{href:_,as:v,children:E,prefetch:O=null,passHref:j,replace:S,shallow:C,scroll:N,onClick:T,onMouseEnter:x,onTouchStart:A,legacyBehavior:M=!1,onNavigate:R,ref:L,unstable_dynamicOnHover:k,...I}=e;r=E,M&&("string"==typeof r||"number"==typeof r)&&(r=(0,o.jsx)("a",{children:r}));let U=u.default.useContext(i.AppRouterContext),w=!1!==O,F=!1!==O?null===(t=O)||"auto"===t?h.FetchStrategy.PPR:h.FetchStrategy.Full:h.FetchStrategy.PPR,{href:D,as:K}=u.default.useMemo(()=>{let e=y(_);return{href:e,as:v?y(v):e}},[_,v]);M&&(n=u.default.Children.only(r));let B=M?n&&"object"==typeof n&&n.ref:L,z=u.default.useCallback(e=>(null!==U&&(P.current=(0,s.mountLinkInstance)(e,D,U,F,w,b)),()=>{P.current&&((0,s.unmountLinkForCurrentNavigation)(P.current),P.current=null),(0,s.unmountPrefetchableInstance)(e)}),[w,D,U,F,b]),Q={ref:(0,l.useMergedRef)(z,B),onClick(e){M||"function"!=typeof T||T(e),M&&n.props&&"function"==typeof n.props.onClick&&n.props.onClick(e),U&&(e.defaultPrevented||function(e,t,r,n,o,a,i){let{nodeName:l}=e.currentTarget;if(!("A"===l.toUpperCase()&&function(e){let t=e.currentTarget.getAttribute("target");return t&&"_self"!==t||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||e.currentTarget.hasAttribute("download"))){if(!(0,p.isLocalURL)(t)){o&&(e.preventDefault(),location.replace(t));return}if(e.preventDefault(),i){let e=!1;if(i({preventDefault:()=>{e=!0}}),e)return}u.default.startTransition(()=>{(0,d.dispatchNavigateAction)(r||t,o?"replace":"push",null==a||a,n.current)})}}(e,D,K,P,S,N,R))},onMouseEnter(e){M||"function"!=typeof x||x(e),M&&n.props&&"function"==typeof n.props.onMouseEnter&&n.props.onMouseEnter(e),U&&w&&(0,s.onNavigationIntent)(e.currentTarget,!0===k)},onTouchStart:function(e){M||"function"!=typeof A||A(e),M&&n.props&&"function"==typeof n.props.onTouchStart&&n.props.onTouchStart(e),U&&w&&(0,s.onNavigationIntent)(e.currentTarget,!0===k)}};return(0,f.isAbsoluteUrl)(K)?Q.href=K:M&&!j&&("a"!==n.type||"href"in n.props)||(Q.href=(0,c.addBasePath)(K)),a=M?u.default.cloneElement(n,Q):(0,o.jsx)("a",{...I,...Q,children:r}),(0,o.jsx)(m.Provider,{value:g,children:a})}let m=(0,u.createContext)(s.IDLE_LINK_STATUS),b=()=>(0,u.useContext)(m);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[499],{1035:(e,t,l)=>{l.d(t,{DialogHost:()=>d,Z:()=>o});var r=l(3365),n=l(1521),s=l(867),a=l(4969);let c=null,i=[];function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(l=>{var r;return r={kind:"confirm",message:e,...t,resolve:l},void(c?c(r):i.push(r))})}function d(e){var t,l;let{children:o}=e,{t:d}=(0,s.kj)(),[h,m]=(0,n.useState)([]),u=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(c=e=>m(t=>[...t,e]),i.length>0){let e=i.splice(0,i.length);m(t=>[...t,...e])}return()=>{c=null}},[]);let x=h[0],g=(0,n.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,a.V)(p,!!x,u),(0,n.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),g(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,g]),(0,r.jsxs)(r.Fragment,{children:[o,x&&(0,r.jsx)("div",{className:"modal-backdrop",onClick:()=>g(!1),role:"presentation",children:(0,r.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{id:"modal-title",children:null!=(t=x.title)?t:d("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,r.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,r.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>g(!1),children:d("dialog.cancel")}),(0,r.jsx)("button",{ref:u,type:"button",className:x.danger?"danger":"primary",onClick:()=>g(!0),children:null!=(l=x.okLabel)?l:d("dialog.ok")})]})]})})]})}},1701:(e,t,l)=>{l.d(t,{L:()=>u,StartDialogHost:()=>p});var r=l(3365),n=l(1521),s=l(5549),a=l(867),c=l(4969),i=l(3486),o=l(3069);let d=null,h=[],m=1;function u(e){return new Promise(t=>{let l={...e,id:m++,resolve:t};d?d(l):h.push(l)})}function p(){let[e,t]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(d=e=>t(t=>[...t,e]),h.length>0){let e=h.splice(0,h.length);t(t=>[...t,...e])}return()=>{d=null}},[]);let l=e[0];return l?(0,r.jsx)(g,{req:l,onDone:e=>{l.resolve(e),t(e=>e.slice(1))}},l.id):null}let x=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase();function g(e){var t,l,d,h,m,u;let{req:p,onDone:g}=e,{t:f}=(0,a.kj)(),j=(0,a.W3)(),v=(0,n.useId)(),b=(0,n.useRef)(null),y=(0,n.useRef)(null),[k,w]=(0,n.useState)(null),[N,F]=(0,n.useState)(""),[B,C]=(0,n.useState)({}),[S,D]=(0,n.useState)({}),[E,T]=(0,n.useState)({kind:"choose"}),[H,O]=(0,n.useState)(""),[W,I]=(0,n.useState)(""),[L,R]=(0,n.useState)({}),[A,q]=(0,n.useState)([]),[P,z]=(0,n.useState)(!1),U=(0,n.useRef)(new Set),V=(0,n.useRef)(void 0),K=e=>g({started:e,...V.current?{reply:V.current}:{}}),_="fetching"===E.kind||"starting"===E.kind||""!==W,X=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return s.FH.startOptions(p.sessionIds).then(t=>{w(t);let l={};for(let e of t.repos)l[x(e.repoDir)]=e;C(l);let r={};for(let e of t.sessions){if(!e.vcs||!e.repoDir||e.fixed&&!e.choice)continue;let t=function(e,t){var l,r,n,s,a,c,i;let o=null!=(a=null!=(s=null==t||null==(l=t.remotes.find(e=>"origin"===e.name))?void 0:l.name)?s:null==t||null==(r=t.remotes[0])?void 0:r.name)?a:"",d=null!=(i=null!=(c=null==t?void 0:t.current)?c:null==t||null==(n=t.local[0])?void 0:n.name)?i:"main";return e?"previous-session"===e.from?{from:"previous-session",local:d,remote:o,remoteBranch:d,onBranch:!1}:"local"===e.from?{from:"local",local:e.branch,remote:o,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"remote",local:(null==t?void 0:t.local.some(t=>t.name===e.branch))?e.branch:d,remote:e.remote,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"local",local:d,remote:o,remoteBranch:"main",onBranch:!1}}(e.choice,l[x(e.repoDir)]);r[e.id]=e.prepared||e.fixed?{...t,from:"keep"}:t}D(t=>e?{...r,...Object.fromEntries(Object.entries(t).filter(e=>{let[t]=e;return t in r}))}:r)}).catch(e=>F(e.message))};(0,n.useEffect)(()=>{X()},[p.sessionIds]),(0,c.V)(b,!0,y),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&!e.defaultPrevented&&(e.preventDefault(),_||K(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[_,K]);let J=e=>e?B[x(e)]:void 0,M=(e,t)=>D(l=>({...l,[e]:{...l[e],...t}})),$=e=>{e&&C(t=>({...t,[x(e.repoDir)]:e}))},G=()=>{s.FH.runVcs(p.sessionIds).then(q).catch(()=>q([]))},Z=()=>{U.current.clear(),T({kind:"choose"})},Q=async function(){var e;let t,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O("");let r=(()=>{var e,t;let l={},r=new Map;for(let n of null!=(e=null==k?void 0:k.sessions)?e:[]){let e=S[n.id],s=J(n.repoDir);if(!e||!n.repoDir||!s||s.problem||"keep"===e.from)continue;let a=n.fixed?{rechoose:!0}:{};if("previous-session"===e.from)l[n.id]={from:"previous-session",...a};else if("current"===e.from){if(!s.current)return{problem:f("startdlg.needBranch",{name:n.name})};l[n.id]={from:"local",branch:s.current,...e.onBranch?{onBranch:!0}:{},...a}}else if("local"===e.from){if(!e.local||!s.local.some(t=>t.name===e.local))return{problem:f("startdlg.needBranch",{name:n.name})};l[n.id]={from:"local",branch:e.local,...e.onBranch?{onBranch:!0}:{},...a}}else{let c=e.remoteBranch.trim();if(!e.remote||!c)return{problem:f("startdlg.needBranch",{name:n.name})};l[n.id]={from:"remote",remote:e.remote,branch:c,...e.onBranch?{onBranch:!0}:{},...a};let i="".concat(x(n.repoDir),"|").concat(e.remote),o=null!=(t=r.get(i))?t:{key:i,dir:s.repoDir,remote:e.remote,branches:[]};o.branches.includes(c)||o.branches.push(c),r.set(i,o)}}return{starts:l,groups:[...r.values()].map(e=>({...e,key:"".concat(e.key,"|").concat([...e.branches].sort().join(","))}))}})();if("problem"in r)return void O(r.problem);if(!l.skipFetch)for(let e of r.groups){if(U.current.has(e.key))continue;T({kind:"fetching",what:e.branches.map(t=>"".concat(e.remote,"/").concat(t)).join(", ")});let t=await s.FH.startFetch(e.dir,e.remote,e.branches).catch(e=>({ok:!1,problem:e.message,missing:[]}));if($(t.repo),!t.ok)return void T({kind:"fetchFailed",group:e,result:t})}T({kind:"starting"});try{t=await p.start(r.starts)}catch(e){t={started:!1,reason:e.message}}if(V.current=t,t.started)return void K(!0);T({kind:"failed",reply:t}),(null==(e=t.failure)?void 0:e.stage)==="preflight"&&G()},Y=async(e,t)=>{I("".concat(x(e),"|").concat(t)),R(l=>({...l,[x(e)]:f("startdlg.fetching",{what:t})}));try{let l=await s.FH.startFetch(e,t);$(l.repo),R(r=>{var n,s,a,c;return{...r,[x(e)]:l.ok?"":"".concat(f("startdlg.fetchFailed",{what:t})," ").concat(null!=(c=null!=(a=l.problem)?a:null==(n=l.fetched)?void 0:n.detail)?c:"").concat((null==(s=l.fetched)?void 0:s.auth)?" ".concat(f("prep.fetchAuth")):"")}})}catch(t){R(l=>({...l,[x(e)]:t.message}))}finally{I("")}},ee=async e=>{try{await navigator.clipboard.writeText(e),z(!0),window.setTimeout(()=>z(!1),2500)}catch(e){O(f("plan.copyFailed"))}},et=Object.values(S).some(e=>"remote"===e.from),el=(null!=(h=null==k?void 0:k.sessions)?h:[]).filter(e=>e.vcs),er=1===el.length?(e=>{var t,l,r;let n=S[e.id],s=J(e.repoDir);if(!n||!s)return;let a=e=>e?" @ ".concat(e.slice(0,8)):"";return"keep"===n.from?e.fixed&&(null==(t=e.started)?void 0:t.branch)?"".concat(e.started.branch).concat(a(null!=(r=e.started.tipNow)?r:e.started.recorded)):void 0:"current"===n.from?s.current?"".concat(s.current).concat(a(s.head)):void 0:"local"===n.from?"".concat(n.local).concat(a(null==(l=s.local.find(e=>e.name===n.local))?void 0:l.commit)):"remote"===n.from&&n.remoteBranch.trim()?"".concat(n.remote,"/").concat(n.remoteBranch.trim()):void 0})(el[0]):void 0,en=er?f("unattended"===p.mode?"startdlg.goUnattendedOn":"startdlg.goStepOn",{where:er}):"unattended"===p.mode?f("startdlg.goUnattended"):f("startdlg.goStep");return(0,r.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!_&&K(!1),children:(0,r.jsxs)("div",{ref:b,className:"modal wide start-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"".concat(v,"-title"),onClick:e=>e.stopPropagation(),style:{overflowWrap:"anywhere"},children:[(0,r.jsx)("h2",{id:"".concat(v,"-title"),children:f("startdlg.title")}),(0,r.jsxs)("p",{className:"small muted",style:{marginTop:0},children:[f("startdlg.intro")," ",k&&"choose"===E.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>void X(!0),disabled:_,children:f("startdlg.refresh")})]}),N&&(0,r.jsx)(o.X,{reason:N}),!k&&!N&&(0,r.jsx)("p",{className:"small",role:"status",children:f("startdlg.loading")}),k&&("choose"===E.kind||"fetching"===E.kind||"starting"===E.kind)&&k.sessions.map(e=>{var t,l,n,s,a,c,i,o,d,h,m,u;let p=J(e.repoDir),g=S[e.id],b="start-".concat(v,"-").concat(e.id),y=null!=(c=null==p||null==(t=p.remotes.find(e=>e.name===(null==g?void 0:g.remote)))?void 0:t.branches)?c:[];return(0,r.jsxs)("fieldset",{className:"option",style:{border:"1px solid var(--line)",borderRadius:"var(--radius)",padding:"8px 12px",margin:"10px 0"},children:[(0,r.jsx)("legend",{style:{padding:"0 4px"},children:(0,r.jsx)("strong",{children:e.name})}),e.repoDir&&(0,r.jsx)("p",{className:"muted small",style:{margin:"2px 0 6px"},children:f("startdlg.repoOn",{repo:e.repoDir,branch:null!=(i=null==p?void 0:p.current)?i:"HEAD"})}),e.vcs?p&&!p.problem&&g?e.fixed&&e.rechooseBlocked?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:f("startdlg.fixed",{start:e.fixed})}),(0,r.jsx)("p",{className:"muted small",children:f("startdlg.rechooseBlocked",{tasks:e.rechooseBlocked})})]}):(0,r.jsxs)(r.Fragment,{children:[e.fixed&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",style:{margin:"2px 0"},children:f("startdlg.fixed",{start:e.fixed})}),(null==(l=e.started)?void 0:l.branch)&&(0,r.jsxs)("p",{className:"small",style:{margin:"2px 0"},children:[e.started.tipNow?f("startdlg.branchNow",{branch:e.started.branch,now:e.started.tipNow.slice(0,8),recorded:(null!=(d=e.started.recorded)?d:"").slice(0,8)}):f("startdlg.branchGone",{branch:e.started.branch,recorded:(null!=(h=e.started.recorded)?h:"").slice(0,8)}),e.started.remote?" ".concat(f("startdlg.branchRemote",{name:e.started.remote.name,commit:e.started.remote.commit.slice(0,8)})):""]}),p.current&&(null==(n=e.started)?void 0:n.branch)&&p.current!==e.started.branch&&"per-task"!==e.started.mode&&(0,r.jsx)("p",{className:"notice caution small",style:{margin:"4px 0"},children:f("startdlg.differs",{current:p.current,head:(null!=(m=p.head)?m:"").slice(0,8),branch:e.started.branch})}),(0,r.jsx)("div",{className:"option",children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"keep"===g.from,onChange:()=>M(e.id,{from:"keep"}),disabled:_}),(0,r.jsx)("span",{children:(null==(s=e.started)?void 0:s.branch)?f("startdlg.keepStarted",{branch:e.started.branch}):f("startdlg.keepStartedNoBranch")})]})}),p.current&&p.current!==(null==(a=e.started)?void 0:a.branch)&&(0,r.jsx)("div",{className:"option",children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"current"===g.from,onChange:()=>M(e.id,{from:"current"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.useCurrent",{branch:p.current,commit:(null!=(u=p.head)?u:"").slice(0,8)})})]})})]}),e.prepared&&(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"keep"===g.from,onChange:()=>M(e.id,{from:"keep"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.keep")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.prepared",{start:e.prepared})})]}),(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"local"===g.from,onChange:()=>M(e.id,{from:"local"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.local")})]}),(0,r.jsx)("div",{className:"row",style:{marginTop:4},children:(0,r.jsxs)("select",{"aria-label":f("startdlg.localBranch"),value:g.local,onChange:t=>M(e.id,{from:"local",local:t.target.value}),disabled:_,style:{width:"auto",minWidth:240,maxWidth:"100%"},children:[!p.local.some(e=>e.name===g.local)&&(0,r.jsx)("option",{value:g.local,children:g.local}),p.local.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," \xb7 ",e.commit.slice(0,8)]},e.name))]})}),(0,r.jsx)("p",{className:"why",children:f("startdlg.localWhy")})]}),(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"remote"===g.from,onChange:()=>M(e.id,{from:"remote"}),disabled:_||0===p.remotes.length}),(0,r.jsx)("span",{children:f("startdlg.remote")})]}),0===p.remotes.length?(0,r.jsx)("p",{className:"muted small",children:f("startdlg.noRemote")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",style:{marginTop:4},children:[p.remotes.length>1&&(0,r.jsx)("select",{"aria-label":f("startdlg.remoteName"),value:g.remote,onChange:t=>M(e.id,{from:"remote",remote:t.target.value}),disabled:_,style:{width:"auto"},children:p.remotes.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))}),1===p.remotes.length&&(0,r.jsxs)("code",{children:[g.remote,"/"]}),(0,r.jsx)("input",{type:"text","aria-label":f("startdlg.remoteBranch"),list:"".concat(b,"-remote"),value:g.remoteBranch,onChange:t=>M(e.id,{from:"remote",remoteBranch:t.target.value}),onFocus:()=>"remote"!==g.from&&M(e.id,{from:"remote"}),disabled:_,style:{width:"auto",minWidth:240,flex:"1 1 240px"},placeholder:"main"}),(0,r.jsx)("datalist",{id:"".concat(b,"-remote"),children:y.map(e=>(0,r.jsx)("option",{value:e.name},e.name))}),(0,r.jsx)("button",{type:"button",onClick:()=>void Y(p.repoDir,g.remote),disabled:_||!g.remote,children:f("startdlg.refreshRemote")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.remoteWhy")}),(0,r.jsx)("p",{className:"muted small",style:{margin:"2px 0"},children:p.lastFetched?f("startdlg.lastFetched",{when:j(p.lastFetched)}):y.length>0?f("startdlg.lastFetchedUnknown"):f("startdlg.neverFetched")}),L[x(p.repoDir)]&&(0,r.jsx)("p",{className:"small",role:"status",children:L[x(p.repoDir)]})]})]}),e.previousOffered&&(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"previous-session"===g.from,onChange:()=>M(e.id,{from:"previous-session"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.previous")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.previousWhy")})]}),(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:g.onBranch&&("local"===g.from||"remote"===g.from||"current"===g.from),onChange:t=>M(e.id,{onBranch:t.target.checked}),disabled:_||"local"!==g.from&&"remote"!==g.from&&"current"!==g.from}),(0,r.jsx)("span",{children:f("startdlg.onBranch")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.onBranchWhy")})]}),e.fixed&&"keep"!==g.from&&(0,r.jsx)("p",{className:"notice caution small",children:f("startdlg.rechooseNote")})]}):e.fixed?(0,r.jsx)("p",{className:"small",children:f("startdlg.fixed",{start:e.fixed})}):(0,r.jsx)("p",{className:"err small",children:f("startdlg.repoProblem",{problem:null!=(o=null==p?void 0:p.problem)?o:""})}):(0,r.jsx)("p",{className:"small",children:f("startdlg.vcsOff")})]},e.id)}),"fetching"===E.kind&&(0,r.jsx)("p",{className:"notice small",role:"status",children:f("startdlg.fetching",{what:E.what})}),"starting"===E.kind&&(0,r.jsx)("p",{className:"notice small",role:"status",children:f("startdlg.starting")}),"fetchFailed"===E.kind&&(0,r.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,r.jsxs)("p",{style:{marginTop:0},children:[(0,r.jsx)("strong",{children:f("startdlg.fetchFailed",{what:E.group.branches.map(e=>"".concat(E.group.remote,"/").concat(e)).join(", ")})})," ",(0,r.jsx)("code",{children:null!=(u=null!=(m=E.result.problem)?m:null==(t=E.result.fetched)?void 0:t.detail)?u:""})]}),E.result.missing.length>0&&(0,r.jsx)("p",{className:"small",children:f("startdlg.missing",{names:E.result.missing.join(", ")})}),(null==(l=E.result.fetched)?void 0:l.auth)&&(0,r.jsx)("p",{className:"small",children:f("prep.fetchAuth")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{type:"button",className:"primary",onClick:()=>void Q(),children:f("startdlg.retryFetch")}),(()=>{var e,t;let l=J(E.group.dir),n=null!=(t=null==l||null==(e=l.remotes.find(e=>e.name===E.group.remote))?void 0:e.branches)?t:[];return E.group.branches.every(e=>n.some(t=>t.name===e))?(0,r.jsx)("button",{type:"button",onClick:()=>{U.current.add(E.group.key),Q()},children:f("startdlg.useFetched")}):null})(),(0,r.jsx)("button",{type:"button",className:"quiet",onClick:Z,children:f("startdlg.back")})]}),(()=>{var e,t;let l=J(E.group.dir),n=null!=(t=null==l||null==(e=l.remotes.find(e=>e.name===E.group.remote))?void 0:e.branches)?t:[],s=E.group.branches.filter(e=>!n.some(t=>t.name===e));return s.length>0?(0,r.jsx)("p",{className:"muted small",children:f("startdlg.useFetchedNo",{what:s.map(e=>"".concat(E.group.remote,"/").concat(e)).join(", ")})}):E.result.lastFetched?(0,r.jsx)("p",{className:"muted small",children:f("prep.lastFetched",{when:j(E.result.lastFetched)})}):null})(),E.result.fetchCommand&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",style:{marginTop:8},children:f("prep.ownTerminal")}),(0,r.jsx)("pre",{className:"sync-cmd",children:E.result.fetchCommand}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{var e;ee(null!=(e=E.result.fetchCommand)?e:"")},children:f("prep.copyFetch")}),P&&(0,r.jsx)("span",{className:"badge done",children:f("prep.copied")})]})]})]}),"failed"===E.kind&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.X,{failure:E.reply.failure,reason:E.reply.reason}),(null==(d=E.reply.failure)?void 0:d.stage)==="preflight"&&A.some(e=>!e.ready)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:f("startdlg.vcsFix")}),(0,r.jsx)(i.w,{groups:A,sessionIds:p.sessionIds,onChange:()=>{G(),X()}})]})]}),H&&(0,r.jsx)("p",{className:"err small",role:"alert",children:H}),"choose"===E.kind&&et&&(0,r.jsx)("p",{className:"why",children:f("prep.password")}),(0,r.jsxs)("div",{className:"row modal-actions",children:[(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(!1),disabled:_,children:f("dialog.cancel")}),"failed"===E.kind?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:Z,children:f("startdlg.back")}),(0,r.jsx)("button",{type:"button",className:"primary",onClick:()=>void Q({skipFetch:!0}),children:f("startdlg.tryAgain")})]}):"fetchFailed"!==E.kind&&(0,r.jsx)("button",{ref:y,type:"button",className:"primary",onClick:()=>void Q(),disabled:_||!k,children:en})]})]})})}},3069:(e,t,l)=>{l.d(t,{$:()=>h,X:()=>i});var r=l(3365),n=l(1521),s=l(5549),a=l(867),c=l(7527);function i(e){var t,l;let{failure:n,reason:c,onDismiss:i,intro:o,children:d}=e,{t:h}=(0,a.kj)(),m=(0,a.W3)(),u=null!=(l=null!=(t=null==n?void 0:n.message)?t:c)?l:"";return(0,r.jsxs)("div",{className:"notice caution start-failure",role:"alert",style:{overflowWrap:"anywhere"},children:[o&&(0,r.jsx)("p",{className:"small",style:{marginTop:0},children:o}),(0,r.jsx)("strong",{children:h("startfail.title")}),n&&(0,r.jsx)("p",{className:"small",style:{margin:"4px 0"},children:h("startfail.where",{stage:h("startfail.stage.".concat(n.stage))})}),(0,r.jsx)("pre",{className:"sync-cmd small",style:{margin:"6px 0"},children:u}),d,n&&(0,r.jsxs)("p",{className:"muted small",style:{margin:"4px 0"},children:[n.runId?h("startfail.when",{when:m(n.at),run:n.runId}):h("startfail.whenNoRun",{when:m(n.at)}),n.sessions.length>0?" \xb7 ".concat(n.sessions.map(e=>'"'.concat(e,'"')).join(", ")):""]}),(0,r.jsxs)("div",{className:"row",style:{marginTop:6},children:[n&&(0,r.jsx)("a",{className:"button-link",href:s.FH.startFailureUrl(n.id),download:!0,children:h("startfail.download")}),(0,r.jsx)("a",{className:n?"button-link":"button-link plain",href:s.FH.terminalUrl(),download:!0,children:h("startfail.terminal")}),i&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:i,children:h("startfail.dismiss")})]}),(0,r.jsx)("p",{className:"why",children:h("startfail.downloadWhy")})]})}let o="cop.startFailure.dismissed";function d(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(o))?e:"[]");return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}catch(e){return[]}}function h(){let{t:e}=(0,a.kj)(),[t,l]=(0,n.useState)([]),[h,m]=(0,n.useState)([]);(0,c.z)(()=>s.FH.startFailures(!0).then(e=>{l(e),m(d())}).catch(()=>void 0),5e3);let u=t.find(e=>!h.includes(e.id));return u?(0,r.jsx)("div",{style:{marginBottom:12},children:(0,r.jsx)(i,{failure:u,intro:e("at-turn"===u.stage?"startfail.laterSession":"startfail.later"),onDismiss:()=>{let e=[...new Set([...d(),u.id])].slice(-50);try{window.localStorage.setItem(o,JSON.stringify(e))}catch(e){}m(e)}})}):null}},3486:(e,t,l)=>{l.d(t,{w:()=>i});var r=l(3365),n=l(1521),s=l(5549),a=l(867);let c={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function i(e){let{groups:t,sessionIds:l,onChange:s}=e,{t:c}=(0,a.kj)(),[i,d]=(0,n.useState)(""),h=t.filter(e=>!e.ready);return 0===h.length?i?(0,r.jsxs)("p",{className:"notice small",role:"status",children:[(0,r.jsx)("strong",{children:c("runvcs.ready")})," ",i]}):null:(0,r.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,r.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:c("runvcs.title")}),(0,r.jsx)("p",{className:"small",children:c("runvcs.why")}),h.map(e=>(0,r.jsx)(o,{group:e,sessionIds:l,onChange:s,onDone:d},e.repoDir))]})}function o(e){var t;let{group:l,sessionIds:i,onChange:o,onDone:d}=e,{t:h}=(0,a.kj)(),[m,u]=(0,n.useState)(!1),[p,x]=(0,n.useState)(!1),[g,f]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[b,y]=(0,n.useState)({}),k=(e,t)=>{var l,r;return null!=(r=null!=(l=b[e])?l:t)?r:void 0},w=l.actions.find(e=>"snapshot-here"===e.id&&e.available),N=e=>(null!=e?e:"—").slice(0,8),F=async e=>{if("review-inputs"===e)return void u(e=>!e);f(!0),v("");try{var t,r,n;let a="snapshot-on-base"===e?Object.fromEntries(l.inputs.map(e=>[e.path,"include"])):Object.fromEntries(l.entries.filter(e=>k(e.path,e.choice)).map(e=>[e.path,k(e.path,e.choice)])),c=await s.FH.runVcsPrepare(i,l.repoDir,e,a);v(c.ok?null!=(t=c.result)?t:"":null!=(r=c.problem)?r:""),c.ok&&d("".concat(l.repoDir,": ").concat(null!=(n=c.result)?n:"")),o()}catch(e){v(e.message)}finally{f(!1)}};return(0,r.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,r.jsx)("table",{className:"small",children:(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.repo")}),(0,r.jsx)("td",{children:(0,r.jsx)("code",{children:l.repoDir})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.current")}),(0,r.jsxs)("td",{children:[(0,r.jsx)("code",{children:null!=(t=l.branch)?t:"HEAD"})," @ ",(0,r.jsx)("code",{children:N(l.head)})]})]}),l.workBranch&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.workBranch")}),(0,r.jsxs)("td",{children:[(0,r.jsx)("code",{children:l.workBranch.name})," @ ",(0,r.jsx)("code",{children:N(l.workBranch.head)})]})]}),l.baseBranch&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.base")}),(0,r.jsxs)("td",{children:[(0,r.jsx)("code",{children:l.baseBranch})," @ ",(0,r.jsx)("code",{children:N(l.baseHead)})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.sessions")}),(0,r.jsx)("td",{children:l.sessions.map(e=>"".concat(e.name," (").concat(h("runvcs.role.".concat(e.role)),")")).join(", ")})]}),l.inputPatterns.length>0&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.patterns")}),(0,r.jsx)("td",{children:l.inputPatterns.map(e=>(0,r.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),l.problem&&(0,r.jsxs)("p",{className:"small",children:[(0,r.jsx)("strong",{children:h("runvcs.problem")})," ",l.problem]}),l.inputs.length>0&&(0,r.jsx)("p",{className:"small",children:h("runvcs.inputsCount",{n:l.inputs.length})}),m&&l.inputs.length>0&&(0,r.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:l.inputs.map(e=>(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:e.path})," — ",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,s.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,r.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),l.unrelated.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:(0,r.jsx)("strong",{children:h("runvcs.unrelated",{n:l.unrelated.length})})}),(0,r.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:l.unrelated.slice(0,30).map(e=>(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),w&&l.entries.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:(0,r.jsx)("strong",{children:h("runvcs.choose",{n:l.entries.length})})}),(0,r.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:l.entries.map(e=>{var t;return(0,r.jsxs)("li",{style:{marginBottom:4},children:[(0,r.jsx)("code",{children:e.path})," ",(0,r.jsxs)("span",{className:"muted",children:["(",e.input?"".concat(h("vcs.snapshotInput"),", "):"",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,s.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,r.jsx)("span",{className:"err",children:h("vcs.snapshotBlocked")}):(0,r.jsx)("select",{"aria-label":e.path,value:null!=(t=k(e.path,e.choice))?t:"",onChange:t=>y({...b,[e.path]:t.target.value}),disabled:g||e.allowed.length<2,children:e.allowed.map(e=>(0,r.jsx)("option",{value:e,children:h("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,r.jsx)("div",{className:"muted",children:e.reason})]},e.path)})})]}),p?(0,r.jsxs)("p",{className:"small muted",children:[h("runvcs.cancelled")," ",(0,r.jsx)("button",{className:"quiet",onClick:()=>x(!1),children:h("runvcs.showAgain")})]}):(0,r.jsxs)("div",{children:[l.actions.map(e=>{var t,n,s;return(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void F(e.id),disabled:g||!e.available,children:[h(c[e.id],{branch:null!=(t=l.baseBranch)?t:"",current:null!=(n=l.branch)?n:"HEAD"}),"review-inputs"===e.id&&m?" ✓":""]}),e.recommended&&(0,r.jsx)("span",{className:"badge done",style:{marginLeft:6},children:h("runvcs.recommended")}),(0,r.jsx)("p",{className:"why",children:e.available?e.result:"".concat(h("runvcs.notNow")," ").concat(null!=(s=e.why)?s:"")})]},e.id)}),(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsx)("button",{className:"quiet",onClick:()=>x(!0),disabled:g,children:h("runvcs.cancel")}),(0,r.jsx)("p",{className:"why",children:h("runvcs.cancelWhy")})]})]}),j&&(0,r.jsx)("p",{className:"small",role:"status",children:j})]})}},4969:(e,t,l)=>{l.d(t,{V:()=>s});var r=l(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,t,l){(0,r.useEffect)(()=>{var r,s;if(!t)return;let a=document.activeElement instanceof HTMLElement?document.activeElement:null,c=e.current,i=null!=(s=null!=(r=null==l?void 0:l.current)?r:null==c?void 0:c.querySelector(n))?s:null;null==i||i.focus();let o=e=>{if("Tab"!==e.key||!c)return;let t=Array.from(c.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let l=t[0],r=t[t.length-1],s=c.contains(document.activeElement);e.shiftKey&&(document.activeElement===l||!s)?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r&&s||(e.preventDefault(),l.focus())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),a&&document.contains(a)&&a.focus()}},[e,t,l])}},7527:(e,t,l)=>{l.d(t,{z:()=>n});var r=l(1521);function n(e,t){let l=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=(0,r.useRef)(e);n.current=e,(0,r.useEffect)(()=>{let e;if(!l)return;let r=!1,s=async()=>{try{await n.current()}catch(e){}finally{r||(e=setTimeout(()=>void s(),t))}};return s(),()=>{r=!0,e&&clearTimeout(e)}},[t,l])}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[549],{5549:(t,o,e)=>{e.d(o,{AV:()=>a,Dh:()=>u,FH:()=>m,FZ:()=>r,Zm:()=>h,aT:()=>s,c5:()=>f,dK:()=>l,nC:()=>n,rt:()=>d,ub:()=>i,zi:()=>y});let n="/api";function s(t,o){return"/sessions/view?id=".concat(encodeURIComponent(t)).concat(o?"#".concat(o):"")}let c="cop-api-token";function a(){try{let t=/(?:^#|&)token=([0-9a-f]{16,})/i.exec(window.location.hash);if(t)return window.localStorage.setItem(c,t[1]),window.history.replaceState(null,"",window.location.pathname+window.location.search),t[1];return window.localStorage.getItem(c)||""}catch(t){return""}}function i(t){let o=a();return o?"".concat(t).concat(t.includes("?")?"&":"?","token=").concat(encodeURIComponent(o)):t}let r=["exit-zero","exit-nonzero","output-contains","output-omits","output-matches","file-exists","file-missing","file-contains"];function d(t){return t.startsWith("exit-")||t.startsWith("output-")}function l(t){return"output-contains"===t||"output-omits"===t||"output-matches"===t||"file-contains"===t}function h(t){return"limit-reached"===t.status||"aborted"===t.status||!!t.limit&&("failed"===t.status||"blocked"===t.status)}function u(t){return("failed"===t.status||"blocked"===t.status)&&"contract-conflict"!==t.stopCode}async function p(t,o){let e,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===s.timeoutMs?3e4:s.timeoutMs;try{var i;e=await fetch("".concat(n).concat(t),{...o,...null!==c&&!(null==o?void 0:o.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{},...null!=(i=null==o?void 0:o.headers)?i:{}}})}catch(o){if("TimeoutError"===o.name)throw Error("The API did not answer within ".concat(Math.round((null!=c?c:0)/1e3)," s (").concat(t.split("?")[0],"). It may be busy; try again."));throw o}if(!e.ok){let t="".concat(e.status," ").concat(e.statusText);try{let o=await e.json();(null==o?void 0:o.message)&&(t=Array.isArray(o.message)?o.message.join("; "):o.message)}catch(t){}throw Error(t)}let r=await e.text();return r?JSON.parse(r):void 0}let m={health:()=>p("/health"),doctor:()=>p("/doctor"),settings:()=>p("/settings"),saveSettings:t=>p("/settings",{method:"PUT",body:JSON.stringify(t)}),level1:()=>p("/level1"),setLevel1:t=>p("/level1",{method:"PUT",body:JSON.stringify({content:t})}),resetLevel1:()=>p("/level1",{method:"DELETE"}),presets:()=>p("/presets"),savePreset:(t,o)=>p("/presets/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:o})}),deletePreset:t=>p("/presets/".concat(encodeURIComponent(t)),{method:"DELETE"}),personas:()=>p("/personas"),savePersona:(t,o)=>p("/personas/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:o})}),deletePersona:t=>p("/personas/".concat(encodeURIComponent(t)),{method:"DELETE"}),sessions:()=>p("/sessions"),reorderSessions:t=>p("/sessions-order",{method:"PUT",body:JSON.stringify({ids:t})}),metrics:()=>p("/metrics"),preparePreview:function(t){let o=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return p("/repo/prepare/preview",{method:"POST",body:JSON.stringify({dir:t,fetch:o})},{timeoutMs:33e4})},prepareProject:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return p("/repo/prepare",{method:"POST",body:JSON.stringify({dir:t,fingerprint:o,...e})})},session:t=>p("/sessions/".concat(t)),createSession:(t,o)=>p("/sessions",{method:"POST",body:JSON.stringify({name:t,projectDir:o})}),updateSession:(t,o)=>p("/sessions/".concat(t),{method:"PUT",body:JSON.stringify(o)}),deleteSession:t=>p("/sessions/".concat(t),{method:"DELETE"}),addTask:(t,o)=>p("/sessions/".concat(t,"/tasks"),{method:"POST",body:JSON.stringify(o)}),updateTask:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o),{method:"PUT",body:JSON.stringify(e)}),deleteTask:(t,o)=>p("/sessions/".concat(t,"/tasks/").concat(o),{method:"DELETE"}),continueTask:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/continue"),{method:"POST",body:JSON.stringify((null==e?void 0:e.trim())?{instruction:e}:{})}),rerunTask:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return p("/sessions/".concat(t,"/tasks/").concat(o,"/rerun"),{method:"POST",body:JSON.stringify({...e,...n.buildOnFinished?{buildOnFinished:!0}:{}})})},taskChanges:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/changes").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskChangeFile:(t,o,e,n)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/changes/file?path=").concat(encodeURIComponent(e)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/story").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskFiles:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/files").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskLogUrl:(t,o,e)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(o,"/log").concat(e?"?run=".concat(encodeURIComponent(e)):""),taskFileUrl:(t,o,e,s,c)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(o,"/files/").concat(e,"/").concat(encodeURIComponent(s)).concat(c?"?run=".concat(encodeURIComponent(c)):""),saveTaskLog:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/log").concat(e?"?run=".concat(encodeURIComponent(e)):""),{method:"POST",body:"{}"}),saveTaskFile:(t,o,e,n,s)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/files/").concat(e,"/").concat(encodeURIComponent(n)).concat(s?"?run=".concat(encodeURIComponent(s)):""),{method:"POST",body:"{}"}),start:(t,o,e,n)=>p("/sessions/".concat(t,"/start"),{method:"POST",body:JSON.stringify({mode:o,name:e,starts:n})},{timeoutMs:12e4}),startOptions:t=>p("/start/options?sessions=".concat(encodeURIComponent(t.join(",")))),startFetch:(t,o,e)=>p("/start/fetch",{method:"POST",body:JSON.stringify({dir:t,remote:o,...e?{branches:e}:{}})},{timeoutMs:33e4}),startFailures:function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return p("/start/failures".concat(t?"?unanswered=1":""))},startFailureUrl:t=>i("".concat(n,"/start/failures/").concat(encodeURIComponent(t),"/report")),terminalUrl:()=>i("".concat(n,"/terminal")),stop:t=>p("/sessions/".concat(t,"/stop"),{method:"POST",body:"{}"}),approvals:t=>p("/approvals".concat(t?"?session=".concat(encodeURIComponent(t)):"")),undoPreview:(t,o)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/undo")),undoTask:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/undo"),{method:"POST",body:JSON.stringify({how:e})}),acceptTask:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/accept"),{method:"POST",body:JSON.stringify((null==e?void 0:e.trim())?{note:e}:{})}),addTaskNote:(t,o,e)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/notes"),{method:"POST",body:JSON.stringify({text:e})}),kerriganReport:t=>p("/kerrigan/report",{method:"POST",body:JSON.stringify(t)}),checkChanges:t=>p("/changes/check",{method:"POST",body:JSON.stringify({text:t})}),applyChanges:t=>p("/changes/apply",{method:"POST",body:JSON.stringify({text:t})}),workspace:()=>p("/workspace"),workspaceFiles:()=>p("/workspace/files"),workspaceFile:t=>p("/workspace/file?path=".concat(encodeURIComponent(t))),chatThreads:()=>p("/chat/threads"),chatSend:(t,o,e,n)=>p("/chat",{method:"POST",body:JSON.stringify({text:t,...o?{threadId:o}:{},...e?{model:e}:{},...n?{manualModel:!0}:{}})}),chatRewind:(t,o)=>p("/chat/".concat(t,"/rewind"),{method:"POST",body:JSON.stringify({taskId:o})}),repoTree:function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=arguments.length>2?arguments[2]:void 0;return p("/sessions/".concat(t,"/repo/tree?path=").concat(encodeURIComponent(o)).concat(e?"&task=".concat(encodeURIComponent(e)):""))},repoFile:(t,o,e)=>p("/sessions/".concat(t,"/repo/file?path=").concat(encodeURIComponent(o)).concat(e?"&task=".concat(encodeURIComponent(e)):"")),repoLog:t=>p("/sessions/".concat(t,"/repo/log")),sessionEvents:t=>p("/sessions/".concat(t,"/events")),decidePlan:(t,o,e)=>p("/approvals/".concat(t,"/plan"),{method:"POST",body:JSON.stringify({action:o,...(null==e?void 0:e.trim())?{note:e}:{}})}),decide:(t,o)=>p("/approvals/".concat(t),{method:"POST",body:JSON.stringify({action:o})}),setRunMode:(t,o)=>p("/sessions/".concat(t,"/mode"),{method:"POST",body:JSON.stringify({mode:o})}),streamUrl:t=>i("".concat(n,"/sessions/").concat(t,"/stream")),batch:()=>p("/batch").then(t=>null!=t?t:null),startBatch:(t,o,e,n,s,c,a,i)=>p("/batch/start",{method:"POST",body:JSON.stringify({sessionIds:t,mode:o,onFailure:e,model:n,reviewModel:s,name:c,taskIds:a,starts:i})},{timeoutMs:12e4}),suggestedRunName:t=>p("/batch/name?sessions=".concat(encodeURIComponent(t.join(",")))),stopBatch:()=>p("/batch/stop",{method:"POST",body:"{}"}),pauseBatch:()=>p("/batch/pause",{method:"POST",body:"{}"}),resumeBatch:()=>p("/batch/resume",{method:"POST",body:"{}"}),planBrief:t=>p("/plan/brief?lang=".concat(encodeURIComponent(t))),context:(t,o)=>p("/context/".concat(t,"?lang=").concat(encodeURIComponent(o))),setContext:(t,o)=>p("/context/".concat(t),{method:"PUT",body:JSON.stringify({content:o})}),resetContext:(t,o)=>p("/context/".concat(t,"?lang=").concat(encodeURIComponent(o)),{method:"DELETE"}),checkPlan:t=>p("/plan/check",{method:"POST",body:JSON.stringify({text:t})}),importPlan:t=>p("/plan/import",{method:"POST",body:JSON.stringify({text:t})}),browseFolder:t=>p("/browse-folder",{method:"POST",body:JSON.stringify({start:t})},{timeoutMs:null}),tasks:()=>p("/tasks"),activity:()=>p("/activity"),downloadBundle:async t=>{var o,e,s;let c=await fetch("".concat(n,"/export/bundle"),{method:"POST",headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{}},body:JSON.stringify({tasks:t})});if(!c.ok)throw Error(await c.text()||"".concat(c.status," ").concat(c.statusText));let i=null!=(s=c.headers.get("content-disposition"))?s:"",r=null==(o=/filename\*=UTF-8''([^;]+)/i.exec(i))?void 0:o[1],d=null==(e=/filename="([^"]+)"/i.exec(i))?void 0:e[1],l=null!=d?d:"copilot-operator-bundle.json";if(r)try{l=decodeURIComponent(r)}catch(t){}let h=URL.createObjectURL(await c.blob()),u=document.createElement("a");return u.href=h,u.download=l,document.body.appendChild(u),u.click(),u.remove(),setTimeout(()=>URL.revokeObjectURL(h),1e4),l},exportUrl:(t,o)=>{let e=new URLSearchParams;return o.run&&e.set("run",o.run),o.session&&e.set("session",o.session),o.task&&e.set("task",o.task),i("".concat(n,"/export/").concat(t,"?").concat(e.toString()))},taskExchangeUrl:(t,o)=>i("".concat(n,"/sessions/").concat(encodeURIComponent(t),"/tasks/").concat(encodeURIComponent(o),"/exchange")),debugExportUrl:t=>i("".concat(n,"/debug/export").concat(t.length>0?"?sessions=".concat(encodeURIComponent(t.join(","))):"")),vcsStatus:t=>p("/sessions/".concat(t,"/vcs")),runVcs:t=>p("/batch/vcs?ids=".concat(encodeURIComponent(t.join(",")))),runVcsPrepare:function(t,o,e){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return p("/batch/vcs/prepare",{method:"POST",body:JSON.stringify({sessionIds:t,repoDir:o,action:e,choices:n})})},vcsSnapshot:(t,o)=>p("/sessions/".concat(t,"/vcs/snapshot"),{method:"POST",body:JSON.stringify({choices:o})}),restorePreview:(t,o)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/restore")),restore:(t,o)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/restore"),{method:"POST",body:"{}"}),contractCheck:(t,o)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/contract")),applyContractFix:(t,o,e,n)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/contract-fix"),{method:"POST",body:JSON.stringify({choices:e,expect:n})}),restartPlan:(t,o)=>p("/sessions/".concat(t,"/tasks/").concat(o,"/restart")),restartFrom:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return p("/sessions/".concat(t,"/tasks/").concat(o,"/restart"),{method:"POST",body:JSON.stringify(e)})},repoCheck:t=>p("/repo?dir=".concat(encodeURIComponent(t))),project:()=>p("/project"),setProject:t=>p("/project",{method:"PUT",body:JSON.stringify(t)}),models:()=>p("/models"),setDefaultModel:t=>p("/models/default",{method:"PUT",body:JSON.stringify({model:t})}),setDefaultReviewModel:t=>p("/models/review-default",{method:"PUT",body:JSON.stringify({model:t})}),refreshModels:()=>p("/models/refresh",{method:"POST",body:"{}"},{timeoutMs:null}),login:t=>p("/login",{method:"POST",body:JSON.stringify({account:(null==t?void 0:t.trim())||void 0})},{timeoutMs:null})};function y(t){return t<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")}function f(t){if(void 0===t)return"";let o=Math.round(t/1e3);if(o<60)return"".concat(o,"s");let e=Math.floor(o/60);return e<60?"".concat(e,"m ").concat(o%60,"s"):"".concat(Math.floor(e/60),"h ").concat(e%60,"m")}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[699],{1366:(e,t,s)=>{s.d(t,{w:()=>i,y:()=>r});var a=s(3365),n=s(1521),l=s(867);function r(e){let{readOnly:t,scope:s,onReadOnly:r,onScope:i}=e,{t:o}=(0,l.kj)(),d=(0,n.useId)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"option",style:{marginTop:10},children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:e=>r(e.target.checked)}),(0,a.jsx)("span",{children:o("task.readOnlyEdit")})]}),(0,a.jsx)("p",{className:"why",children:o("task.readOnlyEditWhy")})]}),(0,a.jsx)("label",{htmlFor:"".concat(d,"-scope"),children:o("task.scopeEdit")}),(0,a.jsx)("textarea",{id:"".concat(d,"-scope"),value:s,onChange:e=>i(e.target.value),placeholder:"tests/e2e/\nsrc/**/*.ts",style:{minHeight:60},disabled:t}),(0,a.jsx)("p",{className:"why",children:o("task.scopeEditWhy")})]})}function i(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}},1910:(e,t,s)=>{s.d(t,{H:()=>o,u:()=>i});var a=s(3365),n=s(1521),l=s(867),r=s(5549);function i(e){let{label:t,save:s}=e,{t:r}=(0,l.kj)(),[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)(""),[u,m]=(0,n.useState)(!1),h=async()=>{o(!0),c("");try{var e;let t=await s();m(!1),c(t.revealed?r("save.done",{path:t.path}):r("save.savedOnly",{path:t.path,note:null!=(e=t.note)?e:""}))}catch(e){m(!0),c(r("save.failed",{problem:e.message}))}finally{o(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"linkish",disabled:i,title:r("save.why"),onClick:()=>void h(),children:i?r("save.saving"):t}),d&&(0,a.jsx)("span",{className:u?"err small":"muted small",children:d})]})}function o(e){let{sessionId:t,taskId:s,attempt:i}=e,{t:o}=(0,l.kj)(),[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(""),[h,p]=(0,n.useState)(!1),f=async()=>{c(!0),m("");try{let e=await r.FH.downloadBundle([{sessionId:t,taskId:s,attempt:i}]);p(!1),m(o("reg.bundleSaved",{name:e}))}catch(e){p(!0),m(o("save.failed",{problem:e.message}))}finally{c(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"linkish",disabled:d,title:o("save.attemptRecordWhy"),onClick:()=>void f(),children:d?o("save.saving"):o("save.attemptRecord")}),u&&(0,a.jsx)("span",{className:h?"err small":"muted small",children:u})]})}},3041:(e,t,s)=>{s.d(t,{e:()=>i});var a=s(1521),n=s(5549),l=s(1035),r=s(867);function i(e){let{t}=(0,r.kj)(),[s,i]=(0,a.useState)(""),[o,d]=(0,a.useState)({taskId:"",text:""}),c=(e,t)=>d({taskId:e,text:t}),u=(0,a.useCallback)(async s=>{i("restore"),c(s.taskId,"");try{var a,r,o,d,u,m,h,p,f,g,k,v,x,j;let i=await n.FH.restorePreview(s.sessionId,s.taskId);if(!i.ok)return void c(s.taskId,t("restore.cannot",{problem:null!=(o=i.problem)?o:""}));let y={repo:i.repoDir,title:s.title,branch:null!=(d=i.branchName)?d:"",commit:(null!=(u=i.baseCommit)?u:"").slice(0,8)},b=i.leftBehind.length>0?t("restore.confirmLosing",{...y,n:i.leftBehind.length,kept:null!=(m=i.keptOn)?m:"",list:i.leftBehind.slice(0,10).join("\n")}):t("restore.confirm",y);if(!await (0,l.Z)(b))return;let N=await n.FH.restore(s.sessionId,s.taskId);if(!N.ok)return void c(s.taskId,t("restore.failed",{problem:null!=(h=N.problem)?h:""}));c(s.taskId,(null!=(p=null==(a=N.leftBehind)?void 0:a.length)?p:0)>0?t("restore.done",{branch:null!=(f=N.branch)?f:"",commit:(null!=(g=N.commit)?g:"").slice(0,8),n:null!=(k=null==(r=N.leftBehind)?void 0:r.length)?k:0,kept:null!=(v=N.keptOn)?v:""}):t("restore.doneNothing",{branch:null!=(x=N.branch)?x:"",commit:(null!=(j=N.commit)?j:"").slice(0,8)})),e()}catch(e){c(s.taskId,e.message)}finally{i("")}},[t,e]),m=(0,a.useCallback)(async s=>{i("restart"),c(s.taskId,"");try{var a,r,o;let i=await n.FH.restartPlan(s.sessionId,s.taskId);if(!i.ok)return void c(s.taskId,t("restart.cannot",{problem:null!=(a=i.problem)?a:""}));let d=i.restores.filter(e=>!e.ok);if(d.length>0)return void c(s.taskId,t("restart.cannot",{problem:d.map(e=>{var t;return"".concat(e.repoDir,": ").concat(null!=(t=e.problem)?t:"")}).join(" | ")}));let u=i.restores.map(e=>{var s,a,n,l,r;return[t("restart.repoLine",{repo:e.repoDir,commit:(null!=(s=e.baseCommit)?s:"").slice(0,8),branch:null!=(a=e.branchName)?a:"",n:e.leftBehind.length,kept:null!=(n=e.keptOn)?n:""}),...e.leftBehind.length>0?[t("restart.commitsHead",{kept:null!=(l=e.keptOn)?l:""})]:[],...e.leftBehind.slice(0,15).map(e=>" ".concat(e)),...e.leftBehind.length>15?[t("restart.commitsMore",{n:e.leftBehind.length-15})]:[],...(null!=(r=e.laterSessions)?r:[]).flatMap(e=>[t("restart.laterSession",{session:e.sessionName,n:e.commits.length,branch:e.branch}),...e.commits.slice(0,15).map(e=>" ".concat(e)),...e.commits.length>15?[t("restart.commitsMore",{n:e.commits.length-15})]:[]])].join("\n")}).join("\n"),m=i.tasks.map(e=>" ".concat(e.sessionName," / ").concat(e.title).concat(e.alreadyQueued?t("restart.alreadyQueued"):t("restart.taskRedo",{status:t("status.".concat(e.status))}))).join("\n"),h="unattended"===i.mode&&!!i.unattendedRefused,p=t("restart.confirm",{title:i.from.title,tasks:i.tasks.length,sessions:i.sessions.length,list:m,repos:u||t("restart.noRepo"),mode:t("unattended"!==i.mode||h?"run.confirm":"run.unattended")})+(h?t("restart.stepByStep",{reason:null!=(r=i.unattendedRefused)?r:""}):"");if(!await (0,l.Z)(p))return;let f=await n.FH.restartFrom(s.sessionId,s.taskId,h?{mode:"confirm"}:{});if(!f.started){c(s.taskId,t("restart.failed",{problem:null!=(o=f.reason)?o:""})),e();return}c(s.taskId,t("restart.started",{requeued:f.requeued,repos:f.restored.length})),e()}catch(e){c(s.taskId,e.message)}finally{i("")}},[t,e]);return{busy:s,message:o.text,messageTask:o.taskId,clearMessage:()=>c("",""),restore:u,restartFrom:m}}},3523:(e,t,s)=>{function a(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now();if(!e)return;let a=Date.parse(e);if(Number.isNaN(a))return;let n=t?Date.parse(t):s;return Number.isNaN(n)?void 0:Math.max(0,n-a)}function n(e){return!!e.startedAt&&!e.finishedAt&&"queued"!==e.status}function l(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),a=t.some(e=>n(e)),l=t.map(e=>e.finishedAt?Date.parse(e.finishedAt):NaN).filter(e=>!Number.isNaN(e)),r=Date.parse(e.startedAt),i=a||0===l.length?s:Math.max(...l);return{ms:Number.isNaN(r)?0:Math.max(0,i-r),live:a,tasks:t.length}}function r(e){var t,s;let a=new Map;for(let s of e){if(!s.runGroup)continue;let e=null!=(t=a.get(s.runGroup.id))?t:{run:s.runGroup,tasks:[]};e.tasks.push(s),a.set(s.runGroup.id,e)}return null!=(s=[...a.values()].sort((e,t)=>Date.parse(t.run.startedAt)-Date.parse(e.run.startedAt))[0])?s:null}s.d(t,{DG:()=>n,d5:()=>a,eZ:()=>l,hH:()=>r})},6983:(e,t,s)=>{s.d(t,{J:()=>d});var a=s(3365),n=s(1521),l=s(5549),r=s(867),i=s(4969),o=s(287);function d(e){var t,s,d,c,u;let{sessionId:m,taskId:h,title:p,onClose:f}=e,{t:g}=(0,r.kj)(),k=(0,n.useId)(),[v,x]=(0,n.useState)(null),[j,y]=(0,n.useState)(""),[b,N]=(0,n.useState)(""),[w,I]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),F=(0,n.useRef)(null),B=(0,n.useRef)(null);(0,i.V)(F,!0,B),(0,n.useEffect)(()=>{let e=!0;return l.FH.session(m).then(t=>{var s;e&&x(null!=(s=t.tasks.find(e=>e.id===h))?s:null)}).catch(t=>{e&&N(t.message)}),()=>{e=!1}},[m,h]),(0,n.useEffect)(()=>{let e=e=>{"Escape"!==e.key||e.defaultPrevented||w||document.querySelector('[role="alertdialog"]')||f(C)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,C,f]);let D=async()=>{if(j.trim()){I(!0),N("");try{await l.FH.continueTask(m,h,j),N(g("fup.saved",{title:p})),S(!0)}catch(e){N(e.message)}finally{I(!1)}}},H=(null!=(c=null==v?void 0:v.checkResults)?c:[]).filter(e=>!e.passed),E=(null==v||null==(t=v.review)?void 0:t.verdict)==="fail"&&null!=(u=v.review.findings)?u:[],R=null==v||null==(s=v.vcs)?void 0:s.branch,M=null==v||null==(d=v.vcs)?void 0:d.commit;return(0,a.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!w&&f(C),children:(0,a.jsxs)("div",{ref:F,className:"modal wide",role:"dialog","aria-modal":"true","aria-labelledby":"".concat(k,"-title"),onClick:e=>e.stopPropagation(),style:{overflowWrap:"anywhere"},children:[(0,a.jsx)("h2",{id:"".concat(k,"-title"),children:g("fup.title",{title:p})}),C?(0,a.jsx)(o.f,{target:{sessionId:m,taskId:h,title:p},intro:"".concat(b," ").concat(g("runq.ask")),focusFirst:!0,onClose:()=>f(!0)}):v?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"notice caution small",children:[(0,a.jsx)("strong",{children:g("fup.ended",{status:g("status.".concat(v.status))})}),v.reason&&(0,a.jsx)("p",{style:{margin:"4px 0"},children:v.reason}),H.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{style:{marginTop:6},children:g("fup.failedChecks")}),(0,a.jsx)("ul",{style:{margin:"2px 0",paddingLeft:18},children:H.slice(0,10).map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("code",{children:e.name}),": ",e.detail]},e.name))})]}),E.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{style:{marginTop:6},children:g("fup.findings")}),(0,a.jsx)("ul",{style:{margin:"2px 0",paddingLeft:18},children:E.slice(0,10).map((e,t)=>(0,a.jsxs)("li",{children:[e.what,e.where?" (".concat(e.where,")"):""]},t))})]}),v.summary&&v.summary!==v.reason&&(0,a.jsxs)("p",{style:{margin:"6px 0 0"},children:[g("fup.summary")," ",v.summary]})]}),(0,a.jsxs)("ul",{className:"small",style:{margin:"8px 0",paddingLeft:18},children:[(0,a.jsx)("li",{children:g("fup.chat")}),(0,a.jsx)("li",{children:R?M?g("fup.branch",{branch:R,commit:M.slice(0,8)}):g("fup.branchNotCommitted",{branch:R}):g("fup.noVcs")}),(0,a.jsx)("li",{children:g("fup.kept")})]}),(0,a.jsxs)("details",{className:"small",children:[(0,a.jsx)("summary",{children:g("fup.original")}),(0,a.jsx)("pre",{className:"tall",children:v.prompt})]}),(0,a.jsx)("label",{htmlFor:"".concat(k,"-prompt"),style:{marginTop:10},children:g("fup.prompt")}),(0,a.jsx)("textarea",{id:"".concat(k,"-prompt"),ref:B,className:"prose",value:j,onChange:e=>y(e.target.value),placeholder:g("fup.placeholder"),style:{minHeight:180},disabled:w}),(0,a.jsx)("p",{className:"why",children:g("fup.startOver",{fix:g("reg.fixPrompt")})}),(0,a.jsxs)("div",{className:"row modal-actions",children:[b&&(0,a.jsx)("span",{className:"small grow err",children:b}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>f(!1),disabled:w,children:g("dialog.cancel")}),(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void D(),disabled:w||!j.trim(),children:g("fup.save")})]})]}):(0,a.jsx)("p",{className:"muted small",children:b||g("fup.loading")})]})})}}}]);
|