diff --git a/backend/apps/agents/manager/AgentLaunch.py b/backend/apps/agents/manager/AgentLaunch.py
index 179110ae..3b544556 100644
--- a/backend/apps/agents/manager/AgentLaunch.py
+++ b/backend/apps/agents/manager/AgentLaunch.py
@@ -61,6 +61,13 @@ class AgentLaunch(AgentManagerProtocol):
):
from backend.apps.outputs.workspace_io import app_workspace_dir
bound = app_workspace_dir(config.selected_app_output_ids[0])
+ if bound:
+ # The user is about to EDIT this app: a serve-static runtime must boot vite now or the agent's changes render nowhere (ENG-209).
+ try:
+ from backend.apps.outputs.runtime import manager as p_rt_manager
+ await p_rt_manager.ensure_editing(bound)
+ except Exception:
+ pass
if bound:
config.target_directory = bound
diff --git a/backend/apps/outputs/outputs.py b/backend/apps/outputs/outputs.py
index fa38e207..6af4b347 100644
--- a/backend/apps/outputs/outputs.py
+++ b/backend/apps/outputs/outputs.py
@@ -120,18 +120,23 @@ async def serve_workspace_file(workspace_id: str, filepath: str, p_d: str = ""):
if not os.path.isfile(full_path):
raise HTTPException(status_code=404, detail="File not found")
- with open(full_path) as f:
- content = f.read()
-
- if filepath == "index.html":
+ # endswith, not equality: serve-mode delivers frontend/dist/index.html through this same route and needs the identical injection + token rewrite (ENG-209).
+ if filepath.endswith("index.html"):
+ with open(full_path) as f:
+ content = f.read()
input_json, result_json = decode_data_param(p_d) if p_d else ("{}", "null")
backend_url_json = backend_url_for_workspace(workspace_id)
content = inject_data_into_html(content, input_json, result_json, backend_url_json, with_runtime=True)
# Iframe sub-resource fetches (,