@giamme/forge 0.16.0 → 0.18.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.
Files changed (95) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/SKILL.md +16 -3
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +8 -0
  5. package/docs/commands.md +70 -6
  6. package/docs/dataset.md +13 -0
  7. package/docs/decomposed-runs.md +8 -0
  8. package/docs/forge-ui.md +23 -2
  9. package/docs/memory.md +2 -0
  10. package/docs/reviews.md +15 -1
  11. package/docs/safety.md +8 -0
  12. package/forge +24 -1
  13. package/package.json +1 -1
  14. package/references/dataset.md +143 -5
  15. package/references/decision-models.md +15 -2
  16. package/references/decompose.md +180 -11
  17. package/references/planning.md +3 -2
  18. package/references/solo.md +2 -1
  19. package/references/ui.md +5 -2
  20. package/scripts/forge-artifact.sh +14 -0
  21. package/scripts/forge-brief.py +132 -0
  22. package/scripts/forge-compare.py +11 -1
  23. package/scripts/forge-config.py +176 -9
  24. package/scripts/forge-contract.py +98 -4
  25. package/scripts/forge-control.py +86 -13
  26. package/scripts/forge-dispatch.sh +14 -10
  27. package/scripts/forge-du.py +167 -0
  28. package/scripts/forge-issues.py +4 -3
  29. package/scripts/forge-ledger.py +3 -1
  30. package/scripts/forge-lib-adopt.sh +8 -1
  31. package/scripts/forge-lib-plans.sh +5 -2
  32. package/scripts/forge-lib-review.sh +29 -1
  33. package/scripts/forge-metrics.sh +29 -3
  34. package/scripts/forge-parallel-options.sh +4 -0
  35. package/scripts/forge-parallel.sh +506 -10
  36. package/scripts/forge-plan-check.py +25 -2
  37. package/scripts/forge-planner.py +20 -6
  38. package/scripts/forge-prompt.py +120 -0
  39. package/scripts/forge-retro.py +115 -0
  40. package/scripts/forge-runs-compact.py +443 -0
  41. package/scripts/forge-runs-rm.py +2 -0
  42. package/scripts/forge-runs.py +18 -3
  43. package/scripts/forge-schedule.py +279 -4
  44. package/scripts/forge-shadow.py +35 -10
  45. package/scripts/forge-solo.sh +2 -0
  46. package/scripts/forge-summarize.py +698 -0
  47. package/scripts/forge-sweep.py +25 -10
  48. package/scripts/forge-ui-options.sh +10 -0
  49. package/scripts/forge_brief/__init__.py +587 -0
  50. package/scripts/forge_brief/answers.py +459 -0
  51. package/scripts/forge_dataset/__init__.py +10 -0
  52. package/scripts/forge_dataset/cli.py +83 -0
  53. package/scripts/forge_dataset/export.py +18 -4
  54. package/scripts/forge_dataset/facts.py +280 -0
  55. package/scripts/forge_dataset/harvest.py +56 -9
  56. package/scripts/forge_dataset/history.py +5 -3
  57. package/scripts/forge_dataset/outcomes.py +206 -58
  58. package/scripts/forge_dataset/pairs.py +174 -0
  59. package/scripts/forge_dataset/risk.py +108 -0
  60. package/scripts/forge_dataset/tiers.py +427 -0
  61. package/scripts/forge_decide/__init__.py +11 -1
  62. package/scripts/forge_decide/cli.py +23 -2
  63. package/scripts/forge_decide/labels.py +30 -6
  64. package/scripts/forge_decide/replay.py +10 -4
  65. package/scripts/forge_locations.py +366 -0
  66. package/scripts/forge_registry.py +19 -0
  67. package/scripts/forge_retro/__init__.py +417 -0
  68. package/scripts/forge_retro/issues.py +1193 -0
  69. package/scripts/forge_retro/report.py +671 -0
  70. package/scripts/forge_side/__init__.py +477 -0
  71. package/scripts/forge_storage.py +515 -0
  72. package/ui/README.md +68 -8
  73. package/ui/docs/api.md +217 -20
  74. package/ui/forge_ui/control.py +92 -11
  75. package/ui/forge_ui/export.py +31 -5
  76. package/ui/forge_ui/findings.py +4 -2
  77. package/ui/forge_ui/links.py +337 -0
  78. package/ui/forge_ui/models.py +57 -4
  79. package/ui/forge_ui/projects.py +4 -1
  80. package/ui/forge_ui/reader.py +732 -34
  81. package/ui/forge_ui/server.py +8 -0
  82. package/ui/forge_ui/static/app.js +92 -5
  83. package/ui/forge_ui/static/briefview.js +302 -0
  84. package/ui/forge_ui/static/checksview.js +6 -2
  85. package/ui/forge_ui/static/controls.js +5 -0
  86. package/ui/forge_ui/static/diffview.js +7 -3
  87. package/ui/forge_ui/static/index.html +3 -0
  88. package/ui/forge_ui/static/panel.js +311 -4
  89. package/ui/forge_ui/static/runmodel.js +13 -1
  90. package/ui/forge_ui/static/storageview.js +271 -0
  91. package/ui/forge_ui/static/style.css +100 -3
  92. package/ui/forge_ui/static/worktreesview.js +3 -3
  93. package/ui/forge_ui/storage.py +136 -0
  94. package/ui/forge_ui/transcripts.py +35 -10
  95. package/ui/forge_ui/worktrees.py +154 -13
