prometeu-studio/docs/studio/pull-requests/PR-07a-assets-event-topology-and-lifecycle-foundation.md

125 lines
5.7 KiB
Markdown

# PR-07a Assets Event Topology and Lifecycle Foundation
Domain owner: `docs/studio`
## Briefing
Refactor the `Assets` workspace foundation away from a monolithic `AssetWorkspace` that redraws major regions after local changes.
This slice establishes the corrective architectural direction for the Studio as a whole.
`Assets` is the first consumer and proving ground, but the target is not an `Assets`-only pattern.
The Studio-standard direction is:
- lifecycle-aware UI components;
- typed workspace events as the update mechanism;
- component-scoped subscriptions;
- explicit separation between structural workspace sync and local UI projection updates;
- reusable workspace framework pieces that other Studio workspaces must consume instead of inventing their own refresh-heavy flow.
## Objective
Create the event-driven workspace foundation required for all later `Assets` refactor slices and establish it as the correct Studio-wide pattern for workspace implementation.
After this PR:
- the workspace root coordinates composition instead of owning every region render path;
- navigator, row, details, and details-internal controls can subscribe independently;
- the workspace event bus becomes the primary update path for UI change propagation;
- `refresh()` is no longer the default answer for local state changes.
- the extracted lifecycle/event-driven primitives are designed for reuse by non-`Assets` workspaces.
## Dependencies
- [`../specs/4. Assets Workspace Specification.md`](../specs/4.%20Assets%20Workspace%20Specification.md)
- [`./PR-05a-assets-workspace-foundation-and-service-state.md`](./PR-05a-assets-workspace-foundation-and-service-state.md)
- existing `StudioWorkspaceEventBus`
- existing `StudioControlLifecycle` support
## Scope
- define the target event topology for the `Assets` workspace
- define the target event topology as the canonical Studio workspace model
- split workspace responsibilities between composition, state coordination, and component rendering
- extract reusable workspace framework primitives where the abstraction is already justified by the `Assets` refactor
- introduce lifecycle-aware component boundaries for:
- navigator host
- asset-list host
- asset-row item
- details host
- details-local sections/forms
- introduce reusable patterns or base components for:
- workspace composition roots
- lifecycle-managed event subscribers
- projection host controls
- structural-sync versus local-patch orchestration
- define typed events for:
- structural snapshot changes
- projection changes
- selection changes
- selected-asset details lifecycle
- local patch propagation
- demote global redraw events to transitional or removable status
## Non-Goals
- no final navigator visuals redesign in this slice
- no final details-panel redesign in this slice
- no mutation-semantics redesign beyond event routing needs
- no broad shell-level event-system rewrite outside `Assets`
- no fake generalization disconnected from concrete `Assets` usage
## Execution Method
1. Define the component tree and ownership model.
The workspace root should compose controls and services, not render every region inline.
2. Introduce event contracts for the asset workspace projection model.
The baseline contract should distinguish:
- structural workspace sync events
- navigator projection events
- selected-asset details events
- per-asset patch events
3. Convert `AssetWorkspace` into a composition root plus orchestration layer.
It may still coordinate service calls, but rendering responsibilities should move into dedicated controls.
4. Extract reusable workspace-framework pieces while doing the refactor.
`Assets` should consume the same primitives that future Studio workspaces are expected to consume.
5. Require lifecycle installation for event-consuming controls.
Every component that subscribes to workspace events must implement `StudioControlLifecycle` and subscribe only while attached to the scene.
6. Mark the existing redraw-request pattern as transitional.
`StudioAssetsNavigatorRedrawRequestedEvent` and `StudioAssetsDetailsRedrawRequestedEvent` should no longer be the target architecture.
7. Propagate the rule to Studio documentation.
The resulting plans/spec updates should make clear that future workspaces are expected to build on this framework instead of introducing workspace-local refresh architecture.
## Acceptance Criteria
- the refactor has a clear component topology instead of one render-heavy workspace class
- lifecycle-aware controls own their own subscriptions
- the workspace event bus carries typed update events that components can consume independently
- local UI changes can be expressed without a full workspace refresh path
- the old redraw-request events are either removed or isolated behind temporary compatibility adapters
- the extracted primitives are reusable by other Studio workspaces
- the plan explicitly establishes this direction as the Studio-standard workspace architecture
## Validation
- unit tests for event routing between composition root and child controls
- unit tests for lifecycle subscribe/unsubscribe behavior on workspace controls
- smoke validation that mounting and unmounting the workspace does not leak subscriptions
## Affected Artifacts
- `prometeu-studio/src/main/java/p/studio/workspaces/assets/AssetWorkspace.java`
- new reusable workspace-framework classes under `prometeu-studio/src/main/java/p/studio/...`
- new `Assets` workspace controls under `prometeu-studio/src/main/java/p/studio/workspaces/assets/...`
- `prometeu-studio/src/main/java/p/studio/events/...`
- `docs/studio/specs/1. Studio Shell and Workspace Layout Specification.md`
- `docs/studio/specs/3. Studio Components Module Specification.md`
- tests for workspace event topology and lifecycle behavior