Polish Dream QA user tone

#18
PRODUCT.md CHANGED
@@ -42,6 +42,8 @@ The voice is a calm dream companion who asks good questions and takes odd detail
42
  6. The demo path must survive Space constraints and still have a model-backed route.
43
  7. English mode is the default public path; Chinese mode is a first-class toggle, not a separate product.
44
  8. Recommendation quality is tested with a deterministic Today Tip eval set before deployment.
 
 
45
 
46
  ## Accessibility & Inclusion
47
 
 
42
  6. The demo path must survive Space constraints and still have a model-backed route.
43
  7. English mode is the default public path; Chinese mode is a first-class toggle, not a separate product.
44
  8. Recommendation quality is tested with a deterministic Today Tip eval set before deployment.
45
+ 9. English mode must stay natural English, including translated or paraphrased dream anchors; mixed Chinese helper text is a regression.
46
+ 10. Tiny actions should feel like a first step the user may choose, not a hard command to solve the real-world problem immediately.
47
 
48
  ## Accessibility & Inclusion
49
 
README.md CHANGED
@@ -55,8 +55,9 @@ This is not a therapy, diagnosis, or prophecy product.
55
 
56
  - Default public UI: English.
57
  - Toggle: `English / 中文`.
58
- - English mode may preserve user-provided dream anchors as written, but all UI labels, guidance, and generated helper text should be English.
59
  - Chinese mode keeps the warm `梦境问答台` wording.
 
60
 
61
  ## Current Direction References
62
 
 
55
 
56
  - Default public UI: English.
57
  - Toggle: `English / 中文`.
58
+ - English mode translates or paraphrases non-English dream anchors into natural English, so an international judge does not see mixed UI/model language.
59
  - Chinese mode keeps the warm `梦境问答台` wording.
60
+ - Today Tips should be small and optional: "write the first sentence" beats "handle it immediately."
61
 
62
  ## Current Direction References
63
 
docs/handoff.md CHANGED
@@ -51,6 +51,12 @@ Final positioning:
51
 
52
  > Dream QA helps you record a dream, answer or skip one gentle question, and leave with one grounded Today Tip.
53
 
 
 
 
 
 
 
54
  ## Model Decision
55
 
56
  Use:
 
51
 
52
  > Dream QA helps you record a dream, answer or skip one gentle question, and leave with one grounded Today Tip.
53
 
54
+ 2026-06-09 tone contract:
55
+
56
+ - English mode is not just English UI chrome; generated anchors, questions, and Today Tips should read as natural English.
57
+ - If the model receives Chinese anchors while the selected language is English, translate or paraphrase them unless a short exact quote is intentionally preserved.
58
+ - Tiny actions should feel like five-minute first steps. Avoid urgent command phrasing such as "address it immediately."
59
+
60
  ## Model Decision
61
 
62
  Use:
docs/prd.md CHANGED
@@ -102,6 +102,7 @@ Acceptance criteria:
102
  - Result is readable on mobile and desktop.
103
  - Result avoids medical, prophetic, or deterministic framing.
104
  - Today tip references a concrete dream anchor.
 
105
 
106
  #### Story 6: Bilingual Demo
107
 
@@ -112,6 +113,7 @@ Acceptance criteria:
112
  - Default UI title is `Dream QA`.
113
  - A visible `English / 中文` control exists.
114
  - English mode renders English labels and card headings.
 
115
  - Chinese mode renders `梦境问答台` and Chinese Today Tip labels.
116
  - Both modes use the same model/pipeline route.
117
 
@@ -147,6 +149,8 @@ Prompts must:
147
  - Keep final advice small enough to execute today.
148
  - Require at least one dream anchor in the final tip.
149
  - Follow selected language: English by default, Chinese when selected.
 
 
150
 
151
  ### Evaluation Strategy
152
 
 
102
  - Result is readable on mobile and desktop.
103
  - Result avoids medical, prophetic, or deterministic framing.
104
  - Today tip references a concrete dream anchor.
105
+ - Optional tiny action is a five-minute first step, not a command to solve the whole issue immediately.
106
 
107
  #### Story 6: Bilingual Demo
108
 
 
113
  - Default UI title is `Dream QA`.
114
  - A visible `English / 中文` control exists.
115
  - English mode renders English labels and card headings.
116
+ - English mode translates or paraphrases non-English anchors into English unless preserving a deliberate user quote.
117
  - Chinese mode renders `梦境问答台` and Chinese Today Tip labels.
118
  - Both modes use the same model/pipeline route.
119
 
 
149
  - Keep final advice small enough to execute today.
150
  - Require at least one dream anchor in the final tip.
151
  - Follow selected language: English by default, Chinese when selected.
152
+ - Avoid mixed-language leakage in English output.
153
+ - Avoid hard commands such as "address it immediately"; prefer optional first-step language.
154
 
155
  ### Evaluation Strategy
156
 
docs/smoke/2026-06-08-post-refactor-polish-smoke.md CHANGED
@@ -127,11 +127,106 @@ has_zh_anchor=True
127
  - Chrome extension control returned a closed native pipe while opening the same local URL.
128
  - Because both browser automation surfaces were unstable, no visual screenshot claim is made here. The local Gradio `/config`, app build check, action flow, full pytest suite, and deterministic quality evaluator passed.
129
 
130
- ## Deployment Status
131
 
132
- Not yet deployed in this smoke file. After commit and GitHub/HF sync, update this file or add a follow-up remote smoke section with:
133
 
134
- - GitHub PR URL and merge commit.
135
- - HF Space PR discussion URL and Space `main` SHA.
136
- - Public Space `/config` result.
137
- - Public app flow check.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  - Chrome extension control returned a closed native pipe while opening the same local URL.
128
  - Because both browser automation surfaces were unstable, no visual screenshot claim is made here. The local Gradio `/config`, app build check, action flow, full pytest suite, and deterministic quality evaluator passed.
129
 
130
+ ## GitHub Sync
131
 
132
+ Feature branch commit:
133
 
