@clagentic/console 1.0.0-beta.1

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.
Files changed (221) hide show
  1. package/CREDITS.md +3 -0
  2. package/LICENSE +21 -0
  3. package/README.md +250 -0
  4. package/bin/cli.js +2812 -0
  5. package/lib/agents-favorites.js +164 -0
  6. package/lib/agents.js +282 -0
  7. package/lib/ask-user-mcp-server.js +120 -0
  8. package/lib/browser-mcp-server.js +484 -0
  9. package/lib/build-user-env.js +63 -0
  10. package/lib/certs/fullchain.pem +47 -0
  11. package/lib/certs/privkey.pem +5 -0
  12. package/lib/cli-sessions.js +265 -0
  13. package/lib/codex-defaults.js +18 -0
  14. package/lib/config.js +332 -0
  15. package/lib/crisis-safety.js +60 -0
  16. package/lib/daemon-projects.js +164 -0
  17. package/lib/daemon.js +1602 -0
  18. package/lib/dm.js +128 -0
  19. package/lib/ipc.js +125 -0
  20. package/lib/ipv4-only.js +39 -0
  21. package/lib/mcp-local.js +385 -0
  22. package/lib/notes.js +141 -0
  23. package/lib/os-users.js +529 -0
  24. package/lib/pages.js +1325 -0
  25. package/lib/project-connection.js +302 -0
  26. package/lib/project-external-trigger.js +236 -0
  27. package/lib/project-file-watch.js +120 -0
  28. package/lib/project-filesystem.js +528 -0
  29. package/lib/project-http.js +753 -0
  30. package/lib/project-image.js +95 -0
  31. package/lib/project-knowledge.js +88 -0
  32. package/lib/project-loop.js +1304 -0
  33. package/lib/project-mcp.js +374 -0
  34. package/lib/project-memory.js +39 -0
  35. package/lib/project-notifications.js +262 -0
  36. package/lib/project-sessions.js +1581 -0
  37. package/lib/project-user-mention.js +193 -0
  38. package/lib/project-user-message.js +628 -0
  39. package/lib/project.js +1303 -0
  40. package/lib/public/app.js +1031 -0
  41. package/lib/public/apple-touch-icon.png +0 -0
  42. package/lib/public/claude-code-avatar.png +0 -0
  43. package/lib/public/codex-avatar.png +0 -0
  44. package/lib/public/console-icon.png +0 -0
  45. package/lib/public/css/admin.css +736 -0
  46. package/lib/public/css/agent-picker.css +119 -0
  47. package/lib/public/css/base.css +235 -0
  48. package/lib/public/css/channel-layout.css +441 -0
  49. package/lib/public/css/command-palette.css +559 -0
  50. package/lib/public/css/debate.css +1609 -0
  51. package/lib/public/css/diff.css +139 -0
  52. package/lib/public/css/filebrowser.css +1976 -0
  53. package/lib/public/css/highlight.css +144 -0
  54. package/lib/public/css/home-hub.css +545 -0
  55. package/lib/public/css/icon-strip.css +1856 -0
  56. package/lib/public/css/input.css +1349 -0
  57. package/lib/public/css/loop.css +1248 -0
  58. package/lib/public/css/mention.css +317 -0
  59. package/lib/public/css/menus.css +857 -0
  60. package/lib/public/css/messages.css +1833 -0
  61. package/lib/public/css/mobile-nav.css +1332 -0
  62. package/lib/public/css/notifications-center.css +296 -0
  63. package/lib/public/css/overlays.css +1273 -0
  64. package/lib/public/css/playbook.css +264 -0
  65. package/lib/public/css/profile.css +397 -0
  66. package/lib/public/css/rewind.css +671 -0
  67. package/lib/public/css/scheduler-modal.css +1495 -0
  68. package/lib/public/css/scheduler.css +1420 -0
  69. package/lib/public/css/server-settings.css +909 -0
  70. package/lib/public/css/session-search.css +159 -0
  71. package/lib/public/css/sidebar.css +2012 -0
  72. package/lib/public/css/skills.css +789 -0
  73. package/lib/public/css/sticky-notes.css +854 -0
  74. package/lib/public/css/stt.css +155 -0
  75. package/lib/public/css/title-bar.css +674 -0
  76. package/lib/public/css/tooltip.css +67 -0
  77. package/lib/public/css/user-settings.css +702 -0
  78. package/lib/public/emoji-data.json +1 -0
  79. package/lib/public/favicon-banded-32.png +0 -0
  80. package/lib/public/favicon-banded.png +0 -0
  81. package/lib/public/favicon-dark.svg +32 -0
  82. package/lib/public/favicon.svg +32 -0
  83. package/lib/public/icon-192.png +0 -0
  84. package/lib/public/icon-512.png +0 -0
  85. package/lib/public/icon-banded-76.png +0 -0
  86. package/lib/public/icon-banded-96.png +0 -0
  87. package/lib/public/icon-mono.svg +25 -0
  88. package/lib/public/icons/email/gmail.svg +7 -0
  89. package/lib/public/icons/email/outlook.svg +35 -0
  90. package/lib/public/icons/email/yahoo.svg +1 -0
  91. package/lib/public/index.html +1946 -0
  92. package/lib/public/manifest.json +27 -0
  93. package/lib/public/markdown-worker.js +43 -0
  94. package/lib/public/marked.min.js +6 -0
  95. package/lib/public/modules/admin.js +954 -0
  96. package/lib/public/modules/agent-picker.js +429 -0
  97. package/lib/public/modules/app-connection.js +216 -0
  98. package/lib/public/modules/app-cursors.js +492 -0
  99. package/lib/public/modules/app-dm.js +265 -0
  100. package/lib/public/modules/app-favicon.js +231 -0
  101. package/lib/public/modules/app-header.js +242 -0
  102. package/lib/public/modules/app-home-hub.js +432 -0
  103. package/lib/public/modules/app-loop-ui.js +691 -0
  104. package/lib/public/modules/app-loop-wizard.js +439 -0
  105. package/lib/public/modules/app-messages.js +1415 -0
  106. package/lib/public/modules/app-misc.js +463 -0
  107. package/lib/public/modules/app-notifications.js +651 -0
  108. package/lib/public/modules/app-panels.js +1061 -0
  109. package/lib/public/modules/app-projects.js +875 -0
  110. package/lib/public/modules/app-rate-limit.js +529 -0
  111. package/lib/public/modules/app-rendering.js +739 -0
  112. package/lib/public/modules/app-skills-install.js +285 -0
  113. package/lib/public/modules/avatar.js +36 -0
  114. package/lib/public/modules/command-palette.js +491 -0
  115. package/lib/public/modules/console-logo.js +162 -0
  116. package/lib/public/modules/context-sources.js +365 -0
  117. package/lib/public/modules/diff.js +412 -0
  118. package/lib/public/modules/dom-refs.js +21 -0
  119. package/lib/public/modules/emoji-picker.js +222 -0
  120. package/lib/public/modules/events.js +21 -0
  121. package/lib/public/modules/filebrowser.js +1966 -0
  122. package/lib/public/modules/fileicons.js +172 -0
  123. package/lib/public/modules/icons.js +80 -0
  124. package/lib/public/modules/input.js +1102 -0
  125. package/lib/public/modules/longpress.js +74 -0
  126. package/lib/public/modules/markdown.js +486 -0
  127. package/lib/public/modules/mcp-ui.js +295 -0
  128. package/lib/public/modules/mention.js +1093 -0
  129. package/lib/public/modules/notifications.js +613 -0
  130. package/lib/public/modules/playbook.js +578 -0
  131. package/lib/public/modules/profile.js +594 -0
  132. package/lib/public/modules/project-settings.js +849 -0
  133. package/lib/public/modules/project-switcher.js +375 -0
  134. package/lib/public/modules/qrcode.js +87 -0
  135. package/lib/public/modules/rewind.js +381 -0
  136. package/lib/public/modules/scheduler-config.js +1611 -0
  137. package/lib/public/modules/scheduler-history.js +131 -0
  138. package/lib/public/modules/scheduler.js +1689 -0
  139. package/lib/public/modules/server-settings.js +842 -0
  140. package/lib/public/modules/session-search.js +456 -0
  141. package/lib/public/modules/settings-defaults.js +253 -0
  142. package/lib/public/modules/sidebar-mobile.js +1425 -0
  143. package/lib/public/modules/sidebar-projects.js +2022 -0
  144. package/lib/public/modules/sidebar-sessions.js +1548 -0
  145. package/lib/public/modules/sidebar-users.js +449 -0
  146. package/lib/public/modules/sidebar.js +348 -0
  147. package/lib/public/modules/skills.js +793 -0
  148. package/lib/public/modules/state.js +3 -0
  149. package/lib/public/modules/sticky-notes.js +1221 -0
  150. package/lib/public/modules/store.js +34 -0
  151. package/lib/public/modules/stt.js +266 -0
  152. package/lib/public/modules/terminal.js +987 -0
  153. package/lib/public/modules/theme.js +812 -0
  154. package/lib/public/modules/tool-palette.js +562 -0
  155. package/lib/public/modules/tools.js +2285 -0
  156. package/lib/public/modules/tooltip.js +150 -0
  157. package/lib/public/modules/user-settings.js +544 -0
  158. package/lib/public/modules/utils.js +56 -0
  159. package/lib/public/modules/ws-ref.js +26 -0
  160. package/lib/public/style.css +34 -0
  161. package/lib/public/sw.js +159 -0
  162. package/lib/push.js +149 -0
  163. package/lib/scheduler.js +471 -0
  164. package/lib/sdk-bridge.js +1792 -0
  165. package/lib/sdk-message-processor.js +740 -0
  166. package/lib/sdk-message-queue.js +42 -0
  167. package/lib/sdk-skill-discovery.js +131 -0
  168. package/lib/sdk-worker.js +677 -0
  169. package/lib/server-admin.js +712 -0
  170. package/lib/server-auth.js +737 -0
  171. package/lib/server-dm.js +170 -0
  172. package/lib/server-palette.js +104 -0
  173. package/lib/server-settings.js +553 -0
  174. package/lib/server-skills.js +280 -0
  175. package/lib/server.js +1390 -0
  176. package/lib/session-search.js +693 -0
  177. package/lib/sessions.js +946 -0
  178. package/lib/smtp.js +221 -0
  179. package/lib/terminal-manager.js +219 -0
  180. package/lib/terminal.js +39 -0
  181. package/lib/themes/ayu-light.json +9 -0
  182. package/lib/themes/catppuccin-latte.json +9 -0
  183. package/lib/themes/catppuccin-mocha.json +9 -0
  184. package/lib/themes/clagentic-dark.json +10 -0
  185. package/lib/themes/clagentic-light.json +10 -0
  186. package/lib/themes/dracula.json +9 -0
  187. package/lib/themes/everforest-light.json +9 -0
  188. package/lib/themes/everforest.json +9 -0
  189. package/lib/themes/github-light.json +9 -0
  190. package/lib/themes/gruvbox-dark.json +9 -0
  191. package/lib/themes/gruvbox-light.json +9 -0
  192. package/lib/themes/monokai.json +9 -0
  193. package/lib/themes/nord-light.json +9 -0
  194. package/lib/themes/nord.json +9 -0
  195. package/lib/themes/one-dark.json +9 -0
  196. package/lib/themes/one-light.json +9 -0
  197. package/lib/themes/rose-pine-dawn.json +9 -0
  198. package/lib/themes/rose-pine.json +9 -0
  199. package/lib/themes/solarized-dark.json +9 -0
  200. package/lib/themes/solarized-light.json +9 -0
  201. package/lib/themes/tokyo-night-light.json +9 -0
  202. package/lib/themes/tokyo-night.json +9 -0
  203. package/lib/updater.js +124 -0
  204. package/lib/user-presence.js +92 -0
  205. package/lib/users-auth.js +146 -0
  206. package/lib/users-permissions.js +118 -0
  207. package/lib/users-preferences.js +254 -0
  208. package/lib/users.js +465 -0
  209. package/lib/utils.js +64 -0
  210. package/lib/worktree.js +134 -0
  211. package/lib/ws-schema.js +464 -0
  212. package/lib/yoke/adapters/claude-worker.js +759 -0
  213. package/lib/yoke/adapters/claude.js +1599 -0
  214. package/lib/yoke/adapters/codex.js +1559 -0
  215. package/lib/yoke/codex-app-server.js +352 -0
  216. package/lib/yoke/index.js +319 -0
  217. package/lib/yoke/instructions.js +61 -0
  218. package/lib/yoke/interface.js +98 -0
  219. package/lib/yoke/mcp-bridge-server.js +302 -0
  220. package/lib/yoke/package.json +7 -0
  221. package/package.json +72 -0
