feat(workflow): show object state machines on record detail#65
Merged
Conversation
The StateMachineViewer existed and was unit-tested but had no route into the app. Wire it onto record detail as a "Lifecycle" diagram: - useStateMachines / deriveStateMachines resolve each `meta.stateMachines` entry against the object's fields. State machines carry no explicit field link, so match a machine to the select field whose option values cover its state names; that field's value on the record becomes the current state. States are classified initial/normal/final and labelled from the matched field's (localized) option labels; transitions carry their event + description. - RecordStateMachines renders one titled card per machine. - StateMachineViewer gains a `scrollable` prop (default true) so it lays out at natural height when embedded in the detail scroll view instead of collapsing a nested flex-1 ScrollView. - DetailViewRenderer gains a `footer` slot; the detail screen passes the lifecycle diagram through it (only when a machine is present). Verified in-browser against a local 7.5.0 server: the crm_opportunity "Lifecycle" diagram renders with the current stage highlighted, initial/final markers, and localized state labels. Adds deriveStateMachines unit tests; typecheck clean; full jest suite green apart from the pre-existing snapshots. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StateMachineViewerexisted and was unit-tested but had no route into the app. This surfaces it as a Lifecycle diagram on the record detail page (completing the trio: actions ✅, flows ✅, state machines ✅).useStateMachines/deriveStateMachinesresolve eachmeta.stateMachinesentry against the object's fields. State machines carry no explicit field link, so a machine is matched to the select field whose option values cover its state names; that field's value on the record becomes the current state. States are classified initial/normal/final and labelled from the matched field's (localized) option labels; transitions carry their event + description.RecordStateMachinesrenders one titled card per machine.StateMachineViewergains ascrollableprop (defaulttrue, backward-compatible) so it lays out at natural height when embedded in the detail scroll view instead of collapsing a nestedflex-1ScrollView.DetailViewRenderergains afooterslot; the detail screen passes the lifecycle diagram through it, only when a machine is present.Verification
crm_opportunityLifecycle diagram renders with the current stage (提案 / proposal) highlighted, initial (●) / final (◎) markers, transition event descriptions, and localized state labels.deriveStateMachinesunit tests (field matching, initial/final classification, transitions, current-state, no-match + no-machine fallbacks) — 3 pass; existingStateMachineViewertest still green.tsc --noEmitclean; full jest suite 1125 pass (20 pre-existing snapshot failures, unrelated).Notes
Read-only diagram for now. Driving transitions (tap an outgoing edge to advance the stage) could build on the same derivation + the existing record-update path in a follow-up.
🤖 Generated with Claude Code