@clagentic/console 1.12.0-beta.2 → 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/bin/cli.js +4 -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-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +3 -4
- package/lib/build-update-standing.js +34 -14
- package/lib/cli/session-subcommands.js +26 -8
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +25 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +16 -22
- package/lib/notify/core.js +53 -18
- package/lib/notify/payload.js +2 -3
- package/lib/notify/type-registry.js +17 -0
- package/lib/notify/types.js +38 -1
- package/lib/outbound-access.js +12 -1
- package/lib/outbound-entry.js +8 -1
- package/lib/project-connection.js +9 -8
- package/lib/project-filesystem.js +23 -0
- package/lib/project-loop.js +16 -19
- package/lib/project-notifications.js +68 -7
- package/lib/project-sessions.js +9 -0
- 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 +26 -4
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +24 -1
- package/lib/prompt-source.js +16 -0
- package/lib/public/app.js +31 -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 +1 -1
- 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/sidebar.css +11 -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 +41 -7
- 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 +12 -0
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +59 -29
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +22 -7
- 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 +52 -55
- 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 +114 -21
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- 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 +47 -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 +18 -0
- package/lib/public/modules/terminal.js +65 -4
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +35 -83
- package/lib/public/notify-target.js +70 -10
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +7 -3
- package/lib/queued-chat.js +392 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +122 -43
- package/lib/sdk-message-processor.js +46 -39
- 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 +83 -19
- package/lib/session-directory.js +33 -8
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +26 -0
- package/lib/session-input.js +176 -9
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +49 -5
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +7 -0
- package/lib/user-shell-settings.js +105 -0
- package/lib/ws-schema.js +27 -4
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +6 -0
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +218 -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/codex-app-server.js +8 -2
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/registry.js +32 -0
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +1 -1
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Reads a vendor login's terminal output for the sign-in URL and the code
|
|
2
|
+
// step. Pure: no DOM, no app imports. The patterns are declared per vendor
|
|
3
|
+
// beside its login command (the registry's loginPatterns) as regular
|
|
4
|
+
// expression sources; nothing here names a vendor.
|
|
5
|
+
|
|
6
|
+
function compile(source) {
|
|
7
|
+
if (typeof source !== "string" || !source) return null;
|
|
8
|
+
try {
|
|
9
|
+
return new RegExp(source);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {?{url: string, codePrompt?: string, userCode?: string}} patterns
|
|
17
|
+
* @returns {?{url: RegExp, codePrompt: ?RegExp, userCode: ?RegExp}} null when
|
|
18
|
+
* the vendor declares no usable URL pattern (it then shows no panel)
|
|
19
|
+
*/
|
|
20
|
+
export function compileLoginPatterns(patterns) {
|
|
21
|
+
if (!patterns) return null;
|
|
22
|
+
var url = compile(patterns.url);
|
|
23
|
+
if (!url) return null;
|
|
24
|
+
return { url: url, codePrompt: compile(patterns.codePrompt), userCode: compile(patterns.userCode) };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// A sign-in URL is opened from the panel, so only a web URL is accepted
|
|
28
|
+
// whatever a pattern matched.
|
|
29
|
+
function isWebUrl(text) {
|
|
30
|
+
return /^https?:\/\/[^\s]+$/.test(text);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {string[]} lines logical lines, hard-wrapped URLs already joined
|
|
35
|
+
* @param {?object} compiled compileLoginPatterns result
|
|
36
|
+
* @returns {?{url: string, codePrompt: boolean, userCode: string}} null when
|
|
37
|
+
* no sign-in URL is present. The newest URL wins, so a retried login shows
|
|
38
|
+
* its current link.
|
|
39
|
+
*/
|
|
40
|
+
export function parseLoginLines(lines, compiled) {
|
|
41
|
+
if (!compiled || !Array.isArray(lines)) return null;
|
|
42
|
+
var url = "";
|
|
43
|
+
var urlLine = -1;
|
|
44
|
+
for (var i = lines.length - 1; i >= 0 && !url; i--) {
|
|
45
|
+
var hit = compiled.url.exec(lines[i]);
|
|
46
|
+
if (hit && isWebUrl(hit[0])) { url = hit[0]; urlLine = i; }
|
|
47
|
+
}
|
|
48
|
+
if (!url) return null;
|
|
49
|
+
|
|
50
|
+
// The code and the prompt follow their URL on screen, so reading from the
|
|
51
|
+
// newest URL on keeps a retried link from pairing with an older attempt's
|
|
52
|
+
// dead code.
|
|
53
|
+
var text = lines.slice(urlLine).join("\n");
|
|
54
|
+
var userCode = "";
|
|
55
|
+
if (compiled.userCode) {
|
|
56
|
+
var codeHit = compiled.userCode.exec(text);
|
|
57
|
+
if (codeHit && codeHit[1]) userCode = codeHit[1];
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
url: url,
|
|
61
|
+
codePrompt: !!compiled.codePrompt && compiled.codePrompt.test(text),
|
|
62
|
+
userCode: userCode,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The host of a URL for display, "" when it does not parse. Never the query. */
|
|
67
|
+
export function displayHost(url) {
|
|
68
|
+
try {
|
|
69
|
+
return new URL(url).host;
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Ties one login terminal to its sign-in panel. Only the terminal marked as a
|
|
2
|
+
// login tab gets one of these, so no other terminal's output is ever read for
|
|
3
|
+
// a URL or code. Parsing is client-side over the terminal's own buffer; the
|
|
4
|
+
// server sees nothing but the code the user types, through the same terminal
|
|
5
|
+
// input message as every other keystroke.
|
|
6
|
+
|
|
7
|
+
import { bufferLogicalLines } from './terminal-links.js';
|
|
8
|
+
import { compileLoginPatterns, parseLoginLines } from './login-parser.js';
|
|
9
|
+
import { createLoginPanel } from './login-panel.js';
|
|
10
|
+
|
|
11
|
+
// Rows of recent output read per update; a sign-in screen is a few lines.
|
|
12
|
+
var SCAN_ROWS = 200;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {object} opts
|
|
16
|
+
* @param {object} opts.patterns the vendor's loginPatterns (or null)
|
|
17
|
+
* @param {string} opts.vendorName
|
|
18
|
+
* @param {string} opts.identity "os-users", "shared" or ""
|
|
19
|
+
* @param {function(string):void} opts.sendCode types into this terminal only
|
|
20
|
+
* @param {function(object):void} opts.mount puts the panel element in the page
|
|
21
|
+
* @param {function(string):void} opts.copy
|
|
22
|
+
* @param {function(string):void} opts.openLink
|
|
23
|
+
* @returns {{feed: function, setActive: function, close: function}}
|
|
24
|
+
*/
|
|
25
|
+
export function createLoginTab(opts) {
|
|
26
|
+
var compiled = compileLoginPatterns(opts.patterns);
|
|
27
|
+
var panel = null;
|
|
28
|
+
var dismissed = false;
|
|
29
|
+
var active = true;
|
|
30
|
+
|
|
31
|
+
function ensurePanel() {
|
|
32
|
+
if (panel || dismissed) return panel;
|
|
33
|
+
panel = createLoginPanel({
|
|
34
|
+
vendorName: opts.vendorName,
|
|
35
|
+
identity: opts.identity,
|
|
36
|
+
sendCode: opts.sendCode,
|
|
37
|
+
copy: opts.copy,
|
|
38
|
+
openLink: opts.openLink,
|
|
39
|
+
onDismiss: function () { dismissed = true; panel = null; },
|
|
40
|
+
});
|
|
41
|
+
opts.mount(panel.element);
|
|
42
|
+
panel.setHidden(!active);
|
|
43
|
+
return panel;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
/** Call after output was written to the terminal. */
|
|
48
|
+
feed: function (xterm) {
|
|
49
|
+
if (!compiled || dismissed || !xterm || !xterm.buffer) return;
|
|
50
|
+
var lines = bufferLogicalLines(xterm.buffer.active, xterm.cols, SCAN_ROWS);
|
|
51
|
+
var parsed = parseLoginLines(lines, compiled);
|
|
52
|
+
if (!parsed) return;
|
|
53
|
+
ensurePanel().update(parsed);
|
|
54
|
+
},
|
|
55
|
+
setActive: function (isActive) {
|
|
56
|
+
active = !!isActive;
|
|
57
|
+
if (panel) panel.setHidden(!active);
|
|
58
|
+
},
|
|
59
|
+
/** The terminal exited or closed: drop the panel and everything it held. */
|
|
60
|
+
close: function () {
|
|
61
|
+
if (panel) panel.remove();
|
|
62
|
+
panel = null;
|
|
63
|
+
dismissed = true;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { copyToClipboard, showToast } from './utils.js';
|
|
2
2
|
import { iconHtml, refreshIcons } from './icons.js';
|
|
3
|
+
import { store } from './store.js';
|
|
4
|
+
import { routeTo } from './notify-client.js';
|
|
3
5
|
|
|
4
6
|
var ctx;
|
|
5
7
|
var basePath = "/";
|
|
@@ -50,14 +52,20 @@ export function showDoneNotification() {
|
|
|
50
52
|
else sessionTitle = activeItem.textContent || "Claude";
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
// The same target and tag the server's push for this turn carries (the
|
|
56
|
+
// response_done type collapses per session), so the page's notification and
|
|
57
|
+
// the push replace each other instead of showing twice, and a tap routes to
|
|
58
|
+
// the session through the one router.
|
|
59
|
+
var target = { slug: store.get('currentSlug'), sessionId: store.get('activeSessionId') };
|
|
53
60
|
var n = new Notification(sessionTitle, {
|
|
54
61
|
body: preview,
|
|
55
|
-
tag: "
|
|
62
|
+
tag: globalThis.NotifyTarget.tagFor("response_done", "session", target),
|
|
56
63
|
});
|
|
57
64
|
|
|
58
65
|
n.onclick = function() {
|
|
59
66
|
window.focus();
|
|
60
67
|
n.close();
|
|
68
|
+
routeTo(target);
|
|
61
69
|
};
|
|
62
70
|
|
|
63
71
|
setTimeout(function() { n.close(); }, 5000);
|
|
@@ -6,9 +6,12 @@ import '../notify-sw-logic.js';
|
|
|
6
6
|
import { store } from './store.js';
|
|
7
7
|
import { getWs } from './ws-ref.js';
|
|
8
8
|
import { switchProject } from './app-projects.js';
|
|
9
|
+
import { openDm } from './app-dm.js';
|
|
9
10
|
|
|
10
11
|
var Target = globalThis.NotifyTarget;
|
|
11
12
|
var PENDING_KEY = 'pending-notif-session';
|
|
13
|
+
var PENDING_PEER_KEY = 'pending-notif-dm';
|
|
14
|
+
var PENDING_PLACE_KEY = 'pending-notif-place';
|
|
12
15
|
|
|
13
16
|
export var urlForTarget = Target.urlForTarget;
|
|
14
17
|
|
|
@@ -22,41 +25,107 @@ var pendingSession = null;
|
|
|
22
25
|
// True while the deep link's query is still on the URL as the only durable
|
|
23
26
|
// copy of the target (sessionStorage refused it).
|
|
24
27
|
var queryHoldsTarget = false;
|
|
28
|
+
// The person whose conversation a route is waiting to open once connected.
|
|
29
|
+
// Held like the session: in memory, and in sessionStorage so a reload or a
|
|
30
|
+
// suspension before the connection is up keeps the destination.
|
|
31
|
+
var pendingPeer = null;
|
|
32
|
+
// True while the deep link's ?dm= is still on the URL as the only durable copy.
|
|
33
|
+
var peerQueryHoldsTarget = false;
|
|
34
|
+
// The system notification type a cold-start tap named (?notify=<type>), held
|
|
35
|
+
// like the peer so a reload before the connection keeps the destination.
|
|
36
|
+
var pendingPlace = null;
|
|
37
|
+
var placeQueryHoldsTarget = false;
|
|
25
38
|
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
// The places a system notification's action lives, by type: a system target
|
|
40
|
+
// names no project or session, so the type says where it opens. Registered by
|
|
41
|
+
// the module that owns the place; the router and the service worker carry no
|
|
42
|
+
// per-type branch.
|
|
43
|
+
var places = Object.create(null);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} type a notification type.
|
|
47
|
+
* @param {function(object): void} open opens the place; given the target.
|
|
48
|
+
*/
|
|
49
|
+
export function registerPlace(type, open) {
|
|
50
|
+
places[type] = open;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The system notification type whose place a cold-start tap is waiting to open,
|
|
55
|
+
* or null; taking it ends the wait (and the query, if it was the only copy).
|
|
56
|
+
* @returns {?string}
|
|
57
|
+
*/
|
|
58
|
+
export function takePendingPlace() {
|
|
59
|
+
var type = pendingPlace !== null ? pendingPlace : readStored(PENDING_PLACE_KEY);
|
|
60
|
+
pendingPlace = null;
|
|
61
|
+
clearStored(PENDING_PLACE_KEY);
|
|
62
|
+
if (placeQueryHoldsTarget) {
|
|
63
|
+
placeQueryHoldsTarget = false;
|
|
64
|
+
stripQuery(['notify']);
|
|
65
|
+
}
|
|
66
|
+
return type;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The conversation a route is waiting to open, or null; taking it ends the wait
|
|
71
|
+
* (and with it the deep link's query, if that was the target's only copy).
|
|
72
|
+
* @returns {?string} the other person's user id.
|
|
73
|
+
*/
|
|
74
|
+
export function takePendingPeer() {
|
|
75
|
+
var peer = pendingPeer !== null ? pendingPeer : readStored(PENDING_PEER_KEY);
|
|
76
|
+
pendingPeer = null;
|
|
77
|
+
clearStored(PENDING_PEER_KEY);
|
|
78
|
+
if (peerQueryHoldsTarget) {
|
|
79
|
+
peerQueryHoldsTarget = false;
|
|
80
|
+
stripQuery(['dm']);
|
|
81
|
+
}
|
|
82
|
+
return peer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Returns whether sessionStorage took the target; the in-memory copy is kept
|
|
86
|
+
// either way.
|
|
87
|
+
function rememberPendingPeer(peer) {
|
|
88
|
+
pendingPeer = String(peer);
|
|
89
|
+
return storeValue(PENDING_PEER_KEY, pendingPeer);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function storeValue(key, value) {
|
|
30
93
|
try {
|
|
31
|
-
sessionStorage.setItem(
|
|
94
|
+
sessionStorage.setItem(key, value);
|
|
32
95
|
return true;
|
|
33
96
|
} catch (e) {
|
|
34
|
-
console.debug('[notify] could not store
|
|
97
|
+
console.debug('[notify] could not store ' + key + ':', e && e.message ? e.message : e);
|
|
35
98
|
return false;
|
|
36
99
|
}
|
|
37
100
|
}
|
|
38
101
|
|
|
39
|
-
function
|
|
102
|
+
function readStored(key) {
|
|
40
103
|
try {
|
|
41
|
-
return sessionStorage.getItem(
|
|
104
|
+
return sessionStorage.getItem(key);
|
|
42
105
|
} catch (e) {
|
|
43
|
-
console.debug('[notify] could not read
|
|
106
|
+
console.debug('[notify] could not read ' + key + ':', e && e.message ? e.message : e);
|
|
44
107
|
return null;
|
|
45
108
|
}
|
|
46
109
|
}
|
|
47
110
|
|
|
48
|
-
function
|
|
111
|
+
function clearStored(key) {
|
|
49
112
|
try {
|
|
50
|
-
sessionStorage.removeItem(
|
|
113
|
+
sessionStorage.removeItem(key);
|
|
51
114
|
} catch (e) {
|
|
52
|
-
console.debug('[notify] could not clear
|
|
115
|
+
console.debug('[notify] could not clear ' + key + ':', e && e.message ? e.message : e);
|
|
53
116
|
}
|
|
54
117
|
}
|
|
55
118
|
|
|
56
|
-
|
|
119
|
+
// Returns whether sessionStorage took the target. The in-memory copy is always
|
|
120
|
+
// kept, so a caller that sees false still has the route.
|
|
121
|
+
function rememberPendingSession(id) {
|
|
122
|
+
pendingSession = String(id);
|
|
123
|
+
return storeValue(PENDING_KEY, pendingSession);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function stripQuery(keys) {
|
|
57
127
|
var params = new URLSearchParams(location.search);
|
|
58
|
-
params.delete(
|
|
59
|
-
params.delete('request');
|
|
128
|
+
keys.forEach(function (k) { params.delete(k); });
|
|
60
129
|
var rest = params.toString();
|
|
61
130
|
history.replaceState(null, '', location.pathname + (rest ? '?' + rest : '') + location.hash);
|
|
62
131
|
}
|
|
@@ -68,12 +137,12 @@ function stripDeepLinkQuery() {
|
|
|
68
137
|
* @returns {?number}
|
|
69
138
|
*/
|
|
70
139
|
export function takePendingSession() {
|
|
71
|
-
var raw = pendingSession !== null ? pendingSession :
|
|
140
|
+
var raw = pendingSession !== null ? pendingSession : readStored(PENDING_KEY);
|
|
72
141
|
pendingSession = null;
|
|
73
|
-
|
|
142
|
+
clearStored(PENDING_KEY);
|
|
74
143
|
if (queryHoldsTarget) {
|
|
75
144
|
queryHoldsTarget = false;
|
|
76
|
-
|
|
145
|
+
stripQuery(['session', 'request']);
|
|
77
146
|
}
|
|
78
147
|
return raw === null ? null : parseId(raw);
|
|
79
148
|
}
|
|
@@ -88,9 +157,22 @@ function parseId(id) {
|
|
|
88
157
|
// through the pending key once that project's connection is up; the same
|
|
89
158
|
// project switches at once when its connection is open, else the same key
|
|
90
159
|
// carries it.
|
|
91
|
-
export function routeTo(target) {
|
|
160
|
+
export function routeTo(target, type) {
|
|
92
161
|
var t = Target.makeTarget(target);
|
|
93
162
|
if (!t) return;
|
|
163
|
+
// A system notification's target names no place: its type does.
|
|
164
|
+
if (!t.peerId && !t.slug && !t.sessionId && type && places[type]) {
|
|
165
|
+
places[type](t);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// A direct message opens the conversation with the other person; before the
|
|
169
|
+
// connection is up it waits for takePendingPeer.
|
|
170
|
+
if (t.peerId) {
|
|
171
|
+
var peerWs = getWs();
|
|
172
|
+
if (peerWs && peerWs.readyState === 1) openDm(t.peerId);
|
|
173
|
+
else rememberPendingPeer(t.peerId);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
94
176
|
var current = store.get('currentSlug') || '';
|
|
95
177
|
var sessionId = parseId(t.sessionId);
|
|
96
178
|
if (t.slug && t.slug !== current) {
|
|
@@ -112,9 +194,20 @@ export function routeTo(target) {
|
|
|
112
194
|
// When sessionStorage refused the target, the query stays until the route has
|
|
113
195
|
// been taken, so a reload still finds it.
|
|
114
196
|
function consumeDeepLink() {
|
|
197
|
+
var peer = Target.parsePeerLink(location.search);
|
|
198
|
+
if (peer) {
|
|
199
|
+
if (rememberPendingPeer(peer)) stripQuery(['dm']);
|
|
200
|
+
else peerQueryHoldsTarget = true;
|
|
201
|
+
}
|
|
202
|
+
var place = Target.parsePlaceLink(location.search);
|
|
203
|
+
if (place) {
|
|
204
|
+
pendingPlace = place;
|
|
205
|
+
if (storeValue(PENDING_PLACE_KEY, place)) stripQuery(['notify']);
|
|
206
|
+
else placeQueryHoldsTarget = true;
|
|
207
|
+
}
|
|
115
208
|
var link = Target.parseDeepLink(location.search);
|
|
116
209
|
if (!link) return;
|
|
117
|
-
if (rememberPendingSession(link.sessionId))
|
|
210
|
+
if (rememberPendingSession(link.sessionId)) stripQuery(['session', 'request']);
|
|
118
211
|
else queryHoldsTarget = true;
|
|
119
212
|
}
|
|
120
213
|
|
|
@@ -146,7 +239,7 @@ export function initNotifyClient() {
|
|
|
146
239
|
consumeDeepLink();
|
|
147
240
|
if (navigator.serviceWorker) {
|
|
148
241
|
navigator.serviceWorker.addEventListener('message', function (event) {
|
|
149
|
-
if (event.data && event.data.type === 'notify_route') routeTo(event.data.target);
|
|
242
|
+
if (event.data && event.data.type === 'notify_route') routeTo(event.data.target, event.data.notifyType);
|
|
150
243
|
});
|
|
151
244
|
}
|
|
152
245
|
document.addEventListener('visibilitychange', reconcile);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Ties a terminal the client asked for to the terminal the server reports
|
|
2
|
+
// back. A command queued for "the next terminal" would otherwise land in
|
|
3
|
+
// whichever terminal is created first, including one somebody else opened in
|
|
4
|
+
// the same window. The request id travels in term_create and returns in
|
|
5
|
+
// term_created; only the matching terminal takes the queued command.
|
|
6
|
+
|
|
7
|
+
var counter = 0;
|
|
8
|
+
|
|
9
|
+
/** @returns {string} a client-unique id for one term_create request */
|
|
10
|
+
export function newTermRequestId() {
|
|
11
|
+
counter += 1;
|
|
12
|
+
return "tq-" + Date.now().toString(36) + "-" + counter;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Takes the queued command and login vendor when this term_created answers the
|
|
17
|
+
* queued request; any other terminal leaves the slot alone.
|
|
18
|
+
* @param {{get: function(string): *, set: function(object)}} store
|
|
19
|
+
* @param {{requestId?: string}} msg the term_created message
|
|
20
|
+
* @returns {?{command: string, vendor: string}} null when nothing is queued or
|
|
21
|
+
* the terminal is not the one requested
|
|
22
|
+
*/
|
|
23
|
+
export function consumePendingTerm(store, msg) {
|
|
24
|
+
var command = store.get("pendingTermCommand");
|
|
25
|
+
var requestId = store.get("pendingTermRequestId");
|
|
26
|
+
if (!command || !requestId || !msg || msg.requestId !== requestId) return null;
|
|
27
|
+
var vendor = store.get("pendingLoginVendor") || "";
|
|
28
|
+
store.set({ pendingTermCommand: null, pendingLoginVendor: "", pendingTermRequestId: "" });
|
|
29
|
+
return { command: command, vendor: vendor };
|
|
30
|
+
}
|
|
@@ -34,6 +34,26 @@ export function customIconSlug(iconStr) {
|
|
|
34
34
|
return iconStr.slice(1, -1); // strip leading and trailing ":"
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The URL a custom-icon slug is served from (the global custom-icon store).
|
|
39
|
+
* Every place that draws a custom icon, project icons and agent avatars alike,
|
|
40
|
+
* builds its URL here.
|
|
41
|
+
* @param {string} slug A slug already validated against CUSTOM_ICON_RE's body.
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
export function customIconUrl(slug) {
|
|
45
|
+
return "/api/custom-emoji/" + encodeURIComponent(slug);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* True when slug is a valid custom-icon slug ([a-z0-9_-]{1,64}).
|
|
50
|
+
* @param {unknown} slug
|
|
51
|
+
* @returns {boolean}
|
|
52
|
+
*/
|
|
53
|
+
export function isCustomIconSlug(slug) {
|
|
54
|
+
return typeof slug === "string" && isCustomIcon(":" + slug + ":");
|
|
55
|
+
}
|
|
56
|
+
|
|
37
57
|
// Minimal HTML-escape for the string-composition path (projectIconHtml).
|
|
38
58
|
// Mirrors escapeHtml() from utils.js without importing it, so this module
|
|
39
59
|
// stays DOM-free / Node-importable (see file header).
|
|
@@ -73,7 +93,7 @@ export function projectIconHtml(iconStr, fallbackHtml) {
|
|
|
73
93
|
// (hide the broken image) since this string-built markup has no JS
|
|
74
94
|
// event-listener wiring of its own. The handler is a fixed literal —
|
|
75
95
|
// nothing from iconStr is interpolated into it.
|
|
76
|
-
return '<img src="
|
|
96
|
+
return '<img src="' + customIconUrl(slug) + '" alt=":' + slug + ':" class="project-emoji-img" onerror="this.style.display='none'">';
|
|
77
97
|
}
|
|
78
98
|
return escapeForHtml(iconStr);
|
|
79
99
|
}
|
|
@@ -100,7 +120,7 @@ export function renderProjectIcon(iconStr, el, parseEmojisFn) {
|
|
|
100
120
|
var slug = customIconSlug(iconStr);
|
|
101
121
|
if (slug) {
|
|
102
122
|
var img = document.createElement("img");
|
|
103
|
-
img.src =
|
|
123
|
+
img.src = customIconUrl(slug);
|
|
104
124
|
img.alt = ":" + slug + ":";
|
|
105
125
|
img.className = "project-emoji-img";
|
|
106
126
|
// Graceful fallback: if the image 404s (deleted-in-use), show nothing
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// queued-button.js - the control on a queued outbox item. Labelled in words and
|
|
2
|
+
// sized like the send button (the styling is on .shell-queued-btn). One place,
|
|
3
|
+
// so every kind of outbox item draws its controls the same way.
|
|
4
|
+
|
|
5
|
+
export function queuedButton(label, cls) {
|
|
6
|
+
var b = document.createElement("button");
|
|
7
|
+
b.className = "shell-queued-btn " + cls;
|
|
8
|
+
b.textContent = label;
|
|
9
|
+
b.setAttribute("aria-label", label);
|
|
10
|
+
return b;
|
|
11
|
+
}
|
|
@@ -4,12 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import { sendWs } from './ws-ref.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// requestId is optional: the server echoes it on its answer to the request, so
|
|
8
|
+
// a caller that waits for the answer (the composer's outbox) can tell which of
|
|
9
|
+
// its requests an answer or an error is for. The schedule panel sends none.
|
|
10
|
+
function withRequestId(msg, requestId) {
|
|
11
|
+
if (requestId) msg.requestId = requestId;
|
|
12
|
+
return msg;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export function
|
|
12
|
-
return sendWs({ type: "
|
|
15
|
+
export function sendScheduledNow(id, requestId) {
|
|
16
|
+
return sendWs(withRequestId({ type: "send_scheduled_now", id: id }, requestId));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function cancelScheduledInput(id, requestId) {
|
|
20
|
+
return sendWs(withRequestId({ type: "cancel_scheduled_message", id: id }, requestId));
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
// Asks for the armed inputs of the session on screen; the answer arrives as
|