@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.
- package/CREDITS.md +3 -0
- package/LICENSE +21 -0
- package/README.md +250 -0
- package/bin/cli.js +2812 -0
- package/lib/agents-favorites.js +164 -0
- package/lib/agents.js +282 -0
- package/lib/ask-user-mcp-server.js +120 -0
- package/lib/browser-mcp-server.js +484 -0
- package/lib/build-user-env.js +63 -0
- package/lib/certs/fullchain.pem +47 -0
- package/lib/certs/privkey.pem +5 -0
- package/lib/cli-sessions.js +265 -0
- package/lib/codex-defaults.js +18 -0
- package/lib/config.js +332 -0
- package/lib/crisis-safety.js +60 -0
- package/lib/daemon-projects.js +164 -0
- package/lib/daemon.js +1602 -0
- package/lib/dm.js +128 -0
- package/lib/ipc.js +125 -0
- package/lib/ipv4-only.js +39 -0
- package/lib/mcp-local.js +385 -0
- package/lib/notes.js +141 -0
- package/lib/os-users.js +529 -0
- package/lib/pages.js +1325 -0
- package/lib/project-connection.js +302 -0
- package/lib/project-external-trigger.js +236 -0
- package/lib/project-file-watch.js +120 -0
- package/lib/project-filesystem.js +528 -0
- package/lib/project-http.js +753 -0
- package/lib/project-image.js +95 -0
- package/lib/project-knowledge.js +88 -0
- package/lib/project-loop.js +1304 -0
- package/lib/project-mcp.js +374 -0
- package/lib/project-memory.js +39 -0
- package/lib/project-notifications.js +262 -0
- package/lib/project-sessions.js +1581 -0
- package/lib/project-user-mention.js +193 -0
- package/lib/project-user-message.js +628 -0
- package/lib/project.js +1303 -0
- package/lib/public/app.js +1031 -0
- package/lib/public/apple-touch-icon.png +0 -0
- package/lib/public/claude-code-avatar.png +0 -0
- package/lib/public/codex-avatar.png +0 -0
- package/lib/public/console-icon.png +0 -0
- package/lib/public/css/admin.css +736 -0
- package/lib/public/css/agent-picker.css +119 -0
- package/lib/public/css/base.css +235 -0
- package/lib/public/css/channel-layout.css +441 -0
- package/lib/public/css/command-palette.css +559 -0
- package/lib/public/css/debate.css +1609 -0
- package/lib/public/css/diff.css +139 -0
- package/lib/public/css/filebrowser.css +1976 -0
- package/lib/public/css/highlight.css +144 -0
- package/lib/public/css/home-hub.css +545 -0
- package/lib/public/css/icon-strip.css +1856 -0
- package/lib/public/css/input.css +1349 -0
- package/lib/public/css/loop.css +1248 -0
- package/lib/public/css/mention.css +317 -0
- package/lib/public/css/menus.css +857 -0
- package/lib/public/css/messages.css +1833 -0
- package/lib/public/css/mobile-nav.css +1332 -0
- package/lib/public/css/notifications-center.css +296 -0
- package/lib/public/css/overlays.css +1273 -0
- package/lib/public/css/playbook.css +264 -0
- package/lib/public/css/profile.css +397 -0
- package/lib/public/css/rewind.css +671 -0
- package/lib/public/css/scheduler-modal.css +1495 -0
- package/lib/public/css/scheduler.css +1420 -0
- package/lib/public/css/server-settings.css +909 -0
- package/lib/public/css/session-search.css +159 -0
- package/lib/public/css/sidebar.css +2012 -0
- package/lib/public/css/skills.css +789 -0
- package/lib/public/css/sticky-notes.css +854 -0
- package/lib/public/css/stt.css +155 -0
- package/lib/public/css/title-bar.css +674 -0
- package/lib/public/css/tooltip.css +67 -0
- package/lib/public/css/user-settings.css +702 -0
- package/lib/public/emoji-data.json +1 -0
- package/lib/public/favicon-banded-32.png +0 -0
- package/lib/public/favicon-banded.png +0 -0
- package/lib/public/favicon-dark.svg +32 -0
- package/lib/public/favicon.svg +32 -0
- package/lib/public/icon-192.png +0 -0
- package/lib/public/icon-512.png +0 -0
- package/lib/public/icon-banded-76.png +0 -0
- package/lib/public/icon-banded-96.png +0 -0
- package/lib/public/icon-mono.svg +25 -0
- package/lib/public/icons/email/gmail.svg +7 -0
- package/lib/public/icons/email/outlook.svg +35 -0
- package/lib/public/icons/email/yahoo.svg +1 -0
- package/lib/public/index.html +1946 -0
- package/lib/public/manifest.json +27 -0
- package/lib/public/markdown-worker.js +43 -0
- package/lib/public/marked.min.js +6 -0
- package/lib/public/modules/admin.js +954 -0
- package/lib/public/modules/agent-picker.js +429 -0
- package/lib/public/modules/app-connection.js +216 -0
- package/lib/public/modules/app-cursors.js +492 -0
- package/lib/public/modules/app-dm.js +265 -0
- package/lib/public/modules/app-favicon.js +231 -0
- package/lib/public/modules/app-header.js +242 -0
- package/lib/public/modules/app-home-hub.js +432 -0
- package/lib/public/modules/app-loop-ui.js +691 -0
- package/lib/public/modules/app-loop-wizard.js +439 -0
- package/lib/public/modules/app-messages.js +1415 -0
- package/lib/public/modules/app-misc.js +463 -0
- package/lib/public/modules/app-notifications.js +651 -0
- package/lib/public/modules/app-panels.js +1061 -0
- package/lib/public/modules/app-projects.js +875 -0
- package/lib/public/modules/app-rate-limit.js +529 -0
- package/lib/public/modules/app-rendering.js +739 -0
- package/lib/public/modules/app-skills-install.js +285 -0
- package/lib/public/modules/avatar.js +36 -0
- package/lib/public/modules/command-palette.js +491 -0
- package/lib/public/modules/console-logo.js +162 -0
- package/lib/public/modules/context-sources.js +365 -0
- package/lib/public/modules/diff.js +412 -0
- package/lib/public/modules/dom-refs.js +21 -0
- package/lib/public/modules/emoji-picker.js +222 -0
- package/lib/public/modules/events.js +21 -0
- package/lib/public/modules/filebrowser.js +1966 -0
- package/lib/public/modules/fileicons.js +172 -0
- package/lib/public/modules/icons.js +80 -0
- package/lib/public/modules/input.js +1102 -0
- package/lib/public/modules/longpress.js +74 -0
- package/lib/public/modules/markdown.js +486 -0
- package/lib/public/modules/mcp-ui.js +295 -0
- package/lib/public/modules/mention.js +1093 -0
- package/lib/public/modules/notifications.js +613 -0
- package/lib/public/modules/playbook.js +578 -0
- package/lib/public/modules/profile.js +594 -0
- package/lib/public/modules/project-settings.js +849 -0
- package/lib/public/modules/project-switcher.js +375 -0
- package/lib/public/modules/qrcode.js +87 -0
- package/lib/public/modules/rewind.js +381 -0
- package/lib/public/modules/scheduler-config.js +1611 -0
- package/lib/public/modules/scheduler-history.js +131 -0
- package/lib/public/modules/scheduler.js +1689 -0
- package/lib/public/modules/server-settings.js +842 -0
- package/lib/public/modules/session-search.js +456 -0
- package/lib/public/modules/settings-defaults.js +253 -0
- package/lib/public/modules/sidebar-mobile.js +1425 -0
- package/lib/public/modules/sidebar-projects.js +2022 -0
- package/lib/public/modules/sidebar-sessions.js +1548 -0
- package/lib/public/modules/sidebar-users.js +449 -0
- package/lib/public/modules/sidebar.js +348 -0
- package/lib/public/modules/skills.js +793 -0
- package/lib/public/modules/state.js +3 -0
- package/lib/public/modules/sticky-notes.js +1221 -0
- package/lib/public/modules/store.js +34 -0
- package/lib/public/modules/stt.js +266 -0
- package/lib/public/modules/terminal.js +987 -0
- package/lib/public/modules/theme.js +812 -0
- package/lib/public/modules/tool-palette.js +562 -0
- package/lib/public/modules/tools.js +2285 -0
- package/lib/public/modules/tooltip.js +150 -0
- package/lib/public/modules/user-settings.js +544 -0
- package/lib/public/modules/utils.js +56 -0
- package/lib/public/modules/ws-ref.js +26 -0
- package/lib/public/style.css +34 -0
- package/lib/public/sw.js +159 -0
- package/lib/push.js +149 -0
- package/lib/scheduler.js +471 -0
- package/lib/sdk-bridge.js +1792 -0
- package/lib/sdk-message-processor.js +740 -0
- package/lib/sdk-message-queue.js +42 -0
- package/lib/sdk-skill-discovery.js +131 -0
- package/lib/sdk-worker.js +677 -0
- package/lib/server-admin.js +712 -0
- package/lib/server-auth.js +737 -0
- package/lib/server-dm.js +170 -0
- package/lib/server-palette.js +104 -0
- package/lib/server-settings.js +553 -0
- package/lib/server-skills.js +280 -0
- package/lib/server.js +1390 -0
- package/lib/session-search.js +693 -0
- package/lib/sessions.js +946 -0
- package/lib/smtp.js +221 -0
- package/lib/terminal-manager.js +219 -0
- package/lib/terminal.js +39 -0
- package/lib/themes/ayu-light.json +9 -0
- package/lib/themes/catppuccin-latte.json +9 -0
- package/lib/themes/catppuccin-mocha.json +9 -0
- package/lib/themes/clagentic-dark.json +10 -0
- package/lib/themes/clagentic-light.json +10 -0
- package/lib/themes/dracula.json +9 -0
- package/lib/themes/everforest-light.json +9 -0
- package/lib/themes/everforest.json +9 -0
- package/lib/themes/github-light.json +9 -0
- package/lib/themes/gruvbox-dark.json +9 -0
- package/lib/themes/gruvbox-light.json +9 -0
- package/lib/themes/monokai.json +9 -0
- package/lib/themes/nord-light.json +9 -0
- package/lib/themes/nord.json +9 -0
- package/lib/themes/one-dark.json +9 -0
- package/lib/themes/one-light.json +9 -0
- package/lib/themes/rose-pine-dawn.json +9 -0
- package/lib/themes/rose-pine.json +9 -0
- package/lib/themes/solarized-dark.json +9 -0
- package/lib/themes/solarized-light.json +9 -0
- package/lib/themes/tokyo-night-light.json +9 -0
- package/lib/themes/tokyo-night.json +9 -0
- package/lib/updater.js +124 -0
- package/lib/user-presence.js +92 -0
- package/lib/users-auth.js +146 -0
- package/lib/users-permissions.js +118 -0
- package/lib/users-preferences.js +254 -0
- package/lib/users.js +465 -0
- package/lib/utils.js +64 -0
- package/lib/worktree.js +134 -0
- package/lib/ws-schema.js +464 -0
- package/lib/yoke/adapters/claude-worker.js +759 -0
- package/lib/yoke/adapters/claude.js +1599 -0
- package/lib/yoke/adapters/codex.js +1559 -0
- package/lib/yoke/codex-app-server.js +352 -0
- package/lib/yoke/index.js +319 -0
- package/lib/yoke/instructions.js +61 -0
- package/lib/yoke/interface.js +98 -0
- package/lib/yoke/mcp-bridge-server.js +302 -0
- package/lib/yoke/package.json +7 -0
- package/package.json +72 -0
|
@@ -0,0 +1,1031 @@
|
|
|
1
|
+
import { avatarUrl, userAvatarUrl } from './modules/avatar.js';
|
|
2
|
+
import { showToast, copyToClipboard, escapeHtml } from './modules/utils.js';
|
|
3
|
+
import { refreshIcons, iconHtml } from './modules/icons.js';
|
|
4
|
+
import { renderMarkdown, highlightCodeBlocks, renderMermaidBlocks, closeMermaidModal, parseEmojis } from './modules/markdown.js';
|
|
5
|
+
import { initSidebar, updatePageTitle, spawnDustParticles } from './modules/sidebar.js';
|
|
6
|
+
import {
|
|
7
|
+
renderSessionList, handleSearchResults, updateSessionPresence,
|
|
8
|
+
updateSessionBadge, populateCliSessionList
|
|
9
|
+
} from './modules/sidebar-sessions.js';
|
|
10
|
+
import {
|
|
11
|
+
renderIconStrip, updateProjectBadge
|
|
12
|
+
} from './modules/sidebar-projects.js';
|
|
13
|
+
import {
|
|
14
|
+
renderUserStrip, closeDmUserPicker, setCurrentDmUser,
|
|
15
|
+
updateDmBadge, renderSidebarPresence, setMentionActive, clearAllMentionActive,
|
|
16
|
+
initSidebarUsers
|
|
17
|
+
} from './modules/sidebar-users.js';
|
|
18
|
+
import { openMobileSheet, updateMobileProjectsTabBadge } from './modules/sidebar-mobile.js';
|
|
19
|
+
import { initRewind, setRewindMode, showRewindModal, clearPendingRewindUuid, addRewindButton, onRewindComplete, onRewindError } from './modules/rewind.js';
|
|
20
|
+
import { initNotifications, showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './modules/notifications.js';
|
|
21
|
+
import { initInput, clearPendingImages, handleInputSync, autoResize, builtinCommands, sendMessage, hasSendableContent, setScheduleBtnDisabled, setScheduleDelayMs, clearScheduleDelay } from './modules/input.js';
|
|
22
|
+
import { initQrCode, triggerShare } from './modules/qrcode.js';
|
|
23
|
+
import { initFileBrowser, loadRootDirectory, refreshTree, handleFsList, handleFsRead, handleDirChanged, refreshIfOpen, handleFileChanged, handleFileHistory, handleGitDiff, handleFileAt, getPendingNavigate, closeFileViewer, resetFileBrowser } from './modules/filebrowser.js';
|
|
24
|
+
import { initTerminal, openTerminal, closeTerminal, resetTerminals, handleTermList, handleTermCreated, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed, sendTerminalCommand } from './modules/terminal.js';
|
|
25
|
+
import { initContextSources, updateTerminalList, updateBrowserTabList, handleContextSourcesState, getActiveSources, hasActiveSources } from './modules/context-sources.js';
|
|
26
|
+
import { initStickyNotes, handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted, openArchive, closeArchive, isArchiveOpen, hideNotes, showNotes, isNotesVisible, createNote } from './modules/sticky-notes.js';
|
|
27
|
+
import { initTheme, getThemeColor, getComputedVar, onThemeChange, getCurrentTheme, getChatLayout } from './modules/theme.js';
|
|
28
|
+
import { initTools, resetToolState, saveToolState, restoreToolState, renderAskUserQuestion, markAskUserAnswered, renderPermissionRequest, markPermissionResolved, markPermissionCancelled, renderElicitationRequest, markElicitationResolved, renderPlanBanner, renderPlanCard, handleTodoWrite, handleTaskCreate, handleTaskUpdate, startThinking, appendThinking, stopThinking, resetThinkingGroup, createToolItem, updateToolExecuting, updateToolResult, markAllToolsDone, addTurnMeta, resetTurnMetaCost, enableMainInput, getTools, getPlanContent, setPlanContent, isPlanFilePath, getTodoTools, updateSubagentActivity, addSubagentToolEntry, markSubagentDone, updateSubagentProgress, initSubagentStop, closeToolGroup, removeToolFromGroup } from './modules/tools.js';
|
|
29
|
+
import { initServerSettings, updateSettingsStats, updateSettingsModels, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleGlobalClaudeMdRead, handleGlobalClaudeMdWrite } from './modules/server-settings.js';
|
|
30
|
+
import { initProjectSettings, handleInstructionsRead, handleInstructionsWrite, handleProjectEnv, handleProjectEnvSaved, isProjectSettingsOpen, handleProjectSharedEnv, handleProjectSharedEnvSaved, handleProjectOwnerChanged } from './modules/project-settings.js';
|
|
31
|
+
import { initSkills, handleSkillInstalled, handleSkillUninstalled } from './modules/skills.js';
|
|
32
|
+
import { initMcp } from './modules/mcp-ui.js';
|
|
33
|
+
import { initScheduler, resetScheduler, handleLoopRegistryUpdated, handleScheduleRunStarted, handleScheduleRunFinished, handleLoopScheduled, openSchedulerToTab, isSchedulerOpen, closeScheduler, enterCraftingMode, exitCraftingMode, handleLoopRegistryFiles, getUpcomingSchedules } from './modules/scheduler.js';
|
|
34
|
+
import { initConsoleLogo, startLogoAnimation, stopLogoAnimation } from './modules/console-logo.js';
|
|
35
|
+
import { initPlaybook, openPlaybook, getPlaybooks, getPlaybookForTip, isCompleted as isPlaybookCompleted } from './modules/playbook.js';
|
|
36
|
+
import { initSTT } from './modules/stt.js';
|
|
37
|
+
import { initProfile, getProfileLang } from './modules/profile.js';
|
|
38
|
+
import { initUserSettings } from './modules/user-settings.js';
|
|
39
|
+
import { initToolPalettes } from './modules/tool-palette.js';
|
|
40
|
+
import { initProjectSwitcher } from './modules/project-switcher.js';
|
|
41
|
+
import { initAdmin, checkAdminAccess } from './modules/admin.js';
|
|
42
|
+
import { initSessionSearch, toggleSearch, closeSearch, isSearchOpen, handleFindInSessionResults, onHistoryPrepended as onSessionSearchHistoryPrepended } from './modules/session-search.js';
|
|
43
|
+
import { initTooltips, registerTooltip } from './modules/tooltip.js';
|
|
44
|
+
import { initCommandPalette, handlePaletteSessionSwitch, setPaletteVersion } from './modules/command-palette.js';
|
|
45
|
+
import { initAgentPicker } from './modules/agent-picker.js';
|
|
46
|
+
import { initLongPress } from './modules/longpress.js';
|
|
47
|
+
import { initConnection, connect as _connConnect, setStatus as _connSetStatus, scheduleReconnect as _connScheduleReconnect, cancelReconnect as _connCancelReconnect } from './modules/app-connection.js';
|
|
48
|
+
import { processMessage as _msgProcessMessage } from './modules/app-messages.js';
|
|
49
|
+
import { getWs as _getWsRef, setWs as _setWsRef } from './modules/ws-ref.js';
|
|
50
|
+
import { initHomeHub, showHomeHub as _hubShowHomeHub, hideHomeHub as _hubHideHomeHub, handleHubSchedules as _hubHandleHubSchedules, renderHomeHub as _hubRenderHomeHub, isHomeHubVisible } from './modules/app-home-hub.js';
|
|
51
|
+
import { initRateLimit, handleRateLimitEvent as _rlHandleRateLimitEvent, updateRateLimitUsage as _rlUpdateRateLimitUsage, addScheduledMessageBubble as _rlAddScheduledMessageBubble, removeScheduledMessageBubble as _rlRemoveScheduledMessageBubble, handleFastModeState as _rlHandleFastModeState, getScheduledMsgEl, resetRateLimitState } from './modules/app-rate-limit.js';
|
|
52
|
+
import { initCursors, handleRemoteCursorMove as _curHandleRemoteCursorMove, handleRemoteCursorLeave as _curHandleRemoteCursorLeave, handleRemoteSelection as _curHandleRemoteSelection, clearRemoteCursors as _curClearRemoteCursors, initCursorToggle } from './modules/app-cursors.js';
|
|
53
|
+
import { initFavicon, updateFavicon as _favUpdateFavicon, setSendBtnMode as _favSetSendBtnMode, blinkIO as _favBlinkIO, blinkSessionDot as _favBlinkSessionDot, updateCrossProjectBlink as _favUpdateCrossProjectBlink, startUrgentBlink as _favStartUrgentBlink, stopUrgentBlink as _favStopUrgentBlink, setActivity as _favSetActivity, drawFaviconAnimFrame as _favDrawFaviconAnimFrame } from './modules/app-favicon.js';
|
|
54
|
+
import { initHeader, closeSessionInfoPopover as _hdrCloseSessionInfoPopover, updateHistorySentinel as _hdrUpdateHistorySentinel, requestMoreHistory as _hdrRequestMoreHistory, prependOlderHistory as _hdrPrependOlderHistory } from './modules/app-header.js';
|
|
55
|
+
import { initMisc, flushPendingExtMessages, showImageModal as _miscShowImageModal, closeImageModal as _miscCloseImageModal, showPasteModal as _miscShowPasteModal, closePasteModal as _miscClosePasteModal, showConfirm as _miscShowConfirm, hideConfirm as _miscHideConfirm, showForceChangePinOverlay as _miscShowForceChangePinOverlay, sendExtensionCommand as _miscSendExtensionCommand, handleExtensionResult as _miscHandleExtensionResult } from './modules/app-misc.js';
|
|
56
|
+
import { initSkillInstall, requireSkills as _siRequireSkills, handleSkillInstallWs as _siHandleSkillInstallWs } from './modules/app-skills-install.js';
|
|
57
|
+
import { initLoopUi, updateLoopInputVisibility as _loopUpdateLoopInputVisibility, updateLoopButton as _loopUpdateLoopButton, showLoopBanner as _loopShowLoopBanner, updateLoopBanner as _loopUpdateLoopBanner, updateRalphBars as _loopUpdateRalphBars, showRalphCraftingBar as _loopShowRalphCraftingBar, showRalphApprovalBar as _loopShowRalphApprovalBar, updateRalphApprovalStatus as _loopUpdateRalphApprovalStatus, openRalphPreviewModal as _loopOpenRalphPreviewModal, showExecModal as _loopShowExecModal, closeExecModal as _loopCloseExecModal, updateExecModalStatus as _loopUpdateExecModalStatus } from './modules/app-loop-ui.js';
|
|
58
|
+
import { initLoopWizard, openRalphWizard as _loopOpenRalphWizard, closeRalphWizard as _loopCloseRalphWizard, getWizardSource as _loopGetWizardSource } from './modules/app-loop-wizard.js';
|
|
59
|
+
import { initAppNotifications, handleNotificationsState as _notifHandleState, handleNotificationCreated as _notifHandleCreated, handleNotificationDismissed as _notifHandleDismissed, handleNotificationDismissedAll as _notifHandleDismissedAll } from './modules/app-notifications.js';
|
|
60
|
+
import { createStore, store } from './modules/store.js';
|
|
61
|
+
import { initPanels, updateConfigChip as _panUpdateConfigChip, getModelEffortLevels as _panGetModelEffortLevels, accumulateUsage as _panAccumulateUsage, updateUsagePanel as _panUpdateUsagePanel, resetUsage as _panResetUsage, toggleUsagePanel as _panToggleUsagePanel, formatTokens as _panFormatTokens, updateStatusPanel as _panUpdateStatusPanel, requestProcessStats as _panRequestProcessStats, toggleStatusPanel as _panToggleStatusPanel, accumulateContext as _panAccumulateContext, updateContextPanel as _panUpdateContextPanel, resetContext as _panResetContext, resetContextData as _panResetContextData, minimizeContext as _panMinimizeContext, expandContext as _panExpandContext, toggleContextPanel as _panToggleContextPanel, getContextView as _panGetContextView, renderCtxPopover as _panRenderCtxPopover, hideCtxPopover as _panHideCtxPopover, formatBytes as _panFormatBytes, formatUptime as _panFormatUptime, getModelSupportsEffort as _panGetModelSupportsEffort, getSessionUsage, setSessionUsage, getContextData, setContextData, setContextView as _panSetContextView, applyContextView as _panApplyContextView } from './modules/app-panels.js';
|
|
62
|
+
import { initProjects, onProjectListUpdated, updateProjectList as _projUpdateProjectList, renderProjectList as _projRenderProjectList, renderTopbarPresence as _projRenderTopbarPresence, switchProject as _projSwitchProject, resetClientState as _projResetClientState, confirmRemoveProject as _projConfirmRemoveProject, handleRemoveProjectCheckResult as _projHandleRemoveProjectCheckResult, handleRemoveProjectResult as _projHandleRemoveProjectResult, openAddProjectModal as _projOpenAddProjectModal, closeAddProjectModal as _projCloseAddProjectModal, handleBrowseDirResult as _projHandleBrowseDirResult, handleAddProjectResult as _projHandleAddProjectResult, handleCloneProgress as _projHandleCloneProgress, showUpdateAvailable as _projShowUpdateAvailable, getCachedProjects, setCachedProjects, getCachedProjectCount, getCachedRemovedProjects, setCachedRemovedProjects } from './modules/app-projects.js';
|
|
63
|
+
import { initRendering, addToMessages as _renAddToMessages, scrollToBottom as _renScrollToBottom, forceScrollToBottom as _renForceScrollToBottom, addUserMessage as _renAddUserMessage, getMsgTime as _renGetMsgTime, shouldGroupMessage as _renShouldGroupMessage, ensureAssistantBlock as _renEnsureAssistantBlock, addCopyHandler as _renAddCopyHandler, appendDelta as _renAppendDelta, flushStreamBuffer as _renFlushStreamBuffer, finalizeAssistantBlock as _renFinalizeAssistantBlock, addSystemMessage as _renAddSystemMessage, addConflictMessage as _renAddConflictMessage, addContextOverflowMessage as _renAddContextOverflowMessage, showClaudePreThinking as _renShowClaudePreThinking, showSuggestionChips as _renShowSuggestionChips, hideSuggestionChips as _renHideSuggestionChips, getGhostSuggestion as _renGetGhostSuggestion, getTurnCounter, setTurnCounter, getPrependAnchor, setPrependAnchor, getActivityEl, setActivityEl, getIsUserScrolledUp, setIsUserScrolledUp, getStickyBottom, armStickyBottom, disarmStickyBottom } from './modules/app-rendering.js';
|
|
64
|
+
import { initDm, openDm as _dmOpenDm, enterDmMode as _dmEnterDmMode, exitDmMode as _dmExitDmMode, appendDmMessage as _dmAppendDmMessage, showDmTypingIndicator as _dmShowDmTypingIndicator, handleDmSend as _dmHandleDmSend } from './modules/app-dm.js';
|
|
65
|
+
import { initMention, handleMentionStart, handleMentionStream, handleMentionDone, handleMentionError, handleMentionActivity, renderMentionUser, renderMentionResponse } from './modules/mention.js';
|
|
66
|
+
|
|
67
|
+
// --- Base path for multi-project routing ---
|
|
68
|
+
var slugMatch = location.pathname.match(/^\/p\/([a-z0-9_-]+)/);
|
|
69
|
+
var basePath = slugMatch ? "/p/" + slugMatch[1] + "/" : "/";
|
|
70
|
+
var wsPath = slugMatch ? "/p/" + slugMatch[1] + "/ws" : "/ws";
|
|
71
|
+
|
|
72
|
+
// --- DOM refs ---
|
|
73
|
+
var $ = function (id) { return document.getElementById(id); };
|
|
74
|
+
var messagesEl = $("messages");
|
|
75
|
+
var inputEl = $("input");
|
|
76
|
+
var sendBtn = $("send-btn");
|
|
77
|
+
function getStatusDot() {
|
|
78
|
+
return document.querySelector("#icon-strip-projects .icon-strip-item.active .icon-strip-status") ||
|
|
79
|
+
document.querySelector("#icon-strip-projects .icon-strip-wt-item.active .icon-strip-status") ||
|
|
80
|
+
document.querySelector("#icon-strip-users .icon-strip-mate.active .icon-strip-status");
|
|
81
|
+
}
|
|
82
|
+
var headerTitleEl = $("header-title");
|
|
83
|
+
var headerRenameBtn = $("header-rename-btn");
|
|
84
|
+
var slashMenu = $("slash-menu");
|
|
85
|
+
var suggestionChipsEl = $("suggestion-chips");
|
|
86
|
+
var sidebar = $("sidebar");
|
|
87
|
+
var sidebarOverlay = $("sidebar-overlay");
|
|
88
|
+
var sessionListEl = $("session-list");
|
|
89
|
+
var newSessionBtn = $("new-session-btn");
|
|
90
|
+
var hamburgerBtn = $("hamburger-btn");
|
|
91
|
+
var sidebarToggleBtn = $("sidebar-toggle-btn");
|
|
92
|
+
var sidebarExpandBtn = $("sidebar-expand-btn");
|
|
93
|
+
var resumeSessionBtn = $("resume-session-btn");
|
|
94
|
+
var imagePreviewBar = $("image-preview-bar");
|
|
95
|
+
var connectOverlay = $("connect-overlay");
|
|
96
|
+
|
|
97
|
+
// --- DM Mode ---
|
|
98
|
+
// dmMode, dmUnread, cachedAllUsers, cachedOnlineIds, cachedDmFavorites,
|
|
99
|
+
// cachedDmConversations, dmRemovedUsers, dmTargetUser, dmKey -> store
|
|
100
|
+
var dmMessageCache = [];
|
|
101
|
+
|
|
102
|
+
var CLAUDE_CODE_AVATAR = "/claude-code-avatar.png";
|
|
103
|
+
|
|
104
|
+
// --- Home Hub (delegated to app-home-hub.js) ---
|
|
105
|
+
function showHomeHub() { _hubShowHomeHub(); }
|
|
106
|
+
function hideHomeHub() { _hubHideHomeHub(); }
|
|
107
|
+
function handleHubSchedules(msg) { _hubHandleHubSchedules(msg); }
|
|
108
|
+
function renderHomeHub(projects) { _hubRenderHomeHub(projects); }
|
|
109
|
+
|
|
110
|
+
// --- DM (delegated to app-dm.js) ---
|
|
111
|
+
function openDm(userId) { _dmOpenDm(userId); }
|
|
112
|
+
function enterDmMode(key, targetUser, messages) { _dmEnterDmMode(key, targetUser, messages); }
|
|
113
|
+
function exitDmMode(skipProjectSwitch) { _dmExitDmMode(skipProjectSwitch); }
|
|
114
|
+
function appendDmMessage(msg) { _dmAppendDmMessage(msg); }
|
|
115
|
+
function showDmTypingIndicator(show) { _dmShowDmTypingIndicator(show); }
|
|
116
|
+
function handleDmSend() { _dmHandleDmSend(); }
|
|
117
|
+
|
|
118
|
+
// --- Project List ---
|
|
119
|
+
var projectListSection = $("project-list-section");
|
|
120
|
+
var projectListEl = $("project-list");
|
|
121
|
+
var projectListAddBtn = $("project-list-add");
|
|
122
|
+
var projectHint = $("project-hint");
|
|
123
|
+
var projectHintDismiss = $("project-hint-dismiss");
|
|
124
|
+
// cachedProjects, cachedProjectCount, cachedRemovedProjects -> modules/app-projects.js
|
|
125
|
+
// currentProjectOwnerId -> store
|
|
126
|
+
var currentSlug = slugMatch ? slugMatch[1] : null; // kept for pre-store init
|
|
127
|
+
|
|
128
|
+
// updateProjectList, renderTopbarPresence, renderProjectList -> modules/app-projects.js
|
|
129
|
+
function updateProjectList(msg) { _projUpdateProjectList(msg); }
|
|
130
|
+
function renderTopbarPresence(serverUsers) { _projRenderTopbarPresence(serverUsers); }
|
|
131
|
+
function renderProjectList() { _projRenderProjectList(); }
|
|
132
|
+
// projectListAddBtn listener -> modules/app-projects.js (initProjects)
|
|
133
|
+
|
|
134
|
+
// Prevent Cmd+Z / Cmd+Shift+Z from triggering browser back/forward (Arc, etc.)
|
|
135
|
+
// Always block browser default for Cmd+Z and manually invoke undo/redo via execCommand
|
|
136
|
+
document.addEventListener("keydown", function (e) {
|
|
137
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "z") {
|
|
138
|
+
var el = document.activeElement;
|
|
139
|
+
var tag = el && el.tagName;
|
|
140
|
+
if (tag === "TEXTAREA" || tag === "INPUT" || (el && el.isContentEditable)) {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
if (e.shiftKey) {
|
|
144
|
+
document.execCommand("redo", false, null);
|
|
145
|
+
} else {
|
|
146
|
+
document.execCommand("undo", false, null);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, true);
|
|
151
|
+
|
|
152
|
+
document.addEventListener("keydown", function (e) {
|
|
153
|
+
if (e.key === "Escape") {
|
|
154
|
+
if (isHomeHubVisible() && store.get('currentSlug')) {
|
|
155
|
+
hideHomeHub();
|
|
156
|
+
if (document.documentElement.classList.contains("pwa-standalone")) {
|
|
157
|
+
history.replaceState(null, "", "/p/" + store.get('currentSlug') + "/");
|
|
158
|
+
} else {
|
|
159
|
+
history.pushState(null, "", "/p/" + store.get('currentSlug') + "/");
|
|
160
|
+
}
|
|
161
|
+
var homeIcon = document.querySelector(".icon-strip-home");
|
|
162
|
+
if (homeIcon) homeIcon.classList.remove("active");
|
|
163
|
+
renderProjectList();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
closeImageModal();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (projectHintDismiss) {
|
|
171
|
+
projectHintDismiss.addEventListener("click", function () {
|
|
172
|
+
projectHint.classList.add("hidden");
|
|
173
|
+
try { localStorage.setItem("clagentic-project-hint-dismissed", "1"); } catch (e) {}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Modal close handlers (replaces inline onclick)
|
|
178
|
+
$("paste-modal").querySelector(".confirm-backdrop").addEventListener("click", function() {
|
|
179
|
+
$("paste-modal").classList.add("hidden");
|
|
180
|
+
});
|
|
181
|
+
$("paste-modal").querySelector(".paste-modal-close").addEventListener("click", function() {
|
|
182
|
+
$("paste-modal").classList.add("hidden");
|
|
183
|
+
});
|
|
184
|
+
$("paste-modal").querySelector(".paste-modal-copy").addEventListener("click", function() {
|
|
185
|
+
var body = $("paste-modal-body");
|
|
186
|
+
if (body) copyToClipboard(body.textContent, "Copied to clipboard");
|
|
187
|
+
});
|
|
188
|
+
$("mermaid-modal").querySelector(".confirm-backdrop").addEventListener("click", closeMermaidModal);
|
|
189
|
+
$("mermaid-modal").querySelector(".mermaid-modal-btn[title='Close']").addEventListener("click", closeMermaidModal);
|
|
190
|
+
$("image-modal").querySelector(".confirm-backdrop").addEventListener("click", closeImageModal);
|
|
191
|
+
$("image-modal").querySelector(".image-modal-close").addEventListener("click", closeImageModal);
|
|
192
|
+
|
|
193
|
+
// showImageModal, closeImageModal -> modules/app-misc.js
|
|
194
|
+
function showImageModal(src) { _miscShowImageModal(src); }
|
|
195
|
+
function closeImageModal() { _miscCloseImageModal(); }
|
|
196
|
+
|
|
197
|
+
// --- State ---
|
|
198
|
+
// connected, processing, activeSessionId, sessionDrafts -> store
|
|
199
|
+
// loopActive, loopAvailable, loopIteration, loopMaxIterations, loopBannerName, loopCurrentSessionId,
|
|
200
|
+
// ralphPhase, ralphCraftingSessionId, ralphCraftingSource, ralphFilesReady, ralphPreviewContent -> modules/app-loop-ui.js
|
|
201
|
+
// wizardStep, wizardSource, wizardData, loopModeChoice, promptAuthor, judgeAuthor -> modules/app-loop-wizard.js
|
|
202
|
+
// slashCommands, cliSessionId -> store
|
|
203
|
+
var projectName = ""; // kept for pre-store localStorage init
|
|
204
|
+
// turnCounter -> modules/app-rendering.js
|
|
205
|
+
|
|
206
|
+
// Restore cached project name and icon for instant display (before WS connects)
|
|
207
|
+
try {
|
|
208
|
+
var _cachedProjectName = localStorage.getItem("clagentic-project-name-" + (currentSlug || "default")) || localStorage.getItem("clay-project-name-" + (currentSlug || "default"));
|
|
209
|
+
if (_cachedProjectName) {
|
|
210
|
+
projectName = _cachedProjectName;
|
|
211
|
+
if (headerTitleEl) headerTitleEl.textContent = _cachedProjectName;
|
|
212
|
+
var _tbp = $("title-bar-project-name");
|
|
213
|
+
if (_tbp) _tbp.textContent = _cachedProjectName;
|
|
214
|
+
}
|
|
215
|
+
var _cachedProjectIcon = localStorage.getItem("clagentic-project-icon-" + (currentSlug || "default")) || localStorage.getItem("clay-project-icon-" + (currentSlug || "default"));
|
|
216
|
+
if (_cachedProjectIcon) {
|
|
217
|
+
var _tbi = $("title-bar-project-icon");
|
|
218
|
+
if (_tbi) {
|
|
219
|
+
_tbi.textContent = _cachedProjectIcon;
|
|
220
|
+
parseEmojis(_tbi);
|
|
221
|
+
_tbi.classList.add("has-icon");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} catch (e) {}
|
|
225
|
+
// messageUuidMap, historyFrom, historyTotal -> store
|
|
226
|
+
// prependAnchor, replayingHistory, isUserScrolledUp, scrollThreshold -> modules/app-rendering.js
|
|
227
|
+
// loadingMore -> moved to store
|
|
228
|
+
// historySentinelObserver -> modules/app-header.js
|
|
229
|
+
|
|
230
|
+
// builtinCommands -> modules/input.js
|
|
231
|
+
|
|
232
|
+
// --- Header session rename, session info popover -> modules/app-header.js
|
|
233
|
+
function closeSessionInfoPopover() { _hdrCloseSessionInfoPopover(); }
|
|
234
|
+
|
|
235
|
+
// --- Modals (confirm, paste) -> modules/app-misc.js
|
|
236
|
+
function showPasteModal(text) { _miscShowPasteModal(text); }
|
|
237
|
+
function closePasteModal() { _miscClosePasteModal(); }
|
|
238
|
+
function showConfirm(text, onConfirm, okLabel, destructive) { _miscShowConfirm(text, onConfirm, okLabel, destructive); }
|
|
239
|
+
function hideConfirm() { _miscHideConfirm(); }
|
|
240
|
+
|
|
241
|
+
// --- Initialize store (single source of truth for client state) ---
|
|
242
|
+
createStore({
|
|
243
|
+
// session / routing
|
|
244
|
+
basePath: basePath,
|
|
245
|
+
wsPath: wsPath,
|
|
246
|
+
dmMode: false,
|
|
247
|
+
historyFrom: 0,
|
|
248
|
+
loadingMore: false,
|
|
249
|
+
historyTotal: 0,
|
|
250
|
+
replayingHistory: false,
|
|
251
|
+
projectName: projectName,
|
|
252
|
+
cwd: "",
|
|
253
|
+
currentSlug: currentSlug,
|
|
254
|
+
currentProjectOwnerId: null,
|
|
255
|
+
isOsUsers: false,
|
|
256
|
+
skipPermsEnabled: false,
|
|
257
|
+
slashCommands: [],
|
|
258
|
+
processing: false,
|
|
259
|
+
activeSessionId: null,
|
|
260
|
+
cliSessionId: null,
|
|
261
|
+
isHeadlessMode: false,
|
|
262
|
+
connected: false,
|
|
263
|
+
// dm
|
|
264
|
+
dmTargetUser: null,
|
|
265
|
+
dmKey: null,
|
|
266
|
+
cachedDmFavorites: [],
|
|
267
|
+
pendingTermCommand: null,
|
|
268
|
+
myUserId: null,
|
|
269
|
+
isMultiUserMode: false,
|
|
270
|
+
dmUnread: {},
|
|
271
|
+
dmRemovedUsers: {},
|
|
272
|
+
cachedAllUsers: [],
|
|
273
|
+
cachedOnlineIds: [],
|
|
274
|
+
cachedDmConversations: [],
|
|
275
|
+
sessionDrafts: {},
|
|
276
|
+
messageUuidMap: [],
|
|
277
|
+
// rendering
|
|
278
|
+
currentMsgTs: null,
|
|
279
|
+
richContextUsage: null,
|
|
280
|
+
currentMsgEl: null,
|
|
281
|
+
currentFullText: "",
|
|
282
|
+
// panels
|
|
283
|
+
currentModel: "",
|
|
284
|
+
currentModels: [],
|
|
285
|
+
currentMode: "default",
|
|
286
|
+
currentEffort: "medium",
|
|
287
|
+
currentBetas: [],
|
|
288
|
+
currentThinking: "adaptive",
|
|
289
|
+
currentThinkingBudget: 10000,
|
|
290
|
+
codexApproval: null,
|
|
291
|
+
codexSandbox: null,
|
|
292
|
+
codexWebSearch: null,
|
|
293
|
+
ctxPopoverVisible: false,
|
|
294
|
+
headerContextEl: null,
|
|
295
|
+
// loop
|
|
296
|
+
loopActive: false,
|
|
297
|
+
loopAvailable: false,
|
|
298
|
+
loopIteration: 0,
|
|
299
|
+
loopMaxIterations: 0,
|
|
300
|
+
loopBannerName: null,
|
|
301
|
+
loopCurrentSessionId: null,
|
|
302
|
+
ralphPhase: "idle",
|
|
303
|
+
ralphCraftingSessionId: null,
|
|
304
|
+
ralphCraftingSource: null,
|
|
305
|
+
ralphFilesReady: { promptReady: false, judgeReady: false, bothReady: false },
|
|
306
|
+
ralphPreviewContent: { prompt: "", judge: "" },
|
|
307
|
+
execModalShown: false,
|
|
308
|
+
// skills
|
|
309
|
+
knownInstalledSkills: {},
|
|
310
|
+
// permissions (RBAC)
|
|
311
|
+
permissions: null,
|
|
312
|
+
// loop wizard
|
|
313
|
+
wizardData: { name: "", task: "", maxIterations: null, cron: null }
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// --- Rewind (module) ---
|
|
317
|
+
initRewind({
|
|
318
|
+
$: $,
|
|
319
|
+
get ws() { return _getWsRef(); },
|
|
320
|
+
get connected() { return store.get('connected'); },
|
|
321
|
+
get processing() { return store.get('processing'); },
|
|
322
|
+
messagesEl: messagesEl,
|
|
323
|
+
addSystemMessage: addSystemMessage,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// --- Theme (module) ---
|
|
327
|
+
initTheme();
|
|
328
|
+
|
|
329
|
+
// --- Tooltips ---
|
|
330
|
+
initTooltips();
|
|
331
|
+
|
|
332
|
+
// --- Long-press context menu for touch devices ---
|
|
333
|
+
initLongPress();
|
|
334
|
+
|
|
335
|
+
// --- Sidebar (module) ---
|
|
336
|
+
var sidebarCtx = {
|
|
337
|
+
$: $,
|
|
338
|
+
get ws() { return _getWsRef(); },
|
|
339
|
+
get connected() { return store.get('connected'); },
|
|
340
|
+
get projectName() { return store.get('projectName'); },
|
|
341
|
+
messagesEl: messagesEl,
|
|
342
|
+
sessionListEl: sessionListEl,
|
|
343
|
+
sidebar: sidebar,
|
|
344
|
+
sidebarOverlay: sidebarOverlay,
|
|
345
|
+
sidebarToggleBtn: sidebarToggleBtn,
|
|
346
|
+
sidebarExpandBtn: sidebarExpandBtn,
|
|
347
|
+
hamburgerBtn: hamburgerBtn,
|
|
348
|
+
newSessionBtn: newSessionBtn,
|
|
349
|
+
resumeSessionBtn: resumeSessionBtn,
|
|
350
|
+
headerTitleEl: headerTitleEl,
|
|
351
|
+
showConfirm: showConfirm,
|
|
352
|
+
onFilesTabOpen: function () { loadRootDirectory(); },
|
|
353
|
+
switchProject: function (slug) { switchProject(slug); },
|
|
354
|
+
openTerminal: function () { openTerminal(); },
|
|
355
|
+
showHomeHub: function () { showHomeHub(); },
|
|
356
|
+
openRalphWizard: function (source) { openRalphWizard(source); },
|
|
357
|
+
getUpcomingSchedules: getUpcomingSchedules,
|
|
358
|
+
get multiUser() { return store.get('isMultiUserMode'); },
|
|
359
|
+
get myUserId() { return store.get('myUserId'); },
|
|
360
|
+
get projectOwnerId() { return store.get('currentProjectOwnerId'); },
|
|
361
|
+
get ownerLocked() { return store.get('ownerLocked'); },
|
|
362
|
+
openDm: function (userId) { openDm(userId); },
|
|
363
|
+
openAddProjectModal: function () { openAddProjectModal(); },
|
|
364
|
+
sendWs: function (msg) { var _ws = _getWsRef(); if (_ws && _ws.readyState === 1) _ws.send(JSON.stringify(msg)); },
|
|
365
|
+
onDmRemoveUser: function (userId) { var dr = Object.assign({}, store.get('dmRemovedUsers')); dr[userId] = true; store.set({ dmRemovedUsers: dr }); },
|
|
366
|
+
getHistoryFrom: function () { return store.get('historyFrom'); },
|
|
367
|
+
get permissions() { return store.get('permissions'); },
|
|
368
|
+
get projectList() { return getCachedProjects() || []; },
|
|
369
|
+
};
|
|
370
|
+
// Render the customizable tool palettes BEFORE initSidebar so the
|
|
371
|
+
// buttons exist in the DOM when sidebar.js (and later terminal.js /
|
|
372
|
+
// mcp-ui.js / etc.) attach click handlers by ID.
|
|
373
|
+
initToolPalettes();
|
|
374
|
+
initSidebar(sidebarCtx);
|
|
375
|
+
initSidebarUsers();
|
|
376
|
+
|
|
377
|
+
initCommandPalette({
|
|
378
|
+
switchProject: function (slug) { switchProject(slug); },
|
|
379
|
+
currentSlug: function () { return store.get('currentSlug'); },
|
|
380
|
+
projectList: function () { return getCachedProjects() || []; },
|
|
381
|
+
allUsers: function () { return store.get('cachedAllUsers') || []; },
|
|
382
|
+
dmConversations: function () { return store.get('cachedDmConversations') || []; },
|
|
383
|
+
myUserId: function () { return store.get('myUserId'); },
|
|
384
|
+
selectSession: function (id) {
|
|
385
|
+
// Close any open panels before switching
|
|
386
|
+
if (isSchedulerOpen()) closeScheduler();
|
|
387
|
+
var stickyPanel = document.getElementById("sticky-notes-panel");
|
|
388
|
+
if (stickyPanel && !stickyPanel.classList.contains("hidden")) {
|
|
389
|
+
var stickyBtn = document.getElementById("sticky-notes-sidebar-btn");
|
|
390
|
+
if (stickyBtn) stickyBtn.click();
|
|
391
|
+
}
|
|
392
|
+
var _ws = _getWsRef();
|
|
393
|
+
if (_ws && _ws.readyState === 1) {
|
|
394
|
+
_ws.send(JSON.stringify({ type: "switch_session", id: id }));
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
openDm: function (userId) { openDm(userId); },
|
|
398
|
+
runAction: function (action) {
|
|
399
|
+
switch (action) {
|
|
400
|
+
case "openSettings":
|
|
401
|
+
var sb = document.getElementById("server-settings-btn");
|
|
402
|
+
if (sb) sb.click();
|
|
403
|
+
break;
|
|
404
|
+
case "showHome": showHomeHub(); break;
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// Agent picker (lr-7db0). No global hotkey — opened from the project
|
|
410
|
+
// session-list "Start agent chat" button.
|
|
411
|
+
initAgentPicker();
|
|
412
|
+
|
|
413
|
+
// Project switcher (Cmd/Ctrl+E). Init after command palette so its
|
|
414
|
+
// keydown listener registers later — capture-phase ordering doesn't
|
|
415
|
+
// matter here but it keeps related bootstrap steps adjacent.
|
|
416
|
+
initProjectSwitcher();
|
|
417
|
+
|
|
418
|
+
// --- Connect overlay (animated console logo) ---
|
|
419
|
+
var consoleLogoSvg = $("console-logo-svg");
|
|
420
|
+
initConsoleLogo(consoleLogoSvg);
|
|
421
|
+
startLogoAnimation();
|
|
422
|
+
function startVerbCycle() { startLogoAnimation(); }
|
|
423
|
+
function stopVerbCycle() { stopLogoAnimation(); }
|
|
424
|
+
|
|
425
|
+
// --- Favicon, IO blink, status/activity -> modules/app-favicon.js
|
|
426
|
+
function startPixelAnim() {}
|
|
427
|
+
function stopPixelAnim() {}
|
|
428
|
+
function updateFavicon(bgColor) { _favUpdateFavicon(bgColor); }
|
|
429
|
+
function setSendBtnMode(mode) { _favSetSendBtnMode(mode); }
|
|
430
|
+
function blinkIO() { _favBlinkIO(); }
|
|
431
|
+
function blinkSessionDot(sessionId) { _favBlinkSessionDot(sessionId); }
|
|
432
|
+
function updateCrossProjectBlink() { _favUpdateCrossProjectBlink(); }
|
|
433
|
+
function startUrgentBlink() { _favStartUrgentBlink(); }
|
|
434
|
+
function stopUrgentBlink() { _favStopUrgentBlink(); }
|
|
435
|
+
function setStatus(status) { _connSetStatus(status); }
|
|
436
|
+
function setActivity(text) { _favSetActivity(text); }
|
|
437
|
+
|
|
438
|
+
// --- Pre-thinking (delegated to app-rendering.js) ---
|
|
439
|
+
function showClaudePreThinking() { _renShowClaudePreThinking(); }
|
|
440
|
+
|
|
441
|
+
// --- Config chip, usage, status, context panels (delegated to app-panels.js) ---
|
|
442
|
+
// currentModels, currentModel, currentMode, currentEffort, currentBetas,
|
|
443
|
+
// currentThinking, currentThinkingBudget, sessionUsage, contextData,
|
|
444
|
+
// headerContextEl, richContextUsage, ctxPopoverVisible -> modules/app-panels.js
|
|
445
|
+
// skipPermsEnabled, isOsUsers -> store
|
|
446
|
+
|
|
447
|
+
function updateConfigChip() { _panUpdateConfigChip(); }
|
|
448
|
+
function getModelEffortLevels() { return _panGetModelEffortLevels(); }
|
|
449
|
+
function getModelSupportsEffort() { return _panGetModelSupportsEffort(); }
|
|
450
|
+
function formatTokens(n) { return _panFormatTokens(n); }
|
|
451
|
+
function updateUsagePanel() { _panUpdateUsagePanel(); }
|
|
452
|
+
function accumulateUsage(cost, usage) { _panAccumulateUsage(cost, usage); }
|
|
453
|
+
function resetUsage() { _panResetUsage(); }
|
|
454
|
+
function toggleUsagePanel() { _panToggleUsagePanel(); }
|
|
455
|
+
function formatBytes(n) { return _panFormatBytes(n); }
|
|
456
|
+
function formatUptime(s) { return _panFormatUptime(s); }
|
|
457
|
+
function updateStatusPanel(data) { _panUpdateStatusPanel(data); }
|
|
458
|
+
function requestProcessStats() { _panRequestProcessStats(); }
|
|
459
|
+
function toggleStatusPanel() { _panToggleStatusPanel(); }
|
|
460
|
+
function updateContextPanel() { _panUpdateContextPanel(); }
|
|
461
|
+
function accumulateContext(cost, usage, modelUsage, lastStreamInputTokens) { _panAccumulateContext(cost, usage, modelUsage, lastStreamInputTokens); }
|
|
462
|
+
function resetContext() { _panResetContext(); }
|
|
463
|
+
function resetContextData() { _panResetContextData(); }
|
|
464
|
+
function minimizeContext() { _panMinimizeContext(); }
|
|
465
|
+
function expandContext() { _panExpandContext(); }
|
|
466
|
+
function toggleContextPanel() { _panToggleContextPanel(); }
|
|
467
|
+
function getContextView() { return _panGetContextView(); }
|
|
468
|
+
function renderCtxPopover() { _panRenderCtxPopover(); }
|
|
469
|
+
function hideCtxPopover() { _panHideCtxPopover(); }
|
|
470
|
+
|
|
471
|
+
// addToMessages, scrollToBottom, forceScrollToBottom -> modules/app-rendering.js
|
|
472
|
+
function addToMessages(el) { _renAddToMessages(el); }
|
|
473
|
+
|
|
474
|
+
var newMsgBtn = $("new-msg-btn");
|
|
475
|
+
var newMsgBtnDefault = "\u2193 Latest";
|
|
476
|
+
var newMsgBtnActivity = "\u2193 New activity";
|
|
477
|
+
|
|
478
|
+
var scrollRafPending = false;
|
|
479
|
+
messagesEl.addEventListener("scroll", function () {
|
|
480
|
+
// While sticky-bottom is armed, suppress "user scrolled up" detection.
|
|
481
|
+
if (getStickyBottom()) return;
|
|
482
|
+
// Coalesce rapid scroll events into one rAF callback so we don't force
|
|
483
|
+
// a layout read (scrollHeight/scrollTop/clientHeight) on every event.
|
|
484
|
+
if (scrollRafPending) return;
|
|
485
|
+
scrollRafPending = true;
|
|
486
|
+
requestAnimationFrame(function () {
|
|
487
|
+
scrollRafPending = false;
|
|
488
|
+
var distFromBottom = messagesEl.scrollHeight - messagesEl.scrollTop - messagesEl.clientHeight;
|
|
489
|
+
var scrolledUp = distFromBottom > 150;
|
|
490
|
+
setIsUserScrolledUp(scrolledUp);
|
|
491
|
+
if (scrolledUp) {
|
|
492
|
+
if (newMsgBtn.classList.contains("hidden")) {
|
|
493
|
+
newMsgBtn.textContent = newMsgBtnDefault;
|
|
494
|
+
}
|
|
495
|
+
newMsgBtn.classList.remove("hidden");
|
|
496
|
+
} else {
|
|
497
|
+
newMsgBtn.classList.add("hidden");
|
|
498
|
+
newMsgBtn.textContent = newMsgBtnDefault;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
newMsgBtn.addEventListener("click", function () {
|
|
504
|
+
forceScrollToBottom();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// Scroll to bottom when returning to the app (e.g. switching back from another
|
|
508
|
+
// Android app or tab). Without this the browser restores a stale scroll offset
|
|
509
|
+
// and leaves the user stranded mid-session instead of at the latest message.
|
|
510
|
+
document.addEventListener("visibilitychange", function () {
|
|
511
|
+
if (!document.hidden) {
|
|
512
|
+
scrollToBottom();
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// Fork session from a user message
|
|
517
|
+
messagesEl.addEventListener("click", function(e) {
|
|
518
|
+
var btn = e.target.closest(".msg-action-fork");
|
|
519
|
+
if (!btn) return;
|
|
520
|
+
var msgEl = btn.closest("[data-uuid]");
|
|
521
|
+
if (!msgEl || !msgEl.dataset.uuid) return;
|
|
522
|
+
var forkUuid = msgEl.dataset.uuid;
|
|
523
|
+
showConfirm("Fork session from this message?", function() {
|
|
524
|
+
var _ws = _getWsRef();
|
|
525
|
+
if (_ws && _ws.readyState === 1) {
|
|
526
|
+
_ws.send(JSON.stringify({ type: "fork_session", uuid: forkUuid }));
|
|
527
|
+
}
|
|
528
|
+
}, "Fork", false);
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
function scrollToBottom() { _renScrollToBottom(); }
|
|
532
|
+
function forceScrollToBottom() { _renForceScrollToBottom(); }
|
|
533
|
+
|
|
534
|
+
// --- Misc module (modals, PWA, extension bridge, force PIN) ---
|
|
535
|
+
initMisc();
|
|
536
|
+
|
|
537
|
+
// --- Favicon module ---
|
|
538
|
+
initFavicon();
|
|
539
|
+
|
|
540
|
+
// --- Header module (rename, info popover, history) ---
|
|
541
|
+
initHeader();
|
|
542
|
+
|
|
543
|
+
// --- Skill Install module ---
|
|
544
|
+
initSkillInstall();
|
|
545
|
+
|
|
546
|
+
initLoopUi();
|
|
547
|
+
initLoopWizard();
|
|
548
|
+
|
|
549
|
+
// --- Notifications module ---
|
|
550
|
+
initAppNotifications();
|
|
551
|
+
|
|
552
|
+
// --- Panels module ---
|
|
553
|
+
initPanels();
|
|
554
|
+
|
|
555
|
+
// --- Rendering module ---
|
|
556
|
+
initRendering();
|
|
557
|
+
|
|
558
|
+
// --- Tools module ---
|
|
559
|
+
initTools({
|
|
560
|
+
$: $,
|
|
561
|
+
get ws() { return _getWsRef(); },
|
|
562
|
+
get connected() { return store.get('connected'); },
|
|
563
|
+
get turnCounter() { return getTurnCounter(); },
|
|
564
|
+
messagesEl: messagesEl,
|
|
565
|
+
inputEl: inputEl,
|
|
566
|
+
finalizeAssistantBlock: function() { finalizeAssistantBlock(); },
|
|
567
|
+
addToMessages: function(el) { addToMessages(el); },
|
|
568
|
+
scrollToBottom: function() { scrollToBottom(); },
|
|
569
|
+
setActivity: function(text) { setActivity(text); },
|
|
570
|
+
stopUrgentBlink: function() { stopUrgentBlink(); },
|
|
571
|
+
showImageModal: showImageModal,
|
|
572
|
+
getContextPercent: function() {
|
|
573
|
+
var cd = getContextData();
|
|
574
|
+
return cd.contextWindow > 0 ? Math.round((cd.input / cd.contextWindow) * 100) : 0;
|
|
575
|
+
},
|
|
576
|
+
getClaudeAvatar: function () { return CLAUDE_CODE_AVATAR; },
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// isPlanFile, toolSummary, toolActivityText, shortPath -> modules/tools.js
|
|
580
|
+
|
|
581
|
+
// AskUserQuestion, PermissionRequest, Plan, Todo, Thinking, Tool items -> modules/tools.js
|
|
582
|
+
|
|
583
|
+
// --- DOM: Messages (delegated to app-rendering.js) ---
|
|
584
|
+
function addUserMessage(text, images, pastes, fromUserId, fromUserName) { _renAddUserMessage(text, images, pastes, fromUserId, fromUserName); }
|
|
585
|
+
function getMsgTime() { return _renGetMsgTime(); }
|
|
586
|
+
function shouldGroupMessage(senderClass) { return _renShouldGroupMessage(senderClass); }
|
|
587
|
+
function ensureAssistantBlock() { return _renEnsureAssistantBlock(); }
|
|
588
|
+
function addCopyHandler(msgEl, rawText) { _renAddCopyHandler(msgEl, rawText); }
|
|
589
|
+
function appendDelta(text) { _renAppendDelta(text); }
|
|
590
|
+
function flushStreamBuffer() { _renFlushStreamBuffer(); }
|
|
591
|
+
function finalizeAssistantBlock() { _renFinalizeAssistantBlock(); }
|
|
592
|
+
function addSystemMessage(text, isError) { _renAddSystemMessage(text, isError); }
|
|
593
|
+
function addConflictMessage(msg) { _renAddConflictMessage(msg); }
|
|
594
|
+
function addContextOverflowMessage(msg) { _renAddContextOverflowMessage(msg); }
|
|
595
|
+
|
|
596
|
+
// pendingTermCommand -> store
|
|
597
|
+
|
|
598
|
+
// --- Rate Limit ---
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
// --- Rate Limit / Scheduled Messages / Fast Mode (delegated to app-rate-limit.js) ---
|
|
602
|
+
function handleRateLimitEvent(msg) { _rlHandleRateLimitEvent(msg); }
|
|
603
|
+
function updateRateLimitUsage(msg) { _rlUpdateRateLimitUsage(msg); }
|
|
604
|
+
function addScheduledMessageBubble(text, resetsAt) { _rlAddScheduledMessageBubble(text, resetsAt); }
|
|
605
|
+
function removeScheduledMessageBubble() { _rlRemoveScheduledMessageBubble(); }
|
|
606
|
+
function handleFastModeState(state) { _rlHandleFastModeState(state); }
|
|
607
|
+
|
|
608
|
+
// --- Prompt suggestion chips (delegated to app-rendering.js) ---
|
|
609
|
+
function showSuggestionChips(suggestion) { _renShowSuggestionChips(suggestion); }
|
|
610
|
+
function hideSuggestionChips() { _renHideSuggestionChips(); }
|
|
611
|
+
|
|
612
|
+
// resetClientState, switchProject -> modules/app-projects.js
|
|
613
|
+
function resetClientState() { _projResetClientState(); }
|
|
614
|
+
function switchProject(slug) { _projSwitchProject(slug); }
|
|
615
|
+
|
|
616
|
+
window.addEventListener("popstate", function () {
|
|
617
|
+
var m = location.pathname.match(/^\/p\/([a-z0-9_-]+)/);
|
|
618
|
+
var newSlug = m ? m[1] : null;
|
|
619
|
+
if (newSlug && newSlug !== store.get('currentSlug')) {
|
|
620
|
+
resetFileBrowser();
|
|
621
|
+
closeArchive();
|
|
622
|
+
if (isSchedulerOpen()) closeScheduler();
|
|
623
|
+
resetScheduler(newSlug);
|
|
624
|
+
store.set({ currentSlug: newSlug });
|
|
625
|
+
basePath = "/p/" + newSlug + "/";
|
|
626
|
+
wsPath = "/p/" + newSlug + "/ws";
|
|
627
|
+
store.set({ basePath: basePath, wsPath: wsPath });
|
|
628
|
+
resetClientState();
|
|
629
|
+
connect();
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
// --- WebSocket (delegated to app-connection.js) ---
|
|
634
|
+
function connect() { _connConnect(); }
|
|
635
|
+
function scheduleReconnect() { _connScheduleReconnect(); }
|
|
636
|
+
|
|
637
|
+
function showUpdateAvailable(msg) { _projShowUpdateAvailable(msg); }
|
|
638
|
+
|
|
639
|
+
function processMessage(msg) { _msgProcessMessage(msg); }
|
|
640
|
+
|
|
641
|
+
// processMessage body moved to modules/app-messages.js (PR-23)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
// --- Progressive history loading -> modules/app-header.js
|
|
645
|
+
function updateHistorySentinel() { _hdrUpdateHistorySentinel(); }
|
|
646
|
+
function requestMoreHistory() { _hdrRequestMoreHistory(); }
|
|
647
|
+
function prependOlderHistory(items, meta) { _hdrPrependOlderHistory(items, meta); }
|
|
648
|
+
|
|
649
|
+
// --- Input module (sendMessage, autoResize, paste/image, slash menu, input handlers) ---
|
|
650
|
+
initInput({
|
|
651
|
+
get ws() { return _getWsRef(); },
|
|
652
|
+
get connected() { return store.get('connected'); },
|
|
653
|
+
get processing() { return store.get('processing'); },
|
|
654
|
+
get basePath() { return basePath; },
|
|
655
|
+
inputEl: inputEl,
|
|
656
|
+
sendBtn: sendBtn,
|
|
657
|
+
slashMenu: slashMenu,
|
|
658
|
+
messagesEl: messagesEl,
|
|
659
|
+
imagePreviewBar: imagePreviewBar,
|
|
660
|
+
slashCommands: function() { return store.get('slashCommands'); },
|
|
661
|
+
messageUuidMap: function() { return store.get('messageUuidMap'); },
|
|
662
|
+
addUserMessage: addUserMessage,
|
|
663
|
+
addSystemMessage: addSystemMessage,
|
|
664
|
+
toggleUsagePanel: toggleUsagePanel,
|
|
665
|
+
toggleStatusPanel: toggleStatusPanel,
|
|
666
|
+
toggleContextPanel: toggleContextPanel,
|
|
667
|
+
resetContextData: resetContextData,
|
|
668
|
+
showImageModal: showImageModal,
|
|
669
|
+
hideSuggestionChips: hideSuggestionChips,
|
|
670
|
+
getGhostSuggestion: function () { return _renGetGhostSuggestion(); },
|
|
671
|
+
disarmStickyBottom: disarmStickyBottom,
|
|
672
|
+
setSendBtnMode: setSendBtnMode,
|
|
673
|
+
isDmMode: function () { return store.get('dmMode'); },
|
|
674
|
+
getDmKey: function () { return store.get('dmKey'); },
|
|
675
|
+
handleDmSend: function () { handleDmSend(); },
|
|
676
|
+
showClaudePreThinking: function () { showClaudePreThinking(); },
|
|
677
|
+
myUserId: function () { return store.get('myUserId'); },
|
|
678
|
+
myDisplayName: function () {
|
|
679
|
+
var u = null;
|
|
680
|
+
try { u = JSON.parse(localStorage.getItem("clagentic_my_user") || localStorage.getItem("clay_my_user") || "null"); } catch (e) {}
|
|
681
|
+
return (u && (u.displayName || u.username)) || document.body.dataset.myDisplayName || "Me";
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
// --- @Mention module ---
|
|
686
|
+
initMention({
|
|
687
|
+
get ws() { return _getWsRef(); },
|
|
688
|
+
get connected() { return store.get('connected'); },
|
|
689
|
+
inputEl: inputEl,
|
|
690
|
+
messagesEl: messagesEl,
|
|
691
|
+
allUsers: function () { return store.get('cachedAllUsers') || []; },
|
|
692
|
+
myUserId: function () { return store.get('myUserId'); },
|
|
693
|
+
scrollToBottom: scrollToBottom,
|
|
694
|
+
addUserMessage: addUserMessage,
|
|
695
|
+
addCopyHandler: addCopyHandler,
|
|
696
|
+
addToMessages: addToMessages,
|
|
697
|
+
showImageModal: showImageModal,
|
|
698
|
+
showPasteModal: showPasteModal,
|
|
699
|
+
});
|
|
700
|
+
// --- STT module (voice input via Web Speech API) ---
|
|
701
|
+
initSTT({
|
|
702
|
+
inputEl: inputEl,
|
|
703
|
+
addSystemMessage: addSystemMessage,
|
|
704
|
+
scrollToBottom: scrollToBottom,
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
// --- User profile (Discord-style popover on user island) ---
|
|
708
|
+
initProfile({
|
|
709
|
+
basePath: basePath,
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// --- User settings (full-screen overlay) ---
|
|
713
|
+
initUserSettings({
|
|
714
|
+
basePath: basePath,
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
// --- Force PIN change overlay -> modules/app-misc.js
|
|
718
|
+
function showForceChangePinOverlay() { _miscShowForceChangePinOverlay(); }
|
|
719
|
+
|
|
720
|
+
// --- Admin (multi-user mode) ---
|
|
721
|
+
// isMultiUserMode, isHeadlessMode, myUserId -> store
|
|
722
|
+
initAdmin({
|
|
723
|
+
get projectList() { return getCachedProjects(); },
|
|
724
|
+
});
|
|
725
|
+
fetch("/api/me").then(function (r) { return r.json(); }).then(function (d) {
|
|
726
|
+
if (d.multiUser) {
|
|
727
|
+
store.set({ isMultiUserMode: true });
|
|
728
|
+
if (document.body) document.body.classList.add('is-multi-user');
|
|
729
|
+
}
|
|
730
|
+
if (d.user && d.user.id) { store.set({ myUserId: d.user.id }); }
|
|
731
|
+
if (d.permissions) store.set({ permissions: d.permissions });
|
|
732
|
+
if (d.mustChangePin) showForceChangePinOverlay();
|
|
733
|
+
// Single-user mode: clear user strip skeletons immediately (no presence message will arrive)
|
|
734
|
+
if (!store.get('isMultiUserMode')) {
|
|
735
|
+
var usersContainer = document.getElementById("icon-strip-users");
|
|
736
|
+
if (usersContainer) {
|
|
737
|
+
usersContainer.innerHTML = "";
|
|
738
|
+
usersContainer.classList.add("hidden");
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
initCursorToggle();
|
|
742
|
+
// Apply RBAC UI gating
|
|
743
|
+
var _perms = store.get('permissions');
|
|
744
|
+
if (_perms) {
|
|
745
|
+
if (!_perms.terminal) {
|
|
746
|
+
var termBtn = document.getElementById("terminal-toggle-btn");
|
|
747
|
+
if (termBtn) termBtn.style.display = "none";
|
|
748
|
+
var termSideBtn = document.getElementById("terminal-sidebar-btn");
|
|
749
|
+
if (termSideBtn) termSideBtn.style.display = "none";
|
|
750
|
+
}
|
|
751
|
+
if (!_perms.fileBrowser) {
|
|
752
|
+
var fbBtn = document.getElementById("file-browser-btn");
|
|
753
|
+
if (fbBtn) fbBtn.style.display = "none";
|
|
754
|
+
}
|
|
755
|
+
if (!_perms.skills) {
|
|
756
|
+
var sBtn = document.getElementById("skills-btn");
|
|
757
|
+
if (sBtn) sBtn.style.display = "none";
|
|
758
|
+
}
|
|
759
|
+
if (!_perms.scheduledTasks) {
|
|
760
|
+
var schBtn = document.getElementById("scheduler-btn");
|
|
761
|
+
if (schBtn) schBtn.style.display = "none";
|
|
762
|
+
}
|
|
763
|
+
if (!_perms.createProject) {
|
|
764
|
+
var addProjBtn = document.getElementById("icon-strip-add");
|
|
765
|
+
if (addProjBtn) addProjBtn.style.display = "none";
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}).catch(function () {});
|
|
769
|
+
// Hide server settings and update controls for non-admin users in multi-user mode
|
|
770
|
+
checkAdminAccess().then(function (isAdmin) {
|
|
771
|
+
if (store.get('isMultiUserMode') && !isAdmin) {
|
|
772
|
+
var settingsBtn = document.getElementById("server-settings-btn");
|
|
773
|
+
if (settingsBtn) settingsBtn.style.display = "none";
|
|
774
|
+
var updatePill = document.getElementById("update-pill-wrap");
|
|
775
|
+
if (updatePill) updatePill.style.display = "none";
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
// --- Notifications module (viewport, banners, notifications, debug, service worker) ---
|
|
780
|
+
initNotifications({
|
|
781
|
+
$: $,
|
|
782
|
+
get ws() { return _getWsRef(); },
|
|
783
|
+
get connected() { return store.get('connected'); },
|
|
784
|
+
messagesEl: messagesEl,
|
|
785
|
+
sessionListEl: sessionListEl,
|
|
786
|
+
scrollToBottom: scrollToBottom,
|
|
787
|
+
basePath: basePath,
|
|
788
|
+
toggleUsagePanel: toggleUsagePanel,
|
|
789
|
+
toggleStatusPanel: toggleStatusPanel,
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
// --- Server Settings ---
|
|
793
|
+
initServerSettings({
|
|
794
|
+
get ws() { return _getWsRef(); },
|
|
795
|
+
get projectName() { return store.get('projectName'); },
|
|
796
|
+
get currentSlug() { return store.get('currentSlug'); },
|
|
797
|
+
wsPath: wsPath,
|
|
798
|
+
get currentModels() { return store.get('currentModels'); },
|
|
799
|
+
set currentModels(v) { store.set({ currentModels: v }); },
|
|
800
|
+
get currentModel() { return store.get('currentModel'); },
|
|
801
|
+
get currentMode() { return store.get('currentMode'); },
|
|
802
|
+
get currentEffort() { return store.get('currentEffort'); },
|
|
803
|
+
get currentBetas() { return store.get('currentBetas'); },
|
|
804
|
+
get currentThinking() { return store.get('currentThinking'); },
|
|
805
|
+
get currentThinkingBudget() { return store.get('currentThinkingBudget'); },
|
|
806
|
+
setContextView: function (v) { _panSetContextView(v); },
|
|
807
|
+
applyContextView: function (v) { _panApplyContextView(v); },
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
// --- Project Settings ---
|
|
811
|
+
initProjectSettings({
|
|
812
|
+
get ws() { return _getWsRef(); },
|
|
813
|
+
get connected() { return store.get('connected'); },
|
|
814
|
+
get currentModels() { return store.get('currentModels'); },
|
|
815
|
+
get currentModel() { return store.get('currentModel'); },
|
|
816
|
+
get currentMode() { return store.get('currentMode'); },
|
|
817
|
+
get currentEffort() { return store.get('currentEffort'); },
|
|
818
|
+
get currentBetas() { return store.get('currentBetas'); },
|
|
819
|
+
get currentThinking() { return store.get('currentThinking'); },
|
|
820
|
+
get currentThinkingBudget() { return store.get('currentThinkingBudget'); },
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
// --- QR code ---
|
|
824
|
+
initQrCode();
|
|
825
|
+
var sharePill = document.getElementById("share-pill");
|
|
826
|
+
if (sharePill) sharePill.addEventListener("click", triggerShare);
|
|
827
|
+
|
|
828
|
+
// --- File browser ---
|
|
829
|
+
initFileBrowser({
|
|
830
|
+
get ws() { return _getWsRef(); },
|
|
831
|
+
get connected() { return store.get('connected'); },
|
|
832
|
+
get activeSessionId() { return store.get('activeSessionId'); },
|
|
833
|
+
get cwd() { return store.get('cwd'); },
|
|
834
|
+
messagesEl: messagesEl,
|
|
835
|
+
fileTreeEl: $("file-tree"),
|
|
836
|
+
fileViewerEl: $("file-viewer"),
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// --- Terminal ---
|
|
840
|
+
initTerminal({
|
|
841
|
+
get ws() { return _getWsRef(); },
|
|
842
|
+
get connected() { return store.get('connected'); },
|
|
843
|
+
terminalContainerEl: $("terminal-container"),
|
|
844
|
+
terminalBodyEl: $("terminal-body"),
|
|
845
|
+
fileViewerEl: $("file-viewer"),
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
// --- Context Sources ---
|
|
849
|
+
initContextSources({
|
|
850
|
+
get ws() { return _getWsRef(); },
|
|
851
|
+
get connected() { return store.get('connected'); },
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// --- Chrome Extension Bridge -> modules/app-misc.js
|
|
855
|
+
function sendExtensionCommand(command, args, requestId) { _miscSendExtensionCommand(command, args, requestId); }
|
|
856
|
+
function handleExtensionResult(requestId, result) { _miscHandleExtensionResult(requestId, result); }
|
|
857
|
+
|
|
858
|
+
// --- Playbook Engine ---
|
|
859
|
+
initPlaybook();
|
|
860
|
+
|
|
861
|
+
// Auto-open playbook from URL param (e.g. ?playbook=push-notifications)
|
|
862
|
+
(function () {
|
|
863
|
+
var params = new URLSearchParams(window.location.search);
|
|
864
|
+
var pbId = params.get("playbook");
|
|
865
|
+
if (pbId) {
|
|
866
|
+
// Small delay to ensure DOM and playbook registry are ready
|
|
867
|
+
setTimeout(function () { openPlaybook(pbId); }, 300);
|
|
868
|
+
// Clean up URL
|
|
869
|
+
params.delete("playbook");
|
|
870
|
+
var clean = params.toString();
|
|
871
|
+
var newUrl = window.location.pathname + (clean ? "?" + clean : "") + window.location.hash;
|
|
872
|
+
window.history.replaceState(null, "", newUrl);
|
|
873
|
+
}
|
|
874
|
+
})();
|
|
875
|
+
|
|
876
|
+
// --- In-session search (Cmd+F / Ctrl+F) ---
|
|
877
|
+
initSessionSearch({
|
|
878
|
+
messagesEl: messagesEl,
|
|
879
|
+
get ws() { return _getWsRef(); },
|
|
880
|
+
getHistoryFrom: function () { return store.get('historyFrom'); },
|
|
881
|
+
});
|
|
882
|
+
var findInSessionBtn = $("find-in-session-btn");
|
|
883
|
+
if (findInSessionBtn) {
|
|
884
|
+
findInSessionBtn.addEventListener("click", function () {
|
|
885
|
+
toggleSearch();
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// --- Sticky Notes ---
|
|
890
|
+
initStickyNotes({
|
|
891
|
+
get ws() { return _getWsRef(); },
|
|
892
|
+
get connected() { return store.get('connected'); },
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
// --- Sticky Notes sidebar button (create new note) ---
|
|
896
|
+
var stickyNotesSidebarBtn = $("sticky-notes-sidebar-btn");
|
|
897
|
+
if (stickyNotesSidebarBtn) {
|
|
898
|
+
stickyNotesSidebarBtn.addEventListener("click", function () {
|
|
899
|
+
if (isSchedulerOpen()) closeScheduler();
|
|
900
|
+
if (isArchiveOpen()) closeArchive();
|
|
901
|
+
showNotes();
|
|
902
|
+
createNote();
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// Sticky Notes badge click → archive toggle
|
|
907
|
+
var stickyNotesBadge = $("sticky-notes-sidebar-count");
|
|
908
|
+
if (stickyNotesBadge) {
|
|
909
|
+
stickyNotesBadge.addEventListener("click", function (e) {
|
|
910
|
+
e.stopPropagation();
|
|
911
|
+
if (isSchedulerOpen()) closeScheduler();
|
|
912
|
+
if (isArchiveOpen()) {
|
|
913
|
+
closeArchive();
|
|
914
|
+
} else {
|
|
915
|
+
openArchive();
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Close archive / scheduler panel when switching to other sidebar panels
|
|
921
|
+
var fileBrowserBtn = $("file-browser-btn");
|
|
922
|
+
var terminalSidebarBtn = $("terminal-sidebar-btn");
|
|
923
|
+
if (fileBrowserBtn) fileBrowserBtn.addEventListener("click", function () { if (isArchiveOpen()) closeArchive(); if (isSchedulerOpen()) closeScheduler(); });
|
|
924
|
+
if (terminalSidebarBtn) terminalSidebarBtn.addEventListener("click", function () { if (isArchiveOpen()) closeArchive(); if (isSchedulerOpen()) closeScheduler(); });
|
|
925
|
+
|
|
926
|
+
// --- Ralph Loop UI (delegated to app-loop-ui.js + app-loop-wizard.js) ---
|
|
927
|
+
function updateLoopInputVisibility(loop) { _loopUpdateLoopInputVisibility(loop); }
|
|
928
|
+
function updateLoopButton() { _loopUpdateLoopButton(); }
|
|
929
|
+
function showLoopBanner(show) { _loopShowLoopBanner(show); }
|
|
930
|
+
function updateLoopBanner(iteration, maxIterations, phase) { _loopUpdateLoopBanner(iteration, maxIterations, phase); }
|
|
931
|
+
function updateRalphBars() { _loopUpdateRalphBars(); }
|
|
932
|
+
function showRalphCraftingBar(show) { _loopShowRalphCraftingBar(show); }
|
|
933
|
+
function showRalphApprovalBar(show) { _loopShowRalphApprovalBar(show); }
|
|
934
|
+
function updateRalphApprovalStatus() { _loopUpdateRalphApprovalStatus(); }
|
|
935
|
+
function openRalphPreviewModal() { _loopOpenRalphPreviewModal(); }
|
|
936
|
+
function showExecModal() { _loopShowExecModal(); }
|
|
937
|
+
function closeExecModal() { _loopCloseExecModal(); }
|
|
938
|
+
function updateExecModalStatus() { _loopUpdateExecModalStatus(); }
|
|
939
|
+
|
|
940
|
+
// --- Notifications (delegated to app-notifications.js) ---
|
|
941
|
+
function handleNotificationsState(msg) { _notifHandleState(msg); }
|
|
942
|
+
function handleNotificationCreated(msg) { _notifHandleCreated(msg); }
|
|
943
|
+
function handleNotificationDismissed(msg) { _notifHandleDismissed(msg); }
|
|
944
|
+
function handleNotificationDismissedAll() { _notifHandleDismissedAll(); }
|
|
945
|
+
|
|
946
|
+
// --- Skill install dialog (delegated to app-skills-install.js) ---
|
|
947
|
+
// knownInstalledSkills, pendingSkillInstalls -> modules/app-skills-install.js
|
|
948
|
+
function requireSkills(opts, cb) { _siRequireSkills(opts, cb); }
|
|
949
|
+
function handleSkillInstallWs(msg) { _siHandleSkillInstallWs(msg); }
|
|
950
|
+
|
|
951
|
+
// --- Ralph Wizard (delegated to app-loop-wizard.js) ---
|
|
952
|
+
function openRalphWizard(source) { _loopOpenRalphWizard(source); }
|
|
953
|
+
function closeRalphWizard() { _loopCloseRalphWizard(); }
|
|
954
|
+
|
|
955
|
+
// --- Ralph Preview Modal (delegated to app-loop-ui.js) ---
|
|
956
|
+
|
|
957
|
+
// --- MCP Servers ---
|
|
958
|
+
initMcp();
|
|
959
|
+
|
|
960
|
+
// --- Skills ---
|
|
961
|
+
initSkills();
|
|
962
|
+
|
|
963
|
+
// --- Scheduler ---
|
|
964
|
+
initScheduler({
|
|
965
|
+
get ws() { return _getWsRef(); },
|
|
966
|
+
get connected() { return store.get('connected'); },
|
|
967
|
+
get activeSessionId() { return store.get('activeSessionId'); },
|
|
968
|
+
basePath: basePath,
|
|
969
|
+
currentSlug: currentSlug, // init-time snapshot, scheduler uses for initial setup
|
|
970
|
+
openRalphWizard: function (source) { openRalphWizard(source); },
|
|
971
|
+
requireClayRalph: function (cb) {
|
|
972
|
+
requireSkills({
|
|
973
|
+
title: "Skill Installation Required",
|
|
974
|
+
reason: "This feature requires the following skill to be installed.",
|
|
975
|
+
skills: [{ name: "clay-ralph", url: "https://github.com/chadbyte/clay-ralph", scope: "global" }]
|
|
976
|
+
}, cb);
|
|
977
|
+
},
|
|
978
|
+
getProjects: function () { return getCachedProjects(); },
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
// --- Remove/Add project (delegated to app-projects.js) ---
|
|
982
|
+
function confirmRemoveProject(slug, name) { _projConfirmRemoveProject(slug, name); }
|
|
983
|
+
function handleRemoveProjectCheckResult(msg) { _projHandleRemoveProjectCheckResult(msg); }
|
|
984
|
+
function handleRemoveProjectResult(msg) { _projHandleRemoveProjectResult(msg); }
|
|
985
|
+
function openAddProjectModal() { _projOpenAddProjectModal(); }
|
|
986
|
+
function closeAddProjectModal() { _projCloseAddProjectModal(); }
|
|
987
|
+
function handleBrowseDirResult(msg) { _projHandleBrowseDirResult(msg); }
|
|
988
|
+
function handleAddProjectResult(msg) { _projHandleAddProjectResult(msg); }
|
|
989
|
+
function handleCloneProgress(msg) { _projHandleCloneProgress(msg); }
|
|
990
|
+
|
|
991
|
+
// --- PWA install prompt -> modules/app-misc.js (set up in initMisc)
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
// --- Remote Cursors (delegated to app-cursors.js) ---
|
|
995
|
+
function handleRemoteCursorMove(msg) { _curHandleRemoteCursorMove(msg); }
|
|
996
|
+
function handleRemoteCursorLeave(msg) { _curHandleRemoteCursorLeave(msg); }
|
|
997
|
+
function handleRemoteSelection(msg) { _curHandleRemoteSelection(msg); }
|
|
998
|
+
function clearRemoteCursors() { _curClearRemoteCursors(); }
|
|
999
|
+
|
|
1000
|
+
// --- Cursors module ---
|
|
1001
|
+
initCursors();
|
|
1002
|
+
|
|
1003
|
+
// --- Rate Limit module ---
|
|
1004
|
+
initRateLimit();
|
|
1005
|
+
|
|
1006
|
+
// --- Projects module ---
|
|
1007
|
+
initProjects();
|
|
1008
|
+
onProjectListUpdated(function (projects) { updateMobileProjectsTabBadge(projects); });
|
|
1009
|
+
|
|
1010
|
+
// --- Home Hub module ---
|
|
1011
|
+
initHomeHub();
|
|
1012
|
+
|
|
1013
|
+
// --- DM module ---
|
|
1014
|
+
initDm();
|
|
1015
|
+
|
|
1016
|
+
// --- Messages module (uses direct imports, no ctx injection needed) ---
|
|
1017
|
+
|
|
1018
|
+
// --- Connection module ---
|
|
1019
|
+
initConnection();
|
|
1020
|
+
|
|
1021
|
+
// --- Init ---
|
|
1022
|
+
lucide.createIcons();
|
|
1023
|
+
connect();
|
|
1024
|
+
if (!store.get('currentSlug')) {
|
|
1025
|
+
showHomeHub();
|
|
1026
|
+
} else if (location.hash === "#scheduler") {
|
|
1027
|
+
// Restore scheduler view after refresh
|
|
1028
|
+
setTimeout(function () { openSchedulerToTab("calendar"); }, 500);
|
|
1029
|
+
} else {
|
|
1030
|
+
inputEl.focus();
|
|
1031
|
+
}
|