copilot-operator 0.1.50 → 0.1.52
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 +587 -574
- package/dist/src/api/operator.controller.js +119 -1023
- package/dist/src/api/operator.service.js +346 -2553
- package/dist/src/config/schema.js +13 -0
- package/dist/src/orchestrator/hold.js +49 -0
- package/dist/src/orchestrator/leadRunner.js +559 -0
- package/dist/src/orchestrator/taskRunner.js +211 -39
- package/dist/src/plan/kerrigan.js +232 -0
- package/dist/src/plan/systemGuide.js +758 -3757
- package/dist/src/protocol/leadSchema.js +156 -0
- package/dist/src/protocol/parser.js +1 -1
- package/dist/src/session/chatNotice.js +191 -0
- package/dist/src/session/checkpoint.js +19 -0
- package/dist/src/session/compose.js +1 -1
- package/dist/src/session/store.js +17 -126
- package/dist/src/session/workspace.js +52 -5
- package/dist/src/transport/chatTransport.js +1 -1
- package/dist/src/transport/copilotTransport.js +135 -1
- package/dist/web/404.html +13 -16
- package/dist/web/_next/static/_1zhoDsMOPAH2xW702E5A/_buildManifest.js +1 -0
- package/dist/web/_next/static/chunks/134-ddd50a7fbb536ec8.js +1 -0
- package/dist/web/_next/static/chunks/163.dbd7d36584d0bb37.js +1 -0
- package/dist/web/_next/static/chunks/220.35531b39410e1a9f.js +1 -0
- package/dist/web/_next/static/chunks/548.71ac96c94136659b.js +1 -0
- package/dist/web/_next/static/chunks/584.6df695c5b86a75aa.js +1 -0
- package/dist/web/_next/static/chunks/67.9ed79e2fbfb56f26.js +1 -0
- package/dist/web/_next/static/chunks/714.1e2338736a70b9c7.js +1 -0
- package/dist/web/_next/static/chunks/747.d2c1249d736dc03b.js +1 -0
- package/dist/web/_next/static/chunks/77.a200abef0f5b4a7f.js +1 -0
- package/dist/web/_next/static/chunks/808-bc7d7eac6d823291.js +1 -0
- package/dist/web/_next/static/chunks/921-dc5538cd779c6432.js +1 -0
- package/dist/web/_next/static/chunks/app/defaults/page-edd7534ca9ecf366.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-8f99a164d76897a0.js +1 -0
- package/dist/web/_next/static/chunks/app/page-4bed816eda370d0c.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-1cf9e75e76da59ed.js +1 -0
- package/dist/web/_next/static/chunks/webpack-77147e31d2125631.js +1 -0
- package/dist/web/_next/static/css/3bea264adc472bc8.css +1 -0
- package/dist/web/defaults.html +13 -16
- package/dist/web/defaults.txt +22 -23
- package/dist/web/index.html +13 -16
- package/dist/web/index.txt +22 -23
- package/dist/web/system.html +13 -16
- package/dist/web/system.txt +22 -23
- package/package.json +5 -23
- package/prompts/lead1.md +116 -0
- 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/prepareFromRemote.js +0 -288
- package/dist/src/vcs/remoteAuth.js +0 -117
- package/dist/src/vcs/startChoice.js +0 -367
- package/dist/src/vcs/syncCommand.js +0 -97
- 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/534-56c68930a1a3c10f.js +0 -1
- package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +0 -1
- package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +0 -1
- package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.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-95bab4c1b1ff9339.js +0 -1
- package/dist/web/_next/static/chunks/app/import/page-8ef75fc08638e75f.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +0 -1
- package/dist/web/_next/static/chunks/app/level1/page-dd3ebf37d29dce4f.js +0 -1
- package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.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-adb64f8ba3d8c06e.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-227a259e383ca2a0.js +0 -1
- package/dist/web/_next/static/chunks/webpack-0f31b926d9a9c5a4.js +0 -1
- package/dist/web/_next/static/css/4335e4ce269ba1ea.css +0 -1
- package/dist/web/_next/static/z74_FBfnnXW5IJCHTgTH2/_buildManifest.js +0 -1
- package/dist/web/appearance.html +0 -16
- package/dist/web/appearance.txt +0 -26
- 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/level1.html +0 -16
- package/dist/web/level1.txt +0 -26
- package/dist/web/presets.html +0 -19
- package/dist/web/presets.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/{z74_FBfnnXW5IJCHTgTH2 → _1zhoDsMOPAH2xW702E5A}/_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,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The command that brings a project's current branch back to the remote's main branch, handed to
|
|
3
|
-
* the operator rather than run.
|
|
4
|
-
*
|
|
5
|
-
* Asked for after a day of runs: a project left on a task branch, with files a step created and
|
|
6
|
-
* nobody committed, wants to go back to where the team's code is. That is `fetch`, `reset --hard`
|
|
7
|
-
* to the remote's main, and `clean -fd` for the new files git does not ignore — three commands that
|
|
8
|
-
* destroy work if pointed at the wrong folder or run a minute too early. So the bot never runs them.
|
|
9
|
-
* It reads the repository, says exactly what would be lost — commits on this branch that the
|
|
10
|
-
* remote's main does not have, changed tracked files, new files — and gives the command, ready to
|
|
11
|
-
* paste into PowerShell, with a read-only preview beside it. Ignored files (`node_modules`, `.env`,
|
|
12
|
-
* build output) are left alone: `clean` without `-x` does not touch them.
|
|
13
|
-
*
|
|
14
|
-
* Nothing here writes to the repository or the network. `git fetch` is in the command, not here:
|
|
15
|
-
* what "would be lost" is computed against the remote branch as last fetched, and the page says so.
|
|
16
|
-
*/
|
|
17
|
-
import { git, lastFetchedAt, porcelainPaths } from './git.js';
|
|
18
|
-
/** A string as a single-quoted PowerShell literal: nothing inside it is expanded. */
|
|
19
|
-
export function psQuote(text) {
|
|
20
|
-
return `'${text.replace(/'/g, "''")}'`;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The two commands, for Windows PowerShell 5.1 and PowerShell 7 alike: `;` and `$LASTEXITCODE`
|
|
24
|
-
* rather than `&&`, which 5.1 does not have, so a failed fetch stops everything after it instead
|
|
25
|
-
* of resetting to a remote branch that is out of date.
|
|
26
|
-
*/
|
|
27
|
-
export function syncCommands(dir, remote, target) {
|
|
28
|
-
const g = `git -C ${psQuote(dir)}`;
|
|
29
|
-
return {
|
|
30
|
-
preview: [
|
|
31
|
-
`${g} fetch ${psQuote(remote)}`,
|
|
32
|
-
`${g} log --oneline ${psQuote(`${target}..HEAD`)}`,
|
|
33
|
-
`${g} status --short`,
|
|
34
|
-
`${g} clean -nd`,
|
|
35
|
-
].join('; '),
|
|
36
|
-
command: `${g} fetch ${psQuote(remote)}; if ($LASTEXITCODE -eq 0) { ${g} reset --hard ${psQuote(target)}; ` +
|
|
37
|
-
`if ($LASTEXITCODE -eq 0) { ${g} clean -fd } }`,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const empty = (repoDir, problem) => ({
|
|
41
|
-
ok: false,
|
|
42
|
-
problem,
|
|
43
|
-
repoDir,
|
|
44
|
-
willLose: { commits: [], changed: [], untracked: [] },
|
|
45
|
-
preview: '',
|
|
46
|
-
command: '',
|
|
47
|
-
});
|
|
48
|
-
export async function planSync(repoDir) {
|
|
49
|
-
const inside = await git(repoDir, ['rev-parse', '--is-inside-work-tree']);
|
|
50
|
-
if (!inside.ok || inside.stdout !== 'true')
|
|
51
|
-
return empty(repoDir, `${repoDir} is not a git repository.`);
|
|
52
|
-
const branch = await git(repoDir, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
|
|
53
|
-
if (!branch.ok || !branch.stdout) {
|
|
54
|
-
return empty(repoDir, 'The repository is not on a branch (a detached HEAD), so there is no "current branch" to bring up to date. Check out a branch first.');
|
|
55
|
-
}
|
|
56
|
-
const remotes = (await git(repoDir, ['remote'])).stdout.split('\n').map((r) => r.trim()).filter(Boolean);
|
|
57
|
-
if (remotes.length === 0)
|
|
58
|
-
return empty(repoDir, 'The repository has no remote, so there is no remote main branch to go back to.');
|
|
59
|
-
const remote = remotes.includes('origin') ? 'origin' : remotes[0];
|
|
60
|
-
// The remote's own idea of its main branch first, then the two usual names.
|
|
61
|
-
let target = '';
|
|
62
|
-
const head = await git(repoDir, ['symbolic-ref', '--quiet', '--short', `refs/remotes/${remote}/HEAD`]);
|
|
63
|
-
if (head.ok && head.stdout)
|
|
64
|
-
target = head.stdout;
|
|
65
|
-
for (const name of ['main', 'master']) {
|
|
66
|
-
if (target)
|
|
67
|
-
break;
|
|
68
|
-
const found = await git(repoDir, ['rev-parse', '--verify', '--quiet', `refs/remotes/${remote}/${name}`]);
|
|
69
|
-
if (found.ok)
|
|
70
|
-
target = `${remote}/${name}`;
|
|
71
|
-
}
|
|
72
|
-
if (!target) {
|
|
73
|
-
return empty(repoDir, `No main branch of ${remote} is known here yet. Run ${syncCommands(repoDir, remote, `${remote}/main`).preview.split('; ')[0]} once, then look again.`);
|
|
74
|
-
}
|
|
75
|
-
const commits = await git(repoDir, ['log', '--format=%h %s', `${target}..HEAD`]);
|
|
76
|
-
const status = await git(repoDir, ['status', '--porcelain', '--untracked-files=no']);
|
|
77
|
-
const clean = await git(repoDir, ['clean', '-nd']);
|
|
78
|
-
const gitDir = (await git(repoDir, ['rev-parse', '--absolute-git-dir'])).stdout;
|
|
79
|
-
const lastFetched = gitDir ? lastFetchedAt(gitDir) : undefined;
|
|
80
|
-
return {
|
|
81
|
-
ok: true,
|
|
82
|
-
repoDir,
|
|
83
|
-
branch: branch.stdout,
|
|
84
|
-
remote,
|
|
85
|
-
target,
|
|
86
|
-
...(lastFetched ? { lastFetched } : {}),
|
|
87
|
-
willLose: {
|
|
88
|
-
commits: commits.ok && commits.stdout ? commits.stdout.split('\n') : [],
|
|
89
|
-
changed: porcelainPaths(status.stdout),
|
|
90
|
-
untracked: clean.stdout
|
|
91
|
-
.split('\n')
|
|
92
|
-
.map((l) => l.replace(/^Would remove\s+/, '').trim())
|
|
93
|
-
.filter(Boolean),
|
|
94
|
-
},
|
|
95
|
-
...syncCommands(repoDir, remote, target),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
@@ -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])}}}]);
|