@clagentic/console 1.12.0-beta.1 → 1.12.0-beta.3
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/LICENSES/README.md +5 -0
- package/README.md +1 -0
- package/bin/cli.js +5 -2
- package/lib/agent-roster-ws.js +84 -0
- package/lib/agent-roster.js +312 -0
- package/lib/auth-required-notify.js +42 -0
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +34 -11
- package/lib/build-update-standing.js +34 -14
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/duration.js +27 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +60 -11
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +31 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +18 -22
- package/lib/notify/core.js +210 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +62 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +81 -0
- package/lib/notify/types.js +57 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +85 -0
- package/lib/outbound-entry.js +116 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +48 -8
- package/lib/project-filesystem.js +43 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +38 -26
- package/lib/project-notifications.js +122 -39
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +11 -1
- package/lib/project-user-mention.js +22 -34
- package/lib/project-user-message.js +208 -4
- package/lib/project-user-shell.js +298 -0
- package/lib/project.js +41 -5
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +98 -25
- package/lib/prompt-reminders.js +38 -33
- package/lib/prompt-source.js +59 -8
- package/lib/public/app.js +32 -2
- package/lib/public/css/agent-messages.css +96 -0
- package/lib/public/css/agent-roster.css +93 -0
- package/lib/public/css/diagnostics.css +29 -1
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +20 -141
- package/lib/public/css/login-panel.css +73 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/sidebar.css +18 -0
- package/lib/public/css/team-panel.css +1 -6
- package/lib/public/css/team-view.css +101 -0
- package/lib/public/css/title-bar.css +10 -0
- package/lib/public/css/user-shell.css +144 -0
- package/lib/public/index.html +44 -7
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/agent-avatar-picker.js +162 -0
- package/lib/public/modules/agent-avatar.js +153 -0
- package/lib/public/modules/agent-messages.js +285 -0
- package/lib/public/modules/agent-roster.js +157 -0
- package/lib/public/modules/app-connection.js +34 -5
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +104 -75
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +32 -7
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +33 -18
- package/lib/public/modules/compaction-state.js +34 -0
- package/lib/public/modules/custom-icons.js +23 -5
- package/lib/public/modules/diagnostics.js +61 -57
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/injected-identity.js +24 -21
- package/lib/public/modules/input.js +176 -15
- package/lib/public/modules/login-panel.js +136 -0
- package/lib/public/modules/login-parser.js +73 -0
- package/lib/public/modules/login-tab.js +66 -0
- package/lib/public/modules/notifications.js +9 -1
- package/lib/public/modules/notify-client.js +246 -0
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/queued-button.js +11 -0
- package/lib/public/modules/scheduled-input-actions.js +12 -4
- package/lib/public/modules/scheduled-outbox.js +230 -0
- package/lib/public/modules/send-now.js +200 -0
- package/lib/public/modules/server-settings.js +50 -1
- package/lib/public/modules/shell-card.js +76 -0
- package/lib/public/modules/shell-line.js +49 -0
- package/lib/public/modules/shell-queue.js +253 -0
- package/lib/public/modules/shell-settings-controls.js +76 -0
- package/lib/public/modules/sidebar-mobile.js +3 -3
- package/lib/public/modules/sidebar-sessions.js +8 -0
- package/lib/public/modules/sidebar-users.js +5 -7
- package/lib/public/modules/team-panel.js +30 -88
- package/lib/public/modules/team-view.js +211 -0
- package/lib/public/modules/terminal-links.js +193 -0
- package/lib/public/modules/terminal.js +84 -107
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +252 -0
- package/lib/public/notify-target.js +157 -0
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +20 -69
- package/lib/push.js +63 -19
- package/lib/queued-chat.js +392 -0
- package/lib/runtime-env.js +1 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +184 -73
- package/lib/sdk-message-processor.js +124 -76
- package/lib/server-auth.js +6 -4
- package/lib/server-dm.js +11 -20
- package/lib/server-settings.js +39 -1
- package/lib/server.js +112 -16
- package/lib/session-directory.js +39 -12
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +37 -1
- package/lib/session-input.js +263 -21
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +80 -9
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +36 -7
- package/lib/user-shell-settings.js +105 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +33 -5
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +17 -1
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +225 -6
- package/lib/yoke/adapters/codex-capabilities.js +6 -1
- package/lib/yoke/adapters/codex-user-shell.js +265 -0
- package/lib/yoke/adapters/codex-vendor.js +7 -0
- package/lib/yoke/adapters/codex.js +186 -52
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +40 -1
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// team-panel.js -
|
|
1
|
+
// team-panel.js - The Agent Teams section of the Team view
|
|
2
2
|
// Handles team_state, team_member_update, team_task_update, team_message,
|
|
3
|
-
// team_gone WS messages
|
|
3
|
+
// team_gone WS messages and registers the "Agent Teams" section with the
|
|
4
|
+
// section registry in team-view.js, which draws it on desktop and mobile.
|
|
4
5
|
|
|
5
6
|
import { store } from './store.js';
|
|
6
7
|
import { getWs } from './ws-ref.js';
|
|
7
8
|
import { escapeHtml } from './utils.js';
|
|
8
|
-
import {
|
|
9
|
+
import { registerTeamSection, openTeamView, refreshTeamView, closeTeamViewIfAutoOpened } from './team-view.js';
|
|
9
10
|
|
|
10
11
|
// --- Module state ---
|
|
11
12
|
var currentTeam = null;
|
|
12
13
|
var teamMessages = [];
|
|
13
|
-
var panelOpen = false;
|
|
14
14
|
|
|
15
15
|
// --- Helpers ---
|
|
16
16
|
|
|
@@ -172,46 +172,38 @@ function renderMessagesSection(container, messages) {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
if (!bodyEl) return;
|
|
178
|
-
bodyEl.innerHTML = "";
|
|
179
|
-
|
|
180
|
-
if (!currentTeam) {
|
|
181
|
-
bodyEl.innerHTML =
|
|
182
|
-
'<div class="team-empty-state">' +
|
|
183
|
-
'<p>No active team</p>' +
|
|
184
|
-
'<p class="team-empty-hint">Start a session with Agent Teams enabled to see live activity here.</p>' +
|
|
185
|
-
'</div>';
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
175
|
+
function renderAgentTeamsSection(container) {
|
|
176
|
+
if (!currentTeam) return;
|
|
188
177
|
|
|
189
|
-
renderMembersSection(
|
|
178
|
+
renderMembersSection(container, currentTeam.members, currentTeam._memberStatuses, currentTeam._memberActivities);
|
|
190
179
|
|
|
191
180
|
var divider1 = document.createElement("hr");
|
|
192
181
|
divider1.className = "mobile-sheet-divider";
|
|
193
|
-
|
|
182
|
+
container.appendChild(divider1);
|
|
194
183
|
|
|
195
|
-
renderTasksSection(
|
|
184
|
+
renderTasksSection(container, currentTeam.tasks);
|
|
196
185
|
|
|
197
186
|
var divider2 = document.createElement("hr");
|
|
198
187
|
divider2.className = "mobile-sheet-divider";
|
|
199
|
-
|
|
188
|
+
container.appendChild(divider2);
|
|
189
|
+
|
|
190
|
+
renderMessagesSection(container, teamMessages);
|
|
191
|
+
}
|
|
200
192
|
|
|
201
|
-
|
|
193
|
+
export function hasActiveTeam() {
|
|
194
|
+
return !!currentTeam;
|
|
202
195
|
}
|
|
203
196
|
|
|
197
|
+
registerTeamSection({
|
|
198
|
+
id: "agent-teams",
|
|
199
|
+
title: "Agent Teams",
|
|
200
|
+
render: renderAgentTeamsSection,
|
|
201
|
+
isAvailable: hasActiveTeam,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
204
|
// --- Exports ---
|
|
205
205
|
|
|
206
206
|
export function initTeamPanel() {
|
|
207
|
-
// Wire close button
|
|
208
|
-
var closeBtn = document.getElementById("team-panel-close");
|
|
209
|
-
if (closeBtn) {
|
|
210
|
-
closeBtn.addEventListener("click", function () {
|
|
211
|
-
toggleTeamPanel();
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
207
|
// Send team_request_state when WS connects
|
|
216
208
|
store.subscribe(["connected"], function (state, prev) {
|
|
217
209
|
if (state.connected && !prev.connected) {
|
|
@@ -229,14 +221,8 @@ export function handleTeamState(msg) {
|
|
|
229
221
|
}
|
|
230
222
|
teamMessages = msg.messages || [];
|
|
231
223
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (currentTeam) {
|
|
235
|
-
panel.classList.remove("hidden");
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
renderTeamPanelBody();
|
|
224
|
+
if (currentTeam) openTeamView({ auto: true });
|
|
225
|
+
else refreshTeamView();
|
|
240
226
|
}
|
|
241
227
|
|
|
242
228
|
export function handleTeamMemberUpdate(msg) {
|
|
@@ -259,7 +245,7 @@ export function handleTeamMemberUpdate(msg) {
|
|
|
259
245
|
}
|
|
260
246
|
}
|
|
261
247
|
|
|
262
|
-
|
|
248
|
+
refreshTeamView();
|
|
263
249
|
}
|
|
264
250
|
|
|
265
251
|
export function handleTeamTaskUpdate(msg) {
|
|
@@ -267,7 +253,7 @@ export function handleTeamTaskUpdate(msg) {
|
|
|
267
253
|
if (msg.tasks) {
|
|
268
254
|
currentTeam.tasks = msg.tasks;
|
|
269
255
|
}
|
|
270
|
-
|
|
256
|
+
refreshTeamView();
|
|
271
257
|
}
|
|
272
258
|
|
|
273
259
|
export function handleTeamMessage(msg) {
|
|
@@ -275,58 +261,14 @@ export function handleTeamMessage(msg) {
|
|
|
275
261
|
teamMessages.push(msg.message);
|
|
276
262
|
if (teamMessages.length > 50) teamMessages.shift();
|
|
277
263
|
}
|
|
278
|
-
|
|
264
|
+
refreshTeamView();
|
|
279
265
|
}
|
|
280
266
|
|
|
281
267
|
export function handleTeamGone() {
|
|
282
268
|
currentTeam = null;
|
|
283
269
|
teamMessages = [];
|
|
284
|
-
panelOpen = false;
|
|
285
|
-
|
|
286
|
-
var panel = document.getElementById("team-panel");
|
|
287
|
-
if (panel) panel.classList.add("hidden");
|
|
288
|
-
|
|
289
|
-
renderTeamPanelBody();
|
|
290
|
-
}
|
|
291
270
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
empty.className = "team-empty-state";
|
|
296
|
-
empty.innerHTML =
|
|
297
|
-
'<p>No active team</p>' +
|
|
298
|
-
'<p class="team-empty-hint">Start a session with Agent Teams enabled to see live activity here.</p>';
|
|
299
|
-
listEl.appendChild(empty);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
renderMembersSection(listEl, currentTeam.members, currentTeam._memberStatuses, currentTeam._memberActivities);
|
|
304
|
-
|
|
305
|
-
var d1 = document.createElement("hr");
|
|
306
|
-
d1.className = "mobile-sheet-divider";
|
|
307
|
-
listEl.appendChild(d1);
|
|
308
|
-
|
|
309
|
-
renderTasksSection(listEl, currentTeam.tasks);
|
|
310
|
-
|
|
311
|
-
var d2 = document.createElement("hr");
|
|
312
|
-
d2.className = "mobile-sheet-divider";
|
|
313
|
-
listEl.appendChild(d2);
|
|
314
|
-
|
|
315
|
-
renderMessagesSection(listEl, teamMessages);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export function toggleTeamPanel() {
|
|
319
|
-
var panel = document.getElementById("team-panel");
|
|
320
|
-
if (!panel) return;
|
|
321
|
-
panelOpen = !panelOpen;
|
|
322
|
-
if (panelOpen) {
|
|
323
|
-
panel.classList.remove("hidden");
|
|
324
|
-
renderTeamPanelBody();
|
|
325
|
-
} else {
|
|
326
|
-
panel.classList.add("hidden");
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export function hasActiveTeam() {
|
|
331
|
-
return !!currentTeam;
|
|
271
|
+
refreshTeamView();
|
|
272
|
+
// A view team_state opened goes away with the team; one the user opened stays.
|
|
273
|
+
closeTeamViewIfAutoOpened();
|
|
332
274
|
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// team-view.js - The Team view: a registry of sections plus the desktop view
|
|
2
|
+
// that hosts them. A section registers an id, a title, a render(container)
|
|
3
|
+
// and an optional isAvailable(). Sections know nothing about each other, so
|
|
4
|
+
// adding one touches no existing section. The desktop view (#team-view) and
|
|
5
|
+
// the mobile Team tab both draw through renderTeamSections().
|
|
6
|
+
|
|
7
|
+
import { refreshIcons } from './icons.js';
|
|
8
|
+
import { isMobileViewport } from './popover-position.js';
|
|
9
|
+
|
|
10
|
+
// Registration order is display order.
|
|
11
|
+
var sections = [];
|
|
12
|
+
var selectedId = null;
|
|
13
|
+
|
|
14
|
+
var viewEl = null;
|
|
15
|
+
var bodyEl = null;
|
|
16
|
+
var openedAutomatically = false;
|
|
17
|
+
|
|
18
|
+
// --- Registry ---
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Register a section. Registering an id that already exists replaces it in
|
|
22
|
+
* place, so a module that is loaded twice does not list itself twice.
|
|
23
|
+
*
|
|
24
|
+
* @param {{id: string, title: string, render: function(HTMLElement): void,
|
|
25
|
+
* isAvailable?: function(): boolean}} section
|
|
26
|
+
*/
|
|
27
|
+
export function registerTeamSection(section) {
|
|
28
|
+
if (!section || typeof section.id !== "string" || !section.id) {
|
|
29
|
+
throw new Error("team section needs a string id");
|
|
30
|
+
}
|
|
31
|
+
if (typeof section.title !== "string" || !section.title) {
|
|
32
|
+
throw new Error("team section " + section.id + " needs a title");
|
|
33
|
+
}
|
|
34
|
+
if (typeof section.render !== "function") {
|
|
35
|
+
throw new Error("team section " + section.id + " needs a render(container) function");
|
|
36
|
+
}
|
|
37
|
+
var entry = {
|
|
38
|
+
id: section.id,
|
|
39
|
+
title: section.title,
|
|
40
|
+
render: section.render,
|
|
41
|
+
isAvailable: typeof section.isAvailable === "function" ? section.isAvailable : null,
|
|
42
|
+
};
|
|
43
|
+
for (var i = 0; i < sections.length; i++) {
|
|
44
|
+
if (sections[i].id === entry.id) {
|
|
45
|
+
sections[i] = entry;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
sections.push(entry);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function unregisterTeamSection(id) {
|
|
53
|
+
sections = sections.filter(function (s) { return s.id !== id; });
|
|
54
|
+
if (selectedId === id) selectedId = null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Sections that have something to show right now, in registration order. */
|
|
58
|
+
export function listTeamSections() {
|
|
59
|
+
return sections.filter(function (s) { return !s.isAvailable || s.isAvailable(); });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --- Rendering (shared by desktop and mobile) ---
|
|
63
|
+
|
|
64
|
+
function buildEmptyState() {
|
|
65
|
+
var empty = document.createElement("div");
|
|
66
|
+
empty.className = "team-empty-state";
|
|
67
|
+
|
|
68
|
+
var title = document.createElement("p");
|
|
69
|
+
title.textContent = "Nothing active";
|
|
70
|
+
empty.appendChild(title);
|
|
71
|
+
|
|
72
|
+
var hint = document.createElement("p");
|
|
73
|
+
hint.className = "team-empty-hint";
|
|
74
|
+
hint.textContent = "Agent activity appears here while it is running. Start a session with Agent Teams enabled to see live team activity.";
|
|
75
|
+
empty.appendChild(hint);
|
|
76
|
+
|
|
77
|
+
return empty;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function buildTabs(available, active, onSelect) {
|
|
81
|
+
var tabs = document.createElement("div");
|
|
82
|
+
tabs.className = "team-view-tabs";
|
|
83
|
+
tabs.setAttribute("role", "tablist");
|
|
84
|
+
|
|
85
|
+
available.forEach(function (s) {
|
|
86
|
+
var tab = document.createElement("button");
|
|
87
|
+
tab.className = "team-view-tab" + (s === active ? " active" : "");
|
|
88
|
+
tab.setAttribute("role", "tab");
|
|
89
|
+
tab.setAttribute("data-section-id", s.id);
|
|
90
|
+
tab.textContent = s.title;
|
|
91
|
+
tab.addEventListener("click", function () { onSelect(s.id); });
|
|
92
|
+
tabs.appendChild(tab);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return tabs;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Draw the available sections into container: a tab strip when there is more
|
|
100
|
+
* than one, the selected section's content, or the empty state when none is
|
|
101
|
+
* available. Replaces whatever the container held.
|
|
102
|
+
*/
|
|
103
|
+
export function renderTeamSections(container) {
|
|
104
|
+
container.innerHTML = "";
|
|
105
|
+
|
|
106
|
+
var available = listTeamSections();
|
|
107
|
+
if (available.length === 0) {
|
|
108
|
+
container.appendChild(buildEmptyState());
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
var active = available[0];
|
|
113
|
+
for (var i = 0; i < available.length; i++) {
|
|
114
|
+
if (available[i].id === selectedId) { active = available[i]; break; }
|
|
115
|
+
}
|
|
116
|
+
selectedId = active.id;
|
|
117
|
+
|
|
118
|
+
if (available.length > 1) {
|
|
119
|
+
container.appendChild(buildTabs(available, active, function (id) {
|
|
120
|
+
selectedId = id;
|
|
121
|
+
renderTeamSections(container);
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var content = document.createElement("div");
|
|
126
|
+
content.className = "team-view-section";
|
|
127
|
+
content.setAttribute("data-section-id", active.id);
|
|
128
|
+
active.render(content);
|
|
129
|
+
container.appendChild(content);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// --- Desktop view ---
|
|
133
|
+
|
|
134
|
+
export function initTeamView() {
|
|
135
|
+
viewEl = document.getElementById("team-view");
|
|
136
|
+
bodyEl = document.getElementById("team-view-body");
|
|
137
|
+
if (!viewEl) return;
|
|
138
|
+
|
|
139
|
+
var closeBtn = document.getElementById("team-view-close");
|
|
140
|
+
if (closeBtn) closeBtn.addEventListener("click", closeTeamView);
|
|
141
|
+
|
|
142
|
+
document.addEventListener("keydown", function (e) {
|
|
143
|
+
if (e.key === "Escape" && isTeamViewOpen()) closeTeamView();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function isTeamViewOpen() {
|
|
148
|
+
return !!viewEl && !viewEl.classList.contains("hidden");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function setTeamButtonActive(on) {
|
|
152
|
+
var btn = document.getElementById("icon-strip-team-btn");
|
|
153
|
+
if (!btn) return;
|
|
154
|
+
if (on) btn.classList.add("active");
|
|
155
|
+
else btn.classList.remove("active");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Open the view. A no-op on a phone viewport, where the Team tab is the entry.
|
|
160
|
+
* opts.auto marks an open the client made on its own (a section announcing
|
|
161
|
+
* live activity); a view the user already had open stays the user's.
|
|
162
|
+
*/
|
|
163
|
+
export function openTeamView(opts) {
|
|
164
|
+
if (!viewEl || !bodyEl || isMobileViewport()) return;
|
|
165
|
+
if (!isTeamViewOpen()) openedAutomatically = !!(opts && opts.auto);
|
|
166
|
+
viewEl.classList.remove("hidden");
|
|
167
|
+
setTeamButtonActive(true);
|
|
168
|
+
renderTeamSections(bodyEl);
|
|
169
|
+
refreshIcons();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function closeTeamView() {
|
|
173
|
+
if (!viewEl) return;
|
|
174
|
+
viewEl.classList.add("hidden");
|
|
175
|
+
openedAutomatically = false;
|
|
176
|
+
setTeamButtonActive(false);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Close the view only when the client opened it on its own, so the chat comes
|
|
181
|
+
* back when the activity that opened it ends. A view the user opened stays.
|
|
182
|
+
*/
|
|
183
|
+
export function closeTeamViewIfAutoOpened() {
|
|
184
|
+
if (openedAutomatically) closeTeamView();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function toggleTeamView() {
|
|
188
|
+
if (isTeamViewOpen()) closeTeamView();
|
|
189
|
+
else openTeamView();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Whether a container a section drew into is still on screen: the registry has
|
|
194
|
+
* no close hook, so a section that updates itself later asks this first. False
|
|
195
|
+
* once the container was detached (a tab switch or re-render) or sits inside a
|
|
196
|
+
* hidden view.
|
|
197
|
+
*/
|
|
198
|
+
export function isSectionContainerShown(container) {
|
|
199
|
+
if (!container) return false;
|
|
200
|
+
if (container.isConnected === false) return false;
|
|
201
|
+
for (var node = container; node; node = node.parentNode) {
|
|
202
|
+
if (node.classList && node.classList.contains("hidden")) return false;
|
|
203
|
+
}
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Re-render in place after a section's data changed; a no-op while closed. */
|
|
208
|
+
export function refreshTeamView() {
|
|
209
|
+
if (!isTeamViewOpen()) return;
|
|
210
|
+
renderTeamSections(bodyEl);
|
|
211
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Link detection for the console terminal, kept free of DOM and app imports so
|
|
2
|
+
// it can be unit-tested against a fake xterm buffer.
|
|
3
|
+
//
|
|
4
|
+
// xterm's WebLinksAddon only sees one row. This provider rebuilds "logical
|
|
5
|
+
// lines" and detects URLs that span rows in two cases:
|
|
6
|
+
// 1. soft wrap: xterm marked the continuation row isWrapped.
|
|
7
|
+
// 2. hard wrap: a program printed the URL itself across rows, so xterm did
|
|
8
|
+
// not mark isWrapped. Joined only when the row is full to the last column
|
|
9
|
+
// and ends inside a URL, and the next row is nothing but URL text: one
|
|
10
|
+
// whitespace-free token, with only padding after it.
|
|
11
|
+
//
|
|
12
|
+
// Remaining ambiguity: a real newline right after a URL that ends exactly at
|
|
13
|
+
// the last column, followed by a single-token line (for example "Done"), looks
|
|
14
|
+
// the same as a hard wrap and is joined. A following line with more than one
|
|
15
|
+
// word is never joined.
|
|
16
|
+
|
|
17
|
+
var URL_CHAR_CLASS = "[^\\s'\"\\]>)}{]";
|
|
18
|
+
var URL_RE_SOURCE = "https?:\\/\\/" + URL_CHAR_CLASS + "+";
|
|
19
|
+
var URL_AT_ROW_END_RE = new RegExp(URL_RE_SOURCE + "$");
|
|
20
|
+
var URL_CONTINUATION_RE = new RegExp("^" + URL_CHAR_CLASS + "+$");
|
|
21
|
+
|
|
22
|
+
function rowText(buffer, y, trimRight) {
|
|
23
|
+
var line = buffer.getLine(y);
|
|
24
|
+
return line ? line.translateToString(trimRight) : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A URL longer than this many rows is cut here: joining stops and the row past
|
|
28
|
+
// the bound is treated as not continued. Far above any sign-in URL, and it
|
|
29
|
+
// keeps every lookup linear in a fixed window instead of in buffer length.
|
|
30
|
+
export var MAX_LINK_ROWS = 64;
|
|
31
|
+
|
|
32
|
+
// Row y fills to the last column and row y+1 is URL text alone, not marked as
|
|
33
|
+
// a soft-wrapped row. Looks at two rows only.
|
|
34
|
+
function hardWrapCandidate(buffer, y, cols) {
|
|
35
|
+
var next = buffer.getLine(y + 1);
|
|
36
|
+
if (!next || next.isWrapped) return false;
|
|
37
|
+
var text = rowText(buffer, y, false);
|
|
38
|
+
if (text === null || text.length < cols) return false;
|
|
39
|
+
var nextText = rowText(buffer, y + 1, true);
|
|
40
|
+
return nextText !== null && URL_CONTINUATION_RE.test(nextText);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// hard[i] is true when row lo+i continues onto the next row by a hard wrap.
|
|
44
|
+
// One forward pass: a row qualifies when it ends in a URL, or when it is one
|
|
45
|
+
// full-width token continuing a hard wrap from the row above. The row before
|
|
46
|
+
// lo is assumed not to continue, which is the cut at the bound.
|
|
47
|
+
function hardWrapFlags(buffer, lo, hi, cols) {
|
|
48
|
+
var flags = [];
|
|
49
|
+
var prev = false;
|
|
50
|
+
for (var y = lo; y <= hi; y++) {
|
|
51
|
+
var flag = false;
|
|
52
|
+
if (hardWrapCandidate(buffer, y, cols)) {
|
|
53
|
+
var text = rowText(buffer, y, false);
|
|
54
|
+
var token = text.match(/\S+$/);
|
|
55
|
+
flag = !!token && (URL_AT_ROW_END_RE.test(text) || (token[0].length === cols && prev));
|
|
56
|
+
}
|
|
57
|
+
flags.push(flag);
|
|
58
|
+
prev = flag;
|
|
59
|
+
}
|
|
60
|
+
return flags;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getLogicalLine(buffer, y, cols) {
|
|
64
|
+
var lo = Math.max(0, y - MAX_LINK_ROWS);
|
|
65
|
+
var hi = Math.min(buffer.length - 1, y + MAX_LINK_ROWS);
|
|
66
|
+
var hard = hardWrapFlags(buffer, lo, hi, cols);
|
|
67
|
+
|
|
68
|
+
var startY = y;
|
|
69
|
+
while (startY > lo && y - startY < MAX_LINK_ROWS - 1) {
|
|
70
|
+
var line = buffer.getLine(startY);
|
|
71
|
+
if (!line) break;
|
|
72
|
+
if (!line.isWrapped && !hard[startY - 1 - lo]) break;
|
|
73
|
+
startY--;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var endY = startY;
|
|
77
|
+
while (endY < hi && endY - startY < MAX_LINK_ROWS - 1) {
|
|
78
|
+
var next = buffer.getLine(endY + 1);
|
|
79
|
+
if (!next || !(next.isWrapped || hard[endY - lo])) break;
|
|
80
|
+
endY++;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var text = "";
|
|
84
|
+
var rowOffsets = []; // { y, startOffset, length }
|
|
85
|
+
for (var row = startY; row <= endY; row++) {
|
|
86
|
+
var t = rowText(buffer, row, row === endY); // trim trailing spaces on the last row only
|
|
87
|
+
if (t === null) break;
|
|
88
|
+
rowOffsets.push({ y: row, startOffset: text.length, length: t.length });
|
|
89
|
+
text += t;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { text: text, startY: startY, endY: endY, rowOffsets: rowOffsets };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function offsetToBufferPos(rowOffsets, offset) {
|
|
96
|
+
for (var i = 0; i < rowOffsets.length; i++) {
|
|
97
|
+
var ro = rowOffsets[i];
|
|
98
|
+
if (offset < ro.startOffset + ro.length) {
|
|
99
|
+
return { x: offset - ro.startOffset + 1, y: ro.y + 1 }; // 1-based
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var last = rowOffsets[rowOffsets.length - 1];
|
|
103
|
+
return { x: last.length + 1, y: last.y + 1 };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Every URL in the logical line that crosses a row boundary.
|
|
107
|
+
function findMultiRowUrls(logical) {
|
|
108
|
+
var re = new RegExp(URL_RE_SOURCE, "g");
|
|
109
|
+
var found = [];
|
|
110
|
+
var match;
|
|
111
|
+
while ((match = re.exec(logical.text)) !== null) {
|
|
112
|
+
var start = offsetToBufferPos(logical.rowOffsets, match.index);
|
|
113
|
+
var end = offsetToBufferPos(logical.rowOffsets, match.index + match[0].length - 1);
|
|
114
|
+
if (start.y !== end.y) found.push({ url: match[0], start: start, end: end });
|
|
115
|
+
}
|
|
116
|
+
return found;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// The last maxRows rows of the buffer as logical lines: soft-wrapped and
|
|
120
|
+
// hard-wrapped rows are joined exactly as the link provider joins them, so a
|
|
121
|
+
// URL a program broke across rows reads as one token. Used to read a login
|
|
122
|
+
// terminal's output; the join rules are the provider's own.
|
|
123
|
+
export function bufferLogicalLines(buffer, cols, maxRows) {
|
|
124
|
+
var first = Math.max(0, buffer.length - (maxRows || 200));
|
|
125
|
+
var lines = [];
|
|
126
|
+
var y = first;
|
|
127
|
+
while (y < buffer.length) {
|
|
128
|
+
var logical = getLogicalLine(buffer, y, cols);
|
|
129
|
+
// A logical line that began above the window is read from its start, so
|
|
130
|
+
// its head is never dropped.
|
|
131
|
+
lines.push(logical.text);
|
|
132
|
+
y = Math.max(logical.endY, y) + 1;
|
|
133
|
+
}
|
|
134
|
+
return lines;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// opts.onHover(url) / opts.onLeave() let the owner remember the link under
|
|
138
|
+
// the pointer, for a copy-link action.
|
|
139
|
+
export function createMultiLineLinkProvider(xterm, opts) {
|
|
140
|
+
opts = opts || {};
|
|
141
|
+
return {
|
|
142
|
+
provideLinks: function (y, callback) {
|
|
143
|
+
var buffer = xterm.buffer.active;
|
|
144
|
+
var bufferY = y - 1; // provideLinks is 1-based
|
|
145
|
+
var logical = getLogicalLine(buffer, bufferY, xterm.cols);
|
|
146
|
+
|
|
147
|
+
if (logical.startY === logical.endY || bufferY !== logical.startY) {
|
|
148
|
+
callback(undefined);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var links = findMultiRowUrls(logical).map(function (hit) {
|
|
153
|
+
return {
|
|
154
|
+
range: { start: hit.start, end: hit.end },
|
|
155
|
+
text: hit.url,
|
|
156
|
+
activate: function () {
|
|
157
|
+
window.open(hit.url, "_blank", "noopener");
|
|
158
|
+
},
|
|
159
|
+
hover: function () {
|
|
160
|
+
if (opts.onHover) opts.onHover(hit.url);
|
|
161
|
+
},
|
|
162
|
+
leave: function () {
|
|
163
|
+
if (opts.onLeave) opts.onLeave();
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
callback(links.length > 0 ? links : undefined);
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// getSelection() joins rows with a newline. When the whole selection sits
|
|
174
|
+
// inside one multi-row URL, return the selected part of the URL with the row
|
|
175
|
+
// breaks removed; otherwise return the selection unchanged.
|
|
176
|
+
export function copyTextForSelection(xterm, selection) {
|
|
177
|
+
if (!selection || !/[\r\n]/.test(selection)) return selection;
|
|
178
|
+
var pos = xterm.getSelectionPosition && xterm.getSelectionPosition();
|
|
179
|
+
if (!pos) return selection;
|
|
180
|
+
var buffer = xterm.buffer.active;
|
|
181
|
+
var logical = getLogicalLine(buffer, pos.start.y, xterm.cols);
|
|
182
|
+
if (logical.endY < pos.end.y) return selection;
|
|
183
|
+
var joined = selection.replace(/[\r\n]+/g, "");
|
|
184
|
+
var urls = findMultiRowUrls(logical);
|
|
185
|
+
for (var i = 0; i < urls.length; i++) {
|
|
186
|
+
var hit = urls[i];
|
|
187
|
+
if (pos.start.y >= hit.start.y - 1 && pos.end.y <= hit.end.y - 1 &&
|
|
188
|
+
hit.url.indexOf(joined) !== -1) {
|
|
189
|
+
return joined;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return selection;
|
|
193
|
+
}
|