134
+ ```text
135
+ 0193b67 feat: polish dream qa post-refactor flow
136
+ ```
137
+
138
+ GitHub PR:
139
+
140
+ ```text
141
+ https://github.com/adjcjh777/dream-customs-build-small/pull/2
142
+ ```
143
+
144
+ Observed PR status:
145
+
146
+ ```text
147
+ MERGED
148
+ merge_commit=f2cafa12f9db694acf2181a54fc6059419bbd4e7
149
+ ```
150
+
151
+ Result: GitHub `main` contains the English-first Dream QA polish.
152
+
153
+ ## Hugging Face Space Sync
154
+
155
+ HF Space PR:
156
+
157
+ ```text
158
+ https://huggingface.co/spaces/build-small-hackathon/dream-customs/discussions/17
159
+ ```
160
+
161
+ Observed refs:
162
+
163
+ ```text
164
+ space/main=19c54925bbb525405bc2540391a434ddaeba4139
165
+ refs/pr/17=2017dd6906f3cce640e4a53508ea21b163c3b52e
166
+ ```
167
+
168
+ Observed discussion metadata:
169
+
170
+ ```text
171
+ num=17
172
+ title=Deploy Dream QA post-refactor polish
173
+ status=open
174
+ is_pull_request=True
175
+ ```
176
+
177
+ Merge status: BLOCKED.
178
+
179
+ Blockers observed:
180
+
181
+ - Chrome extension automation could list browser sessions but failed to control Chrome tabs with `native pipe is closed`.
182
+ - HF Hub API `merge_pull_request(... discussion_num=17)` returned an `HfHubHTTPError`; this matches the previous pattern where API merge rights are not available from the cached token.
183
+ - Follow-up Chrome diagnostics on 2026-06-09 showed:
184
+ - Google Chrome is installed and running.
185
+ - Codex Chrome Extension is installed and enabled in the selected `Default` profile.
186
+ - Native host manifest exists and has the expected extension origin.
187
+ - Despite those checks, Chrome automation still fails at tab control with `native pipe is closed`.
188
+ - A follow-up API merge retry still returned `HfHubHTTPError`.
189
+ - A safety check for direct Space git sync could not prove fast-forward safety because `git fetch space main` failed at the HF git/LFS negotiation layer with `fatal: expected 'acknowledgments'`.
190
+
191
+ Result: HF Space PR #17 is ready but not merged. Public Space `main` is still `19c54925...` until a logged-in browser merge succeeds or the HF token gains merge permission.
192
+
193
+ ## Hugging Face Merge Follow-up - 2026-06-09
194
+
195
+ Chrome logged-in merge succeeded.
196
+
197
+ Observed discussion metadata:
198
+
199
+ ```text
200
+ num=17
201
+ title=Deploy Dream QA post-refactor polish
202
+ status=merged
203
+ is_pull_request=True
204
+ ```
205
+
206
+ Observed refs after merge:
207
+
208
+ ```text
209
+ space/main=c2a7a861b44613ff477695f4f1a15f781a440fae
210
+ refs/pr/17=2017dd6906f3cce640e4a53508ea21b163c3b52e
211
+ ```
212
+
213
+ HF Space was paused immediately after merge, then restarted from the Space page.
214
+
215
+ Runtime check:
216
+
217
+ ```text
218
+ stage=RUNNING
219
+ hardware=zero-a10g
220
+ requested_hardware=zero-a10g
221
+ ```
222
+
223
+ Public Space `/config` check:
224
+
225
+ ```text
226
+ title=Dream QA
227
+ version=4.44.1
228
+ mode=blocks
229
+ component_count=72
230
+ ```
231
+
232
+ Result: HF Space `main` now contains the Dream QA post-refactor polish, and the public Space is serving the updated Gradio app config.
docs/smoke/2026-06-09-user-tone-polish-smoke.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dream QA User Tone Polish Smoke - 2026-06-09
2
+
3
+ ## Scope
4
+
5
+ - Remove English-mode Chinese anchor leakage observed in the public Space user walk-through.
6
+ - Make Today Tip actions warmer, smaller, and less command-like.
7
+ - Remove backend jargon from the public user flow.
8
+ - Keep Chinese mode available through the language toggle.
9
+
10
+ ## Local Verification
11
+
12
+ Commands:
13
+
14
+ ```text
15
+ .venv/bin/python -m pytest -q
16
+ .venv/bin/python scripts/evaluate_today_tip_quality.py
17
+ git diff --check
18
+ ```
19
+
20
+ Observed:
21
+
22
+ ```text
23
+ 95 passed, 2 warnings
24
+ {"case_count": 11, "failures": {}, "passes": true}
25
+ git diff --check clean
26
+ ```
27
+
28
+ ## Local Gradio Config
29
+
30
+ Observed from `http://127.0.0.1:7860/config`:
31
+
32
+ ```text
33
+ title=Dream QA
34
+ version=4.44.1
35
+ mode=blocks
36
+ component_count=72
37
+ ```
38
+
39
+ ## Local Action Smoke
40
+
41
+ English dream:
42
+
43
+ ```text
44
+ I dreamed I was in an elevator where the floor buttons melted like wax. The number 14 kept blinking, and I felt late but strangely calm.
45
+ ```
46
+
47
+ English answer:
48
+
49
+ ```text
50
+ I want to make starting my overdue email easier without feeling trapped by it.
51
+ ```
52
+
53
+ Observed:
54
+
55
+ ```text
56
+ en_after_submit=ask
57
+ question=When you think about the elevator and the melted button, what real thing today feels hard to start?
58
+ en_after_answer=tip
59
+ title=Today Tip
60
+ has_chinese_leakage=False
61
+ has_first_sentence=True
62
+ has_immediately=False
63
+ ```
64
+
65
+ Chinese smoke:
66
+
67
+ ```text
68
+ zh_after_skip=tip
69
+ title=今日小 Tips
70
+ has_zh_title=True
71
+ ```
72
+
73
+ ## Hugging Face Space Sync
74
+
75
+ Pending.
76
+
77
+ ## Public User-View Review
78
+
79
+ Pending.
docs/spec.md CHANGED
@@ -32,6 +32,8 @@ The user wakes up after a vivid or unsettling dream and wants help making sense
32
  6. End with one small today tip, not a pile of advice.
33
  7. Keep the MVP stable enough for Gradio Space and demo-video recording.
34
  8. Default to English for public judging; keep Chinese as a first-class toggle.
 
 
35
 
36
  ## 5. User Inputs
37
 
@@ -187,6 +189,8 @@ The final result must:
187
  - Avoid generic advice that could fit any dream.
188
  - Keep the today tip small enough to try today.
189
  - Use English UI/output labels by default and Chinese labels only when `中文` is selected.
 
 
190
 
191
  ## 10. UX Structure
192
 
 
32
  6. End with one small today tip, not a pile of advice.
33
  7. Keep the MVP stable enough for Gradio Space and demo-video recording.
34
  8. Default to English for public judging; keep Chinese as a first-class toggle.
35
+ 9. In English mode, translate or paraphrase non-English dream anchors into natural English instead of leaking mixed-language helper text.
36
+ 10. Treat tiny actions as optional first steps; avoid urgent commands such as "fix it immediately" or "address it immediately."
37
 
38
  ## 5. User Inputs
39
 
 
189
  - Avoid generic advice that could fit any dream.
190
  - Keep the today tip small enough to try today.
191
  - Use English UI/output labels by default and Chinese labels only when `中文` is selected.
