@aarwitz/tapp 0.17.27 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +2 -2
- package/AGENTS.md +43 -44
- package/README.md +32 -42
- package/bin/tapp.js +168 -99
- package/browser/app.css +220 -208
- package/browser/app.js +173 -20
- package/browser/index.html +118 -57
- package/browser/tokens.css +33 -25
- package/docs/BROWSER-PRODUCT.md +16 -8
- package/docs/BUSINESS-WORKFLOWS.md +134 -0
- package/docs/PRODUCT-ENGINE.md +5 -0
- package/mcp-server/src/browser-product.js +15 -3
- package/mcp-server/src/business-observation.d.ts +2 -0
- package/mcp-server/src/business-observation.js +25 -0
- package/mcp-server/src/business-workflow-files.js +36 -0
- package/mcp-server/src/business-workflow-runtime.js +47 -0
- package/mcp-server/src/business-workflows.d.ts +50 -0
- package/mcp-server/src/business-workflows.js +169 -0
- package/mcp-server/src/environment-capabilities.d.ts +16 -0
- package/mcp-server/src/environment-capabilities.js +78 -0
- package/mcp-server/src/index.js +546 -794
- package/mcp-server/src/product-operations.js +3 -1
- package/mcp-server/src/public-network.js +65 -0
- package/mcp-server/src/web-audit.js +77 -17
- package/mcp-server/src/web-explorer.js +11 -1
- package/mcp-server/src/web-flow.js +17 -4
- package/package.json +7 -1
- package/scripts/run-web-flow.js +4 -0
- package/skills/tapp/SKILL.md +14 -13
- package/skills/tapp/references/commands.md +73 -57
package/browser/app.js
CHANGED
|
@@ -13,7 +13,7 @@ function apiRoute(route) {
|
|
|
13
13
|
const state = {
|
|
14
14
|
csrf: "", session: null, project: null, activeJob: null, activeView: "overview",
|
|
15
15
|
selectedTargetId: "", selectedRunId: "", selectedFindingId: "", githubRepositories: [],
|
|
16
|
-
uploadedEntries: [], live: { active:false },
|
|
16
|
+
uploadedEntries: [], live: { active:false }, transcript: [], transcriptSource: "", frameTimer: null,
|
|
17
17
|
};
|
|
18
18
|
const $ = (selector) => document.querySelector(selector);
|
|
19
19
|
const $$ = (selector) => [...document.querySelectorAll(selector)];
|
|
@@ -99,20 +99,32 @@ function showProduct() {
|
|
|
99
99
|
activateView(location.hash.slice(1) || state.activeView);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
function sourceLayer(repository) {
|
|
103
|
+
return repository?.source?.kind === "website" ? "Website" : "Repository";
|
|
104
|
+
}
|
|
105
|
+
|
|
102
106
|
function renderRepositoryChrome() {
|
|
103
107
|
const repositories = state.session?.repositories || [];
|
|
104
108
|
const current = state.project?.repository || state.session?.repository;
|
|
105
109
|
const switcher = $("#repository-switcher");
|
|
106
110
|
switcher.classList.toggle("hidden", repositories.length < 1);
|
|
107
|
-
switcher.innerHTML = repositories.map((repository) => `<option value="${esc(repository.id)}" ${repository.id === current?.id ? "selected" : ""}>${esc(repository.name)} · ${esc(repository.source?.kind || "repository")}</option>`).join("") + '<option value="__add__">+ Add
|
|
111
|
+
switcher.innerHTML = repositories.map((repository) => `<option value="${esc(repository.id)}" ${repository.id === current?.id ? "selected" : ""}>${esc(repository.name)} · ${esc(repository.source?.kind || "repository")}</option>`).join("") + '<option value="__add__">+ Add project…</option>';
|
|
108
112
|
$("#refresh-project").classList.toggle("hidden", !current);
|
|
109
113
|
if (!current) return;
|
|
114
|
+
const website = sourceLayer(current) === "Website";
|
|
110
115
|
$("#sidebar-project-name").textContent = state.project?.application?.name || current.name;
|
|
111
|
-
$("#sidebar-project-source").textContent = current.source?.label || current.root || "Repository";
|
|
116
|
+
$("#sidebar-project-source").textContent = website ? "Website · no source, no release verdict" : (current.source?.label || current.root || "Repository");
|
|
112
117
|
$("#project-avatar").textContent = (state.project?.application?.name || current.name || "T").slice(0, 1).toUpperCase();
|
|
113
118
|
$("#repository-title").textContent = current.source?.label || current.name;
|
|
114
|
-
$("#repository-detail").textContent = current.source?.note || (current.ephemeral ? "This is an isolated working copy. Review and export changes before updating the source repository." : `Direct local checkout · ${current.root}`);
|
|
115
|
-
$("#settings-repository").innerHTML = `<dl class="settings-dl"><div><dt>Source</dt><dd>${esc(pretty(current.source?.kind))}</dd></div><div><dt>Location</dt><dd><code>${esc(current.root)}</code></dd></div><div><dt>Write mode</dt><dd>${current.ephemeral ? "Isolated review copy" : "Direct checkout"}</dd></div></dl>`;
|
|
119
|
+
$("#repository-detail").textContent = current.source?.note || (website ? "Connected website. Tapp can explore, record, and check it; a release verdict needs a source revision." : current.ephemeral ? "This is an isolated working copy. Review and export changes before updating the source repository." : `Direct local checkout · ${current.root}`);
|
|
120
|
+
$("#settings-repository").innerHTML = `<dl class="settings-dl"><div><dt>Layer</dt><dd>${sourceLayer(current)}</dd></div><div><dt>Source</dt><dd>${esc(pretty(current.source?.kind))}</dd></div><div><dt>Location</dt><dd><code>${esc(current.root || current.source?.label || "—")}</code></dd></div><div><dt>Write mode</dt><dd>${website ? "Observation only" : current.ephemeral ? "Isolated review copy" : "Direct checkout"}</dd></div></dl>`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function setCount(id, value, { alert = false } = {}) {
|
|
124
|
+
const node = $(id);
|
|
125
|
+
node.textContent = value;
|
|
126
|
+
node.classList.toggle("zero", !value);
|
|
127
|
+
node.classList.toggle("alert", alert && value > 0);
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
function renderTargets() {
|
|
@@ -132,9 +144,14 @@ function renderTargets() {
|
|
|
132
144
|
$("#target-status").textContent = target ? `${pretty(target.platform)} · ${target.name}` : targets.length > 1 ? "Selection required" : "No target selected";
|
|
133
145
|
$("#sidebar-target").textContent = target ? `${pretty(target.platform)} · ${target.name}` : "Select a target";
|
|
134
146
|
$("#sidebar-runner").textContent = target ? (state.session?.runners?.find((runner) => runner.platform === target.platform)?.label || "Runner resolves at execution") : "Runner not selected";
|
|
147
|
+
const appId = target?.runtime?.bundleId || target?.runtime?.applicationId || target?.build?.bundleId || "";
|
|
148
|
+
$("#sidebar-app-row").classList.toggle("hidden", !appId);
|
|
149
|
+
$("#sidebar-app-id").textContent = appId;
|
|
150
|
+
renderDeviceChrome(target);
|
|
135
151
|
$("#runtime-row").classList.toggle("hidden", !targets.length);
|
|
136
152
|
$("#serial-field").classList.toggle("hidden", target?.platform !== "android");
|
|
137
153
|
$("#explore").disabled = !target;
|
|
154
|
+
$("#command-run").disabled = !target || !!state.activeJob;
|
|
138
155
|
$("#explore").textContent = target && targets.length > 1 ? `Build & explore ${target.name}` : "Build, launch & explore";
|
|
139
156
|
$("#start-session").disabled = !target || state.live?.active === true;
|
|
140
157
|
$("#explore-help").textContent = !target ? (targets.length > 1 ? `Choose one of the ${targets.length} detected targets. Tapp will not select one for you.` : "Inspect to discover a runnable target.")
|
|
@@ -143,20 +160,63 @@ function renderTargets() {
|
|
|
143
160
|
: "Builds and starts the selected repository web application, then explores it in Chromium.";
|
|
144
161
|
}
|
|
145
162
|
|
|
163
|
+
function renderDeviceChrome(target) {
|
|
164
|
+
const platform = state.live?.active ? state.live.platform : target?.platform;
|
|
165
|
+
const frame = $("#device-frame");
|
|
166
|
+
frame.className = `device-frame ${platform === "ios" ? "" : platform || ""}`.trim();
|
|
167
|
+
$("#device-feed-label").textContent = platform === "android" ? "Live Android Feed" : platform === "web" ? "Live Browser Feed" : "Live iPhone Feed";
|
|
168
|
+
$("#device-meta-device").textContent = platform === "ios" ? (target?.runtime?.surface || "iOS Simulator")
|
|
169
|
+
: platform === "android" ? (target?.runtime?.serial || "Android emulator / device")
|
|
170
|
+
: platform === "web" ? "Chromium" : "—";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The device panel shows whichever real surface exists right now: an interactive session's frame,
|
|
174
|
+
// else the newest screenshot the running exploration wrote. Nothing is synthesized.
|
|
175
|
+
function frameSource() {
|
|
176
|
+
if (state.live?.active) return "/api/live-session/frame";
|
|
177
|
+
if (state.activeJob && state.jobHasFrame) return `/api/jobs/${state.activeJob}/frame`;
|
|
178
|
+
return "";
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// One in-flight capture at a time; the next request waits for the previous image to land so a
|
|
182
|
+
// slow simulator does not pile up frame requests.
|
|
146
183
|
function refreshLiveFrame() {
|
|
147
|
-
|
|
184
|
+
clearTimeout(state.frameTimer);
|
|
185
|
+
const source = frameSource();
|
|
186
|
+
if (!source) { stopLiveFrames(); return; }
|
|
148
187
|
const image = $("#live-frame-image");
|
|
149
188
|
const loading = $("#live-frame-loading");
|
|
150
|
-
|
|
151
|
-
image.
|
|
152
|
-
image.
|
|
153
|
-
image.
|
|
189
|
+
$("#device-placeholder").classList.add("hidden");
|
|
190
|
+
if (!image.naturalWidth) loading.classList.remove("hidden");
|
|
191
|
+
image.onload = () => { loading.classList.add("hidden"); scheduleLiveFrame(); };
|
|
192
|
+
image.onerror = () => { loading.textContent = "Live frame could not be captured. The semantic controls remain available."; scheduleLiveFrame(); };
|
|
193
|
+
image.src = apiRoute(`${source}?at=${Date.now()}`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function scheduleLiveFrame() {
|
|
197
|
+
clearTimeout(state.frameTimer);
|
|
198
|
+
if (frameSource()) state.frameTimer = setTimeout(refreshLiveFrame, 1500);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function stopLiveFrames() {
|
|
202
|
+
clearTimeout(state.frameTimer);
|
|
203
|
+
state.frameTimer = null;
|
|
154
204
|
}
|
|
155
205
|
|
|
156
206
|
function renderLiveSession() {
|
|
157
207
|
const live = state.live || { active:false };
|
|
158
208
|
$("#live-session-panel").classList.toggle("hidden", !live.active);
|
|
159
|
-
if (!live.active)
|
|
209
|
+
if (!live.active) {
|
|
210
|
+
// Keep the last real frame on screen after a run; only show the placeholder when nothing was ever captured.
|
|
211
|
+
if (!frameSource()) stopLiveFrames();
|
|
212
|
+
const hasFrame = !!$("#live-frame-image").getAttribute("src");
|
|
213
|
+
$("#live-frame-loading").classList.toggle("hidden", hasFrame || !frameSource());
|
|
214
|
+
$("#device-placeholder").classList.toggle("hidden", hasFrame);
|
|
215
|
+
if (!state.activeJob) $("#live-screen-title").textContent = hasFrame ? $("#live-screen-title").textContent : "—";
|
|
216
|
+
renderDeviceChrome(currentTarget());
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
renderDeviceChrome(currentTarget());
|
|
160
220
|
$("#live-screen-title").textContent = live.screenTitle || live.targetName || "Running target";
|
|
161
221
|
$("#live-platform").textContent = `${pretty(live.platform)} · ${live.targetName || "live target"}`;
|
|
162
222
|
$("#live-recorded-steps").textContent = `${live.recordedSteps || 0} recorded step${live.recordedSteps === 1 ? "" : "s"}`;
|
|
@@ -205,7 +265,7 @@ function renderPlan(plan) {
|
|
|
205
265
|
$("#plan-status").textContent = plan ? `${items.length} proposed · ${pending} pending` : "No plan";
|
|
206
266
|
$("#plan-list").innerHTML = planHtml(plan);
|
|
207
267
|
$("#coverage-plan-list").innerHTML = planHtml(plan);
|
|
208
|
-
|
|
268
|
+
setCount("#contract-count", state.project?.model?.artifacts?.contracts?.length || 0);
|
|
209
269
|
}
|
|
210
270
|
|
|
211
271
|
function renderArtifacts(model, plan) {
|
|
@@ -274,7 +334,7 @@ function findingTitle(finding) { return finding.title || finding.message || find
|
|
|
274
334
|
function renderFindings() {
|
|
275
335
|
const filter = $("#finding-filter").value;
|
|
276
336
|
const findings = allFindings().filter((finding) => filter === "all" || String(finding.severity).toLowerCase() === filter);
|
|
277
|
-
|
|
337
|
+
setCount("#finding-count", allFindings().filter((finding) => ["critical", "high"].includes(String(finding.severity).toLowerCase())).length, { alert:true });
|
|
278
338
|
$("#findings-list").innerHTML = findings.length ? findings.map((finding) => `<button class="finding-row ${finding.__id === state.selectedFindingId ? "selected" : ""}" data-finding-id="${esc(finding.__id)}"><span class="severity ${esc(String(finding.severity || "info").toLowerCase())}"></span><span><strong>${esc(findingTitle(finding))}</strong><small>${esc(finding.screen || finding.category || pretty(finding.type))} · ${compactDate(finding.__createdAt)}</small></span><em>${esc(finding.severity || "info")}</em></button>`).join("") : '<div class="empty">No findings match this view.</div>';
|
|
279
339
|
const selected = findings.find((finding) => finding.__id === state.selectedFindingId) || findings[0];
|
|
280
340
|
if (selected) state.selectedFindingId = selected.__id;
|
|
@@ -282,7 +342,7 @@ function renderFindings() {
|
|
|
282
342
|
}
|
|
283
343
|
|
|
284
344
|
function renderRuns(runs) {
|
|
285
|
-
|
|
345
|
+
setCount("#run-count", runs.length);
|
|
286
346
|
$("#runs-list").innerHTML = runs.length ? runs.map((run) => {
|
|
287
347
|
const report = run.report;
|
|
288
348
|
const failed = report?.gate?.failed === true;
|
|
@@ -324,6 +384,78 @@ function renderRunners() {
|
|
|
324
384
|
$("#actor-list").innerHTML = actors.length ? actors.map((actor) => `<div class="actor-row"><span>${esc(actor.name.slice(0, 1).toUpperCase())}</span><div><strong>${esc(actor.name)}</strong><small>${esc((actor.roles || []).join(", ") || actor.session || "actor")} · ${(actor.credentialRequirements || []).length} credential binding(s)</small></div></div>`).join("") : '<p class="muted">No actors are configured. Tapp will ask only when a reviewed journey requires one.</p>';
|
|
325
385
|
}
|
|
326
386
|
|
|
387
|
+
const chatTime = (value) => new Intl.DateTimeFormat(undefined, { hour:"numeric", minute:"2-digit" }).format(new Date(value));
|
|
388
|
+
|
|
389
|
+
function renderChat() {
|
|
390
|
+
const node = $("#chat-transcript");
|
|
391
|
+
const stickToBottom = node.scrollTop + node.clientHeight >= node.scrollHeight - 24;
|
|
392
|
+
node.innerHTML = state.transcript.map((entry) => `<div class="chat-bubble ${esc(entry.kind || "")} ${esc(entry.severity || "")}">${esc(entry.text)}<small>${chatTime(entry.at)}</small></div>`).join("")
|
|
393
|
+
+ (state.activeJob ? '<div class="chat-bubble typing">tapp is working…</div>' : "");
|
|
394
|
+
if (stickToBottom) node.scrollTop = node.scrollHeight;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// The transcript is the engine's own progress log, bubble per entry. Phase changes get the
|
|
398
|
+
// `phase` style; everything else is narration of what actually happened.
|
|
399
|
+
function syncTranscriptFromJob(name, job) {
|
|
400
|
+
const key = job.id;
|
|
401
|
+
if (state.transcriptSource !== key) { state.transcript = [{ at: job.createdAt, kind: "phase", text: `${pretty(name)} started` }]; state.transcriptSource = key; }
|
|
402
|
+
const seen = state.transcript.length - 1;
|
|
403
|
+
for (const entry of job.progress.slice(seen)) {
|
|
404
|
+
// Engine progress lines can carry a whole contract result; the transcript keeps the lede.
|
|
405
|
+
const text = String(entry.text || "").trim().replace(/\s+/g, " ").slice(0, 220).replace(/(.{219}).+/, "$1…");
|
|
406
|
+
if (!text) continue;
|
|
407
|
+
const last = state.transcript.at(-1);
|
|
408
|
+
if (last && last.text === text) continue;
|
|
409
|
+
state.transcript.push({ at: entry.at, kind: entry.phase === "explore" || entry.phase === "runtime" ? "" : "phase", text });
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function finishTranscript(name, job) {
|
|
414
|
+
if (job.status === "failed") { state.transcript.push({ at: job.completedAt || new Date().toISOString(), kind: "failed", text: job.error?.message || `${pretty(name)} failed` }); return; }
|
|
415
|
+
const report = job.result?.report || job.result;
|
|
416
|
+
for (const finding of (report?.findings || []).slice(0, 12)) {
|
|
417
|
+
const severity = String(finding.severity || "info").toLowerCase();
|
|
418
|
+
state.transcript.push({ at: job.completedAt || new Date().toISOString(), kind: "finding", severity, text: `${pretty(severity)} issue${finding.screen ? ` on ${finding.screen}` : ""}: ${finding.title || finding.message || finding.type || "finding"}` });
|
|
419
|
+
}
|
|
420
|
+
const summary = report?.headline || (name === "gate" ? (job.result?.passed === false ? "Release gate blocked this revision." : "Release gate completed.") : `${pretty(name)} completed`);
|
|
421
|
+
state.transcript.push({ at: job.completedAt || new Date().toISOString(), kind: "summary", text: summary });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function seedIdleTranscript() {
|
|
425
|
+
if (state.transcriptSource) return;
|
|
426
|
+
const latest = latestRun();
|
|
427
|
+
const report = latest?.report;
|
|
428
|
+
state.transcript = report
|
|
429
|
+
? [{ at: latest.createdAt, kind: "summary", text: `Last run: ${report.headline || "release run completed"} · ${report.screensExplored || 0} states · ${(report.findings || []).length} findings` }]
|
|
430
|
+
: [{ at: new Date().toISOString(), kind: "phase", text: state.project?.state?.inspected ? "Ready. Run a release check to watch Tapp build, launch, and explore the real app." : "Inspecting the project to discover its targets." }];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function renderCommandState(job = null, name = "") {
|
|
434
|
+
const running = !!state.activeJob;
|
|
435
|
+
const pill = $("#phase-pill");
|
|
436
|
+
pill.classList.toggle("hidden", !running);
|
|
437
|
+
pill.classList.toggle("running", running);
|
|
438
|
+
$("#command-run").disabled = running || !currentTarget();
|
|
439
|
+
$("#run-progress").classList.toggle("hidden", !running);
|
|
440
|
+
$("#idle-badges").classList.toggle("hidden", running);
|
|
441
|
+
if (running) {
|
|
442
|
+
const progress = job?.progress?.at(-1);
|
|
443
|
+
const text = progress?.text || `${pretty(name)}…`;
|
|
444
|
+
$("#phase-pill-text").textContent = text;
|
|
445
|
+
$("#run-progress-text").textContent = text;
|
|
446
|
+
const ratio = progress?.current && progress?.total ? Math.min(92, Math.round(progress.current / progress.total * 100)) : Math.min(88, 8 + (job?.progress?.length || 0) * 4);
|
|
447
|
+
$("#run-progress-bar").style.width = `${ratio}%`;
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const target = currentTarget();
|
|
451
|
+
const runner = target ? state.session?.runners?.find((item) => item.platform === target.platform) : null;
|
|
452
|
+
$("#idle-badges").innerHTML = [
|
|
453
|
+
target ? `<span><b>${esc(pretty(target.platform))}</b> · ${esc(target.name)}</span>` : "<span>No target selected</span>",
|
|
454
|
+
runner ? `<span>${esc(runner.label)} · ${esc(pretty(runner.status))}</span>` : "",
|
|
455
|
+
`<span>Idle · ${target ? "Ready for next release check" : "Choose a target to run"}</span>`,
|
|
456
|
+
].filter(Boolean).join("");
|
|
457
|
+
}
|
|
458
|
+
|
|
327
459
|
function renderJourney(status) {
|
|
328
460
|
const flags = productJourneyFlags({ status, hasTarget:!!currentTarget(), hasEvidence:(state.project?.evidence || []).some((run) => run.report) });
|
|
329
461
|
$$(".journey button").forEach((button, index) => button.classList.toggle("done", !!flags[index]));
|
|
@@ -351,15 +483,24 @@ function renderProject() {
|
|
|
351
483
|
renderRunners();
|
|
352
484
|
renderLiveSession();
|
|
353
485
|
renderJourney(project.state);
|
|
486
|
+
seedIdleTranscript();
|
|
487
|
+
renderChat();
|
|
488
|
+
renderCommandState();
|
|
354
489
|
}
|
|
355
490
|
|
|
356
491
|
async function refreshSession() {
|
|
357
492
|
state.session = await api("/api/session");
|
|
358
493
|
state.csrf = state.session.csrfToken;
|
|
359
494
|
const local = state.session.mode === "local";
|
|
360
|
-
$("#mode-pill").textContent = local ? "
|
|
361
|
-
$("#
|
|
362
|
-
$("#privacy-note-
|
|
495
|
+
$("#mode-pill").textContent = local ? "Self-host · this machine" : "Cloud · outbound runner";
|
|
496
|
+
$("#onboarding-mode-pill").textContent = local ? "Self-host · this machine" : "Cloud";
|
|
497
|
+
$("#privacy-note-title").textContent = local ? "Your code stays on this machine in self-host mode." : "Your repository stays in your private Tapp workspace.";
|
|
498
|
+
$("#privacy-note-detail").textContent = local ? "Ordinary exploration, replay, and merge decisions are deterministic and require no API key. This machine must stay open while Tapp runs." : "Builds and application runs execute on your connected outbound runner; the hosted control plane keeps the evidence.";
|
|
499
|
+
$("#website-connect-link").classList.toggle("hidden", local);
|
|
500
|
+
$(".local-runner-card").classList.toggle("hidden", local);
|
|
501
|
+
$("#website-source-note").textContent = local
|
|
502
|
+
? "In the local Studio, website checks run from the CLI: npx -y @aarwitz/tapp@latest explore https://example.com --read-only. Website projects live in the hosted Studio."
|
|
503
|
+
: "You confirm you own the site before Tapp observes it. Accounts and backend access are configured privately, never in chat.";
|
|
363
504
|
if (!local) {
|
|
364
505
|
$("#github-source-copy").textContent = "Repository upload works now. GitHub App connection will add selected-repository import without changing the product workflow.";
|
|
365
506
|
$("#github-source-note").textContent = "Use This Mac now; GitHub can be added independently later.";
|
|
@@ -384,6 +525,9 @@ async function runOperation(name, body = {}) {
|
|
|
384
525
|
$("#operation-title").textContent = pretty(name);
|
|
385
526
|
$("#operation-progress").textContent = "Starting operation";
|
|
386
527
|
$("#operation-progress-bar").style.width = "6%";
|
|
528
|
+
syncTranscriptFromJob(name, started.job);
|
|
529
|
+
renderCommandState(started.job, name);
|
|
530
|
+
renderChat();
|
|
387
531
|
try {
|
|
388
532
|
while (true) {
|
|
389
533
|
await new Promise((resolve) => setTimeout(resolve, 650));
|
|
@@ -392,7 +536,14 @@ async function runOperation(name, body = {}) {
|
|
|
392
536
|
$("#operation-progress").textContent = progress?.text || "Working…";
|
|
393
537
|
const ratio = progress?.current && progress?.total ? Math.min(92, Math.round(progress.current / progress.total * 100)) : Math.min(88, 8 + job.progress.length * 4);
|
|
394
538
|
$("#operation-progress-bar").style.width = `${ratio}%`;
|
|
539
|
+
syncTranscriptFromJob(name, job);
|
|
540
|
+
renderCommandState(job, name);
|
|
541
|
+
renderChat();
|
|
542
|
+
const screen = [...job.progress].reverse().find((entry) => entry.screen)?.screen;
|
|
543
|
+
if (screen && !state.live?.active) $("#live-screen-title").textContent = screen;
|
|
544
|
+
if (job.frame && !state.jobHasFrame) { state.jobHasFrame = true; refreshLiveFrame(); }
|
|
395
545
|
if (operationIsPending(job.status)) continue;
|
|
546
|
+
finishTranscript(name, job);
|
|
396
547
|
if (job.status === "failed") throw new Error(job.error?.message || "Operation failed");
|
|
397
548
|
if (job.status !== "completed") throw new Error(`Operation ended in an unknown '${job.status}' state`);
|
|
398
549
|
$("#operation-progress-bar").style.width = "100%";
|
|
@@ -404,6 +555,7 @@ async function runOperation(name, body = {}) {
|
|
|
404
555
|
return job.result;
|
|
405
556
|
}
|
|
406
557
|
} finally {
|
|
558
|
+
if (state.jobHasFrame) { state.jobHasFrame = false; await new Promise((resolve) => setTimeout(resolve, 200)); stopLiveFrames(); }
|
|
407
559
|
state.activeJob = null;
|
|
408
560
|
try {
|
|
409
561
|
await refreshSession();
|
|
@@ -614,6 +766,8 @@ document.addEventListener("click", (event) => {
|
|
|
614
766
|
activateView(view);
|
|
615
767
|
setTimeout(() => document.getElementById(destination)?.scrollIntoView({ behavior:"smooth", block:"start" }), 20);
|
|
616
768
|
}
|
|
769
|
+
const localButton = event.target.closest("[data-local-repository]");
|
|
770
|
+
if (localButton) api("/api/repositories/local", { method:"POST", body:JSON.stringify({ runnerId:localButton.dataset.localRunner, repositoryId:localButton.dataset.localRepository }) }).then(async () => { state.selectedTargetId = ""; await refreshSession(); await refresh(); }).catch((error) => toast(error.message, true));
|
|
617
771
|
const liveControl = event.target.closest("[data-live-control]");
|
|
618
772
|
if (liveControl) {
|
|
619
773
|
const target = liveControl.dataset.liveTarget;
|
|
@@ -626,7 +780,8 @@ document.addEventListener("click", (event) => {
|
|
|
626
780
|
}
|
|
627
781
|
});
|
|
628
782
|
|
|
629
|
-
|
|
783
|
+
$$("[data-brand-home]").forEach((button) => button.addEventListener("click", () => state.project?.connected ? (showProduct(), activateView("overview")) : showSourceOnboarding()));
|
|
784
|
+
$("#command-run").addEventListener("click", () => runOperation("initialize", operationPayload({ explore:true })).catch((error) => toast(error.message, true)));
|
|
630
785
|
$("#refresh-project").addEventListener("click", () => refresh().catch((error) => toast(error.message, true)));
|
|
631
786
|
$("#change-source").addEventListener("click", showSourceOnboarding);
|
|
632
787
|
$("#settings-add-repository").addEventListener("click", showSourceOnboarding);
|
|
@@ -677,5 +832,3 @@ try {
|
|
|
677
832
|
// choice when detection is ambiguous.
|
|
678
833
|
if (state.project?.connected && !state.project?.state?.inspected) await runOperation("initialize", { write:true });
|
|
679
834
|
} catch (error) { toast(error.message, true); }
|
|
680
|
-
const localButton = event.target.closest("[data-local-repository]");
|
|
681
|
-
if(localButton) api("/api/repositories/local",{method:"POST",body:JSON.stringify({runnerId:localButton.dataset.localRunner,repositoryId:localButton.dataset.localRepository})}).then(async()=>{state.selectedTargetId="";await refreshSession();await refresh();}).catch(error=>toast(error.message,true));
|