clay-server 4.0.1-beta.1 → 4.1.0-beta.10
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/LICENSE +661 -21
- package/LICENSES/MIT-legacy.txt +21 -0
- package/LICENSES/README.md +7 -0
- package/README.md +2 -2
- package/bin/cli.js +1 -3
- package/lib/ask-user-request-identity.js +23 -0
- package/lib/autonomous-run-record.js +32 -0
- package/lib/autonomous-run-scheduler.js +92 -0
- package/lib/context-usage.js +47 -0
- package/lib/daemon-project-access.js +118 -0
- package/lib/daemon-projects.js +19 -5
- package/lib/daemon.js +19 -20
- package/lib/default-ai-runtime.js +117 -0
- package/lib/durable-scheduler-record.js +61 -0
- package/lib/durable-scheduler-store.js +185 -0
- package/lib/durable-scheduler.js +495 -0
- package/lib/git-cli.js +1 -0
- package/lib/issue-work-session.js +10 -0
- package/lib/issues-comments.js +40 -0
- package/lib/issues-commit-verification.js +30 -0
- package/lib/issues-mcp-server.js +27 -0
- package/lib/issues-schema.js +119 -0
- package/lib/issues-service.js +339 -0
- package/lib/issues-store.js +210 -0
- package/lib/loop-cron.js +47 -0
- package/lib/loop-durable-schedule.js +159 -0
- package/lib/loop-guidance.js +35 -0
- package/lib/loop-registry-occurrence.js +76 -0
- package/lib/model-entry.js +15 -0
- package/lib/project-ask-user.js +4 -1
- package/lib/project-autonomous-run.js +498 -0
- package/lib/project-capsule-turn.js +1 -0
- package/lib/project-connection.js +8 -1
- package/lib/project-delegated-session.js +1 -0
- package/lib/project-filesystem.js +10 -10
- package/lib/project-full-access.js +86 -0
- package/lib/project-http.js +3 -1
- package/lib/project-issue-launch.js +154 -0
- package/lib/project-issues.js +58 -0
- package/lib/project-logs-access-scope.js +94 -0
- package/lib/project-logs-mcp-server.js +8 -12
- package/lib/project-logs-query.js +3 -0
- package/lib/project-logs-service.js +86 -84
- package/lib/project-logs-store.js +5 -3
- package/lib/project-loop-interview.js +163 -0
- package/lib/project-loop.js +150 -64
- package/lib/project-message-delivery.js +4 -2
- package/lib/project-models.js +71 -3
- package/lib/project-notifications.js +1 -1
- package/lib/project-pair-autonomous-stop.js +16 -0
- package/lib/project-pair-lifecycle.js +140 -102
- package/lib/project-pair-message.js +50 -0
- package/lib/project-pair-owned-stop.js +18 -0
- package/lib/project-pair-replacement-state.js +72 -0
- package/lib/project-pair-task-control.js +277 -0
- package/lib/project-pair-usage.js +76 -0
- package/lib/project-pending-message-queue.js +328 -0
- package/lib/project-scheduled-messages.js +499 -0
- package/lib/project-scheduled-task-execution.js +236 -0
- package/lib/project-scheduled-tasks.js +481 -0
- package/lib/project-session-notes.js +11 -4
- package/lib/project-session-pair.js +123 -127
- package/lib/project-sessions.js +143 -32
- package/lib/project-tool-llm-runtime.js +48 -0
- package/lib/project-user-message.js +224 -62
- package/lib/project-worker-proposal.js +69 -58
- package/lib/project-workspace-query.js +25 -0
- package/lib/project.js +396 -73
- package/lib/public/app.js +96 -26
- package/lib/public/css/default-ai.css +33 -0
- package/lib/public/css/home-hub.css +15 -2
- package/lib/public/css/home-sidebar.css +50 -2
- package/lib/public/css/icon-strip.css +40 -0
- package/lib/public/css/input.css +160 -114
- package/lib/public/css/issues.css +101 -0
- package/lib/public/css/mates.css +0 -1
- package/lib/public/css/messages.css +19 -0
- package/lib/public/css/pane.css +98 -2
- package/lib/public/css/pending-message-queue.css +190 -0
- package/lib/public/css/rewind.css +11 -2
- package/lib/public/css/scheduled-tasks.css +122 -0
- package/lib/public/css/sticky-notes.css +24 -4
- package/lib/public/index.html +43 -150
- package/lib/public/modules/app-connection.js +3 -0
- package/lib/public/modules/app-cursors.js +29 -12
- package/lib/public/modules/app-loop-ui.js +4 -8
- package/lib/public/modules/app-message-router.js +8 -0
- package/lib/public/modules/app-messages.js +38 -22
- package/lib/public/modules/app-notifications.js +2 -0
- package/lib/public/modules/app-panels.js +9 -1
- package/lib/public/modules/app-projects.js +3 -0
- package/lib/public/modules/app-rate-limit.js +0 -179
- package/lib/public/modules/ask-user-state.js +66 -0
- package/lib/public/modules/autonomous-run.js +285 -0
- package/lib/public/modules/chat-render-runtime.js +0 -2
- package/lib/public/modules/clay-file-links.js +111 -0
- package/lib/public/modules/clay-issue-links.js +131 -0
- package/lib/public/modules/clay-log-links.js +2 -0
- package/lib/public/modules/cursor-sharing-preference.js +38 -0
- package/lib/public/modules/default-ai.js +377 -0
- package/lib/public/modules/filebrowser.js +43 -2
- package/lib/public/modules/home-sidebar.js +16 -8
- package/lib/public/modules/home-surface.js +5 -0
- package/lib/public/modules/input.js +92 -40
- package/lib/public/modules/issues-context.js +117 -0
- package/lib/public/modules/issues-render.js +29 -0
- package/lib/public/modules/issues.js +270 -0
- package/lib/public/modules/loop-interview.js +151 -0
- package/lib/public/modules/markdown.js +4 -0
- package/lib/public/modules/message-delivery.js +5 -3
- package/lib/public/modules/pending-message-image-editor.js +143 -0
- package/lib/public/modules/pending-message-queue-model.js +22 -0
- package/lib/public/modules/pending-message-queue.js +491 -0
- package/lib/public/modules/permission-hints.js +13 -0
- package/lib/public/modules/project-access.js +141 -0
- package/lib/public/modules/project-grouping.js +22 -0
- package/lib/public/modules/project-logs.js +2 -2
- package/lib/public/modules/scheduled-message-state.js +22 -0
- package/lib/public/modules/scheduled-task-edit-state.js +7 -0
- package/lib/public/modules/scheduled-task-engine.js +48 -0
- package/lib/public/modules/scheduled-task-form.js +122 -0
- package/lib/public/modules/scheduled-task-recurrence.js +46 -0
- package/lib/public/modules/scheduled-task-schedule-rule.js +115 -0
- package/lib/public/modules/scheduled-tasks.js +459 -0
- package/lib/public/modules/scheduler-config.js +6 -52
- package/lib/public/modules/scheduler.js +9 -21
- package/lib/public/modules/sidebar-mobile.js +3 -0
- package/lib/public/modules/sidebar-projects.js +14 -171
- package/lib/public/modules/sidebar.js +0 -11
- package/lib/public/modules/split-pair-ui.js +5 -0
- package/lib/public/modules/split-view.js +3 -0
- package/lib/public/modules/sticky-note-markdown.js +1 -0
- package/lib/public/modules/sticky-notes-browser.js +1 -1
- package/lib/public/modules/sticky-notes.js +117 -4
- package/lib/public/modules/terminal.js +2 -0
- package/lib/public/modules/tool-palette-order.js +3 -3
- package/lib/public/modules/tools.js +26 -5
- package/lib/public/modules/worker-proposal.js +4 -0
- package/lib/public/style.css +3 -0
- package/lib/record-revision.js +11 -0
- package/lib/schedule-rule.js +151 -0
- package/lib/schedule-validation.js +124 -0
- package/lib/scheduled-run-state.js +87 -0
- package/lib/scheduled-task-records.js +127 -0
- package/lib/scheduler.js +179 -196
- package/lib/sdk-bridge.js +191 -22
- package/lib/sdk-message-processor.js +32 -2
- package/lib/sdk-turn-queue.js +14 -0
- package/lib/server-admin.js +3 -3
- package/lib/server-cursor-sharing.js +65 -0
- package/lib/server-default-ai.js +265 -0
- package/lib/server-durable-scheduler.js +26 -0
- package/lib/server-global-ws.js +10 -0
- package/lib/server-home-chat.js +29 -9
- package/lib/server-home-clay-entry.js +4 -1
- package/lib/server-home-debate-planning.js +32 -14
- package/lib/server-home-mate-creation.js +30 -11
- package/lib/server-home-models.js +14 -6
- package/lib/server-issue-links.js +18 -0
- package/lib/server-mates.js +4 -3
- package/lib/server-palette.js +17 -14
- package/lib/server.js +247 -102
- package/lib/session-notes-mcp-server.js +2 -2
- package/lib/session-pair-factory.js +45 -4
- package/lib/session-pair-history.js +40 -0
- package/lib/session-pair-mcp-server.js +22 -4
- package/lib/session-pair-operation.js +11 -0
- package/lib/session-pair-prompts.js +31 -2
- package/lib/session-pair-query-start.js +22 -0
- package/lib/session-pair-turn-control.js +8 -3
- package/lib/session-provenance.js +1 -0
- package/lib/session-query-tool-bridge.js +52 -0
- package/lib/session-search.js +4 -1
- package/lib/session-spawn-mcp-server.js +2 -1
- package/lib/session-split-groups.js +35 -1
- package/lib/sessions.js +53 -3
- package/lib/tool-llm.js +1 -0
- package/lib/users-default-ai-preferences.js +80 -0
- package/lib/users-home-surface-preferences.js +2 -1
- package/lib/users-preferences.js +35 -0
- package/lib/users-scheduled-task-preferences.js +44 -0
- package/lib/users.js +16 -0
- package/lib/worker-proposal-control.js +69 -0
- package/lib/worker-proposal-decision.js +7 -0
- package/lib/worker-runtime-catalog.js +52 -0
- package/lib/workspace-query-access.js +3 -2
- package/lib/workspace-query-projection.js +29 -0
- package/lib/workspace-query-service.js +20 -30
- package/lib/worktree.js +8 -4
- package/lib/ws-schema.js +62 -1
- package/lib/yoke/adapters/antigravity.js +1 -0
- package/lib/yoke/adapters/claude-worker.js +22 -18
- package/lib/yoke/adapters/claude.js +85 -16
- package/lib/yoke/adapters/codex.js +28 -7
- package/lib/yoke/claude-context-usage.js +57 -0
- package/lib/yoke/claude-message-correlation.js +31 -0
- package/lib/yoke/claude-model-switch.js +15 -0
- package/lib/yoke/claude-user-input.js +2 -0
- package/lib/yoke/index.js +2 -0
- package/lib/yoke/mcp-bridge-server.js +7 -1
- package/lib/yoke/package.json +1 -1
- package/lib/yoke/session-tool-transport.js +53 -0
- package/lib/yoke/user-input.js +21 -7
- package/package.json +9 -10
- package/bin/claude-relay.js +0 -6
- package/lib/public/modules/app-loop-wizard.js +0 -439
|
@@ -10,7 +10,9 @@ import { animateMarkdownChange, beginMarkdownPresentation, cancelMarkdownFollow,
|
|
|
10
10
|
import { store } from './store.js';
|
|
11
11
|
import { enterMarkdownSlides, exitMarkdownSlides, handleMarkdownSlideKey, syncMarkdownSlidesButton, toggleMarkdownSlideLevelMenu } from './markdown-slides.js';
|
|
12
12
|
import { initFileViewerTabs, openFileViewerTab, previewFileViewerTab, updateFileViewerTab, closeFileViewerTab, focusedFileViewerTab, clearFileViewerTabs } from './filebrowser-tabs.js';
|
|
13
|
+
import { closeIssues } from './issues.js';
|
|
13
14
|
import { initFileBrowserContextMenu, downloadProjectFile } from './filebrowser-context-menu.js';
|
|
15
|
+
import { registerClayFileLinkOpener } from './clay-file-links.js';
|
|
14
16
|
|
|
15
17
|
var ctx;
|
|
16
18
|
var showDropHint = function () {};
|
|
@@ -34,6 +36,7 @@ var FILE_RICH_PREVIEW_MAX_BYTES = 1024 * 1024;
|
|
|
34
36
|
|
|
35
37
|
export function initFileBrowser(_ctx) {
|
|
36
38
|
ctx = _ctx;
|
|
39
|
+
registerClayFileLinkOpener(openFile);
|
|
37
40
|
var mainPanels = document.getElementById("main-panels");
|
|
38
41
|
if (mainPanels && ctx.fileViewerEl) mainPanels.appendChild(ctx.fileViewerEl);
|
|
39
42
|
initFileViewerTabs({
|
|
@@ -528,6 +531,7 @@ export function resetFileBrowser() {
|
|
|
528
531
|
pendingGitDiff = null;
|
|
529
532
|
fileAtCache = {};
|
|
530
533
|
pendingFileAt = null;
|
|
534
|
+
store.set({ fileReadRequest: { requestId: "reset-" + Date.now() + "-" + Math.random().toString(36).slice(2), path: null }, pendingFileNavigation: null });
|
|
531
535
|
// Clear tree UI
|
|
532
536
|
if (ctx && ctx.fileTreeEl) ctx.fileTreeEl.innerHTML = "";
|
|
533
537
|
// Hide the file browser panel, show sessions panel
|
|
@@ -544,10 +548,16 @@ var pendingRenderedOpen = false;
|
|
|
544
548
|
|
|
545
549
|
export function openFile(filePath, opts) {
|
|
546
550
|
if (!filePath) return;
|
|
551
|
+
var state = store.snap();
|
|
552
|
+
if (!state.connected) return false;
|
|
553
|
+
if (opts && opts.projectSlug && opts.projectSlug !== state.currentSlug) return false;
|
|
554
|
+
if (opts && opts.sessionId && String(opts.sessionId) !== String(state.activeSessionId)) return false;
|
|
555
|
+
closeIssues();
|
|
547
556
|
if (followedFileChanged(filePath) || (opts && opts.diff && isFollowingMarkdown(filePath))) {
|
|
548
557
|
cancelMarkdownFollow();
|
|
549
558
|
}
|
|
550
559
|
pendingRenderedOpen = !!(opts && opts.rendered);
|
|
560
|
+
store.set({ pendingFileNavigation: opts && opts.line ? { path: filePath, line: opts.line, column: opts.column || null, requestId: null } : null });
|
|
551
561
|
openFileViewerTab(filePath);
|
|
552
562
|
if (opts && opts.diff) {
|
|
553
563
|
pendingOpenMode = { type: "diff", oldStr: opts.diff.oldStr, newStr: opts.diff.newStr };
|
|
@@ -559,6 +569,7 @@ export function openFile(filePath, opts) {
|
|
|
559
569
|
|
|
560
570
|
export function openWorkingTreeDiff(diff) {
|
|
561
571
|
if (!diff || !diff.path) return;
|
|
572
|
+
closeIssues();
|
|
562
573
|
openFileViewerTab(diff.path);
|
|
563
574
|
pendingRenderedOpen = false;
|
|
564
575
|
pendingOpenMode = diff.binary ? null : {
|
|
@@ -674,8 +685,13 @@ function requestDirectory(dirPath) {
|
|
|
674
685
|
}
|
|
675
686
|
|
|
676
687
|
function requestFileContent(filePath) {
|
|
688
|
+
var requestId = "file-read-" + Date.now() + "-" + Math.random().toString(36).slice(2);
|
|
689
|
+
var state = store.snap();
|
|
690
|
+
store.set({ fileReadRequest: { requestId: requestId, path: filePath, projectSlug: state.currentSlug || null, sessionId: state.activeSessionId != null ? String(state.activeSessionId) : null, accountId: state.myUserId || null } });
|
|
691
|
+
var pending = store.get('pendingFileNavigation');
|
|
692
|
+
if (pending && pending.path === filePath) store.set({ pendingFileNavigation: Object.assign({}, pending, { requestId: requestId }) });
|
|
677
693
|
if (ctx.ws && ctx.connected) {
|
|
678
|
-
ctx.ws.send(JSON.stringify({ type: "fs_read", path: filePath }));
|
|
694
|
+
ctx.ws.send(JSON.stringify({ type: "fs_read", path: filePath, requestId: requestId, projectSlug: state.currentSlug || null, sessionId: state.activeSessionId != null ? String(state.activeSessionId) : null, accountId: state.myUserId || null }));
|
|
679
695
|
}
|
|
680
696
|
}
|
|
681
697
|
|
|
@@ -948,6 +964,15 @@ function restoreExpanded(expandedSet) {
|
|
|
948
964
|
}
|
|
949
965
|
|
|
950
966
|
export function handleFsRead(msg) {
|
|
967
|
+
var request = store.get('fileReadRequest');
|
|
968
|
+
var state = store.snap();
|
|
969
|
+
if (!request || !state.connected || msg.requestId !== request.requestId || msg.path !== request.path) return;
|
|
970
|
+
if ((request.projectSlug || null) !== (state.currentSlug || null)) return;
|
|
971
|
+
if ((request.sessionId || null) !== (state.activeSessionId == null ? null : String(state.activeSessionId))) return;
|
|
972
|
+
if ((request.accountId || null) !== (state.myUserId || null)) return;
|
|
973
|
+
if ((request.projectSlug || null) !== (msg.projectSlug || null)) return;
|
|
974
|
+
if ((request.sessionId || null) !== (msg.sessionId == null ? null : String(msg.sessionId))) return;
|
|
975
|
+
if ((request.accountId || null) !== (msg.accountId || null)) return;
|
|
951
976
|
showFileContent(msg);
|
|
952
977
|
}
|
|
953
978
|
|
|
@@ -1117,7 +1142,7 @@ function showFileContent(msg) {
|
|
|
1117
1142
|
document.getElementById("file-viewer-slides").classList.add("hidden");
|
|
1118
1143
|
|
|
1119
1144
|
if (msg.error) {
|
|
1120
|
-
bodyEl.innerHTML = '<div class="file-tree-error">' + escapeHtml(msg.error) + '</div>';
|
|
1145
|
+
bodyEl.innerHTML = '<div class="file-tree-error">Unable to open <strong>' + escapeHtml(msg.path) + '</strong>: ' + escapeHtml(msg.error) + '</div>';
|
|
1121
1146
|
} else if (msg.binary) {
|
|
1122
1147
|
if (msg.imageUrl) {
|
|
1123
1148
|
bodyEl.innerHTML = '<div class="file-viewer-image"><img src="' + escapeHtml(msg.imageUrl) + '" alt="' + escapeHtml(msg.path) + '"></div>';
|
|
@@ -1186,6 +1211,22 @@ function showFileContent(msg) {
|
|
|
1186
1211
|
pendingOpenMode = null;
|
|
1187
1212
|
pendingRenderedOpen = false;
|
|
1188
1213
|
|
|
1214
|
+
var pendingFileLine = store.get('pendingFileNavigation');
|
|
1215
|
+
var activeRead = store.get('fileReadRequest');
|
|
1216
|
+
if (pendingFileLine && activeRead && pendingFileLine.requestId === activeRead.requestId && pendingFileLine.path === msg.path && !msg.error) {
|
|
1217
|
+
var requestedLine = pendingFileLine.line;
|
|
1218
|
+
store.set({ pendingFileNavigation: null });
|
|
1219
|
+
requestAnimationFrame(function () {
|
|
1220
|
+
var rows = document.querySelectorAll("#file-viewer-body .file-viewer-gutter, #file-viewer-body .file-viewer-code-content");
|
|
1221
|
+
if (!rows.length) return;
|
|
1222
|
+
var target = rows[0];
|
|
1223
|
+
var lineHeight = parseFloat(getComputedStyle(target).lineHeight) || 20;
|
|
1224
|
+
document.getElementById("file-viewer-body").scrollTop = Math.max(0, (requestedLine - 1) * lineHeight - 80);
|
|
1225
|
+
});
|
|
1226
|
+
} else if (msg.error) {
|
|
1227
|
+
store.set({ pendingFileNavigation: null });
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1189
1230
|
// Request edit history for this file (skip on auto-refresh)
|
|
1190
1231
|
if (!keepRenderState) {
|
|
1191
1232
|
historyVisible = false;
|
|
@@ -10,7 +10,6 @@ import { openHomeConversationsSheet, refreshHomeConversationsSheet } from './hom
|
|
|
10
10
|
import { renderHomeSidebarChats } from './home-sidebar-chat-list.js';
|
|
11
11
|
import { syncHomeSessionDetails } from './home-session-actions.js';
|
|
12
12
|
import { toggleHomeCapsules } from './home-dock.js';
|
|
13
|
-
import { openHomeScheduler } from './scheduler.js';
|
|
14
13
|
|
|
15
14
|
var initialized = false;
|
|
16
15
|
var requestedMateIds = {};
|
|
@@ -54,16 +53,30 @@ function renderSidebarState() {
|
|
|
54
53
|
var expand = document.getElementById("home-sidebar-expand");
|
|
55
54
|
if (collapse) collapse.setAttribute("aria-expanded", String(!collapsed));
|
|
56
55
|
if (expand) expand.setAttribute("aria-expanded", String(!collapsed));
|
|
56
|
+
renderMatesState();
|
|
57
57
|
renderChatScope();
|
|
58
58
|
renderRecentConversations();
|
|
59
59
|
refreshHomeConversationsSheet();
|
|
60
60
|
syncHomeSessionDetails();
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
function renderMatesState() {
|
|
64
|
+
var section = document.querySelector(".home-sidebar-mate-section");
|
|
65
|
+
var toggle = document.getElementById("home-sidebar-mate-label");
|
|
66
|
+
if (!section || !toggle) return;
|
|
67
|
+
var collapsed = store.get('homeMatesCollapsed') === true;
|
|
68
|
+
section.classList.toggle("home-sidebar-mates-collapsed", collapsed);
|
|
69
|
+
toggle.setAttribute("aria-expanded", String(!collapsed));
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
function setCollapsed(collapsed) {
|
|
64
73
|
updateHomeSurfacePreference({ sidebarCollapsed: collapsed });
|
|
65
74
|
}
|
|
66
75
|
|
|
76
|
+
function toggleMates() {
|
|
77
|
+
updateHomeSurfacePreference({ matesCollapsed: store.get('homeMatesCollapsed') !== true });
|
|
78
|
+
}
|
|
79
|
+
|
|
67
80
|
function setChatScope(event) {
|
|
68
81
|
var scope = event.currentTarget.dataset.homeChatScope;
|
|
69
82
|
if (scope !== "current" && scope !== "all") return;
|
|
@@ -120,11 +133,6 @@ function toggleCapsulesFromSidebar() {
|
|
|
120
133
|
closeNarrowDrawer(!opening);
|
|
121
134
|
}
|
|
122
135
|
|
|
123
|
-
function openScheduledTasksFromSidebar() {
|
|
124
|
-
openHomeScheduler();
|
|
125
|
-
closeNarrowDrawer(false);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
136
|
function handleSidebarKeydown(event) {
|
|
129
137
|
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
130
138
|
if (!document.body.classList.contains("home-active")) return;
|
|
@@ -139,18 +147,18 @@ export function initHomeSidebar() {
|
|
|
139
147
|
initialized = true;
|
|
140
148
|
document.getElementById("home-sidebar-collapse").addEventListener("click", function () { setCollapsed(true); });
|
|
141
149
|
document.getElementById("home-sidebar-expand").addEventListener("click", function () { setCollapsed(false); });
|
|
150
|
+
document.getElementById("home-sidebar-mate-label").addEventListener("click", toggleMates);
|
|
142
151
|
document.getElementById("home-sidebar-backdrop").addEventListener("click", function () { setCollapsed(true); });
|
|
143
152
|
document.getElementById("home-sidebar-new").addEventListener("click", startConversationFromSidebar);
|
|
144
153
|
document.getElementById("home-sidebar-all").addEventListener("click", openAllConversations);
|
|
145
154
|
document.getElementById("home-sidebar-debate").addEventListener("click", openDebatesFromSidebar);
|
|
146
|
-
document.getElementById("home-scheduler-btn").addEventListener("click", openScheduledTasksFromSidebar);
|
|
147
155
|
document.getElementById("home-tools-btn").addEventListener("click", toggleCapsulesFromSidebar);
|
|
148
156
|
var scopeButtons = document.querySelectorAll("[data-home-chat-scope]");
|
|
149
157
|
for (var i = 0; i < scopeButtons.length; i++) scopeButtons[i].addEventListener("click", setChatScope);
|
|
150
158
|
store.subscribe(function (state, prev) {
|
|
151
159
|
if (state.connected !== prev.connected && state.connected) requestConversationLists(true);
|
|
152
160
|
if (state.cachedMatesList !== prev.cachedMatesList) requestConversationLists(false);
|
|
153
|
-
if (state.homeMateSessions !== prev.homeMateSessions || state.homeChatMateId !== prev.homeChatMateId || state.homeChatSessionId !== prev.homeChatSessionId || state.homeSidebarCollapsed !== prev.homeSidebarCollapsed || state.homeChatScope !== prev.homeChatScope) {
|
|
161
|
+
if (state.homeMateSessions !== prev.homeMateSessions || state.homeChatMateId !== prev.homeChatMateId || state.homeChatSessionId !== prev.homeChatSessionId || state.homeSidebarCollapsed !== prev.homeSidebarCollapsed || state.homeMatesCollapsed !== prev.homeMatesCollapsed || state.homeChatScope !== prev.homeChatScope) {
|
|
154
162
|
renderSidebarState();
|
|
155
163
|
}
|
|
156
164
|
});
|
|
@@ -48,6 +48,7 @@ export function updateHomeSurfacePreference(patch) {
|
|
|
48
48
|
activeMateId: state.homeChatMateId || null,
|
|
49
49
|
activeSessionByMate: Object.assign({}, state.homeActiveSessionByMate || {}),
|
|
50
50
|
sidebarCollapsed: state.homeSidebarCollapsed === true,
|
|
51
|
+
matesCollapsed: state.homeMatesCollapsed === true,
|
|
51
52
|
chatScope: normalizeChatScope(state.homeChatScope),
|
|
52
53
|
subSurface: normalizeSubSurface(state.homeSubSurface),
|
|
53
54
|
};
|
|
@@ -56,6 +57,7 @@ export function updateHomeSurfacePreference(patch) {
|
|
|
56
57
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "activeMateId")) next.activeMateId = patch.activeMateId;
|
|
57
58
|
if (patch && patch.activeSessionByMate) next.activeSessionByMate = Object.assign({}, next.activeSessionByMate, patch.activeSessionByMate);
|
|
58
59
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "sidebarCollapsed")) next.sidebarCollapsed = patch.sidebarCollapsed === true;
|
|
60
|
+
if (patch && Object.prototype.hasOwnProperty.call(patch, "matesCollapsed")) next.matesCollapsed = patch.matesCollapsed === true;
|
|
59
61
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "chatScope")) next.chatScope = normalizeChatScope(patch.chatScope);
|
|
60
62
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "subSurface")) next.subSurface = normalizeSubSurface(patch.subSurface);
|
|
61
63
|
store.set({
|
|
@@ -63,6 +65,7 @@ export function updateHomeSurfacePreference(patch) {
|
|
|
63
65
|
homeSurfaceProjectSlug: next.projectSlug,
|
|
64
66
|
homeActiveSessionByMate: normalizeSessions(next.activeSessionByMate),
|
|
65
67
|
homeSidebarCollapsed: next.sidebarCollapsed,
|
|
68
|
+
homeMatesCollapsed: next.matesCollapsed,
|
|
66
69
|
homeChatScope: next.chatScope,
|
|
67
70
|
homeSubSurface: next.subSurface,
|
|
68
71
|
});
|
|
@@ -72,6 +75,7 @@ export function updateHomeSurfacePreference(patch) {
|
|
|
72
75
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "activeMateId")) outgoing.activeMateId = next.activeMateId;
|
|
73
76
|
if (patch && patch.activeSessionByMate) outgoing.activeSessionByMate = patch.activeSessionByMate;
|
|
74
77
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "sidebarCollapsed")) outgoing.sidebarCollapsed = next.sidebarCollapsed;
|
|
78
|
+
if (patch && Object.prototype.hasOwnProperty.call(patch, "matesCollapsed")) outgoing.matesCollapsed = next.matesCollapsed;
|
|
75
79
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "chatScope")) outgoing.chatScope = next.chatScope;
|
|
76
80
|
if (patch && Object.prototype.hasOwnProperty.call(patch, "subSurface")) outgoing.subSurface = next.subSurface;
|
|
77
81
|
return send({ type: "home_surface_set", preference: outgoing });
|
|
@@ -129,6 +133,7 @@ export function handleHomeSurfaceState(msg) {
|
|
|
129
133
|
homeSurfaceProjectSlug: intent ? intendedProject : savedProject,
|
|
130
134
|
homeActiveSessionByMate: normalizeSessions(preference.activeSessionByMate),
|
|
131
135
|
homeSidebarCollapsed: preference.sidebarCollapsed === true,
|
|
136
|
+
homeMatesCollapsed: preference.matesCollapsed === true,
|
|
132
137
|
homeChatScope: normalizeChatScope(preference.chatScope),
|
|
133
138
|
homeSubSurface: normalizeSubSurface(preference.subSurface),
|
|
134
139
|
};
|
|
@@ -10,6 +10,8 @@ import { VENDOR_AVATARS, VENDOR_NAMES } from './app-rendering.js';
|
|
|
10
10
|
import { showToast } from './utils.js';
|
|
11
11
|
import { isShellCommandMode, submitShellCommand } from './shell-command.js';
|
|
12
12
|
import { showPasteModal } from './paste-modal.js';
|
|
13
|
+
import { prepareAutonomousPayload } from './autonomous-run.js';
|
|
14
|
+
export { setScheduleBtnDisabled } from './scheduled-message-state.js';
|
|
13
15
|
|
|
14
16
|
var ctx;
|
|
15
17
|
|
|
@@ -24,6 +26,7 @@ var isComposing = false;
|
|
|
24
26
|
var isRemoteInput = false;
|
|
25
27
|
var scheduleDelayMs = 0; // 0 = no schedule, >0 = delay in ms
|
|
26
28
|
var _setScheduleDelayFn = null; // set by initInput
|
|
29
|
+
var scheduleRequestCounter = 0;
|
|
27
30
|
|
|
28
31
|
export function hasSendableContent() {
|
|
29
32
|
return !!(
|
|
@@ -57,19 +60,6 @@ export function clearScheduleDelay() {
|
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
export function setScheduleBtnDisabled(disabled) {
|
|
61
|
-
var btn = document.getElementById("schedule-btn");
|
|
62
|
-
if (!btn) return;
|
|
63
|
-
btn.disabled = disabled;
|
|
64
|
-
if (disabled) {
|
|
65
|
-
btn.style.opacity = "0.3";
|
|
66
|
-
btn.style.pointerEvents = "none";
|
|
67
|
-
} else {
|
|
68
|
-
btn.style.opacity = "";
|
|
69
|
-
btn.style.pointerEvents = "";
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
63
|
export var builtinCommands = [
|
|
74
64
|
{ name: "clear", desc: "Clear conversation" },
|
|
75
65
|
{ name: "context", desc: "Context window usage" },
|
|
@@ -93,6 +83,24 @@ function commitVendorForTurn() {
|
|
|
93
83
|
store.set({ vendorSelectionLocked: false, sessionHasHistory: true });
|
|
94
84
|
}
|
|
95
85
|
|
|
86
|
+
function scheduleAdmissionMap() {
|
|
87
|
+
return store.get("pendingScheduleAdmissions") || {};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function scheduleDraftMatches(left, right) {
|
|
91
|
+
return !!left && !!right && JSON.stringify(left) === JSON.stringify(right);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function scheduleContextMatches(left, right) {
|
|
95
|
+
return !!left && !!right && left.projectSlug === right.projectSlug && String(left.sessionId) === String(right.sessionId) && left.accountId === right.accountId;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
store.subscribe(function (state, previous) {
|
|
99
|
+
if (state.currentSlug === previous.currentSlug && state.activeSessionId === previous.activeSessionId &&
|
|
100
|
+
state.myUserId === previous.myUserId && state.connected === previous.connected) return;
|
|
101
|
+
if (Object.keys(scheduleAdmissionMap()).length > 0) store.set({ pendingScheduleAdmissions: {}, pendingScheduleAdmission: null });
|
|
102
|
+
});
|
|
103
|
+
|
|
96
104
|
function showPreThinkingForTurn() {
|
|
97
105
|
if (ctx.isMateDm && ctx.isMateDm()) {
|
|
98
106
|
ctx.showMatePreThinking();
|
|
@@ -294,19 +302,40 @@ export function sendMessage() {
|
|
|
294
302
|
// Scheduled message: queue message with timer delay
|
|
295
303
|
if (scheduleDelayMs > 0) {
|
|
296
304
|
var resetsAt = Date.now() + scheduleDelayMs;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
305
|
+
var scheduleContext = {
|
|
306
|
+
projectSlug: store.get("currentSlug"),
|
|
307
|
+
sessionId: store.get("activeSessionId"),
|
|
308
|
+
accountId: store.get("myUserId") || "default",
|
|
309
|
+
};
|
|
310
|
+
var scheduleDraft = { text: ctx.inputEl.value, images: images, pastes: pastes, files: files, delay: scheduleDelayMs };
|
|
311
|
+
var admissions = scheduleAdmissionMap();
|
|
312
|
+
var scheduleRequestId = null;
|
|
313
|
+
var admissionIds = Object.keys(admissions);
|
|
314
|
+
for (var admissionIndex = 0; admissionIndex < admissionIds.length; admissionIndex++) {
|
|
315
|
+
var candidate = admissions[admissionIds[admissionIndex]];
|
|
316
|
+
if (candidate.context.projectSlug === scheduleContext.projectSlug && String(candidate.context.sessionId) === String(scheduleContext.sessionId) &&
|
|
317
|
+
candidate.context.accountId === scheduleContext.accountId && scheduleDraftMatches(candidate.draft, scheduleDraft)) {
|
|
318
|
+
scheduleRequestId = candidate.requestId;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (!scheduleRequestId) {
|
|
323
|
+
scheduleRequestCounter++;
|
|
324
|
+
scheduleRequestId = "schedule-" + Date.now().toString(36) + "-" + scheduleRequestCounter;
|
|
325
|
+
admissions = Object.assign({}, admissions);
|
|
326
|
+
admissions[scheduleRequestId] = { requestId: scheduleRequestId, context: scheduleContext, draft: scheduleDraft };
|
|
327
|
+
var boundedIds = Object.keys(admissions);
|
|
328
|
+
while (boundedIds.length > 8) delete admissions[boundedIds.shift()];
|
|
329
|
+
}
|
|
330
|
+
store.set({ pendingScheduleAdmissions: admissions, pendingScheduleAdmission: admissions[scheduleRequestId] });
|
|
331
|
+
ctx.ws.send(JSON.stringify({
|
|
332
|
+
type: "schedule_message", requestId: scheduleRequestId,
|
|
333
|
+
projectSlug: scheduleContext.projectSlug, sessionId: scheduleContext.sessionId, accountId: scheduleContext.accountId,
|
|
334
|
+
text: text || "", images: images, pastes: pastes, resetsAt: resetsAt,
|
|
335
|
+
}));
|
|
304
336
|
return;
|
|
305
337
|
}
|
|
306
338
|
|
|
307
|
-
ctx.currentMsgTs = Date.now();
|
|
308
|
-
ctx.addUserMessage(text, images.length > 0 ? images : null, pastes.length > 0 ? pastes : null);
|
|
309
|
-
|
|
310
339
|
var payload = { type: "message", text: text || "" };
|
|
311
340
|
if (images.length > 0) {
|
|
312
341
|
payload.images = images;
|
|
@@ -317,11 +346,9 @@ export function sendMessage() {
|
|
|
317
346
|
// Include selected vendor for session binding (server uses on first message)
|
|
318
347
|
var _selVendor = store.get("currentVendor") || null;
|
|
319
348
|
if (_selVendor) payload.vendor = _selVendor;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
optimisticUsers[optimisticUsers.length - 1].dataset.clientMessageId = clientMessageId;
|
|
324
|
-
}
|
|
349
|
+
if (!prepareAutonomousPayload(payload)) return;
|
|
350
|
+
ctx.currentMsgTs = Date.now();
|
|
351
|
+
sendAcknowledgedMessage(payload);
|
|
325
352
|
|
|
326
353
|
// A turn blocked on an unanswered tool-permission request looks like a
|
|
327
354
|
// black hole: the new message queues silently while the dots keep
|
|
@@ -335,17 +362,6 @@ export function sendMessage() {
|
|
|
335
362
|
showToast("A tool permission request is still waiting — your message is queued until you answer it.", "error");
|
|
336
363
|
}
|
|
337
364
|
|
|
338
|
-
// First message commits the vendor and bumps the session into
|
|
339
|
-
// has-history state. The server won't re-fire session_switched after a
|
|
340
|
-
// message, so show the small vendor avatar next to the config chip.
|
|
341
|
-
// Bumping sessionHasHistory drives in-session lock states (e.g. the
|
|
342
|
-
// Codex model picker that becomes informational once the thread is
|
|
343
|
-
// bound to a model).
|
|
344
|
-
commitVendorForTurn();
|
|
345
|
-
|
|
346
|
-
// Show pre-thinking dots before server responds
|
|
347
|
-
showPreThinkingForTurn();
|
|
348
|
-
|
|
349
365
|
ctx.inputEl.value = "";
|
|
350
366
|
sendInputSync();
|
|
351
367
|
clearPendingImages();
|
|
@@ -357,6 +373,42 @@ export function sendMessage() {
|
|
|
357
373
|
}
|
|
358
374
|
}
|
|
359
375
|
|
|
376
|
+
export function handleAcceptedOrdinaryMessage() {
|
|
377
|
+
if (!ctx) return;
|
|
378
|
+
commitVendorForTurn();
|
|
379
|
+
showPreThinkingForTurn();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function handleScheduleMessageResult(msg) {
|
|
383
|
+
var admissions = scheduleAdmissionMap();
|
|
384
|
+
var pending = admissions[msg && msg.requestId];
|
|
385
|
+
var currentContext = { projectSlug: store.get("currentSlug"), sessionId: store.get("activeSessionId"), accountId: store.get("myUserId") || "default" };
|
|
386
|
+
if (!pending || !msg || msg.requestId !== pending.requestId) return false;
|
|
387
|
+
if (!store.get("connected") || !scheduleContextMatches(pending.context, currentContext) ||
|
|
388
|
+
msg.projectSlug !== currentContext.projectSlug || String(msg.sessionId) !== String(currentContext.sessionId) || msg.accountId !== currentContext.accountId) {
|
|
389
|
+
admissions = Object.assign({}, admissions);
|
|
390
|
+
delete admissions[msg.requestId];
|
|
391
|
+
store.set({ pendingScheduleAdmissions: admissions, pendingScheduleAdmission: null });
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
if (!msg.ok) {
|
|
395
|
+
showToast(msg.error || "Could not schedule the message.", "error");
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
admissions = Object.assign({}, admissions);
|
|
399
|
+
delete admissions[msg.requestId];
|
|
400
|
+
store.set({ pendingScheduleAdmissions: admissions, pendingScheduleAdmission: null });
|
|
401
|
+
var currentDraft = { text: ctx.inputEl.value, images: pendingImages, pastes: pendingPastes.map(function (p) { return p.text; }), files: pendingFiles, delay: scheduleDelayMs };
|
|
402
|
+
if (JSON.stringify(currentDraft) !== JSON.stringify(pending.draft)) return true;
|
|
403
|
+
clearScheduleDelay();
|
|
404
|
+
ctx.inputEl.value = "";
|
|
405
|
+
sendInputSync();
|
|
406
|
+
clearPendingImages();
|
|
407
|
+
autoResize();
|
|
408
|
+
ctx.inputEl.focus();
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
|
|
360
412
|
export function sendTextMessage(text) {
|
|
361
413
|
if (!ctx || !ctx.inputEl || typeof text !== "string" || !text.trim()) return false;
|
|
362
414
|
clearPendingImages();
|
|
@@ -1059,7 +1111,7 @@ export function initInput(_ctx) {
|
|
|
1059
1111
|
document.addEventListener("paste", function (e) {
|
|
1060
1112
|
// Don't intercept paste when typing in modals or other non-chat inputs
|
|
1061
1113
|
var target = e.target;
|
|
1062
|
-
if (target && target.closest && target.closest(".sticky-note, #notes-archive,
|
|
1114
|
+
if (target && target.closest && target.closest(".sticky-note, #notes-archive, .confirm-modal, #paste-modal, .scheduler-detail, #debate-modal, .us-modal")) return;
|
|
1063
1115
|
|
|
1064
1116
|
var cd = e.clipboardData;
|
|
1065
1117
|
if (!cd) return;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Account, connection, and project correlation around the Issues workbench.
|
|
2
|
+
|
|
3
|
+
import { store } from './store.js';
|
|
4
|
+
import { getWs } from './ws-ref.js';
|
|
5
|
+
import { showToast } from './utils.js';
|
|
6
|
+
import { openIssues, closeIssues, handleIssuesMessage } from './issues.js';
|
|
7
|
+
|
|
8
|
+
var updatingRequests = false;
|
|
9
|
+
|
|
10
|
+
function accountKey(state) {
|
|
11
|
+
return state.isMultiUserMode ? 'user:' + String(state.myUserId || '') : 'single';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function context(state) {
|
|
15
|
+
return { accountKey: accountKey(state), projectSlug: state.currentSlug || null, epoch: state.issuesEpoch || 0 };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function sameContext(item, state) {
|
|
19
|
+
var current = context(state);
|
|
20
|
+
return !!item && item.accountKey === current.accountKey && item.projectSlug === current.projectSlug && item.epoch === current.epoch;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function enableActions() {
|
|
24
|
+
var panel = document.getElementById('issues-panel');
|
|
25
|
+
if (!panel) return;
|
|
26
|
+
panel.querySelectorAll('#issue-form [type="submit"], [data-issue-work]').forEach(function (button) { button.disabled = false; });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function resetState(closePanel) {
|
|
30
|
+
var timer = store.get('issuesSearchTimer');
|
|
31
|
+
if (timer) clearTimeout(timer);
|
|
32
|
+
if (closePanel) closeIssues();
|
|
33
|
+
store.set({ issuesRequests: {}, issuesSelected: null, issuesRows: [], issuesCache: {}, issuesViewRequest: null, issuesMutationRequest: null,
|
|
34
|
+
issuesSearchTimer: null, issueLinkRequests: {}, issueLinkOpenRef: null, issuesEpoch: (store.get('issuesEpoch') || 0) + 1 });
|
|
35
|
+
enableActions();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function annotateRequests(state) {
|
|
39
|
+
if (updatingRequests) return;
|
|
40
|
+
var requests = state.issuesRequests || {};
|
|
41
|
+
var ids = Object.keys(requests);
|
|
42
|
+
var next = null;
|
|
43
|
+
var current = context(state);
|
|
44
|
+
for (var i = 0; i < ids.length; i++) {
|
|
45
|
+
var item = requests[ids[i]];
|
|
46
|
+
if (item.accountKey !== undefined) continue;
|
|
47
|
+
if (!next) next = Object.assign({}, requests);
|
|
48
|
+
next[ids[i]] = Object.assign({}, item, current);
|
|
49
|
+
}
|
|
50
|
+
if (!next) return;
|
|
51
|
+
updatingRequests = true;
|
|
52
|
+
store.set({ issuesRequests: next });
|
|
53
|
+
updatingRequests = false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function sendOpenSession(target) {
|
|
57
|
+
var ws = getWs();
|
|
58
|
+
var entry = store.get('issuesSelected');
|
|
59
|
+
if (!entry || !ws || ws.readyState !== 1) { showToast('Reconnect to open issue work', 'warn'); return; }
|
|
60
|
+
var id = 'issues-' + crypto.randomUUID();
|
|
61
|
+
var current = context(store.snap());
|
|
62
|
+
var pending = Object.assign({}, store.get('issuesRequests') || {});
|
|
63
|
+
pending[id] = Object.assign({ action: 'issue_open_work', intent: 'work', slug: current.projectSlug }, current);
|
|
64
|
+
store.set({ issuesRequests: pending });
|
|
65
|
+
ws.send(JSON.stringify({ type: 'issue_open_work', requestId: id,
|
|
66
|
+
args: { ref: entry.ref, expectedRevision: entry.revision, sessionOriginId: target.dataset.issueSession } }));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function initIssuesContext() {
|
|
70
|
+
var initial = new URLSearchParams(window.location.search).get('issue');
|
|
71
|
+
var initialOpened = false;
|
|
72
|
+
function tryInitial(state) {
|
|
73
|
+
if (initialOpened || !initial || !/^issue:[A-Za-z0-9_-]{24}$/.test(initial)) return;
|
|
74
|
+
if (!state.connected || !state.currentSlug || (state.isMultiUserMode && !state.myUserId)) return;
|
|
75
|
+
if (state.issuesOpen && state.issuesViewRequest) { initialOpened = true; return; }
|
|
76
|
+
initialOpened = true;
|
|
77
|
+
openIssues(initial);
|
|
78
|
+
}
|
|
79
|
+
store.subscribe(function (state, previous) {
|
|
80
|
+
var accountChanged = state.myUserId !== previous.myUserId || state.isMultiUserMode !== previous.isMultiUserMode;
|
|
81
|
+
if (state.currentSlug !== previous.currentSlug || accountChanged || (previous.connected && !state.connected)) resetState(true);
|
|
82
|
+
else annotateRequests(state);
|
|
83
|
+
if (!previous.connected && state.connected) enableActions();
|
|
84
|
+
tryInitial(state);
|
|
85
|
+
});
|
|
86
|
+
document.addEventListener('click', function (event) {
|
|
87
|
+
var target = event.target.closest && event.target.closest('[data-issue-session], [data-issue-work]');
|
|
88
|
+
if (!target) return;
|
|
89
|
+
if (target.dataset.issueSession) {
|
|
90
|
+
event.preventDefault(); event.stopImmediatePropagation(); sendOpenSession(target); return;
|
|
91
|
+
}
|
|
92
|
+
var ws = getWs();
|
|
93
|
+
if (!ws || ws.readyState !== 1) {
|
|
94
|
+
event.preventDefault(); event.stopImmediatePropagation(); target.disabled = false;
|
|
95
|
+
showToast('Reconnect to start issue work', 'warn');
|
|
96
|
+
}
|
|
97
|
+
}, true);
|
|
98
|
+
document.addEventListener('submit', function (event) {
|
|
99
|
+
if (!event.target || event.target.id !== 'issue-form') return;
|
|
100
|
+
var ws = getWs();
|
|
101
|
+
if (ws && ws.readyState === 1) return;
|
|
102
|
+
event.preventDefault(); event.stopImmediatePropagation(); enableActions();
|
|
103
|
+
showToast('Reconnect to save this issue', 'warn');
|
|
104
|
+
}, true);
|
|
105
|
+
tryInitial(store.snap());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function handleIssuesMessageInContext(msg) {
|
|
109
|
+
var state = store.snap();
|
|
110
|
+
if (msg.type === 'issue_updated' || msg.type === 'issue_commented' || msg.type === 'issue_deleted') {
|
|
111
|
+
if (!msg.projectSlug || msg.projectSlug !== state.currentSlug || (state.isMultiUserMode && !state.myUserId)) return true;
|
|
112
|
+
} else if (msg.type === 'issues_result') {
|
|
113
|
+
var item = (state.issuesRequests || {})[msg.requestId];
|
|
114
|
+
if (!sameContext(item, state)) return true;
|
|
115
|
+
}
|
|
116
|
+
return handleIssuesMessage(msg);
|
|
117
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { escapeHtml } from './utils.js';
|
|
2
|
+
import { renderMarkdown } from './markdown.js';
|
|
3
|
+
export function statusLabel(status) { return { open: 'Open', in_progress: 'In progress', resolved: 'Resolved', closed: 'Closed' }[status] || 'Issue'; }
|
|
4
|
+
function esc(value) { return escapeHtml(String(value || '')); }
|
|
5
|
+
function options(values, selected) { return values.map(function (value) { return '<option value="' + value + '"' + (value === selected ? ' selected' : '') + '>' + esc(statusLabel(value) === 'Issue' ? value.replace(/_/g, ' ') : statusLabel(value)) + '</option>'; }).join(''); }
|
|
6
|
+
export function renderIssueList(result) {
|
|
7
|
+
var filtered = !!(result.query || result.status || result.type);
|
|
8
|
+
if (!result.issues.length) return '<div class="issues-empty"><i data-lucide="circle-dot"></i><h2>' + (filtered ? 'No matching issues' : 'No issues yet') + '</h2><p>' + (filtered ? 'Try a different search or filter.' : 'Manage issues through Driver chat.') + '</p></div>';
|
|
9
|
+
return result.issues.map(function (entry) {
|
|
10
|
+
return '<button class="issue-row" data-open-issue="' + esc(entry.ref) + '"><div class="issue-row-head"><span class="issue-type">' + esc(entry.type) + '</span><span class="issue-status" data-status="' + entry.status + '">' + statusLabel(entry.status) + '</span></div><strong>' + esc(entry.title) + '</strong><p>' + esc(entry.summary) + '</p><small>' + esc(entry.priority) + ' · revision ' + entry.revision + '</small></button>';
|
|
11
|
+
}).join('') + (result.nextCursor ? '<button data-issues-more="' + esc(result.nextCursor) + '">Load more</button>' : '');
|
|
12
|
+
}
|
|
13
|
+
export function renderIssueDetail(entry) {
|
|
14
|
+
var author = entry.updatedBy || entry.author || {};
|
|
15
|
+
var comments = (entry.comments || []).map(function (comment) { var commentAuthor = comment.author || {}; var review = comment.review; return '<article class="issue-comment"><div class="issue-comment-meta">' + esc(commentAuthor.displayName || commentAuthor.userId || 'Project member') + ' · ' + esc(new Date(comment.at).toLocaleString()) + '</div><p>' + esc(comment.body) + '</p>' + (review ? '<small>' + esc(review.action) + ' · ' + esc(review.response) + '</small>' : '') + '</article>'; }).join('');
|
|
16
|
+
return '<div class="issue-detail"><span class="issue-status" data-status="' + entry.status + '">' + statusLabel(entry.status) + '</span><h2>' + esc(entry.title) + '</h2><p>' + esc(entry.summary) + '</p><small>' + esc(entry.type) + ' · ' + esc(entry.priority) + ' · revision ' + entry.revision + ' · ' + esc(author.displayName || author.userId || 'Local user') + '</small><div class="markdown-body">' + renderMarkdown(entry.body || '') + '</div>' +
|
|
17
|
+
(entry.verifiedCommit ? '<section><h3>Resolution</h3><p>' + esc(entry.resolutionSummary) + '</p><code>' + esc(entry.verifiedCommit.sha) + '</code><p>' + esc(entry.verifiedCommit.subject) + '</p></section>' : '') +
|
|
18
|
+
(entry.closeReason ? '<section class="issue-evidence"><h3>Closure</h3><p>' + esc(entry.closeReason.replace(/_/g, ' ')) + '</p></section>' : '') +
|
|
19
|
+
'<div class="issue-actions"><button data-issue-edit>Edit</button><button data-issue-work' + (entry.status === 'resolved' || entry.status === 'closed' ? ' disabled title="Reopen this issue to start work"' : '') + '>Start work</button><button data-issue-history>History</button><button data-issue-copy>Copy reference</button>' + (entry.canDelete ? '<button data-issue-delete>Delete issue</button>' : '') + '</div>' +
|
|
20
|
+
((entry.linkedWorkSessions || []).length ? '<section><h3>Linked work sessions</h3>' + entry.linkedWorkSessions.map(function (link) { return '<button data-issue-session="' + esc(link.sessionId) + '">Open Driver session</button>'; }).join('') + '</section>' : '') +
|
|
21
|
+
((entry.resolutionHistory || []).length ? '<section class="issue-evidence"><h3>Resolution history</h3>' + entry.resolutionHistory.map(function (item) { return '<p>' + esc(item.resolutionSummary) + ' <code>' + esc(item.verifiedCommit && item.verifiedCommit.sha) + '</code></p>'; }).join('') + '</section>' : '') + '<section class="issue-discussion"><h3>Discussion' + (comments ? ' (' + entry.comments.length + ')' : '') + '</h3>' + (comments || '<p class="issue-discussion-empty">No comments yet.</p>') + '<form id="issue-comment-form"><label for="issue-comment-input">Add a comment</label><textarea id="issue-comment-input" rows="3" required placeholder="Add context, a correction, or a question."></textarea><p class="issue-comment-status" role="status"></p><button type="submit">Comment</button></form></section></div>';
|
|
22
|
+
}
|
|
23
|
+
export function renderIssueForm(entry) {
|
|
24
|
+
var item = entry || {};
|
|
25
|
+
return '<form id="issue-form"><label>Title<input name="title" maxlength="200" required value="' + esc(item.title) + '"></label><label>Summary<textarea name="summary" maxlength="400">' + esc(item.summary) + '</textarea></label><div class="issue-fields"><label>Type<select name="type">' + options(['bug', 'feature', 'plan'], item.type || 'bug') + '</select></label><label>Priority<select name="priority">' + options(['normal', 'important', 'urgent'], item.priority || 'normal') + '</select></label><label>Status<select name="status">' + options(['open', 'in_progress', 'resolved', 'closed'], item.status || 'open') + '</select></label></div><label>Details (Markdown)<textarea name="body" rows="10" maxlength="20000">' + esc(item.body) + '</textarea></label><div data-resolution-fields><label>Resolution summary<input name="resolutionSummary" maxlength="400" value="' + esc(item.resolutionSummary) + '"></label><label>Resolving commit SHA<input name="commitSha" value="' + esc(item.verifiedCommit && item.verifiedCommit.sha) + '"></label></div><label data-close-fields>Close reason<select name="closeReason">' + options(['declined', 'duplicate', 'non_code_decision'], item.closeReason || 'non_code_decision') + '</select></label><div class="issue-actions"><button type="submit">Save issue</button><button type="button" data-issue-cancel>Cancel</button></div></form>';
|
|
26
|
+
}
|
|
27
|
+
export function renderIssueHistory(result) {
|
|
28
|
+
return '<h2>Revision history</h2>' + result.revisions.slice().reverse().map(function (revision) { var actor = revision.author || {}; return '<button class="issue-row" data-issue-revision="' + revision.revision + '"><strong>Revision ' + revision.revision + '</strong><p>' + esc(actor.displayName || actor.userId || 'Local user') + ' · ' + esc(new Date(revision.at).toLocaleString()) + '</p><small>' + statusLabel(revision.status) + '</small></button>'; }).join('');
|
|
29
|
+
}
|