192
+ - Keep English mode fully English unless preserving a deliberate short user quote.
193
+ - Make the optional tiny action a five-minute first step, not a demand to complete the whole waking-life problem.
194
 
195
  ## 10. UX Structure
196
 
docs/superpowers/plans/2026-06-08-post-refactor-polish.md CHANGED
@@ -25,7 +25,7 @@
25
  - No source edits required.
26
  - Record result in `docs/smoke/2026-06-08-post-refactor-polish-smoke.md`.
27
 
28
- - [ ] **Step 1: Verify branch relationship**
29
 
30
  Run:
31
 
@@ -36,7 +36,7 @@ git log --oneline origin/main..HEAD
36
 
37
  Expected: shows the post-merge Dream QA commits that are on `feature/dream-customs-ui-voice-settings` but not `origin/main`.
38
 
39
- - [ ] **Step 2: Create or update GitHub PR**
40
 
41
  Run:
42
 
@@ -54,7 +54,7 @@ gh pr create \
54
  --body-file /tmp/dream-qa-post-refactor-pr.md
55
  ```
56
 
57
- - [ ] **Step 3: Merge GitHub PR**
58
 
59
  Use the authenticated browser/CLI path available in the session. Verify with:
60
 
@@ -70,7 +70,7 @@ Expected: `state` is `MERGED`.
70
  - Create or update: `docs/smoke/2026-06-08-post-refactor-polish-smoke.md`
71
  - Test: no new unit test required for this task.
72
 
73
- - [ ] **Step 1: Verify deployed config**
74
 
75
  Run:
76
 
@@ -227,7 +227,7 @@ Run:
227
  git diff --check
228
  ```
229
 
230
- - [ ] **Step 3: Commit and push**
231
 
232
  Run:
233
 
@@ -247,6 +247,8 @@ git ls-remote space refs/heads/main
247
 
248
  Expected: Space `main` advances to the deployment commit.
249
 
 
 
250
  ## Self-Review
251
 
252
  - Spec coverage: covers GitHub main alignment, deployed smoke, English-first toggle, quality evaluation, MiniCPM follow-up quality, docs, tests, commit, push, and HF Space sync.
 
25
  - No source edits required.
26
  - Record result in `docs/smoke/2026-06-08-post-refactor-polish-smoke.md`.
27
 
28
+ - [x] **Step 1: Verify branch relationship**
29
 
30
  Run:
31
 
 
36
 
37
  Expected: shows the post-merge Dream QA commits that are on `feature/dream-customs-ui-voice-settings` but not `origin/main`.
38
 
39
+ - [x] **Step 2: Create or update GitHub PR**
40
 
41
  Run:
42
 
 
54
  --body-file /tmp/dream-qa-post-refactor-pr.md
55
  ```
56
 
57
+ - [x] **Step 3: Merge GitHub PR**
58
 
59
  Use the authenticated browser/CLI path available in the session. Verify with:
60
 
 
70
  - Create or update: `docs/smoke/2026-06-08-post-refactor-polish-smoke.md`
71
  - Test: no new unit test required for this task.
72
 
73
+ - [x] **Step 1: Verify deployed config**
74
 
75
  Run:
76
 
 
227
  git diff --check
228
  ```
229
 
230
+ - [x] **Step 3: Commit and push**
231
 
232
  Run:
233
 
 
247
 
248
  Expected: Space `main` advances to the deployment commit.
249
 
250
+ Observed 2026-06-09: HF Space PR #17 is open and ready, but merge is blocked because Chrome extension tab control fails with `native pipe is closed`, HF API merge returns `HfHubHTTPError`, and a direct git fast-forward safety check cannot complete because `git fetch space main` fails with `fatal: expected 'acknowledgments'`.
251
+
252
  ## Self-Review
253
 
254
  - Spec coverage: covers GitHub main alignment, deployed smoke, English-first toggle, quality evaluation, MiniCPM follow-up quality, docs, tests, commit, push, and HF Space sync.