@@ -0,0 +1,271 @@
1
+ /* forge-ui Disk screen (#139): what forge takes on disk in every repository it has runs for (run dirs, worktrees,
2
+ its data home) and the command that takes each part back (window.ForgeStorage, and a CommonJS module under
3
+ node:test). Route #/disk. The same report as `forge du --all`, from the same rules (scripts/forge_storage.py).
4
+ The commands come from the server and are only ever copied: the page runs nothing, so it works with
5
+ --read-only too. Measuring visits every file, so it runs once in the background when the screen opens and
6
+ again on "Measure again"; the page polls only while a measurement runs.
7
+ The pure helpers are tested in ui/tests/js/storageview.test.js.
8
+ ctx = { runHref(path) -> href | null, tablePrefs?(id), saveTablePrefs?(id, prefs) }. */
9
+ (function (root, factory) {
10
+ 'use strict';
11
+ const api = factory(root);
12
+ if (typeof module === 'object' && module.exports) module.exports = api;
13
+ else root.ForgeStorage = api;
14
+ })(typeof self !== 'undefined' ? self : this, function (root) {
15
+ 'use strict';
16
+
17
+ const list = v => Array.isArray(v) ? v : [];
18
+ const POLL_MS = 2000;
19
+
20
+ /* ---------- pure ---------- */
21
+ function humanBytes(n) {
22
+ if (!Number.isFinite(n) || n < 0) return '—';
23
+ const units = ['B', 'KB', 'MB', 'GB', 'TB'];
24
+ let i = 0, v = n;
25
+ while (v >= 1024 && i < units.length - 1) { v /= 1024; i += 1; }
26
+ return (i === 0 ? String(v) : v.toFixed(v < 10 ? 1 : 0)) + ' ' + units[i];
27
+ }
28
+ // One line on the whole: what forge takes and what can go without losing a run.
29
+ function summary(data) {
30
+ const t = (data && data.totals) || {};
31
+ const parts = [`${humanBytes(t.runs || 0)} in ${list(data && data.runs).length} run dirs`,
32
+ `${humanBytes(t.worktrees || 0)} in ${list(data && data.worktrees).length} worktree folders`];
33
+ if (data && data.data_home) parts.push(`${humanBytes(t.data_home || 0)} in the data home`);
34
+ return { total: (t.runs || 0) + (t.worktrees || 0) + (t.data_home || 0), text: parts.join(' · '), reclaimable: t.reclaimable || 0 };
35
+ }
36
+ // The data home's parts, largest first, with what each is for.
37
+ const HOME_LABEL = { dataset: 'dataset (kept: what forge learns from)', blobs: 'dataset blobs (kept)', archive: 'archives of deleted runs (forge runs rm)',
38
+ exports: 'exports (forge dataset export writes them again)', legacy: 'legacy files from older releases', storage: 'storage records', other: 'other' };
39
+ function homeParts(home) {
40
+ const p = (home && home.parts) || {};
41
+ return Object.keys(HOME_LABEL).filter(k => p[k] > 0).map(k => ({ key: k, label: HOME_LABEL[k], bytes: p[k] })).sort((a, b) => b.bytes - a.bytes);
42
+ }
43
+ const repoName = p => typeof p === 'string' && p ? p.replace(/\/+$/, '').split('/').pop() : '—';
44
+ // The chart's parts, in a fixed order that fixes their colours (--disk-1 … --disk-6): a part keeps its colour
45
+ // whatever else is on screen.
46
+ const PARTS = [
47
+ { key: 'snapshots', label: 'review snapshots', note: 'can go: nothing reads them', color: 'var(--disk-1)' },
48
+ { key: 'logs', label: 'logs', note: 'gzipping the log copies takes most of it back', color: 'var(--disk-2)' },
49
+ { key: 'other', label: 'other run files', note: 'prompts, diffs, verdicts: what forge-ui shows', color: 'var(--disk-3)' },
50
+ { key: 'strays', label: "not forge's", note: 'found inside run dirs; forge never removes them', color: 'var(--disk-4)' },
51
+ { key: 'worktrees', label: 'worktrees', note: 'see the Worktrees screen', color: 'var(--disk-5)' },
52
+ { key: 'home', label: 'data home', note: 'the dataset (kept), archives, exports', color: 'var(--disk-6)' },
53
+ ];
54
+ // [{key, label, note, color, bytes, share}] of everything forge takes, in PARTS order; empty parts stay (0 bytes).
55
+ function breakdown(data) {
56
+ const t = (data && data.totals) || {}, runs = list(data && data.runs);
57
+ const sum = f => runs.reduce((n, r) => n + (Number(f(r)) || 0), 0);
58
+ const bytes = { snapshots: sum(r => r.snapshots), logs: sum(r => (r.logs || 0) + (r.gz || 0)), other: sum(r => (r.other || 0) + (r.fractal || 0)),
59
+ strays: sum(r => r.strays), worktrees: t.worktrees || 0, home: (data && data.data_home && data.data_home.bytes) || 0 };
60
+ const total = Object.values(bytes).reduce((a, b) => a + b, 0);
61
+ return PARTS.map(p => ({ ...p, bytes: bytes[p.key], share: total ? bytes[p.key] / total : 0 }));
62
+ }
63
+ // [{repo, name, total, parts: {key: bytes}}] largest first: each repository's run dirs and worktree folders.
64
+ function byRepo(data) {
65
+ const out = new Map();
66
+ const at = repo => {
67
+ const k = repo || '';
68
+ if (!out.has(k)) out.set(k, { repo: repo || null, name: repo ? repoName(repo) : 'unknown repository', total: 0,
69
+ parts: { snapshots: 0, logs: 0, other: 0, strays: 0, worktrees: 0 } });
70
+ return out.get(k);
71
+ };
72
+ const add = (g, key, n) => { n = Number(n) || 0; g.parts[key] += n; g.total += n; };
73
+ for (const r of list(data && data.runs)) {
74
+ const g = at(r.repo);
75
+ add(g, 'snapshots', r.snapshots); add(g, 'logs', (r.logs || 0) + (r.gz || 0)); add(g, 'other', (r.other || 0) + (r.fractal || 0)); add(g, 'strays', r.strays);
76
+ }
77
+ for (const w of list(data && data.worktrees)) add(at(w.repo), 'worktrees', w.bytes);
78
+ return Array.from(out.values()).filter(g => g.total > 0).sort((a, b) => b.total - a.total);
79
+ }
80
+ const pct = x => x >= 0.995 ? '100%' : x >= 0.1 ? Math.round(x * 100) + '%' : x > 0 ? (x * 100 < 1 ? '<1%' : (x * 100).toFixed(0) + '%') : '0%';
81
+
82
+ /* ---------- DOM ---------- */
83
+ function render(host, ctx) {
84
+ const UI = root.ForgeUI;
85
+ const el = (tag, text, cls) => UI.el(tag, text, cls);
86
+ const s = { answer: null, error: null, timer: null, seq: 0 };
87
+
88
+ const head = el('div', undefined, 'wt-head');
89
+ const again = el('button', 'Measure again'); again.type = 'button';
90
+ again.title = 'Visit every file again now; it takes a while on large run dirs';
91
+ again.addEventListener('click', () => load(true));
92
+ const stamp = el('span', '', 'muted wt-stamp');
93
+ head.append(el('h1', 'Disk', 'module-title'), again, stamp);
94
+ const lede = el('p', 'What forge takes on disk in every repository it has runs for, and the command that takes each part back. Review snapshots and log copies can go without losing a run: every run stays viewable here and in the dataset. Commands are only copied: this page runs nothing.', 'muted wt-lede');
95
+ const status = el('p', undefined, 'wt-totals'); status.setAttribute('role', 'status');
96
+ const cmds = el('div', undefined, 'disk-commands');
97
+ const chart = el('section', undefined, 'disk-chart');
98
+ chart.setAttribute('aria-label', 'Where the space goes');
99
+ const tip = el('div', undefined, 'disk-tip'); tip.hidden = true; tip.setAttribute('role', 'tooltip');
100
+ const tableHost = el('div', undefined, 'wt-table');
101
+ const extra = el('section', undefined, 'disk-extra');
102
+ host.replaceChildren(head, lede, status, chart, cmds, tableHost, extra, tip);
103
+
104
+ // one tooltip for every segment: what it is, its size and its share, beside the pointer or the focused segment
105
+ function showTip(seg, x, y) {
106
+ const p = seg._part;
107
+ tip.replaceChildren(el('strong', p.label), el('span', ` ${humanBytes(p.bytes)} · ${pct(p.share)}${seg._of ? ' of ' + seg._of : ''}`), el('span', p.note, 'muted'));
108
+ tip.hidden = false;
109
+ const box = host.getBoundingClientRect(), w = tip.offsetWidth;
110
+ tip.style.left = Math.max(0, Math.min(x - box.left + 12, box.width - w)) + 'px';
111
+ tip.style.top = (y - box.top + 16) + 'px';
112
+ }
113
+ function segment(part, width, of) {
114
+ const seg = el('span', undefined, 'disk-seg');
115
+ seg._part = part; seg._of = of;
116
+ seg.style.flexGrow = String(width); seg.style.background = part.color;
117
+ seg.tabIndex = 0;
118
+ seg.setAttribute('aria-label', `${part.label}: ${humanBytes(part.bytes)}, ${pct(part.share)}${of ? ' of ' + of : ''}`);
119
+ seg.addEventListener('pointermove', e => showTip(seg, e.clientX, e.clientY));
120
+ seg.addEventListener('pointerleave', () => { tip.hidden = true; });
121
+ seg.addEventListener('focus', () => { const r = seg.getBoundingClientRect(); showTip(seg, r.left + r.width / 2, r.bottom - 8); });
122
+ seg.addEventListener('blur', () => { tip.hidden = true; });
123
+ return seg;
124
+ }
125
+ function drawChart(d) {
126
+ const parts = breakdown(d), total = parts.reduce((n, p) => n + p.bytes, 0);
127
+ if (!total) { chart.replaceChildren(); return; }
128
+ const whole = el('div', undefined, 'disk-bar disk-bar-whole');
129
+ for (const p of parts) if (p.bytes > 0) whole.append(segment(p, p.bytes));
130
+ const legend = el('ul', undefined, 'disk-legend');
131
+ for (const p of parts) {
132
+ if (!p.bytes) continue;
133
+ const li = el('li'); const sw = el('i', undefined, 'disk-swatch'); sw.style.background = p.color;
134
+ li.append(sw, el('span', p.label), el('strong', humanBytes(p.bytes)), el('span', pct(p.share), 'muted'));
135
+ li.title = p.note; legend.append(li);
136
+ }
137
+ const repos = byRepo(d).slice(0, 10), top = repos.length ? repos[0].total : 0;
138
+ const rows = el('div', undefined, 'disk-repos');
139
+ for (const g of repos) {
140
+ const row = el('div', undefined, 'disk-repo');
141
+ const name = el('span', g.name, 'disk-repo-name'); if (g.repo) name.title = g.repo;
142
+ const track = el('div', undefined, 'disk-track');
143
+ const bar = el('div', undefined, 'disk-bar'); bar.style.width = (100 * g.total / top) + '%';
144
+ for (const p of parts) {
145
+ const n = g.parts[p.key] || 0;
146
+ if (n > 0) bar.append(segment({ ...p, bytes: n, share: n / g.total }, n, g.name));
147
+ }
148
+ track.append(bar);
149
+ row.append(name, track, el('span', humanBytes(g.total), 'disk-repo-size'));
150
+ rows.append(row);
151
+ }
152
+ const parts2 = [el('h2', 'Where the space goes', 'plate'), whole, legend];
153
+ if (repos.length) parts2.push(el('h2', 'By repository' + (byRepo(d).length > repos.length ? ' (the 10 largest)' : ''), 'plate disk-sub'), rows);
154
+ chart.replaceChildren(...parts2);
155
+ }
156
+
157
+ function copyButton(command) {
158
+ const b = el('button', 'Copy', 'wt-copy'); b.type = 'button';
159
+ b.setAttribute('aria-label', 'Copy: ' + command);
160
+ b.addEventListener('click', async () => {
161
+ try { await navigator.clipboard.writeText(command); b.textContent = 'Copied'; }
162
+ catch (_) { b.textContent = 'Copy failed: select it'; }
163
+ setTimeout(() => { b.textContent = 'Copy'; }, 2500);
164
+ });
165
+ return b;
166
+ }
167
+ function commandBox(c) {
168
+ const box = el('div', undefined, 'wt-cmd');
169
+ const code = el('code', c.command, 'mono'); code.tabIndex = 0; code.title = c.label;
170
+ box.append(code, copyButton(c.command));
171
+ return box;
172
+ }
173
+ const when = t => Number.isFinite(t) ? new Date(t * 1000).toLocaleString() : '—';
174
+ const bytesCell = n => Number.isFinite(n) && n > 0 ? humanBytes(n) : '—';
175
+ const columns = [
176
+ { id: 'run', label: 'Run', value: r => r.run_id, cell: r => {
177
+ const href = ctx.runHref ? ctx.runHref(r.path) : null;
178
+ const n = el(href ? 'a' : 'span', r.run_id, 'mono'); if (href) n.href = href; n.title = r.path; return n; } },
179
+ { id: 'repo', label: 'Repository', value: r => repoName(r.repo), cell: r => { const n = el('span', repoName(r.repo)); if (r.repo) n.title = r.repo; return n; } },
180
+ { id: 'total', label: 'Total', value: r => r.total, cell: r => humanBytes(r.total) },
181
+ { id: 'snapshots', label: 'Snapshots', title: 'review snapshots: nothing reads one once its review ended', value: r => r.snapshots, cell: r => bytesCell(r.snapshots) },
182
+ { id: 'logs', label: 'Logs', value: r => r.logs + r.gz, cell: r => bytesCell(r.logs + r.gz) },
183
+ { id: 'strays', label: "Not forge's", title: 'a dependency install or a .git found inside the run dir: forge never removes these', value: r => r.strays, cell: r => bytesCell(r.strays) },
184
+ { id: 'reclaimable', label: 'Can go', title: 'what forge runs compact --logs would take back (logs estimated)', value: r => r.reclaimable, cell: r => bytesCell(r.reclaimable) },
185
+ { id: 'command', label: 'Command', sortable: false, cls: 'wt-command-col', cell: r => { const box = el('div', undefined, 'wt-cmds'); for (const c of list(r.commands)) box.append(commandBox(c)); return box; } },
186
+ { id: 'updated', label: 'Changed', value: r => r.updated, cell: r => when(r.updated) },
187
+ { id: 'path', label: 'Path', value: r => r.path, cell: r => el('span', r.path, 'mono'), hidden: true },
188
+ ];
189
+ function drawExtra(d) {
190
+ const out = [];
191
+ if (list(d.strays).length) {
192
+ const box = el('div', undefined, 'disk-block');
193
+ box.append(el('h2', "Not forge's, found inside run dirs", 'plate'), el('p', 'forge never removes these. Delete them by hand if nothing needs them.', 'muted'));
194
+ const ul = el('ul', undefined, 'disk-list');
195
+ for (const x of list(d.strays)) { const li = el('li'); li.append(el('strong', humanBytes(x.bytes)), el('span', ' '), el('span', x.path, 'mono')); ul.append(li); }
196
+ box.append(ul); out.push(box);
197
+ }
198
+ const wt = el('div', undefined, 'disk-block');
199
+ wt.append(el('h2', 'Worktrees', 'plate'));
200
+ const line = el('p');
201
+ line.append(el('span', `${humanBytes((d.totals || {}).worktrees || 0)} in ${list(d.worktrees).length} worktree folders. `));
202
+ const a = el('a', 'Open the Worktrees screen'); a.href = '#/worktrees';
203
+ line.append(a, el('span', ' for the state of each one and the command that removes it safely.'));
204
+ wt.append(line);
205
+ if (list(d.worktrees).length) {
206
+ const ul = el('ul', undefined, 'disk-list');
207
+ for (const w of list(d.worktrees).slice(0, 8)) { const li = el('li'); li.append(el('strong', humanBytes(w.bytes)), el('span', ' '), el('span', w.path, 'mono')); ul.append(li); }
208
+ wt.append(ul);
209
+ }
210
+ out.push(wt);
211
+ if (d.data_home) {
212
+ const box = el('div', undefined, 'disk-block');
213
+ box.append(el('h2', 'Data home', 'plate'));
214
+ const p = el('p'); p.append(el('span', humanBytes(d.data_home.bytes) + ' in '), el('span', d.data_home.path, 'mono')); box.append(p);
215
+ const ul = el('ul', undefined, 'disk-list');
216
+ for (const x of homeParts(d.data_home)) { const li = el('li'); li.append(el('strong', humanBytes(x.bytes)), el('span', ' ' + x.label)); ul.append(li); }
217
+ box.append(ul); out.push(box);
218
+ }
219
+ extra.replaceChildren(...out);
220
+ }
221
+ function drawNow() {
222
+ const a = s.answer, d = a && a.data;
223
+ if (s.error) status.replaceChildren(el('span', `Could not read the disk report (${s.error}).`, 'warn'));
224
+ else if (!a) status.replaceChildren(el('span', 'Asking…', 'muted'));
225
+ else if (a.state === 'unavailable' || (a.state === 'error' && !d)) status.replaceChildren(el('span', `Could not measure: ${a.error || 'unknown error'}.`, 'warn'));
226
+ else if (a.state === 'measuring' && !d) {
227
+ const p = a.progress;
228
+ status.replaceChildren(el('span', p && p.of ? `Measuring run dir ${p.done + 1} of ${p.of}… every file is visited, so a large one takes a while.` : 'Measuring… every file is visited, so this takes a while.', 'muted'));
229
+ } else if (d) {
230
+ const sum = summary(d);
231
+ const parts = [el('strong', humanBytes(sum.total)), el('span', ' · ' + sum.text)];
232
+ if (sum.reclaimable) parts.push(el('span', ` · about ${humanBytes(sum.reclaimable)} can go without losing a run`));
233
+ if (a.state === 'measuring') parts.push(el('span', ' · measuring again…', 'muted'));
234
+ if (!d.complete) parts.push(el('span', ' · measuring stopped at its time limit: some sizes are lower bounds', 'muted'));
235
+ status.replaceChildren(...parts);
236
+ }
237
+ if (!d) { chart.replaceChildren(); cmds.replaceChildren(); tableHost.replaceChildren(); extra.replaceChildren(); return; }
238
+ drawChart(d);
239
+ stamp.textContent = 'measured ' + when(d.computed);
240
+ cmds.replaceChildren(...list(d.commands).map(commandBox));
241
+ if (!list(d.runs).length) tableHost.replaceChildren(el('p', 'forge has no registered runs.', 'muted'));
242
+ else {
243
+ tableHost.replaceChildren();
244
+ root.ForgeTable.render(tableHost, { id: 'disk', label: 'Run dirs', columns, rows: list(d.runs), className: 'wt-grid',
245
+ onRow: (_row, tr) => { for (const td of tr.children) if (!td.classList.contains('wt-command-col') && !td.title) td.title = td.textContent; },
246
+ prefs: ctx.tablePrefs ? ctx.tablePrefs('disk') : null, savePrefs: p => ctx.saveTablePrefs && ctx.saveTablePrefs('disk', p) });
247
+ }
248
+ drawExtra(d);
249
+ }
250
+ // A redraw never pulls a command out from under someone selecting or copying it (#115).
251
+ const draw = () => { if (UI.guard) UI.guard(host, drawNow); else drawNow(); };
252
+
253
+ async function load(refresh) {
254
+ const mine = ++s.seq;
255
+ again.disabled = true;
256
+ const res = await UI.get('/api/storage' + (refresh ? '?refresh=1' : ''));
257
+ if (mine !== s.seq) return;
258
+ if (res.ok) { s.answer = res.data; s.error = null; } else s.error = res.detail || res.error || 'no answer';
259
+ again.disabled = !!(s.answer && s.answer.state === 'measuring');
260
+ draw();
261
+ clearTimeout(s.timer);
262
+ if (host.isConnected && s.answer && s.answer.state === 'measuring')
263
+ s.timer = setTimeout(() => { if (host.isConnected) load(false); }, POLL_MS);
264
+ }
265
+ drawNow();
266
+ load(false);
267
+ return { reload: () => load(true) };
268
+ }
269
+
270
+ return { render, humanBytes, summary, homeParts, repoName, HOME_LABEL, PARTS, breakdown, byRepo, pct };
271
+ });
@@ -61,6 +61,13 @@
61
61
  --sev-p1: light-dark(#783ebd, #c18dff);
62
62
  --sev-p2: light-dark(#335dbd, #88a9ff);
63
63
  --sev-p3: light-dark(#56635b, #a7b2ab);
64
+ /* the Disk screen's parts, a fixed categorical order checked for colour-blind separation on --module, both themes */
65
+ --disk-1: light-dark(#2a78d6, #3987e5);
66
+ --disk-2: light-dark(#eb6834, #d95926);
67
+ --disk-3: light-dark(#1baf7a, #199e70);
68
+ --disk-4: light-dark(#eda100, #c98500);
69
+ --disk-5: light-dark(#e87ba4, #d55181);
70
+ --disk-6: light-dark(#6250d6, #9085e9);
64
71
  /* the 3D stage: body, hairlines and the accent of what is live */
65
72
  --stage-accent: var(--lamp-amber);
66
73
  --stage-body: light-dark(#f3f5f0, #161c19);
@@ -337,7 +344,7 @@ body.no-tasks .tasks-module { display: none; }
337
344
  body[data-shell=workbench].no-tasks .run-view { grid-template-rows: auto minmax(0, 1fr) auto 0; }
338
345
  body[data-shell=immersive] .sidebar { position: absolute; z-index: 4; left: var(--gap); top: var(--gap); bottom: var(--gap); width: var(--runs-w); box-shadow: var(--ply-1); }
339
346
  body[data-shell=immersive][data-runs=closed] .sidebar { display: none; }
340
- body[data-shell=immersive]:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run]) #main { left: calc(var(--L) - var(--gap)); }
347
+ body[data-shell=immersive]:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=disk], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run]) #main { left: calc(var(--L) - var(--gap)); }
341
348
  body[data-shell=immersive] .stage-row, body[data-shell=immersive] .stage-col { position: absolute; inset: 0; }
342
349
  body[data-shell=immersive] .stage-col .stage-slot { position: absolute; inset: 0; }
343
350
  body[data-shell=immersive] .insp-module { position: absolute; z-index: 3; right: var(--gap); top: var(--gap); bottom: var(--gap); width: var(--insp-w); box-shadow: var(--ply-1); }
@@ -392,7 +399,7 @@ body[data-shell=workbench] .map-cards-host { overflow: auto; }
392
399
  body[data-shell=workbench] .map-cards { padding: var(--s-4); }
393
400
 
394
401
  /* content views: the leaderboard and the waiting pages */
395
- body:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run]) #main { padding: var(--s-6) var(--s-6) var(--s-8); }
402
+ body:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=disk], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run]) #main { padding: var(--s-6) var(--s-6) var(--s-8); }
396
403
 
