clay-server 5.1.0-beta.1 → 5.1.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 +4 -0
- package/LICENSES/dicebear-avatars.md +16 -0
- package/bin/cli.js +9 -91
- package/lib/builtin-mates.js +7 -7
- package/lib/daemon-project-access.js +7 -1
- package/lib/daemon-settings.js +11 -0
- package/lib/daemon.js +10 -37
- package/lib/dicebear-avatar.js +62 -0
- package/lib/knowledge-db-service.js +175 -0
- package/lib/knowledge-db-validation.js +0 -0
- package/lib/knowledge-document-index.js +49 -0
- package/lib/knowledge-draft-store.js +56 -0
- package/lib/knowledge-file-store.js +199 -0
- package/lib/knowledge-markdown.js +128 -0
- package/lib/linear-store.js +35 -8
- package/lib/mate-identity-file.js +39 -0
- package/lib/mate-knowledge-mcp-server.js +29 -6
- package/lib/mate-knowledge-service.js +23 -2
- package/lib/mate-knowledge-sync.js +37 -22
- package/lib/mate-ready-creation.js +2 -1
- package/lib/mate-workspace-color.js +4 -0
- package/lib/mates-identity.js +4 -4
- package/lib/mates-prompts.js +4 -3
- package/lib/mates.js +30 -11
- package/lib/os-users.js +5 -16
- package/lib/project-connection.js +36 -9
- package/lib/project-debate-proposal.js +6 -0
- package/lib/project-debate-workspace.js +43 -0
- package/lib/project-debate.js +4 -2
- package/lib/project-filesystem.js +21 -39
- package/lib/project-knowledge.js +315 -136
- package/lib/project-mate-creation-proposal.js +1 -0
- package/lib/project-mate-interaction.js +7 -6
- package/lib/project-server-settings.js +31 -0
- package/lib/project-sessions.js +92 -182
- package/lib/project-user-knowledge.js +60 -0
- package/lib/project.js +62 -21
- package/lib/public/app.js +79 -71
- package/lib/public/clay-studio-wordmark-bold.svg +20 -0
- package/lib/public/css/clay-workspace.css +105 -0
- package/lib/public/css/debates-workbench.css +47 -0
- package/lib/public/css/home-debate-live.css +26 -0
- package/lib/public/css/home-hub.css +3 -1
- package/lib/public/css/home-mate-model-picker.css +15 -131
- package/lib/public/css/home-mate-settings.css +168 -16
- package/lib/public/css/icon-strip.css +249 -32
- package/lib/public/css/input.css +3 -1
- package/lib/public/css/mate-conversation.css +176 -0
- package/lib/public/css/mate-knowledge-workbench.css +118 -0
- package/lib/public/css/mate-workspace-color.css +16 -0
- package/lib/public/css/mates.css +28 -28
- package/lib/public/css/menus.css +3 -0
- package/lib/public/css/messages.css +1 -114
- package/lib/public/css/mobile-nav.css +16 -16
- package/lib/public/css/overlays.css +15 -0
- package/lib/public/css/project-logs.css +7 -0
- package/lib/public/css/project-mate-creation.css +105 -0
- package/lib/public/css/project-settings-modal.css +56 -0
- package/lib/public/css/right-workbench.css +3 -3
- package/lib/public/css/server-settings-system.css +125 -0
- package/lib/public/css/session-folders.css +80 -21
- package/lib/public/css/session-github.css +25 -16
- package/lib/public/css/settings-ui.css +247 -22
- package/lib/public/css/shared-browser.css +7 -3
- package/lib/public/css/sidebar.css +183 -107
- package/lib/public/css/title-bar.css +156 -1
- package/lib/public/css/worker-delegation.css +47 -0
- package/lib/public/css/worker-proposal.css +72 -150
- package/lib/public/css/you.css +74 -0
- package/lib/public/index.html +206 -548
- package/lib/public/modules/account-island.js +232 -0
- package/lib/public/modules/admin-settings-email.js +197 -0
- package/lib/public/modules/admin-settings-invitations.js +183 -0
- package/lib/public/modules/admin-settings-projects.js +198 -0
- package/lib/public/modules/admin-settings-ui.js +100 -0
- package/lib/public/modules/admin-settings-users.js +331 -0
- package/lib/public/modules/admin.js +19 -949
- package/lib/public/modules/app-cursors.js +19 -43
- package/lib/public/modules/app-debate-ui.js +4 -3
- package/lib/public/modules/app-dm.js +0 -2
- package/lib/public/modules/app-header.js +106 -0
- package/lib/public/modules/app-message-router.js +12 -3
- package/lib/public/modules/app-messages.js +47 -61
- package/lib/public/modules/app-notifications.js +4 -7
- package/lib/public/modules/app-projects.js +5 -38
- package/lib/public/modules/app-rate-limit.js +70 -12
- package/lib/public/modules/app-rendering.js +12 -13
- package/lib/public/modules/avatar.js +30 -9
- package/lib/public/modules/chat-render-runtime.js +16 -4
- package/lib/public/modules/command-palette.js +2 -15
- package/lib/public/modules/context-sources.js +27 -18
- package/lib/public/modules/cursor-sharing-preference.js +3 -3
- package/lib/public/modules/debate-controls.js +299 -0
- package/lib/public/modules/debate.js +2 -0
- package/lib/public/modules/debates-workbench.js +339 -0
- package/lib/public/modules/default-ai.js +88 -65
- package/lib/public/modules/header-tui-font.js +10 -20
- package/lib/public/modules/home-debate-controls.js +18 -289
- package/lib/public/modules/home-mate-avatar-editor.js +228 -0
- package/lib/public/modules/home-mate-color-picker.js +66 -0
- package/lib/public/modules/home-mate-creation.js +1 -1
- package/lib/public/modules/home-mate-instructions.js +90 -0
- package/lib/public/modules/home-mate-model-picker.js +80 -271
- package/lib/public/modules/home-mate-profile-editor.js +72 -0
- package/lib/public/modules/home-mate-settings.js +118 -125
- package/lib/public/modules/home-shell.js +3 -0
- package/lib/public/modules/home-surface-boot.js +1 -9
- package/lib/public/modules/icon-strip-tooltip.js +95 -0
- package/lib/public/modules/knowledge-db-edit-state.js +35 -0
- package/lib/public/modules/knowledge-db-workbench.js +234 -0
- package/lib/public/modules/knowledge-history-state.js +55 -0
- package/lib/public/modules/knowledge-markdown-editor.js +57 -0
- package/lib/public/modules/knowledge-preview-links.js +70 -0
- package/lib/public/modules/knowledge-workbench-shell.js +21 -0
- package/lib/public/modules/linear-settings.js +3 -2
- package/lib/public/modules/markdown.js +5 -6
- package/lib/public/modules/mate-knowledge-workbench-state.js +174 -0
- package/lib/public/modules/mate-knowledge-workbench.js +500 -0
- package/lib/public/modules/mate-knowledge.js +11 -3
- package/lib/public/modules/mate-management.js +54 -10
- package/lib/public/modules/mate-sidebar.js +11 -1
- package/lib/public/modules/mate-workspace-color.js +33 -0
- package/lib/public/modules/mention.js +5 -13
- package/lib/public/modules/notification-settings.js +81 -0
- package/lib/public/modules/notifications.js +44 -28
- package/lib/public/modules/personal-settings-dialog.js +51 -0
- package/lib/public/modules/profile.js +66 -24
- package/lib/public/modules/project-chat-identity.js +79 -0
- package/lib/public/modules/project-debate-planning-workspace.js +250 -0
- package/lib/public/modules/project-debate-workspace.js +185 -0
- package/lib/public/modules/project-header-identity.js +127 -0
- package/lib/public/modules/project-logs-render.js +9 -4
- package/lib/public/modules/project-mate-creation-workspace.js +414 -0
- package/lib/public/modules/project-mate-navigation.js +238 -0
- package/lib/public/modules/project-session-navigation.js +29 -0
- package/lib/public/modules/project-settings-environment.js +106 -0
- package/lib/public/modules/project-settings.js +72 -628
- package/lib/public/modules/project-switcher.js +6 -8
- package/lib/public/modules/projects-hub-view.js +5 -6
- package/lib/public/modules/projects-hub.js +2 -6
- package/lib/public/modules/qrcode.js +27 -8
- package/lib/public/modules/search-clay-chat.js +8 -11
- package/lib/public/modules/server-settings-controls.js +316 -0
- package/lib/public/modules/server-settings-environment.js +194 -0
- package/lib/public/modules/server-settings-navigation.js +39 -0
- package/lib/public/modules/server-settings-state.js +54 -0
- package/lib/public/modules/server-settings.js +116 -788
- package/lib/public/modules/server-storage-settings.js +84 -0
- package/lib/public/modules/session-activity-tooltip.js +12 -0
- package/lib/public/modules/session-create-form.js +86 -14
- package/lib/public/modules/session-create.js +50 -7
- package/lib/public/modules/session-github.js +2 -1
- package/lib/public/modules/session-list-visibility.js +41 -0
- package/lib/public/modules/session-presence-ui.js +3 -0
- package/lib/public/modules/session-title-marquee.js +51 -0
- package/lib/public/modules/settings-env-values.js +34 -0
- package/lib/public/modules/settings-select.js +121 -0
- package/lib/public/modules/shared-browser.js +22 -12
- package/lib/public/modules/sidebar-mates.js +3 -50
- package/lib/public/modules/sidebar-mobile.js +63 -60
- package/lib/public/modules/sidebar-projects.js +84 -97
- package/lib/public/modules/sidebar-session-folders-ui.js +2 -2
- package/lib/public/modules/sidebar-session-hierarchy.js +149 -70
- package/lib/public/modules/sidebar-sessions.js +49 -50
- package/lib/public/modules/sidebar.js +11 -13
- package/lib/public/modules/stt-picker.js +14 -5
- package/lib/public/modules/terminal-prefs.js +22 -0
- package/lib/public/modules/theme.js +88 -52
- package/lib/public/modules/thinking-lifecycle.js +7 -6
- package/lib/public/modules/tool-palette-order.js +4 -3
- package/lib/public/modules/tool-palette.js +13 -3
- package/lib/public/modules/tools.js +22 -22
- package/lib/public/modules/user-settings-account.js +318 -0
- package/lib/public/modules/user-settings-appearance.js +55 -0
- package/lib/public/modules/user-settings-editors.js +24 -0
- package/lib/public/modules/user-settings-integrations.js +104 -0
- package/lib/public/modules/user-settings-layout.js +80 -0
- package/lib/public/modules/user-settings-preferences.js +48 -0
- package/lib/public/modules/user-settings-profile.js +53 -0
- package/lib/public/modules/user-settings-themes.js +38 -0
- package/lib/public/modules/user-settings-voice.js +75 -0
- package/lib/public/modules/user-settings.js +53 -480
- package/lib/public/modules/worker-proposal.js +42 -8
- package/lib/public/modules/worker-runtime-picker.js +115 -0
- package/lib/public/modules/you-activity.js +121 -0
- package/lib/public/modules/you.js +251 -0
- package/lib/public/style.css +20 -8
- package/lib/public/vendor/codemirror/LICENSE +21 -0
- package/lib/public/vendor/codemirror/codemirror.css +344 -0
- package/lib/public/vendor/codemirror/codemirror.js +9884 -0
- package/lib/public/vendor/codemirror/continuelist.js +101 -0
- package/lib/public/vendor/codemirror/markdown.js +886 -0
- package/lib/public/vendor/codemirror/show-hint.css +37 -0
- package/lib/public/vendor/codemirror/show-hint.js +523 -0
- package/lib/sdk-bridge.js +15 -3
- package/lib/sdk-message-processor.js +16 -4
- package/lib/sdk-quota-snapshot.js +37 -0
- package/lib/server-admin.js +11 -0
- package/lib/server-appearance-settings.js +71 -0
- package/lib/server-home-chat-events.js +1 -1
- package/lib/server-home-chat.js +25 -3
- package/lib/server-home-debate-planning.js +4 -1
- package/lib/server-home-debates.js +2 -0
- package/lib/server-home-mate-creation.js +4 -1
- package/lib/server-linear.js +14 -8
- package/lib/server-mate-instructions.js +44 -0
- package/lib/server-mates.js +14 -4
- package/lib/server-notification-settings.js +67 -0
- package/lib/server-palette.js +1 -1
- package/lib/server-settings.js +69 -1
- package/lib/server-storage.js +57 -0
- package/lib/server-user-knowledge.js +119 -0
- package/lib/server.js +31 -3
- package/lib/session-visibility.js +7 -2
- package/lib/sessions.js +35 -10
- package/lib/startup-projects.js +40 -0
- package/lib/storage-native-walk.js +85 -0
- package/lib/storage-usage.js +144 -0
- package/lib/user-knowledge-service.js +167 -0
- package/lib/users-permissions.js +7 -0
- package/lib/users-preferences.js +0 -74
- package/lib/users-project-mate-filter-preferences.js +39 -0
- package/lib/users.js +6 -4
- package/lib/workspace-query-access.js +4 -1
- package/lib/ws-schema.js +52 -4
- package/lib/yoke/acp-process-manager.js +2 -2
- package/lib/yoke/adapters/codex.js +12 -52
- package/lib/yoke/codex-app-server.js +2 -2
- package/lib/yoke/codex-model-catalog.js +52 -0
- package/lib/yoke/codex-rate-limits.js +26 -0
- package/package.json +12 -3
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// Existing Mates share the project rail while retaining their conversations.
|
|
2
|
+
import { store } from './store.js';
|
|
3
|
+
import { applyWorkspaceColor } from './mate-workspace-color.js';
|
|
4
|
+
import { mateAvatarUrl } from './avatar.js';
|
|
5
|
+
import { renderMateProjectHeader, renderOrdinaryProjectHeader } from './project-header-identity.js';
|
|
6
|
+
import { getHomeMateName } from './home-mate-selection.js';
|
|
7
|
+
import { switchProject } from './app-projects.js';
|
|
8
|
+
import { closeTerminal } from './terminal.js';
|
|
9
|
+
import { closeFileViewer } from './filebrowser.js';
|
|
10
|
+
import { getActiveMentionMateIds, onMentionActiveChange, bindIconTooltip, hideIconTooltip, showMateCtxMenu } from './sidebar-mates.js';
|
|
11
|
+
|
|
12
|
+
var FILTER_MODES = ['all', 'projects', 'mates'];
|
|
13
|
+
var FILTER_LABELS = { all: 'All', projects: 'Projects', mates: 'Mates' };
|
|
14
|
+
var filterSaveQueue = Promise.resolve();
|
|
15
|
+
|
|
16
|
+
export function normalizeProjectMateFilterMode(mode) {
|
|
17
|
+
return FILTER_MODES.indexOf(mode) === -1 ? 'all' : mode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function advanceProjectMateFilter(mode, turns) {
|
|
21
|
+
var index = FILTER_MODES.indexOf(normalizeProjectMateFilterMode(mode));
|
|
22
|
+
return { mode: FILTER_MODES[(index + 1) % FILTER_MODES.length], turns: (Number(turns) || 0) + 1 };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function applyProjectMateFilter() {
|
|
26
|
+
var rail = document.getElementById('icon-strip-projects');
|
|
27
|
+
var knob = document.getElementById('icon-strip-filter-knob');
|
|
28
|
+
if (!rail || !knob) return;
|
|
29
|
+
var mode = normalizeProjectMateFilterMode(store.get('projectMateFilterMode'));
|
|
30
|
+
var turns = Number(store.get('projectMateFilterTurns')) || 0;
|
|
31
|
+
var next = FILTER_MODES[(FILTER_MODES.indexOf(mode) + 1) % FILTER_MODES.length];
|
|
32
|
+
rail.dataset.filterMode = mode;
|
|
33
|
+
knob.dataset.mode = mode;
|
|
34
|
+
knob.setAttribute('aria-label', 'Showing ' + FILTER_LABELS[mode].toLowerCase() + '. Activate to show ' + FILTER_LABELS[next].toLowerCase());
|
|
35
|
+
knob.querySelector('.icon-strip-filter-pointer').style.transform = 'rotate(' + (turns * 120) + 'deg)';
|
|
36
|
+
document.getElementById('icon-strip-filter-label').textContent = FILTER_LABELS[mode];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function saveProjectMateFilter(mode) {
|
|
40
|
+
filterSaveQueue = filterSaveQueue.catch(function () {}).then(function () {
|
|
41
|
+
return fetch('/api/user/project-mate-filter', {
|
|
42
|
+
method: 'PUT',
|
|
43
|
+
headers: { 'Content-Type': 'application/json' },
|
|
44
|
+
credentials: 'same-origin',
|
|
45
|
+
keepalive: true,
|
|
46
|
+
body: JSON.stringify({ mode: mode })
|
|
47
|
+
});
|
|
48
|
+
}).catch(function () {});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function activateProjectMateFilter() {
|
|
52
|
+
var next = advanceProjectMateFilter(store.get('projectMateFilterMode'), store.get('projectMateFilterTurns'));
|
|
53
|
+
store.set({ projectMateFilterMode: next.mode, projectMateFilterTurns: next.turns, projectMateFilterActivated: true });
|
|
54
|
+
saveProjectMateFilter(next.mode);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function restoreProjectMateFilter() {
|
|
58
|
+
fetch('/api/profile', { credentials: 'same-origin' }).then(function (response) {
|
|
59
|
+
if (!response.ok) throw new Error('Unable to restore project and Mate filter');
|
|
60
|
+
return response.json();
|
|
61
|
+
}).then(function (profile) {
|
|
62
|
+
if (store.get('projectMateFilterActivated')) return;
|
|
63
|
+
var mode = normalizeProjectMateFilterMode(profile.projectMateFilterMode);
|
|
64
|
+
store.set({ projectMateFilterMode: mode, projectMateFilterTurns: FILTER_MODES.indexOf(mode) });
|
|
65
|
+
}).catch(function () {});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function navigationMates(mates) {
|
|
69
|
+
return (Array.isArray(mates) ? mates : []).filter(function (mate) {
|
|
70
|
+
return mate && mate.id && !mate.archived;
|
|
71
|
+
}).sort(function (a, b) {
|
|
72
|
+
var aClay = a.builtinKey === 'clay' ? 0 : 1;
|
|
73
|
+
var bClay = b.builtinKey === 'clay' ? 0 : 1;
|
|
74
|
+
return aClay - bClay || (a.createdAt || 0) - (b.createdAt || 0);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function isMateWorkspace(state) {
|
|
79
|
+
return (!!state.activeProjectMateId && state.activeProjectSlug === state.currentSlug) || (state.projectsHubList || []).some(function (project) {
|
|
80
|
+
return project.slug === state.currentSlug && project.isMate === true;
|
|
81
|
+
}) || navigationMates(state.cachedMatesList).some(function (mate) {
|
|
82
|
+
return state.currentSlug === 'mate-' + mate.id;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function mateForWorkspace(state) {
|
|
87
|
+
var mates = navigationMates(state.cachedMatesList);
|
|
88
|
+
for (var i = 0; i < mates.length; i++) if (state.currentSlug === 'mate-' + mates[i].id) return mates[i];
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function renderMateHeaderDefault(state) {
|
|
93
|
+
var mate = mateForWorkspace(state);
|
|
94
|
+
if (!mate || state.homeShellVisible) {
|
|
95
|
+
renderOrdinaryProjectHeader(state);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
renderMateProjectHeader(state, mate);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function openMateWorkspace(mateId) {
|
|
102
|
+
var mate = navigationMates(store.get('cachedMatesList')).find(function (item) { return item.id === mateId; });
|
|
103
|
+
if (!mate) return;
|
|
104
|
+
if (store.get('currentSlug') !== 'mate-' + mateId) {
|
|
105
|
+
closeTerminal();
|
|
106
|
+
closeFileViewer();
|
|
107
|
+
}
|
|
108
|
+
switchProject('mate-' + mateId);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function createMateIcon(mateId) {
|
|
112
|
+
var button = document.createElement('button');
|
|
113
|
+
button.type = 'button';
|
|
114
|
+
button.className = 'icon-strip-item icon-strip-project-mate';
|
|
115
|
+
button.dataset.mateId = mateId;
|
|
116
|
+
button.innerHTML = '<img class="icon-strip-mate-avatar" alt="" draggable="false"><span class="icon-strip-pill"></span><span class="icon-strip-status"></span><span class="icon-strip-project-badge"></span>';
|
|
117
|
+
button.addEventListener('click', function () {
|
|
118
|
+
hideIconTooltip();
|
|
119
|
+
openMateWorkspace(mateId);
|
|
120
|
+
});
|
|
121
|
+
bindIconTooltip(button, function () {
|
|
122
|
+
var mate = navigationMates(store.get('cachedMatesList')).find(function (item) { return item.id === mateId; });
|
|
123
|
+
return {
|
|
124
|
+
text: mate ? getHomeMateName(mate) : 'Mate',
|
|
125
|
+
kind: 'mate',
|
|
126
|
+
avatarUrl: mate ? mateAvatarUrl(mate, 24) : '',
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
button.addEventListener('contextmenu', function (event) {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
var mate = navigationMates(store.get('cachedMatesList')).find(function (item) { return item.id === mateId; });
|
|
132
|
+
if (mate) showMateCtxMenu(button, mate);
|
|
133
|
+
});
|
|
134
|
+
return button;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function renderProjectMates() {
|
|
138
|
+
var rail = document.getElementById('icon-strip-projects');
|
|
139
|
+
if (!rail) return;
|
|
140
|
+
hideIconTooltip();
|
|
141
|
+
var state = store.snap();
|
|
142
|
+
var clay = navigationMates(state.cachedMatesList).find(function (mate) { return mate.builtinKey === 'clay'; });
|
|
143
|
+
var clayActive = !!clay && !state.homeShellVisible && !state.dmMode && state.currentSlug === 'mate-' + clay.id;
|
|
144
|
+
document.body.classList.toggle('clay-workspace-active', clayActive);
|
|
145
|
+
var clayEntry = document.querySelector('.icon-strip-brand');
|
|
146
|
+
if (clayEntry) {
|
|
147
|
+
clayEntry.disabled = !clay;
|
|
148
|
+
clayEntry.classList.toggle('active', clayActive);
|
|
149
|
+
clayEntry.setAttribute('aria-label', clay ? 'Open Clay' : 'Clay is unavailable');
|
|
150
|
+
if (clayActive) clayEntry.setAttribute('aria-current', 'page');
|
|
151
|
+
else clayEntry.removeAttribute('aria-current');
|
|
152
|
+
}
|
|
153
|
+
document.body.classList.toggle('mate-workspace-active', !state.homeShellVisible && isMateWorkspace(state));
|
|
154
|
+
applyWorkspaceColor(mateForWorkspace(state));
|
|
155
|
+
renderMateHeaderDefault(state);
|
|
156
|
+
var mates = navigationMates(state.cachedMatesList).filter(function (mate) {
|
|
157
|
+
return mate.builtinKey !== 'clay';
|
|
158
|
+
});
|
|
159
|
+
var mentionActive = getActiveMentionMateIds();
|
|
160
|
+
var projects = state.projectsHubList || [];
|
|
161
|
+
var unread = state.dmUnread || {};
|
|
162
|
+
var icons = {};
|
|
163
|
+
rail.querySelectorAll('[data-mate-id]').forEach(function (button) { icons[button.dataset.mateId] = button; });
|
|
164
|
+
mates.forEach(function (mate) {
|
|
165
|
+
var button = icons[mate.id] || createMateIcon(mate.id);
|
|
166
|
+
delete icons[mate.id];
|
|
167
|
+
var active = !state.homeShellVisible && !state.dmMode && state.currentSlug === 'mate-' + mate.id;
|
|
168
|
+
var project = projects.find(function (item) { return item.slug === 'mate-' + mate.id; });
|
|
169
|
+
var busy = !!(project && project.isProcessing) || !!mentionActive[mate.id];
|
|
170
|
+
var count = active ? 0 : (unread[mate.id] || 0);
|
|
171
|
+
button.classList.toggle('active', !!active);
|
|
172
|
+
button.setAttribute('aria-label', getHomeMateName(mate) + ', Mate' + (busy ? ', working' : '') + (count ? ', ' + count + ' unread' : ''));
|
|
173
|
+
if (active) button.setAttribute('aria-current', 'page');
|
|
174
|
+
else button.removeAttribute('aria-current');
|
|
175
|
+
var avatar = button.querySelector('img');
|
|
176
|
+
var url = mateAvatarUrl(mate, 38);
|
|
177
|
+
if (avatar.getAttribute('src') !== url) avatar.src = url;
|
|
178
|
+
var status = button.querySelector('.icon-strip-status');
|
|
179
|
+
status.classList.toggle('processing', busy);
|
|
180
|
+
status.classList.toggle('connected', !!state.connected);
|
|
181
|
+
var badge = button.querySelector('.icon-strip-project-badge');
|
|
182
|
+
badge.classList.toggle('has-unread', count > 0);
|
|
183
|
+
badge.textContent = count > 99 ? '99+' : count ? String(count) : '';
|
|
184
|
+
if (!button.parentNode) rail.appendChild(button);
|
|
185
|
+
});
|
|
186
|
+
Object.keys(icons).forEach(function (id) { icons[id].remove(); });
|
|
187
|
+
var ordered = Array.from(rail.querySelectorAll('[data-mate-id]'));
|
|
188
|
+
mates.forEach(function (mate, index) {
|
|
189
|
+
var button = ordered.find(function (item) { return item.dataset.mateId === mate.id; });
|
|
190
|
+
if (ordered[index] === button) return;
|
|
191
|
+
rail.insertBefore(button, ordered[index] || null);
|
|
192
|
+
ordered.splice(ordered.indexOf(button), 1);
|
|
193
|
+
ordered.splice(index, 0, button);
|
|
194
|
+
});
|
|
195
|
+
var separator = rail.querySelector('.icon-strip-peer-separator');
|
|
196
|
+
var hasProjects = !!rail.querySelector(':scope > .icon-strip-item[data-slug], :scope > .icon-strip-group');
|
|
197
|
+
if (hasProjects && mates.length) {
|
|
198
|
+
if (!separator) {
|
|
199
|
+
separator = document.createElement('div');
|
|
200
|
+
separator.className = 'icon-strip-peer-separator';
|
|
201
|
+
}
|
|
202
|
+
var firstMate = rail.querySelector(':scope > [data-mate-id]');
|
|
203
|
+
if (firstMate) rail.insertBefore(separator, firstMate);
|
|
204
|
+
} else if (separator) {
|
|
205
|
+
separator.remove();
|
|
206
|
+
}
|
|
207
|
+
rail.querySelectorAll('[data-slug]').forEach(function (item) {
|
|
208
|
+
item.classList.toggle('active', !state.homeShellVisible && !state.dmMode && item.dataset.slug === state.currentSlug);
|
|
209
|
+
});
|
|
210
|
+
var home = document.querySelector('.icon-strip-home');
|
|
211
|
+
if (home && !home.classList.contains('icon-strip-brand')) home.classList.toggle('active', !!state.homeShellVisible);
|
|
212
|
+
applyProjectMateFilter();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function initProjectMateNavigation() {
|
|
216
|
+
var clayEntry = document.querySelector('.icon-strip-brand');
|
|
217
|
+
if (clayEntry) {
|
|
218
|
+
clayEntry.addEventListener('click', function () {
|
|
219
|
+
var clay = navigationMates(store.get('cachedMatesList')).find(function (mate) { return mate.builtinKey === 'clay'; });
|
|
220
|
+
hideIconTooltip();
|
|
221
|
+
if (clay) openMateWorkspace(clay.id);
|
|
222
|
+
});
|
|
223
|
+
bindIconTooltip(clayEntry, { text: 'Clay', kind: 'mate', avatarUrl: 'clay-studio-symbol.png' });
|
|
224
|
+
}
|
|
225
|
+
var knob = document.getElementById('icon-strip-filter-knob');
|
|
226
|
+
if (knob) knob.addEventListener('click', activateProjectMateFilter);
|
|
227
|
+
store.subscribe(function (state, previous) {
|
|
228
|
+
if (state.cachedMatesList !== previous.cachedMatesList || state.homeChatMateId !== previous.homeChatMateId ||
|
|
229
|
+
state.homeShellVisible !== previous.homeShellVisible || state.projectsHubList !== previous.projectsHubList ||
|
|
230
|
+
state.dmUnread !== previous.dmUnread || state.currentSlug !== previous.currentSlug ||
|
|
231
|
+
state.dmMode !== previous.dmMode || state.connected !== previous.connected) renderProjectMates();
|
|
232
|
+
if (state.projectMateFilterMode !== previous.projectMateFilterMode ||
|
|
233
|
+
state.projectMateFilterTurns !== previous.projectMateFilterTurns) applyProjectMateFilter();
|
|
234
|
+
});
|
|
235
|
+
onMentionActiveChange(renderProjectMates);
|
|
236
|
+
renderProjectMates();
|
|
237
|
+
restoreProjectMateFilter();
|
|
238
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Exact project/session navigation shared by search, notifications and links.
|
|
2
|
+
import { store } from './store.js';
|
|
3
|
+
import { getWs } from './ws-ref.js';
|
|
4
|
+
import { switchProject } from './app-projects.js';
|
|
5
|
+
|
|
6
|
+
function flush() {
|
|
7
|
+
var pending = store.get('pendingProjectSessionNavigation');
|
|
8
|
+
var ws = getWs();
|
|
9
|
+
if (!pending || store.get('activeProjectSlug') !== pending.projectSlug || !ws || ws.readyState !== 1) return false;
|
|
10
|
+
store.set({ pendingProjectSessionNavigation: null });
|
|
11
|
+
ws.send(JSON.stringify({ type: 'switch_session', id: pending.sessionId }));
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function openProjectSession(projectSlug, sessionId) {
|
|
16
|
+
var id = Number(sessionId);
|
|
17
|
+
if (!projectSlug || !Number.isSafeInteger(id) || id < 1) return false;
|
|
18
|
+
store.set({ pendingProjectSessionNavigation: { projectSlug: projectSlug, sessionId: id } });
|
|
19
|
+
switchProject(projectSlug);
|
|
20
|
+
flush();
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function initProjectSessionNavigation() {
|
|
25
|
+
store.subscribe(function (state, previous) {
|
|
26
|
+
if (state.activeProjectSlug !== previous.activeProjectSlug || state.connected !== previous.connected || state.pendingProjectSessionNavigation !== previous.pendingProjectSessionNavigation) flush();
|
|
27
|
+
});
|
|
28
|
+
flush();
|
|
29
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { refreshIcons } from './icons.js';
|
|
2
|
+
import { store } from './store.js';
|
|
3
|
+
import { getWs } from './ws-ref.js';
|
|
4
|
+
import { parseEnvString, serializeEnvValue, looksLikeEnv } from './settings-env-values.js';
|
|
5
|
+
|
|
6
|
+
function state() { return store.get('projectEnvironmentEditor') || {}; }
|
|
7
|
+
function update(values) { store.set({ projectEnvironmentEditor: Object.assign({}, state(), values) }); }
|
|
8
|
+
function status(text) { document.getElementById('ps-env-save-status').textContent = text; }
|
|
9
|
+
function send(message) {
|
|
10
|
+
var ws = getWs();
|
|
11
|
+
if (!ws || ws.readyState !== 1) { status('Disconnected. Your draft is kept. Reconnect and try again.'); return false; }
|
|
12
|
+
ws.send(JSON.stringify(message)); return true;
|
|
13
|
+
}
|
|
14
|
+
export function projectEnvironmentDirty() { return state().slug === store.get("projectSettingsSlug") && !!(state().dirty || state().saving); }
|
|
15
|
+
export function openProjectEnvironment(slug) {
|
|
16
|
+
if (state().slug === slug && (state().loaded || state().loading || state().dirty)) return;
|
|
17
|
+
var cached = Object.assign({}, store.get('projectEnvironmentDrafts') || {});
|
|
18
|
+
if (state().slug && state().dirty) cached[state().slug] = state();
|
|
19
|
+
store.set({ projectEnvironmentDrafts: cached });
|
|
20
|
+
if (cached[slug]) { store.set({ projectEnvironmentEditor: cached[slug] }); render(); status('Unsaved changes'); return; }
|
|
21
|
+
update({ slug: slug, saved: '', rows: [], dirty: false, loaded: false, loading: false, editing: false, saving: false });
|
|
22
|
+
render(); status('Loading…');
|
|
23
|
+
var requestId = crypto.randomUUID();
|
|
24
|
+
update({ requestId: requestId });
|
|
25
|
+
if (send({ type: 'get_project_env', slug: slug, requestId: requestId })) update({ loading: true });
|
|
26
|
+
}
|
|
27
|
+
export function handleProjectEnv(msg) {
|
|
28
|
+
if (!state().loading || (msg.slug !== state().slug || msg.requestId !== state().requestId)) return;
|
|
29
|
+
update({ loading: false });
|
|
30
|
+
if (msg.error) { status(msg.error); return; }
|
|
31
|
+
update({ loaded: true, saved: msg.envrc || '', rows: parseEnvString(msg.envrc || '') });
|
|
32
|
+
render(); status('');
|
|
33
|
+
}
|
|
34
|
+
function changeRows(rows) { update({ rows: rows, dirty: true }); document.getElementById('ps-env-save').disabled = false; status('Unsaved changes'); }
|
|
35
|
+
function render() {
|
|
36
|
+
var editor = state();
|
|
37
|
+
var list = document.getElementById('ps-env-list'); list.replaceChildren();
|
|
38
|
+
(editor.rows || []).forEach(function (entry, index) {
|
|
39
|
+
var row = document.createElement('div'); row.className = 'ps-env-row';
|
|
40
|
+
var key = document.createElement('input'); key.className = 'ps-env-key'; key.value = entry.key; key.placeholder = 'KEY'; key.setAttribute('aria-label', 'Variable name');
|
|
41
|
+
var value = document.createElement('input'); value.className = 'ps-env-val'; value.type = 'password'; value.value = entry.value; value.placeholder = 'Value'; value.setAttribute('aria-label', 'Variable value');
|
|
42
|
+
[key, value].forEach(function (input) { input.autocomplete = 'off'; input.spellcheck = false; input.disabled = !!editor.saving; });
|
|
43
|
+
function changed() {
|
|
44
|
+
var rows = state().rows.slice(); rows[index] = { key: key.value, value: value.value }; changeRows(rows);
|
|
45
|
+
}
|
|
46
|
+
key.addEventListener('input', changed); value.addEventListener('input', changed);
|
|
47
|
+
key.addEventListener('paste', function (event) {
|
|
48
|
+
var text = event.clipboardData.getData('text');
|
|
49
|
+
if (!looksLikeEnv(text)) return;
|
|
50
|
+
event.preventDefault(); var rows = state().rows.slice();
|
|
51
|
+
rows.splice.apply(rows, [index, 1].concat(parseEnvString(text))); changeRows(rows); render();
|
|
52
|
+
});
|
|
53
|
+
var remove = document.createElement('button'); remove.className = 'ps-env-del'; remove.textContent = '×'; remove.setAttribute('aria-label', 'Remove variable'); remove.disabled = !!editor.saving;
|
|
54
|
+
remove.onclick = function () { var rows = state().rows.slice(); rows.splice(index, 1); changeRows(rows); render(); };
|
|
55
|
+
remove.innerHTML = '<i data-lucide="x"></i>';
|
|
56
|
+
var reveal = document.createElement('button'); reveal.type = 'button'; reveal.className = 'settings-btn-sm'; reveal.textContent = 'Show';
|
|
57
|
+
reveal.setAttribute('aria-label', 'Show variable value'); reveal.setAttribute('aria-pressed', 'false');
|
|
58
|
+
reveal.onclick = function () { var visible = value.type === 'password'; value.type = visible ? 'text' : 'password'; reveal.textContent = visible ? 'Hide' : 'Show'; reveal.setAttribute('aria-pressed', String(visible)); };
|
|
59
|
+
row.append(key, value, reveal, remove); list.appendChild(row);
|
|
60
|
+
});
|
|
61
|
+
document.getElementById('ps-env-add-btn').disabled = !editor.loaded || !!editor.saving;
|
|
62
|
+
document.getElementById('ps-env-save').disabled = !editor.loaded || !editor.dirty || !!editor.saving;
|
|
63
|
+
refreshIcons();
|
|
64
|
+
}
|
|
65
|
+
function clearCachedDraft() {
|
|
66
|
+
var cached = Object.assign({}, store.get('projectEnvironmentDrafts') || {}); delete cached[state().slug]; store.set({ projectEnvironmentDrafts: cached });
|
|
67
|
+
}
|
|
68
|
+
export function discardProjectEnvironment() {
|
|
69
|
+
clearCachedDraft();
|
|
70
|
+
update({ rows: parseEnvString(state().saved || ''), editing: false, dirty: false }); render(); status(''); document.getElementById('ps-env-add-btn').focus();
|
|
71
|
+
}
|
|
72
|
+
export function handleProjectEnvSaved(msg) {
|
|
73
|
+
if (!state().saving || (msg.slug !== state().slug || msg.requestId !== state().requestId)) return;
|
|
74
|
+
update({ saving: false });
|
|
75
|
+
if (!msg.ok) { render(); status(msg.error || 'Save failed. Your draft is kept.'); return; }
|
|
76
|
+
clearCachedDraft();
|
|
77
|
+
update({ saved: state().submitted, dirty: false, editing: false });
|
|
78
|
+
render(); document.getElementById('ps-env-add-btn').focus(); status('Saved. ' + (msg.timing || 'Applies to newly created coding-agent processes.'));
|
|
79
|
+
}
|
|
80
|
+
function save() {
|
|
81
|
+
var names = {};
|
|
82
|
+
var rows = state().rows || [];
|
|
83
|
+
for (var i = 0; i < rows.length; i++) {
|
|
84
|
+
var key = rows[i].key.trim();
|
|
85
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) { status('Enter a valid name for every variable.'); return; }
|
|
86
|
+
if (Object.prototype.hasOwnProperty.call(names, key)) { status('Each variable needs a unique name.'); return; }
|
|
87
|
+
names[key] = true;
|
|
88
|
+
}
|
|
89
|
+
var envrc = rows.map(function (row) { return 'export ' + row.key.trim() + '=' + serializeEnvValue(row.value); }).join('\n');
|
|
90
|
+
var requestId = crypto.randomUUID();
|
|
91
|
+
update({ requestId: requestId });
|
|
92
|
+
if (!send({ type: 'set_project_env', slug: state().slug, envrc: envrc, requestId: requestId })) return;
|
|
93
|
+
update({ submitted: envrc, saving: true }); render(); status('Saving…');
|
|
94
|
+
}
|
|
95
|
+
export function initProjectEnvironment() {
|
|
96
|
+
document.getElementById('ps-env-add-btn').onclick = function () { changeRows((state().rows || []).concat([{ key: '', value: '' }])); render(); document.querySelector('#ps-env-list .ps-env-row:last-child input').focus(); };
|
|
97
|
+
document.getElementById('ps-env-save').onclick = save;
|
|
98
|
+
store.subscribe(function (next, previous) {
|
|
99
|
+
if (next.myUserId !== previous.myUserId) {
|
|
100
|
+
store.set({ projectEnvironmentEditor: {}, projectEnvironmentDrafts: {} }); render(); status(''); return;
|
|
101
|
+
}
|
|
102
|
+
if (previous.connected && !next.connected && (state().saving || state().loading)) {
|
|
103
|
+
update({ saving: false, loading: false }); render(); status('Disconnected. Your draft is kept. Reconnect and try again.');
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|