docs/superpowers/plans/2026-06-09-dream-qa-user-tone-polish.md ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dream QA User Tone Polish Implementation Plan
2
+
3
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+ **Goal:** Make the public Dream QA flow feel less technical, keep English mode fully English, and produce warmer, more specific Today Tips after the user's answer.
6
+
7
+ **Architecture:** Keep the existing Dream QA flow and Gradio structure. Tighten prompt contracts, normalize model-returned English cards against common Chinese anchor leakage, soften render/UI safety copy, and extend deterministic tests so the product polish is guarded before Space deployment.
8
+
9
+ **Tech Stack:** Python, Pydantic, Gradio, pytest, Hugging Face Space.
10
+
11
+ ---
12
+
13
+ ## File Map
14
+
15
+ - Modify `dream_customs/prompts.py`: strengthen English language instructions and final Today Tip behavior.
16
+ - Modify `dream_customs/pipeline.py`: add a small English-output cleanup for common Chinese anchor leakage.
17
+ - Modify `dream_customs/models.py`: improve deterministic demo output.
18
+ - Modify `dream_customs/render.py`: make non-crisis safety copy warmer and less defensive.
19
+ - Modify `dream_customs/ui/copy.py`: remove backend jargon from the public flow and rename runtime copy to advanced user language.
20
+ - Modify `dream_customs/ui/app.py`: rename the public settings accordion from `Runtime settings` to `Advanced`.
21
+ - Modify `tests/test_ui_actions.py`: update UI copy expectations and add English-language leakage checks.
22
+ - Modify `tests/fixtures/today_tip_eval_cases.json`: add an English case that previously exposed Chinese leakage.
23
+ - Modify `scripts/evaluate_today_tip_quality.py`: fail English outputs that contain common Chinese leakage or hard-command phrasing.
24
+ - Modify `docs/spec.md`, `docs/prd.md`, `docs/handoff.md`, `README.md`: align the product contract with the user-tone polish.
25
+ - Create `docs/smoke/2026-06-09-user-tone-polish-smoke.md`: record local, HF, and browser/user-view verification.
26
+
27
+ ---
28
+
29
+ ### Task 1: Guard English Product Quality
30
+
31
+ **Files:**
32
+ - Modify: `tests/test_ui_actions.py`
33
+ - Modify: `tests/fixtures/today_tip_eval_cases.json`
34
+ - Modify: `scripts/evaluate_today_tip_quality.py`
35
+
36
+ - [x] **Step 1: Add UI copy expectations**
37
+
38
+ Update `test_processing_note_is_story_copy_not_backend_jargon` so it expects public copy to mention the user flow and rejects `model routes`, `fallback`, `token`, `endpoint`, and `debug`.
39
+
40
+ - [x] **Step 2: Add English leakage checks**
41
+
42
+ Add a test that runs an English elevator dream through `submit_dream_action` and `answer_to_card_action`, then asserts the card text/html do not contain `数字`, `电梯`, `按钮`, `楼层`, or `融化`.
43
+
44
+ - [x] **Step 3: Extend deterministic evaluator**
45
+
46
+ Update `scripts/evaluate_today_tip_quality.py` so English cases fail on the same Chinese leakage terms and hard-command phrases such as `address it immediately`.
47
+
48
+ - [x] **Step 4: Add eval fixture**
49
+
50
+ Add or update an English elevator/email case in `tests/fixtures/today_tip_eval_cases.json` with required anchors `elevator`, `button`, and `14`.
51
+
52
+ - [x] **Step 5: Run focused failing tests**
53
+
54
+ Run:
55
+
56
+ ```bash
57
+ .venv/bin/python -m pytest tests/test_ui_actions.py -q
58
+ .venv/bin/python scripts/evaluate_today_tip_quality.py
59
+ ```
60
+
61
+ Expected before implementation: at least one failure for changed expectations.
62
+
63
+ ### Task 2: Polish Prompts, Fallbacks, and Rendering
64
+
65
+ **Files:**
66
+ - Modify: `dream_customs/prompts.py`
67
+ - Modify: `dream_customs/pipeline.py`
68
+ - Modify: `dream_customs/models.py`
69
+ - Modify: `dream_customs/render.py`
70
+ - Modify: `dream_customs/ui/copy.py`
71
+ - Modify: `dream_customs/ui/app.py`
72
+
73
+ - [x] **Step 1: Tighten English prompt contract**
74
+
75
+ Update `_language_instruction` so English mode says to translate or paraphrase non-English dream anchors into natural English, except short quoted fragments that the user explicitly wrote.
76
+
77
+ - [x] **Step 2: Make Today Tip instructions more product-like**
78
+
79
+ Update `today_tip_prompt` to ask for short, warm, specific output; the `tiny_action` should be a 5-minute first step and should avoid demanding words such as "immediately".
80
+
81
+ - [x] **Step 3: Add English cleanup**
82
+
83
+ In `dream_customs/pipeline.py`, normalize common Chinese anchor leakage in English `TodayTipCard` fields after parsing. Preserve Chinese mode unchanged.
84
+
85
+ - [x] **Step 4: Improve deterministic fallback**
86
+
87
+ Update the English fake Today Tip to demonstrate the desired behavior: small first step, no hard command, one dream-detail metaphor, and no Chinese terms.
88
+
89
+ - [x] **Step 5: Soften render copy**
90
+
91
+ Change default English safety copy to a warmer boundary sentence, without weakening crisis safety behavior.
92
+
93
+ - [x] **Step 6: Remove public backend jargon**
94
+
95
+ Change English and Chinese processing/runtime help copy so public users see product language, not model-route/fallback language.
96
+
97
+ - [x] **Step 7: Rename settings surface**
98
+
99
+ Change the visible `Runtime settings` accordion to `Advanced` while keeping advanced endpoint controls collapsed.
100
+
101
+ - [x] **Step 8: Run focused tests**
102
+
103
+ Run:
104
+
105
+ ```bash
106
+ .venv/bin/python -m pytest tests/test_ui_actions.py -q
107
+ .venv/bin/python scripts/evaluate_today_tip_quality.py
108
+ ```
109
+
110
+ Expected: focused tests pass.
111
+
112
+ ### Task 3: Align Docs and Smoke Evidence
113
+
114
+ **Files:**
115
+ - Modify: `README.md`
116
+ - Modify: `PRODUCT.md`
117
+ - Modify: `docs/spec.md`
118
+ - Modify: `docs/prd.md`
119
+ - Modify: `docs/handoff.md`
120
+ - Add: `docs/smoke/2026-06-09-user-tone-polish-smoke.md`
121
+ - Modify: this plan file checkbox state.
122
+
123
+ - [x] **Step 1: Update product docs**
124
+
125
+ Record that English mode should stay natural English, avoid mixed Chinese UI/model terms, and produce small optional actions rather than hard commands.
126
+
127
+ - [x] **Step 2: Run full verification**
128
+
129
+ Run:
130
+
131
+ ```bash
132
+ .venv/bin/python -m pytest -q
133
+ .venv/bin/python scripts/evaluate_today_tip_quality.py
134
+ git diff --check
135
+ ```
136
+
137
+ Expected: all commands pass.
138
+
139
+ - [x] **Step 3: Run local app config/action smoke**
140
+
141
+ Start the local app on port `7862`, check `/config`, and run one action-level English elevator/email flow plus one Chinese flow.
142
+
143
+ - [x] **Step 4: Record smoke evidence**
144
+
145
+ Write non-secret results to `docs/smoke/2026-06-09-user-tone-polish-smoke.md`.
146
+
147
+ - [ ] **Step 5: Commit and push**
148
+
149
+ Commit the plan, implementation, docs, and smoke evidence. Push `feature/dream-qa-user-tone-polish` to GitHub.
150
+
151
+ ### Task 4: Sync HF Space, Browser Merge, and User-View Review
152
+
153
+ **Files:**
154
+ - Modify: `docs/smoke/2026-06-09-user-tone-polish-smoke.md`
155
+
156
+ - [ ] **Step 1: Create HF Space PR**
157
+
158
+ Upload the current folder to `build-small-hackathon/dream-customs` with `create_pr=True`.
159
+
160
+ - [ ] **Step 2: Merge with browser**
161
+
162
+ Open the HF discussion PR in Chrome, verify it is ready to merge, and click Merge from the logged-in browser session.
163
+
164
+ - [ ] **Step 3: Restart and verify Space**
165
+
166
+ If the Space is paused, restart it. Verify runtime is `RUNNING` and public `/config` returns `title=Dream QA`.
167
+
168
+ - [ ] **Step 4: Experience as a user**
169
+
170
+ Use the public Space in the browser with the elevator/email dream. Check that English mode stays English, the question feels grounded, and the Today Tip is warm and actionable.
171
+
172
+ - [ ] **Step 5: Record final evidence**
173
+
174
+ Append HF PR number, merge SHA, runtime, public config, and user-view notes to the smoke document. Commit and push the final evidence.
175
+
176
+ ---
177
+
178
+ ## Self-Review
179
+
180
+ - Spec coverage: The plan covers the exact user feedback: English leakage, technical UI copy, hard Today Tip command, defensive safety wording, docs alignment, HF browser merge, and post-merge user-view review.
181
+ - Placeholder scan: No TBD/TODO/fill-later placeholders remain.
182
+ - Type consistency: Existing `TodayTipCard`, `submit_dream_action`, and `answer_to_card_action` APIs are reused without schema changes.
dream_customs/models.py CHANGED
@@ -99,8 +99,8 @@ class FakeTextClient:
99
  "Maybe this dream is not predicting lateness. It turns the feeling of being stuck before "
