prometeu-studio/discussion/workflow/plans/PLN-0028-consume-frontend-owned-semantic-presentation-in-studio.md
2026-04-02 15:03:00 +01:00

133 lines
5.5 KiB
Markdown

---
id: PLN-0028
ticket: studio-frontend-owned-semantic-editor-presentation
title: Consume frontend-owned semantic presentation in Studio and retire generic FE theme usage
status: review
created: 2026-04-02
completed:
tags:
- studio
- editor
- semantic-highlighting
- frontend
- presentation
---
## Objective
Make Studio consume the frontend-owned semantic presentation descriptor from LSP, apply FE-owned resources, and degrade cleanly to no highlight when semantic presentation data is unavailable.
## Background
`DEC-0012` and `PLN-0027` move semantic presentation ownership out of Studio. After the descriptor and frontend resources exist, Studio must stop relying on generic frontend presentation styling and instead consume FE-owned semantic presentation data.
## Scope
### Included
- Studio-side consumption of the LSP semantic presentation descriptor.
- Mechanical semantic key to CSS class projection.
- Loading FE-owned highlight resources through normal Java resource resolution.
- Graceful no-highlight behavior when descriptor/resources are unavailable.
- Removal of generic FE-specific highlight ownership assumptions from Studio runtime flow.
### Excluded
- Frontend contract creation.
- LSP descriptor creation.
- Spec writing.
## Execution Steps
### Step 1 - Add descriptor-aware Studio highlight consumption
**What:**
Teach Studio editor highlighting flow to consume the frontend semantic presentation descriptor.
**How:**
Extend the Studio-side LSP consumption path so semantic highlight application depends on descriptor data and no longer assumes a single generic frontend presentation.
**File(s):**
- `prometeu-studio/src/main/java/p/studio/workspaces/editor/EditorWorkspace.java`
- `prometeu-studio/src/main/java/p/studio/workspaces/editor/EditorDocumentPresentationRegistry.java`
- `prometeu-studio/src/main/java/p/studio/workspaces/editor/syntaxhighlight/EditorDocumentSemanticHighlighting.java`
### Step 2 - Replace generic FE styling assumption with mechanical class projection
**What:**
Project frontend semantic keys directly into CSS classes.
**How:**
Implement a stable Studio-side projection rule such as `semanticKey -> editor-semantic-<semanticKey>` and apply those classes to semantic spans without any semantic translation layer.
**File(s):**
- `prometeu-studio/src/main/java/p/studio/workspaces/editor/syntaxhighlight/EditorDocumentSemanticHighlighting.java`
- any adjacent presentation/style support files
### Step 3 - Load FE-owned resources and remove generic FE ownership path
**What:**
Load FE-owned stylesheet resources rather than Studio-owned generic FE semantic CSS.
**How:**
Use descriptor resources surfaced through LSP, attach the referenced stylesheet(s) to the editor presentation/runtime flow, and stop depending on generic `fe.css` as the semantic owner for FE documents.
**File(s):**
- `prometeu-studio/src/main/java/p/studio/workspaces/editor/EditorDocumentPresentationRegistry.java`
- `prometeu-studio/src/main/resources/themes/editor/presentations/fe.css` if retired or narrowed
### Step 4 - Implement graceful no-highlight degradation
**What:**
Ensure Studio continues to work without semantic highlight when descriptor/resources are absent.
**How:**
When the descriptor is absent or resources cannot be consumed, skip semantic styling for that frontend document, preserve editor usability, and avoid user-facing Studio errors.
**File(s):**
- `prometeu-studio/src/main/java/p/studio/workspaces/editor/EditorWorkspace.java`
- semantic highlight routing/presentation files in the editor workspace
### Step 5 - Add Studio tests for FE-owned semantic presentation consumption
**What:**
Cover descriptor consumption, class projection, and no-highlight degradation.
**How:**
Add editor-side tests that assert Studio consumes descriptor data, applies projected classes, and keeps operating when descriptor/resources are missing.
**File(s):**
- `prometeu-studio/src/test/java/p/studio/workspaces/editor/...`
## Test Requirements
### Unit Tests
- Editor highlight routing tests for semantic key projection.
- Presentation registry tests for descriptor-driven resource loading.
- No-highlight degradation tests when descriptor/resources are absent.
### Integration Tests
- End-to-end Studio/LSP test using a frontend document with FE-owned semantic keys and FE-owned stylesheet resources.
### Manual Verification
- Open a PBS document and verify semantic colors come from FE-owned presentation resources, not generic Studio FE theme assumptions.
- Temporarily remove or break the descriptor/resource and verify the editor remains usable with no semantic highlight.
## Acceptance Criteria
- [ ] Studio consumes frontend-owned semantic presentation descriptor data from LSP.
- [ ] Studio projects semantic keys mechanically to CSS classes.
- [ ] Generic Studio-owned frontend semantic presentation is no longer the runtime owner for FE highlight.
- [ ] Missing descriptor/resources degrade to no highlight without Studio UI errors.
- [ ] Studio tests cover the new descriptor consumption path.
## Dependencies
- Depends on `DEC-0012`.
- Depends on `PLN-0027` for descriptor and resource publication.
- Can run after or in parallel with `PLN-0026`, but should not merge before the contract surface in `PLN-0027` exists.
## Risks
- Existing Studio presentation registry may assume static local stylesheets and need a broader refactor.
- Descriptor-driven resource loading can accidentally leak stylesheet accumulation if lifecycle cleanup is not handled carefully.
- Partial migration may leave residual `fe.css` assumptions in tests or runtime paths.