synabun 2.4.3 → 2.4.5
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 +36 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +66 -36
- package/docs/whatsapp.md +3 -3
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +8 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +2 -0
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +4 -0
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/memory-client.d.ts +5 -0
- package/mcp-server/dist/services/memory-client.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-client.js +21 -2
- package/mcp-server/dist/services/memory-client.js.map +1 -1
- package/mcp-server/dist/services/memory-writer.d.ts +3 -0
- package/mcp-server/dist/services/memory-writer.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-writer.js +7 -1
- package/mcp-server/dist/services/memory-writer.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +12 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +68 -17
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +38 -2
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +260 -8
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +19 -4
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +85 -17
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +11 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +113 -27
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/browser-readers.d.ts +6 -0
- package/mcp-server/dist/tools/browser-readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-readers.js +17 -0
- package/mcp-server/dist/tools/browser-readers.js.map +1 -0
- package/mcp-server/dist/tools/remember.d.ts.map +1 -1
- package/mcp-server/dist/tools/remember.js +6 -2
- package/mcp-server/dist/tools/remember.js.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.js +25 -20
- package/mcp-server/dist/tools/youtube/analytics.js.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts +5 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +7 -3
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.d.ts +2 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.js +5 -3
- package/mcp-server/dist/tools/youtube/navigate.js.map +1 -1
- package/mcp-server/dist/tools/youtube/playlist.js +2 -2
- package/mcp-server/dist/tools/youtube/playlist.js.map +1 -1
- package/mcp-server/dist/tools/youtube/readers.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/readers.js +15 -0
- package/mcp-server/dist/tools/youtube/readers.js.map +1 -0
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +8 -1
- package/mcp-server/src/services/identity.ts +5 -0
- package/mcp-server/src/services/memory-client.ts +32 -12
- package/mcp-server/src/services/memory-writer.ts +5 -2
- package/mcp-server/src/services/neural-interface.ts +67 -19
- package/mcp-server/src/services/typesafe-config.ts +268 -7
- package/mcp-server/src/tools/agents.ts +79 -17
- package/mcp-server/src/tools/browser-observe.ts +117 -28
- package/mcp-server/src/tools/browser-readers.ts +19 -0
- package/mcp-server/src/tools/remember.ts +6 -1
- package/mcp-server/src/tools/youtube/analytics.ts +26 -28
- package/mcp-server/src/tools/youtube/helpers.ts +8 -2
- package/mcp-server/src/tools/youtube/navigate.ts +6 -7
- package/mcp-server/src/tools/youtube/playlist.ts +2 -2
- package/mcp-server/src/tools/youtube/readers.ts +15 -0
- package/neural-interface/i18n/en.json +487 -8
- package/neural-interface/i18n/pt-BR.json +487 -8
- package/neural-interface/lib/agents-studio-api.js +7 -2
- package/neural-interface/lib/antigravity/home.js +43 -8
- package/neural-interface/lib/antigravity/tool-call.js +14 -0
- package/neural-interface/lib/assistant-api.js +90 -0
- package/neural-interface/lib/assistant-brains/antigravity.js +4 -2
- package/neural-interface/lib/assistant-brains/claude.js +10 -0
- package/neural-interface/lib/assistant-dispatch.js +276 -42
- package/neural-interface/lib/assistant-memory.js +3 -1
- package/neural-interface/lib/assistant-persona.js +14 -3
- package/neural-interface/lib/assistant-route-gate.js +11 -2
- package/neural-interface/lib/assistant-router.js +18 -8
- package/neural-interface/lib/assistant-runtime.js +103 -6
- package/neural-interface/lib/assistant-spilled-output.js +53 -0
- package/neural-interface/lib/assistant-task-prompt.js +15 -2
- package/neural-interface/lib/browser-connection-state.js +20 -0
- package/neural-interface/lib/browser-default.js +22 -2
- package/neural-interface/lib/browser-extension-adapter.js +221 -15
- package/neural-interface/lib/browser-extension-bridge.js +89 -9
- package/neural-interface/lib/browser-extension-folder.js +50 -11
- package/neural-interface/lib/browser-extension-package.js +6 -5
- package/neural-interface/lib/browser-extension-pin.json +15 -13
- package/neural-interface/lib/browser-extension-protocol.js +141 -14
- package/neural-interface/lib/browser-extension-setup.js +210 -40
- package/neural-interface/lib/browser-extension-update.js +104 -0
- package/neural-interface/lib/browser-extraction.js +38 -14
- package/neural-interface/lib/claude-bg-tasks.js +183 -0
- package/neural-interface/lib/claude-history.js +12 -1
- package/neural-interface/lib/confined-fs.js +25 -0
- package/neural-interface/lib/coordination/operations.js +2 -0
- package/neural-interface/lib/db.js +39 -16
- package/neural-interface/lib/editor-completion-opencode.js +2 -2
- package/neural-interface/lib/git-bash/manager.js +28 -3
- package/neural-interface/lib/git-status-runner.js +31 -3
- package/neural-interface/lib/loop-inventory.js +162 -0
- package/neural-interface/lib/loop-stall.js +74 -4
- package/neural-interface/lib/memory-session-capture.js +157 -66
- package/neural-interface/lib/native-loop-providers.js +73 -13
- package/neural-interface/lib/native-loop-runtime.js +3 -0
- package/neural-interface/lib/opencode-protocol.js +4 -2
- package/neural-interface/lib/peer-identity.js +62 -16
- package/neural-interface/lib/remote-policy.js +24 -7
- package/neural-interface/lib/session-cache-builder.js +66 -18
- package/neural-interface/lib/session-capture-gate.js +42 -0
- package/neural-interface/lib/session-indexer.js +28 -20
- package/neural-interface/lib/teams/README.md +22 -1
- package/neural-interface/lib/teams/api.js +79 -6
- package/neural-interface/lib/teams/index.js +2 -0
- package/neural-interface/lib/teams/recovery.js +68 -0
- package/neural-interface/lib/teams/scheduler.js +352 -31
- package/neural-interface/lib/teams/worktrees.js +123 -30
- package/neural-interface/lib/ui-blob-api.js +14 -5
- package/neural-interface/lib/ui-blob-store.js +302 -39
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +7 -2
- package/neural-interface/public/shared/agents/studio/ax-api.js +16 -0
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +318 -13
- package/neural-interface/public/shared/agents/studio/ax-teams.js +141 -9
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +4 -0
- package/neural-interface/public/shared/assistant/asst-api.js +42 -0
- package/neural-interface/public/shared/assistant/asst-composer.js +85 -12
- package/neural-interface/public/shared/assistant/asst-panel.js +285 -10
- package/neural-interface/public/shared/assistant/asst-render.js +205 -4
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +18 -1
- package/neural-interface/public/shared/assistant/asst-state.js +241 -2
- package/neural-interface/public/shared/assistant/asst-steer.js +294 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +20 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-claude.js +147 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-model.js +527 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-panel.js +161 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-view.js +508 -0
- package/neural-interface/public/shared/browser-extension-updates.js +90 -0
- package/neural-interface/public/shared/cp/cp-bg-tasks.js +130 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +41 -15
- package/neural-interface/public/shared/extension-setup/es-view.js +51 -11
- package/neural-interface/public/shared/extension-update-view.js +34 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +8 -4
- package/neural-interface/public/shared/settings/settings-ai-browser.js +23 -3
- package/neural-interface/public/shared/settings/settings-browser-extension.js +581 -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-extension-update.js +114 -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/styles.css +200 -13
- package/neural-interface/public/shared/ui-claude-panel.js +110 -1
- package/neural-interface/public/shared/ui-notifications.js +23 -4
- package/neural-interface/public/shared/ui-settings-entry.js +6 -0
- package/neural-interface/public/shared/ui-settings.js +48 -11
- package/neural-interface/public/shared/ui-tray-columns.js +9 -2
- package/neural-interface/public/shared/worker-end.js +18 -0
- package/neural-interface/scripts/patch-node-pty.mjs +151 -0
- package/neural-interface/scripts/rebuild-pty.js +10 -0
- package/neural-interface/server.js +503 -281
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
#es-steps > li[data-step][data-done], #es-extensions-url + #es-copy-url, #es-folder + #es-copy-folder + #es-reveal,
|
|
17
17
|
#es-alternatives, #es-reload, #es-restart, #es-copied, #es-progress (the bytes of the extension's download, while
|
|
18
18
|
the state is "downloading"). The ticket element is the only thing the extension's content script reads; it is
|
|
19
|
-
filled only while the extension is on this page and the server waits for it.
|
|
20
|
-
|
|
19
|
+
filled only while the extension is on this page and the server waits for it.
|
|
20
|
+
Beside the Settings guide (a setup started from Settings → Browser, status `guided`) the page is its companion:
|
|
21
|
+
data-companion="true", one card with the live status and no steps, folder or other browsers; the steps are in
|
|
22
|
+
Settings, and this tab stays open only to pair the extension by itself. Opened on its own (the extension's popup,
|
|
23
|
+
an older flow) it is the four-step page as before. -->
|
|
24
|
+
<main id="es-setup" class="es-setup" data-state="idle" data-layout="result" data-companion="false" aria-busy="true">
|
|
21
25
|
<div class="es-top">
|
|
22
26
|
<p class="es-brand"><img src="/icon-192.png" alt="" width="32" height="32"><span>SynaBun</span></p>
|
|
23
27
|
<p id="es-browser" class="es-browser" hidden><span id="es-browser-label"></span> <strong id="es-browser-name"></strong></p>
|
|
@@ -83,6 +87,7 @@
|
|
|
83
87
|
</section>
|
|
84
88
|
<p id="es-reload" class="es-note es-warn" hidden></p>
|
|
85
89
|
<div class="es-row es-actions" id="es-actions" hidden>
|
|
90
|
+
<a class="es-button es-button-primary" id="es-update-flow" href="/#browser-extension-update" hidden></a>
|
|
86
91
|
<a class="es-button es-button-primary" id="es-back" href="/" hidden></a>
|
|
87
92
|
<button type="button" class="es-button es-button-primary" id="es-restart" data-action="restart" hidden></button>
|
|
88
93
|
</div>
|
|
@@ -193,6 +193,22 @@ export function createAgentsApi({ fetch: fetchFn = (...args) => globalThis.fetch
|
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
195
|
landTeam: async (teamId, body = {}) => send('POST', teamUrl(teamId, '/land'), { body }),
|
|
196
|
+
/**
|
|
197
|
+
* `{ force: true }` also deletes what a discard kept (the owner's word, behind its own question). `{ remove: true }`
|
|
198
|
+
* (capability `teams-quick-discard`): the team's record goes too, in the same step, once the discard left nothing
|
|
199
|
+
* → `teamRemoved`, and `removal` (why it stays) when it does not.
|
|
200
|
+
*/
|
|
196
201
|
discardTeam: async (teamId, body = {}) => send('POST', teamUrl(teamId, '/discard'), { body }),
|
|
202
|
+
/**
|
|
203
|
+
* A ready team whose work is on its base branch already: its worktrees, branches and record, once the server asked
|
|
204
|
+
* git again (capability `teams-on-target`) → { teamRemoved, branch, removed }. The owner's question was answered.
|
|
205
|
+
*/
|
|
206
|
+
cleanupMergedTeam: async (teamId) => send('POST', teamUrl(teamId, '/cleanup-merged'), { body: { userConfirmed: true } }),
|
|
207
|
+
/** A landed team's worktrees and branches (capability `teams-cleanup`). The owner's question was answered: `userConfirmed`. */
|
|
208
|
+
cleanupTeam: async (teamId) => send('POST', teamUrl(teamId, '/cleanup'), { body: { userConfirmed: true } }),
|
|
209
|
+
/** A closed team's record, once nothing of it is left (capability `teams-remove`). */
|
|
210
|
+
removeTeam: async (teamId) => send('DELETE', teamUrl(teamId), { body: {} }),
|
|
211
|
+
/** Every closed team that can go → { removed: [ids], skipped: [{ teamId, code, next, … }] } (capability `teams-remove`). */
|
|
212
|
+
clearFinishedTeams: async () => send('POST', `${base}/teams/clear-finished`, { body: {} }),
|
|
197
213
|
};
|
|
198
214
|
}
|
|
@@ -9,11 +9,26 @@
|
|
|
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
|
+
// The routes are the team scheduler's (GET /teams, /teams/:id, POST /teams/:id/land and /discard; with the
|
|
24
|
+
// capabilities `teams-cleanup` and `teams-remove`, POST /teams/:id/cleanup, DELETE /teams/:id and POST
|
|
25
|
+
// /teams/clear-finished; with `teams-on-target`, POST /teams/:id/cleanup-merged; with `teams-quick-discard`, the
|
|
26
|
+
// list's `liveRuns` / `left` and discard's `remove`). A server that does not have them yet answers "not there": the
|
|
27
|
+
// place then says what teams are and waits, without an error; a server without a capability is offered nothing that
|
|
28
|
+
// needs it.
|
|
14
29
|
|
|
15
30
|
import { html, setHTML, ICONS } from '../../skills/studio/sx-dom.js';
|
|
16
|
-
import { teamRows, teamView } from './ax-teams.js';
|
|
31
|
+
import { teamRows, teamView, splitTeams, clearableTeams, quickActionOf } from './ax-teams.js';
|
|
17
32
|
import { baseName } from './ax-library.js';
|
|
18
33
|
import { AX_ICONS } from './ax-icons.js';
|
|
19
34
|
import { timeTag, loadingHTML, errorHTML, emptyHTML, errorText, wordOr } from './ax-ui.js';
|
|
@@ -38,6 +53,15 @@ const chip = (label, tone) => html`<span class="sx-state-chip ax-run-state ax-ru
|
|
|
38
53
|
const teamState = (t, state) => wordOr(t, 'agentsStudio.teams.state', state || 'unknown');
|
|
39
54
|
const sliceState = (t, state) => wordOr(t, 'agentsStudio.teams.sliceState', state || 'unknown');
|
|
40
55
|
const shortCommit = (commit) => String(commit || '').slice(0, 9);
|
|
56
|
+
/** A team's status as a chip: "Already on <branch>" for a ready team whose work is there, its status otherwise. */
|
|
57
|
+
const statusChip = (t, team) => (team.onTarget ? chip(t('agentsStudio.teams.onTarget', { branch: team.onTarget.branch }), team.tone) : chip(teamState(t, team.status), team.tone));
|
|
58
|
+
|
|
59
|
+
/** A card's quick action: its words and its kind of button (the decision is ax-teams.js `quickActionOf`). */
|
|
60
|
+
const QUICK = Object.freeze({
|
|
61
|
+
'cleanup-merged': { label: 'agentsStudio.teams.cleanupMerged', kind: 'primary' },
|
|
62
|
+
'discard-remove': { label: 'agentsStudio.teams.discardRemove', kind: 'danger' },
|
|
63
|
+
discard: { label: 'agentsStudio.teams.discard', kind: 'danger' },
|
|
64
|
+
});
|
|
41
65
|
|
|
42
66
|
function listHTML(ctx, st) {
|
|
43
67
|
const { t } = ctx;
|
|
@@ -50,10 +74,113 @@ function listHTML(ctx, st) {
|
|
|
50
74
|
lines: [t('agentsStudio.teams.emptyHelp'), st.available === false ? t(st.notRunning ? 'agentsStudio.teams.notRunning' : 'agentsStudio.teams.notAvailable') : t('agentsStudio.teams.emptyHow')],
|
|
51
75
|
});
|
|
52
76
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
77
|
+
const { open, finished } = splitTeams(rows);
|
|
78
|
+
// Whether the server can say a finished team still has worktrees (and remove the ones that do not).
|
|
79
|
+
const removing = ctx.caps.has('teams-remove');
|
|
80
|
+
const clear = clearableTeams(rows);
|
|
81
|
+
const canClear = ctx.owner && removing && clear.removable.length > 0;
|
|
82
|
+
let first = true;
|
|
83
|
+
const rowHTML = (row) => {
|
|
84
|
+
const autofocus = first;
|
|
85
|
+
first = false;
|
|
86
|
+
// The card opens the team; its quick action (the owner's, a team that waits on the owner) is a button of its own
|
|
87
|
+
// beside it, never inside it, and the team's title describes it.
|
|
88
|
+
const quick = ctx.owner ? quickActionOf(row, ctx.caps) : null;
|
|
89
|
+
const titleId = `ax-team-t-${row.id}`;
|
|
90
|
+
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` : ''}>
|
|
91
|
+
<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>
|
|
92
|
+
<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>
|
|
93
|
+
</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>`;
|
|
94
|
+
};
|
|
95
|
+
return html`<div class="ax-team-groups">
|
|
96
|
+
<section class="ax-team-group" aria-labelledby="ax-teams-open-title">
|
|
97
|
+
<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>
|
|
98
|
+
${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>`}
|
|
99
|
+
</section>
|
|
100
|
+
${finished.length ? html`<section class="ax-team-group" aria-labelledby="ax-teams-finished-title">
|
|
101
|
+
<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>
|
|
102
|
+
<ul class="ax-team-list" aria-labelledby="ax-teams-finished-title">${finished.map(rowHTML)}</ul>
|
|
103
|
+
</section>` : ''}
|
|
104
|
+
</div>`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** How one thing that is left reads in a list: its folder (or branch), its branch beside it. */
|
|
108
|
+
const leftLine = (item) => (item.path && item.branch ? `${item.path} · ${item.branch}` : item.path || item.branch);
|
|
109
|
+
|
|
110
|
+
/** Why a discard kept a worktree, as a short note: the reason, the files, the commits. */
|
|
111
|
+
function keptNote(ctx, kept) {
|
|
112
|
+
if (!kept) return '';
|
|
113
|
+
const { t } = ctx;
|
|
114
|
+
const parts = [kept.reason ? wordOr(t, 'agentsStudio.teams.keptReason', kept.reason) : ''];
|
|
115
|
+
if (kept.files.length) parts.push(ctx.tp('agentsStudio.teams.keptFiles', kept.files.length));
|
|
116
|
+
if (kept.commits) parts.push(ctx.tp('agentsStudio.teams.keptCommits', kept.commits));
|
|
117
|
+
return parts.filter(Boolean).join(' · ');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Why a finished team's record cannot go, when nothing that is left is the reason. */
|
|
121
|
+
function blockedText(t, code) {
|
|
122
|
+
const said = t(`agentsStudio.teams.removalBlocked.${code}`);
|
|
123
|
+
return said === `agentsStudio.teams.removalBlocked.${code}` ? t('agentsStudio.teams.removalBlocked.other') : said;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Why a team stayed in the list after a step that would have removed it (the answer's `removal`). */
|
|
127
|
+
function stayReason(t, removal) {
|
|
128
|
+
const code = removal?.code;
|
|
129
|
+
return !code || code === 'TEAM_WORKTREES_LEFT' ? t('agentsStudio.teams.leftTag') : blockedText(t, code);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A finished team's worktrees and branches: what is still on disk and in git, and the one step that fits (the
|
|
134
|
+
* owner's only). Nothing is drawn for a server that does not say (no `removal`).
|
|
135
|
+
*/
|
|
136
|
+
function diskHTML(ctx, st, team) {
|
|
137
|
+
const { t } = ctx;
|
|
138
|
+
const r = team.removal;
|
|
139
|
+
if (!team.finished || !r) return '';
|
|
140
|
+
const busy = st.busy ? html` disabled` : '';
|
|
141
|
+
const keptBy = new Map(team.kept.filter((item) => item.sliceId).map((item) => [item.sliceId, item]));
|
|
142
|
+
const lead = r.next === 'cleanup' ? 'agentsStudio.teams.cleanupLead' : r.next === 'force_discard' ? 'agentsStudio.teams.keptLead' : 'agentsStudio.teams.byHandLead';
|
|
143
|
+
const owner = ctx.owner;
|
|
144
|
+
const actions = [
|
|
145
|
+
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>` : '',
|
|
146
|
+
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>` : '',
|
|
147
|
+
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>` : '',
|
|
148
|
+
].filter(Boolean);
|
|
149
|
+
return html`<section class="ax-side-card ax-team-disk" aria-labelledby="ax-team-disk-title">
|
|
150
|
+
<h4 class="sx-section-title" id="ax-team-disk-title">${AX_ICONS.branch} ${t('agentsStudio.teams.diskTitle')}</h4>
|
|
151
|
+
${r.removable ? html`<p class="sx-note">${t('agentsStudio.teams.diskClean')}</p>` : ''}
|
|
152
|
+
${!r.removable && r.left.length ? html`<p class="sx-field-note${r.next === 'force_discard' ? ' sx-warn-text' : ''}" role="note">${t(lead)}</p>
|
|
153
|
+
<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>` : ''}
|
|
154
|
+
${!r.removable && !r.left.length ? html`<p class="sx-field-note sx-warn-text" role="note">${blockedText(t, r.code)}</p>` : ''}
|
|
155
|
+
${actions.length ? html`<div class="sx-row ax-team-actions">${actions}</div>` : ''}
|
|
156
|
+
</section>`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A ready team whose work is on its base branch already (merged outside SynaBun): where it is, and either the one
|
|
161
|
+
* step that fits (Clean up & remove, the owner's) or exactly what keeps the worktrees and branches from going
|
|
162
|
+
* (uncommitted edits per worktree, commits the base branch lacks, a live worker, git's own words).
|
|
163
|
+
*/
|
|
164
|
+
function onTargetHTML(ctx, st, team) {
|
|
165
|
+
const o = team.onTarget;
|
|
166
|
+
if (!o) return '';
|
|
167
|
+
const { t } = ctx;
|
|
168
|
+
const branch = o.branch;
|
|
169
|
+
const problems = [
|
|
170
|
+
...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>`),
|
|
171
|
+
...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>`),
|
|
172
|
+
...(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>`] : []),
|
|
173
|
+
...o.other.map((line) => html`<li><span class="sx-mono sx-dim">${line}</span></li>`),
|
|
174
|
+
];
|
|
175
|
+
const offer = ctx.owner && team.canCleanupMerged && ctx.caps.has('teams-on-target');
|
|
176
|
+
return html`<section class="ax-side-card ax-team-ontarget${o.clean ? '' : ' is-blocked'}" aria-labelledby="ax-team-ontarget-title">
|
|
177
|
+
<h4 class="sx-section-title" id="ax-team-ontarget-title">${AX_ICONS.branch} ${t('agentsStudio.teams.onTarget', { branch })}</h4>
|
|
178
|
+
<p class="sx-note">${t('agentsStudio.teams.onTargetLead', { branch })}</p>
|
|
179
|
+
${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>
|
|
180
|
+
${problems.length ? html`<ul class="sx-plain-list ax-left-list">${problems}</ul>` : ''}
|
|
181
|
+
<p class="sx-help">${t('agentsStudio.teams.onTargetFix', { branch })}</p>`}
|
|
182
|
+
${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>` : ''}
|
|
183
|
+
</section>`;
|
|
57
184
|
}
|
|
58
185
|
|
|
59
186
|
function sliceHTML(ctx, slice) {
|
|
@@ -83,10 +210,12 @@ function detailHTML(ctx, st) {
|
|
|
83
210
|
const i = team.integration;
|
|
84
211
|
const l = team.landing;
|
|
85
212
|
const tests = i.tests;
|
|
213
|
+
// Why Land is not offered: its work is on its base branch already, or the team is not ready yet.
|
|
214
|
+
const landHelp = team.onTarget ? t('agentsStudio.teams.onTargetNothingToLand', { branch: team.onTarget.branch }) : t('agentsStudio.teams.landNotReady');
|
|
86
215
|
return html`<div class="ax-team">
|
|
87
216
|
<section class="ax-team-summary" aria-label="${t('agentsStudio.teams.summary')}">
|
|
88
217
|
<dl class="ax-facts">
|
|
89
|
-
<div><dt>${t('agentsStudio.teams.status')}</dt><dd>${
|
|
218
|
+
<div><dt>${t('agentsStudio.teams.status')}</dt><dd>${statusChip(t, team)}</dd></div>
|
|
90
219
|
${team.project ? html`<div><dt>${t('agentsStudio.teams.project')}</dt><dd class="sx-mono" title="${team.project}">${team.project}</dd></div>` : ''}
|
|
91
220
|
${team.density ? html`<div><dt>${t('agentsStudio.teams.densityLabel')}</dt><dd>${wordOr(t, 'agentsStudio.teams.density', team.density)}</dd></div>` : ''}
|
|
92
221
|
${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 +223,8 @@ function detailHTML(ctx, st) {
|
|
|
94
223
|
</dl>
|
|
95
224
|
${team.attention ? html`<p class="sx-field-note sx-warn-text ax-team-attention" role="note">${team.attention}</p>` : ''}
|
|
96
225
|
</section>
|
|
226
|
+
${onTargetHTML(ctx, st, team)}
|
|
227
|
+
${diskHTML(ctx, st, team)}
|
|
97
228
|
<section aria-labelledby="ax-team-slices-title">
|
|
98
229
|
<h4 class="sx-section-title" id="ax-team-slices-title">${ctx.tp('agentsStudio.teams.slices', team.slices.length)}</h4>
|
|
99
230
|
${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 +245,16 @@ function detailHTML(ctx, st) {
|
|
|
114
245
|
<section class="ax-side-card" aria-labelledby="ax-team-land-title">
|
|
115
246
|
<h4 class="sx-section-title" id="ax-team-land-title">${ICONS.publish} ${t('agentsStudio.teams.landing')}</h4>
|
|
116
247
|
<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>
|
|
248
|
+
<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>
|
|
118
249
|
${l.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono">${l.targetBranch}</dd></div>` : ''}
|
|
119
250
|
${l.commit ? html`<div><dt>${t('agentsStudio.teams.head')}</dt><dd class="sx-mono">${shortCommit(l.commit)}</dd></div>` : ''}
|
|
120
251
|
${l.at ? html`<div><dt>${t('agentsStudio.teams.landedAt')}</dt><dd>${timeTag(l.at, ctx.locale)}</dd></div>` : ''}
|
|
121
252
|
</dl>
|
|
122
253
|
${l.error ? html`<p class="sx-field-note sx-err-text">${l.error}</p>` : ''}
|
|
123
254
|
${ctx.owner ? html`<div class="sx-row ax-team-actions">
|
|
124
|
-
<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') :
|
|
255
|
+
<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>
|
|
125
256
|
<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">${
|
|
257
|
+
</div>${team.canLand ? '' : html`<p class="sx-help">${landHelp}</p>`}` : ''}
|
|
127
258
|
</section>
|
|
128
259
|
</div>`}
|
|
129
260
|
<section aria-labelledby="ax-team-feed-title">
|
|
@@ -234,8 +365,15 @@ export function renderTeams(main, ctx, st) {
|
|
|
234
365
|
st.busy = true;
|
|
235
366
|
ctx.render({ keepFocus: true });
|
|
236
367
|
try {
|
|
237
|
-
if (land)
|
|
238
|
-
|
|
368
|
+
if (land) {
|
|
369
|
+
await ctx.api.landTeam(view.id, {});
|
|
370
|
+
ctx.toast(t('agentsStudio.teams.landedToast'));
|
|
371
|
+
} else {
|
|
372
|
+
const out = await ctx.api.discardTeam(view.id, {});
|
|
373
|
+
const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
|
|
374
|
+
// What holds work is kept: say so, and where it can be deleted.
|
|
375
|
+
ctx.toast(kept ? ctx.tp('agentsStudio.teams.discardKeptToast', kept) : t('agentsStudio.teams.discardedToast'));
|
|
376
|
+
}
|
|
239
377
|
} catch (error) {
|
|
240
378
|
ctx.toast(t(land ? 'agentsStudio.teams.landFailed' : 'agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
|
|
241
379
|
}
|
|
@@ -243,6 +381,157 @@ export function renderTeams(main, ctx, st) {
|
|
|
243
381
|
await reload();
|
|
244
382
|
};
|
|
245
383
|
|
|
384
|
+
/** The things a question lists: at most ten, then how many more. */
|
|
385
|
+
const listed = (items) => [...items.slice(0, 10).map((item) => `• ${leftLine(item)}`), items.length > 10 ? ctx.tp('agentsStudio.teams.moreItems', items.length - 10) : null];
|
|
386
|
+
|
|
387
|
+
/** Clean up worktrees, Force delete kept work, or Remove: one finished team, behind its question. */
|
|
388
|
+
const finish = async (which) => {
|
|
389
|
+
const view = teamView(st.team);
|
|
390
|
+
const name = view.title || view.id;
|
|
391
|
+
const left = view.removal?.left || [];
|
|
392
|
+
const asks = {
|
|
393
|
+
cleanup: {
|
|
394
|
+
title: t('agentsStudio.teams.cleanupTitle', { name }),
|
|
395
|
+
lines: [t('agentsStudio.teams.cleanupAsk'), ...listed(left), t('agentsStudio.teams.cleanupSafe', { branch: view.landing.targetBranch || view.baseBranch || t('agentsStudio.teams.yourBranch') })],
|
|
396
|
+
label: t('agentsStudio.teams.cleanup'), kind: 'primary',
|
|
397
|
+
},
|
|
398
|
+
'force-discard': {
|
|
399
|
+
title: t('agentsStudio.teams.forceTitle', { name }),
|
|
400
|
+
lines: [t('agentsStudio.teams.forceAsk'), ...listed(left), t('agentsStudio.teams.forceWarn')],
|
|
401
|
+
label: t('agentsStudio.teams.forceDiscard'), kind: 'danger',
|
|
402
|
+
},
|
|
403
|
+
remove: {
|
|
404
|
+
title: t('agentsStudio.teams.removeTitle', { name }),
|
|
405
|
+
lines: [t('agentsStudio.teams.removeAsk'), t('agentsStudio.teams.removeKeeps')],
|
|
406
|
+
label: t('agentsStudio.teams.remove'), kind: 'danger',
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
const q = asks[which];
|
|
410
|
+
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' });
|
|
411
|
+
if (answer !== 'go') return;
|
|
412
|
+
st.busy = true;
|
|
413
|
+
ctx.render({ keepFocus: true });
|
|
414
|
+
try {
|
|
415
|
+
if (which === 'cleanup') {
|
|
416
|
+
await ctx.api.cleanupTeam(view.id);
|
|
417
|
+
ctx.toast(t('agentsStudio.teams.cleanedToast'));
|
|
418
|
+
} else if (which === 'force-discard') {
|
|
419
|
+
const out = await ctx.api.discardTeam(view.id, { force: true });
|
|
420
|
+
const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
|
|
421
|
+
ctx.toast(kept ? ctx.tp('agentsStudio.teams.forceIncomplete', kept) : t('agentsStudio.teams.forcedToast'), kept ? 'error' : 'info');
|
|
422
|
+
} else {
|
|
423
|
+
await ctx.api.removeTeam(view.id);
|
|
424
|
+
ctx.toast(t('agentsStudio.teams.removedToast'));
|
|
425
|
+
st.busy = false;
|
|
426
|
+
// The team is gone: back to the list, read again.
|
|
427
|
+
st.rows = (st.rows || []).filter((row) => row.id !== view.id);
|
|
428
|
+
st.team = null;
|
|
429
|
+
ctx.go({ type: 'back' });
|
|
430
|
+
await reload();
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
} catch (error) {
|
|
434
|
+
const key = which === 'cleanup' ? 'agentsStudio.teams.cleanupFailed' : which === 'force-discard' ? 'agentsStudio.teams.forceFailed' : 'agentsStudio.teams.removeFailed';
|
|
435
|
+
ctx.toast(t(key, { error: errorText(t, error) }), 'error');
|
|
436
|
+
}
|
|
437
|
+
st.busy = false;
|
|
438
|
+
await reload();
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/** A team that left the list: drawn without it now (the reload confirms), and its detail closed when it was open. */
|
|
442
|
+
const dropTeam = (teamId) => {
|
|
443
|
+
st.rows = (st.rows || []).filter((row) => row.id !== teamId);
|
|
444
|
+
if (st.teamId === teamId) st.team = null;
|
|
445
|
+
if (ctx.view.teamId === teamId) ctx.go({ type: 'back' });
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Clean up & remove a ready team whose work is on its base branch already: behind a question that says where the
|
|
450
|
+
* work is, what is deleted and that git is asked again first (the server refuses, deleting nothing, if a worktree
|
|
451
|
+
* got edits or a branch got commits since this page read it).
|
|
452
|
+
*/
|
|
453
|
+
const cleanupMerged = async ({ id, name, branch, count, items = [] }) => {
|
|
454
|
+
const answer = await ctx.ask({
|
|
455
|
+
title: t('agentsStudio.teams.cleanupMergedTitle', { name }),
|
|
456
|
+
lines: [ctx.tp('agentsStudio.teams.cleanupMergedAsk', count, { branch }), ...listed(items), t('agentsStudio.teams.cleanupMergedSafe', { branch })],
|
|
457
|
+
className: 'ax-dlg',
|
|
458
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t('agentsStudio.teams.cleanupMerged'), kind: 'primary' }],
|
|
459
|
+
focus: 'cancel',
|
|
460
|
+
});
|
|
461
|
+
if (answer !== 'go') return;
|
|
462
|
+
st.busy = true;
|
|
463
|
+
ctx.render({ keepFocus: true });
|
|
464
|
+
try {
|
|
465
|
+
const out = await ctx.api.cleanupMergedTeam(id);
|
|
466
|
+
if (out?.teamRemoved === false) ctx.toast(t('agentsStudio.teams.cleanupMergedKeptToast', { reason: stayReason(t, out.removal) }));
|
|
467
|
+
else { ctx.toast(t('agentsStudio.teams.cleanupMergedToast', { branch: out?.branch || branch })); dropTeam(id); }
|
|
468
|
+
} catch (error) {
|
|
469
|
+
ctx.toast(t('agentsStudio.teams.cleanupMergedFailed', { error: errorText(t, error) }), 'error');
|
|
470
|
+
}
|
|
471
|
+
st.busy = false;
|
|
472
|
+
await reload();
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* A card's Discard, or Discard & remove when nothing of the team is on disk or in git. Each question says whether
|
|
477
|
+
* the card leaves the list: Discard moves it to Finished; Discard & remove takes it off, and keeps the team (in
|
|
478
|
+
* Finished, discarded) when a worktree or branch holding work turns up after all.
|
|
479
|
+
*/
|
|
480
|
+
const quickDiscard = async (row, remove) => {
|
|
481
|
+
const name = row.title || row.id;
|
|
482
|
+
const answer = await ctx.ask({
|
|
483
|
+
title: t(remove ? 'agentsStudio.teams.discardRemoveTitle' : 'agentsStudio.teams.discardTitle', { name }),
|
|
484
|
+
lines: remove
|
|
485
|
+
? [t('agentsStudio.teams.discardRemoveAsk'), t('agentsStudio.teams.discardRemoveSafe')]
|
|
486
|
+
: [t('agentsStudio.teams.discardAsk'), t('agentsStudio.teams.discardMoves'), t('agentsStudio.teams.discardKeeps')],
|
|
487
|
+
className: 'ax-dlg',
|
|
488
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t(remove ? 'agentsStudio.teams.discardRemove' : 'agentsStudio.teams.discard'), kind: 'danger' }],
|
|
489
|
+
focus: 'cancel',
|
|
490
|
+
});
|
|
491
|
+
if (answer !== 'go') return;
|
|
492
|
+
st.busy = true;
|
|
493
|
+
ctx.render({ keepFocus: true });
|
|
494
|
+
try {
|
|
495
|
+
const out = await ctx.api.discardTeam(row.id, remove ? { remove: true } : {});
|
|
496
|
+
const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
|
|
497
|
+
if (kept) ctx.toast(ctx.tp('agentsStudio.teams.discardKeptToast', kept));
|
|
498
|
+
else if (remove && out?.teamRemoved === true) { ctx.toast(t('agentsStudio.teams.discardRemovedToast')); dropTeam(row.id); }
|
|
499
|
+
else if (remove) ctx.toast(t('agentsStudio.teams.discardStaysToast', { reason: stayReason(t, out?.removal) }));
|
|
500
|
+
else ctx.toast(t('agentsStudio.teams.discardedToast'));
|
|
501
|
+
} catch (error) {
|
|
502
|
+
ctx.toast(t('agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
|
|
503
|
+
}
|
|
504
|
+
st.busy = false;
|
|
505
|
+
await reload();
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
/** Clear finished: every finished team with nothing left goes; the rest stay, and the toast says how many. */
|
|
509
|
+
const clearFinished = async () => {
|
|
510
|
+
const { removable, kept } = clearableTeams(st.rows || []);
|
|
511
|
+
if (!removable.length) return;
|
|
512
|
+
const answer = await ctx.ask({
|
|
513
|
+
title: t('agentsStudio.teams.clearTitle'),
|
|
514
|
+
lines: [ctx.tp('agentsStudio.teams.clearAsk', removable.length), kept ? ctx.tp('agentsStudio.teams.clearSkips', kept) : null, t('agentsStudio.teams.removeKeeps')],
|
|
515
|
+
className: 'ax-dlg',
|
|
516
|
+
buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t('agentsStudio.teams.clearFinished'), kind: 'danger' }],
|
|
517
|
+
focus: 'cancel',
|
|
518
|
+
});
|
|
519
|
+
if (answer !== 'go') return;
|
|
520
|
+
st.busy = true;
|
|
521
|
+
ctx.render({ keepFocus: true });
|
|
522
|
+
try {
|
|
523
|
+
const out = await ctx.api.clearFinishedTeams();
|
|
524
|
+
const removed = Array.isArray(out?.removed) ? out.removed.length : 0;
|
|
525
|
+
const skipped = Array.isArray(out?.skipped) ? out.skipped.length : 0;
|
|
526
|
+
const said = [removed ? ctx.tp('agentsStudio.teams.clearedToast', removed) : t('agentsStudio.teams.clearNothing'), skipped ? ctx.tp('agentsStudio.teams.clearSkippedToast', skipped) : ''].filter(Boolean).join(' ');
|
|
527
|
+
ctx.toast(said, removed ? 'info' : 'error');
|
|
528
|
+
} catch (error) {
|
|
529
|
+
ctx.toast(t('agentsStudio.teams.clearFailed', { error: errorText(t, error) }), 'error');
|
|
530
|
+
}
|
|
531
|
+
st.busy = false;
|
|
532
|
+
await reload();
|
|
533
|
+
};
|
|
534
|
+
|
|
246
535
|
main.addEventListener('click', (e) => {
|
|
247
536
|
const el = e.target.closest?.('[data-act]');
|
|
248
537
|
if (!el || !main.contains(el) || el.disabled) return;
|
|
@@ -252,5 +541,21 @@ export function renderTeams(main, ctx, st) {
|
|
|
252
541
|
else if (act === 'refresh' || act === 'retry') { st.error = null; st.detailError = null; reload(); }
|
|
253
542
|
else if (act === 'focus-run') ctx.focusRun(el.dataset.run);
|
|
254
543
|
else if (act === 'land' || act === 'discard') decide(act);
|
|
544
|
+
else if (act === 'cleanup' || act === 'force-discard' || act === 'remove') finish(act);
|
|
545
|
+
else if (act === 'clear-finished') clearFinished();
|
|
546
|
+
else if (act === 'quick') {
|
|
547
|
+
// A card's own action: never the card's click (which opens the team).
|
|
548
|
+
e.stopPropagation();
|
|
549
|
+
const row = (st.rows || []).find((r) => r.id === el.dataset.team);
|
|
550
|
+
const which = row ? quickActionOf(row, ctx.caps) : null;
|
|
551
|
+
if (!which || which !== el.dataset.quick) return;
|
|
552
|
+
if (which === 'cleanup-merged') cleanupMerged({ id: row.id, name: row.title || row.id, branch: row.onTarget.branch, count: row.left ?? 1 });
|
|
553
|
+
else quickDiscard(row, which === 'discard-remove');
|
|
554
|
+
} else if (act === 'cleanup-merged' && st.team) {
|
|
555
|
+
const view = teamView(st.team);
|
|
556
|
+
if (!view.canCleanupMerged) return;
|
|
557
|
+
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 }] : [])];
|
|
558
|
+
cleanupMerged({ id: view.id, name: view.title || view.id, branch: view.onTarget.branch, count: items.length || 1, items });
|
|
559
|
+
}
|
|
255
560
|
}, { signal });
|
|
256
561
|
}
|