100
  "starting into an elevator paused at floor 14."
101
  ),
102
- today_tip="For today, press one very small elevator button: open the task, without asking yourself to arrive yet.",
103
- tiny_action="Spend five minutes writing which floor you want to stop at first today.",
104
  caring_note="You can move one floor at a time; the whole building does not need to be solved this morning.",
105
  )
106
  return TodayTipCard(
 
99
  "Maybe this dream is not predicting lateness. It turns the feeling of being stuck before "
100
  "starting into an elevator paused at floor 14."
101
  ),
102
+ today_tip="For today, press one very small elevator button: open the task and write only the first line.",
103
+ tiny_action="Set a five-minute timer, open the task, and stop after the first line.",
104
  caring_note="You can move one floor at a time; the whole building does not need to be solved this morning.",
105
  )
106
  return TodayTipCard(
dream_customs/pipeline.py CHANGED
@@ -117,6 +117,22 @@ _ZH_ANCHOR_MARKERS = [
117
  "楼层",
118
  ]
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  def _dedupe_preserve_order(items: List[str]) -> List[str]:
122
  seen = set()
@@ -171,15 +187,52 @@ def _extract_dream_anchors(intake: DreamIntake) -> List[str]:
171
  return _dedupe_preserve_order(candidates)[:5]
172
 
173
 
174
- def _primary_anchor(intake: DreamIntake, language: str = "en") -> str:
 
 
 
 
 
 
 
 
 
175
  anchors = _extract_dream_anchors(intake)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  if anchors:
177
  return anchors[0]
178
  return "梦里的那个细节" if _is_zh(language) else "that dream detail"
179
 
180
 
181
  def _secondary_anchor(intake: DreamIntake, language: str = "en") -> str:
182
- anchors = _extract_dream_anchors(intake)
183
  return anchors[1] if len(anchors) > 1 else _primary_anchor(intake, language)
184
 
185
 
@@ -227,10 +280,24 @@ def _fallback_interpretation(intake: DreamIntake, language: str = "en") -> str:
227
  def _grounded_today_tip(intake: DreamIntake, language: str = "en") -> str:
228
  primary = _primary_anchor(intake, language)
229
  if not _is_zh(language):
230
- return f"For today, borrow one action from the {primary}: open the smallest first step and stop there."
 
 
 
231
  return f"今天先从「{primary}」借一个动作:只做最小的第一步,不急着把整件事完成。"
232
 
233
 
 
 
 
 
 
 
 
 
 
 
 
234
  def _anchor_in_text(text: str, anchors: List[str]) -> bool:
235
  clean = (text or "").lower()
236
  for anchor in anchors:
@@ -483,7 +550,7 @@ def build_qa_state(
483
  answers: Optional[List[str]] = None,
484
  language: str = "en",
485
  ) -> DreamQAState:
486
- anchors = _extract_dream_anchors(intake)
487
  return DreamQAState(
488
  dream_summary=_summary_from_intake(intake, language),
489
  main_question=_main_question_from_intake(intake, language),
@@ -496,8 +563,12 @@ def build_qa_state(
496
 
497
  def _polish_today_tip(card: TodayTipCard, intake: DreamIntake, answers: str = "", language: str = "en") -> TodayTipCard:
498
  polished = card.model_copy(deep=True)
499
- intake_anchors = _extract_dream_anchors(intake)
500
- card_anchors = polished.dream_anchors
 
 
 
 
501
  if intake_anchors and not any(_text_uses_anchor(anchor, intake_anchors) for anchor in card_anchors):
502
  anchors = intake_anchors
503
  else:
@@ -518,7 +589,15 @@ def _polish_today_tip(card: TodayTipCard, intake: DreamIntake, answers: str = ""
518
  or not _anchor_in_text(polished.today_tip, anchors)
519
  ):
520
  polished.today_tip = _grounded_today_tip(intake, language)
521
- if not polished.tiny_action.strip():
 
 
 
 
 
 
 
 
522
  if _is_zh(language):
523
  polished.tiny_action = f"用 5 分钟写下:今天和「{anchors[0]}」有关的第一小步是什么?"
524
  else:
@@ -531,6 +610,8 @@ def _polish_today_tip(card: TodayTipCard, intake: DreamIntake, answers: str = ""
531
  )
532
  merged = "\n".join([intake.merged_text(), answers or ""])
533
  polished.safety_note = safety_note() if needs_escalation(merged) else ""
 
 
534
  return polished
535
 
536
 
 
117
  "楼层",
118
  ]
119
 
120
+ _ZH_TO_EN_PHRASES = {
121
+ "电梯按钮": "elevator button",
122
+ "融化的按钮": "melted button",
123
+ "按钮融化": "melted button",
124
+ "数字 14": "floor 14",
125
+ "数字14": "floor 14",
126
+ "楼层数字": "floor number",
127
+ "楼层": "floor",
128
+ "老楼": "old apartment building",
129
+ "蓝色楼道": "blue hallway",
130
+ "电梯": "elevator",
131
+ "按钮": "button",
132
+ "融化": "melted",
133
+ "梦境": "dream",
134
+ }
135
+
136
 
137
  def _dedupe_preserve_order(items: List[str]) -> List[str]:
138
  seen = set()
 
187
  return _dedupe_preserve_order(candidates)[:5]
188
 
189
 
190
+ def _english_anchor_text(text: str) -> str:
191
+ clean = text or ""
192
+ for source, target in sorted(_ZH_TO_EN_PHRASES.items(), key=lambda item: len(item[0]), reverse=True):
193
+ clean = clean.replace(source, target)
194
+ clean = re.sub(r"[\u4e00-\u9fff]+", "dream detail", clean)
195
+ clean = re.sub(r"\s+", " ", clean).strip(" .,:;!?\"'()[]{}")
196
+ return clean
197
+
198
+
199
+ def _anchors_for_language(intake: DreamIntake, language: str = "en") -> List[str]:
200
  anchors = _extract_dream_anchors(intake)
201
+ if _is_zh(language):
202
+ return anchors
203
+ localized = [_english_anchor_text(anchor) for anchor in anchors]
204
+ return _dedupe_preserve_order([anchor for anchor in localized if anchor])
205
+
206
+
207
+ def _clean_english_today_tip_language(card: TodayTipCard) -> TodayTipCard:
208
+ cleaned = card.model_copy(deep=True)
209
+ for field in (
210
+ "dream_summary",
211
+ "main_question",
212
+ "interpretation",
213
+ "today_tip",
214
+ "tiny_action",
215
+ "caring_note",
216
+ "safety_note",
217
+ ):
218
+ setattr(cleaned, field, _english_anchor_text(getattr(cleaned, field)))
219
+ cleaned.dream_anchors = _dedupe_preserve_order(
220
+ [_english_anchor_text(anchor) for anchor in cleaned.dream_anchors if anchor]
221
+ )
222
+ cleaned.followup_questions = [_english_anchor_text(question) for question in cleaned.followup_questions]
223
+ cleaned.user_answers = [_english_anchor_text(answer) for answer in cleaned.user_answers]
224
+ return cleaned
225
+
226
+
227
+ def _primary_anchor(intake: DreamIntake, language: str = "en") -> str:
228
+ anchors = _anchors_for_language(intake, language)
229
  if anchors:
230
  return anchors[0]
231
  return "梦里的那个细节" if _is_zh(language) else "that dream detail"
232
 
233
 
234
  def _secondary_anchor(intake: DreamIntake, language: str = "en") -> str:
235
+ anchors = _anchors_for_language(intake, language)
236
  return anchors[1] if len(anchors) > 1 else _primary_anchor(intake, language)
237
 
238
 
 
280
  def _grounded_today_tip(intake: DreamIntake, language: str = "en") -> str:
281
  primary = _primary_anchor(intake, language)
282
  if not _is_zh(language):
283
+ return (
284
+ f"For today, borrow one action from the {primary}: open the task, write only the first line, "
285
+ "and let that be enough for now."
286
+ )
287
  return f"今天先从「{primary}」借一个动作:只做最小的第一步,不急着把整件事完成。"
288
 
289
 
290
+ def _answer_based_tiny_action(answers: str, language: str = "en") -> str:
291
+ lowered = (answers or "").lower()
292
+ if _is_zh(language):
293
+ if "邮件" in lowered or "email" in lowered:
294
+ return "给自己 5 分钟,只打开那封邮件,写下第一句话;今天不要求立刻发出。"
295
+ return ""
296
+ if "email" in lowered or "message" in lowered:
297
+ return "Set a five-minute timer, open the email, and write only the first sentence. You do not have to send it yet."
298
+ return ""
299
+
300
+
301
  def _anchor_in_text(text: str, anchors: List[str]) -> bool:
302
  clean = (text or "").lower()
303
  for anchor in anchors:
 
550
  answers: Optional[List[str]] = None,
551
  language: str = "en",
552
  ) -> DreamQAState:
553
+ anchors = _anchors_for_language(intake, language)
554
  return DreamQAState(
555
  dream_summary=_summary_from_intake(intake, language),
556
  main_question=_main_question_from_intake(intake, language),
 
563
 
564
  def _polish_today_tip(card: TodayTipCard, intake: DreamIntake, answers: str = "", language: str = "en") -> TodayTipCard:
565
  polished = card.model_copy(deep=True)
566
+ intake_anchors = _anchors_for_language(intake, language)
567
+ card_anchors = (
568
+ polished.dream_anchors
569
+ if _is_zh(language)
570
+ else _dedupe_preserve_order([_english_anchor_text(anchor) for anchor in polished.dream_anchors])
571
+ )
572
  if intake_anchors and not any(_text_uses_anchor(anchor, intake_anchors) for anchor in card_anchors):
573
  anchors = intake_anchors
574
  else:
 
589
  or not _anchor_in_text(polished.today_tip, anchors)
590
  ):
591
  polished.today_tip = _grounded_today_tip(intake, language)
592
+ hard_action_markers = ["address it immediately", "fix it immediately", "solve it immediately"]
593
+ answer_action = _answer_based_tiny_action(answers, language)
594
+ if answer_action and (
595
+ not polished.tiny_action.strip()
596
+ or any(marker in polished.tiny_action.lower() for marker in hard_action_markers)
597
+ or "email" in (answers or "").lower()
598
+ ):
599
+ polished.tiny_action = answer_action
600
+ elif not polished.tiny_action.strip() or any(marker in polished.tiny_action.lower() for marker in hard_action_markers):
601
  if _is_zh(language):
602
  polished.tiny_action = f"用 5 分钟写下:今天和「{anchors[0]}」有关的第一小步是什么?"
603
  else:
 
610
  )