@@ -0,0 +1,375 @@
1
+ // project-switcher.js — macOS Cmd+Tab-style quick switcher.
2
+ //
3
+ // Two modes share the same overlay:
4
+ // Cmd/Ctrl+E → projects only (non-Mate), activates via switchProject
5
+ // Cmd/Ctrl+M → Mates only, activates via openDm
6
+ //
7
+ // While the modifier is still held, repeating the same shortcut cycles
8
+ // forward and Shift cycles back. Releasing the modifier commits —
9
+ // matching Cmd+Tab semantics. Enter commits explicitly; Escape cancels.
10
+ //
11
+ // Each mode has its own in-memory MRU list so the ordering stays
12
+ // mode-specific (visiting projects shouldn't reorder the mate list,
13
+ // and vice versa). No persistence — MRU is a transient hint and
14
+ // project rule forbids localStorage for preferences.
15
+
16
+ import { store } from './store.js';
17
+ import { refreshIcons } from './icons.js';
18
+ import { getCachedProjects, switchProject } from './app-projects.js';
19
+ import { openDm } from './app-dm.js';
20
+ import { parseEmojis } from './markdown.js';
21
+
22
+ var _projectMru = []; // project slugs, most recent first
23
+ var _mateMru = []; // mate ids (mate_XXX), most recent first
24
+ var _overlay = null;
25
+ var _list = null;
26
+ var _headerEl = null;
27
+ var _open = false;
28
+ var _mode = 'project'; // 'project' | 'mate'
29
+ var _highlightedIndex = 0;
30
+ var _entries = [];
31
+
32
+ export function openSwitcherForMode(mode) {
33
+ if (mode !== 'project' && mode !== 'mate') return;
34
+ if (_open) closeSwitcher(false);
35
+ openSwitcher(mode);
36
+ }
37
+
38
+ export function initProjectSwitcher() {
39
+ buildOverlayIfMissing();
40
+ _list = _overlay.querySelector('.cmd-palette-results');
41
+ _headerEl = _overlay.querySelector('.project-switcher-header');
42
+
43
+ // Seed MRUs from current state.
44
+ var seedSlug = store.get('currentSlug');
45
+ if (seedSlug) _projectMru = [seedSlug];
46
+
47
+ // Track MRUs by watching the store for navigation changes.
48
+ store.subscribe(function (state, prev) {
49
+ if (state.currentSlug && state.currentSlug !== prev.currentSlug) {
50
+ bumpMru(_projectMru, state.currentSlug);
51
+ _projectMru = _projectMru; // (keep reference; bumpMru mutates via reassignment)
52
+ }
53
+ var curMate = mateIdFrom(state.dmTargetUser);
54
+ var prevMate = mateIdFrom(prev.dmTargetUser);
55
+ if (curMate && curMate !== prevMate) bumpMru(_mateMru, curMate);
56
+ });
57
+
58
+ var backdrop = _overlay.querySelector('.cmd-palette-backdrop');
59
+ if (backdrop) backdrop.addEventListener('click', function () { closeSwitcher(false); });
60
+
61
+ document.addEventListener('keydown', handleKeyDown, true);
62
+ document.addEventListener('keyup', handleKeyUp, true);
63
+ window.addEventListener('blur', function () { if (_open) closeSwitcher(false); });
64
+
65
+ // Wire hotkey hint pills next to the icon strip so the keybinding is
66
+ // discoverable in the same surface users use for clicking. Clicking
67
+ // the pill is equivalent to pressing the shortcut itself.
68
+ var isMac = /Mac|iPhone|iPod|iPad/i.test(navigator.platform);
69
+ var projectHintLabel = isMac ? '\u2318E' : 'Ctrl+E';
70
+ var mateHintLabel = isMac ? '\u2318M' : 'Ctrl+M';
71
+ var projectHint = document.getElementById('icon-strip-hint-project');
72
+ var mateHint = document.getElementById('icon-strip-hint-mate');
73
+ if (projectHint) {
74
+ projectHint.textContent = projectHintLabel;
75
+ projectHint.title = 'Switch project (' + projectHintLabel + ')';
76
+ projectHint.addEventListener('click', function () { openSwitcherForMode('project'); });
77
+ }
78
+ if (mateHint) {
79
+ mateHint.textContent = mateHintLabel;
80
+ mateHint.title = 'Switch mate (' + mateHintLabel + ')';
81
+ mateHint.addEventListener('click', function () { openSwitcherForMode('mate'); });
82
+ }
83
+
84
+ // Mate hint: always hidden since mates feature is removed
85
+ if (mateHint) mateHint.classList.add('hidden');
86
+ }
87
+
88
+ function buildOverlayIfMissing() {
89
+ _overlay = document.getElementById('project-switcher');
90
+ if (_overlay) return;
91
+ var isMac = /Mac|iPhone|iPod|iPad/i.test(navigator.platform);
92
+ var modKbd = isMac ? '<kbd>\u2318</kbd>' : '<kbd>Ctrl</kbd>';
93
+ _overlay = document.createElement('div');
94
+ _overlay.id = 'project-switcher';
95
+ _overlay.className = 'cmd-palette hidden project-switcher';
96
+ _overlay.innerHTML =
97
+ '<div class="cmd-palette-backdrop"></div>' +
98
+ '<div class="cmd-palette-dialog project-switcher-dialog">' +
99
+ '<div class="project-switcher-header">Switch project</div>' +
100
+ '<div class="cmd-palette-results"></div>' +
101
+ '<div class="cmd-palette-footer project-switcher-footer">' +
102
+ '<span class="project-switcher-shortcuts">' + modKbd + '<kbd class="proj-next-key">E</kbd> next \u00b7 <kbd>\u21E7</kbd>' + modKbd + '<kbd class="proj-prev-key">E</kbd> prev \u00b7 <kbd>\u23CE</kbd> select \u00b7 <kbd>Esc</kbd> cancel</span>' +
103
+ '</div>' +
104
+ '</div>';
105
+ document.body.appendChild(_overlay);
106
+ }
107
+
108
+ function mateIdFrom(target) {
109
+ return null;
110
+ }
111
+
112
+ function bumpMru(list, key) {
113
+ // Mutate the original array to preserve the module-level reference
114
+ // so subscribers / future reads see the update without a reassign.
115
+ var idx = list.indexOf(key);
116
+ if (idx !== -1) list.splice(idx, 1);
117
+ list.unshift(key);
118
+ }
119
+
120
+ function handleKeyDown(e) {
121
+ if (!e.key) return;
122
+ var isMod = (e.metaKey || e.ctrlKey) && !e.altKey;
123
+ var k = e.key.toLowerCase();
124
+
125
+ // Mode shortcuts: Cmd/Ctrl+E (projects) and Cmd/Ctrl+M (mates).
126
+ // Pressing the other shortcut while open switches mode; pressing the
127
+ // same shortcut cycles.
128
+ if (isMod && (k === 'e' || k === 'm')) {
129
+ var requestedMode = k === 'e' ? 'project' : 'mate';
130
+ e.preventDefault();
131
+ e.stopPropagation();
132
+ if (!_open) {
133
+ openSwitcher(requestedMode);
134
+ } else if (_mode !== requestedMode) {
135
+ // Switched modes mid-flight. Rebuild the list for the new mode.
136
+ openSwitcher(requestedMode);
137
+ } else if (e.shiftKey) {
138
+ cycle(-1);
139
+ } else {
140
+ cycle(1);
141
+ }
142
+ return;
143
+ }
144
+
145
+ if (!_open) return;
146
+
147
+ if (e.key === 'Escape') {
148
+ e.preventDefault();
149
+ e.stopPropagation();
150
+ closeSwitcher(false);
151
+ return;
152
+ }
153
+ if (e.key === 'Enter') {
154
+ e.preventDefault();
155
+ e.stopPropagation();
156
+ closeSwitcher(true);
157
+ return;
158
+ }
159
+ if (e.key === 'ArrowRight' || e.key === 'ArrowDown') { e.preventDefault(); cycle(1); return; }
160
+ if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') { e.preventDefault(); cycle(-1); return; }
161
+ }
162
+
163
+ function handleKeyUp(e) {
164
+ if (!_open) return;
165
+ if (e.key === 'Meta' || e.key === 'Control') {
166
+ closeSwitcher(true);
167
+ }
168
+ }
169
+
170
+ function openSwitcher(mode) {
171
+ _mode = mode;
172
+ _entries = buildEntries(mode);
173
+ if (_entries.length === 0) {
174
+ // Nothing to switch to; don't show an empty modal.
175
+ if (_open) closeSwitcher(false);
176
+ return;
177
+ }
178
+ if (_headerEl) {
179
+ _headerEl.textContent = mode === 'mate' ? 'Switch mate' : 'Switch project';
180
+ }
181
+ updateFooterShortcut(mode);
182
+ renderEntries();
183
+ _highlightedIndex = pickInitialIndex();
184
+ paintHighlight();
185
+ _overlay.classList.remove('hidden');
186
+ _open = true;
187
+ refreshIcons();
188
+ // UI chrome matches the rest of Clay by swapping native emoji into
189
+ // Twemoji <img>s (same pattern as title bar, icon strip, project
190
+ // settings). The global COLR font fallback alone isn't reliable for
191
+ // UI surfaces because OS emoji fonts tend to match first.
192
+ parseEmojis(_list);
193
+ }
194
+
195
+ function updateFooterShortcut(mode) {
196
+ var nextKey = _overlay.querySelector('.proj-next-key');
197
+ var prevKey = _overlay.querySelector('.proj-prev-key');
198
+ var letter = mode === 'mate' ? 'M' : 'E';
199
+ if (nextKey) nextKey.textContent = letter;
200
+ if (prevKey) prevKey.textContent = letter;
201
+ }
202
+
203
+ function pickInitialIndex() {
204
+ // Highlight the "previous" selectable entry (Cmd+Tab semantics),
205
+ // while keeping the list in a stable natural order. Uses MRU to
206
+ // find which project/mate was visited before the current one, then
207
+ // locates its position in _entries.
208
+ if (_entries.length === 0) return 0;
209
+ var mru = _mode === 'mate' ? _mateMru : _projectMru;
210
+ var currentKey = currentActiveKey();
211
+ for (var m = 0; m < mru.length; m++) {
212
+ var key = mru[m];
213
+ if (key === currentKey) continue;
214
+ for (var i = 0; i < _entries.length; i++) {
215
+ if (_entries[i].key === key && !_entries[i].disabled) return i;
216
+ }
217
+ }
218
+ // Fallback: first non-current, non-disabled entry.
219
+ for (var j = 0; j < _entries.length; j++) {
220
+ if (!_entries[j].disabled && _entries[j].key !== currentKey) return j;
221
+ }
222
+ for (var d = 0; d < _entries.length; d++) {
223
+ if (!_entries[d].disabled) return d;
224
+ }
225
+ return 0;
226
+ }
227
+
228
+ function currentActiveKey() {
229
+ if (_mode === 'mate') {
230
+ return mateIdFrom(store.get('dmTargetUser'));
231
+ }
232
+ return store.get('currentSlug');
233
+ }
234
+
235
+ function buildEntries(mode) {
236
+ if (mode === 'mate') return buildMateEntries();
237
+ return buildProjectEntries();
238
+ }
239
+
240
+ function buildProjectEntries() {
241
+ var projects = getCachedProjects() || [];
242
+ // Keep natural (server-provided) order so the list looks the same
243
+ // every time the switcher opens. MRU only drives initial highlight.
244
+ return projects.map(function (p) {
245
+ // Worktrees can end up "outside project path" (parent workspace
246
+ // unmounted or moved); those are effectively unreachable from
247
+ // this session and shouldn't be switchable.
248
+ var unreachable = p.isWorktree && p.worktreeAccessible === false;
249
+ return {
250
+ key: p.slug,
251
+ title: p.title || p.project || p.slug,
252
+ icon: p.icon || null,
253
+ fallbackIcon: 'folder',
254
+ isCurrent: p.slug === store.get('currentSlug'),
255
+ disabled: unreachable,
256
+ disabledReason: unreachable ? 'Outside project path' : null,
257
+ };
258
+ });
259
+ }
260
+
261
+ function buildMateEntries() {
262
+ return [];
263
+ }
264
+
265
+ function closeSwitcher(commit) {
266
+ if (!_open) return;
267
+ _open = false;
268
+ _overlay.classList.add('hidden');
269
+ if (!commit) return;
270
+ var entry = _entries[_highlightedIndex];
271
+ if (!entry || entry.disabled) return;
272
+ if (_mode === 'mate') {
273
+ if (entry.key !== currentActiveKey()) openDm(entry.key);
274
+ } else {
275
+ if (entry.key !== store.get('currentSlug')) switchProject(entry.key);
276
+ }
277
+ }
278
+
279
+ function cycle(delta) {
280
+ if (_entries.length === 0) return;
281
+ // Skip over disabled entries so unreachable worktrees aren't part
282
+ // of the cycle. If every entry is disabled (shouldn't happen, since
283
+ // openSwitcher bails on empty lists), fall back to plain stepping.
284
+ var step = delta > 0 ? 1 : -1;
285
+ var idx = _highlightedIndex;
286
+ for (var i = 0; i < _entries.length; i++) {
287
+ idx = (idx + step + _entries.length) % _entries.length;
288
+ if (!_entries[idx].disabled) {
289
+ _highlightedIndex = idx;
290
+ paintHighlight();
291
+ return;
292
+ }
293
+ }
294
+ }
295
+
296
+ function renderEntries() {
297
+ if (!_list) return;
298
+ _list.innerHTML = '';
299
+ for (var i = 0; i < _entries.length; i++) {
300
+ _list.appendChild(buildEntryNode(_entries[i], i));
301
+ }
302
+ }
303
+
304
+ function buildEntryNode(entry, index) {
305
+ var item = document.createElement('button');
306
+ item.type = 'button';
307
+ item.className = 'cmd-palette-item project-switcher-item';
308
+ if (entry.disabled) item.classList.add('disabled');
309
+ if (entry.disabled && entry.disabledReason) item.title = entry.disabledReason;
310
+ item.dataset.index = String(index);
311
+
312
+ var iconWrap = document.createElement('div');
313
+ iconWrap.className = 'cmd-palette-item-icon';
314
+ if (entry.icon) {
315
+ iconWrap.textContent = entry.icon;
316
+ } else if (entry.avatarUrl) {
317
+ var img = document.createElement('img');
318
+ img.src = entry.avatarUrl;
319
+ img.alt = '';
320
+ img.className = 'project-switcher-avatar';
321
+ iconWrap.appendChild(img);
322
+ } else {
323
+ var fallback = document.createElement('i');
324
+ fallback.setAttribute('data-lucide', entry.fallbackIcon || 'folder');
325
+ iconWrap.appendChild(fallback);
326
+ }
327
+ item.appendChild(iconWrap);
328
+
329
+ var body = document.createElement('div');
330
+ body.className = 'cmd-palette-item-body';
331
+ var titleRow = document.createElement('div');
332
+ titleRow.className = 'cmd-palette-item-title-row';
333
+ var title = document.createElement('span');
334
+ title.className = 'cmd-palette-item-title';
335
+ title.textContent = entry.title;
336
+ titleRow.appendChild(title);
337
+ if (entry.isCurrent) {
338
+ var badge = document.createElement('span');
339
+ badge.className = 'project-switcher-current';
340
+ badge.textContent = 'current';
341
+ titleRow.appendChild(badge);
342
+ }
343
+ if (entry.disabled && entry.disabledReason) {
344
+ var reason = document.createElement('span');
345
+ reason.className = 'project-switcher-disabled-reason';
346
+ reason.textContent = entry.disabledReason;
347
+ titleRow.appendChild(reason);
348
+ }
349
+ body.appendChild(titleRow);
350
+ item.appendChild(body);
351
+
352
+ item.addEventListener('mouseenter', function () {
353
+ if (entry.disabled) return;
354
+ _highlightedIndex = index;
355
+ paintHighlight();
356
+ });
357
+ item.addEventListener('click', function () {
358
+ if (entry.disabled) return;
359
+ _highlightedIndex = index;
360
+ closeSwitcher(true);
361
+ });
362
+ return item;
363
+ }
364
+
365
+ function paintHighlight() {
366
+ if (!_list) return;
367
+ var items = _list.querySelectorAll('.cmd-palette-item');
368
+ for (var i = 0; i < items.length; i++) {
369
+ items[i].classList.toggle('active', i === _highlightedIndex);
370
+ }
371
+ var active = items[_highlightedIndex];
372
+ if (active && active.scrollIntoView) {
373
+ active.scrollIntoView({ block: 'nearest' });
374
+ }
375
+ }
@@ -0,0 +1,87 @@
1
+ import { copyToClipboard } from './utils.js';
2
+
3
+ function getShareUrl() {
4
+ var url = window.location.href;
5
+ var h = window.location.hostname;
6
+ if ((h === "localhost" || h === "127.0.0.1") && window.__lanHost) {
7
+ url = url.replace(h + ":" + window.location.port, window.__lanHost);
8
+ }
9
+ return url;
10
+ }
11
+
12
+ export function triggerShare() {
13
+ var url = getShareUrl();
14
+
15
+ // Use Web Share API on mobile only
16
+ var isMobile = window.innerWidth <= 768 || /Mobi|Android/i.test(navigator.userAgent);
17
+ if (isMobile && navigator.share) {
18
+ navigator.share({ title: document.title || "Clagentic:Console", url: url }).catch(function () {});
19
+ return;
20
+ }
21
+
22
+ // Show QR overlay
23
+ var qrOverlay = document.getElementById("qr-overlay");
24
+ var qrCanvas = document.getElementById("qr-canvas");
25
+ var qrUrl = document.getElementById("qr-url");
26
+ var qrShareBtn = document.getElementById("qr-share-btn");
27
+
28
+ var qr = qrcode(0, "M");
29
+ qr.addData(url);
30
+ qr.make();
31
+ qrCanvas.innerHTML = qr.createSvgTag(5, 0);
32
+ qrUrl.innerHTML = url + '<span class="qr-hint">click to copy</span>';
33
+
34
+ // Show browser share button if Web Share API is available
35
+ if (qrShareBtn) {
36
+ if (navigator.share) {
37
+ qrShareBtn.classList.remove("hidden");
38
+ } else {
39
+ qrShareBtn.classList.add("hidden");
40
+ }
41
+ }
42
+
43
+ qrOverlay.classList.remove("hidden");
44
+ }
45
+
46
+ export function initQrCode() {
47
+ var qrOverlay = document.getElementById("qr-overlay");
48
+ var qrUrl = document.getElementById("qr-url");
49
+
50
+ // click URL to copy
51
+ qrUrl.addEventListener("click", function () {
52
+ var url = getShareUrl();
53
+ copyToClipboard(url).then(function () {
54
+ qrUrl.innerHTML = "Copied!";
55
+ qrUrl.classList.add("copied");
56
+ setTimeout(function () {
57
+ qrUrl.innerHTML = url + '<span class="qr-hint">click to copy</span>';
58
+ qrUrl.classList.remove("copied");
59
+ }, 1500);
60
+ });
61
+ });
62
+
63
+ qrOverlay.addEventListener("click", function () {
64
+ qrOverlay.classList.add("hidden");
65
+ });
66
+
67
+ // prevent closing when clicking the inner card
68
+ document.getElementById("qr-overlay-inner").addEventListener("click", function (e) {
69
+ e.stopPropagation();
70
+ });
71
+
72
+ // Browser share button
73
+ var qrShareBtn = document.getElementById("qr-share-btn");
74
+ if (qrShareBtn) {
75
+ qrShareBtn.addEventListener("click", function () {
76
+ var url = getShareUrl();
77
+ navigator.share({ title: document.title || "Clagentic:Console", url: url }).catch(function () {});
78
+ });
79
+ }
80
+
81
+ // ESC to close
82
+ document.addEventListener("keydown", function (e) {
83
+ if (e.key === "Escape" && !qrOverlay.classList.contains("hidden")) {
84
+ qrOverlay.classList.add("hidden");
85
+ }
86
+ });
87
+ }