397
404
  /* ---------- the stage: the panel the run is inlaid on ---------- */
398
405
  .stage-slot { position: relative; background: var(--stage-bg); }
@@ -545,7 +552,13 @@ dialog.keys-sheet::backdrop { background: light-dark(rgb(17 22 19 / .35), rgb(0
545
552
  .strip-wrap[hidden], .graph[hidden] { display: none; }
546
553
  .tasks-module { overflow: hidden; }
547
554
  .tasks-module .run-tasks { flex: 1; min-height: 0; overflow: auto; }
548
- body[data-tasks=closed] .tasks-module :is(.run-tasks, .splitter, .dt-tools) { display: none; }
555
+ /* the run's summaries switch, above the table (#133 B): a row of its own, its model beside the bank */
556
+ .tasks-switch { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); padding: var(--s-1) var(--s-2); border-bottom: 1px solid var(--rule); font-size: var(--t-sm); }
557
+ .tasks-switch[hidden] { display: none; }
558
+ .tasks-switch .sum-msgs { flex-basis: 100%; }
559
+ .tasks-switch .sum-model { display: inline-flex; }
560
+ .tasks-switch .sum-state { font-weight: 600; }
561
+ body[data-tasks=closed] .tasks-module :is(.run-tasks, .splitter, .dt-tools, .tasks-switch, .run-questions) { display: none; }
549
562
  body[data-tasks=closed] .tasks-module .module-head { border-bottom: 0; }
550
563
  .run-tasks .dt, .run-tasks .dt-frame, .run-tasks .table-scroll { height: 100%; }
551
564
  .run-tasks .table-scroll { border: 0; border-radius: 0; }
@@ -556,6 +569,20 @@ body[data-tasks=closed] .tasks-module .module-head { border-bottom: 0; }
556
569
  .insp-head h2 { font-size: var(--t-md); line-height: 1.3; margin: 0 0 2px; }
557
570
  .insp-kind { color: var(--muted); font-size: var(--t-sm); }
558
571
  .insp-head .chip { margin-top: 4px; }
572
+ /* a task opens here: title, goal and links, then the text buttons, then one line per attempt */
573
+ .task-header { display: grid; gap: 6px; margin: 0 0 var(--s-3); min-width: 0; }
574
+ .task-header-top { display: grid; gap: 4px; padding-right: 72px; min-width: 0; } /* clear the Close key */
575
+ .task-header h2 { font-size: var(--t-md); font-weight: 650; line-height: 1.3; margin: 0; }
576
+ .task-header .task-goal { margin: 0; color: var(--ink); text-wrap: pretty; }
577
+ .task-links { margin: 0; }
578
+ .task-links a.chip::before { content: none; } /* a link is not a status: no lamp */
579
+ .task-link-text { color: var(--ink-2); font-family: var(--mono); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
580
+ .task-texts { flex-wrap: wrap; max-width: 100%; }
581
+ .inspector .task-reveal { margin: 0; }
582
+ .attempt-trail { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; gap: 2px; min-width: 0; }
583
+ .trail-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; font-size: var(--t-xs); }
584
+ .trail-summary { font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
585
+ .trail-nav { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; }
559
586
  .inspector > .insp-close { position: absolute; right: var(--s-3); top: var(--s-3); min-height: 28px; padding: 0 9px; }
560
587
  .insp-section { margin: var(--s-5) 0 0; }
561
588
  .inspector > .insp-section:first-child { margin-top: var(--s-1); }
@@ -765,9 +792,49 @@ p.ctl-request-refused { color: var(--warn-ink); font-weight: 600; }
765
792
  .ctl-changes li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
766
793
  .ctl-what { color: var(--ink); font-weight: 600; }
767
794
  .ctl[aria-busy=true] .ctl-row { opacity: .7; }
795
+
796
+ /* a task's summary (#133 B): its text, where it came from, and the task's own switch (a row like a control's) */
797
+ .sum-section .sum-text { margin: 0 0 var(--s-1); white-space: pre-line; overflow-wrap: anywhere; }
798
+ .sum-by { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 var(--s-2); font-size: var(--t-xs); }
799
+ .sum-error { margin: 0 0 var(--s-2); }
800
+ .sum-sources { list-style: none; margin: 0 0 var(--s-2); padding: 0; display: grid; gap: 2px; font-size: var(--t-xs); }
801
+ .sum-sources li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; overflow-wrap: anywhere; }
802
+ .sum-switch { display: grid; gap: 6px; padding: var(--s-2) 10px; border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module-2); }
803
+ .sum-label { margin: 0; font-family: var(--font-plate); font-weight: 700; font-size: .786rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
804
+ .sum-bank { justify-self: start; flex-wrap: wrap; max-width: 100%; }
805
+ p.sum-note { margin: 0; font-size: var(--t-xs); }
806
+ .sum-msgs:empty { display: none; }
807
+ /* the one-sentence column: one line, cut off at the cell's edge */
808
+ .sum-col { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
768
809
  /* who decided an escalation, on the line that reports it */
769
810
  .src-plate { font-size: .714rem; padding: 0 5px; vertical-align: 1px; }
770
811
 
812
+ /* brief questions (#135): the run's open questions above the task table, and each question in the inspector.
813
+ The tasks module is 208px tall, so the list is a short strip and scrolls; the table keeps the rest. */
814
+ .run-questions { display: flex; flex-direction: column; flex: 0 1 auto; max-height: 5.5rem; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--rule); }
815
+ .run-questions[hidden] { display: none; }
816
+ .brief-list-head { display: flex; align-items: center; gap: var(--s-2); margin: 0; padding: 6px 10px; flex: none; }
817
+ .brief-list { list-style: none; margin: 0; padding: 0; overflow: auto; min-height: 0; flex: 1 1 auto; }
818
+ a.brief-open { display: grid; gap: 2px; min-width: 0; padding: 6px 10px; border-top: 1px solid var(--rule); color: inherit; text-decoration: none; }
819
+ a.brief-open:hover { text-decoration: none; background: var(--module-2); }
820
+ .brief-open-top { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; min-width: 0; }
821
+ .brief-open-task { color: var(--muted); }
822
+ .brief-open-text, .brief-text, .brief-got { overflow-wrap: anywhere; }
823
+ .brief-when { color: var(--muted); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
824
+ .brief-section .brief-questions { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
825
+ .brief-q { display: grid; gap: 4px; padding: var(--s-2) 10px; border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module-2); }
826
+ .brief-q p { margin: 0; }
827
+ .brief-text { white-space: pre-line; }
828
+ .brief-why, .brief-options, .brief-default, .brief-scope { font-size: var(--t-xs); color: var(--muted); overflow-wrap: anywhere; }
829
+ .brief-flags { display: flex; flex-wrap: wrap; gap: var(--s-1); }
830
+ .brief-box { display: grid; gap: 6px; margin-top: 2px; }
831
+ .brief-box textarea { width: 100%; min-height: 4.5rem; padding: 6px 10px; resize: vertical; }
832
+ .brief-box .brief-send { justify-self: start; }
833
+ .brief-msgs:empty { display: none; }
834
+ .brief-q .brief-notice { margin: 0; }
835
+ .brief-parked { margin-top: var(--s-2); }
836
+ .brief-parked > .brief-questions { margin-top: var(--s-2); }
837
+
771
838
  /* ---------- tables ---------- */
772
839
  .table-scroll { overflow: auto; max-width: 100%; border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module); }
773
840
  table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-variant-numeric: tabular-nums; }
@@ -1326,6 +1393,35 @@ table.wt-grid { width: max-content; min-width: 100%; }
1326
1393
  .wt-group { display: grid; grid-template-columns: minmax(8em, max-content) 1fr; align-items: center; gap: var(--s-3); margin: var(--s-2) 0; }
1327
1394
  .wt-copy:focus-visible, .wt-cmd code:focus-visible, .wt-groups summary:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }
1328
1395
 
1396
+ /* ---------- disk (#/disk), on the worktrees screen's parts ---------- */
1397
+ .disk-commands { display: grid; gap: 4px; max-width: 48em; }
1398
+ .disk-extra { display: grid; grid-template-columns: repeat(auto-fit, minmax(22em, 1fr)); gap: var(--s-4); }
1399
+ .disk-block h2 { margin: 0 0 var(--s-2); }
1400
+ .disk-block p { margin: 0 0 var(--s-2); }
1401
+ .disk-list { margin: 0; padding-left: 1.2em; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
1402
+ .disk-list li { overflow-wrap: anywhere; }
1403
+ .disk-view { position: relative; }
1404
+ .disk-chart { display: grid; gap: var(--s-2); padding: var(--s-4); border-radius: var(--r-module); background: var(--module); box-shadow: var(--ply-1); }
1405
+ .disk-chart h2 { margin: 0; justify-self: start; }
1406
+ .disk-chart .disk-sub { margin-top: var(--s-3); }
1407
+ .disk-bar { display: flex; gap: 2px; height: 14px; min-width: 2px; }
1408
+ .disk-bar-whole { height: 22px; }
1409
+ .disk-seg { flex-basis: 0; min-width: 2px; height: 100%; cursor: default; }
1410
+ .disk-seg:first-child { border-radius: 4px 0 0 4px; }
1411
+ .disk-seg:last-child { border-radius: 0 4px 4px 0; }
1412
+ .disk-seg:only-child { border-radius: 4px; }
1413
+ .disk-seg:hover, .disk-seg:focus-visible { outline: 2px solid var(--route); outline-offset: 1px; position: relative; z-index: 1; }
1414
+ .disk-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin: 0; padding: 0; list-style: none; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
1415
+ .disk-legend li { display: inline-flex; align-items: center; gap: 6px; }
1416
+ .disk-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
1417
+ .disk-repos { display: grid; gap: 6px; }
1418
+ .disk-repo { display: grid; grid-template-columns: minmax(8em, 16em) minmax(0, 1fr) 6em; align-items: center; gap: var(--s-3); font-size: var(--t-sm); }
1419
+ .disk-repo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1420
+ .disk-repo-size { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
1421
+ .disk-track { min-width: 0; }
1422
+ .disk-tip { position: absolute; z-index: 5; display: grid; gap: 2px; max-width: 22em; padding: 6px 10px; border-radius: var(--r-key); background: var(--key); color: var(--ink); box-shadow: var(--ply-2); font-size: var(--t-sm); pointer-events: none; font-variant-numeric: tabular-nums; }
1423
+ @media (max-width: 640px) { .disk-repo { grid-template-columns: minmax(0, 1fr) 5em; } .disk-track { grid-column: 1 / -1; grid-row: 2; } }
1424
+
1329
1425
  /* ---------- projects (#/projects) ---------- */
1330
1426
  .projects-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); max-width: 1600px; }
1331
1427
  .prj-head { display: flex; align-items: baseline; gap: var(--s-4); flex-wrap: wrap; }
@@ -1526,6 +1622,7 @@ dialog.set-guide::backdrop { background: light-dark(rgb(17 22 19 / .35), rgb(0 0
1526
1622
  /* Commits adopted from outside a run */
1527
1623
  .adoptions { display: grid; gap: var(--s-2); margin: 0; padding: 0; list-style: none; font-size: var(--t-sm); }
1528
1624
  .adoptions p { margin: var(--s-1) 0 0; text-wrap: pretty; }
1625
+ .adoption-links { display: flex; flex-wrap: wrap; gap: var(--s-3); }
1529
1626
 
1530
1627
  /* A held redraw that has lasted (#115) */
1531
1628
  .live-held { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 30; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module); color: var(--ink); box-shadow: var(--ply-2); font-size: var(--t-sm); }
@@ -57,7 +57,7 @@
57
57
  const UI = root.ForgeUI;
58
58
  const el = (tag, text, cls) => UI.el(tag, text, cls);
59
59
  const start = ctx.filter || {};
60
- const s = { data: null, error: null, filter: { repo: start.repo || '', run: start.run || '', status: 'all', kind: 'all' }, timer: null, seq: 0, loading: false };
60
+ const s = { data: null, error: null, filter: { repo: start.repo || '', run: start.run || '', status: 'disk', kind: 'all' }, timer: null, seq: 0, loading: false };
61
61
 
62
62
  const head = el('div', undefined, 'wt-head');
63
63
  const refreshKey = el('button', 'Read again'); refreshKey.type = 'button';
@@ -180,8 +180,8 @@
180
180
  notes.replaceChildren(...out);
181
181
  }
182
182
  function drawTotals(rows) {
183
- const t = totals(rows);
184
- sums.replaceChildren(el('strong', `${t.onDisk} on disk`), el('span', ` · ${humanBytes(t.bytes)}${t.pending ? ` so far, ${t.pending} still being measured` : ''} · ${t.count - t.onDisk} removed or missing · ${t.count} listed`));
183
+ const t = totals(rows), hidden = list(s.data && s.data.rows).length - list(rows).length;
184
+ sums.replaceChildren(el('strong', `${t.onDisk} on disk`), el('span', ` · ${humanBytes(t.bytes)}${t.pending ? ` so far, ${t.pending} still being measured` : ''} · ${t.count - t.onDisk} removed or missing · ${t.count} listed${hidden > 0 ? ` · ${hidden} more hidden by the filters` : ''}`));
185
185
  }
186
186
  function drawGroups() {
187
187
  const items = list(s.data && s.data.runs).filter(g => g.command && (!s.filter.run || g.key === s.filter.run) && (!s.filter.repo || g.repo === s.filter.repo));
@@ -0,0 +1,136 @@
1
+ """The Disk screen (#139): what forge takes on disk, in every repository it has runs for, and the command that
2
+ takes each part back. The same report as `forge du --all`, from the same rules (scripts/forge_storage.py,
3
+ loaded read-only the way worktrees.py loads forge_worktrees.py), never a second rule.
4
+
5
+ Read-only: the commands are text to copy, never run, so the screen works with --read-only too.
6
+
7
+ Cost: measuring visits every file of every run dir (tens of seconds for tens of GB), so none of it happens
8
+ on the normal poll. The screen asks /api/storage when it opens; the first ask starts one background
9
+ measurement and answers `measuring` until it is done. The answer is kept for CACHE_S; ?refresh=1 measures
10
+ again. Nothing is written: the footprint the storage.warn-gb check reads is `forge du`'s and the background
11
+ compaction's to keep.
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import importlib.machinery
16
+ import importlib.util
17
+ from pathlib import Path
18
+ import shlex
19
+ import threading
20
+ import time
21
+
22
+ RULES = Path(__file__).resolve().parents[2] / 'scripts' / 'forge_storage.py'
23
+ CACHE_S = 600
24
+ _STATE = {}
25
+ _LOCK = threading.Lock()
26
+
27
+
28
+ class _ReadOnlyLoader(importlib.machinery.SourceFileLoader):
29
+ def set_data(self, *args, **kwargs):
30
+ pass # no .pyc beside forge's scripts
31
+
32
+
33
+ def rules():
34
+ """forge's storage rule module (scripts/forge_storage.py), or None when it cannot be loaded."""
35
+ with _LOCK:
36
+ if 'rules' not in _STATE:
37
+ try:
38
+ spec = importlib.util.spec_from_file_location(
39
+ 'forge_storage_for_ui', RULES, loader=_ReadOnlyLoader('forge_storage_for_ui', str(RULES)))
40
+ module = importlib.util.module_from_spec(spec)
41
+ spec.loader.exec_module(module)
42
+ if not (callable(module.report) and callable(module.scan)):
43
+ raise TypeError('not the forge storage module')
44
+ _STATE['rules'] = module
45
+ except Exception:
46
+ _STATE['rules'] = None
47
+ return _STATE['rules']
48
+
49
+
50
+ def data_home():
51
+ """forge's data home, as the dataset resolves it; None when the dataset package cannot be loaded."""
52
+ try:
53
+ import sys
54
+ scripts = str(RULES.parent)
55
+ if scripts not in sys.path:
56
+ sys.path.insert(0, scripts)
57
+ from forge_dataset import data_home as home
58
+ return home()
59
+ except Exception:
60
+ return None
61
+
62
+
63
+ def q(text):
64
+ return shlex.quote(str(text))
65
+
66
+
67
+ def with_commands(result):
68
+ """The report with the commands that take each part back: text to copy, never run here."""
69
+ for run in result['runs']:
70
+ run['commands'] = []
71
+ if run['reclaimable']:
72
+ run['commands'].append(dict(label='remove its review snapshots and gzip its log copies (the run stays, viewable)',
73
+ command='forge runs compact %s --logs' % q(run['path'])))
74
+ run['commands'].append(dict(label='delete the run dir, after the dataset and an archive keep its traces (dry run)',
75
+ command='forge runs rm %s --dry-run' % q(run['path'])))
76
+ commands = []
77
+ if result['totals']['reclaimable']:
78
+ commands.append(dict(label='every run: remove the leftover review snapshots and gzip the log copies',
79
+ command='forge runs compact --all --logs', bytes=result['totals']['reclaimable']))
80
+ commands.append(dict(label='the same report in the terminal', command='forge du --all'))
81
+ result['commands'] = commands
82
+ return result
83
+
84
+
85
+ class Screen:
86
+ """The cached answer of /api/storage for one server; one measurement at a time, in a background thread."""
87
+
88
+ def __init__(self):
89
+ self.lock = threading.Lock()
90
+ self.result = None
91
+ self.error = None
92
+ self.started = None
93
+ self.progress = None
94
+ self.thread = None
95
+
96
+ def _work(self, module):
97
+ try:
98
+ home = data_home()
99
+
100
+ def progress(index, count, _path):
101
+ with self.lock:
102
+ self.progress = dict(done=index, of=count)
103
+ result = with_commands(module.report(None, home=home, progress=progress))
104
+ with self.lock:
105
+ self.result, self.error = result, None
106
+ except Exception as exc: # noqa: BLE001 -- the screen says what went wrong instead
107
+ with self.lock:
108
+ self.error = '%s: %s' % (type(exc).__name__, exc)
109
+ finally:
110
+ with self.lock:
111
+ self.thread, self.progress = None, None
112
+
113
+ def answer(self, refresh=False, now=None):
114
+ now = time.time() if now is None else now
115
+ module = rules()
116
+ if module is None:
117
+ return dict(state='unavailable', error='scripts/forge_storage.py could not be loaded', data=None)
118
+ with self.lock:
119
+ stale = self.result is None or now - self.result['computed'] > CACHE_S
120
+ if (refresh or stale) and self.thread is None:
121
+ self.started = now
122
+ self.thread = threading.Thread(target=self._work, args=(module,), name='forge-ui-storage', daemon=True)
123
+ self.thread.start()
124
+ measuring = self.thread is not None
125
+ return dict(state='measuring' if measuring else ('error' if self.error and self.result is None else 'ready'),
126
+ error=self.error, started=self.started if measuring else None, progress=self.progress,
127
+ data=self.result)
128
+
129
+
130
+ def screen(server):
131
+ """The server's Screen, made on first use."""
132
+ with _LOCK:
133
+ found = getattr(server, 'storage_screen', None)
134
+ if found is None:
135
+ found = server.storage_screen = Screen()
136
+ return found