File size: 11,684 Bytes
5862322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# Hackathon Rescue Implementation Plan

Date: 2026-06-15

## Goal

Turn the current Trans-Temporal Express prototype into one judge-ready endpoint:

1. A polished intro.
2. A clean first-person engine control.
3. Real generated destination and character imagery.
4. Real launch, travel, arrival, and ambient audio.
5. A final conversation scene where the world and character are the center of the UI.

This plan supersedes the prior split `/blank` intro plus `/app` cockpit flow for the hackathon demo.

## Product Decisions

- Use one endpoint for the whole experience. Prefer `/app/` as the canonical app and redirect `/`, `/blank`, and `/blank/` to it.
- Keep Gradio for backend wiring, but hide the default controls from the user-facing experience.
- The user should interact with the train cab, not with form fields.
- Do not silently demo fixture SVG images. If real image generation is unavailable, show a clear developer warning.
- Audio is part of the core experience, not a later nice-to-have.

## Target User Flow

1. User lands on `/app/`.
2. Full-screen ticket/train intro plays for 10-14 seconds, with skip available.
3. Intro dissolves into the train cab.
4. A highlighted physical control prompts the user to choose Past or Future.
5. The user chooses Past or Future using in-cockpit controls.
6. The throttle illuminates and prompts the user to launch.
7. User pulls/clicks the throttle.
8. The app starts the backend launch through hidden Gradio components.
9. Travel animation masks model latency: engine vibration, era signs, year counter, temporal tunnel, SFX.
10. When image generation completes, braking and steam reveal play.
11. Destination fills the windshield.
12. Character is centered or near-centered in the destination scene.
13. Chrome fades back; live voice becomes the primary action.

## Phase 0: Asset And License Gate

Goal: import only safe, demo-appropriate assets from the internet.

Rules:

- Prefer Pixabay and Mixkit for sound effects and ambient loops because their license pages allow free use and modification without attribution, subject to prohibited-use restrictions.
- Use Freesound only for CC0 or CC BY assets. Do not use CC BY-NC or Sampling+ assets.
- Record every imported file in `static/audio/ASSET_LICENSES.md` or `static/assets_licenses.md`.
- Store source URL, creator, license, download date, original filename, local filename, and any edits.
- Avoid recognizable brands, trademarked content, celebrity/person likenesses, copyrighted train IP, or commercial movie/game sounds.

Initial asset list:

- `static/audio/sfx/lever_pull.mp3`
- `static/audio/sfx/button_click.mp3`
- `static/audio/sfx/ticket_clang.mp3`
- `static/audio/sfx/charge_up.mp3`
- `static/audio/sfx/gears_grinding.mp3`
- `static/audio/sfx/train_whistle.mp3`
- `static/audio/sfx/materialize.mp3`
- `static/audio/sfx/time_warp.mp3`
- `static/audio/sfx/brake_screech.mp3`
- `static/audio/sfx/steam_burst.mp3`
- `static/audio/sfx/chime.mp3`
- `static/audio/ambient/temporal_storm.mp3`
- `static/audio/ambient/rain.mp3`
- `static/audio/ambient/marketplace.mp3`
- `static/audio/ambient/ocean.mp3`
- `static/audio/ambient/machinery.mp3`
- `static/audio/ambient/wind.mp3`

Implementation tasks:

- Search and download candidates from approved sources.
- Normalize audio to small MP3/OGG files suitable for web playback.
- Trim long files into short loops where needed.
- Add a manifest mapping app keys to files.
- Add automated existence checks for required demo audio files.

Validation:

- All imported assets have a license entry.
- No NC assets are used.
- App still runs if an optional audio file is missing.

## Phase 1: One Endpoint

Files:

- `app.py`
- `src/time_machine/ui/gradio_app.py`
- `src/time_machine/ui/blank_app.py`
- `src/time_machine/ui/assets/intro.*`
- `src/time_machine/ui/assets/cockpit.*`

Tasks:

- Mount only the main app for the demo path.
- Redirect `/`, `/blank`, and `/blank/` to `/app/`.
- Move intro HTML/CSS/JS into the main app as an overlay.
- Remove the separate intro Gradio app from the happy path.
- Keep the intro skippable.
- Add a local flag such as `?skip_intro=1` for repeated development testing.

Validation:

- `http://localhost:7865/` lands in the full experience.
- `http://localhost:7865/app/` runs intro then cockpit.
- `http://localhost:7865/blank/` does not expose a half-finished alternate product.

## Phase 2: Real Image Generation Contract

Files:

- `src/time_machine/application/container.py`
- `src/time_machine/adapters/image_gen/together.py`
- `src/time_machine/ui/view_models.py`
- `config/app.yaml`
- `config/models.yaml`

Tasks:

- Add explicit image generation readiness to startup/runtime state.
- In `modal` and `dev` demo profiles, require `TIME_MACHINE_IMAGE_API_KEY` or `TOGETHER_API_KEY`.
- Stop silently falling back to fixture SVG portraits for the hackathon profile.
- Keep fixture fallback only for tests and local no-network development.
- Add a UI developer warning if image generation is disabled.
- Improve prompts so the world scene has a clear empty/usable foreground area for the character.
- Improve portrait prompts so character output matches warm animated-film style and avoids crude flat avatar output.
- Cache generated images by encounter id to avoid flicker and repeated API calls.

Validation:

- With image API key: world and portrait are PNGs, not fixture SVGs.
- Without image API key in demo profile: app clearly reports missing image config.
- Fixture tests still pass.

## Phase 3: Replace Form Controls With Engine Controls

Files:

