synabun 2.4.4 → 2.4.6
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 +42 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +5 -4
- package/docs/whatsapp.md +19 -3
- package/hooks/claude-code/session-start.mjs +21 -18
- package/lib/claude-global-config.js +214 -0
- package/lib/client-config-repair.js +17 -3
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +6 -1
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +1 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +1 -0
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +1 -1
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +18 -3
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +85 -16
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +24 -5
- package/mcp-server/dist/tools/skill-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/skill-tools.js +88 -8
- package/mcp-server/dist/tools/skill-tools.js.map +1 -1
- package/mcp-server/dist/tools/tool-groups.d.ts.map +1 -1
- package/mcp-server/dist/tools/tool-groups.js +19 -4
- package/mcp-server/dist/tools/tool-groups.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/index.ts +6 -1
- package/mcp-server/src/services/neural-interface.ts +2 -1
- package/mcp-server/src/services/tool-catalog.ts +1 -1
- package/mcp-server/src/tools/agents.ts +78 -16
- package/mcp-server/src/tools/skill-tools.ts +82 -9
- package/mcp-server/src/tools/tool-groups.ts +19 -4
- package/neural-interface/i18n/en.json +484 -19
- package/neural-interface/i18n/pt-BR.json +484 -19
- package/neural-interface/lib/agents-studio-api.js +7 -2
- package/neural-interface/lib/antigravity/home.js +43 -8
- package/neural-interface/lib/antigravity/panel-bridge.js +7 -3
- package/neural-interface/lib/antigravity/tool-call.js +14 -0
- package/neural-interface/lib/assistant-brains/antigravity.js +4 -2
- package/neural-interface/lib/assistant-dispatch.js +15 -1
- package/neural-interface/lib/assistant-persona.js +8 -3
- package/neural-interface/lib/assistant-route-gate.js +11 -2
- package/neural-interface/lib/assistant-runtime.js +95 -13
- package/neural-interface/lib/assistant-spilled-output.js +53 -0
- package/neural-interface/lib/assistant-user-context.js +7 -3
- package/neural-interface/lib/browser-default.js +22 -2
- package/neural-interface/lib/browser-extension-bridge.js +50 -3
- package/neural-interface/lib/browser-extension-pin.json +7 -7
- package/neural-interface/lib/browser-extension-protocol.js +30 -1
- package/neural-interface/lib/browser-extension-setup.js +204 -36
- package/neural-interface/lib/claude-agent-bridge.js +13 -2
- package/neural-interface/lib/codex-thread-history.js +144 -7
- package/neural-interface/lib/codex-worker-app-server.js +84 -30
- package/neural-interface/lib/db.js +26 -0
- package/neural-interface/lib/greeting/sources.js +7 -3
- package/neural-interface/lib/jsonl-lines.js +10 -11
- package/neural-interface/lib/line-buffer.js +88 -0
- package/neural-interface/lib/loop-stall.js +15 -1
- package/neural-interface/lib/memory-list-read.js +105 -0
- package/neural-interface/lib/memory-timers.js +4 -1
- package/neural-interface/lib/native-loop-runtime.js +7 -3
- package/neural-interface/lib/provider-panel-api-key-auth.js +33 -6
- package/neural-interface/lib/remote-policy.js +24 -7
- package/neural-interface/lib/skills/api-v2.js +18 -3
- package/neural-interface/lib/skills/bundle.js +2 -2
- package/neural-interface/lib/skills/deploy.js +169 -34
- package/neural-interface/lib/skills/digest.js +57 -3
- package/neural-interface/lib/skills/health.js +55 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +12 -0
- package/neural-interface/lib/skills/runtime-checks.js +7 -4
- package/neural-interface/lib/skills/scan-shell.js +56 -7
- package/neural-interface/lib/skills/scan.js +13 -12
- package/neural-interface/lib/skills/service.js +7 -2
- package/neural-interface/lib/skills/telemetry.js +2 -2
- package/neural-interface/lib/teams/README.md +34 -6
- package/neural-interface/lib/teams/api.js +94 -10
- package/neural-interface/lib/teams/index.js +4 -0
- package/neural-interface/lib/teams/landing.js +195 -75
- package/neural-interface/lib/teams/recovery.js +68 -0
- package/neural-interface/lib/teams/scheduler.js +380 -61
- package/neural-interface/lib/teams/worktrees.js +123 -30
- package/neural-interface/lib/terminal-token-redaction.js +228 -58
- package/neural-interface/lib/terminal-tokens.js +18 -0
- package/neural-interface/lib/whatsapp/brain.js +21 -0
- package/neural-interface/lib/whatsapp/bridge.js +40 -4
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +6 -2
- package/neural-interface/public/index.html +117 -37
- package/neural-interface/public/shared/agents/studio/ax-api.js +27 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +1 -1
- package/neural-interface/public/shared/agents/studio/ax-icons.js +1 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-main.js +127 -41
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +436 -33
- package/neural-interface/public/shared/agents/studio/ax-teams.js +357 -10
- package/neural-interface/public/shared/agents/studio/ax-ui.js +31 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +67 -69
- package/neural-interface/public/shared/agents/studio/ax-work-answer.js +86 -0
- package/neural-interface/public/shared/agents/studio/ax-work-view.js +305 -0
- package/neural-interface/public/shared/agents/studio/ax-work.css +74 -0
- package/neural-interface/public/shared/agents/studio/ax-work.js +300 -0
- package/neural-interface/public/shared/browser-extension-updates.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-deferred.js +90 -0
- package/neural-interface/public/shared/cdx/cdx-render.js +18 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +2 -1
- package/neural-interface/public/shared/extension-setup/es-page.js +23 -4
- package/neural-interface/public/shared/extension-setup/es-view.js +51 -11
- package/neural-interface/public/shared/extension-update-view.js +1 -1
- package/neural-interface/public/shared/loading-diagnostic-entry.js +16 -1
- package/neural-interface/public/shared/settings/settings-ai-browser.js +23 -3
- package/neural-interface/public/shared/settings/settings-browser-extension.js +575 -197
- package/neural-interface/public/shared/settings/settings-extension-diagrams.js +116 -0
- package/neural-interface/public/shared/settings/settings-extension-guide.js +222 -0
- package/neural-interface/public/shared/settings/settings-ia.js +2 -2
- package/neural-interface/public/shared/settings/settings-shell.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-operations-view.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-plan.js +42 -3
- package/neural-interface/public/shared/skills/studio/sx-publish-view.js +20 -4
- package/neural-interface/public/shared/styles.css +196 -13
- package/neural-interface/public/shared/ui-settings.js +48 -11
- package/neural-interface/server.js +336 -253
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/skills/skill-forge/SKILL.md +7 -3
|
@@ -9,14 +9,37 @@
|
|
|
9
9
|
// integration branch and its last test result, the landing, and the feed of the team's events and messages. Land
|
|
10
10
|
// and Discard are the owner's, each behind a question that says what it does.
|
|
11
11
|
//
|
|
12
|
-
// The
|
|
13
|
-
//
|
|
12
|
+
// The list is in two: Open (under way, the rail's count) and Finished (landed, completed, discarded, failed). A
|
|
13
|
+
// finished team says what of it is still on disk and in git, and offers the one step that fits: Clean up worktrees
|
|
14
|
+
// (landed), Force delete kept work (a discard that kept work), Remove (nothing left); Clear finished removes every
|
|
15
|
+
// finished team that can go and says how many stay. Each is behind a question that names what goes.
|
|
16
|
+
//
|
|
17
|
+
// A ready team whose work somebody merged into its base branch outside SynaBun says "Already on <branch>" instead
|
|
18
|
+
// of "Ready to land", in the list and in its detail, and offers Clean up & remove when nothing would be lost (or
|
|
19
|
+
// says what is in the way). A card of the Open list that waits on the owner (needs attention, ready; never a running
|
|
20
|
+
// one, never one with a live worker) has one quick action beside it: Clean up & remove, Discard & remove (nothing
|
|
21
|
+
// of the team on disk) or Discard. The decisions are ax-teams.js `quickActionOf` / `teamView`.
|
|
22
|
+
//
|
|
23
|
+
// Land follows the server's preview of the landing (`landing.preview`): it is drawn only while a landing sent now
|
|
24
|
+
// would be accepted, and otherwise the card says why in the page's words. Its question shows what will move (the
|
|
25
|
+
// target branch, its tip, the integration head, the tests on that head) and the request carries those values; an
|
|
26
|
+
// answer that they no longer hold (LANDING_PREVIEW_STALE) lands nothing and asks again with the fresh ones. When the
|
|
27
|
+
// tests are all that is in the way, Land without tests is a second, plain button with a question of its own, and the
|
|
28
|
+
// only request that carries the owner's override. The decisions are ax-teams.js `landWithPreview` / `landQuestionOf`.
|
|
29
|
+
// A server without the preview is drawn as before.
|
|
30
|
+
//
|
|
31
|
+
// The routes are the team scheduler's (GET /teams, /teams/:id, POST /teams/:id/land and /discard; with the
|
|
32
|
+
// capabilities `teams-cleanup` and `teams-remove`, POST /teams/:id/cleanup, DELETE /teams/:id and POST
|
|
33
|
+
// /teams/clear-finished; with `teams-on-target`, POST /teams/:id/cleanup-merged; with `teams-quick-discard`, the
|
|
34
|
+
// list's `liveRuns` / `left` and discard's `remove`). A server that does not have them yet answers "not there": the
|
|
35
|
+
// place then says what teams are and waits, without an error; a server without a capability is offered nothing that
|
|
36
|
+
// needs it.
|
|
14
37
|
|
|
15
38
|
import { html, setHTML, ICONS } from '../../skills/studio/sx-dom.js';
|
|
16
|
-
import { teamRows, teamView } from './ax-teams.js';
|
|
39
|
+
import { teamRows, teamView, splitTeams, clearableTeams, quickActionOf, landQuestionOf, landWithPreview, landCopy } from './ax-teams.js';
|
|
17
40
|
import { baseName } from './ax-library.js';
|
|
18
41
|
import { AX_ICONS } from './ax-icons.js';
|
|
19
|
-
import { timeTag, loadingHTML, errorHTML, emptyHTML, errorText, wordOr } from './ax-ui.js';
|
|
42
|
+
import { timeTag, loadingHTML, errorHTML, emptyHTML, errorText, wordOr, shellText } from './ax-ui.js';
|
|
20
43
|
|
|
21
44
|
let life = null;
|
|
22
45
|
let refreshTimer = 0;
|
|
@@ -38,6 +61,57 @@ const chip = (label, tone) => html`<span class="sx-state-chip ax-run-state ax-ru
|
|
|
38
61
|
const teamState = (t, state) => wordOr(t, 'agentsStudio.teams.state', state || 'unknown');
|
|
39
62
|
const sliceState = (t, state) => wordOr(t, 'agentsStudio.teams.sliceState', state || 'unknown');
|
|
40
63
|
const shortCommit = (commit) => String(commit || '').slice(0, 9);
|
|
64
|
+
/** A team's status as a chip: "Already on <branch>" for a ready team whose work is there, its status otherwise. */
|
|
65
|
+
const statusChip = (t, team) => (team.onTarget ? chip(t('agentsStudio.teams.onTarget', { branch: team.onTarget.branch }), team.tone) : chip(teamState(t, team.status), team.tone));
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A string of the landing: the translator's, or the module's own English (ax-teams.js LAND_COPY) when the locale
|
|
69
|
+
* file of this build does not have the key yet. The question that moves the owner's branch never shows a key.
|
|
70
|
+
*/
|
|
71
|
+
const say = (t, key, params) => {
|
|
72
|
+
const said = t(key, params);
|
|
73
|
+
return said === key ? landCopy(key, params) || key : said;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The landing's question in the Studio's dialog (ax-teams.js `landQuestionOf` says what is in it): the lines before,
|
|
78
|
+
* the facts as the page's fact list (a branch and a hash in monospace, a hash whole in its title, the tests as a
|
|
79
|
+
* status chip), the lines after, and Cancel with the keyboard on it. Answers 'go' or 'cancel'.
|
|
80
|
+
*/
|
|
81
|
+
function askLanding(ctx, question) {
|
|
82
|
+
const { t } = ctx;
|
|
83
|
+
const lineOf = (line) => {
|
|
84
|
+
const p = document.createElement('p');
|
|
85
|
+
if (line.tone === 'warn') { p.className = 'sx-warn-text'; p.setAttribute('role', 'note'); }
|
|
86
|
+
p.dataset.land = line.id;
|
|
87
|
+
p.textContent = line.key ? say(t, line.key, line.params) : line.text;
|
|
88
|
+
return p;
|
|
89
|
+
};
|
|
90
|
+
let extra = null;
|
|
91
|
+
if (question.facts.length) {
|
|
92
|
+
const facts = document.createElement('dl');
|
|
93
|
+
facts.className = 'ax-facts';
|
|
94
|
+
setHTML(facts, html`${question.facts.map((fact) => html`<div data-land="${fact.id}"><dt>${say(t, fact.label)}</dt><dd${fact.chip ? '' : html` class="sx-mono"`}${fact.value && fact.shown !== fact.value ? html` title="${fact.value}"` : ''}>${fact.chip ? chip(say(t, fact.chip.key), fact.chip.tone) : fact.value ? fact.shown : fact.missing ? say(t, fact.missing) : '—'}</dd></div>`)}`);
|
|
95
|
+
extra = document.createElement('div');
|
|
96
|
+
extra.className = 'ax-dlg-form';
|
|
97
|
+
extra.append(facts, ...question.after.map(lineOf));
|
|
98
|
+
}
|
|
99
|
+
return ctx.ask({
|
|
100
|
+
title: say(t, question.title.key, question.title.params),
|
|
101
|
+
lines: [...question.before.map(lineOf), ...(extra ? [] : question.after.map(lineOf))],
|
|
102
|
+
extra,
|
|
103
|
+
className: 'ax-dlg',
|
|
104
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, ...(question.confirm ? [{ id: 'go', label: say(t, question.confirm.key), kind: question.confirm.kind }] : [])],
|
|
105
|
+
focus: 'cancel',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A card's quick action: its words and its kind of button (the decision is ax-teams.js `quickActionOf`). */
|
|
110
|
+
const QUICK = Object.freeze({
|
|
111
|
+
'cleanup-merged': { label: 'agentsStudio.teams.cleanupMerged', kind: 'primary' },
|
|
112
|
+
'discard-remove': { label: 'agentsStudio.teams.discardRemove', kind: 'danger' },
|
|
113
|
+
discard: { label: 'agentsStudio.teams.discard', kind: 'danger' },
|
|
114
|
+
});
|
|
41
115
|
|
|
42
116
|
function listHTML(ctx, st) {
|
|
43
117
|
const { t } = ctx;
|
|
@@ -50,10 +124,113 @@ function listHTML(ctx, st) {
|
|
|
50
124
|
lines: [t('agentsStudio.teams.emptyHelp'), st.available === false ? t(st.notRunning ? 'agentsStudio.teams.notRunning' : 'agentsStudio.teams.notAvailable') : t('agentsStudio.teams.emptyHow')],
|
|
51
125
|
});
|
|
52
126
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
127
|
+
const { open, finished } = splitTeams(rows);
|
|
128
|
+
// Whether the server can say a finished team still has worktrees (and remove the ones that do not).
|
|
129
|
+
const removing = ctx.caps.has('teams-remove');
|
|
130
|
+
const clear = clearableTeams(rows);
|
|
131
|
+
const canClear = ctx.owner && removing && clear.removable.length > 0;
|
|
132
|
+
let first = true;
|
|
133
|
+
const rowHTML = (row) => {
|
|
134
|
+
const autofocus = first;
|
|
135
|
+
first = false;
|
|
136
|
+
// The card opens the team; its quick action (the owner's, a team that waits on the owner) is a button of its own
|
|
137
|
+
// beside it, never inside it, and the team's title describes it.
|
|
138
|
+
const quick = ctx.owner ? quickActionOf(row, ctx.caps) : null;
|
|
139
|
+
const titleId = `ax-team-t-${row.id}`;
|
|
140
|
+
return html`<li class="ax-team-item"><button type="button" class="ax-team-row" data-act="open-team" data-team="${row.id}"${autofocus ? html` data-autofocus` : ''}>
|
|
141
|
+
<span class="ax-team-row-main"><span class="ax-team-title" id="${titleId}">${row.title || row.id}</span><span class="sx-mono ax-team-id">${row.id}</span></span>
|
|
142
|
+
<span class="ax-team-row-meta">${statusChip(t, row)}${row.onTarget && !row.onTarget.clean ? html`<span class="ax-team-left">${t('agentsStudio.teams.onTargetBlocked')}</span>` : ''}${row.finished && removing && !row.removable ? html`<span class="ax-team-left">${t('agentsStudio.teams.leftTag')}</span>` : ''}${row.slices !== null ? html`<span>${ctx.tp('agentsStudio.teams.slices', row.slices)}</span>` : ''}${row.density ? html`<span>${wordOr(t, 'agentsStudio.teams.density', row.density)}</span>` : ''}${row.project ? html`<span class="sx-tag" title="${row.project}">${AX_ICONS.pin}<span>${baseName(row.project)}</span></span>` : ''}<span class="sx-spacer"></span>${timeTag(row.createdAt, ctx.locale)}</span>
|
|
143
|
+
</button>${quick ? html`<span class="ax-team-quick"><button type="button" class="sx-btn sx-btn--sm sx-btn--${QUICK[quick].kind}" data-act="quick" data-quick="${quick}" data-team="${row.id}" aria-describedby="${titleId}"${st.busy ? html` disabled` : ''}>${ICONS.trash}${t(QUICK[quick].label)}</button></span>` : ''}</li>`;
|
|
144
|
+
};
|
|
145
|
+
return html`<div class="ax-team-groups">
|
|
146
|
+
<section class="ax-team-group" aria-labelledby="ax-teams-open-title">
|
|
147
|
+
<header class="ax-team-group-head"><h4 class="sx-section-title" id="ax-teams-open-title">${t('agentsStudio.teams.openTitle')}</h4><span class="ax-team-group-count">${open.length}</span></header>
|
|
148
|
+
${open.length ? html`<ul class="ax-team-list" aria-labelledby="ax-teams-open-title">${open.map(rowHTML)}</ul>` : html`<p class="sx-note">${t('agentsStudio.teams.openEmpty')}</p>`}
|
|
149
|
+
</section>
|
|
150
|
+
${finished.length ? html`<section class="ax-team-group" aria-labelledby="ax-teams-finished-title">
|
|
151
|
+
<header class="ax-team-group-head"><h4 class="sx-section-title" id="ax-teams-finished-title">${t('agentsStudio.teams.finishedTitle')}</h4><span class="ax-team-group-count">${finished.length}</span><span class="sx-spacer"></span>${canClear ? html`<button type="button" class="sx-btn sx-btn--sm" data-act="clear-finished"${st.busy ? html` disabled` : ''}>${ICONS.trash}${t('agentsStudio.teams.clearFinished')}</button>` : ''}</header>
|
|
152
|
+
<ul class="ax-team-list" aria-labelledby="ax-teams-finished-title">${finished.map(rowHTML)}</ul>
|
|
153
|
+
</section>` : ''}
|
|
154
|
+
</div>`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** How one thing that is left reads in a list: its folder (or branch), its branch beside it. */
|
|
158
|
+
const leftLine = (item) => (item.path && item.branch ? `${item.path} · ${item.branch}` : item.path || item.branch);
|
|
159
|
+
|
|
160
|
+
/** Why a discard kept a worktree, as a short note: the reason, the files, the commits. */
|
|
161
|
+
function keptNote(ctx, kept) {
|
|
162
|
+
if (!kept) return '';
|
|
163
|
+
const { t } = ctx;
|
|
164
|
+
const parts = [kept.reason ? wordOr(t, 'agentsStudio.teams.keptReason', kept.reason) : ''];
|
|
165
|
+
if (kept.files.length) parts.push(ctx.tp('agentsStudio.teams.keptFiles', kept.files.length));
|
|
166
|
+
if (kept.commits) parts.push(ctx.tp('agentsStudio.teams.keptCommits', kept.commits));
|
|
167
|
+
return parts.filter(Boolean).join(' · ');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Why a finished team's record cannot go, when nothing that is left is the reason. */
|
|
171
|
+
function blockedText(t, code) {
|
|
172
|
+
const said = t(`agentsStudio.teams.removalBlocked.${code}`);
|
|
173
|
+
return said === `agentsStudio.teams.removalBlocked.${code}` ? t('agentsStudio.teams.removalBlocked.other') : said;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Why a team stayed in the list after a step that would have removed it (the answer's `removal`). */
|
|
177
|
+
function stayReason(t, removal) {
|
|
178
|
+
const code = removal?.code;
|
|
179
|
+
return !code || code === 'TEAM_WORKTREES_LEFT' ? t('agentsStudio.teams.leftTag') : blockedText(t, code);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A finished team's worktrees and branches: what is still on disk and in git, and the one step that fits (the
|
|
184
|
+
* owner's only). Nothing is drawn for a server that does not say (no `removal`).
|
|
185
|
+
*/
|
|
186
|
+
function diskHTML(ctx, st, team) {
|
|
187
|
+
const { t } = ctx;
|
|
188
|
+
const r = team.removal;
|
|
189
|
+
if (!team.finished || !r) return '';
|
|
190
|
+
const busy = st.busy ? html` disabled` : '';
|
|
191
|
+
const keptBy = new Map(team.kept.filter((item) => item.sliceId).map((item) => [item.sliceId, item]));
|
|
192
|
+
const lead = r.next === 'cleanup' ? 'agentsStudio.teams.cleanupLead' : r.next === 'force_discard' ? 'agentsStudio.teams.keptLead' : 'agentsStudio.teams.byHandLead';
|
|
193
|
+
const owner = ctx.owner;
|
|
194
|
+
const actions = [
|
|
195
|
+
owner && team.canCleanup && ctx.caps.has('teams-cleanup') ? html`<button type="button" class="sx-btn sx-btn--primary" data-act="cleanup"${busy}>${ICONS.trash}${t('agentsStudio.teams.cleanup')}</button>` : '',
|
|
196
|
+
owner && team.canForceDiscard ? html`<button type="button" class="sx-btn sx-btn--danger" data-act="force-discard"${busy}>${ICONS.trash}${t('agentsStudio.teams.forceDiscard')}</button>` : '',
|
|
197
|
+
owner && team.canRemove && ctx.caps.has('teams-remove') ? html`<button type="button" class="sx-btn sx-btn--danger" data-act="remove"${busy}>${ICONS.trash}${t('agentsStudio.teams.remove')}</button>` : '',
|
|
198
|
+
].filter(Boolean);
|
|
199
|
+
return html`<section class="ax-side-card ax-team-disk" aria-labelledby="ax-team-disk-title">
|
|
200
|
+
<h4 class="sx-section-title" id="ax-team-disk-title">${AX_ICONS.branch} ${t('agentsStudio.teams.diskTitle')}</h4>
|
|
201
|
+
${r.removable ? html`<p class="sx-note">${t('agentsStudio.teams.diskClean')}</p>` : ''}
|
|
202
|
+
${!r.removable && r.left.length ? html`<p class="sx-field-note${r.next === 'force_discard' ? ' sx-warn-text' : ''}" role="note">${t(lead)}</p>
|
|
203
|
+
<ul class="sx-plain-list ax-left-list">${r.left.map((item) => { const note = keptNote(ctx, keptBy.get(item.sliceId)); return html`<li><span class="sx-mono ax-left-path">${item.path || item.branch}</span>${item.path && item.branch ? html`<span class="sx-mono sx-dim">${item.branch}</span>` : ''}${note ? html`<span class="sx-help">${note}</span>` : ''}</li>`; })}</ul>` : ''}
|
|
204
|
+
${!r.removable && !r.left.length ? html`<p class="sx-field-note sx-warn-text" role="note">${blockedText(t, r.code)}</p>` : ''}
|
|
205
|
+
${actions.length ? html`<div class="sx-row ax-team-actions">${actions}</div>` : ''}
|
|
206
|
+
</section>`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A ready team whose work is on its base branch already (merged outside SynaBun): where it is, and either the one
|
|
211
|
+
* step that fits (Clean up & remove, the owner's) or exactly what keeps the worktrees and branches from going
|
|
212
|
+
* (uncommitted edits per worktree, commits the base branch lacks, a live worker, git's own words).
|
|
213
|
+
*/
|
|
214
|
+
function onTargetHTML(ctx, st, team) {
|
|
215
|
+
const o = team.onTarget;
|
|
216
|
+
if (!o) return '';
|
|
217
|
+
const { t } = ctx;
|
|
218
|
+
const branch = o.branch;
|
|
219
|
+
const problems = [
|
|
220
|
+
...o.dirty.map((item) => html`<li><span class="sx-mono ax-left-path">${ctx.tp('agentsStudio.teams.onTargetDirty', item.files.length, { path: item.path })}</span><span class="sx-mono sx-dim">${item.files.slice(0, 6).join(', ')}${item.files.length > 6 ? ' …' : ''}</span></li>`),
|
|
221
|
+
...o.unmerged.map((item) => html`<li><span class="sx-mono ax-left-path">${ctx.tp('agentsStudio.teams.onTargetUnmerged', item.commits, { branch: item.branch, target: branch })}</span></li>`),
|
|
222
|
+
...(o.runs === null ? [html`<li><span class="sx-help">${t('agentsStudio.teams.onTargetNoRuns')}</span></li>`] : o.runs > 0 ? [html`<li><span class="sx-help">${ctx.tp('agentsStudio.teams.onTargetRuns', o.runs)}</span></li>`] : []),
|
|
223
|
+
...o.other.map((line) => html`<li><span class="sx-mono sx-dim">${line}</span></li>`),
|
|
224
|
+
];
|
|
225
|
+
const offer = ctx.owner && team.canCleanupMerged && ctx.caps.has('teams-on-target');
|
|
226
|
+
return html`<section class="ax-side-card ax-team-ontarget${o.clean ? '' : ' is-blocked'}" aria-labelledby="ax-team-ontarget-title">
|
|
227
|
+
<h4 class="sx-section-title" id="ax-team-ontarget-title">${AX_ICONS.branch} ${t('agentsStudio.teams.onTarget', { branch })}</h4>
|
|
228
|
+
<p class="sx-note">${t('agentsStudio.teams.onTargetLead', { branch })}</p>
|
|
229
|
+
${o.clean ? html`<p class="sx-field-note" role="note">${t('agentsStudio.teams.onTargetClean', { branch })}</p>` : html`<p class="sx-field-note sx-warn-text" role="note">${t('agentsStudio.teams.onTargetNotClean')}</p>
|
|
230
|
+
${problems.length ? html`<ul class="sx-plain-list ax-left-list">${problems}</ul>` : ''}
|
|
231
|
+
<p class="sx-help">${t('agentsStudio.teams.onTargetFix', { branch })}</p>`}
|
|
232
|
+
${offer ? html`<div class="sx-row ax-team-actions"><button type="button" class="sx-btn sx-btn--primary" data-act="cleanup-merged"${st.busy ? html` disabled` : ''}>${ICONS.trash}${t('agentsStudio.teams.cleanupMerged')}</button></div>` : ''}
|
|
233
|
+
</section>`;
|
|
57
234
|
}
|
|
58
235
|
|
|
59
236
|
function sliceHTML(ctx, slice) {
|
|
@@ -76,17 +253,28 @@ function sliceHTML(ctx, slice) {
|
|
|
76
253
|
|
|
77
254
|
function detailHTML(ctx, st) {
|
|
78
255
|
const { t } = ctx;
|
|
79
|
-
if (st.
|
|
256
|
+
if (!st.team && (st.detailLoading || st.detailFor !== ctx.view.teamId)) return loadingHTML(t);
|
|
80
257
|
if (st.detailError) return errorHTML(t, st.detailError);
|
|
81
258
|
if (!st.team) return emptyHTML({ icon: AX_ICONS.teams, title: t('agentsStudio.teams.goneTitle'), lines: [t('agentsStudio.teams.goneHelp')], actions: html`<button type="button" class="sx-btn" data-act="back">${t('agentsStudio.teams.backToList')}</button>` });
|
|
82
259
|
const team = teamView(st.team);
|
|
83
260
|
const i = team.integration;
|
|
84
261
|
const l = team.landing;
|
|
85
262
|
const tests = i.tests;
|
|
263
|
+
// What a landing sent now would move (the server's preview; null on a server without it, or for a team that is over).
|
|
264
|
+
const preview = team.landPreview;
|
|
265
|
+
const why = team.landWhy;
|
|
266
|
+
// Why Land is not offered: its work is on its base branch already, the preview's refusal in the page's words (the
|
|
267
|
+
// server's own sentence for a code the page does not know), or, without a preview, that the team is not ready yet.
|
|
268
|
+
const landHelp = team.onTarget ? t('agentsStudio.teams.onTargetNothingToLand', { branch: team.onTarget.branch })
|
|
269
|
+
: why ? (why.key ? say(t, why.key, why.params) : why.text)
|
|
270
|
+
: t('agentsStudio.teams.landNotReady');
|
|
271
|
+
// With a preview Land is drawn only while it can land; without one it is there and disabled, as before.
|
|
272
|
+
const landButton = !preview || team.canLand;
|
|
273
|
+
const busy = st.busy ? html` disabled` : '';
|
|
86
274
|
return html`<div class="ax-team">
|
|
87
275
|
<section class="ax-team-summary" aria-label="${t('agentsStudio.teams.summary')}">
|
|
88
276
|
<dl class="ax-facts">
|
|
89
|
-
<div><dt>${t('agentsStudio.teams.status')}</dt><dd>${
|
|
277
|
+
<div><dt>${t('agentsStudio.teams.status')}</dt><dd>${statusChip(t, team)}</dd></div>
|
|
90
278
|
${team.project ? html`<div><dt>${t('agentsStudio.teams.project')}</dt><dd class="sx-mono" title="${team.project}">${team.project}</dd></div>` : ''}
|
|
91
279
|
${team.density ? html`<div><dt>${t('agentsStudio.teams.densityLabel')}</dt><dd>${wordOr(t, 'agentsStudio.teams.density', team.density)}</dd></div>` : ''}
|
|
92
280
|
${team.baseBranch || team.baseCommit ? html`<div><dt>${t('agentsStudio.teams.base')}</dt><dd class="sx-mono">${team.baseBranch}${team.baseCommit ? ` @ ${shortCommit(team.baseCommit)}` : ''}</dd></div>` : ''}
|
|
@@ -94,6 +282,8 @@ function detailHTML(ctx, st) {
|
|
|
94
282
|
</dl>
|
|
95
283
|
${team.attention ? html`<p class="sx-field-note sx-warn-text ax-team-attention" role="note">${team.attention}</p>` : ''}
|
|
96
284
|
</section>
|
|
285
|
+
${onTargetHTML(ctx, st, team)}
|
|
286
|
+
${diskHTML(ctx, st, team)}
|
|
97
287
|
<section aria-labelledby="ax-team-slices-title">
|
|
98
288
|
<h4 class="sx-section-title" id="ax-team-slices-title">${ctx.tp('agentsStudio.teams.slices', team.slices.length)}</h4>
|
|
99
289
|
${team.slices.length ? html`<div class="ax-slices">${team.slices.map((slice) => sliceHTML(ctx, slice))}</div>` : html`<p class="sx-note">${t('agentsStudio.teams.noSlices')}</p>`}
|
|
@@ -114,16 +304,17 @@ function detailHTML(ctx, st) {
|
|
|
114
304
|
<section class="ax-side-card" aria-labelledby="ax-team-land-title">
|
|
115
305
|
<h4 class="sx-section-title" id="ax-team-land-title">${ICONS.publish} ${t('agentsStudio.teams.landing')}</h4>
|
|
116
306
|
<dl class="ax-facts">
|
|
117
|
-
<div><dt>${t('agentsStudio.teams.status')}</dt><dd>${l.state ? wordOr(t, 'agentsStudio.teams.landingState', l.state) : t(team.status === 'merged' || team.status === 'landed' ? 'agentsStudio.teams.landed' : 'agentsStudio.teams.notLanded')}</dd></div>
|
|
118
|
-
${l.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono">${l.targetBranch}</dd></div>` : ''}
|
|
307
|
+
<div><dt>${t('agentsStudio.teams.status')}</dt><dd>${team.onTarget ? t('agentsStudio.teams.onTarget', { branch: team.onTarget.branch }) : l.state ? wordOr(t, 'agentsStudio.teams.landingState', l.state) : t(team.status === 'merged' || team.status === 'landed' ? 'agentsStudio.teams.landed' : 'agentsStudio.teams.notLanded')}</dd></div>
|
|
308
|
+
${preview?.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono"${preview.targetHead ? html` title="${preview.targetHead}"` : ''}>${preview.targetBranch}${preview.targetHead ? ` @ ${shortCommit(preview.targetHead)}` : ''}</dd></div>` : l.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono">${l.targetBranch}</dd></div>` : ''}
|
|
119
309
|
${l.commit ? html`<div><dt>${t('agentsStudio.teams.head')}</dt><dd class="sx-mono">${shortCommit(l.commit)}</dd></div>` : ''}
|
|
120
310
|
${l.at ? html`<div><dt>${t('agentsStudio.teams.landedAt')}</dt><dd>${timeTag(l.at, ctx.locale)}</dd></div>` : ''}
|
|
121
311
|
</dl>
|
|
122
312
|
${l.error ? html`<p class="sx-field-note sx-err-text">${l.error}</p>` : ''}
|
|
123
|
-
${ctx.owner ? html`<div class="sx-row ax-team-actions">
|
|
124
|
-
|
|
313
|
+
${ctx.owner ? html`${!team.canLand && why ? html`<p class="sx-field-note${why.tone === 'warn' ? ' sx-warn-text' : ''}" role="note" data-land-why="${why.code || 'other'}">${landHelp}</p>` : ''}<div class="sx-row ax-team-actions">
|
|
314
|
+
${landButton ? html`<button type="button" class="sx-btn sx-btn--primary" data-act="land"${team.canLand && !st.busy ? '' : html` disabled`} title="${team.canLand ? t('agentsStudio.teams.landHelp') : landHelp}">${ICONS.publish}${t('agentsStudio.teams.land')}</button>` : ''}
|
|
315
|
+
${team.canLandUntested ? html`<button type="button" class="sx-btn" data-act="land-untested"${busy} title="${say(t, 'agentsStudio.teams.landUntestedHelp')}">${say(t, 'agentsStudio.teams.landUntested')}</button>` : ''}
|
|
125
316
|
<button type="button" class="sx-btn sx-btn--danger" data-act="discard"${team.canDiscard && !st.busy ? '' : html` disabled`}>${ICONS.trash}${t('agentsStudio.teams.discard')}</button>
|
|
126
|
-
</div>${team.canLand ? '' : html`<p class="sx-help">${
|
|
317
|
+
</div>${team.canLand || why ? '' : html`<p class="sx-help">${landHelp}</p>`}` : ''}
|
|
127
318
|
</section>
|
|
128
319
|
</div>`}
|
|
129
320
|
<section aria-labelledby="ax-team-feed-title">
|
|
@@ -155,20 +346,21 @@ export async function loadTeams(ctx, st, { teamId = null } = {}) {
|
|
|
155
346
|
st.error = error;
|
|
156
347
|
}
|
|
157
348
|
st.loading = false;
|
|
158
|
-
if (teamId) await loadTeam(ctx, st, teamId);
|
|
349
|
+
if (teamId && ctx.view.teamId === teamId) await loadTeam(ctx, st, teamId);
|
|
159
350
|
}
|
|
160
351
|
|
|
161
352
|
async function loadTeam(ctx, st, teamId) {
|
|
162
353
|
const gen = ctx.gen();
|
|
354
|
+
const read = ++st.detailRead;
|
|
163
355
|
st.detailLoading = true;
|
|
164
356
|
try {
|
|
165
357
|
const res = await ctx.api.team(teamId);
|
|
166
|
-
if (!ctx.alive(gen)) return;
|
|
358
|
+
if (!ctx.alive(gen) || read !== st.detailRead) return;
|
|
167
359
|
st.team = res.team;
|
|
168
360
|
st.teamId = teamId;
|
|
169
361
|
st.detailError = null;
|
|
170
362
|
} catch (error) {
|
|
171
|
-
if (!ctx.alive(gen)) return;
|
|
363
|
+
if (!ctx.alive(gen) || read !== st.detailRead) return;
|
|
172
364
|
st.detailError = error;
|
|
173
365
|
}
|
|
174
366
|
// Read once for this team: a team that is gone (or a server without the route) is not asked for again by a redraw.
|
|
@@ -187,7 +379,7 @@ export function onTeamChanged(ctx, st, teamId) {
|
|
|
187
379
|
}
|
|
188
380
|
|
|
189
381
|
export function newTeamsState() {
|
|
190
|
-
return { rows: null, available: null, notRunning: false, loading: false, error: null, team: null, teamId: null, detailFor: null, detailLoading: false, detailError: null, busy: false };
|
|
382
|
+
return { rows: null, available: null, notRunning: false, loading: false, error: null, team: null, teamId: null, detailFor: null, detailRead: 0, detailLoading: false, detailError: null, busy: false };
|
|
191
383
|
}
|
|
192
384
|
|
|
193
385
|
/** Draw Teams in the main area: the list, or one team. */
|
|
@@ -197,12 +389,19 @@ export function renderTeams(main, ctx, st) {
|
|
|
197
389
|
const { signal } = life;
|
|
198
390
|
const { t } = ctx;
|
|
199
391
|
const teamId = ctx.view.teamId;
|
|
200
|
-
if (teamId && st.teamId !== teamId) {
|
|
392
|
+
if (teamId && st.teamId !== teamId) {
|
|
393
|
+
st.detailRead++;
|
|
394
|
+
st.detailLoading = false;
|
|
395
|
+
st.team = null;
|
|
396
|
+
st.teamId = teamId;
|
|
397
|
+
st.detailError = null;
|
|
398
|
+
st.detailFor = null;
|
|
399
|
+
}
|
|
201
400
|
const row = teamId ? (st.rows || []).find((r) => r.id === teamId) : null;
|
|
202
401
|
const title = teamId ? (st.team ? teamView(st.team).title : row?.title) || teamId : t('agentsStudio.rail.teams');
|
|
203
402
|
setHTML(main, html`<section class="sx-place ax-place" aria-labelledby="ax-teams-title">
|
|
204
403
|
<header class="sx-place-head">
|
|
205
|
-
|
|
404
|
+
<button type="button" class="sx-link" data-act="back">${ICONS.back}${shellText(t, ctx.view.from === 'manage-teams' ? 'agentsStudio.teams.manage' : 'agentsStudio.rail.work')}</button>
|
|
206
405
|
<h3 class="sx-place-title" id="ax-teams-title" tabindex="-1"${teamId ? html` data-autofocus` : ''}>${title}</h3>
|
|
207
406
|
${teamId ? html`<span class="sx-mono sx-dim">${teamId}</span>` : html`<p class="sx-place-sub">${t('agentsStudio.teams.sub')}</p>`}
|
|
208
407
|
<span class="sx-spacer"></span>
|
|
@@ -218,29 +417,216 @@ export function renderTeams(main, ctx, st) {
|
|
|
218
417
|
if (st.rows === null && !st.loading && !st.error) reload();
|
|
219
418
|
else if (teamId && st.detailFor !== teamId && !st.detailLoading) loadTeam(ctx, st, teamId).then(() => { if (ctx.view.place === 'teams') ctx.render({ keepFocus: true }); });
|
|
220
419
|
|
|
221
|
-
const
|
|
420
|
+
const gen = ctx.gen();
|
|
421
|
+
const afterWrite = () => {
|
|
422
|
+
if (!ctx.alive(gen)) return;
|
|
423
|
+
ctx.refreshWork?.();
|
|
424
|
+
return reload();
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Land, or Land without tests (`untested`: the owner's own decision, the only request with the override). The
|
|
429
|
+
* question shows what will move and the request carries exactly those values. When the server answers that they
|
|
430
|
+
* no longer hold, nothing was landed and nothing is sent again by itself: the question comes back with the fresh
|
|
431
|
+
* values (or, when they offer nothing any more, with why), for the owner to confirm again or cancel.
|
|
432
|
+
*/
|
|
433
|
+
const land = async (untested) => {
|
|
434
|
+
const view = teamView(st.team);
|
|
435
|
+
if (!(untested ? view.canLandUntested : view.canLand)) return;
|
|
436
|
+
const name = view.title || view.id;
|
|
437
|
+
const branch = view.landing.targetBranch || view.baseBranch || t('agentsStudio.teams.yourBranch');
|
|
438
|
+
const failedOn = view.integration.tests?.passed === false ? view.integration.tests.commit : '';
|
|
439
|
+
let done = null;
|
|
440
|
+
try {
|
|
441
|
+
done = await landWithPreview({
|
|
442
|
+
preview: view.landPreview,
|
|
443
|
+
untested,
|
|
444
|
+
ask: ({ preview, offer, stale }) => askLanding(ctx, landQuestionOf({ preview, offer, stale, name, branch, failedOn })),
|
|
445
|
+
send: (body) => { st.busy = true; ctx.render({ keepFocus: true }); return ctx.api.landTeam(view.id, body); },
|
|
446
|
+
});
|
|
447
|
+
if (done.outcome === 'landed') ctx.toast(t('agentsStudio.teams.landedToast'));
|
|
448
|
+
} catch (error) {
|
|
449
|
+
ctx.toast(t('agentsStudio.teams.landFailed', { error: errorText(t, error) }), 'error');
|
|
450
|
+
}
|
|
451
|
+
// Cancelled before anything was asked of the server: the page is as it was.
|
|
452
|
+
if (done && done.outcome !== 'landed' && !done.stale) return;
|
|
453
|
+
st.busy = false;
|
|
454
|
+
await afterWrite();
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
const discard = async () => {
|
|
458
|
+
const view = teamView(st.team);
|
|
459
|
+
const answer = await ctx.ask({
|
|
460
|
+
title: t('agentsStudio.teams.discardTitle', { name: view.title || view.id }),
|
|
461
|
+
lines: [t('agentsStudio.teams.discardAsk'), t('agentsStudio.teams.discardKeeps')],
|
|
462
|
+
className: 'ax-dlg',
|
|
463
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t('agentsStudio.teams.discard'), kind: 'danger' }],
|
|
464
|
+
focus: 'cancel',
|
|
465
|
+
});
|
|
466
|
+
if (answer !== 'go') return;
|
|
467
|
+
st.busy = true;
|
|
468
|
+
ctx.render({ keepFocus: true });
|
|
469
|
+
try {
|
|
470
|
+
const out = await ctx.api.discardTeam(view.id, {});
|
|
471
|
+
const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
|
|
472
|
+
// What holds work is kept: say so, and where it can be deleted.
|
|
473
|
+
ctx.toast(kept ? ctx.tp('agentsStudio.teams.discardKeptToast', kept) : t('agentsStudio.teams.discardedToast'));
|
|
474
|
+
} catch (error) {
|
|
475
|
+
ctx.toast(t('agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
|
|
476
|
+
}
|
|
477
|
+
st.busy = false;
|
|
478
|
+
await afterWrite();
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
/** The things a question lists: at most ten, then how many more. */
|
|
482
|
+
const listed = (items) => [...items.slice(0, 10).map((item) => `• ${leftLine(item)}`), items.length > 10 ? ctx.tp('agentsStudio.teams.moreItems', items.length - 10) : null];
|
|
483
|
+
|
|
484
|
+
/** Clean up worktrees, Force delete kept work, or Remove: one finished team, behind its question. */
|
|
485
|
+
const finish = async (which) => {
|
|
222
486
|
const view = teamView(st.team);
|
|
223
|
-
const
|
|
487
|
+
const name = view.title || view.id;
|
|
488
|
+
const left = view.removal?.left || [];
|
|
489
|
+
const asks = {
|
|
490
|
+
cleanup: {
|
|
491
|
+
title: t('agentsStudio.teams.cleanupTitle', { name }),
|
|
492
|
+
lines: [t('agentsStudio.teams.cleanupAsk'), ...listed(left), t('agentsStudio.teams.cleanupSafe', { branch: view.landing.targetBranch || view.baseBranch || t('agentsStudio.teams.yourBranch') })],
|
|
493
|
+
label: t('agentsStudio.teams.cleanup'), kind: 'primary',
|
|
494
|
+
},
|
|
495
|
+
'force-discard': {
|
|
496
|
+
title: t('agentsStudio.teams.forceTitle', { name }),
|
|
497
|
+
lines: [t('agentsStudio.teams.forceAsk'), ...listed(left), t('agentsStudio.teams.forceWarn')],
|
|
498
|
+
label: t('agentsStudio.teams.forceDiscard'), kind: 'danger',
|
|
499
|
+
},
|
|
500
|
+
remove: {
|
|
501
|
+
title: t('agentsStudio.teams.removeTitle', { name }),
|
|
502
|
+
lines: [t('agentsStudio.teams.removeAsk'), t('agentsStudio.teams.removeKeeps')],
|
|
503
|
+
label: t('agentsStudio.teams.remove'), kind: 'danger',
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
const q = asks[which];
|
|
507
|
+
const answer = await ctx.ask({ title: q.title, lines: q.lines, className: 'ax-dlg', buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: q.label, kind: q.kind }], focus: 'cancel' });
|
|
508
|
+
if (answer !== 'go') return;
|
|
509
|
+
st.busy = true;
|
|
510
|
+
ctx.render({ keepFocus: true });
|
|
511
|
+
try {
|
|
512
|
+
if (which === 'cleanup') {
|
|
513
|
+
await ctx.api.cleanupTeam(view.id);
|
|
514
|
+
ctx.toast(t('agentsStudio.teams.cleanedToast'));
|
|
515
|
+
} else if (which === 'force-discard') {
|
|
516
|
+
const out = await ctx.api.discardTeam(view.id, { force: true });
|
|
517
|
+
const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
|
|
518
|
+
ctx.toast(kept ? ctx.tp('agentsStudio.teams.forceIncomplete', kept) : t('agentsStudio.teams.forcedToast'), kept ? 'error' : 'info');
|
|
519
|
+
} else {
|
|
520
|
+
await ctx.api.removeTeam(view.id);
|
|
521
|
+
ctx.toast(t('agentsStudio.teams.removedToast'));
|
|
522
|
+
st.busy = false;
|
|
523
|
+
// The team is gone: back to the list, read again.
|
|
524
|
+
st.rows = (st.rows || []).filter((row) => row.id !== view.id);
|
|
525
|
+
st.team = null;
|
|
526
|
+
ctx.go({ type: 'back' });
|
|
527
|
+
await afterWrite();
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
} catch (error) {
|
|
531
|
+
const key = which === 'cleanup' ? 'agentsStudio.teams.cleanupFailed' : which === 'force-discard' ? 'agentsStudio.teams.forceFailed' : 'agentsStudio.teams.removeFailed';
|
|
532
|
+
ctx.toast(t(key, { error: errorText(t, error) }), 'error');
|
|
533
|
+
}
|
|
534
|
+
st.busy = false;
|
|
535
|
+
await afterWrite();
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/** A team that left the list: drawn without it now (the reload confirms), and its detail closed when it was open. */
|
|
539
|
+
const dropTeam = (teamId) => {
|
|
540
|
+
st.rows = (st.rows || []).filter((row) => row.id !== teamId);
|
|
541
|
+
if (st.teamId === teamId) st.team = null;
|
|
542
|
+
if (ctx.view.teamId === teamId) ctx.go({ type: 'back' });
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Clean up & remove a ready team whose work is on its base branch already: behind a question that says where the
|
|
547
|
+
* work is, what is deleted and that git is asked again first (the server refuses, deleting nothing, if a worktree
|
|
548
|
+
* got edits or a branch got commits since this page read it).
|
|
549
|
+
*/
|
|
550
|
+
const cleanupMerged = async ({ id, name, branch, count, items = [] }) => {
|
|
551
|
+
const answer = await ctx.ask({
|
|
552
|
+
title: t('agentsStudio.teams.cleanupMergedTitle', { name }),
|
|
553
|
+
lines: [ctx.tp('agentsStudio.teams.cleanupMergedAsk', count, { branch }), ...listed(items), t('agentsStudio.teams.cleanupMergedSafe', { branch })],
|
|
554
|
+
className: 'ax-dlg',
|
|
555
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t('agentsStudio.teams.cleanupMerged'), kind: 'primary' }],
|
|
556
|
+
focus: 'cancel',
|
|
557
|
+
});
|
|
558
|
+
if (answer !== 'go') return;
|
|
559
|
+
st.busy = true;
|
|
560
|
+
ctx.render({ keepFocus: true });
|
|
561
|
+
try {
|
|
562
|
+
const out = await ctx.api.cleanupMergedTeam(id);
|
|
563
|
+
if (out?.teamRemoved === false) ctx.toast(t('agentsStudio.teams.cleanupMergedKeptToast', { reason: stayReason(t, out.removal) }));
|
|
564
|
+
else { ctx.toast(t('agentsStudio.teams.cleanupMergedToast', { branch: out?.branch || branch })); dropTeam(id); }
|
|
565
|
+
} catch (error) {
|
|
566
|
+
ctx.toast(t('agentsStudio.teams.cleanupMergedFailed', { error: errorText(t, error) }), 'error');
|
|
567
|
+
}
|
|
568
|
+
st.busy = false;
|
|
569
|
+
await afterWrite();
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* A card's Discard, or Discard & remove when nothing of the team is on disk or in git. Each question says whether
|
|
574
|
+
* the card leaves the list: Discard moves it to Finished; Discard & remove takes it off, and keeps the team (in
|
|
575
|
+
* Finished, discarded) when a worktree or branch holding work turns up after all.
|
|
576
|
+
*/
|
|
577
|
+
const quickDiscard = async (row, remove) => {
|
|
578
|
+
const name = row.title || row.id;
|
|
579
|
+
const answer = await ctx.ask({
|
|
580
|
+
title: t(remove ? 'agentsStudio.teams.discardRemoveTitle' : 'agentsStudio.teams.discardTitle', { name }),
|
|
581
|
+
lines: remove
|
|
582
|
+
? [t('agentsStudio.teams.discardRemoveAsk'), t('agentsStudio.teams.discardRemoveSafe')]
|
|
583
|
+
: [t('agentsStudio.teams.discardAsk'), t('agentsStudio.teams.discardMoves'), t('agentsStudio.teams.discardKeeps')],
|
|
584
|
+
className: 'ax-dlg',
|
|
585
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t(remove ? 'agentsStudio.teams.discardRemove' : 'agentsStudio.teams.discard'), kind: 'danger' }],
|
|
586
|
+
focus: 'cancel',
|
|
587
|
+
});
|
|
588
|
+
if (answer !== 'go') return;
|
|
589
|
+
st.busy = true;
|
|
590
|
+
ctx.render({ keepFocus: true });
|
|
591
|
+
try {
|
|
592
|
+
const out = await ctx.api.discardTeam(row.id, remove ? { remove: true } : {});
|
|
593
|
+
const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
|
|
594
|
+
if (kept) ctx.toast(ctx.tp('agentsStudio.teams.discardKeptToast', kept));
|
|
595
|
+
else if (remove && out?.teamRemoved === true) { ctx.toast(t('agentsStudio.teams.discardRemovedToast')); dropTeam(row.id); }
|
|
596
|
+
else if (remove) ctx.toast(t('agentsStudio.teams.discardStaysToast', { reason: stayReason(t, out?.removal) }));
|
|
597
|
+
else ctx.toast(t('agentsStudio.teams.discardedToast'));
|
|
598
|
+
} catch (error) {
|
|
599
|
+
ctx.toast(t('agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
|
|
600
|
+
}
|
|
601
|
+
st.busy = false;
|
|
602
|
+
await afterWrite();
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
/** Clear finished: every finished team with nothing left goes; the rest stay, and the toast says how many. */
|
|
606
|
+
const clearFinished = async () => {
|
|
607
|
+
const { removable, kept } = clearableTeams(st.rows || []);
|
|
608
|
+
if (!removable.length) return;
|
|
224
609
|
const answer = await ctx.ask({
|
|
225
|
-
title: t(
|
|
226
|
-
lines:
|
|
227
|
-
? [t('agentsStudio.teams.landAsk', { branch: view.landing.targetBranch || view.baseBranch || t('agentsStudio.teams.yourBranch') }), t('agentsStudio.teams.landRefuses')]
|
|
228
|
-
: [t('agentsStudio.teams.discardAsk'), t('agentsStudio.teams.discardKeeps')],
|
|
610
|
+
title: t('agentsStudio.teams.clearTitle'),
|
|
611
|
+
lines: [ctx.tp('agentsStudio.teams.clearAsk', removable.length), kept ? ctx.tp('agentsStudio.teams.clearSkips', kept) : null, t('agentsStudio.teams.removeKeeps')],
|
|
229
612
|
className: 'ax-dlg',
|
|
230
|
-
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t(
|
|
613
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t('agentsStudio.teams.clearFinished'), kind: 'danger' }],
|
|
231
614
|
focus: 'cancel',
|
|
232
615
|
});
|
|
233
616
|
if (answer !== 'go') return;
|
|
234
617
|
st.busy = true;
|
|
235
618
|
ctx.render({ keepFocus: true });
|
|
236
619
|
try {
|
|
237
|
-
|
|
238
|
-
|
|
620
|
+
const out = await ctx.api.clearFinishedTeams();
|
|
621
|
+
const removed = Array.isArray(out?.removed) ? out.removed.length : 0;
|
|
622
|
+
const skipped = Array.isArray(out?.skipped) ? out.skipped.length : 0;
|
|
623
|
+
const said = [removed ? ctx.tp('agentsStudio.teams.clearedToast', removed) : t('agentsStudio.teams.clearNothing'), skipped ? ctx.tp('agentsStudio.teams.clearSkippedToast', skipped) : ''].filter(Boolean).join(' ');
|
|
624
|
+
ctx.toast(said, removed ? 'info' : 'error');
|
|
239
625
|
} catch (error) {
|
|
240
|
-
ctx.toast(t(
|
|
626
|
+
ctx.toast(t('agentsStudio.teams.clearFailed', { error: errorText(t, error) }), 'error');
|
|
241
627
|
}
|
|
242
628
|
st.busy = false;
|
|
243
|
-
await
|
|
629
|
+
await afterWrite();
|
|
244
630
|
};
|
|
245
631
|
|
|
246
632
|
main.addEventListener('click', (e) => {
|
|
@@ -251,6 +637,23 @@ export function renderTeams(main, ctx, st) {
|
|
|
251
637
|
else if (act === 'back') ctx.go({ type: 'back' });
|
|
252
638
|
else if (act === 'refresh' || act === 'retry') { st.error = null; st.detailError = null; reload(); }
|
|
253
639
|
else if (act === 'focus-run') ctx.focusRun(el.dataset.run);
|
|
254
|
-
else if (act === 'land' || act === '
|
|
640
|
+
else if (act === 'land' || act === 'land-untested') land(act === 'land-untested');
|
|
641
|
+
else if (act === 'discard') discard();
|
|
642
|
+
else if (act === 'cleanup' || act === 'force-discard' || act === 'remove') finish(act);
|
|
643
|
+
else if (act === 'clear-finished') clearFinished();
|
|
644
|
+
else if (act === 'quick') {
|
|
645
|
+
// A card's own action: never the card's click (which opens the team).
|
|
646
|
+
e.stopPropagation();
|
|
647
|
+
const row = (st.rows || []).find((r) => r.id === el.dataset.team);
|
|
648
|
+
const which = row ? quickActionOf(row, ctx.caps) : null;
|
|
649
|
+
if (!which || which !== el.dataset.quick) return;
|
|
650
|
+
if (which === 'cleanup-merged') cleanupMerged({ id: row.id, name: row.title || row.id, branch: row.onTarget.branch, count: row.left ?? 1 });
|
|
651
|
+
else quickDiscard(row, which === 'discard-remove');
|
|
652
|
+
} else if (act === 'cleanup-merged' && st.team) {
|
|
653
|
+
const view = teamView(st.team);
|
|
654
|
+
if (!view.canCleanupMerged) return;
|
|
655
|
+
const items = [...view.slices.filter((slice) => slice.worktree || slice.branch).map((slice) => ({ path: slice.worktree, branch: slice.branch })), ...(view.integration.branch ? [{ path: '', branch: view.integration.branch }] : [])];
|
|
656
|
+
cleanupMerged({ id: view.id, name: view.title || view.id, branch: view.onTarget.branch, count: items.length || 1, items });
|
|
657
|
+
}
|
|
255
658
|
}, { signal });
|
|
256
659
|
}
|