MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / hydrateSessionDefaultsForMcp

Function hydrateSessionDefaultsForMcp

src/runtime/bootstrap-runtime.ts:49–88  ·  view source on GitHub ↗

* Hydrates MCP session defaults and reports whether a background simulator refresh was scheduled.

(
  defaults: Partial<SessionDefaults> | undefined,
  profiles: Record<string, Partial<SessionDefaults>> | undefined,
  activeProfile: string | undefined,
)

Source from the content-addressed store, hash-verified

47 * Hydrates MCP session defaults and reports whether a background simulator refresh was scheduled.
48 */
49function hydrateSessionDefaultsForMcp(
50 defaults: Partial<SessionDefaults> | undefined,
51 profiles: Record<string, Partial<SessionDefaults>> | undefined,
52 activeProfile: string | undefined,
53): MCPSessionHydrationResult {
54 const hydratedDefaults = { ...(defaults ?? {}) };
55 const hydratedProfiles = profiles ?? {};
56 const hasHydratedDefaults = Object.keys(hydratedDefaults).length > 0;
57 const hydratedProfileEntries = Object.entries(hydratedProfiles);
58 if (!hasHydratedDefaults && hydratedProfileEntries.length === 0) {
59 return { hydrated: false, refreshScheduled: false };
60 }
61
62 if (hasHydratedDefaults) {
63 sessionStore.setDefaultsForProfile(null, hydratedDefaults);
64 }
65 for (const [profileName, profileDefaults] of hydratedProfileEntries) {
66 const trimmedName = profileName.trim();
67 if (!trimmedName) continue;
68 sessionStore.setDefaultsForProfile(trimmedName, profileDefaults);
69 }
70 const normalizedActiveProfile = activeProfile?.trim();
71 if (normalizedActiveProfile) {
72 sessionStore.setActiveProfile(normalizedActiveProfile);
73 }
74
75 const activeDefaults = sessionStore.getAll();
76 const revision = sessionStore.getRevision();
77 const refreshScheduled = scheduleSimulatorDefaultsRefresh({
78 expectedRevision: revision,
79 reason: 'startup-hydration',
80 profile: sessionStore.getActiveProfile(),
81 persist: false,
82 simulatorId: activeDefaults.simulatorId,
83 simulatorName: activeDefaults.simulatorName,
84 recomputePlatform: true,
85 });
86
87 return { hydrated: true, refreshScheduled };
88}
89
90function logHydrationResult(hydration: MCPSessionHydrationResult): void {
91 if (!hydration.hydrated) {

Callers 1

bootstrapRuntimeFunction · 0.85

Calls 6

setDefaultsForProfileMethod · 0.80
setActiveProfileMethod · 0.80
getAllMethod · 0.80
getRevisionMethod · 0.80
getActiveProfileMethod · 0.80

Tested by

no test coverage detected