You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Decide how to split the native preview classes #489
NativePreviewCorrection (2,561 lines, 91 methods) and NativePreviewBuild (2,241 lines, 78 methods) each hold several responsibilities in one main-actor class, and the Correction suffix on four classes does not say what they do.
What
Answer these before changing code:
Which responsibilities in the two classes change for different reasons, and which state each one owns.
Whether a split can keep the preview reuse and cleanup guarantees described in Docs/maintainer-architecture.md.
Decision: split both classes by responsibility and rename the four Correction classes after what they do. The work lands in four PRs, in this order.
Rename the classes.
Current
What it does
New name
NativePreviewCorrection
Implements RenderPreview with the direct renderer and falls back to the native action
NativePreviewTool
NativeCrashToolCorrection
Provides the six Organizer crash tools
NativeCrashTools
NativeTestableStateCorrection
Stops _IDETestableState from creating notice providers after invalidation
NativeTestableStateNoticeGuard
NativeSimulatorLaunchCorrection
Hooks the Simulator launcher to record the PIDs of launches it owns
NativeSimulatorLaunchTracker
Move preview definition discovery to NativePreviewDefinitions. This covers source lookup, the registry, and the provider specification. Move product staging to NativePreviewStaging, which handles target selection, framework dependencies, static linking, and app preparation. NativePreviewBuild and NativePreviewProductSignature call staging today, so this also removes their dependency on the tool class.
Move WorkspaceSession into its own NativePreviewSession type. The new type owns its stages, simulator, and installed applications, and it also owns the operations that stop, reset, and close them.
Split NativePreviewBuild three ways:
Project input synchronization moves to NativePreviewProjectInputs, which owns synchronizedProjects.
Destination resolution and selection, including the source plan, move to NativePreviewDestinations, which owns destinationPreparation and sourceSelections.
NativePreviewBuild keeps the build operation and target records.
The split keeps the reuse and cleanup guarantees in Docs/maintainer-architecture.md. Session state still changes only inside renderQueue.withAccess(to:), and only NativePreviewTool calls the session. Cancellation and retainWorkspaces still wait for running renders before they close a session. Definition discovery and staging do not touch session state.
Activity
lynnswap commentedon Nov 20, 2026
Decision: split both classes by responsibility and rename the four
Correctionclasses after what they do. The work lands in four PRs, in this order.Rename the classes.
NativePreviewCorrectionRenderPreviewwith the direct renderer and falls back to the native actionNativePreviewToolNativeCrashToolCorrectionNativeCrashToolsNativeTestableStateCorrection_IDETestableStatefrom creating notice providers after invalidationNativeTestableStateNoticeGuardNativeSimulatorLaunchCorrectionNativeSimulatorLaunchTrackerMove preview definition discovery to
NativePreviewDefinitions. This covers source lookup, the registry, and the provider specification. Move product staging toNativePreviewStaging, which handles target selection, framework dependencies, static linking, and app preparation.NativePreviewBuildandNativePreviewProductSignaturecall staging today, so this also removes their dependency on the tool class.Move
WorkspaceSessioninto its ownNativePreviewSessiontype. The new type owns its stages, simulator, and installed applications, and it also owns the operations that stop, reset, and close them.Split
NativePreviewBuildthree ways:NativePreviewProjectInputs, which ownssynchronizedProjects.NativePreviewDestinations, which ownsdestinationPreparationandsourceSelections.NativePreviewBuildkeeps the build operation and target records.The split keeps the reuse and cleanup guarantees in
Docs/maintainer-architecture.md. Session state still changes only insiderenderQueue.withAccess(to:), and onlyNativePreviewToolcalls the session. Cancellation andretainWorkspacesstill wait for running renders before they close a session. Definition discovery and staging do not touch session state.