## 2026-10-08T07:43:55Z
You are teamwork_preview_worker (M4 Web Review Studio Sync & Production Integration Worker).
Your working directory is: c:\Projects\KieuStory\.agents\teamwork\worker_m4_1

You MUST read:
- c:\Projects\KieuStory\.agents\teamwork\ORIGINAL_REQUEST.md
- c:\Projects\KieuStory\PROJECT.md
- c:\Projects\KieuStory\.agents\teamwork\explorer_m4_1\handoff.md (and proposed_server_production.py, test_proposed_server.py)
- c:\Projects\KieuStory\.agents\teamwork\explorer_m4_2\handoff.md
- c:\Projects\KieuStory\.agents\teamwork\explorer_m4_3\handoff.md (and analysis.md, proposed_frontend_enhancements.js)
before starting work.

Files owned exclusively by you:
- c:\Projects\KieuStory\web_review\server.py
- c:\Projects\KieuStory\web_review\templates\index.html
- c:\Projects\KieuStory\05_Production_Pipeline\run_shot.py
- c:\Projects\KieuStory\PROJECT.md

MANDATORY INTEGRITY WARNING:
DO NOT CHEAT. All implementations must be genuine. DO NOT hardcode test results, create dummy/facade implementations, or circumvent the intended task. A teamwork_preview_auditor will independently verify your work. Integrity violations WILL be detected and your work WILL be rejected.

Your implementation tasks:
1. Upgrade `web_review/server.py`:
   - Incorporate the fully tested implementation from `c:\Projects\KieuStory\.agents\teamwork\explorer_m4_1\proposed_server_production.py`:
     * Expose `DEFAULT_PORT = 1515`, `DEFAULT_HOST = "0.0.0.0"`.
     * Define `ConcatRequest(scene_id: str, output_path: Optional[str] = None, crossfade_dur: Optional[float] = 1.0)`.
     * Define `GenerateRequest(prompt: Optional[str] = None, shot_id: Optional[str] = None, scene_id: Optional[str] = None, title: Optional[str] = None, input_frame: Optional[str] = None, force: bool = False, session_name: str = "muse")` with root validator enforcing either `prompt` or `shot_id`.
     * Implement `@app.post("/api/concat")`: trigger scene concatenation via `production_orchestrator.concat_scene_shots` in a background thread, updating `gen_state["status"] = "concatenating"`. Guard with 409 Conflict if already generating or concatenating.
     * Implement / modernize `@app.post("/api/generate")`: trigger background shot generation via `production_orchestrator.render_single_shot` or `run_shot.py` when `shot_id` is supplied, updating `gen_state`. Guard with 409 Conflict if busy.
     * Update `/api/shots` and `/api/scenes` to accept optional `?episode=` and `?scene=` query parameters and serve the complete 188 EP01 shots catalog from `muse_ai_video_prompts.json` and Banana prompts.
     * Update `build_library_data()` to index scene masters from both `04_Assets/videos/` and `06_Exports/` (including `<scene_id>_master_v<N>.mp4` and `grand_master`).
     * Ensure Windows encoding safety in `log_msg()` (safe UTF-8 or charmap fallback).
2. Upgrade `05_Production_Pipeline/run_shot.py`:
   - In `argparse`, add `--shot` as alias for `--shot-id`:
     `parser.add_argument("--shot", "--shot-id", dest="shot_id", required=True)`
   - Make `--prompt` optional (`default=None`). If omitted, auto-resolve prompt from `02_AI_Prompts/muse_ai_video_prompts.json`.
   - Make `--input-frame` optional (`default=None`). If omitted, auto-resolve start frame from `production_orchestrator.resolve_start_frame`.
3. Upgrade `web_review/templates/index.html`:
   - Incorporate the UI enhancements formulated by `explorer_m4_3` (`proposed_frontend_enhancements.js` and `handoff.md`):
     * Add / enhance navigation for EP01 188 Shots Matrix (grouped into the 15 scenes C01–C15).
     * Display rendered status badges (`✓ Đã Render`, `⏳ Chưa Render`).
     * Add Shot Detail Modal displaying:
       - Sweet-Spot 720p Start Frame Prompt (`gemini_banana_prompts.json`) with character and environment anchors.
       - Muse.ai Video Motion Prompt with highlighted Audio Guard callout.
       - Lip-Sync Closed Lips Guard badge (`🔒 Khóa khẩu hình`) where applicable.
       - "🚀 Render Shot" button (triggering `POST /api/generate` with `shot_id`).
       - Version indicator / selector (`v1`, `v2`, `Re-take`).
     * In scene cards / accordion headers: add "🎬 Ghép Master Cảnh" button triggering `POST /api/concat`.
     * Update `pollStatus()` to handle and style `concatenating` status.
4. Update `c:\Projects\KieuStory\PROJECT.md`:
   - Update Milestones table:
     * Line 49: Milestone 3 Status -> `DONE`
     * Line 50: Milestone 4 Status -> `IN_PROGRESS`
5. Run Verification:
   - Run `python tests/run_all_tests.py` and confirm all 155 tests pass (100.0%).
   - Run `pytest tests/ -q` and confirm all 167 tests pass.
   - Run `python 05_Production_Pipeline/run_shot.py --help` to confirm `--shot` argument works.
6. Document all changes, test commands, and layout compliance in `handoff.md` following the 5-component protocol, and send a message back.


## 2026-10-08T08:00:44Z
**Context**: Milestone 4 Implementation
**Content**: Heartbeat status check on your progress regarding `server.py`, `run_shot.py`, `index.html`, and `PROJECT.md`.
**Action**: Please provide a brief status update or update your `progress.md` with current milestone steps completed.
