@clagentic/console 1.5.0 → 1.6.0-beta.2
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/README.md +23 -4
- package/bin/cli.js +15 -82
- package/lib/agents-favorites.js +21 -6
- package/lib/config.js +1 -1
- package/lib/daemon.js +153 -22
- package/lib/drain.js +213 -0
- package/lib/lite-detect.js +6 -5
- package/lib/loop-handoff.js +282 -0
- package/lib/mcp-local.js +18 -2
- package/lib/memory-limits.js +436 -0
- package/lib/model-context-windows.js +65 -0
- package/lib/project-loop.js +31 -3
- package/lib/project-sessions.js +26 -0
- package/lib/project-team.js +4 -1
- package/lib/project.js +8 -0
- package/lib/public/app.js +4 -0
- package/lib/public/css/base.css +18 -0
- package/lib/public/css/diagnostics.css +279 -0
- package/lib/public/css/icon-strip.css +201 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/mobile-nav.css +24 -0
- package/lib/public/css/server-settings.css +100 -0
- package/lib/public/index.html +26 -0
- package/lib/public/modules/app-header.js +4 -7
- package/lib/public/modules/app-home-hub.js +31 -7
- package/lib/public/modules/app-messages.js +13 -0
- package/lib/public/modules/app-notifications.js +5 -1
- package/lib/public/modules/app-panels.js +11 -21
- package/lib/public/modules/app-projects.js +10 -5
- package/lib/public/modules/command-palette.js +16 -5
- package/lib/public/modules/custom-icons-settings.js +399 -0
- package/lib/public/modules/custom-icons.js +114 -0
- package/lib/public/modules/diagnostic-format.js +34 -0
- package/lib/public/modules/diagnostics.js +297 -0
- package/lib/public/modules/emoji-picker.js +253 -6
- package/lib/public/modules/model-context-windows.js +62 -0
- package/lib/public/modules/popover-position.js +192 -0
- package/lib/public/modules/project-icon.js +113 -0
- package/lib/public/modules/project-settings.js +2 -2
- package/lib/public/modules/project-switcher.js +2 -1
- package/lib/public/modules/scheduler-config.js +5 -8
- package/lib/public/modules/scheduler.js +5 -6
- package/lib/public/modules/server-settings.js +6 -0
- package/lib/public/modules/sidebar-mobile.js +4 -6
- package/lib/public/modules/sidebar-projects.js +35 -90
- package/lib/public/modules/sidebar-sessions.js +6 -20
- package/lib/public/modules/sticky-notes.js +4 -4
- package/lib/public/modules/terminal.js +5 -12
- package/lib/public/style.css +1 -0
- package/lib/sdk-bridge.js +75 -10
- package/lib/sdk-message-processor.js +12 -0
- package/lib/sdk-worker.js +4 -1
- package/lib/server-settings.js +221 -1
- package/lib/server.js +30 -1
- package/lib/sessions.js +27 -11
- package/lib/settings-preflight.js +212 -0
- package/lib/ws-schema.js +2 -0
- package/lib/yoke/adapters/claude-worker.js +14 -2
- package/lib/yoke/adapters/claude.js +16 -0
- package/lib/yoke/adapters/diagnostic-patterns.js +120 -0
- package/lib/yoke/index.js +4 -0
- package/lib/yoke/interface.js +99 -0
- package/package.json +2 -1
- package/scripts/postinstall.js +41 -0
- package/lib/certs/fullchain.pem +0 -47
- package/lib/certs/privkey.pem +0 -5
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// diagnostics.js — Diagnostic event rendering for epic lr-1a52 stage 4/5 (lr-8294).
|
|
2
|
+
//
|
|
3
|
+
// Consumes { type:'diagnostic', severity:'info'|'warning'|'error', source:string, message:string,
|
|
4
|
+
// actionable?:{label:string, action:string} } messages from the backend.
|
|
5
|
+
//
|
|
6
|
+
// Contract (set by stages 1-3, do NOT modify):
|
|
7
|
+
// - The message arrives via sendAndRecord — it is persisted in session history.
|
|
8
|
+
// - Diagnostics can arrive from any source (CLI stderr today, settings preflight in stage 5).
|
|
9
|
+
// - severity 'warning' and 'error' produce a toast (info lands quietly in the panel).
|
|
10
|
+
//
|
|
11
|
+
// Public surface:
|
|
12
|
+
// initDiagnostics() — call once on page load (wires up panel button)
|
|
13
|
+
// addDiagnostic(msg) — call from processMessage case 'diagnostic'
|
|
14
|
+
// formatDiagnosticSource(source) — pure helper, exported for tests
|
|
15
|
+
|
|
16
|
+
import { iconHtml, refreshIcons } from './icons.js';
|
|
17
|
+
import { formatDiagnosticSource as _formatSource } from './diagnostic-format.js';
|
|
18
|
+
|
|
19
|
+
// --- Module state ---
|
|
20
|
+
var diagnostics = []; // [{severity, source, message, actionable, ts}]
|
|
21
|
+
var panelEl = null;
|
|
22
|
+
var panelListEl = null;
|
|
23
|
+
var panelToggleBtn = null;
|
|
24
|
+
var panelBadgeEl = null;
|
|
25
|
+
|
|
26
|
+
// Severity priority (higher = more prominent).
|
|
27
|
+
var SEVERITY_ORDER = { error: 2, warning: 1, info: 0 };
|
|
28
|
+
|
|
29
|
+
// ============================================================
|
|
30
|
+
// Init
|
|
31
|
+
// ============================================================
|
|
32
|
+
|
|
33
|
+
export function initDiagnostics() {
|
|
34
|
+
panelEl = document.getElementById("diagnostics-panel");
|
|
35
|
+
panelListEl = document.getElementById("diagnostics-panel-list");
|
|
36
|
+
panelToggleBtn = document.getElementById("diagnostics-panel-btn");
|
|
37
|
+
panelBadgeEl = document.getElementById("diagnostics-panel-badge");
|
|
38
|
+
|
|
39
|
+
if (!panelEl || !panelListEl || !panelToggleBtn) return;
|
|
40
|
+
|
|
41
|
+
// Shared helper: close panel and return focus to the topbar button (WCAG 2.1 §2.4.3).
|
|
42
|
+
// Both the close button click and the Escape-key path use this so focus restoration
|
|
43
|
+
// is consistent for all keyboard-accessible dismiss gestures.
|
|
44
|
+
function closePanelAndRefocus() {
|
|
45
|
+
closePanel();
|
|
46
|
+
if (panelToggleBtn) panelToggleBtn.focus();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Close button inside the panel header.
|
|
50
|
+
var closeBtn = panelEl.querySelector(".diagnostics-panel-close");
|
|
51
|
+
if (closeBtn) {
|
|
52
|
+
closeBtn.addEventListener("click", function () {
|
|
53
|
+
closePanelAndRefocus();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Toggle button in the topbar.
|
|
58
|
+
panelToggleBtn.addEventListener("click", function () {
|
|
59
|
+
if (panelEl.classList.contains("hidden")) {
|
|
60
|
+
openPanel();
|
|
61
|
+
} else {
|
|
62
|
+
closePanel();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Keyboard: dismiss on Escape when panel is focused.
|
|
67
|
+
panelEl.addEventListener("keydown", function (e) {
|
|
68
|
+
if (e.key === "Escape") {
|
|
69
|
+
closePanelAndRefocus();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Click-outside dismiss: the panel is a non-modal surface (no backdrop
|
|
74
|
+
// element), so listen on the document and close when a click lands
|
|
75
|
+
// outside the panel and outside its topbar toggle button (lr-b580).
|
|
76
|
+
document.addEventListener("click", function (e) {
|
|
77
|
+
if (panelEl.classList.contains("hidden")) return;
|
|
78
|
+
if (panelEl.contains(e.target)) return;
|
|
79
|
+
if (panelToggleBtn && panelToggleBtn.contains(e.target)) return;
|
|
80
|
+
closePanelAndRefocus();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ============================================================
|
|
85
|
+
// Public: add a diagnostic
|
|
86
|
+
// ============================================================
|
|
87
|
+
|
|
88
|
+
export function addDiagnostic(msg) {
|
|
89
|
+
var entry = {
|
|
90
|
+
severity: msg.severity || "info",
|
|
91
|
+
source: msg.source || "",
|
|
92
|
+
message: msg.message || "",
|
|
93
|
+
actionable: msg.actionable || null,
|
|
94
|
+
ts: Date.now(),
|
|
95
|
+
};
|
|
96
|
+
diagnostics.push(entry);
|
|
97
|
+
|
|
98
|
+
// Render the new entry in the panel list.
|
|
99
|
+
_appendEntry(entry);
|
|
100
|
+
|
|
101
|
+
// Update the badge to reflect the highest-severity unread diagnostic.
|
|
102
|
+
_updateBadge();
|
|
103
|
+
|
|
104
|
+
// Toast for warning and error severity only.
|
|
105
|
+
if (entry.severity === "warning" || entry.severity === "error") {
|
|
106
|
+
_showDiagnosticToast(entry);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Re-export the pure formatter so callers that import from this module
|
|
111
|
+
// can reach it without a second import. Tests should import from
|
|
112
|
+
// diagnostic-format.js directly (no DOM deps there).
|
|
113
|
+
export { formatDiagnosticSource } from './diagnostic-format.js';
|
|
114
|
+
|
|
115
|
+
// ============================================================
|
|
116
|
+
// Toast
|
|
117
|
+
// ============================================================
|
|
118
|
+
|
|
119
|
+
function _showDiagnosticToast(entry) {
|
|
120
|
+
var el = document.createElement("div");
|
|
121
|
+
// Use a dedicated class so diagnostics are visually distinct from error messages.
|
|
122
|
+
el.className = "toast toast-diagnostic toast-diagnostic-" + entry.severity;
|
|
123
|
+
el.setAttribute("role", "alert");
|
|
124
|
+
el.setAttribute("aria-live", "assertive");
|
|
125
|
+
|
|
126
|
+
var headerEl = document.createElement("div");
|
|
127
|
+
headerEl.className = "toast-diagnostic-header";
|
|
128
|
+
|
|
129
|
+
var severityEl = document.createElement("span");
|
|
130
|
+
severityEl.className = "toast-diagnostic-severity toast-diag-sev-" + entry.severity;
|
|
131
|
+
severityEl.textContent = entry.severity.toUpperCase();
|
|
132
|
+
|
|
133
|
+
var sourceEl = document.createElement("span");
|
|
134
|
+
sourceEl.className = "toast-diagnostic-source";
|
|
135
|
+
sourceEl.textContent = _formatSource(entry.source);
|
|
136
|
+
|
|
137
|
+
var dismissBtn = document.createElement("button");
|
|
138
|
+
dismissBtn.className = "toast-diagnostic-dismiss";
|
|
139
|
+
dismissBtn.setAttribute("aria-label", "Dismiss diagnostic notification");
|
|
140
|
+
dismissBtn.innerHTML = iconHtml("x");
|
|
141
|
+
|
|
142
|
+
headerEl.appendChild(severityEl);
|
|
143
|
+
headerEl.appendChild(sourceEl);
|
|
144
|
+
headerEl.appendChild(dismissBtn);
|
|
145
|
+
|
|
146
|
+
var msgEl = document.createElement("div");
|
|
147
|
+
msgEl.className = "toast-diagnostic-msg";
|
|
148
|
+
msgEl.textContent = entry.message;
|
|
149
|
+
|
|
150
|
+
var hintEl = document.createElement("div");
|
|
151
|
+
hintEl.className = "toast-diagnostic-hint";
|
|
152
|
+
hintEl.textContent = "See Diagnostics panel for details";
|
|
153
|
+
|
|
154
|
+
el.appendChild(headerEl);
|
|
155
|
+
el.appendChild(msgEl);
|
|
156
|
+
el.appendChild(hintEl);
|
|
157
|
+
|
|
158
|
+
document.body.appendChild(el);
|
|
159
|
+
refreshIcons();
|
|
160
|
+
|
|
161
|
+
// Animate in.
|
|
162
|
+
requestAnimationFrame(function () { el.classList.add("visible"); });
|
|
163
|
+
|
|
164
|
+
// Auto-dismiss after 6s.
|
|
165
|
+
var timer = setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
|
|
166
|
+
|
|
167
|
+
// Manual dismiss.
|
|
168
|
+
dismissBtn.addEventListener("click", function () {
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
_removeDiagnosticToast(el);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Keyboard dismiss.
|
|
174
|
+
el.addEventListener("keydown", function (e) {
|
|
175
|
+
if (e.key === "Escape" || e.key === "Enter" || e.key === " ") {
|
|
176
|
+
clearTimeout(timer);
|
|
177
|
+
_removeDiagnosticToast(el);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function _removeDiagnosticToast(el) {
|
|
183
|
+
el.classList.remove("visible");
|
|
184
|
+
setTimeout(function () {
|
|
185
|
+
if (el.parentNode) el.parentNode.removeChild(el);
|
|
186
|
+
}, 300);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ============================================================
|
|
190
|
+
// Panel
|
|
191
|
+
// ============================================================
|
|
192
|
+
|
|
193
|
+
function openPanel() {
|
|
194
|
+
if (!panelEl) return;
|
|
195
|
+
panelEl.classList.remove("hidden");
|
|
196
|
+
panelEl.setAttribute("aria-expanded", "true");
|
|
197
|
+
if (panelToggleBtn) {
|
|
198
|
+
panelToggleBtn.setAttribute("aria-expanded", "true");
|
|
199
|
+
panelToggleBtn.classList.add("active");
|
|
200
|
+
}
|
|
201
|
+
// Focus the panel for keyboard navigation.
|
|
202
|
+
panelEl.focus();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function closePanel() {
|
|
206
|
+
if (!panelEl) return;
|
|
207
|
+
panelEl.classList.add("hidden");
|
|
208
|
+
panelEl.setAttribute("aria-expanded", "false");
|
|
209
|
+
if (panelToggleBtn) {
|
|
210
|
+
panelToggleBtn.setAttribute("aria-expanded", "false");
|
|
211
|
+
panelToggleBtn.classList.remove("active");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function _appendEntry(entry) {
|
|
216
|
+
if (!panelListEl) return;
|
|
217
|
+
|
|
218
|
+
// Remove the empty-state placeholder if present.
|
|
219
|
+
var emptyEl = panelListEl.querySelector(".diagnostics-empty");
|
|
220
|
+
if (emptyEl) emptyEl.parentNode.removeChild(emptyEl);
|
|
221
|
+
|
|
222
|
+
var item = document.createElement("div");
|
|
223
|
+
item.className = "diagnostics-item diagnostics-item-" + entry.severity;
|
|
224
|
+
|
|
225
|
+
// Icon strip: severity pill.
|
|
226
|
+
var meta = document.createElement("div");
|
|
227
|
+
meta.className = "diagnostics-item-meta";
|
|
228
|
+
|
|
229
|
+
var sevEl = document.createElement("span");
|
|
230
|
+
sevEl.className = "diagnostics-sev-badge diagnostics-sev-" + entry.severity;
|
|
231
|
+
sevEl.setAttribute("aria-label", "Severity: " + entry.severity);
|
|
232
|
+
sevEl.textContent = entry.severity;
|
|
233
|
+
|
|
234
|
+
var srcEl = document.createElement("span");
|
|
235
|
+
srcEl.className = "diagnostics-source";
|
|
236
|
+
srcEl.textContent = _formatSource(entry.source);
|
|
237
|
+
|
|
238
|
+
meta.appendChild(sevEl);
|
|
239
|
+
meta.appendChild(srcEl);
|
|
240
|
+
|
|
241
|
+
var msgEl = document.createElement("div");
|
|
242
|
+
msgEl.className = "diagnostics-message";
|
|
243
|
+
msgEl.textContent = entry.message;
|
|
244
|
+
|
|
245
|
+
item.appendChild(meta);
|
|
246
|
+
item.appendChild(msgEl);
|
|
247
|
+
|
|
248
|
+
// Actionable hint: surface label when present.
|
|
249
|
+
if (entry.actionable && entry.actionable.label) {
|
|
250
|
+
var actionEl = document.createElement("div");
|
|
251
|
+
actionEl.className = "diagnostics-actionable";
|
|
252
|
+
|
|
253
|
+
var fixIcon = document.createElement("span");
|
|
254
|
+
fixIcon.className = "diagnostics-actionable-icon";
|
|
255
|
+
fixIcon.innerHTML = iconHtml("info");
|
|
256
|
+
|
|
257
|
+
var fixText = document.createElement("span");
|
|
258
|
+
fixText.className = "diagnostics-actionable-text";
|
|
259
|
+
fixText.textContent = entry.actionable.label;
|
|
260
|
+
|
|
261
|
+
actionEl.appendChild(fixIcon);
|
|
262
|
+
actionEl.appendChild(fixText);
|
|
263
|
+
item.appendChild(actionEl);
|
|
264
|
+
refreshIcons();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
panelListEl.appendChild(item);
|
|
268
|
+
|
|
269
|
+
// Scroll the panel to the newest entry.
|
|
270
|
+
panelListEl.scrollTop = panelListEl.scrollHeight;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// ============================================================
|
|
274
|
+
// Badge
|
|
275
|
+
// ============================================================
|
|
276
|
+
|
|
277
|
+
function _updateBadge() {
|
|
278
|
+
if (!panelBadgeEl) return;
|
|
279
|
+
var count = diagnostics.length;
|
|
280
|
+
if (count === 0) {
|
|
281
|
+
panelBadgeEl.classList.add("hidden");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
// Show count; cap at 99.
|
|
285
|
+
panelBadgeEl.textContent = count > 99 ? "99+" : String(count);
|
|
286
|
+
panelBadgeEl.classList.remove("hidden");
|
|
287
|
+
|
|
288
|
+
// Badge color reflects the highest-severity diagnostic in the list.
|
|
289
|
+
panelBadgeEl.className = "diagnostics-panel-badge";
|
|
290
|
+
var maxSev = "info";
|
|
291
|
+
for (var i = 0; i < diagnostics.length; i++) {
|
|
292
|
+
if (SEVERITY_ORDER[diagnostics[i].severity] > SEVERITY_ORDER[maxSev]) {
|
|
293
|
+
maxSev = diagnostics[i].severity;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
panelBadgeEl.classList.add("diagnostics-badge-" + maxSev);
|
|
297
|
+
}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
// Replaces hand-curated EMOJI_CATEGORIES in sidebar-projects.js / project-settings.js
|
|
3
3
|
|
|
4
4
|
import { parseEmojis } from './markdown.js';
|
|
5
|
+
import { showToast } from './utils.js';
|
|
6
|
+
import { slugifyFilename, fetchCustomIconList, uploadCustomIcon, deleteCustomIcon, matchesCustomIconQuery } from './custom-icons.js';
|
|
5
7
|
|
|
6
|
-
// Group metadata matching emojibase-data group numbers
|
|
8
|
+
// Group metadata matching emojibase-data group numbers.
|
|
9
|
+
// "custom" is a string key (not a numeric group) so it never collides with emojibase groups.
|
|
7
10
|
var GROUP_META = [
|
|
8
11
|
{ g: 0, icon: "😀", label: "Smileys & Emotion" },
|
|
9
12
|
{ g: 1, icon: "🧑", label: "People & Body" },
|
|
@@ -14,6 +17,7 @@ var GROUP_META = [
|
|
|
14
17
|
{ g: 7, icon: "💡", label: "Objects" },
|
|
15
18
|
{ g: 8, icon: "❤️", label: "Symbols" },
|
|
16
19
|
{ g: 9, icon: "🏁", label: "Flags" },
|
|
20
|
+
{ g: "custom", icon: "🖼", label: "Custom" },
|
|
17
21
|
];
|
|
18
22
|
|
|
19
23
|
// Cached data promise — fetched once
|
|
@@ -137,10 +141,17 @@ export function buildEmojiPicker(opts) {
|
|
|
137
141
|
|
|
138
142
|
var currentCatIdx = 0;
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
// customMatches (optional) — custom-icon {slug, url} entries to render as
|
|
145
|
+
// image tiles alongside plain-text emoji results (lr-0847: search previously
|
|
146
|
+
// never included custom icons at all, so "console" could never find
|
|
147
|
+
// ":clagentic-console:" regardless of query). Appended after the emoji
|
|
148
|
+
// results, reusing the same select-on-click behavior as the Custom tab.
|
|
149
|
+
function buildGrid(emojis, customMatches) {
|
|
141
150
|
grid.innerHTML = "";
|
|
142
151
|
noResults.style.display = "none";
|
|
143
|
-
|
|
152
|
+
var hasEmojis = emojis && emojis.length > 0;
|
|
153
|
+
var hasCustom = customMatches && customMatches.length > 0;
|
|
154
|
+
if (!hasEmojis && !hasCustom) {
|
|
144
155
|
noResults.style.display = "block";
|
|
145
156
|
return;
|
|
146
157
|
}
|
|
@@ -157,24 +168,260 @@ export function buildEmojiPicker(opts) {
|
|
|
157
168
|
frag.appendChild(btn);
|
|
158
169
|
})(emojis[i]);
|
|
159
170
|
}
|
|
171
|
+
if (hasCustom) {
|
|
172
|
+
for (var ci = 0; ci < customMatches.length; ci++) {
|
|
173
|
+
(function (entry) {
|
|
174
|
+
var btn = document.createElement("button");
|
|
175
|
+
btn.className = "emoji-picker-item emoji-picker-item-custom";
|
|
176
|
+
btn.title = ":" + entry.slug + ":";
|
|
177
|
+
var img = document.createElement("img");
|
|
178
|
+
img.src = entry.url;
|
|
179
|
+
img.alt = ":" + entry.slug + ":";
|
|
180
|
+
img.className = "emoji-picker-custom-img";
|
|
181
|
+
btn.appendChild(img);
|
|
182
|
+
btn.addEventListener("click", function (e) {
|
|
183
|
+
e.stopPropagation();
|
|
184
|
+
onSelect(":" + entry.slug + ":");
|
|
185
|
+
});
|
|
186
|
+
frag.appendChild(btn);
|
|
187
|
+
})(customMatches[ci]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
160
190
|
grid.appendChild(frag);
|
|
161
191
|
parseEmojis(grid);
|
|
162
192
|
scrollArea.scrollTop = 0;
|
|
163
193
|
}
|
|
164
194
|
|
|
195
|
+
// --- Custom emoji panel ---
|
|
196
|
+
|
|
197
|
+
// Cached list of uploads from GET /api/custom-emoji
|
|
198
|
+
var customList = null; // null = not fetched yet
|
|
199
|
+
|
|
200
|
+
function fetchCustomList(cb) {
|
|
201
|
+
fetchCustomIconList().then(function (list) {
|
|
202
|
+
customList = list;
|
|
203
|
+
if (cb) cb(customList);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function buildCustomPanel() {
|
|
208
|
+
grid.innerHTML = "";
|
|
209
|
+
noResults.style.display = "none";
|
|
210
|
+
|
|
211
|
+
var panel = document.createElement("div");
|
|
212
|
+
panel.className = "emoji-picker-custom-panel";
|
|
213
|
+
|
|
214
|
+
// Hidden file input (opened by upload tile click)
|
|
215
|
+
var fileInput = document.createElement("input");
|
|
216
|
+
fileInput.type = "file";
|
|
217
|
+
fileInput.accept = "image/png,image/jpeg,image/gif,image/webp";
|
|
218
|
+
fileInput.style.display = "none";
|
|
219
|
+
panel.appendChild(fileInput);
|
|
220
|
+
|
|
221
|
+
// Slug confirm dialog (shown inline before upload)
|
|
222
|
+
var slugConfirm = document.createElement("div");
|
|
223
|
+
slugConfirm.className = "emoji-picker-slug-confirm hidden";
|
|
224
|
+
slugConfirm.innerHTML =
|
|
225
|
+
'<label class="emoji-picker-slug-label">Slug</label>' +
|
|
226
|
+
'<input type="text" class="emoji-picker-slug-input" maxlength="64" spellcheck="false" autocomplete="off">' +
|
|
227
|
+
'<div class="emoji-picker-slug-actions">' +
|
|
228
|
+
'<button class="emoji-picker-slug-cancel">Cancel</button>' +
|
|
229
|
+
'<button class="emoji-picker-slug-ok primary">Upload</button>' +
|
|
230
|
+
'</div>';
|
|
231
|
+
panel.appendChild(slugConfirm);
|
|
232
|
+
|
|
233
|
+
var slugInput = slugConfirm.querySelector(".emoji-picker-slug-input");
|
|
234
|
+
var slugOk = slugConfirm.querySelector(".emoji-picker-slug-ok");
|
|
235
|
+
var slugCancel = slugConfirm.querySelector(".emoji-picker-slug-cancel");
|
|
236
|
+
var pendingFile = null;
|
|
237
|
+
|
|
238
|
+
function showSlugConfirm(file) {
|
|
239
|
+
pendingFile = file;
|
|
240
|
+
slugInput.value = slugifyFilename(file.name);
|
|
241
|
+
slugConfirm.classList.remove("hidden");
|
|
242
|
+
slugInput.focus();
|
|
243
|
+
slugInput.select();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function hideSlugConfirm() {
|
|
247
|
+
slugConfirm.classList.add("hidden");
|
|
248
|
+
pendingFile = null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function doUpload() {
|
|
252
|
+
if (!pendingFile) return;
|
|
253
|
+
var slug = slugInput.value.trim().toLowerCase()
|
|
254
|
+
.replace(/[^a-z0-9_-]+/g, "-")
|
|
255
|
+
.replace(/^-+|-+$/g, "")
|
|
256
|
+
.slice(0, 64);
|
|
257
|
+
if (!slug || !/^[a-z0-9_-]{1,64}$/.test(slug)) return;
|
|
258
|
+
|
|
259
|
+
// Check for duplicate in the already-fetched list
|
|
260
|
+
var existing = customList || [];
|
|
261
|
+
var hasDup = existing.some(function (e) { return e.slug === slug; });
|
|
262
|
+
|
|
263
|
+
function proceed() {
|
|
264
|
+
hideSlugConfirm();
|
|
265
|
+
uploadCustomIcon(slug, pendingFile).then(function (result) {
|
|
266
|
+
if (!result.ok) {
|
|
267
|
+
// lr-0847: the picker previously swallowed upload failures here
|
|
268
|
+
// (bare `return`), so a failed upload looked identical to a
|
|
269
|
+
// successful one from the user's perspective — nothing happened,
|
|
270
|
+
// no icon appeared, no explanation. Settings surfaces the same
|
|
271
|
+
// uploadCustomIcon() failure via window.alert; use the app's
|
|
272
|
+
// shared toast here since the picker is a transient popover, not
|
|
273
|
+
// a modal dialog.
|
|
274
|
+
showToast(result.error || "Upload failed", "warn");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Refresh the custom grid after upload
|
|
278
|
+
customList = null;
|
|
279
|
+
fetchCustomList(function () { buildCustomPanel(); renderCustomGrid(); });
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (hasDup) {
|
|
284
|
+
// Confirm overwrite
|
|
285
|
+
if (window.confirm(":" + slug + ": already exists — overwrite?")) {
|
|
286
|
+
proceed();
|
|
287
|
+
} else {
|
|
288
|
+
hideSlugConfirm();
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
proceed();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
slugOk.addEventListener("click", function (e) { e.stopPropagation(); doUpload(); });
|
|
296
|
+
slugCancel.addEventListener("click", function (e) { e.stopPropagation(); hideSlugConfirm(); });
|
|
297
|
+
slugInput.addEventListener("keydown", function (e) {
|
|
298
|
+
e.stopPropagation();
|
|
299
|
+
if (e.key === "Enter") { e.preventDefault(); doUpload(); }
|
|
300
|
+
if (e.key === "Escape") { e.preventDefault(); hideSlugConfirm(); }
|
|
301
|
+
});
|
|
302
|
+
// Prevent slug input clicks from bubbling to the picker's document-click close handler
|
|
303
|
+
slugInput.addEventListener("click", function (e) { e.stopPropagation(); });
|
|
304
|
+
|
|
305
|
+
fileInput.addEventListener("change", function () {
|
|
306
|
+
var file = fileInput.files && fileInput.files[0];
|
|
307
|
+
fileInput.value = ""; // reset so same file can be re-selected
|
|
308
|
+
if (!file) return;
|
|
309
|
+
showSlugConfirm(file);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// Grid of existing uploads
|
|
313
|
+
var customGrid = document.createElement("div");
|
|
314
|
+
customGrid.className = "emoji-picker-grid";
|
|
315
|
+
panel.appendChild(customGrid);
|
|
316
|
+
|
|
317
|
+
function renderCustomGrid() {
|
|
318
|
+
customGrid.innerHTML = "";
|
|
319
|
+
|
|
320
|
+
// Upload tile (always first)
|
|
321
|
+
var uploadTile = document.createElement("button");
|
|
322
|
+
uploadTile.className = "emoji-picker-item emoji-picker-upload-tile";
|
|
323
|
+
uploadTile.title = "Upload image";
|
|
324
|
+
uploadTile.textContent = "+";
|
|
325
|
+
uploadTile.addEventListener("click", function (e) {
|
|
326
|
+
e.stopPropagation();
|
|
327
|
+
fileInput.click();
|
|
328
|
+
});
|
|
329
|
+
customGrid.appendChild(uploadTile);
|
|
330
|
+
|
|
331
|
+
var list = customList || [];
|
|
332
|
+
for (var ci = 0; ci < list.length; ci++) {
|
|
333
|
+
(function (entry) {
|
|
334
|
+
var tile = document.createElement("div");
|
|
335
|
+
tile.className = "emoji-picker-custom-tile";
|
|
336
|
+
|
|
337
|
+
var img = document.createElement("img");
|
|
338
|
+
img.src = entry.url;
|
|
339
|
+
img.alt = ":" + entry.slug + ":";
|
|
340
|
+
img.className = "emoji-picker-custom-img";
|
|
341
|
+
img.title = ":" + entry.slug + ":";
|
|
342
|
+
img.addEventListener("click", function (e) {
|
|
343
|
+
e.stopPropagation();
|
|
344
|
+
onSelect(":" + entry.slug + ":");
|
|
345
|
+
});
|
|
346
|
+
tile.appendChild(img);
|
|
347
|
+
|
|
348
|
+
var delBtn = document.createElement("button");
|
|
349
|
+
delBtn.className = "emoji-picker-custom-delete";
|
|
350
|
+
delBtn.title = "Delete";
|
|
351
|
+
delBtn.textContent = "×";
|
|
352
|
+
delBtn.addEventListener("click", function (e) {
|
|
353
|
+
e.stopPropagation();
|
|
354
|
+
deleteCustomIcon(entry.slug).then(function () {
|
|
355
|
+
customList = null;
|
|
356
|
+
fetchCustomList(function () { buildCustomPanel(); renderCustomGrid(); });
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
tile.appendChild(delBtn);
|
|
360
|
+
|
|
361
|
+
customGrid.appendChild(tile);
|
|
362
|
+
})(list[ci]);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (list.length === 0) {
|
|
366
|
+
var emptyHint = document.createElement("div");
|
|
367
|
+
emptyHint.className = "emoji-picker-custom-empty";
|
|
368
|
+
emptyHint.textContent = "No custom icons yet — click + to upload";
|
|
369
|
+
emptyHint.style.gridColumn = "1 / -1";
|
|
370
|
+
customGrid.appendChild(emptyHint);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Attach renderCustomGrid to the panel so switchCategory can re-invoke it
|
|
375
|
+
panel._renderCustomGrid = renderCustomGrid;
|
|
376
|
+
|
|
377
|
+
if (customList !== null) {
|
|
378
|
+
renderCustomGrid();
|
|
379
|
+
} else {
|
|
380
|
+
fetchCustomList(function () { renderCustomGrid(); });
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
grid.appendChild(panel);
|
|
384
|
+
scrollArea.scrollTop = 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
165
387
|
function switchCategory(idx) {
|
|
166
388
|
currentCatIdx = idx;
|
|
167
389
|
for (var j = 0; j < tabBtns.length; j++) {
|
|
168
390
|
tabBtns[j].classList.toggle("active", j === idx);
|
|
169
391
|
}
|
|
170
|
-
|
|
171
|
-
|
|
392
|
+
var meta = GROUP_META[idx];
|
|
393
|
+
if (meta.g === "custom") {
|
|
394
|
+
buildCustomPanel();
|
|
395
|
+
} else if (_byGroup) {
|
|
396
|
+
buildGrid(_byGroup[meta.g] || []);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function matchingCustomIcons(query) {
|
|
401
|
+
var list = customList || [];
|
|
402
|
+
var matches = [];
|
|
403
|
+
for (var i = 0; i < list.length; i++) {
|
|
404
|
+
if (matchesCustomIconQuery(list[i].slug, query)) matches.push(list[i]);
|
|
172
405
|
}
|
|
406
|
+
return matches;
|
|
173
407
|
}
|
|
174
408
|
|
|
175
409
|
function showSearchResults(query) {
|
|
176
410
|
tabBar.style.display = "none";
|
|
177
|
-
|
|
411
|
+
var emojiMatches = searchEmojis(query);
|
|
412
|
+
if (customList === null) {
|
|
413
|
+
// Custom list not fetched yet (user hasn't opened the Custom tab this
|
|
414
|
+
// session) — show emoji matches immediately, then re-render with
|
|
415
|
+
// custom-icon matches once the list arrives so search never blocks on it.
|
|
416
|
+
buildGrid(emojiMatches, []);
|
|
417
|
+
fetchCustomList(function () {
|
|
418
|
+
if (searchInput.value.trim() === query.trim()) {
|
|
419
|
+
buildGrid(emojiMatches, matchingCustomIcons(query));
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
buildGrid(emojiMatches, matchingCustomIcons(query));
|
|
178
425
|
}
|
|
179
426
|
|
|
180
427
|
function showCategory() {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* model-context-windows.js — shared source of truth for the model context-window
|
|
3
|
+
* map and beta-aware resolution. (lr-336f)
|
|
4
|
+
*
|
|
5
|
+
* This is the ES module (browser) copy. The CJS backend copy lives at
|
|
6
|
+
* lib/model-context-windows.js. A CI test (test/model-context-windows-parity.test.js)
|
|
7
|
+
* asserts both files produce identical resolution results so they cannot silently drift.
|
|
8
|
+
*
|
|
9
|
+
* When adding a new model: update BOTH this file and lib/model-context-windows.js.
|
|
10
|
+
* The parity test will fail if they disagree.
|
|
11
|
+
*
|
|
12
|
+
* The map is keyed by a lowercase model-name substring. Lookup is a linear scan so
|
|
13
|
+
* insertion order matters for overlapping substrings — more-specific keys should
|
|
14
|
+
* appear before less-specific ones.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var KNOWN_CONTEXT_WINDOWS = {
|
|
18
|
+
"opus-4-6": 1000000,
|
|
19
|
+
"claude-sonnet-4": 1000000,
|
|
20
|
+
"gpt-5.5": 1048576,
|
|
21
|
+
"gpt-5.4": 1048576,
|
|
22
|
+
"gpt-5.3": 1048576,
|
|
23
|
+
"gpt-5.2": 1048576,
|
|
24
|
+
"gpt-4.1": 1047576,
|
|
25
|
+
"o3": 200000,
|
|
26
|
+
"o4-mini": 200000,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the context window for a model identifier, applying the beta-first
|
|
31
|
+
* rule for the context-1m beta.
|
|
32
|
+
*
|
|
33
|
+
* activeBetas: optional array of active beta strings. When any entry contains
|
|
34
|
+
* "context-1m", the true window is 1M regardless of the model — the SDK
|
|
35
|
+
* reports the model's base window in ModelUsage but the beta extends it.
|
|
36
|
+
*
|
|
37
|
+
* Returns the window size in tokens, or 0 when the model is not in
|
|
38
|
+
* KNOWN_CONTEXT_WINDOWS and no beta applies. Callers treat 0 as "unknown"
|
|
39
|
+
* and should degrade cleanly (skip any window-based guard rather than
|
|
40
|
+
* guessing a default).
|
|
41
|
+
*
|
|
42
|
+
* Note: the resolveContextWindow wrapper in app-panels.js adds an sdkValue
|
|
43
|
+
* fallback and a hasBeta() store accessor on top of this core function.
|
|
44
|
+
* This function itself is store-agnostic.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveModelContextWindow(model, activeBetas) {
|
|
47
|
+
// Beta check must come first — the SDK does not reflect the extended window.
|
|
48
|
+
if (Array.isArray(activeBetas)) {
|
|
49
|
+
for (var bi = 0; bi < activeBetas.length; bi++) {
|
|
50
|
+
if (activeBetas[bi].indexOf("context-1m") !== -1) return 1000000;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!model) return 0;
|
|
54
|
+
var lc = model.toLowerCase();
|
|
55
|
+
// UI beta-toggle appends [1m] to the model name
|
|
56
|
+
if (lc.indexOf("[1m]") !== -1) return 1000000;
|
|
57
|
+
var keys = Object.keys(KNOWN_CONTEXT_WINDOWS);
|
|
58
|
+
for (var i = 0; i < keys.length; i++) {
|
|
59
|
+
if (lc.indexOf(keys[i]) !== -1) return KNOWN_CONTEXT_WINDOWS[keys[i]];
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
62
|
+
}
|