@giamme/forge 0.18.0 → 0.20.0
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/CHANGELOG.md +49 -0
- package/README.md +1 -0
- package/SKILL.md +19 -2
- package/VERSION +1 -1
- package/docs/artifacts.md +25 -1
- package/docs/commands.md +217 -18
- package/docs/decomposed-runs.md +114 -1
- package/docs/development.md +2 -1
- package/docs/forge-ui.md +138 -18
- package/docs/memory.md +25 -4
- package/docs/models.md +8 -0
- package/docs/reviews.md +122 -0
- package/forge +26 -3
- package/package.json +2 -1
- package/references/dataset.md +20 -1
- package/references/decompose.md +641 -41
- package/references/harnesses.md +18 -3
- package/references/memory.md +30 -5
- package/references/planning.md +43 -14
- package/references/ui.md +53 -6
- package/registry.tsv +8 -3
- package/scripts/forge-brief.py +88 -3
- package/scripts/forge-compare.py +4 -3
- package/scripts/forge-contract.py +202 -27
- package/scripts/forge-control.py +117 -5
- package/scripts/forge-dispatch.sh +34 -5
- package/scripts/forge-findings.py +675 -0
- package/scripts/forge-group.py +496 -0
- package/scripts/forge-groups.py +89 -0
- package/scripts/forge-handoff.py +1128 -0
- package/scripts/forge-issues.py +228 -97
- package/scripts/forge-lib-group.sh +641 -0
- package/scripts/forge-lib-plans.sh +339 -3
- package/scripts/forge-lib-task.sh +197 -4
- package/scripts/forge-memory.sh +711 -17
- package/scripts/forge-parallel.sh +721 -38
- package/scripts/forge-planner.py +104 -8
- package/scripts/forge-route.py +190 -12
- package/scripts/forge-runs.py +9 -5
- package/scripts/forge-schedule.py +417 -52
- package/scripts/forge-solo.sh +2 -0
- package/scripts/forge-sweep.py +199 -44
- package/scripts/forge-worktrees.py +243 -0
- package/scripts/forge_brief/__init__.py +294 -50
- package/scripts/forge_brief/answers.py +58 -11
- package/scripts/forge_brief/proposals.py +1630 -0
- package/scripts/forge_dataset/efforts.py +4 -3
- package/scripts/forge_dataset/export.py +24 -12
- package/scripts/forge_dataset/facts.py +5 -3
- package/scripts/forge_dataset/forecast.py +8 -18
- package/scripts/forge_dataset/harvest.py +204 -9
- package/scripts/forge_dataset/history.py +11 -6
- package/scripts/forge_dataset/importer.py +65 -1
- package/scripts/forge_dataset/names.py +66 -0
- package/scripts/forge_dataset/reviewers.py +5 -2
- package/scripts/forge_dataset/risk.py +6 -3
- package/scripts/forge_dataset/routing.py +6 -1
- package/scripts/forge_findings/__init__.py +17 -0
- package/scripts/forge_findings/apply.py +441 -0
- package/scripts/forge_findings/status.py +43 -0
- package/scripts/forge_findings/store.py +583 -0
- package/scripts/forge_findings/tags.py +53 -0
- package/scripts/forge_findings/triage.py +603 -0
- package/scripts/forge_groups/__init__.py +308 -0
- package/scripts/forge_groups/attribute.py +289 -0
- package/scripts/forge_groups/review.py +286 -0
- package/scripts/forge_identity.py +327 -0
- package/scripts/forge_memory_list.py +7 -3
- package/scripts/forge_owner.py +152 -0
- package/scripts/forge_side/__init__.py +228 -38
- package/ui/docs/api.md +303 -29
- package/ui/forge_ui/control.py +1018 -6
- package/ui/forge_ui/executions.py +8 -1
- package/ui/forge_ui/export.py +31 -4
- package/ui/forge_ui/groups.py +264 -0
- package/ui/forge_ui/models.py +70 -8
- package/ui/forge_ui/projects.py +209 -22
- package/ui/forge_ui/reader.py +262 -19
- package/ui/forge_ui/server.py +4 -0
- package/ui/forge_ui/static/app.js +93 -13
- package/ui/forge_ui/static/briefview.js +350 -47
- package/ui/forge_ui/static/diffview.js +86 -1
- package/ui/forge_ui/static/findingsactions.js +201 -0
- package/ui/forge_ui/static/groupsview.js +332 -0
- package/ui/forge_ui/static/index.html +3 -0
- package/ui/forge_ui/static/panel.js +127 -7
- package/ui/forge_ui/static/projectsview.js +764 -30
- package/ui/forge_ui/static/runmodel.js +14 -3
- package/ui/forge_ui/static/storageview.js +91 -10
- package/ui/forge_ui/static/style.css +138 -5
- package/ui/forge_ui/static/triageview.js +423 -0
- package/ui/forge_ui/static/worktreesview.js +233 -12
- package/ui/forge_ui/storage.py +14 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/* forge-ui Worktrees screen (#125): every worktree forge created, in any repository, with its state
|
|
2
|
-
that removes it
|
|
3
|
-
narrowed to one repository (#/worktrees/repo/<root>) or one run (#/worktrees/runs/<key>).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/* forge-ui Worktrees screen (#125, removals #147): every worktree forge created, in any repository, with its state
|
|
2
|
+
and the command that removes it (window.ForgeWorktrees, and a CommonJS module under node:test). Route #/worktrees,
|
|
3
|
+
optionally narrowed to one repository (#/worktrees/repo/<root>) or one run (#/worktrees/runs/<key>).
|
|
4
|
+
With write controls the page removes worktrees through POST /api/worktrees/remove (`forge worktrees rm`): a dry run,
|
|
5
|
+
then a confirmation, then the real call. Under read-only, or with no token, it only copies the commands.
|
|
6
|
+
Paths, branches, reasons and commit subjects enter the page as text.
|
|
7
|
+
The pure helpers (filters, totals, sizes, which rows can be removed) are tested in ui/tests/js/worktreesview.test.js.
|
|
7
8
|
ctx = { filter?: {repo, run}, runHref(key), tablePrefs?(id), saveTablePrefs?(id, prefs) }. */
|
|
8
9
|
(function (root, factory) {
|
|
9
10
|
'use strict';
|
|
@@ -52,12 +53,78 @@
|
|
|
52
53
|
const repoName = p => typeof p === 'string' && p ? p.replace(/\/+$/, '').split('/').pop() : '—';
|
|
53
54
|
const label = status => LABEL[status] || status || '—';
|
|
54
55
|
|
|
56
|
+
// A removal is the command the server offers: failed or finished, or an unknown folder git has already dropped.
|
|
57
|
+
const BLOCK = {
|
|
58
|
+
in_use: 'its run is active',
|
|
59
|
+
dirty: 'uncommitted changes',
|
|
60
|
+
locked: 'locked by git',
|
|
61
|
+
needed: 'its run still needs it',
|
|
62
|
+
missing: 'already gone (prune)',
|
|
63
|
+
foreign: "not forge's",
|
|
64
|
+
removed: 'already removed',
|
|
65
|
+
unknown: 'not a leftover',
|
|
66
|
+
};
|
|
67
|
+
function removable(row) {
|
|
68
|
+
if (!row || typeof row !== 'object') return false;
|
|
69
|
+
if (row.status === 'failed' || row.status === 'finished') return true;
|
|
70
|
+
return row.status === 'unknown' && row.leftover === true;
|
|
71
|
+
}
|
|
72
|
+
function blockReason(row) {
|
|
73
|
+
if (!row || typeof row !== 'object' || removable(row)) return null;
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(BLOCK, row.status)) return BLOCK[row.status];
|
|
75
|
+
return row.status ? String(row.status) : 'cannot remove';
|
|
76
|
+
}
|
|
77
|
+
// Paths of the removable rows in the current filtered view, in that view's order.
|
|
78
|
+
function selectable(rows, filter) {
|
|
79
|
+
return filterRows(rows, filter).filter(removable).map(r => r.path).filter(p => typeof p === 'string');
|
|
80
|
+
}
|
|
81
|
+
function answerRows(answer) {
|
|
82
|
+
return list(answer && answer.rows).filter(r => r && typeof r === 'object');
|
|
83
|
+
}
|
|
84
|
+
function rowBit(r) {
|
|
85
|
+
const path = r.path == null ? '' : String(r.path);
|
|
86
|
+
const reason = r.reason == null || r.reason === '' ? '' : String(r.reason);
|
|
87
|
+
return reason ? path + ' (' + reason + ')' : path;
|
|
88
|
+
}
|
|
89
|
+
// One sentence for the dry run: how many would go, then each skip (and any failure) with its reason.
|
|
90
|
+
function summaryText(answer) {
|
|
91
|
+
const rows = answerRows(answer);
|
|
92
|
+
const n = rows.filter(r => r.status === 'would-remove').length;
|
|
93
|
+
let text = (n === 1 ? '1 worktree' : n + ' worktrees') + ' would be removed.';
|
|
94
|
+
const skipped = rows.filter(r => r.status === 'skipped');
|
|
95
|
+
const failed = rows.filter(r => r.status === 'failed');
|
|
96
|
+
if (skipped.length) text += ' Skipped: ' + skipped.map(rowBit).join('; ') + '.';
|
|
97
|
+
if (failed.length) text += ' Failed: ' + failed.map(rowBit).join('; ') + '.';
|
|
98
|
+
return text;
|
|
99
|
+
}
|
|
100
|
+
function resultLines(answer) {
|
|
101
|
+
return answerRows(answer).map(r => ({
|
|
102
|
+
path: r.path == null ? '' : String(r.path),
|
|
103
|
+
status: r.status == null ? '' : String(r.status),
|
|
104
|
+
reason: r.reason == null ? '' : String(r.reason),
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
// The line shown for one result row: "removed", "skipped (reason)", "failed (reason)".
|
|
108
|
+
function resultPhrase(line) {
|
|
109
|
+
const reason = line && line.reason ? ' (' + line.reason + ')' : '';
|
|
110
|
+
if (!line) return '';
|
|
111
|
+
if (line.status === 'removed') return 'removed';
|
|
112
|
+
if (line.status === 'skipped') return 'skipped' + reason;
|
|
113
|
+
if (line.status === 'failed') return 'failed' + reason;
|
|
114
|
+
return (line.status || '') + reason;
|
|
115
|
+
}
|
|
116
|
+
const confirmQuestion = n => 'Remove ' + n + ' worktrees?';
|
|
117
|
+
|
|
55
118
|
/* ---------- DOM ---------- */
|
|
56
119
|
function render(host, ctx) {
|
|
57
120
|
const UI = root.ForgeUI;
|
|
58
121
|
const el = (tag, text, cls) => UI.el(tag, text, cls);
|
|
59
122
|
const start = ctx.filter || {};
|
|
60
|
-
const s = { data: null, error: null, filter: { repo: start.repo || '', run: start.run || '', status: 'disk', kind: 'all' }, timer: null, seq: 0, loading: false
|
|
123
|
+
const s = { data: null, error: null, filter: { repo: start.repo || '', run: start.run || '', status: 'disk', kind: 'all' }, timer: null, seq: 0, loading: false,
|
|
124
|
+
controls: false, selected: new Set(), branches: false, busy: false };
|
|
125
|
+
// Table roots whose replaceWith remounts the select-all. ForgeTable keeps the root private and swaps it on redraw.
|
|
126
|
+
const armedTables = new WeakSet();
|
|
127
|
+
const LEDE_COPY = 'Every worktree forge created, in any repository it knows, with what state it is in and the command that removes it safely. Commands are only copied: this page runs nothing.';
|
|
61
128
|
|
|
62
129
|
const head = el('div', undefined, 'wt-head');
|
|
63
130
|
const refreshKey = el('button', 'Read again'); refreshKey.type = 'button';
|
|
@@ -65,7 +132,7 @@
|
|
|
65
132
|
refreshKey.addEventListener('click', () => load(true));
|
|
66
133
|
const stamp = el('span', '', 'muted wt-stamp');
|
|
67
134
|
head.append(el('h1', 'Worktrees', 'module-title'), refreshKey, stamp);
|
|
68
|
-
const lede = el('p',
|
|
135
|
+
const lede = el('p', LEDE_COPY, 'muted wt-lede');
|
|
69
136
|
const notes = el('div', undefined, 'wt-notes muted');
|
|
70
137
|
const sums = el('p', undefined, 'wt-totals'); sums.setAttribute('role', 'status');
|
|
71
138
|
const filters = el('div', undefined, 'wt-filters');
|
|
@@ -150,8 +217,32 @@
|
|
|
150
217
|
return box;
|
|
151
218
|
};
|
|
152
219
|
const pathCell = r => { const n = el('span', shortPath(r.path), 'mono'); n.title = r.path; return n; };
|
|
220
|
+
function selectCell(r) {
|
|
221
|
+
const wrap = el('span');
|
|
222
|
+
const box = el('input'); box.type = 'checkbox';
|
|
223
|
+
if (removable(r)) {
|
|
224
|
+
box.checked = s.selected.has(r.path);
|
|
225
|
+
box.disabled = s.busy;
|
|
226
|
+
box._path = r.path;
|
|
227
|
+
box.setAttribute('aria-label', 'Select ' + String(r.path));
|
|
228
|
+
box.addEventListener('change', () => {
|
|
229
|
+
if (box.checked) s.selected.add(r.path); else s.selected.delete(r.path);
|
|
230
|
+
syncSelectAll(); syncBar();
|
|
231
|
+
});
|
|
232
|
+
const go = el('button', 'Remove'); go.type = 'button'; go.disabled = s.busy;
|
|
233
|
+
go.addEventListener('click', () => removePaths([r.path]));
|
|
234
|
+
wrap.append(box, go);
|
|
235
|
+
} else {
|
|
236
|
+
const why = blockReason(r) || 'cannot remove';
|
|
237
|
+
box.disabled = true; box.title = why;
|
|
238
|
+
box.setAttribute('aria-label', why);
|
|
239
|
+
wrap.append(box, el('span', why, 'muted wt-note'));
|
|
240
|
+
}
|
|
241
|
+
return wrap;
|
|
242
|
+
}
|
|
243
|
+
const selectColumn = { id: 'select', label: 'Select', sortable: false, hideable: false, cls: 'wt-command-col', cell: selectCell };
|
|
153
244
|
const columns = [
|
|
154
|
-
{ id: 'status', label: 'Status', value: r => STATUSES.indexOf(r.status), cell: statusCell },
|
|
245
|
+
{ id: 'status', label: 'Status', hideable: false, value: r => STATUSES.indexOf(r.status), cell: statusCell },
|
|
155
246
|
{ id: 'run', label: 'Run', value: r => r.run_id, cell: runCell },
|
|
156
247
|
{ id: 'task', label: 'Task', value: r => r.task, mono: true, cell: r => r.task || (r.kind && r.kind !== 'task' ? r.kind : '—') },
|
|
157
248
|
{ id: 'command', label: 'Command', sortable: false, cls: 'wt-command-col', cell: commandCell },
|
|
@@ -197,20 +288,80 @@
|
|
|
197
288
|
}
|
|
198
289
|
groups.replaceChildren(d);
|
|
199
290
|
}
|
|
291
|
+
function shownPaths() { return selectable(list(s.data && s.data.rows), s.filter); }
|
|
292
|
+
function chosenPaths() { return shownPaths().filter(p => s.selected.has(p)); }
|
|
293
|
+
function pruneSelection() {
|
|
294
|
+
if (!s.data) return;
|
|
295
|
+
const live = new Set(selectable(s.data.rows, { status: 'all', kind: 'all' }));
|
|
296
|
+
for (const p of [...s.selected]) if (!live.has(p)) s.selected.delete(p);
|
|
297
|
+
}
|
|
298
|
+
function syncBar() {
|
|
299
|
+
if (!removeSel) return;
|
|
300
|
+
const n = chosenPaths().length;
|
|
301
|
+
removeSel.textContent = 'Remove selected (' + n + ')';
|
|
302
|
+
removeSel.disabled = n === 0 || s.busy;
|
|
303
|
+
if (branchesBox) branchesBox.disabled = s.busy;
|
|
304
|
+
for (const b of tableHost.querySelectorAll('tbody button')) if (b.textContent === 'Remove') b.disabled = s.busy;
|
|
305
|
+
}
|
|
306
|
+
function syncSelectAll() {
|
|
307
|
+
const box = tableHost.querySelector('th[data-col="select"] input');
|
|
308
|
+
if (!box) return;
|
|
309
|
+
const paths = shownPaths(), n = paths.filter(p => s.selected.has(p)).length;
|
|
310
|
+
box.indeterminate = n > 0 && n < paths.length;
|
|
311
|
+
box.checked = paths.length > 0 && n === paths.length;
|
|
312
|
+
box.disabled = paths.length === 0 || s.busy;
|
|
313
|
+
}
|
|
314
|
+
function mountSelectAll() {
|
|
315
|
+
const text = tableHost.querySelector('th[data-col="select"] .th-text');
|
|
316
|
+
if (!text) return;
|
|
317
|
+
const box = el('input'); box.type = 'checkbox';
|
|
318
|
+
box.setAttribute('aria-label', 'Select all removable worktrees');
|
|
319
|
+
box.addEventListener('dragstart', e => e.preventDefault());
|
|
320
|
+
box.addEventListener('change', () => {
|
|
321
|
+
const paths = shownPaths();
|
|
322
|
+
if (box.checked) for (const p of paths) s.selected.add(p);
|
|
323
|
+
else for (const p of paths) s.selected.delete(p);
|
|
324
|
+
for (const input of tableHost.querySelectorAll('tbody input')) {
|
|
325
|
+
if (typeof input._path === 'string' && paths.includes(input._path)) input.checked = s.selected.has(input._path);
|
|
326
|
+
}
|
|
327
|
+
syncSelectAll(); syncBar();
|
|
328
|
+
});
|
|
329
|
+
text.replaceChildren(box);
|
|
330
|
+
syncSelectAll();
|
|
331
|
+
}
|
|
332
|
+
// Sort, drag, Alt+arrow, the Columns menu and Reset all rebuild the header from `c.label` and swap the table root
|
|
333
|
+
// with replaceWith. Nothing tells us, so the box mounted after render would vanish until the next full draw.
|
|
334
|
+
function armRedraw(node) {
|
|
335
|
+
if (!node || armedTables.has(node) || typeof node.replaceWith !== 'function') return;
|
|
336
|
+
const orig = node.replaceWith;
|
|
337
|
+
armedTables.add(node);
|
|
338
|
+
node.replaceWith = function (...nodes) {
|
|
339
|
+
const out = orig.apply(this, nodes);
|
|
340
|
+
for (const next of nodes) armRedraw(next);
|
|
341
|
+
if (s.controls && host.isConnected) mountSelectAll();
|
|
342
|
+
return out;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
200
345
|
function drawNow() {
|
|
346
|
+
pruneSelection();
|
|
201
347
|
syncFilters(); drawNotes();
|
|
202
348
|
const d = s.data;
|
|
203
349
|
if (!d) { tableHost.replaceChildren(el('p', s.error ? '' : 'Reading every repository\'s worktrees… the first read runs git status in each, so it can take a few seconds.', 'muted')); sums.replaceChildren(); return; }
|
|
204
350
|
const rows = filterRows(d.rows, s.filter);
|
|
205
351
|
drawTotals(rows);
|
|
206
352
|
UI.keepOpen(groups, drawGroups);
|
|
207
|
-
if (!rows.length) {
|
|
353
|
+
if (!rows.length) {
|
|
354
|
+
tableHost.replaceChildren(el('p', list(d.rows).length ? `No worktrees match these filters (${list(d.rows).length} hidden).` : 'forge has no worktrees on record.', 'muted'));
|
|
355
|
+
syncBar(); return;
|
|
356
|
+
}
|
|
208
357
|
const id = 'worktrees';
|
|
358
|
+
const cols = s.controls ? [selectColumn].concat(columns) : columns;
|
|
209
359
|
tableHost.replaceChildren();
|
|
210
|
-
root.ForgeTable.render(tableHost, { id, label: 'Worktrees', columns, rows, className: 'wt-grid', rowClass: r => 'wt-row-' + r.status,
|
|
360
|
+
const table = root.ForgeTable.render(tableHost, { id, label: 'Worktrees', columns: cols, rows, className: 'wt-grid', rowClass: r => 'wt-row-' + r.status,
|
|
211
361
|
// a cell cut short by its width says the whole of itself on hover
|
|
212
362
|
onRow: (_row, tr) => { for (const td of tr.children) if (!td.classList.contains('wt-command-col') && !td.title) td.title = td.textContent; },
|
|
213
363
|
prefs: ctx.tablePrefs ? ctx.tablePrefs(id) : null, savePrefs: p => ctx.saveTablePrefs && ctx.saveTablePrefs(id, p) });
|
|
364
|
+
if (s.controls) { armRedraw(table); mountSelectAll(); syncBar(); }
|
|
214
365
|
}
|
|
215
366
|
// A redraw never pulls a command out from under someone selecting or copying it (#115).
|
|
216
367
|
const draw = () => { if (UI.guard) UI.guard(host, drawNow); else drawNow(); };
|
|
@@ -234,8 +385,78 @@
|
|
|
234
385
|
const pending = s.data && s.data.sizes_pending > 0;
|
|
235
386
|
s.timer = setTimeout(() => { if (host.isConnected && document.visibilityState === 'visible') load(false); else schedule(); }, pending ? SIZE_POLL_MS : POLL_MS);
|
|
236
387
|
}
|
|
388
|
+
|
|
389
|
+
let branchesBox = null, removeSel = null, outcomeHost = null;
|
|
390
|
+
function showFailure(res) {
|
|
391
|
+
const text = res && res.status === 409 ? 'busy: another removal is running' : UI.outcomeText(res).text;
|
|
392
|
+
const line = el('p', text, 'warn'); line.setAttribute('role', 'status');
|
|
393
|
+
outcomeHost.replaceChildren(line);
|
|
394
|
+
}
|
|
395
|
+
function showLines(lines) {
|
|
396
|
+
const ul = el('ul');
|
|
397
|
+
for (const line of lines) {
|
|
398
|
+
const li = el('li');
|
|
399
|
+
li.append(el('span', line.path, 'mono'), el('span', ' ' + resultPhrase(line)));
|
|
400
|
+
ul.append(li);
|
|
401
|
+
}
|
|
402
|
+
outcomeHost.replaceChildren(ul);
|
|
403
|
+
}
|
|
404
|
+
// Nothing is removed on the first click: dry run, the summary, confirm, then the real call.
|
|
405
|
+
async function removePaths(paths) {
|
|
406
|
+
const wanted = list(paths).filter(p => typeof p === 'string' && p);
|
|
407
|
+
if (s.busy || !wanted.length || !outcomeHost) return;
|
|
408
|
+
const branches = !!s.branches;
|
|
409
|
+
const body = dryRun => ({ paths: wanted.slice(), branches, dry_run: dryRun });
|
|
410
|
+
s.busy = true; syncBar(); syncSelectAll();
|
|
411
|
+
try {
|
|
412
|
+
const dry = await UI.post('/api/worktrees/remove', body(true)) || { ok: false };
|
|
413
|
+
if (!host.isConnected) return;
|
|
414
|
+
if (!dry.ok) { showFailure(dry); return; }
|
|
415
|
+
const data = dry.data || {};
|
|
416
|
+
const n = answerRows(data).filter(r => r.status === 'would-remove').length;
|
|
417
|
+
outcomeHost.replaceChildren(el('p', summaryText(data)));
|
|
418
|
+
// Nothing would be removed: the summary is the answer. Do not ask, and do not send the real call.
|
|
419
|
+
if (n === 0) return;
|
|
420
|
+
const yes = await UI.confirmInline(outcomeHost, confirmQuestion(n), { danger: true });
|
|
421
|
+
if (!yes || !host.isConnected) return;
|
|
422
|
+
const real = await UI.post('/api/worktrees/remove', body(false)) || { ok: false };
|
|
423
|
+
if (!host.isConnected) return;
|
|
424
|
+
if (!real.ok) { showFailure(real); return; }
|
|
425
|
+
const lines = resultLines(real.data);
|
|
426
|
+
showLines(lines);
|
|
427
|
+
for (const line of lines) if (line.status === 'removed') s.selected.delete(line.path);
|
|
428
|
+
s.busy = false; // the refresh draws the checkboxes; they must not stay disabled
|
|
429
|
+
await load(true);
|
|
430
|
+
} finally {
|
|
431
|
+
s.busy = false;
|
|
432
|
+
if (host.isConnected) { syncBar(); syncSelectAll(); }
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function enableControls() {
|
|
436
|
+
if (s.controls) return;
|
|
437
|
+
const bar = el('div', undefined, 'wt-filters');
|
|
438
|
+
bar.setAttribute('role', 'group'); bar.setAttribute('aria-label', 'Remove worktrees');
|
|
439
|
+
branchesBox = el('input'); branchesBox.type = 'checkbox';
|
|
440
|
+
const branchesLabel = el('label');
|
|
441
|
+
branchesLabel.append(branchesBox, el('span', 'Delete merged branches too'));
|
|
442
|
+
branchesBox.addEventListener('change', () => { s.branches = branchesBox.checked; });
|
|
443
|
+
removeSel = el('button', 'Remove selected (0)'); removeSel.type = 'button'; removeSel.disabled = true;
|
|
444
|
+
removeSel.addEventListener('click', () => removePaths(chosenPaths()));
|
|
445
|
+
bar.append(branchesLabel, removeSel);
|
|
446
|
+
outcomeHost = el('div', undefined, 'wt-notes'); outcomeHost.setAttribute('role', 'status');
|
|
447
|
+
host.insertBefore(bar, tableHost);
|
|
448
|
+
host.insertBefore(outcomeHost, tableHost);
|
|
449
|
+
s.controls = true;
|
|
450
|
+
lede.textContent = 'Every worktree forge created, in any repository it knows, with what state it is in and the command that removes it safely. A removal runs through forge worktrees rm after a dry run and a confirmation. Commands can still be copied.';
|
|
451
|
+
}
|
|
452
|
+
|
|
237
453
|
drawNow();
|
|
238
454
|
load(false);
|
|
455
|
+
UI.controlsEnabled().then(on => {
|
|
456
|
+
if (!on || !host.isConnected) return;
|
|
457
|
+
enableControls();
|
|
458
|
+
draw();
|
|
459
|
+
});
|
|
239
460
|
return {
|
|
240
461
|
setFilter(f) {
|
|
241
462
|
const repo = (f && f.repo) || '', run = (f && f.run) || '';
|
|
@@ -246,5 +467,5 @@
|
|
|
246
467
|
};
|
|
247
468
|
}
|
|
248
469
|
|
|
249
|
-
return { render, filterRows, totals, humanBytes, repoName, shortPath, label, STATUSES, LABEL };
|
|
470
|
+
return { render, filterRows, totals, humanBytes, repoName, shortPath, label, removable, blockReason, selectable, summaryText, resultLines, STATUSES, LABEL };
|
|
250
471
|
});
|
package/ui/forge_ui/storage.py
CHANGED
|
@@ -82,6 +82,20 @@ def with_commands(result):
|
|
|
82
82
|
return result
|
|
83
83
|
|
|
84
84
|
|
|
85
|
+
def with_keys(answer, keys):
|
|
86
|
+
"""The answer with each run's forge-ui key, or None for a run dir the run list does not show (the Disk screen
|
|
87
|
+
links only the ones it can open). A copy: the cached result keeps no key, since the run list changes."""
|
|
88
|
+
data = answer.get('data')
|
|
89
|
+
if not data:
|
|
90
|
+
return answer
|
|
91
|
+
from forge_ui.reader import run_key
|
|
92
|
+
runs = []
|
|
93
|
+
for run in data['runs']:
|
|
94
|
+
key = run_key(run['path'])
|
|
95
|
+
runs.append(dict(run, key=key if key in keys else None))
|
|
96
|
+
return dict(answer, data=dict(data, runs=runs))
|
|
97
|
+
|
|
98
|
+
|
|
85
99
|
class Screen:
|
|
86
100
|
"""The cached answer of /api/storage for one server; one measurement at a time, in a background thread."""
|
|
87
101
|
|