- `src/time_machine/ui/assets/cockpit.html`
- `src/time_machine/ui/assets/cockpit.css`
- `src/time_machine/ui/assets/cockpit.js`
- `src/time_machine/ui/gradio_app.py`

Tasks:

- Hide the visible Gradio dropdown, coordinate textarea, launch button, souvenir button, save button, markdown readouts, microphone controls, and audio widgets from the first-screen UI.
- Keep their `elem_id`s and backend wiring intact.
- Add custom in-cockpit controls:
  - Past button or switch.
  - Future button or switch.
  - Throttle lever as the launch action.
  - Optional surprise route as a small randomizer/lighted ticket slot.
- On Past/Future selection, set the hidden Gradio route dropdown.
- On throttle click, trigger the hidden Gradio launch button.
- Add guided highlight states:
  - After intro: highlight Past/Future selector.
  - After selection: highlight throttle.
  - During launch: disable controls and show engine state.
  - After arrival: fade controls and focus voice.

Validation:

- User can complete launch without seeing or using Gradio form controls.
- Keyboard and screen-reader users can still trigger the custom controls.
- Hidden Gradio components continue to receive the expected values.

## Phase 4: Cinematic Layout Rescue

Files:

- `src/time_machine/ui/assets/cockpit.css`
- `src/time_machine/ui/assets/cockpit.js`
- `src/time_machine/ui/assets/cockpit.html`

Tasks:

- Make the windshield/world area the dominant visual region.
- Center the generated character in the scene after arrival.
- Remove or collapse UI chrome that competes with the final world:
  - Route card fades to a small top-left plate.
  - Year module shrinks after reveal.
  - Narration becomes a temporary subtitle, then clears.
  - Throttle and dashboard dim once conversation is ready.
  - Comm screen becomes the live voice affordance, not a competing panel.
- Avoid blocking the character with narration text.
- Replace current portrait crop behavior with a full-body or bust overlay treatment that feels intentionally staged.
- Add final state class `.tm-state-conversation-ready` layout rules that prioritize scene/character.

Validation:

- In `conversation_ready`, the screenshot reads as "I am looking at a person in another world."
- Character is not hidden behind controls or placed as a side widget.
- Mobile view does not overlap controls, subtitles, and character.

## Phase 5: Audio System

Files:

- `src/time_machine/ui/assets/cockpit.js`
- `src/time_machine/ui/assets/intro.js`
- `src/time_machine/ui/assets/cockpit.html`
- `src/time_machine/ui/assets/intro.html`
- `static/audio/**`
- `static/asset_manifest.json`

Tasks:

- Add a shared `AudioManager`.
- Preload known SFX with graceful missing-file handling.
- Unlock Web Audio after first user interaction.
- Play intro SFX:
  - ticket appears
  - conductor punch
  - charge-up
  - materialization
  - train whistle
- Play cockpit SFX:
  - button click
  - lever pull
  - charge-up
  - time warp
  - brake screech
  - steam burst
  - arrival chime
- Add ambient loops:
  - temporal storm during travel
  - destination ambience based on `ambient_key`
- Add ducking:
  - ambient lower under narration
  - ambient lower under character speech
  - restore after speech
- Keep procedural tones only as fallback.

Validation:

- User hears distinct launch, travel, braking, arrival, and world ambience.
- Missing audio does not break the page.
- Browser autoplay restrictions are handled through user interaction.

## Phase 6: Intro Polish

Files:

- `src/time_machine/ui/assets/intro.html`
- `src/time_machine/ui/assets/intro.css`
- `src/time_machine/ui/assets/intro.js`

Tasks:

- Keep ticket/conductor/train beats, but shorten the total runtime.
- Avoid dark empty time at the beginning.
- Add tighter animation timing and audio hits.
- End with a direct dissolve into the cockpit, not a route navigation.
- Show skip affordance after 1 second.

Validation:

- Intro feels intentional in 10-14 seconds.
- Skip works immediately after it appears.
- Transition into cockpit feels continuous.

## Phase 7: Tests And Demo Verification

Tasks:

- Unit tests:
  - payload contains image readiness flags.
  - missing image API warning path.
  - hidden Gradio launch wiring is unchanged.
- Browser verification:
  - intro first frame
  - cockpit ready
  - Past selected
  - travel animation
  - braking/steam
  - final world/character
- Manual audio check:
  - SFX fire at expected moments.
  - ambience loops and ducks.
- Demo script:
  - Past launch path.
  - Future launch path.
  - Live voice handoff.

## Risk Register

- Real image generation latency may be longer than the intro/travel animation.
  - Mitigation: keep travel loop alive until scene and portrait are ready.
- Browser autoplay restrictions can block audio.
  - Mitigation: first user click after intro unlocks audio; intro skip and controls call `audioManager.unlock()`.
- Downloaded audio licenses can be ambiguous.
  - Mitigation: use only clear license pages and keep a ledger.
- Gradio DOM changes can break hidden-control automation.
  - Mitigation: target stable `elem_id`s and add smoke tests.
- Network/image API failure could ruin demo.
  - Mitigation: pre-generate and cache demo encounter images before judging where possible.

## Suggested Implementation Order

1. One endpoint and intro overlay.
2. Hide Gradio controls and build engine controls.
3. Final-state layout rescue.
4. Real image generation hard gate and prompt improvements.
5. Audio asset import and `AudioManager`.
6. Intro timing/audio polish.
7. Browser screenshots and demo rehearsal.

## External License References

- Pixabay Content License Summary: https://pixabay.com/service/license-summary/
- Mixkit License: https://mixkit.co/license/
- Freesound FAQ Licenses: https://freesound.org/help/faq/#licenses-0