Skip to content

Commit 4f0d3fb

Browse files
Copilotfderuiter
andauthored
Add setup wizard UX design specification details
Co-authored-by: fderuiter <127706008+fderuiter@users.noreply.github.com>
1 parent ba0997a commit 4f0d3fb

2 files changed

Lines changed: 101 additions & 1 deletion

File tree

packages/plugins-streamlit/src/imednet_streamlit/pages/setup_wizard.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,84 @@
2727
"Export / Save",
2828
)
2929

30+
_STATE_TRANSITION_DIAGRAM = """```text
31+
[Step 1: Scan & Profile]
32+
├─ Scan button → discovered_schema, validation_report=None
33+
└─ Next (enabled when forms discovered) → Step 2
34+
35+
[Step 2: Field Mapping]
36+
├─ Mapping selectors → mapping_config.mappings
37+
├─ Previous → Step 1
38+
└─ Next → Step 3
39+
40+
[Step 3: Terminology Normalization]
41+
├─ Normalization inputs → mapping_config.terminology_lookups
42+
├─ Snapshot controls → _wizard_snapshots / mapping_config restore
43+
├─ Previous → Step 2
44+
└─ Next → Step 4
45+
46+
[Step 4: Layout & Visual Configuration]
47+
├─ Widget and layout controls → mapping_config.widgets
48+
├─ Preview metrics → validation_report
49+
├─ Previous → Step 3
50+
└─ Next → Step 5
51+
52+
[Step 5: Export / Save]
53+
├─ Download JSON payload
54+
├─ Save locally (.imednet/configs)
55+
└─ Previous → Step 4
56+
57+
Global transitions:
58+
- Numbered nav buttons jump to any step (1..5)
59+
- wizard_step is clamped to range 1..5 on every transition
60+
```"""
61+
62+
_SESSION_STATE_WIREFRAME = "\n".join(
63+
[
64+
"| Wizard step | Primary UI frame | Session state mutations |",
65+
"| --- | --- | --- |",
66+
(
67+
"| 1 | Scan action + AE/PD/DD form selectors | `discovered_schema`, "
68+
"`wizard_target_form_*`,<br>`validation_report` reset |"
69+
),
70+
(
71+
"| 2 | Canonical target cards with source form/field/fallback controls | "
72+
"`mapping_config.mappings` |"
73+
),
74+
(
75+
"| 3 | Mapping selector + raw→normalized value inputs + snapshot controls | "
76+
"`mapping_config.terminology_lookups`, `_wizard_snapshots`,"
77+
"<br>`mapping_config` restore/reset |"
78+
),
79+
(
80+
"| 4 | Widget type multiselect + layout slider + preview metrics grid | "
81+
"`mapping_config.widgets`, `validation_report` |"
82+
),
83+
(
84+
"| 5 | JSON preview + download + local save action | writes config file "
85+
"locally; no additional session mutation required |"
86+
),
87+
]
88+
)
89+
90+
_UX_REVIEW_NOTES = "\n".join(
91+
[
92+
(
93+
"- The setup wizard remains a dedicated page in Streamlit multi-page "
94+
'navigation (`st.Page(..., title="Setup Wizard")`) and does not fork '
95+
"to separate app routes."
96+
),
97+
(
98+
"- In-page progression is controlled by `wizard_step` so reruns preserve "
99+
"context while users move through numbered tabs and Previous/Next controls."
100+
),
101+
(
102+
"- Guardrails are presented inline (`st.info`) when prerequisites are "
103+
"missing, which aligns with Streamlit's rerun-first interaction pattern."
104+
),
105+
]
106+
)
107+
30108
_CANONICAL_FIELDS = (
31109
("AE", "event_term", "Adverse Event Term"),
32110
("AE", "severity", "Severity"),
@@ -38,6 +116,16 @@
38116
_WIDGET_TYPES = ("kpi_card", "bar_chart", "line_chart", "data_table")
39117

40118

119+
def _render_design_specification() -> None:
120+
st.markdown("### Wizard UX design specification")
121+
st.markdown("#### Flowchart / state transitions")
122+
st.markdown(_STATE_TRANSITION_DIAGRAM)
123+
st.markdown("#### Wireframe mapped to session state")
124+
st.markdown(_SESSION_STATE_WIREFRAME)
125+
st.markdown("#### UX review: Streamlit multi-page alignment")
126+
st.markdown(_UX_REVIEW_NOTES)
127+
128+
41129
def _initialise_state(study_key: str) -> None:
42130
st.session_state.setdefault(_KEY_WIZARD_STEP, 1)
43131
st.session_state.setdefault(_KEY_DISCOVERED_SCHEMA, None)
@@ -467,6 +555,7 @@ def _step_export(study_key: str) -> None:
467555

468556
def render_page() -> None:
469557
st.title("🧭 Study Setup Wizard")
558+
_render_design_specification()
470559

471560
if not st.session_state.get("_imednet_connected"):
472561
st.info("Please connect from the sidebar to configure and publish a study mapping.")

tests/unit/streamlit/test_pages_setup_wizard.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(self) -> None:
4747
self.info_calls: list[str] = []
4848
self.error_calls: list[str] = []
4949
self.titles: list[str] = []
50+
self.markdown_calls: list[str] = []
5051

5152
def title(self, value: str) -> None:
5253
self.titles.append(value)
@@ -55,7 +56,7 @@ def subheader(self, value: str) -> None:
5556
return None
5657

5758
def markdown(self, value: str) -> None:
58-
return None
59+
self.markdown_calls.append(value)
5960

6061
def caption(self, value: str) -> None:
6162
return None
@@ -261,6 +262,16 @@ def test_setup_wizard_scan_and_next_step() -> None:
261262
assert fake_st.session_state["wizard_step"] == 2
262263

263264

265+
def test_setup_wizard_renders_design_specification_sections() -> None:
266+
fake_st = _FakeStreamlit()
267+
_run_setup_wizard(fake_st)
268+
269+
joined_markdown = "\n".join(fake_st.markdown_calls)
270+
assert "Flowchart / state transitions" in joined_markdown
271+
assert "Wireframe mapped to session state" in joined_markdown
272+
assert "UX review: Streamlit multi-page alignment" in joined_markdown
273+
274+
264275
def test_setup_wizard_mapping_normalization_preview_and_export() -> None:
265276
fake_st = _FakeStreamlit()
266277
fake_st.session_state["wizard_step"] = 2

0 commit comments

Comments
 (0)