From c152374d1ba94ba0180d2fa26673d279b14aa512 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 15:06:49 -0500 Subject: [PATCH 1/2] fix(agents): ask the person before an agent opens a project over unsaved changes formsurface_open_project no longer replaces a document that has unsaved changes. The window shows its Discard Changes dialog with a line naming the project the agent asked for, and the agent call waits for the answer. Discard Changes opens the project; Cancel, or no answer within answer_within_seconds (5 to 600, default 120), refuses the call and keeps the document as it was. Other agent calls wait while the dialog is open. A document with no unsaved changes opens without asking, as before. The new dialog line is in every language table. --- .../formsurface-painting/references/tools.md | 2 +- .../formsurface-painting/references/tools.md | 2 +- .docs/wiki/Painting-with-Agents.md | 4 ++ backend/tests/test_f3_mcp.py | 21 ++++++- frontend/src/i18n/more16/cs.json | 3 +- frontend/src/i18n/more16/da.json | 3 +- frontend/src/i18n/more16/de.json | 3 +- frontend/src/i18n/more16/es-MX.json | 3 +- frontend/src/i18n/more16/es.json | 3 +- frontend/src/i18n/more16/fi.json | 3 +- frontend/src/i18n/more16/fr-CA.json | 3 +- frontend/src/i18n/more16/fr.json | 3 +- frontend/src/i18n/more16/hu.json | 3 +- frontend/src/i18n/more16/id.json | 3 +- frontend/src/i18n/more16/it.json | 3 +- frontend/src/i18n/more16/ja.json | 3 +- frontend/src/i18n/more16/ko.json | 3 +- frontend/src/i18n/more16/nb.json | 3 +- frontend/src/i18n/more16/nl.json | 3 +- frontend/src/i18n/more16/pl.json | 3 +- frontend/src/i18n/more16/pt-BR.json | 3 +- frontend/src/i18n/more16/ru.json | 3 +- frontend/src/i18n/more16/sv.json | 3 +- frontend/src/i18n/more16/th.json | 3 +- frontend/src/i18n/more16/tr.json | 3 +- frontend/src/i18n/more16/uk.json | 3 +- frontend/src/i18n/more16/vi.json | 3 +- frontend/src/i18n/more16/zh-CN.json | 3 +- frontend/src/i18n/more16/zh-TW.json | 3 +- frontend/src/i18n/strings.json | 3 +- frontend/src/main.ts | 51 ++++++++++++++-- .../tests/window/test_home_and_library.py | 59 +++++++++++++++++++ mcp/server.py | 6 +- 33 files changed, 185 insertions(+), 38 deletions(-) diff --git a/.agents/skills/formsurface-painting/references/tools.md b/.agents/skills/formsurface-painting/references/tools.md index 7c59467..2d75ea7 100644 --- a/.agents/skills/formsurface-painting/references/tools.md +++ b/.agents/skills/formsurface-painting/references/tools.md @@ -22,7 +22,7 @@ When this table and the server disagree, the server wins and this file is stale. | `formsurface_text_resource` | text, target (alpha, stencil, fill), font (sans-serif, serif, monospace or a loaded font), bold | image size, brush | | `formsurface_load_mesh` | file (glb, gltf, obj, fbx, usd, usda, usdc, usdz, ply, dae in workspace/meshes), reproject (carry every matched set's painting over by surface position; stays on until false) | status; bakes reset, sets keep their layers when material and tile match (reprojected when asked, undo cleared) | | `formsurface_save_project` | name (default the open project, or a new one named after the mesh) | folder, file, bytes, sets, layers; the whole document (every set's size, channel roles, layer stack with settings, masks, generators, effects, base material and layer pixels) as workspace/projects/name/project.fsproj | -| `formsurface_open_project` | name | the project's mesh loaded and every set restored exactly (bakes are not stored: bake again), plus status | +| `formsurface_open_project` | name, answer_within_seconds (5 to 600, default 120) | the project's mesh loaded and every set restored exactly (bakes are not stored: bake again), plus status; over unsaved changes the window asks the person (Discard Changes) and the call waits: Cancel or no answer in time refuses it and keeps the document | | `formsurface_instance_layer` | layer_id (any layer or folder on the active set, not itself an instance copy), texture_set (name or index) | new layer id in the target set; settings edits to any copy update all copies, layers added to a source folder follow; strokes stay on the source and painting a copy is refused | | `formsurface_list_smart_materials` | none | materials with layer names and whether they have a thumbnail, intelligent mask names, saved intelligent mask names | | `formsurface_apply_smart_material` | name | new layer ids, baked flag | diff --git a/.claude/skills/formsurface-painting/references/tools.md b/.claude/skills/formsurface-painting/references/tools.md index 7c59467..2d75ea7 100644 --- a/.claude/skills/formsurface-painting/references/tools.md +++ b/.claude/skills/formsurface-painting/references/tools.md @@ -22,7 +22,7 @@ When this table and the server disagree, the server wins and this file is stale. | `formsurface_text_resource` | text, target (alpha, stencil, fill), font (sans-serif, serif, monospace or a loaded font), bold | image size, brush | | `formsurface_load_mesh` | file (glb, gltf, obj, fbx, usd, usda, usdc, usdz, ply, dae in workspace/meshes), reproject (carry every matched set's painting over by surface position; stays on until false) | status; bakes reset, sets keep their layers when material and tile match (reprojected when asked, undo cleared) | | `formsurface_save_project` | name (default the open project, or a new one named after the mesh) | folder, file, bytes, sets, layers; the whole document (every set's size, channel roles, layer stack with settings, masks, generators, effects, base material and layer pixels) as workspace/projects/name/project.fsproj | -| `formsurface_open_project` | name | the project's mesh loaded and every set restored exactly (bakes are not stored: bake again), plus status | +| `formsurface_open_project` | name, answer_within_seconds (5 to 600, default 120) | the project's mesh loaded and every set restored exactly (bakes are not stored: bake again), plus status; over unsaved changes the window asks the person (Discard Changes) and the call waits: Cancel or no answer in time refuses it and keeps the document | | `formsurface_instance_layer` | layer_id (any layer or folder on the active set, not itself an instance copy), texture_set (name or index) | new layer id in the target set; settings edits to any copy update all copies, layers added to a source folder follow; strokes stay on the source and painting a copy is refused | | `formsurface_list_smart_materials` | none | materials with layer names and whether they have a thumbnail, intelligent mask names, saved intelligent mask names | | `formsurface_apply_smart_material` | name | new layer ids, baked flag | diff --git a/.docs/wiki/Painting-with-Agents.md b/.docs/wiki/Painting-with-Agents.md index a8b891b..4d78c1f 100644 --- a/.docs/wiki/Painting-with-Agents.md +++ b/.docs/wiki/Painting-with-Agents.md @@ -24,6 +24,10 @@ To use an agent outside this folder, `./formsurface agents install` registers th `formsurface_status` first: it reports the texture sets, layers, brush and camera, or says that no editor is linked. Then one idea per layer: set the base material, add a layer or a fill layer, bake the mesh maps once and drive wear with generators, take a screenshot, paint strokes with viewport points, check from a second angle, save the project, export the maps. The skill's `references/tools.md` lists every tool with its arguments. +## Unsaved painting + +An agent never throws away painting the person has not saved. When `formsurface_open_project` would replace a document with unsaved changes, the window shows its Discard Changes dialog with a line naming the project the agent asked for, and the agent's call waits. Discard Changes opens the project. Cancel, or no answer within the call's `answer_within_seconds` (120 by default), refuses the call and leaves the document as it was. Other agent calls wait while the dialog is open. A document with no unsaved changes opens without asking. + ## Without an open editor `./formsurface batch --headless job.json` and `./formsurface script --headless job.py` start the service, the editor and a windowless Chrome, Chromium or Edge, run, and stop what they started. diff --git a/backend/tests/test_f3_mcp.py b/backend/tests/test_f3_mcp.py index ba9214d..d0879fd 100644 --- a/backend/tests/test_f3_mcp.py +++ b/backend/tests/test_f3_mcp.py @@ -34,7 +34,7 @@ def linked(engine): return json.loads(r.read())["editor_linked"] -async def call_with_editor(engine, reply): +async def call_with_editor(engine, reply, tool="formsurface_status", arguments=None): seen = [] ready = asyncio.Event() @@ -55,7 +55,7 @@ async def editor(): break await asyncio.sleep(0.1) async with Client(params(engine["base"])) as client: - result = await client.call_tool("formsurface_status", {}) + result = await client.call_tool(tool, arguments or {}) await task return result, seen @@ -100,6 +100,23 @@ def test_editor_refusal_comes_back_as_a_tool_error(engine): assert "no mesh is loaded" in text_of(result) +def test_open_project_gives_the_person_a_time_to_answer_about_unsaved_changes(engine): + _, seen = run(call_with_editor(engine, {"ok": True, "result": {}}, "formsurface_open_project", {"name": "crate"})) + assert seen[0]["command"] == "open_project" + assert seen[0]["args"] == {"name": "crate", "answer_within": 120} + _, seen = run(call_with_editor(engine, {"ok": True, "result": {}}, "formsurface_open_project", {"name": "crate", "answer_within_seconds": 30})) + assert seen[0]["args"] == {"name": "crate", "answer_within": 30} + + +def test_open_project_refuses_an_answer_time_out_of_range(engine): + async def go(): + async with Client(params(engine["base"])) as client: + return await client.call_tool("formsurface_open_project", {"name": "crate", "answer_within_seconds": 1}) + + result = run(go()) + assert result.is_error + + @pytest.mark.parametrize("service", ["http://evil.example:8766", "http://192.168.1.10:8766"]) def test_mcp_server_refuses_to_talk_to_a_non_local_service(service): done = subprocess.run([sys.executable, "-I", str(MCP_SERVER)], env={"FORMSURFACE_SERVICE": service}, capture_output=True, text=True, timeout=60, stdin=subprocess.DEVNULL) diff --git a/frontend/src/i18n/more16/cs.json b/frontend/src/i18n/more16/cs.json index 743a25f..d2ee6ef 100644 --- a/frontend/src/i18n/more16/cs.json +++ b/frontend/src/i18n/more16/cs.json @@ -15,5 +15,6 @@ "Memory {0}": "Paměť {0}", "Reply {0} tokens": "Odpověď {0} tokenů", "Chat {0} tokens": "Chat {0} tokenů", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV dlaždice zapnuty: UDIM dlaždice každého materiálu sdílejí zásobník vrstev aktivní dlaždice a tahy malují přes ně; každá dlaždice si ponechá vlastní malbu" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV dlaždice zapnuty: UDIM dlaždice každého materiálu sdílejí zásobník vrstev aktivní dlaždice a tahy malují přes ně; každá dlaždice si ponechá vlastní malbu", + "An agent asks to open {0}.": "Agent žádá o otevření {0}." } diff --git a/frontend/src/i18n/more16/da.json b/frontend/src/i18n/more16/da.json index 872d8aa..c92b4ee 100644 --- a/frontend/src/i18n/more16/da.json +++ b/frontend/src/i18n/more16/da.json @@ -15,5 +15,6 @@ "Memory {0}": "Hukommelse {0}", "Reply {0} tokens": "Svar {0} tokens", "Chat {0} tokens": "Chat {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles slået til: hvert materiales UDIM-tiles deler den aktive tiles lagstak, og strøg maler hen over dem; hver tile beholder sin egen maling" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles slået til: hvert materiales UDIM-tiles deler den aktive tiles lagstak, og strøg maler hen over dem; hver tile beholder sin egen maling", + "An agent asks to open {0}.": "En agent beder om at åbne {0}." } diff --git a/frontend/src/i18n/more16/de.json b/frontend/src/i18n/more16/de.json index c32111a..d83832f 100644 --- a/frontend/src/i18n/more16/de.json +++ b/frontend/src/i18n/more16/de.json @@ -15,5 +15,6 @@ "Memory {0}": "Speicher {0}", "Reply {0} tokens": "Antwort {0} Tokens", "Chat {0} tokens": "Chat {0} Tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-Tiles an: Die UDIM-Tiles jedes Materials teilen sich den Ebenenstapel des aktiven Tiles, und Striche malen über alle hinweg; jedes Tile behält seine eigene Bemalung" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-Tiles an: Die UDIM-Tiles jedes Materials teilen sich den Ebenenstapel des aktiven Tiles, und Striche malen über alle hinweg; jedes Tile behält seine eigene Bemalung", + "An agent asks to open {0}.": "Ein Agent möchte {0} öffnen." } diff --git a/frontend/src/i18n/more16/es-MX.json b/frontend/src/i18n/more16/es-MX.json index 0a9177b..87d3f29 100644 --- a/frontend/src/i18n/more16/es-MX.json +++ b/frontend/src/i18n/more16/es-MX.json @@ -15,5 +15,6 @@ "Memory {0}": "Memoria {0}", "Reply {0} tokens": "Respuesta {0} tokens", "Chat {0} tokens": "Chat {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Teselas UV activadas: las teselas UDIM de cada material comparten la pila de capas de la tesela activa y los trazos pintan a través de ellas; cada tesela conserva su propia pintura" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Teselas UV activadas: las teselas UDIM de cada material comparten la pila de capas de la tesela activa y los trazos pintan a través de ellas; cada tesela conserva su propia pintura", + "An agent asks to open {0}.": "Un agente pide abrir {0}." } diff --git a/frontend/src/i18n/more16/es.json b/frontend/src/i18n/more16/es.json index 0a9177b..87d3f29 100644 --- a/frontend/src/i18n/more16/es.json +++ b/frontend/src/i18n/more16/es.json @@ -15,5 +15,6 @@ "Memory {0}": "Memoria {0}", "Reply {0} tokens": "Respuesta {0} tokens", "Chat {0} tokens": "Chat {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Teselas UV activadas: las teselas UDIM de cada material comparten la pila de capas de la tesela activa y los trazos pintan a través de ellas; cada tesela conserva su propia pintura" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Teselas UV activadas: las teselas UDIM de cada material comparten la pila de capas de la tesela activa y los trazos pintan a través de ellas; cada tesela conserva su propia pintura", + "An agent asks to open {0}.": "Un agente pide abrir {0}." } diff --git a/frontend/src/i18n/more16/fi.json b/frontend/src/i18n/more16/fi.json index 31c4b93..dc374e5 100644 --- a/frontend/src/i18n/more16/fi.json +++ b/frontend/src/i18n/more16/fi.json @@ -15,5 +15,6 @@ "Memory {0}": "Muisti {0}", "Reply {0} tokens": "Vastaus {0} tokenia", "Chat {0} tokens": "Chat {0} tokenia", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-ruudut päällä: kunkin materiaalin UDIM-ruudut jakavat aktiivisen ruudun tasopinon ja vedot maalaavat niiden yli; jokainen ruutu säilyttää oman maalauksensa" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-ruudut päällä: kunkin materiaalin UDIM-ruudut jakavat aktiivisen ruudun tasopinon ja vedot maalaavat niiden yli; jokainen ruutu säilyttää oman maalauksensa", + "An agent asks to open {0}.": "Agentti pyytää avaamaan kohteen {0}." } diff --git a/frontend/src/i18n/more16/fr-CA.json b/frontend/src/i18n/more16/fr-CA.json index bdb8210..3ce3dc7 100644 --- a/frontend/src/i18n/more16/fr-CA.json +++ b/frontend/src/i18n/more16/fr-CA.json @@ -15,5 +15,6 @@ "Memory {0}": "Mémoire {0}", "Reply {0} tokens": "Réponse {0} jetons", "Chat {0} tokens": "Clavardage {0} jetons", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tuiles UV activées : les tuiles UDIM de chaque matériau partagent la pile de calques de la tuile active et les traits peignent à travers elles; chaque tuile garde sa propre peinture" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tuiles UV activées : les tuiles UDIM de chaque matériau partagent la pile de calques de la tuile active et les traits peignent à travers elles; chaque tuile garde sa propre peinture", + "An agent asks to open {0}.": "Un agent demande d'ouvrir {0}." } diff --git a/frontend/src/i18n/more16/fr.json b/frontend/src/i18n/more16/fr.json index e3a3eae..55ba949 100644 --- a/frontend/src/i18n/more16/fr.json +++ b/frontend/src/i18n/more16/fr.json @@ -15,5 +15,6 @@ "Memory {0}": "Mémoire {0}", "Reply {0} tokens": "Réponse {0} jetons", "Chat {0} tokens": "Chat {0} jetons", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tuiles UV activées : les tuiles UDIM de chaque matériau partagent la pile de calques de la tuile active et les traits peignent à travers elles ; chaque tuile garde sa propre peinture" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tuiles UV activées : les tuiles UDIM de chaque matériau partagent la pile de calques de la tuile active et les traits peignent à travers elles ; chaque tuile garde sa propre peinture", + "An agent asks to open {0}.": "Un agent demande d'ouvrir {0}." } diff --git a/frontend/src/i18n/more16/hu.json b/frontend/src/i18n/more16/hu.json index dce619e..692e1e4 100644 --- a/frontend/src/i18n/more16/hu.json +++ b/frontend/src/i18n/more16/hu.json @@ -15,5 +15,6 @@ "Memory {0}": "Memória {0}", "Reply {0} tokens": "Válasz {0} token", "Chat {0} tokens": "Chat {0} token", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-csempék be: az egyes anyagok UDIM-csempéi az aktív csempe rétegvermét osztják meg, és a húzások átfestenek rajtuk; minden csempe megtartja a saját festését" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-csempék be: az egyes anyagok UDIM-csempéi az aktív csempe rétegvermét osztják meg, és a húzások átfestenek rajtuk; minden csempe megtartja a saját festését", + "An agent asks to open {0}.": "Egy ügynök a(z) {0} megnyitását kéri." } diff --git a/frontend/src/i18n/more16/id.json b/frontend/src/i18n/more16/id.json index ca5d17e..73f292f 100644 --- a/frontend/src/i18n/more16/id.json +++ b/frontend/src/i18n/more16/id.json @@ -15,5 +15,6 @@ "Memory {0}": "Memori {0}", "Reply {0} tokens": "Balasan {0} token", "Chat {0} tokens": "Obrolan {0} token", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tile UV aktif: tile UDIM setiap material berbagi tumpukan lapisan tile aktif dan goresan melukis di semuanya; setiap tile mempertahankan lukisannya sendiri" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tile UV aktif: tile UDIM setiap material berbagi tumpukan lapisan tile aktif dan goresan melukis di semuanya; setiap tile mempertahankan lukisannya sendiri", + "An agent asks to open {0}.": "Sebuah agen meminta untuk membuka {0}." } diff --git a/frontend/src/i18n/more16/it.json b/frontend/src/i18n/more16/it.json index 55bec5b..88e16a2 100644 --- a/frontend/src/i18n/more16/it.json +++ b/frontend/src/i18n/more16/it.json @@ -15,5 +15,6 @@ "Memory {0}": "Memoria {0}", "Reply {0} tokens": "Risposta {0} token", "Chat {0} tokens": "Chat {0} token", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tile UV attivati: i tile UDIM di ogni materiale condividono la pila di livelli del tile attivo e i tratti dipingono attraverso di essi; ogni tile conserva la propria pittura" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tile UV attivati: i tile UDIM di ogni materiale condividono la pila di livelli del tile attivo e i tratti dipingono attraverso di essi; ogni tile conserva la propria pittura", + "An agent asks to open {0}.": "Un agente chiede di aprire {0}." } diff --git a/frontend/src/i18n/more16/ja.json b/frontend/src/i18n/more16/ja.json index 198f2a3..7e387ca 100644 --- a/frontend/src/i18n/more16/ja.json +++ b/frontend/src/i18n/more16/ja.json @@ -15,5 +15,6 @@ "Memory {0}": "メモリ {0}", "Reply {0} tokens": "返信 {0} トークン", "Chat {0} tokens": "チャット {0} トークン", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV タイルをオンにしました:各マテリアルの UDIM タイルがアクティブなタイルのレイヤースタックを共有し、ストロークはそれらをまたいでペイントされます。各タイルは自分のペイントを保持します" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV タイルをオンにしました:各マテリアルの UDIM タイルがアクティブなタイルのレイヤースタックを共有し、ストロークはそれらをまたいでペイントされます。各タイルは自分のペイントを保持します", + "An agent asks to open {0}.": "エージェントが {0} を開こうとしています。" } diff --git a/frontend/src/i18n/more16/ko.json b/frontend/src/i18n/more16/ko.json index ee0e91b..b067d12 100644 --- a/frontend/src/i18n/more16/ko.json +++ b/frontend/src/i18n/more16/ko.json @@ -15,5 +15,6 @@ "Memory {0}": "메모리 {0}", "Reply {0} tokens": "응답 {0} 토큰", "Chat {0} tokens": "채팅 {0} 토큰", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV 타일 켜짐: 각 머티리얼의 UDIM 타일이 활성 타일의 레이어 스택을 공유하고 스트로크가 그 타일들에 걸쳐 칠해집니다. 각 타일은 자체 페인트를 유지합니다" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV 타일 켜짐: 각 머티리얼의 UDIM 타일이 활성 타일의 레이어 스택을 공유하고 스트로크가 그 타일들에 걸쳐 칠해집니다. 각 타일은 자체 페인트를 유지합니다", + "An agent asks to open {0}.": "에이전트가 {0} 열기를 요청합니다." } diff --git a/frontend/src/i18n/more16/nb.json b/frontend/src/i18n/more16/nb.json index fb2a73f..b2dda35 100644 --- a/frontend/src/i18n/more16/nb.json +++ b/frontend/src/i18n/more16/nb.json @@ -15,5 +15,6 @@ "Memory {0}": "Minne {0}", "Reply {0} tokens": "Svar {0} tokens", "Chat {0} tokens": "Chat {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles på: UDIM-tilene til hvert materiale deler den aktive tilens lagstabel, og strøk maler på tvers av dem; hver tile beholder sin egen maling" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles på: UDIM-tilene til hvert materiale deler den aktive tilens lagstabel, og strøk maler på tvers av dem; hver tile beholder sin egen maling", + "An agent asks to open {0}.": "En agent ber om å åpne {0}." } diff --git a/frontend/src/i18n/more16/nl.json b/frontend/src/i18n/more16/nl.json index 784a135..4b47cf2 100644 --- a/frontend/src/i18n/more16/nl.json +++ b/frontend/src/i18n/more16/nl.json @@ -15,5 +15,6 @@ "Memory {0}": "Geheugen {0}", "Reply {0} tokens": "Antwoord {0} tokens", "Chat {0} tokens": "Chat {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles aan: de UDIM-tiles van elk materiaal delen de laagstapel van de actieve tile en streken schilderen erdoorheen; elke tile houdt zijn eigen schilderwerk" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles aan: de UDIM-tiles van elk materiaal delen de laagstapel van de actieve tile en streken schilderen erdoorheen; elke tile houdt zijn eigen schilderwerk", + "An agent asks to open {0}.": "Een agent vraagt om {0} te openen." } diff --git a/frontend/src/i18n/more16/pl.json b/frontend/src/i18n/more16/pl.json index f82d3c9..1cc25b3 100644 --- a/frontend/src/i18n/more16/pl.json +++ b/frontend/src/i18n/more16/pl.json @@ -15,5 +15,6 @@ "Memory {0}": "Pamięć {0}", "Reply {0} tokens": "Odpowiedź {0} tokenów", "Chat {0} tokens": "Czat {0} tokenów", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Kafelki UV włączone: kafelki UDIM każdego materiału współdzielą stos warstw aktywnego kafelka, a pociągnięcia malują przez nie; każdy kafelek zachowuje własne malowanie" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Kafelki UV włączone: kafelki UDIM każdego materiału współdzielą stos warstw aktywnego kafelka, a pociągnięcia malują przez nie; każdy kafelek zachowuje własne malowanie", + "An agent asks to open {0}.": "Agent prosi o otwarcie {0}." } diff --git a/frontend/src/i18n/more16/pt-BR.json b/frontend/src/i18n/more16/pt-BR.json index e9a446c..2bb973d 100644 --- a/frontend/src/i18n/more16/pt-BR.json +++ b/frontend/src/i18n/more16/pt-BR.json @@ -15,5 +15,6 @@ "Memory {0}": "Memória {0}", "Reply {0} tokens": "Resposta {0} tokens", "Chat {0} tokens": "Chat {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tiles UV ativados: os tiles UDIM de cada material compartilham a pilha de camadas do tile ativo e os traços pintam através deles; cada tile mantém sua própria pintura" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tiles UV ativados: os tiles UDIM de cada material compartilham a pilha de camadas do tile ativo e os traços pintam através deles; cada tile mantém sua própria pintura", + "An agent asks to open {0}.": "Um agente pede para abrir {0}." } diff --git a/frontend/src/i18n/more16/ru.json b/frontend/src/i18n/more16/ru.json index 9d16b87..2b8a158 100644 --- a/frontend/src/i18n/more16/ru.json +++ b/frontend/src/i18n/more16/ru.json @@ -15,5 +15,6 @@ "Memory {0}": "Память {0}", "Reply {0} tokens": "Ответ {0} токенов", "Chat {0} tokens": "Чат {0} токенов", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-тайлы включены: UDIM-тайлы каждого материала делят стек слоёв активного тайла, мазки рисуют сразу по ним; каждый тайл сохраняет свой рисунок" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-тайлы включены: UDIM-тайлы каждого материала делят стек слоёв активного тайла, мазки рисуют сразу по ним; каждый тайл сохраняет свой рисунок", + "An agent asks to open {0}.": "Агент просит открыть {0}." } diff --git a/frontend/src/i18n/more16/sv.json b/frontend/src/i18n/more16/sv.json index 703fe56..b67001c 100644 --- a/frontend/src/i18n/more16/sv.json +++ b/frontend/src/i18n/more16/sv.json @@ -15,5 +15,6 @@ "Memory {0}": "Minne {0}", "Reply {0} tokens": "Svar {0} tokens", "Chat {0} tokens": "Chatt {0} tokens", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles på: varje materials UDIM-tiles delar den aktiva tilens lagerstapel och drag målar över dem; varje tile behåller sin egen målning" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-tiles på: varje materials UDIM-tiles delar den aktiva tilens lagerstapel och drag målar över dem; varje tile behåller sin egen målning", + "An agent asks to open {0}.": "En agent ber om att öppna {0}." } diff --git a/frontend/src/i18n/more16/th.json b/frontend/src/i18n/more16/th.json index 628e49e..1d23b31 100644 --- a/frontend/src/i18n/more16/th.json +++ b/frontend/src/i18n/more16/th.json @@ -15,5 +15,6 @@ "Memory {0}": "หน่วยความจำ {0}", "Reply {0} tokens": "การตอบกลับ {0} โทเคน", "Chat {0} tokens": "แชต {0} โทเคน", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "เปิดไทล์ UV: ไทล์ UDIM ของแต่ละแมทีเรียลใช้สแต็กเลเยอร์ของไทล์ที่ใช้งานอยู่ร่วมกัน และการลากพู่กันวาดข้ามไทล์ แต่ละไทล์เก็บงานวาดของตัวเองไว้" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "เปิดไทล์ UV: ไทล์ UDIM ของแต่ละแมทีเรียลใช้สแต็กเลเยอร์ของไทล์ที่ใช้งานอยู่ร่วมกัน และการลากพู่กันวาดข้ามไทล์ แต่ละไทล์เก็บงานวาดของตัวเองไว้", + "An agent asks to open {0}.": "เอเจนต์ขอเปิด {0}" } diff --git a/frontend/src/i18n/more16/tr.json b/frontend/src/i18n/more16/tr.json index 4487ddc..9cfab96 100644 --- a/frontend/src/i18n/more16/tr.json +++ b/frontend/src/i18n/more16/tr.json @@ -15,5 +15,6 @@ "Memory {0}": "Bellek {0}", "Reply {0} tokens": "Yanıt {0} token", "Chat {0} tokens": "Sohbet {0} token", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV karoları açık: her malzemenin UDIM karoları etkin karonun katman yığınını paylaşır ve darbeler bunların üzerinden boyar; her karo kendi boyasını korur" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV karoları açık: her malzemenin UDIM karoları etkin karonun katman yığınını paylaşır ve darbeler bunların üzerinden boyar; her karo kendi boyasını korur", + "An agent asks to open {0}.": "Bir ajan {0} projesini açmak istiyor." } diff --git a/frontend/src/i18n/more16/uk.json b/frontend/src/i18n/more16/uk.json index 8ebe300..5f8d5ba 100644 --- a/frontend/src/i18n/more16/uk.json +++ b/frontend/src/i18n/more16/uk.json @@ -15,5 +15,6 @@ "Memory {0}": "Пам'ять {0}", "Reply {0} tokens": "Відповідь {0} токенів", "Chat {0} tokens": "Чат {0} токенів", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-тайли ввімкнено: UDIM-тайли кожного матеріалу ділять стек шарів активного тайла, мазки малюють одразу по них; кожен тайл зберігає свій малюнок" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV-тайли ввімкнено: UDIM-тайли кожного матеріалу ділять стек шарів активного тайла, мазки малюють одразу по них; кожен тайл зберігає свій малюнок", + "An agent asks to open {0}.": "Агент просить відкрити {0}." } diff --git a/frontend/src/i18n/more16/vi.json b/frontend/src/i18n/more16/vi.json index 6491276..f85fbd2 100644 --- a/frontend/src/i18n/more16/vi.json +++ b/frontend/src/i18n/more16/vi.json @@ -15,5 +15,6 @@ "Memory {0}": "Bộ nhớ {0}", "Reply {0} tokens": "Phản hồi {0} token", "Chat {0} tokens": "Trò chuyện {0} token", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tile UV bật: các tile UDIM của mỗi vật liệu dùng chung stack layer của tile đang dùng và nét vẽ vẽ xuyên qua chúng; mỗi tile giữ nét vẽ của riêng nó" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "Tile UV bật: các tile UDIM của mỗi vật liệu dùng chung stack layer của tile đang dùng và nét vẽ vẽ xuyên qua chúng; mỗi tile giữ nét vẽ của riêng nó", + "An agent asks to open {0}.": "Một tác nhân yêu cầu mở {0}." } diff --git a/frontend/src/i18n/more16/zh-CN.json b/frontend/src/i18n/more16/zh-CN.json index 8a67118..db42408 100644 --- a/frontend/src/i18n/more16/zh-CN.json +++ b/frontend/src/i18n/more16/zh-CN.json @@ -15,5 +15,6 @@ "Memory {0}": "内存 {0}", "Reply {0} tokens": "回复 {0} 个令牌", "Chat {0} tokens": "聊天 {0} 个令牌", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV 图块已开启:每种材质的 UDIM 图块共用当前图块的图层堆栈,笔触跨图块绘制;每个图块保留自己的绘制内容" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV 图块已开启:每种材质的 UDIM 图块共用当前图块的图层堆栈,笔触跨图块绘制;每个图块保留自己的绘制内容", + "An agent asks to open {0}.": "代理请求打开 {0}。" } diff --git a/frontend/src/i18n/more16/zh-TW.json b/frontend/src/i18n/more16/zh-TW.json index 937a92a..e2f31e1 100644 --- a/frontend/src/i18n/more16/zh-TW.json +++ b/frontend/src/i18n/more16/zh-TW.json @@ -15,5 +15,6 @@ "Memory {0}": "記憶體 {0}", "Reply {0} tokens": "回覆 {0} 個權杖", "Chat {0} tokens": "聊天 {0} 個權杖", - "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV 圖磚已開啟:每種材質的 UDIM 圖磚共用目前圖磚的圖層堆疊,筆觸跨圖磚繪製;每個圖磚保留自己的繪製內容" + "UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint": "UV 圖磚已開啟:每種材質的 UDIM 圖磚共用目前圖磚的圖層堆疊,筆觸跨圖磚繪製;每個圖磚保留自己的繪製內容", + "An agent asks to open {0}.": "代理程式要求開啟 {0}。" } diff --git a/frontend/src/i18n/strings.json b/frontend/src/i18n/strings.json index 0a73e87..97bbcda 100644 --- a/frontend/src/i18n/strings.json +++ b/frontend/src/i18n/strings.json @@ -1133,5 +1133,6 @@ "Memory {0}", "Reply {0} tokens", "Chat {0} tokens", -"UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint" +"UV tiles on: the UDIM tiles of each material share the active tile's layer stack and strokes paint across them; each tile keeps its own paint", +"An agent asks to open {0}." ] \ No newline at end of file diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 2c0e8ab..d5eddf4 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -3157,14 +3157,52 @@ function askDiscard(): Promise { return Promise.resolve(false); } if (!changed()) return Promise.resolve(true); - return new Promise((resolve) => { - const d = new Dialog('Discard Changes'); - d.body.appendChild(el('

Painting that is not saved is lost.

')); + return discardDialog().answer; +} + +// One Discard Changes dialog; `note` is a line above the warning, `close` answers Cancel. +function discardDialog(note = ''): { answer: Promise; close: () => void } { + const d = new Dialog('Discard Changes'); + const form = el('

Painting that is not saved is lost.

'); + if (note) { + const line = document.createElement('p'); + line.textContent = note; + form.prepend(line); + } + d.body.appendChild(form); + const answer = new Promise((resolve) => { d.onClose = () => resolve(false); d.action('Cancel', () => d.close(), false); d.action('Discard Changes', () => { resolve(true); d.close(); }, true); - d.open(); }); + d.open(); + return { answer, close: () => d.close() }; +} + +const AGENT_ANSWER_S = { least: 5, most: 600, usual: 120 }; +let agentAsking = false; + +// An agent that would replace unsaved painting waits for the person's answer; Cancel or no answer refuses the call. +async function agentMayDiscard(name: string, within: unknown): Promise { + refuseWhileBusy(); + if (!changed()) return; + if (agentAsking) throw new Error('The window is already asking the person about unsaved changes'); + const raw = within === undefined || within === null ? AGENT_ANSWER_S.usual : Number(within); + if (!Number.isFinite(raw)) throw new Error(`answer_within is a number of seconds from ${AGENT_ANSWER_S.least} to ${AGENT_ANSWER_S.most}`); + const seconds = Math.min(AGENT_ANSWER_S.most, Math.max(AGENT_ANSWER_S.least, raw)); + agentAsking = true; + const ask = discardDialog(`An agent asks to open ${name}.`); + let late = false; + const timer = setTimeout(() => { late = true; ask.close(); }, seconds * 1000); + try { + if (await ask.answer) return; + } finally { + clearTimeout(timer); + agentAsking = false; + } + throw new Error(late + ? `No answer within ${seconds} s: the document has unsaved changes and was kept. Ask the person to save or discard them, then try again` + : 'The person kept the unsaved changes; the project was not opened'); } type Busy = 'export' | 'bake' | 'render' | 'save' | 'open'; @@ -3301,7 +3339,10 @@ const agentLink = new AgentLink({ return hit ? { selected: hit } : { selected: null, note: 'No visible layer paints this point' }; }, save_project: async ({ name }) => saveProjectFile(name === undefined || name === null || name === '' ? await projectIdForSave() : String(name)), - open_project: async ({ name }) => ({ ...(await exclusive('open', () => openProjectFile(String(name)))), ...snapshotState() }), + open_project: async ({ name, answer_within }) => { + await agentMayDiscard(String(name), answer_within); + return { ...(await exclusive('open', () => openProjectFile(String(name)))), ...snapshotState() }; + }, load_mesh: async ({ file, reproject }) => { const name = String(file); if (reproject !== undefined && reproject !== null) setControl('m-reproject', Boolean(reproject), 'change'); diff --git a/frontend/tests/window/test_home_and_library.py b/frontend/tests/window/test_home_and_library.py index aa0317a..b71e1f3 100644 --- a/frontend/tests/window/test_home_and_library.py +++ b/frontend/tests/window/test_home_and_library.py @@ -408,3 +408,62 @@ def test_agent_commands_refuse_a_layer_id_that_does_not_exist(service, context): assert after["result"]["layers"] == before["result"]["layers"] assert after["result"]["active_layer"] == before["result"]["active_layer"] page.close() + + +DISCARD = ".cv-dialog:has(.cv-dialog-title:text-is('Discard Changes'))" + + +def agent(base, command, args=None): + return call(base, "POST", "/api/agent", {"command": command, "args": args or {}, "timeout": STEP_S}) + + +def open_in_background(base, args): + from concurrent.futures import ThreadPoolExecutor + + pool = ThreadPoolExecutor(max_workers=1) + future = pool.submit(agent, base, "open_project", args) + pool.shutdown(wait=False) + return future + + +def layer_names(base): + return [layer["name"] for layer in agent(base, "status")[1]["result"]["layers"]] + + +def test_an_agent_opening_a_project_over_unsaved_painting_waits_for_the_person(service, context): + base = service["base"] + page = open_window(context, base, START + "&agent=1") + wait_for(lambda: call(base, "GET", HEALTH_PATH)[1]["editor_linked"], "the window turned Agent link on") + code, body = agent(base, "save_project") + assert code == 200, body + pid = wait_for(lambda: [p["id"] for p in library(service) if p["saved"]], "the agent's save made a project")[0] + saved = layer_names(base) + + assert agent(base, "add_layer", {"name": "Unsaved"})[0] == 200 + waiting = open_in_background(base, {"name": pid}) + page.locator(DISCARD).wait_for(timeout=STEP_S * 1000) + assert pid in page.text_content(DISCARD + " .cv-dialog-body") + assert not waiting.done(), "the agent call returned before the person answered" + page.click(DISCARD + " .cv-dialog-foot .btn:not(.primary)") + code, body = waiting.result(timeout=STEP_S) + assert code == 422 and "kept" in body["detail"], (code, body) + assert "Unsaved" in layer_names(base), "Cancel kept the unsaved layer" + + waiting = open_in_background(base, {"name": pid, "answer_within": 5}) + page.locator(DISCARD).wait_for(timeout=STEP_S * 1000) + code, body = waiting.result(timeout=STEP_S) + assert code == 422 and "No answer" in body["detail"], (code, body) + page.locator(DISCARD).wait_for(state="detached", timeout=STEP_S * 1000) + assert "Unsaved" in layer_names(base), "a question with no answer changed nothing" + + waiting = open_in_background(base, {"name": pid}) + page.locator(DISCARD).wait_for(timeout=STEP_S * 1000) + page.click(DISCARD + " .cv-dialog-foot .btn.primary") + code, body = waiting.result(timeout=STEP_S) + assert code == 200, (code, body) + assert layer_names(base) == saved, "Discard Changes opened the saved project" + + code, body = agent(base, "open_project", {"name": pid}) + assert code == 200, (code, body) + assert page.locator(DISCARD).count() == 0, "a saved document opens without asking" + page.close() diff --git a/mcp/server.py b/mcp/server.py index 66f5e32..dff3f93 100644 --- a/mcp/server.py +++ b/mcp/server.py @@ -75,9 +75,9 @@ def formsurface_save_project(name: str | None = None) -> dict: @server.tool() -def formsurface_open_project(name: str) -> dict: - """Reopen a project saved with formsurface_save_project: loads its mesh from the workspace meshes folder and restores every texture set's layers, settings and pixels, replacing the open document. Bakes are not stored; run formsurface_bake_maps again before using generators that read them.""" - return call("open_project", {"name": name}, timeout=900) +def formsurface_open_project(name: str, answer_within_seconds: Annotated[int, Field(ge=5, le=600)] = 120) -> dict: + """Reopen a project saved with formsurface_save_project: loads its mesh from the workspace meshes folder and restores every texture set's layers, settings and pixels, replacing the open document. When the open document has unsaved changes, the window asks the person with its Discard Changes dialog and this call waits for the answer: Discard Changes opens the project, Cancel or no answer within answer_within_seconds refuses the call and keeps the document as it is (save it first with formsurface_save_project to open without asking). Other tool calls wait while the person is asked. Bakes are not stored; run formsurface_bake_maps again before using generators that read them.""" + return call("open_project", {"name": name, "answer_within": answer_within_seconds}, timeout=900 + answer_within_seconds) @server.tool() From 76a56f681f37aac30824e6dcbaa871b589ff2a08 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 15:41:42 -0500 Subject: [PATCH 2/2] fix(agents): refuse a project that is not saved before asking about unsaved changes An agent open_project over unsaved changes now checks the library first. A name that is not a saved project is refused at once instead of showing the Discard Changes dialog for a project that could not open. --- .docs/wiki/Painting-with-Agents.md | 2 +- frontend/src/main.ts | 3 +++ frontend/tests/window/test_home_and_library.py | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.docs/wiki/Painting-with-Agents.md b/.docs/wiki/Painting-with-Agents.md index 4d78c1f..592409f 100644 --- a/.docs/wiki/Painting-with-Agents.md +++ b/.docs/wiki/Painting-with-Agents.md @@ -26,7 +26,7 @@ To use an agent outside this folder, `./formsurface agents install` registers th ## Unsaved painting -An agent never throws away painting the person has not saved. When `formsurface_open_project` would replace a document with unsaved changes, the window shows its Discard Changes dialog with a line naming the project the agent asked for, and the agent's call waits. Discard Changes opens the project. Cancel, or no answer within the call's `answer_within_seconds` (120 by default), refuses the call and leaves the document as it was. Other agent calls wait while the dialog is open. A document with no unsaved changes opens without asking. +An agent never throws away painting the person has not saved. When `formsurface_open_project` would replace a document with unsaved changes, the window shows its Discard Changes dialog with a line naming the project the agent asked for, and the agent's call waits. Discard Changes opens the project. Cancel, or no answer within the call's `answer_within_seconds` (120 by default), refuses the call and leaves the document as it was. Other agent calls wait while the dialog is open. A document with no unsaved changes opens without asking. A name that is not a saved project is refused without asking. ## Without an open editor diff --git a/frontend/src/main.ts b/frontend/src/main.ts index d5eddf4..5514f89 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -3183,9 +3183,12 @@ const AGENT_ANSWER_S = { least: 5, most: 600, usual: 120 }; let agentAsking = false; // An agent that would replace unsaved painting waits for the person's answer; Cancel or no answer refuses the call. +// A project that is not saved in the library is refused before the person is asked. async function agentMayDiscard(name: string, within: unknown): Promise { refuseWhileBusy(); if (!changed()) return; + const listed = await projects.projects().catch(() => null); + if (!listed?.projects.some((p) => p.id === name && p.saved)) throw new Error(`No saved project ${name} (save one with File > Save project or formsurface_save_project)`); if (agentAsking) throw new Error('The window is already asking the person about unsaved changes'); const raw = within === undefined || within === null ? AGENT_ANSWER_S.usual : Number(within); if (!Number.isFinite(raw)) throw new Error(`answer_within is a number of seconds from ${AGENT_ANSWER_S.least} to ${AGENT_ANSWER_S.most}`); diff --git a/frontend/tests/window/test_home_and_library.py b/frontend/tests/window/test_home_and_library.py index b71e1f3..5f9db05 100644 --- a/frontend/tests/window/test_home_and_library.py +++ b/frontend/tests/window/test_home_and_library.py @@ -440,6 +440,10 @@ def test_an_agent_opening_a_project_over_unsaved_painting_waits_for_the_person(s saved = layer_names(base) assert agent(base, "add_layer", {"name": "Unsaved"})[0] == 200 + code, body = agent(base, "open_project", {"name": "no-such-project"}) + assert code == 422 and "No saved project" in body["detail"], (code, body) + assert page.locator(DISCARD).count() == 0, "a project that cannot open is refused without asking" + waiting = open_in_background(base, {"name": pid}) page.locator(DISCARD).wait_for(timeout=STEP_S * 1000) assert pid in page.text_content(DISCARD + " .cv-dialog-body")