Repository navigation
feat: add Shorts auto-montage overlays, auto-themed stickers, and AI … - #2
Conversation
…map auto-coloring
deltaaa00
left a comment
There was a problem hiding this comment.
@bibed234 Please address the following issues before merging. The new Color Filling Studio exposes features that are not connected to the backend.
-
[P1] Repainting calls an endpoint that does not exist.
restyleCurrentMapFromStudio()sends POST /api/restyle_map, but main.py does not register this route. Reproduced with Flask's test client: the request returns 404. Please implement repainting from the current map_values, applying the selected rules and returning image_url without another AI request.
Location: templates/index.html:1788–1804. -
[P1] Uploaded-map inspection never processes the uploaded image.
The UI sends image_data and reports that it is inspecting the image, but api_analyze_map() never reads that field. It returns cached values or hardcoded sample_values instead. Even image_data="data:image/png;base64,invalid" returns 200 success, source=topic_preview, and preset values such as Germany=84 and France=68. Please implement actual image inspection and validation, or return an explicit unsupported/error response instead of presenting sample data as the inspection result.
Locations: templates/index.html:1756–1778, main.py:297–343, especially hardcoded samples:319–334. -
[P1] Generation ignores the editor's color and label settings.
The form includes filling_txt, filling_num, label_style, auto_style, and palette_theme, but generate() does not pass these settings to auto_map(). The renderer continues reading rules from the local filling.json; automatic colors are only used when the corresponding rule dictionary is empty. Label colors and stroke width remain hardcoded. Please apply the request-specific settings, honor auto_style and palette_theme, and ensure the returned analysis describes the rules actually used to render the PNG.
Locations: templates/index.html:1257–1275, main.py:255–266, map/auto_map.py:245–251, hardcoded label style:393–395 and 419–421. -
[P1] Analysis ignores prefer_cached=false and falls back to shared data from a previous request.
The upload flow explicitly sends prefer_cached=false, but the server unconditionally falls back to LAST_GENERATED_MAP_STATE when map_values is absent. Reproduced by seeding a previous ai_answer and requesting analysis with a different topic and prefer_cached=false: the response contains the previous values. This global state is also shared by users in the same process and can mix their map data; separate server processes will have inconsistent state. Please honor the flag and scope the data to a specific map/session, or require explicit map_values.
Locations: templates/index.html:1770, main.py:303–307, map/auto_map.py:253–258.
Validation: GitHub Actions passed for this commit, and all 92 local tests in tests/test_web.py and tests/test_auto_map.py passed. Those tests do not cover the failing scenarios above. Please add coverage for working repainting, actual image inspection/invalid-image rejection, manual settings affecting the generated output, and isolation of data between different maps/users.
deltaaa00
left a comment
There was a problem hiding this comment.
@bibed234 Re-reviewed commit 54e41c1, considering the current single-user local deployment. The repaint route, request-specific rendering options, and removal of shared map state address the corresponding earlier concerns. The following issues remain.
All findings below are P2 and concern current behavior, not hypothetical multi-user hosting.
-
Numeric Auto-Style uses the UI defaults instead of the calculated palette. The UI sends four default intervals, but _DEFAULT_UI_NUM_BOUNDS contains only two. The condition at map/auto_map.py:440 therefore treats the untouched UI defaults as custom rules. Reproduced with values 1, 50, 99, auto_style=true, palette_theme=auto, and the exact four default UI intervals: the automatic calculation produces three buckets, but rendering uses only (0,100) with #38bdf8. Please align the defaults or explicitly distinguish untouched defaults from manual rules, and test the actual getFormState payload.
Locations: backend condition, UI defaults. -
Four selectable palette names are unsupported by the backend. The menu sends heatmap, emerald_gold, oceanic, and categorical; none exists in _PALETTE_THEMES. _resolve_theme_name silently falls back to topic/mode-based selection. Reproduced by posting each name with numeric map_values to /api/analyze_map: all four resolve to viridis. Please implement/map the menu names consistently or remove unsupported choices; test every selectable value.
Locations: menu, resolver. -
Image inspection still does not recover the map's numbers/words and can replace labels with HEX codes. The new implementation validates images and samples actual pixels, which fixes the fake-image success case. However, it assigns each region a hex_label as its map_value and always reports text mode. The upload UI stores these as lastMapValues, and repaint sends them as ai_answer_override, so the renderer draws strings such as #14b45a instead of the uploaded map's original labels. With number mode selected, these strings also fail numeric parsing. Please either implement actual value extraction or explicitly scope the feature to palette extraction, keeping sampled colors separate from semantic map_values and preventing an unsupported repaint. Do not report numbers/words as inspected when only colors are sampled.
Locations: HEX values assigned, upload result replaces lastMapValues, repaint payload. -
The new override test fails before verifying the rendering behavior. Mock(wraps=ImageDraw.ImageDraw.text) replaces a class method without preserving instance binding; the wrapped function receives no self, causing TypeError: ImageDraw.text() missing 1 required positional argument: 'text'. Reproduced locally, and the same failure is present in Actions. Please use a correctly bound wrapper/spy that invokes the original method with self and retains the assertions.
Location: tests/test_auto_map.py:192–193.
Validation:
- Local tests/test_web.py + tests/test_auto_map.py: 97 passed, 1 failed.
- Three additional isolated reproduction checks confirmed the palette/default-range/image-value behaviors above.
- GitHub Actions run: 324 passed, 1 failed; coverage 87.99%, below the existing 90% requirement. Please restore both passing tests and the coverage threshold before merging. Real Gemini/YouTube requests were not exercised.
| filling_txt = merged_txt | ||
| filling_txt_ci = {str(k).strip().lower(): v for k, v in filling_txt.items()} | ||
| elif mode == "number": | ||
| if req_num and set(req_num.keys()) != _DEFAULT_UI_NUM_BOUNDS and not theme_requested: |
There was a problem hiding this comment.
[P2] The untouched frontend defaults contain four intervals, while _DEFAULT_UI_NUM_BOUNDS contains only two. With auto_style=true and palette_theme=auto, this condition therefore treats default UI rules as custom and overrides the calculated palette. Reproduced with values 1, 50, 99: all use #38bdf8 in (0,100), although _auto_fill_from_ai calculates three buckets. Please align the defaults or explicitly track whether rules were edited.
|
|
||
| def _resolve_theme_name(palette_theme: str = "auto", prompt: str = "", mode: str = "text") -> str: | ||
| theme = (palette_theme or "auto").strip().lower() | ||
| if theme in _PALETTE_THEMES and theme != "auto": |
There was a problem hiding this comment.
[P2] The palette menu sends heatmap, emerald_gold, oceanic, and categorical, but none of these keys is supported here. Each silently falls back to topic/mode selection (all four resolve to viridis for a numeric example). Please align the selectable names with supported backend palettes and cover every menu option.
| matched = avg | ||
|
|
||
| hex_label = f"#{matched[0]:02x}{matched[1]:02x}{matched[2]:02x}" | ||
| region_values[name] = hex_label |
There was a problem hiding this comment.
[P2] This stores sampled color codes as semantic map_values. The upload UI assigns them to lastMapValues and repaint later passes them into auto_map as label values. Thus repaint writes #rrggbb labels instead of the original numbers/words; in number mode these values fail numeric parsing. Please keep extracted palette colors separate from region labels, or implement label extraction and reject unsupported repaint scenarios.
| def test_auto_map_applies_request_color_and_label_overrides(scene, monkeypatch): | ||
| answer, _, real_open = scene | ||
| answer.return_value = {'one': 'CustomLabel', 'two': 'OtherLabel', 'three': ''} | ||
| draw_text = Mock(wraps=ImageDraw.ImageDraw.text) |
There was a problem hiding this comment.
[P2] This Mock does not preserve method binding when installed on ImageDraw.ImageDraw, so wraps calls the original method without self. The test fails with TypeError: ImageDraw.text() missing 1 required positional argument: 'text', locally and in CI. Use a wrapper/spy that calls the original with the instance while keeping the rendering assertions.
…palette-only image inspection, and bound text spy test
|
Thanks for addressing the review feedback! I added tests for map styling and analysis, bringing coverage to 93.63%. All 379 tests pass locally. Merging once CI is green. |
…map auto-coloring