611
  merged = "\n".join([intake.merged_text(), answers or ""])
612
  polished.safety_note = safety_note() if needs_escalation(merged) else ""
613
+ if not _is_zh(language):
614
+ polished = _clean_english_today_tip_language(polished)
615
  return polished
616
 
617
 
dream_customs/prompts.py CHANGED
@@ -20,7 +20,8 @@ def visual_witness_prompt() -> str:
20
 
21
  def _language_instruction(language: str = "en") -> str:
22
  return (
23
- "Write all user-facing fields in English. Keep any user-provided dream anchors as written."
 
24
  if language != "zh"
25
  else "所有面向用户的字段都用自然中文书写。可以保留用户原文里的梦境关键词。"
26
  )
@@ -49,11 +50,13 @@ Return strict JSON with:
49
  def today_tip_prompt(state: DreamQAState, language: str = "en") -> str:
50
  return f"""
51
  You are MiniCPM5-1B writing the final Dream QA result.
52
- Write a non-diagnostic interpretation draft and exactly one primary 今日小 Tips.
53
  Use non-certain language such as "也许", "可以把它当作", "maybe", or "for today, try".
54
  The today_tip must cite at least one concrete dream anchor.
55
  Avoid prophecy, frightening certainty, medical advice, therapy framing, and generic wellness filler.
56
- Keep the tiny_action small enough to try today.
 
 
57
  Use safety_note only for self-harm, harm to others, severe distress, severe insomnia, panic, or inability to function.
58
  {_language_instruction(language)}
59
 
 
20
 
21
  def _language_instruction(language: str = "en") -> str:
22
  return (
23
+ "Write all user-facing fields in natural English. Translate or paraphrase non-English dream anchors "
24
+ "into natural English, except for a short exact quote that the user explicitly wrote and needs preserved."
25
  if language != "zh"
26
  else "所有面向用户的字段都用自然中文书写。可以保留用户原文里的梦境关键词。"
27
  )
 
50
  def today_tip_prompt(state: DreamQAState, language: str = "en") -> str:
51
  return f"""
52
  You are MiniCPM5-1B writing the final Dream QA result.
53
+ Write a non-diagnostic interpretation draft and exactly one primary Today Tip / 今日小 Tips.
54
  Use non-certain language such as "也许", "可以把它当作", "maybe", or "for today, try".
55
  The today_tip must cite at least one concrete dream anchor.
56
  Avoid prophecy, frightening certainty, medical advice, therapy framing, and generic wellness filler.
57
+ Keep the whole result short, warm, and specific to the user's answer.
58
+ The tiny_action must be a 5-minute first step, not a command to solve the whole problem.
59
+ Avoid demanding phrases such as "immediately", "must", "fix it", or "solve it".
60
  Use safety_note only for self-harm, harm to others, severe distress, severe insomnia, panic, or inability to function.
61
  {_language_instruction(language)}
62
 
dream_customs/render.py CHANGED
@@ -40,8 +40,8 @@ def render_today_tip_card(card: TodayTipCard, language: str = "en") -> str:
40
  "history": "追问记录" if is_zh else "Question record",
41
  "safety_default": "这不是诊断,只是一个温和的今日参考。"
42
  if is_zh
43
- else "This is not diagnosis, therapy, or prophecy; just a gentle reference for today.",
44
- "safety_prefix": "这不是诊断。" if is_zh else "This is not diagnosis. ",
45
  "highlight": "梦境细节" if is_zh else "dream detail",
46
  }
47
  tiny_action = (
 
40
  "history": "追问记录" if is_zh else "Question record",
41
  "safety_default": "这不是诊断,只是一个温和的今日参考。"
42
  if is_zh
43
+ else "A gentle reflection for today, not a diagnosis or prophecy.",
44
+ "safety_prefix": "这不是诊断。" if is_zh else "This is not a diagnosis. ",
45
  "highlight": "梦境细节" if is_zh else "dream detail",
46
  }
47
  tiny_action = (
dream_customs/ui/app.py CHANGED
@@ -469,7 +469,7 @@ def build_demo() -> gr.Blocks:
469
  mood_section_html = gr.HTML(_section_title_html(2, initial_copy["side_title"]))
470
  mood = gr.Dropdown(label=initial_copy["mood_label"], choices=MOOD_OPTIONS, value=DEFAULT_MOOD)
471
  side_stamp_html = gr.HTML(_side_stamp_html(DEFAULT_LANGUAGE))
472
- with gr.Accordion("Runtime settings", open=False, elem_classes=["dc-dev"]):
473
  dev_help_html = gr.HTML(_dev_help_html(DEFAULT_LANGUAGE))
474
  text_backend = gr.Dropdown(
475
  label="Text generation",
 
469
  mood_section_html = gr.HTML(_section_title_html(2, initial_copy["side_title"]))
470
  mood = gr.Dropdown(label=initial_copy["mood_label"], choices=MOOD_OPTIONS, value=DEFAULT_MOOD)
471
  side_stamp_html = gr.HTML(_side_stamp_html(DEFAULT_LANGUAGE))
472
+ with gr.Accordion("Advanced", open=False, elem_classes=["dc-dev"]):
473
  dev_help_html = gr.HTML(_dev_help_html(DEFAULT_LANGUAGE))
474
  text_backend = gr.Dropdown(
475
  label="Text generation",
dream_customs/ui/copy.py CHANGED
@@ -27,8 +27,7 @@ APP_COPY = {
27
  "example_button": "Try example",
28
  "submit_button": "Continue",
29
  "processing_note": (
30
- "After submission, Dream QA asks one grounded question before generating a Today Tip. "
31
- "Model routes may take a few seconds; the text-only demo fallback always works."
32
  ),
33
  "image_accordion": "Add image clue",
34
  "image_label": "Upload a sketch, note, or screenshot",
@@ -52,7 +51,7 @@ APP_COPY = {
52
  "side_stamp_title": "Add one concrete detail",
53
  "side_stamp_body": "It helps the final suggestion stay grounded in your dream.",
54
  "language_label": "Language",
55
- "runtime_help": "The automatic route uses the Space configuration. If no endpoint is available, it safely falls back to demo data.",
56
  "card_title": "Today Tip",
57
  "error_state": "The interface state could not be read. Please start over.",
58
  },
@@ -77,8 +76,7 @@ APP_COPY = {
77
  "example_button": "试试示例",
78
  "submit_button": "继续解梦 →",
79
  "processing_note": (
80
- "提交后,梦境助手会先追问关键细节,再成今日小 Tips。"
81
- "模型路线可能需要几秒;text-only demo fallback 始终可用。"
82
  ),
83
  "image_accordion": "添加图片线索",
84
  "image_label": "上传草图、便签或截图",
@@ -102,7 +100,7 @@ APP_COPY = {
102
  "side_stamp_title": "尽量回忆更多细节",
103
  "side_stamp_body": "有助于更准确地理解梦境。",
104
  "language_label": "语言",
105
- "runtime_help": "自动模式会使用 Space 配置的后端;没有端点时会安全回退到 demo 数据。",
106
  "card_title": "今日小 Tips",
107
  "error_state": "界面状态读取失败,请重新开始。",
108
  },
 
27
  "example_button": "Try example",
28
  "submit_button": "Continue",
29
  "processing_note": (
30
+ "After submission, Dream QA asks one grounded question, then turns the dream into a small Today Tip."
 
31
  ),
32
  "image_accordion": "Add image clue",
33
  "image_label": "Upload a sketch, note, or screenshot",
 
51
  "side_stamp_title": "Add one concrete detail",
52
  "side_stamp_body": "It helps the final suggestion stay grounded in your dream.",
53
  "language_label": "Language",
54
+ "runtime_help": "Advanced controls for demos and development. Most visitors can leave these unchanged.",
55
  "card_title": "Today Tip",
56
  "error_state": "The interface state could not be read. Please start over.",
57
  },
 
76
  "example_button": "试试示例",
77
  "submit_button": "继续解梦 →",
78
  "processing_note": (
79
+ "提交后,梦境助手会先追问一个关键细节,再把梦境整理一个今日小 Tips。"
 
80
  ),
81
  "image_accordion": "添加图片线索",
82
  "image_label": "上传草图、便签或截图",
 
100
  "side_stamp_title": "尽量回忆更多细节",
101
  "side_stamp_body": "有助于更准确地理解梦境。",
102
  "language_label": "语言",
103
+ "runtime_help": "高级演示与开发控制普通体验保持默认即可。",
104
  "card_title": "今日小 Tips",
105
  "error_state": "界面状态读取失败,请重新开始。",
106
  },
scripts/evaluate_today_tip_quality.py CHANGED
@@ -14,6 +14,8 @@ FIXTURE_PATH = Path("tests/fixtures/today_tip_eval_cases.json")
14
  OLD_CUSTOMS_TERMS = ["permit", "contraband", "clearance", "sealed", "pact"]
15
  FRIGHTENING_TERMS = ["you will fail", "prophecy says", "fate says", "must mean", "mental illness"]
16
  CHINESE_UI_LABELS = ["今日小", "梦境摘要", "想理解的问题", "解读草稿", "没试过的小事", "关心一句"]
 
 
17
 
18
 
19
  def _load_cases(path: Path = FIXTURE_PATH) -> List[Dict[str, Any]]:
@@ -70,6 +72,12 @@ def evaluate_case(case: Dict[str, Any]) -> List[str]:
70
  chinese_labels = [label for label in CHINESE_UI_LABELS if label in combined]
71
  if chinese_labels:
72
  failures.append("chinese_ui_labels:" + ",".join(chinese_labels))
 
 
 
 
 
 
73
 
74
  if case.get("requires_safety_note") and "trusted person or professional support" not in lowered:
75
  failures.append("missing_support_note")
 
14
  OLD_CUSTOMS_TERMS = ["permit", "contraband", "clearance", "sealed", "pact"]
15
  FRIGHTENING_TERMS = ["you will fail", "prophecy says", "fate says", "must mean", "mental illness"]
16
  CHINESE_UI_LABELS = ["今日小", "梦境摘要", "想理解的问题", "解读草稿", "没试过的小事", "关心一句"]
17
+ CHINESE_LEAKAGE_TERMS = ["数字", "电梯", "按钮", "楼层", "融化", "梦境"]
18
+ HARD_COMMAND_PHRASES = ["address it immediately", "fix it immediately", "solve it immediately"]
19
 
20
 
21
  def _load_cases(path: Path = FIXTURE_PATH) -> List[Dict[str, Any]]:
 
72
  chinese_labels = [label for label in CHINESE_UI_LABELS if label in combined]
73
  if chinese_labels:
74
  failures.append("chinese_ui_labels:" + ",".join(chinese_labels))
75
+ chinese_terms = [term for term in CHINESE_LEAKAGE_TERMS if term in combined]
76
+ if chinese_terms:
77
+ failures.append("chinese_anchor_leakage:" + ",".join(chinese_terms))
78
+ hard_commands = [phrase for phrase in HARD_COMMAND_PHRASES if phrase in lowered]
79
+ if hard_commands:
80
+ failures.append("hard_command:" + ",".join(hard_commands))
81
 
82
  if case.get("requires_safety_note") and "trusted person or professional support" not in lowered:
83
  failures.append("missing_support_note")
tests/fixtures/today_tip_eval_cases.json CHANGED
@@ -6,6 +6,13 @@
6
  "answer": "It felt like being late before I had even started.",
7
  "required_anchors": ["elevator", "button", "14"]
8
  },
 
 
 
 
 
 
 
9
  {
10
  "id": "exam_without_pencil",
11
  "dream_text": "I walked into an exam room and realized every pencil had turned into a glass straw.",
 
6
  "answer": "It felt like being late before I had even started.",
7
  "required_anchors": ["elevator", "button", "14"]
8
  },
9
+ {
10
+ "id": "elevator_email_first_sentence",
11
+ "dream_text": "I dreamed I was in an elevator where the floor buttons melted like wax. The number 14 kept blinking, and I felt late but strangely calm.",
12
+ "mood": "Uneasy",
13
+ "answer": "I want to make starting my overdue email easier without feeling trapped by it.",
14
+ "required_anchors": ["elevator", "button", "14"]
15
+ },
16
  {
17
  "id": "exam_without_pencil",
18
  "dream_text": "I walked into an exam room and realized every pencil had turned into a glass straw.",
tests/test_today_tip_quality_eval.py CHANGED
@@ -4,7 +4,7 @@ from scripts.evaluate_today_tip_quality import _load_cases, evaluate_case, evalu
4
  def test_today_tip_quality_eval_passes_fixture_cases():
5
  result = evaluate_cases(_load_cases())
6
 
7
- assert result["case_count"] == 10
8
  assert result["failures"] == {}
9
  assert result["passes"] is True
10
 
 
4
  def test_today_tip_quality_eval_passes_fixture_cases():
5
  result = evaluate_cases(_load_cases())
6
 
7
+ assert result["case_count"] == 11
8
  assert result["failures"] == {}
9
  assert result["passes"] is True
10
 
tests/test_ui_actions.py CHANGED
@@ -19,7 +19,7 @@ def test_mobile_defaults_to_model_backends():
19
  def test_runtime_settings_are_collapsed_for_public_flow():
20
  source = inspect.getsource(ui_app.build_demo)
21
 
22
- assert 'gr.Accordion("Runtime settings", open=False' in source
23
 
24
 
25
  def test_processing_note_is_story_copy_not_backend_jargon():
@@ -27,8 +27,8 @@ def test_processing_note_is_story_copy_not_backend_jargon():
27
 
28
  assert "grounded question" in lowered
29
  assert "today tip" in lowered
30
- assert "model routes" in lowered
31
- assert "fallback" in lowered
32
  assert "token" not in lowered
33
  assert "endpoint" not in lowered
34
  assert "debug" not in lowered
@@ -131,3 +131,29 @@ def test_mobile_mvp_answer_to_card_generates_today_tip():
131
  assert view["status"] == "tip"
132
  assert view["phase"] == "tip"
133
  assert "It may be asking me to slow down." in view["debug"]["session"]["answer_history"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def test_runtime_settings_are_collapsed_for_public_flow():
20
  source = inspect.getsource(ui_app.build_demo)
21
 
22
+ assert 'gr.Accordion("Advanced", open=False' in source
23
 
24
 
25
  def test_processing_note_is_story_copy_not_backend_jargon():
 
27
 
28
  assert "grounded question" in lowered
29
  assert "today tip" in lowered
30
+ assert "model routes" not in lowered
31
+ assert "fallback" not in lowered
32
  assert "token" not in lowered
33
  assert "endpoint" not in lowered
34
  assert "debug" not in lowered
 
131
  assert view["status"] == "tip"
132
  assert view["phase"] == "tip"
133
  assert "It may be asking me to slow down." in view["debug"]["session"]["answer_history"]
134
+
135
+
136
+ def test_english_today_tip_has_no_chinese_anchor_leakage():
137
+ state, _view_json = submit_dream_action(
138
+ dream_text=(
139
+ "I dreamed I was in an elevator where the floor buttons melted like wax. "
140
+ "The number 14 kept blinking, and I felt late but strangely calm."
141
+ ),
142
+ mood="Uneasy",
143
+ text_backend="demo",
144
+ vision_backend="demo",
145
+ language="en",
146
+ )
147
+
148
+ _state, view_json = answer_to_card_action(
149
+ state,
150
+ "I want to make starting my overdue email easier without feeling trapped by it.",
151
+ text_backend="demo",
152
+ vision_backend="demo",
153
+ language="en",
154
+ )
155
+ view = json.loads(view_json)
156
+ combined = "\n".join([view["card_text"], view["card_html"]])
157
+
158
+ for leaked in ["数字", "电梯", "按钮", "楼层", "融化"]:
159
+ assert leaked not in combined