MCPcopy
hub / github.com/stravu/crystal / setupProcessors

Method setupProcessors

main/src/services/taskQueue.ts:148–478  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

146 }
147
148 private setupProcessors() {
149 // Use platform-specific concurrency for session processing
150 const isLinux = os.platform() === 'linux';
151 const sessionConcurrency = isLinux ? 1 : 5;
152
153 this.sessionQueue.process(sessionConcurrency, async (job) => {
154 const { prompt, worktreeTemplate, index, permissionMode, projectId, baseBranch, autoCommit, toolType, codexConfig, claudeConfig } = job.data;
155 const { sessionManager, worktreeManager, claudeCodeManager } = this.options;
156
157 // Processing session creation job - verbose debug logging removed
158
159 try {
160 let targetProject;
161
162 if (projectId) {
163 // Use the project specified in the job
164 targetProject = sessionManager.getProjectById(projectId);
165 if (!targetProject) {
166 throw new Error(`Project with ID ${projectId} not found`);
167 }
168 } else {
169 // Fall back to active project for backward compatibility
170 targetProject = sessionManager.getActiveProject();
171 if (!targetProject) {
172 throw new Error('No project specified and no active project selected');
173 }
174 }
175
176 let worktreeName = worktreeTemplate;
177 let sessionName: string;
178
179 // Generate a name if template is empty - but skip if we're in multi-session creation with index
180 if (!worktreeName || worktreeName.trim() === '') {
181 // If this is part of a multi-session creation (has index), the base name should have been generated already
182 if (index !== undefined && index >= 0) {
183 // Multi-session creation detected - verbose debug logging removed
184 worktreeName = 'session';
185 sessionName = 'Session';
186 } else {
187 // No worktree template provided - verbose debug logging removed
188 // Use the AI-powered name generator to generate a session name with spaces
189 sessionName = await this.options.worktreeNameGenerator.generateSessionName(prompt);
190 // Convert the session name to a worktree name (spaces to hyphens)
191 worktreeName = sessionName.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
192 // Generated names - verbose debug logging removed
193 }
194 } else {
195 // If we have a worktree template, use it as the session name as-is
196 sessionName = worktreeName;
197
198 // For the worktree name, replace spaces with hyphens and make it lowercase
199 // but keep hyphens that are already there
200 if (worktreeName.includes(' ')) {
201 worktreeName = worktreeName.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
202 } else {
203 // Already a valid worktree name format (no spaces), just clean it up
204 worktreeName = worktreeName.toLowerCase().replace(/[^a-z0-9-]/g, '');
205 }

Callers 1

constructorMethod · 0.95

Calls 15

ensureUniqueNamesMethod · 0.95
formatForDisplayFunction · 0.90
processMethod · 0.80
getProjectByIdMethod · 0.80
generateSessionNameMethod · 0.80
createWorktreeMethod · 0.80
ensureDiffPanelMethod · 0.80
emitSessionCreatedMethod · 0.80
updateSessionStatusMethod · 0.80
runBuildScriptMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected