Initial TrueGrowth source import
This commit is contained in:
20
openspec/changes/refactor-workflow-shell/design.md
Normal file
20
openspec/changes/refactor-workflow-shell/design.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## Context
|
||||
|
||||
Video analyzer, MV creator, and music analyzer each own their page routing and domain-specific task interpretation, but they duplicate workflow shell lifecycle code.
|
||||
|
||||
## Decisions
|
||||
|
||||
- Keep domain sync logic in each workflow's existing `task-sync.ts`.
|
||||
- Share only the thin shell concerns:
|
||||
- step rendering and disabled step behavior
|
||||
- step/history/starred navigation shell rendering
|
||||
- page and history/starred navigation actions
|
||||
- record list/current record/starred UI state
|
||||
- completed task scan, subscription, in-flight de-dupe, and unmount cleanup
|
||||
- Keep storage keys, record schemas, task metadata, provider routing, media execution, and service worker behavior unchanged.
|
||||
|
||||
## Failure Modes
|
||||
|
||||
- Task sync handlers may throw; the shared hook logs the failure and releases the in-flight task id.
|
||||
- Task sync may finish after unmount; the shared hook drops late results.
|
||||
- Record loading may fail or return bad data; the shared record hook falls back to an empty list without changing storage.
|
||||
21
openspec/changes/refactor-workflow-shell/proposal.md
Normal file
21
openspec/changes/refactor-workflow-shell/proposal.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Change: refactor workflow shell
|
||||
|
||||
## Why
|
||||
|
||||
Video analyzer, MV creator, and music analyzer duplicate the same workflow container concerns: step navigation, history/starred state, record loading, and completed task synchronization. This makes small fixes expensive and increases the chance of lifecycle leaks or divergent behavior.
|
||||
|
||||
## What Changes
|
||||
|
||||
- Add shared internal workflow shell primitives for step bars, record state, and task synchronization
|
||||
- Migrate the three workflow containers to those shared primitives without changing user-facing behavior
|
||||
- Preserve existing storage keys, record schemas, task metadata, provider routing, media handling, and service worker behavior
|
||||
- Add focused unit tests for the shared primitives and container-critical edge cases
|
||||
|
||||
## Impact
|
||||
|
||||
- Affected specs: `workflow-shell`
|
||||
- Affected code:
|
||||
- `packages/drawnix/src/components/shared/workflow/`
|
||||
- `packages/drawnix/src/components/video-analyzer/`
|
||||
- `packages/drawnix/src/components/mv-creator/`
|
||||
- `packages/drawnix/src/components/music-analyzer/`
|
||||
@@ -0,0 +1,69 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Workflow Containers SHALL Share Internal Step Navigation
|
||||
|
||||
The system SHALL render workflow step navigation through a shared internal component so that active, past, disabled, and click behavior remains consistent across workflow pages.
|
||||
|
||||
#### Scenario: Workflow step navigation preserves page gates
|
||||
|
||||
- **WHEN** a workflow page renders its steps
|
||||
- **THEN** each step SHALL use the workflow's configured id and label
|
||||
- **AND** steps whose requirements are not met SHALL be disabled
|
||||
- **AND** disabled steps SHALL NOT trigger navigation
|
||||
|
||||
### Requirement: Workflow Containers SHALL Share Completed Task Synchronization
|
||||
|
||||
The system SHALL synchronize completed workflow tasks through a shared internal lifecycle helper that scans existing completed tasks, subscribes to future task updates, avoids duplicate in-flight synchronization, and cleans up subscriptions on unmount.
|
||||
|
||||
#### Scenario: Completed task updates are synchronized once
|
||||
|
||||
- **WHEN** an existing completed task or future completed task matches a workflow sync handler
|
||||
- **THEN** the workflow SHALL run the matching synchronization once per in-flight task id
|
||||
- **AND** apply returned record updates only while the workflow container is still mounted
|
||||
|
||||
#### Scenario: Task synchronization is cleaned up
|
||||
|
||||
- **WHEN** the workflow container unmounts
|
||||
- **THEN** the task update subscription SHALL be unsubscribed
|
||||
- **AND** late synchronization results SHALL NOT update React state
|
||||
|
||||
### Requirement: Workflow Containers SHALL Share Basic Record State
|
||||
|
||||
The system SHALL keep workflow record list, current record, and starred-history state in a shared internal hook while preserving existing storage keys, record schemas, and page-specific navigation behavior.
|
||||
|
||||
#### Scenario: Workflow records load and update without schema changes
|
||||
|
||||
- **WHEN** a workflow container mounts or receives a record update
|
||||
- **THEN** it SHALL use the existing workflow storage functions
|
||||
- **AND** SHALL NOT change stored record shape or storage key
|
||||
|
||||
### Requirement: Workflow Containers SHALL Share History Navigation Shell
|
||||
|
||||
The system SHALL render workflow history and starred navigation through a shared internal component while preserving each workflow's page-specific back target and step configuration.
|
||||
|
||||
#### Scenario: Workflow history navigation preserves behavior
|
||||
|
||||
- **WHEN** a workflow is on a normal step page
|
||||
- **THEN** the navigation SHALL show history and starred entry buttons with existing count badges
|
||||
- **AND** opening either entry SHALL preserve the workflow's existing history page behavior
|
||||
|
||||
#### Scenario: Workflow history header preserves behavior
|
||||
|
||||
- **WHEN** a workflow is on its history page
|
||||
- **THEN** the navigation SHALL show the existing back button, title, and starred filter toggle
|
||||
- **AND** the back button SHALL return to that workflow's configured entry page
|
||||
|
||||
### Requirement: Workflow Containers SHALL Share Navigation Actions
|
||||
|
||||
The system SHALL keep workflow page state and history/starred entry actions in a shared internal hook while preserving workflow-specific default pages and explicit page transitions.
|
||||
|
||||
#### Scenario: Workflow opens history and starred views
|
||||
|
||||
- **WHEN** a workflow container opens all-history or starred-history
|
||||
- **THEN** the shared navigation hook SHALL move to the configured history page
|
||||
- **AND** SHALL set the starred filter to the matching existing value
|
||||
|
||||
#### Scenario: Workflow returns to default page
|
||||
|
||||
- **WHEN** a workflow container requests a restart or history back action
|
||||
- **THEN** the shared navigation hook SHALL return to that workflow's configured default page
|
||||
26
openspec/changes/refactor-workflow-shell/tasks.md
Normal file
26
openspec/changes/refactor-workflow-shell/tasks.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## 1. Shared Workflow Shell
|
||||
|
||||
- [x] 1.1 Add `WorkflowStepBar` with configuration-driven steps and disabled rules
|
||||
- [x] 1.2 Add `useWorkflowTaskSync` for completed task scanning, subscription, de-duping, and cleanup
|
||||
- [x] 1.3 Add `useWorkflowRecords` for record list, current record, starred filter, and basic selection/update actions
|
||||
- [x] 1.4 Add `WorkflowNavBar` for shared step/history/starred navigation shell
|
||||
- [x] 1.5 Add `useWorkflowNavigation` for page and history/starred navigation actions
|
||||
|
||||
## 2. Container Migration
|
||||
|
||||
- [x] 2.1 Migrate video analyzer to shared workflow shell primitives
|
||||
- [x] 2.2 Migrate MV creator to shared workflow shell primitives while preserving `hasShots` navigation gates
|
||||
- [x] 2.3 Migrate music analyzer to shared workflow shell primitives
|
||||
- [x] 2.4 Remove superseded local StepBar implementations and unused imports
|
||||
- [x] 2.5 Migrate duplicated history/starred navigation JSX to `WorkflowNavBar`
|
||||
- [x] 2.6 Migrate duplicated navigation action handlers to `useWorkflowNavigation`
|
||||
|
||||
## 3. Validation
|
||||
|
||||
- [x] 3.1 Add focused unit tests for step bar rendering and disabled behavior
|
||||
- [x] 3.2 Add focused unit tests for task sync lifecycle and cleanup
|
||||
- [x] 3.3 Add focused unit tests for record state helpers
|
||||
- [x] 3.4 Run OpenSpec validation and targeted workflow tests
|
||||
- [x] 3.5 Run broader project checks as far as the current worktree allows
|
||||
- [x] 3.6 Add focused unit tests for shared workflow navigation shell
|
||||
- [x] 3.7 Add focused unit tests for shared workflow navigation hook
|
||||
Reference in New Issue
Block a user