MCPcopy Create free account
hub / github.com/getsentry/XcodeBuildMCP / createDeviceListItems

Function createDeviceListItems

src/utils/renderers/domain-result-text.ts:500–553  ·  view source on GitHub ↗
(
  result: Extract<ToolDomainResult, { kind: 'device-list' }>,
)

Source from the content-addressed store, hash-verified

498}
499
500function createDeviceListItems(
501 result: Extract<ToolDomainResult, { kind: 'device-list' }>,
502): TextRenderableItem[] {
503 const header = createHeader('List Devices');
504 if (result.didError) {
505 return [header, ...createFailureStatusWithDiagnostics(result, 'Failed to list devices')];
506 }
507
508 const groupedByPlatform = new Map<string, typeof result.devices>();
509 for (const device of result.devices) {
510 const platformGroup = groupedByPlatform.get(device.platform) ?? [];
511 platformGroup.push(device);
512 groupedByPlatform.set(device.platform, platformGroup);
513 }
514
515 const platformCounts: Record<string, number> = {};
516 let totalCount = 0;
517 const items: TextRenderableItem[] = [header];
518 const sortedPlatforms = [...groupedByPlatform.entries()].sort(
519 ([left], [right]) => getDevicePlatformInfo(left).order - getDevicePlatformInfo(right).order,
520 );
521
522 for (const [platform, devices] of sortedPlatforms) {
523 const info = getDevicePlatformInfo(platform);
524 const lines: string[] = [''];
525
526 for (const device of devices) {
527 if (lines.length > 1) {
528 lines.push('');
529 }
530 const marker = device.isAvailable ? '\u2713' : '\u2717';
531 lines.push(`${info.emoji} [${marker}] ${device.name}`);
532 lines.push(` OS: ${device.osVersion}`);
533 lines.push(` UDID: ${device.deviceId}`);
534 }
535
536 platformCounts[platform] = devices.length;
537 totalCount += devices.length;
538 items.push(createSection(`${info.label}:`, lines));
539 }
540
541 const countParts = sortedPlatforms
542 .map(([platform]) => `${platformCounts[platform]} ${platform}`)
543 .join(', ');
544 items.push(createStatus('success', `${totalCount} physical devices discovered (${countParts}).`));
545 items.push(
546 createSection('Hints', [
547 'Use the device ID/UDID from above when required by other tools.',
548 "Save a default device with session-set-defaults { deviceId: 'DEVICE_UDID' }.",
549 'Before running build/run/test/UI automation tools, set the desired device identifier in session defaults.',
550 ]),
551 );
552 return items;
553}
554
555function createSimulatorListItems(
556 result: Extract<ToolDomainResult, { kind: 'simulator-list' }>,

Callers 1

createSpecialCaseItemsFunction · 0.85

Calls 7

createHeaderFunction · 0.85
getDevicePlatformInfoFunction · 0.85
createSectionFunction · 0.85
createStatusFunction · 0.85
getMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected