diff --git a/automap_rs/src/lib.rs b/automap_rs/src/lib.rs index 59b7e69..e219bfc 100644 --- a/automap_rs/src/lib.rs +++ b/automap_rs/src/lib.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use pyo3::exceptions::PyValueError; +use pyo3::exceptions::{PyRuntimeError, PyValueError}; use pyo3::prelude::*; use pyo3::types::{PyBytes, PyTuple}; use std::io::{Read, Write}; @@ -189,12 +189,19 @@ fn render_video_rs( } enc_args.extend(["-pix_fmt".into(), "yuv420p".into(), output_path.into()]); - let mut encoder = Command::new(&ffmpeg_bin) + let mut encoder = match Command::new(&ffmpeg_bin) .args(&enc_args) .stdin(Stdio::piped()) .stderr(Stdio::null()) .spawn() - .map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(format!("ffmpeg encoder spawn failed: {e}")))?; + { + Ok(child) => child, + Err(error) => { + let _ = decoder.kill(); + let _ = decoder.wait(); + return Err(PyRuntimeError::new_err(format!("ffmpeg encoder spawn failed: {error}"))); + } + }; let mut enc_in = encoder .stdin @@ -213,12 +220,22 @@ fn render_video_rs( let mut ca_row_buf = if impact_fx_enabled { vec![0u8; width * 4] } else { Vec::new() }; let mut x_resample_lut = if need_zoom_buf { Vec::with_capacity(width) } else { Vec::new() }; + let mut frame_read_error = None; + let mut frame_write_error = None; + let mut decoder_finished = false; for frame_idx in 0..total_frames { - if dec_out.read_exact(&mut bg_buf).is_err() { - if frame_idx == 0 { - break; + if !decoder_finished { + // Keep a complete previous frame when the decoder ends early. + match dec_out.read_exact(&mut frame_buf) { + Ok(()) => std::mem::swap(&mut bg_buf, &mut frame_buf), + Err(error) if frame_idx > 0 && error.kind() == std::io::ErrorKind::UnexpectedEof => { + decoder_finished = true; + } + Err(error) => { + frame_read_error = Some(error); + break; + } } - // Hold the last decoded background frame if the source ended slightly early. } frame_buf.copy_from_slice(&bg_buf); @@ -350,17 +367,25 @@ fn render_video_rs( }; // Stream the composited frame into ffmpeg's stdin. - enc_in - .write_all(out_buf) - .map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(format!("encoder write failed: {e}")))?; + if let Err(error) = enc_in.write_all(out_buf) { + frame_write_error = Some(error); + break; + } } - // Close stdin so ffmpeg flushes and finalizes the MP4 container. + // Close the decoder pipe before waiting. FFmpeg may still be writing frames + // past the requested count and would block on a full pipe. drop(enc_in); - let status = encoder - .wait() - .map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(format!("encoder wait failed: {e}")))?; + drop(dec_out); let _ = decoder.wait(); + let status = encoder.wait(); + if let Some(error) = frame_read_error { + return Err(PyRuntimeError::new_err(format!("decoder read failed: {error}"))); + } + if let Some(error) = frame_write_error { + return Err(PyRuntimeError::new_err(format!("encoder write failed: {error}"))); + } + let status = status.map_err(|e| PyRuntimeError::new_err(format!("encoder wait failed: {e}")))?; if !status.success() { return Err(pyo3::exceptions::PyRuntimeError::new_err(format!( diff --git a/main.py b/main.py index 58e253a..424c1af 100644 --- a/main.py +++ b/main.py @@ -123,7 +123,7 @@ def _available_fonts(): app = Flask(__name__) # Three 10 MiB materials (map, background and music) grow by 4/3 in JSON. -app.config["MAX_CONTENT_LENGTH"] = 48 * 1024 * 1024 +app.config["MAX_CONTENT_LENGTH"] = 64 * 1024 * 1024 from web_auth import init_web_auth @@ -754,6 +754,9 @@ def api_generate_idea(): except ValueError as err: return jsonify(status='error', error=str(err)), 400 + raw_avoid = data.get("avoid_ideas") + avoid_ideas = [str(item).strip() for item in raw_avoid if str(item).strip()][:30] if isinstance(raw_avoid, list) else [] + try: result = generate_map_idea( model, @@ -762,6 +765,7 @@ def api_generate_idea(): available_themes=list(_PALETTE_THEMES.keys()), available_fonts=_available_fonts(), temperature=temperature, + avoid_ideas=avoid_ideas, ) except AIServiceError as error: return jsonify(status='error', error=str(error)), error.status_code diff --git a/map/auto_map.py b/map/auto_map.py index de2edf9..7cc17d6 100644 --- a/map/auto_map.py +++ b/map/auto_map.py @@ -537,6 +537,12 @@ def _numeric_extrema(values): return max(numeric, key=numeric.get), min(numeric, key=numeric.get) +def _format_text_label(value: object) -> str: + """Uppercase the first character while preserving acronyms and other casing.""" + label = "" if value is None else str(value).strip() + return label[:1].upper() + label[1:] + + def _format_legend_bound(val: float) -> str: """Format a numeric legend bound compactly so ranges fit in open sea space.""" abs_val = abs(val) @@ -961,16 +967,24 @@ def _report(stage: int, label: str) -> None: log.success(f"Got information from AI ({len(ai_answer)} entries)") - resolved_theme = _resolve_theme_name(palette_theme, prompt=prompt, mode=mode) - auto_txt, auto_num = _auto_fill_from_ai( - ai_answer, - mode, - palette_theme=palette_theme, - prompt=prompt, - ) + is_painted_map = map_type in constants._PAINTED_MAP_TYPES + if is_painted_map: + resolved_theme = _resolve_theme_name(palette_theme, prompt=prompt, mode=mode) + auto_txt, auto_num = _auto_fill_from_ai( + ai_answer, + mode, + palette_theme=palette_theme, + prompt=prompt, + ) + else: + resolved_theme = "flags" + auto_txt, auto_num = {}, {} + filling_txt = {} + filling_txt_ci = {} + filling_num = {} theme_requested = (palette_theme or "auto").strip().lower() != "auto" - if auto_style is True: + if is_painted_map and auto_style is True: if mode == "text": merged_txt = dict(auto_txt) req_keys_low = {k.strip().lower() for k in req_txt} @@ -1072,53 +1086,57 @@ def _report(stage: int, label: str) -> None: if mode == 'number': try: info = ai_answer_norm[name_key] - color = _random_region_color() + color = _random_region_color() if is_painted_map else (0, 0, 0, 0) num_value = _parse_short_number(info) raw_num_value = _parse_short_number(raw_ai_answer_norm.get(name_key)) - if num_value is None: + if num_value is None and is_painted_map: log.warning(f"Non-numeric value for {name}: {info!r}; using random color") if num_value is not None: if highlight_extrema: numeric_region_values[index] = float(raw_num_value if raw_num_value is not None else num_value) - # Pick the colour of the first matching range. Ranges are - # treated as (low < value <= high) per the docs. - matched_bounds = None - for candidate in (num_value, raw_num_value): - if candidate is None or matched_bounds is not None: - continue - for (low_lim, high_lim), color_tup in filling_num.items(): - if low_lim < candidate <= high_lim: - color = color_tup - matched_bounds = (low_lim, high_lim) - break - if matched_bounds is None and auto_style is True and auto_num: - for (low_lim, high_lim), color_tup in auto_num.items(): - if low_lim < num_value <= high_lim: - color = color_tup - matched_bounds = (low_lim, high_lim) - break - if matched_bounds is not None: - used_num_rules[matched_bounds] = color + if is_painted_map: + # Pick the colour of the first matching range. Ranges are + # treated as (low < value <= high) per the docs. + matched_bounds = None + for candidate in (num_value, raw_num_value): + if candidate is None or matched_bounds is not None: + continue + for (low_lim, high_lim), color_tup in filling_num.items(): + if low_lim < candidate <= high_lim: + color = color_tup + matched_bounds = (low_lim, high_lim) + break + if matched_bounds is None and auto_style is True and auto_num: + for (low_lim, high_lim), color_tup in auto_num.items(): + if low_lim < num_value <= high_lim: + color = color_tup + matched_bounds = (low_lim, high_lim) + break + if matched_bounds is not None: + used_num_rules[matched_bounds] = color except KeyError as e: info = "" - log.warning(f"No data / color for {e}; using random color") - color = _random_region_color() - random_colors[name] = color + if is_painted_map: + log.warning(f"No data / color for {e}; using random color") + color = _random_region_color() + random_colors[name] = color + else: + color = (0, 0, 0, 0) elif mode == 'text': '''Text mode''' raw_info = ai_answer_norm.get(name_key) - info = "" if raw_info is None else str(raw_info).strip() + info = _format_text_label(raw_info) if not info: log.info(f"No information for {name}, skipping") continue - try: - # Match filling colours case-insensitively and ignoring whitespace, - # so "Yes", "yes" and " yes " all find the same colour. - color = filling_txt_ci[info.lower()] - except KeyError: - if map_type in constants._PAINTED_MAP_TYPES: + if is_painted_map: + try: + # Match filling colours case-insensitively and ignoring whitespace, + # so "Yes", "yes" and " yes " all find the same colour. + color = filling_txt_ci[info.lower()] + except KeyError: log.info(f"No filling color for '{info}'; using random") # Repeated answers share a color so categories remain recognizable. try: @@ -1126,9 +1144,9 @@ def _report(stage: int, label: str) -> None: except KeyError: color = _random_region_color() random_colors[info] = color - else: - color = _random_region_color() - used_txt_rules.setdefault(info, color) + used_txt_rules.setdefault(info, color) + else: + color = (0, 0, 0, 0) else: showerror("Error", f"Unknown mode: {mode}") return @@ -1292,7 +1310,7 @@ def _report(stage: int, label: str) -> None: else: result = _alpha_composite(img, text_layer) - if show_legend: + if show_legend and is_painted_map: if mode == "number": legend_src = used_num_rules or effective_num legend_entries = [ @@ -1302,7 +1320,7 @@ def _report(stage: int, label: str) -> None: else: legend_src = used_txt_rules or effective_txt legend_entries = [ - (tuple(c), str(label).strip()) + (tuple(c), _format_text_label(label)) for label, c in legend_src.items() if str(label).strip() ] diff --git a/map/functions.py b/map/functions.py index a09dbc0..e88e8b4 100644 --- a/map/functions.py +++ b/map/functions.py @@ -17,6 +17,7 @@ import json import math import os +import random import re import sys import requests @@ -486,6 +487,26 @@ def _call_model_text( return text.strip() +IDEA_CATEGORIES = ( + "food, drinks, and dining habits", + "driving, traffic, and public transport", + "work, salaries, holidays, and retirement", + "language, slang, names, and alphabets", + "housing, everyday prices, and cost of living", + "climate, weather, nature, and wildlife", + "school, education, and university life", + "sports, hobbies, and pop culture", + "internet, technology, and gaming", + "health, sleep, and daily routines", + "unusual laws, rules, and traditions", + "cities, borders, and surprising geography", +) + + +def _normalize_idea_key(text: str) -> str: + return re.sub(r"[^a-z0-9]+", " ", str(text or "").lower()).strip() + + def generate_map_idea( ai_model: str, api_key: str | None = None, @@ -494,25 +515,49 @@ def generate_map_idea( available_themes: list[str] | tuple[str, ...] | None = None, available_fonts: list[str] | tuple[str, ...] | None = None, temperature: float | None = None, + avoid_ideas: list[str] | tuple[str, ...] | None = None, ) -> dict[str, object]: """Generate a single map idea (and optionally matching map parameters) via the selected AI model.""" - examples_block = "\n".join(f'- "{ex}"' for ex in IDEA_EXAMPLES) + sampled_examples = random.sample(IDEA_EXAMPLES, min(6, len(IDEA_EXAMPLES))) + examples_block = "\n".join(f'- "{ex}"' for ex in sampled_examples) + cleaned_avoid = [str(item).strip() for item in (avoid_ideas or ()) if str(item).strip()][:30] + avoid_keys = {_normalize_idea_key(item) for item in cleaned_avoid} + avoid_block = "" + if cleaned_avoid: + avoid_lines = "\n".join(f'- "{item}"' for item in cleaned_avoid[-20:]) + avoid_block = ( + "\n\nIMPORTANT — Do NOT repeat or closely rephrase any of these already-used ideas:\n" + f"{avoid_lines}" + ) + idea_temp = 1.0 if temperature is None else validate_temperature(temperature) if not with_params: system_msg = ( "You generate short, engaging, curiosity-sparking map topic questions in English. " + "Always pick a fresh, surprising angle and never repeat recent topics. " "Return ONLY the idea itself as a single plain-text sentence/question, with no quotes, " "no numbering, no markdown, and no explanation." ) - user_prompt = ( - "Generate 1 new creative map topic idea in the exact same style and format as these examples:\n" - f"{examples_block}\n\n" - "Return only the idea text." - ) - raw = _call_model_text(system_msg, user_prompt, ai_model, api_key, temperature=temperature, json_mode=False) - idea = raw.strip().splitlines()[0].strip().strip('"\'` ') - if not idea: - raise AIServiceError('The AI model returned an empty idea. Please try again.', 502) + idea = "" + for attempt in range(2): + focus_category = random.choice(IDEA_CATEGORIES) + nonce = random.randint(1000, 9999) + retry_note = "\nPrevious candidate was a duplicate — choose a completely different subject." if attempt else "" + user_prompt = ( + f"Generate 1 fresh, creative map topic idea focused on: {focus_category} (variation #{nonce}).\n" + "Match the concise style of these examples without copying them:\n" + f"{examples_block}" + f"{avoid_block}" + f"{retry_note}\n\n" + "Return only the idea text." + ) + raw = _call_model_text(system_msg, user_prompt, ai_model, api_key, temperature=idea_temp, json_mode=False) + candidate = next(iter(raw.strip().splitlines()), '').strip().strip('"\'` ') + if not candidate: + raise AIServiceError('The AI model returned an empty idea. Please try again.', 502) + idea = candidate + if _normalize_idea_key(candidate) not in avoid_keys: + break return {"idea": idea} raw_themes = [str(t) for t in (available_themes or list(constants._PALETTE_THEMES.keys()))] @@ -524,34 +569,47 @@ def generate_map_idea( system_msg = ( "You generate short, engaging map topic questions in English along with the best map rendering parameters. " + "Always pick a fresh, surprising angle and never repeat recent topics. " "Return ONLY a valid JSON object (no markdown fences, no commentary)." ) - user_prompt = ( - "Generate 1 new creative map topic idea in the same style as these examples:\n" - f"{examples_block}\n\n" - "Return a JSON object with these exact keys:\n" - '- "idea": string (the single map question/topic, no surrounding quotes)\n' - f'- "mode": one of {list(allowed_modes)} ("number" for numeric counts/amounts/years, "text" for names/words/categories)\n' - f'- "map_type": one of {list(allowed_map_types)} ("default" = Europe painted, "flag" = Europe flags, "world" = continents, "world_countries" = all world countries)\n' - f'- "palette_theme": one of {themes}\n' - f'- "font": one of {fonts}\n' - f'- "extra_option": one of {list(allowed_extras)} ("show_most_least" or "show_short_form" only when mode is "number" and map_type is not "world", otherwise "none")\n' - '- "show_legend": boolean (true if a legend helps explain the map, false otherwise)' - ) - raw = _call_model_text(system_msg, user_prompt, ai_model, api_key, temperature=temperature, json_mode=True) - cleaned = raw.strip() - if cleaned.startswith("```"): - cleaned = re.sub(r"^```(?:json)?\s*|\s*```$", "", cleaned, flags=re.IGNORECASE | re.DOTALL).strip() - try: - parsed = json.loads(cleaned) - except json.JSONDecodeError as error: - raise AIServiceError('AI returned invalid JSON for the map idea. Please try again.', 502) from error - if not isinstance(parsed, dict): - raise AIServiceError('AI returned an unexpected format for the map idea.', 502) - - idea = str(parsed.get("idea") or "").strip().strip('"\'` ') - if not idea: - raise AIServiceError('The AI model returned an empty idea. Please try again.', 502) + parsed = None + idea = "" + for attempt in range(2): + focus_category = random.choice(IDEA_CATEGORIES) + nonce = random.randint(1000, 9999) + retry_note = "\nPrevious candidate was a duplicate — choose a completely different subject." if attempt else "" + user_prompt = ( + f"Generate 1 fresh, creative map topic idea focused on: {focus_category} (variation #{nonce}).\n" + "Match the concise style of these examples without copying them:\n" + f"{examples_block}" + f"{avoid_block}" + f"{retry_note}\n\n" + "Return a JSON object with these exact keys:\n" + '- "idea": string (the single map question/topic, no surrounding quotes)\n' + f'- "mode": one of {list(allowed_modes)} ("number" for numeric counts/amounts/years, "text" for names/words/categories)\n' + f'- "map_type": one of {list(allowed_map_types)} ("default" = Europe painted, "flag" = Europe flags, "world" = continents, "world_countries" = all world countries)\n' + f'- "palette_theme": one of {themes}\n' + f'- "font": one of {fonts}\n' + f'- "extra_option": one of {list(allowed_extras)} ("show_most_least" or "show_short_form" only when mode is "number" and map_type is not "world", otherwise "none")\n' + '- "show_legend": boolean (true if a legend helps explain the map, false otherwise)' + ) + raw = _call_model_text(system_msg, user_prompt, ai_model, api_key, temperature=idea_temp, json_mode=True) + cleaned = raw.strip() + if cleaned.startswith("```"): + cleaned = re.sub(r"^```(?:json)?\s*|\s*```$", "", cleaned, flags=re.IGNORECASE | re.DOTALL).strip() + try: + candidate_obj = json.loads(cleaned) + except json.JSONDecodeError as error: + raise AIServiceError('AI returned invalid JSON for the map idea. Please try again.', 502) from error + if not isinstance(candidate_obj, dict): + raise AIServiceError('AI returned an unexpected format for the map idea.', 502) + candidate_idea = str(candidate_obj.get("idea") or "").strip().strip('"\'` ') + if not candidate_idea: + raise AIServiceError('The AI model returned an empty idea. Please try again.', 502) + parsed = candidate_obj + idea = candidate_idea + if _normalize_idea_key(candidate_idea) not in avoid_keys: + break mode = str(parsed.get("mode") or "text").strip().lower() if mode not in allowed_modes: diff --git a/render_progress.py b/render_progress.py index 9e989de..d3d881f 100644 --- a/render_progress.py +++ b/render_progress.py @@ -63,13 +63,20 @@ def tracked(*args, **kwargs): return jsonify(status='error', error='Invalid render ID.'), 400 with self.lock: now = monotonic() - # Evict stale records older than 1 hour before checking capacity/duplicates. + # Keep active renders even if an encoding phase has no progress callbacks. self.records = {key: value for key, value in self.records.items() - if now - value['updated_at'] < 3600} + if value['status'] == 'rendering' or now - value['updated_at'] < 3600} if render_id in self.records: return jsonify(status='error', error='This render ID has already been used.'), 409 if len(self.records) >= 256: - return jsonify(status='error', error='Render service is busy. Try again later.'), 503 + oldest_finished = min( + (key for key, value in self.records.items() if value['status'] != 'rendering'), + key=lambda key: self.records[key]['updated_at'], + default=None, + ) + if oldest_finished is None: + return jsonify(status='error', error='Render service is busy. Try again later.'), 503 + del self.records[oldest_finished] self.records[render_id] = dict(status='rendering', progress=0, phase='Preparing materials', updated_at=now) g.render_progress_id = render_id diff --git a/static/studio.css b/static/studio.css new file mode 100644 index 0000000..bea5ad4 --- /dev/null +++ b/static/studio.css @@ -0,0 +1,351 @@ +/* AutoMap workbench direction. Unslop method by Damir Sokolovsky + (@heydamir), https://heydamir.design/unslop — CC BY 4.0. */ +:root { + color-scheme: dark; + --workbench-bg: #141415; + --workbench-panel: #19191b; + --workbench-raised: #202023; + --workbench-border: rgba(237, 237, 237, .1); + --workbench-text: #ededed; + --workbench-secondary: #a1a1a6; + --workbench-muted: #929298; + --workbench-accent: #8fb69a; + --workbench-ease: cubic-bezier(.22, 1, .36, 1); +} +body, .studio-backdrop { + background: var(--workbench-bg); + color: var(--workbench-text); + font-family: 'IBM Plex Sans', sans-serif; + font-variant-numeric: tabular-nums; +} +::selection { background: #28623c; color: #fff; } +header { + background: #141415; + border-bottom: 1px solid var(--workbench-border); +} +header > div { max-width: 1600px !important; } +main { max-width: 1600px !important; } +main > section { min-width: 0; } +.cyber-card, .studio-glass { + background: var(--workbench-panel); + border: 1px solid var(--workbench-border); + border-radius: 16px; + box-shadow: none; + backdrop-filter: none; + -webkit-backdrop-filter: none; +} +.studio-glass-hover, .studio-glass-hover:hover { + border-color: var(--workbench-border); + box-shadow: none; +} +h1, h2, h3 { font-weight: 500; letter-spacing: 0; } +h1 { color: var(--workbench-text); } +.automap-mark { color: var(--workbench-accent); } +header .automap-mark { width: 28px; height: 28px; } +/* Colors belong to the output, rather than the workbench surrounding it. */ +.canvas-grid { + background-color: #202023; + background-size: 32px 32px; + background-image: + linear-gradient(to right, rgba(237,237,237,.035) 1px, transparent 1px), + linear-gradient(to bottom, rgba(237,237,237,.035) 1px, transparent 1px); +} +.cinema-ambient, .timeline-scanner { display: none; } +.eq-bar { animation: none; transform: scaleY(.3); } +.check-pop, .check-pop-in { animation: none; } +button, a, input, textarea, select, label > div { + transition-property: color, background-color, border-color, opacity, transform; + transition-duration: 160ms; + transition-timing-function: var(--workbench-ease); +} +button, select, textarea, input:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=color]) { + border-radius: 8px; +} +button, a { touch-action: manipulation; } +button:hover:not(:disabled) { border-color: #525259; } +button:disabled { cursor: not-allowed; opacity: .5; } +button:focus-visible, a:focus-visible, input:focus-visible, +textarea:focus-visible, select:focus-visible, summary:focus-visible { + outline: 2px solid var(--workbench-accent); + outline-offset: 4px; +} +/* Hidden radios retain a visible keyboard focus on their associated tile. */ +input.peer:focus-visible + div { + outline: 2px solid var(--workbench-accent); + outline-offset: 4px; +} +input.peer:checked + div { + background: var(--workbench-raised); + border-color: var(--workbench-accent); + box-shadow: inset 3px 0 0 var(--workbench-accent); +} +input, textarea, select { accent-color: var(--workbench-accent); } +input[type=range] { cursor: pointer; } +input[type=range]::-webkit-slider-thumb, +#aiTemperature::-webkit-slider-thumb { + appearance: none; + width: 16px; height: 16px; + background: var(--workbench-accent); + border: 2px solid var(--workbench-panel); + border-radius: 50%; + box-shadow: none; + transform: none; +} +input[type=range]::-moz-range-thumb, +#aiTemperature::-moz-range-thumb { + width: 16px; height: 16px; + background: var(--workbench-accent); + border: 2px solid var(--workbench-panel); + border-radius: 50%; + box-shadow: none; +} +input[type=range]::-webkit-slider-thumb:hover { transform: none; box-shadow: none; } +#aiTemperaturePanel, #smartMapInspectorPanel { + background: var(--workbench-raised); + border-color: var(--workbench-border); + box-shadow: none; +} +#generateBtn, #renderBtn { + min-height: 48px; + background: #28623c; + border: 1px solid #28623c; + color: #fff; + font-weight: 500; +} +#generateBtn:hover:not(:disabled), #renderBtn:hover:not(:disabled) { + background: #205232; + border-color: #bcd5c4; +} +#generateBtn i, #renderBtn i { color: inherit; } +#musicBtn, #cutBtn { background: #202023; border: 1px solid #525259; } +#cutVisualBar { background: #28623c; } +/* Chrome icons use one size; rendered media and stickers keep their own scale. */ +header i, label > i, button > i, a > i, h2 > i { + font-size: 16px; + width: 16px; + flex-shrink: 0; + text-align: center; + color: var(--workbench-secondary); +} +code, .font-mono { font-variant-numeric: tabular-nums; } +#toast { transition-property: transform, opacity; } +::-webkit-scrollbar-track { background: #141415; } +::-webkit-scrollbar-thumb { background: #39393e; } +::-webkit-scrollbar-thumb:hover { background: #525259; } +@media (max-width: 639px) { + header > div { gap: 12px !important; } + header h1 { font-size: 16px; } + main { padding: 16px !important; } + button, select { min-height: 44px; } +} +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { + animation: none !important; + transition-duration: 0ms !important; + scroll-behavior: auto !important; + } +} +/* A preview is a bounded work area, independent of the long parameter form. */ +#mapStage { flex: none; height: 720px; min-height: 520px; } +#mapStage:fullscreen { height: 100%; border-radius: 0; } +#emptyState { background: transparent; border: 0; max-width: 480px; } +#emptyState > div:first-child { + background: transparent; + border: 0; + color: var(--workbench-secondary); +} +#emptyState > div:first-child > i { color: var(--workbench-secondary); } +header h1 { background: none; } +header i, main label i, main button i, main a i { + color: var(--workbench-secondary); +} +@media (max-width: 639px) { + #mapStage { height: 560px; min-height: 440px; } + #emptyState { padding: 16px; } +} + +#headerApiDot, #stageStatusDot { background-color: #8fb69a; } +#mapViewport:fullscreen { background-color: #202023; padding: 32px; } +#mapViewport:fullscreen #serverMapImage { max-height: calc(100vh - 64px); } +main i:not(.animate-spin) { color: var(--workbench-secondary); } +/* Dark atlas desk with forest-green actions and sage selection indicators. */ +header { background: #19191b; } +.cyber-card, .studio-glass { border-radius: 12px; } +input::placeholder, textarea::placeholder { color: #929298; opacity: 1; } +input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), textarea, select { + background-color: #19191b; + color: #ededed; + border-color: #39393e; +} +button[class*="bg-accent-600"]:not([class*="bg-accent-600/"]) { color: #fff; } +#generateBtn i, #renderBtn i { color: #fff; } +#mapViewport { background-color: #202023; } +#mapWorkspace, #videoWorkspace { gap: 20px; align-items: start; } +#mapControls { min-width: 0; gap: 0; } +.control-scroll { min-width: 0; display: flex; flex-direction: column; gap: 16px; } +.workspace-actions { + background: #19191b; + border: 1px solid #39393e; + border-radius: 12px; + padding: 16px; + display: flex; + flex-direction: column; + gap: 8px; +} +.workspace-actions > .mt-auto { padding: 0; } +.workflow-heading, .settings-group > summary { + display: flex; + align-items: center; + gap: 8px; + color: #ededed; + font-size: 14px; + font-weight: 500; +} +.workflow-heading > span, .settings-group > summary > span { + color: #8fb69a; + font-family: 'JetBrains Mono', monospace; + font-size: 12px; +} +.settings-group { border-top: 1px solid #2b2b2f; padding-top: 16px; } +.settings-group > summary { cursor: pointer; min-height: 36px; list-style: none; } +.settings-group > summary::after { content: '+'; margin-inline-start: auto; color: #a1a1a6; } +.settings-group[open] > summary::after { content: '−'; } +.settings-group-body { display: flex; flex-direction: column; gap: 20px; padding-top: 16px; } +#videoPreviewRail { min-width: 0; display: flex; flex-direction: column; gap: 12px; } +#videoPreview { background: #19191b; border-color: #39393e; } +/* The video frame keeps its dark canvas; these are output pixels, not chrome. */ +.video-preview-stage { background: #101812; color-scheme: dark; } +#stageEmptyPlaceholder { color: #b6c7bb; } +#stageEmptyPlaceholder p { color: #b6c7bb; } +#stageEmptyPlaceholder > div { background: #20382a; border-color: #3d5645; } +#stageEmptyPlaceholder i { color: #b6c7bb; } +.workflow-nav { display: flex; gap: 8px; grid-column: 1 / -1; } +.workflow-nav a { + flex: 1; + padding: 12px 8px; + border: 1px solid #39393e; + border-radius: 8px; + background: #19191b; + color: #bcd5c4; + text-align: center; + font-size: 12px; + font-weight: 500; +} +#mapControls, #audioControls, #composerControls, #videoPreviewRail { scroll-margin-top: 88px; } +@media (min-width: 1024px) { + #mapWorkspace { grid-template-columns: 400px minmax(0, 1fr); } + #mapWorkspace > section { grid-column: auto; } + #mapWorkspace > nav { display: none; } + #mapControls { position: sticky; top: 88px; height: calc(100dvh - 112px); } + #mapControls .control-scroll { overflow-y: auto; min-height: 0; padding-right: 4px; scrollbar-gutter: stable; } + #mapControls .workspace-actions { margin-top: 12px; flex-shrink: 0; } + #mapPreviewColumn { position: sticky; top: 88px; } + #mapStage { height: clamp(440px, calc(100dvh - 312px), 720px); min-height: 440px; } + #videoWorkspace { grid-template-columns: 300px minmax(0, 1fr); } + #videoWorkspace > section { grid-column: auto; } + #audioControls { grid-column: 1; grid-row: 1 / span 2; } + #composerControls { grid-column: 2; grid-row: 1; } + #videoPreviewRail { grid-column: 2; grid-row: 2; } + .workflow-nav { display: none; } +} +@media (min-width: 1280px) { + #videoWorkspace { grid-template-columns: 280px minmax(0, 1fr) 320px; } + #audioControls, #composerControls { + position: sticky; + top: 88px; + max-height: calc(100dvh - 112px); + overflow-y: auto; + scrollbar-gutter: stable; + padding-right: 4px; + } + #videoPreviewRail { grid-column: 3; grid-row: 1; position: sticky; top: 88px; } + #renderForm > .grid { grid-template-columns: minmax(0, 1fr); } + #videoPreview .video-preview-stage { width: min(100%, 252px, 49dvh); } + #videoPreview > div:first-child { gap: 8px; } + #videoPreview #stageModeLabel { display: none; } +} +@media (max-width: 1023px) { + #mapControls .workspace-actions { margin-top: 16px; } + #mapPreviewColumn { min-width: 0; } + body { padding-bottom: 112px; } + #generateBtn, #renderBtn { + position: fixed; + bottom: 16px; + left: 16px; + width: calc(100% - 32px); + z-index: 40; + box-shadow: 0 4px 16px rgba(35,55,43,.16); + } + #generateBtn { bottom: 64px; } + #restyleCurrentMapBtn { + position: fixed; + bottom: 12px; + left: 16px; + width: calc(100% - 32px); + min-height: 44px; + z-index: 40; + background: #19191b; + color: #bcd5c4; + } + #videoPreview .video-preview-stage { width: min(100%, 280px, 54svh); } + #toast { bottom: 128px; } +} +/* Keep scrolling panels at their natural height rather than shrinking their contents. */ +.control-scroll > *, #audioControls > *, #composerControls > * { flex-shrink: 0; } +#videoPreview .video-preview-stage { background-color: #101812; } +#statusIndicator, #headerApiText { color: #8fb69a; } +#mapControls .workflow-heading { margin-block: 8px 0; } +@media (min-width: 1280px) { + #renderForm > .grid > * { grid-column: auto; min-width: 0; } + #audioControls .studio-glass { padding: 16px; } + #audioControls code { display: none; } + #audioControls h2 { font-size: 14px; white-space: nowrap; } + #audioControls .truncate { white-space: normal; } + #videoPreview .video-preview-stage { width: min(100%, 252px, 49dvh); } + #videoPreview > div:last-child { flex-wrap: wrap; justify-content: center; } +} +#musicEqBox > [aria-hidden="true"] { display: none; } +#musicEqBox > div:first-child { flex: 1; } +#musicEqBox .truncate { white-space: normal; } +#musicEqBox { padding: 12px; } +#musicEqBox > div:first-child > div:last-child { min-width: 0; flex: 1; } +#mapControls { display: flex; flex-direction: column; } +#mapControls .control-scroll { flex: 1; } +/* The workspace structure also works before utility CSS finishes loading. */ +#mapWorkspace, #videoWorkspace { display: grid; grid-template-columns: minmax(0, 1fr); } +#mapWorkspace > nav { grid-column: 1 / -1; } +#mapPreviewColumn, #audioControls, #composerControls { display: flex; flex-direction: column; } +@media (min-width: 1024px) { + #mapWorkspace { grid-template-columns: 400px minmax(0, 1fr); } + #videoWorkspace { grid-template-columns: 300px minmax(0, 1fr); } +} +@media (min-width: 1280px) { + #videoWorkspace { grid-template-columns: 280px minmax(0, 1fr) 320px; } +} +/* Phone preview content and metadata must never occupy the same space. */ +@media (max-width: 639px) { + #mapStage { height: auto; min-height: 560px; } + #mapViewport { flex-direction: column; padding: 12px; } + #mapCanvasWrapper { flex: 1; min-height: 280px; padding-top: 32px; width: 100%; } + #mapViewportMeta { + position: static; + width: 100%; + flex-shrink: 0; + margin-top: 16px; + padding-top: 12px; + border-top: 1px solid var(--workbench-border); + } + #mapViewportMeta > div:last-child { background: transparent; border: 0; padding: 4px 0; } + #mapViewportMeta #activeFlagsBadges { gap: 4px; } + #mapViewportMeta #activeFlagsBadges > span { padding: 4px 8px; } + #mapControls .workspace-actions { background: transparent; border: 0; padding: 0; } + #mapStage, #audioControls, #composerControls, #videoPreviewRail { scroll-margin-top: 16px; } + #videoPreview #stageEmptyPlaceholder p { font-size: 20px; line-height: 28px; } + #generateBtn { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); } + #restyleCurrentMapBtn { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); } + #renderBtn { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); } + body { padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px)); } +} +@media (max-width: 639px) { + #videoPreviewRail > .workspace-actions { background: transparent; border: 0; padding: 0; } +} diff --git a/templates/index.html b/templates/index.html index c5de43a..9257973 100644 --- a/templates/index.html +++ b/templates/index.html @@ -19,30 +19,27 @@ - AutoMap Studio — AI Cartographic Engine & CLI Dashboard + AutoMap Studio — Map generation workspace - - - + + + + - - - - + -
+
-
+
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + + +
-

AutoMap Studio

+

AutoMap Studio

- +
-
+
-
- - System Ready +
+ + System Ready
- + Video Studio - + - + {% if config.WEB_AUTH_ENABLED and session.get('web_identity') %}
@@ -339,121 +167,123 @@

- +
+ -
- +
+
+ -
+
-
+
-
-
+
+
-

Generation Parameters

-

Configure AI query & cartographic CLI flags

+

Map parameters

+

Configure AI query & cartographic CLI flags

-
- + -
-
- +
+ -
- +
+ -
-
- -

Cartographic Render Stage

- Ready +
+
+ +

Map preview

+ Ready
-
- 100% - -
- - @@ -919,94 +752,91 @@

Cartograp
-

-