Skip to content

Decide how to split the native preview classes #489

Closed

Description

@lynnswap

Why

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:

Activity

  1. lynnswap commented on Nov 20, 2026

    @lynnswap
    OwnerAuthor

    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.

    1. 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
    2. 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.

    3. 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.

    4. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions