MCPcopy
hub / github.com/coder/mux / buildCoreSources

Function buildCoreSources

src/browser/utils/commands/sources.ts:324–1429  ·  view source on GitHub ↗
(p: BuildSourcesParams)

Source from the content-addressed store, hash-verified

322 );
323}
324export function buildCoreSources(p: BuildSourcesParams): Array<() => CommandAction[]> {
325 const actions: Array<() => CommandAction[]> = [];
326
327 // NOTE: We intentionally route to the chat-based creation flow instead of
328 // building a separate prompt. This keeps `/new`, keybinds, and the command
329 // palette perfectly aligned on one experience.
330 const createWorkspaceForSelectedProjectAction = (
331 selected: NonNullable<BuildSourcesParams["selectedWorkspace"]>
332 ): CommandAction => {
333 const metadata = p.workspaceMetadata.get(selected.workspaceId);
334 const targetProjectPath = metadata?.subProjectPath ?? selected.projectPath;
335 const targetProjectLabel = formatProjectHierarchyLabel(targetProjectPath, p.userProjects);
336 return {
337 id: CommandIds.workspaceNew(),
338 title: "Create New Workspace…",
339 subtitle: `for ${targetProjectLabel}`,
340 section: section.workspaces,
341 shortcutHint: formatKeybind(KEYBINDS.NEW_WORKSPACE),
342 run: () => p.onStartWorkspaceCreation(targetProjectPath),
343 };
344 };
345
346 // Workspaces
347 actions.push(() => {
348 const list: CommandAction[] = [];
349
350 const selected = p.selectedWorkspace;
351 if (selected) {
352 list.push(createWorkspaceForSelectedProjectAction(selected));
353 }
354
355 // Switch to workspace
356 // Iterate through all workspace metadata (now keyed by workspace ID)
357 for (const meta of p.workspaceMetadata.values()) {
358 const isCurrent = selected?.workspaceId === meta.id;
359 const isStreaming = p.streamingModels?.has(meta.id) ?? false;
360 // Title is primary (if set), name is secondary identifier
361 const primaryLabel = meta.title ?? meta.name;
362 const secondaryParts = [meta.name, meta.projectName];
363 if (isStreaming) secondaryParts.push("streaming");
364 list.push({
365 id: CommandIds.workspaceSwitch(meta.id),
366 title: `${isCurrent ? "• " : ""}${primaryLabel}`,
367 subtitle: secondaryParts.join(" · "),
368 section: section.workspaces,
369 keywords: [meta.name, meta.projectName, meta.namedWorkspacePath, meta.title].filter(
370 (k): k is string => !!k
371 ),
372 run: () =>
373 p.onSelectWorkspace({
374 projectPath: meta.projectPath,
375 projectName: meta.projectName,
376 namedWorkspacePath: meta.namedWorkspacePath,
377 workspaceId: meta.id,
378 }),
379 });
380 }
381

Callers 2

AppInnerFunction · 0.90
mkFunction · 0.90

Calls 15

formatKeybindFunction · 0.90
createCustomEventFunction · 0.90
getOrderedBaseTabIdsFunction · 0.90
getTabConfigFunction · 0.90
updateRightSidebarLayoutFunction · 0.90
selectTabInTabsetFunction · 0.90
setFocusedTabsetFunction · 0.90
splitFocusedTabsetFunction · 0.90
isTabTypeFunction · 0.90
addToolToFocusedTabsetFunction · 0.90
getPresetForSlotFunction · 0.90

Tested by 1

mkFunction · 0.72