diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4d9d4331c9..ebb4b7f4d0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.865.0" + ".": "1.866.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 62677c823f..e893e893fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## [1.866.0](https://github.com/windmill-labs/windmill/compare/v1.865.0...v1.866.0) (2026-11-10) + + +### Features + +* configurable columns and csv/json/xlsx export on the runs page ([#12302](https://github.com/windmill-labs/windmill/issues/12302)) ([47005d5](https://github.com/windmill-labs/windmill/commit/47005d5fcfe43251b2b184fbe625e7790b9a2adc)) +* show when each job started in the ai session jobs popover ([#12301](https://github.com/windmill-labs/windmill/issues/12301)) ([8b40416](https://github.com/windmill-labs/windmill/commit/8b404164e3487aead898d439de39993e313125be)) + + +### Bug Fixes + +* keep flow nodes on rename and stop masking flow load errors ([#12303](https://github.com/windmill-labs/windmill/issues/12303)) ([3bf4864](https://github.com/windmill-labs/windmill/commit/3bf486415bd88ffea9787f004874d15bbd433265)) +* never break running flows when their flow is deleted ([#12306](https://github.com/windmill-labs/windmill/issues/12306)) ([e3ff8be](https://github.com/windmill-labs/windmill/commit/e3ff8bee3d1e36c5ed1ea4982e8c6e02e24f7b50)) +* pin rsa to 0.9 so the lock refresh stops pulling 0.10 ([#12299](https://github.com/windmill-labs/windmill/issues/12299)) ([188b6cc](https://github.com/windmill-labs/windmill/commit/188b6ccf151e13aeef6d6a25c565ce59f7f02550)) +* read the git sync callback script with the runnable parser ([#12304](https://github.com/windmill-labs/windmill/issues/12304)) ([2e422b4](https://github.com/windmill-labs/windmill/commit/2e422b497ee6f9691fe14812af1cb3646f928b34)) + + +### Performance Improvements + +* list audit logs by timestamp so only recent partitions are read ([#12309](https://github.com/windmill-labs/windmill/issues/12309)) ([a6ec7d0](https://github.com/windmill-labs/windmill/commit/a6ec7d0c18c0168bcda1ba6ccc9216b2bd5077a6)) + ## [1.865.0](https://github.com/windmill-labs/windmill/compare/v1.864.1...v1.865.0) (2026-11-09) diff --git a/backend/.sqlx/query-0deba337ceb95584bfd4fa280310eb31e21c1f7b23210bc65595a86b53c2908d.json b/backend/.sqlx/query-0deba337ceb95584bfd4fa280310eb31e21c1f7b23210bc65595a86b53c2908d.json new file mode 100644 index 0000000000..a86c4392ef --- /dev/null +++ b/backend/.sqlx/query-0deba337ceb95584bfd4fa280310eb31e21c1f7b23210bc65595a86b53c2908d.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO flow_version\n (workspace_id, path, value, schema, created_by)\n\n SELECT v.workspace_id, v.path, v.value, v.schema, v.created_by\n FROM flow_version v\n JOIN flow f ON f.workspace_id = v.workspace_id AND f.path = v.path\n WHERE v.path = $1 AND v.workspace_id = $2 AND v.id = $3\n FOR SHARE OF f\n\n RETURNING id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Int8" + ] + }, + "nullable": [ + false + ] + }, + "hash": "0deba337ceb95584bfd4fa280310eb31e21c1f7b23210bc65595a86b53c2908d" +} diff --git a/backend/.sqlx/query-120756fe619d9497cb2cf0a40687d51895cc0f1294be9e5ad106ea4de8cbb2b5.json b/backend/.sqlx/query-120756fe619d9497cb2cf0a40687d51895cc0f1294be9e5ad106ea4de8cbb2b5.json deleted file mode 100644 index 0c15cfc5f9..0000000000 --- a/backend/.sqlx/query-120756fe619d9497cb2cf0a40687d51895cc0f1294be9e5ad106ea4de8cbb2b5.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE flow_node SET path = $1 WHERE path = $2 AND workspace_id = $3", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Varchar", - "Text", - "Text" - ] - }, - "nullable": [] - }, - "hash": "120756fe619d9497cb2cf0a40687d51895cc0f1294be9e5ad106ea4de8cbb2b5" -} diff --git a/backend/.sqlx/query-14c2784a68f06e7349941671abe5a9108b6f32490cb61b14de71102bb305f71d.json b/backend/.sqlx/query-14c2784a68f06e7349941671abe5a9108b6f32490cb61b14de71102bb305f71d.json deleted file mode 100644 index d7ef4e04e0..0000000000 --- a/backend/.sqlx/query-14c2784a68f06e7349941671abe5a9108b6f32490cb61b14de71102bb305f71d.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH RECURSIVE chain(id, parent_job, flow_innermost_root_job, runnable_id, runnable_path, raw_flow, depth) AS (\n SELECT id, parent_job, flow_innermost_root_job, runnable_id, runnable_path, raw_flow, 0\n FROM v2_job\n WHERE id = $1 AND workspace_id = $2\n UNION ALL\n SELECT j.id, j.parent_job, j.flow_innermost_root_job, j.runnable_id, j.runnable_path, j.raw_flow, c.depth + 1\n FROM v2_job j\n JOIN chain c\n ON j.id = COALESCE(c.flow_innermost_root_job, c.parent_job)\n WHERE j.workspace_id = $2 AND c.depth < $3\n )\n SELECT\n CASE\n WHEN flow_version.id IS NOT NULL THEN\n flow_version.value -> 'flow_env'\n ELSE\n chain.raw_flow -> 'flow_env'\n END AS \"flow_env: Json>>\"\n FROM chain\n LEFT JOIN flow_version\n ON flow_version.id = chain.runnable_id\n AND flow_version.path = chain.runnable_path\n AND flow_version.workspace_id = $2\n WHERE (CASE\n WHEN flow_version.id IS NOT NULL THEN flow_version.value -> 'flow_env'\n ELSE chain.raw_flow -> 'flow_env'\n END) IS NOT NULL\n ORDER BY chain.depth ASC\n LIMIT 1", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "flow_env: Json>>", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Text", - "Int4" - ] - }, - "nullable": [ - null - ] - }, - "hash": "14c2784a68f06e7349941671abe5a9108b6f32490cb61b14de71102bb305f71d" -} diff --git a/backend/.sqlx/query-1642ab69bebc6cde3760a4124fdb1192d9d25ebd688bf39806e92f8fe6e84529.json b/backend/.sqlx/query-1642ab69bebc6cde3760a4124fdb1192d9d25ebd688bf39806e92f8fe6e84529.json new file mode 100644 index 0000000000..aed565f5e9 --- /dev/null +++ b/backend/.sqlx/query-1642ab69bebc6cde3760a4124fdb1192d9d25ebd688bf39806e92f8fe6e84529.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT policy->>'execution_mode' = 'anonymous' FROM app\n WHERE path = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "1642ab69bebc6cde3760a4124fdb1192d9d25ebd688bf39806e92f8fe6e84529" +} diff --git a/backend/.sqlx/query-1d995dd5a094631ae96c16d68026fdeb22714af38162e87c02b052a5b8ec2645.json b/backend/.sqlx/query-1d995dd5a094631ae96c16d68026fdeb22714af38162e87c02b052a5b8ec2645.json deleted file mode 100644 index 4ae3cea3ff..0000000000 --- a/backend/.sqlx/query-1d995dd5a094631ae96c16d68026fdeb22714af38162e87c02b052a5b8ec2645.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM trashbin WHERE workspace_id = $1 AND id = $2", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text", - "Int8" - ] - }, - "nullable": [] - }, - "hash": "1d995dd5a094631ae96c16d68026fdeb22714af38162e87c02b052a5b8ec2645" -} diff --git a/backend/.sqlx/query-29fba245ac4b45d904ee50f424828e8d181651d7a4324c5b42c34de5b747ab95.json b/backend/.sqlx/query-29fba245ac4b45d904ee50f424828e8d181651d7a4324c5b42c34de5b747ab95.json new file mode 100644 index 0000000000..e01828cb4e --- /dev/null +++ b/backend/.sqlx/query-29fba245ac4b45d904ee50f424828e8d181651d7a4324c5b42c34de5b747ab95.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM flow_version WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "29fba245ac4b45d904ee50f424828e8d181651d7a4324c5b42c34de5b747ab95" +} diff --git a/backend/.sqlx/query-bae31609123da68d16bea8e0f1c4624403b6f97e13f13f056501fe2f4efb0f06.json b/backend/.sqlx/query-2d2a3beec12407c9a7ff29ad83a03d6cdd6a5a399a3a026ade25ac1bdb8a8c9b.json similarity index 53% rename from backend/.sqlx/query-bae31609123da68d16bea8e0f1c4624403b6f97e13f13f056501fe2f4efb0f06.json rename to backend/.sqlx/query-2d2a3beec12407c9a7ff29ad83a03d6cdd6a5a399a3a026ade25ac1bdb8a8c9b.json index bc0cc1a797..9eff1da00a 100644 --- a/backend/.sqlx/query-bae31609123da68d16bea8e0f1c4624403b6f97e13f13f056501fe2f4efb0f06.json +++ b/backend/.sqlx/query-2d2a3beec12407c9a7ff29ad83a03d6cdd6a5a399a3a026ade25ac1bdb8a8c9b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "DELETE FROM trashbin WHERE workspace_id = $1", + "query": "DELETE FROM flow_node WHERE workspace_id = $1", "describe": { "columns": [], "parameters": { @@ -10,5 +10,5 @@ }, "nullable": [] }, - "hash": "bae31609123da68d16bea8e0f1c4624403b6f97e13f13f056501fe2f4efb0f06" + "hash": "2d2a3beec12407c9a7ff29ad83a03d6cdd6a5a399a3a026ade25ac1bdb8a8c9b" } diff --git a/backend/.sqlx/query-3453c0b7dd3c4d2c9bc639f379901741955502c9345e82a9b7fbbf3d3c7ab517.json b/backend/.sqlx/query-3453c0b7dd3c4d2c9bc639f379901741955502c9345e82a9b7fbbf3d3c7ab517.json deleted file mode 100644 index 5893b08c81..0000000000 --- a/backend/.sqlx/query-3453c0b7dd3c4d2c9bc639f379901741955502c9345e82a9b7fbbf3d3c7ab517.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM trashbin WHERE expires_at <= now()", - "describe": { - "columns": [], - "parameters": { - "Left": [] - }, - "nullable": [] - }, - "hash": "3453c0b7dd3c4d2c9bc639f379901741955502c9345e82a9b7fbbf3d3c7ab517" -} diff --git a/backend/.sqlx/query-5e312a063a660a1d4da462b8d6e8493a674bcad0f0a4900323475f68d549c79c.json b/backend/.sqlx/query-5e312a063a660a1d4da462b8d6e8493a674bcad0f0a4900323475f68d549c79c.json new file mode 100644 index 0000000000..46c47084d7 --- /dev/null +++ b/backend/.sqlx/query-5e312a063a660a1d4da462b8d6e8493a674bcad0f0a4900323475f68d549c79c.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH RECURSIVE chain(id, parent_job, flow_innermost_root_job, runnable_id, kind, raw_flow, depth) AS (\n SELECT id, parent_job, flow_innermost_root_job, runnable_id, kind, raw_flow, 0\n FROM v2_job\n WHERE id = $1 AND workspace_id = $2\n UNION ALL\n SELECT j.id, j.parent_job, j.flow_innermost_root_job, j.runnable_id, j.kind, j.raw_flow, c.depth + 1\n FROM v2_job j\n JOIN chain c\n ON j.id = COALESCE(c.flow_innermost_root_job, c.parent_job)\n WHERE j.workspace_id = $2 AND c.depth < $3\n )\n SELECT\n CASE\n WHEN flow_version.id IS NOT NULL THEN\n flow_version.value -> 'flow_env'\n ELSE\n chain.raw_flow -> 'flow_env'\n END AS \"flow_env: Json>>\"\n FROM chain\n LEFT JOIN flow_version\n ON flow_version.id = chain.runnable_id\n AND chain.kind IN ('flow', 'unassigned_flow')\n AND flow_version.workspace_id = $2\n WHERE (CASE\n WHEN flow_version.id IS NOT NULL THEN flow_version.value -> 'flow_env'\n ELSE chain.raw_flow -> 'flow_env'\n END) IS NOT NULL\n ORDER BY chain.depth ASC\n LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "flow_env: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Int4" + ] + }, + "nullable": [ + null + ] + }, + "hash": "5e312a063a660a1d4da462b8d6e8493a674bcad0f0a4900323475f68d549c79c" +} diff --git a/backend/.sqlx/query-ed12d54e9cdc18672bbb34d2500adc18b72323e06a1f32e7a1a7589649888927.json b/backend/.sqlx/query-6842391724392d3244f98c8fb8d443f8c19ba123fab9abccba5be75b0e677964.json similarity index 50% rename from backend/.sqlx/query-ed12d54e9cdc18672bbb34d2500adc18b72323e06a1f32e7a1a7589649888927.json rename to backend/.sqlx/query-6842391724392d3244f98c8fb8d443f8c19ba123fab9abccba5be75b0e677964.json index 0088122f66..7c6ee69fae 100644 --- a/backend/.sqlx/query-ed12d54e9cdc18672bbb34d2500adc18b72323e06a1f32e7a1a7589649888927.json +++ b/backend/.sqlx/query-6842391724392d3244f98c8fb8d443f8c19ba123fab9abccba5be75b0e677964.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE flow_node SET path = REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3", + "query": "UPDATE flow_node SET path = REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3 AND NOT EXISTS (SELECT 1 FROM flow_node d WHERE d.workspace_id = $3 AND d.hash_v2 = flow_node.hash_v2 AND d.path = REGEXP_REPLACE(flow_node.path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1'))", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "ed12d54e9cdc18672bbb34d2500adc18b72323e06a1f32e7a1a7589649888927" + "hash": "6842391724392d3244f98c8fb8d443f8c19ba123fab9abccba5be75b0e677964" } diff --git a/backend/.sqlx/query-d1a33665e47e10c4f992e018e234496935fc3415c7aa00642626494a2940cdf2.json b/backend/.sqlx/query-6cdd377dc2987bd46604b187ce7a54c7ce282621ef23ae0b8427b98474b41fef.json similarity index 51% rename from backend/.sqlx/query-d1a33665e47e10c4f992e018e234496935fc3415c7aa00642626494a2940cdf2.json rename to backend/.sqlx/query-6cdd377dc2987bd46604b187ce7a54c7ce282621ef23ae0b8427b98474b41fef.json index 08862eab8a..bfe83cdb18 100644 --- a/backend/.sqlx/query-d1a33665e47e10c4f992e018e234496935fc3415c7aa00642626494a2940cdf2.json +++ b/backend/.sqlx/query-6cdd377dc2987bd46604b187ce7a54c7ce282621ef23ae0b8427b98474b41fef.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE flow_node SET path = REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3", + "query": "UPDATE flow_node SET path = REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3 AND NOT EXISTS (SELECT 1 FROM flow_node d WHERE d.workspace_id = $3 AND d.hash_v2 = flow_node.hash_v2 AND d.path = REGEXP_REPLACE(flow_node.path, 'u/' || $2 || '/(.*)', $1 || '/\\1'))", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "d1a33665e47e10c4f992e018e234496935fc3415c7aa00642626494a2940cdf2" + "hash": "6cdd377dc2987bd46604b187ce7a54c7ce282621ef23ae0b8427b98474b41fef" } diff --git a/backend/.sqlx/query-72597c62d560fcb8604eb5307bbc0442e976e96f13721ffdd63f0739fce516cd.json b/backend/.sqlx/query-72597c62d560fcb8604eb5307bbc0442e976e96f13721ffdd63f0739fce516cd.json new file mode 100644 index 0000000000..af1f7a0277 --- /dev/null +++ b/backend/.sqlx/query-72597c62d560fcb8604eb5307bbc0442e976e96f13721ffdd63f0739fce516cd.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE flow_node n SET path = $1 WHERE path = $2 AND workspace_id = $3\n AND NOT EXISTS (\n SELECT 1 FROM flow_node d\n WHERE d.path = $1 AND d.workspace_id = $3 AND d.hash_v2 = n.hash_v2\n )", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "72597c62d560fcb8604eb5307bbc0442e976e96f13721ffdd63f0739fce516cd" +} diff --git a/backend/.sqlx/query-8aca507d5a1a548ddce49244b1222bbca953b9436f3b9541677e664c84d443ed.json b/backend/.sqlx/query-8aca507d5a1a548ddce49244b1222bbca953b9436f3b9541677e664c84d443ed.json new file mode 100644 index 0000000000..399d21acaa --- /dev/null +++ b/backend/.sqlx/query-8aca507d5a1a548ddce49244b1222bbca953b9436f3b9541677e664c84d443ed.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE app SET policy = jsonb_set(policy, '{execution_mode}', '\"publisher\"')\n WHERE workspace_id = $1 AND policy->>'execution_mode' = 'anonymous'", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "8aca507d5a1a548ddce49244b1222bbca953b9436f3b9541677e664c84d443ed" +} diff --git a/backend/.sqlx/query-a6a973dcd92d2e40fd9a1c1be42052fcd350bd47ee4f63832448b6e6f0f472f0.json b/backend/.sqlx/query-a6a973dcd92d2e40fd9a1c1be42052fcd350bd47ee4f63832448b6e6f0f472f0.json deleted file mode 100644 index 1c396d38fd..0000000000 --- a/backend/.sqlx/query-a6a973dcd92d2e40fd9a1c1be42052fcd350bd47ee4f63832448b6e6f0f472f0.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO flow_version\n (workspace_id, path, value, schema, created_by)\n\n SELECT workspace_id, path, value, schema, created_by\n FROM flow_version WHERE path = $1 AND workspace_id = $2 AND id = $3\n\n RETURNING id\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Text", - "Text", - "Int8" - ] - }, - "nullable": [ - false - ] - }, - "hash": "a6a973dcd92d2e40fd9a1c1be42052fcd350bd47ee4f63832448b6e6f0f472f0" -} diff --git a/backend/.sqlx/query-c98a28cdeced035b21b8893041c4f94e2564a609eb5b8b9c562a0dbded4d5b96.json b/backend/.sqlx/query-b840d72656c29477d2c4554d24aa40ad9224be03c4033f0bab943fb78e92ff57.json similarity index 85% rename from backend/.sqlx/query-c98a28cdeced035b21b8893041c4f94e2564a609eb5b8b9c562a0dbded4d5b96.json rename to backend/.sqlx/query-b840d72656c29477d2c4554d24aa40ad9224be03c4033f0bab943fb78e92ff57.json index ed68e38b67..5f4a77bf9f 100644 --- a/backend/.sqlx/query-c98a28cdeced035b21b8893041c4f94e2564a609eb5b8b9c562a0dbded4d5b96.json +++ b/backend/.sqlx/query-b840d72656c29477d2c4554d24aa40ad9224be03c4033f0bab943fb78e92ff57.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT id, workspace_id, path, value, schema, created_by, created_at\n FROM flow_version\n WHERE workspace_id = $1\n ORDER BY path, created_at", + "query": "SELECT id, workspace_id, path, value, schema, created_by, created_at\n FROM flow_version\n WHERE workspace_id = $1\n AND NOT starts_with(path, '__deleted/')\n ORDER BY path, created_at", "describe": { "columns": [ { @@ -54,5 +54,5 @@ false ] }, - "hash": "c98a28cdeced035b21b8893041c4f94e2564a609eb5b8b9c562a0dbded4d5b96" + "hash": "b840d72656c29477d2c4554d24aa40ad9224be03c4033f0bab943fb78e92ff57" } diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 35d2df0130..75c2466a93 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "arc-swap" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4c94f57a570fce5d381be3289b3f79aef6332d72948fe82ab5772e423ccf92" +checksum = "84a22b5d51209f6de83d37a0b33d320acb8da88823e42a94c075140708f032a5" dependencies = [ "rustversion", ] @@ -2858,9 +2858,9 @@ checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853" [[package]] name = "crc32fast" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" dependencies = [ "cfg-if", ] @@ -7254,9 +7254,9 @@ checksum = "4754a1731458af0443709c9667302793d3f63cc90ec4ba4c8259f2b9515478e5" [[package]] name = "jiff" -version = "0.2.41" +version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcefdcefac59ac8f8401852e3427d55610481fc41e6625c39bac62d2d771623a" +checksum = "fefca06093eeaed707a905795e68206da0edca4edef23d2a3997a3ddbee462aa" dependencies = [ "jiff-core", "jiff-static", @@ -7280,9 +7280,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.41" +version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203edf9b0ce4083ec8fbf4adc823eac89768ea994b4953fc0dab1b90083234dd" +checksum = "41d3213549742662eea1a18e6c5af9be5dfbabeb7611ab71356a54928ec398f0" dependencies = [ "jiff-core", "proc-macro2", @@ -7831,9 +7831,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.32" +version = "1.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69965d2409bff8c8cea3829009fff66a86f05a0570656552ef70f616e8e4bd85" +checksum = "fee3f59f4321dab0c78d828942e7aa09d0bd8ad6e78a501977e6bf3d02938045" dependencies = [ "cc", "libc", @@ -9622,9 +9622,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8db75153506001cb36ed924f08cadc862eb3f8c4d0d534139f29074769d7660" +checksum = "5ec53fd1d256900a9a771bf2720d42cef6f8bc91b4e25065fbd291e3e7222576" dependencies = [ "memchr", "pest_stack_guard", @@ -9633,9 +9633,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20aa17e11fb35664b67d5214a0afac57a360d231b6ec53d6eba0700b27d933b4" +checksum = "adcf794fd301ddc20818a6b4de85ed507f4b45300245cec948982e69e12e3bd7" dependencies = [ "pest", "pest_generator", @@ -9643,9 +9643,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626ec5afccf44ccbfeb2b232316510bb55b4bf34d891afcb0fb07d2b17d7fe9d" +checksum = "c3073afae5db334c25dea9fc3e230a4f191e920c1df080cb9c0b37c9ce1dbb41" dependencies = [ "pest", "pest_meta", @@ -9656,9 +9656,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.9.5" +version = "2.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3f45b6caa65c1b08186832745159c2529994146340a7bf44168095469720f5d" +checksum = "7bc7f614b3742541642af1685faaa910bf6333e3cd3729c2cccd118146a57327" dependencies = [ "pest", ] @@ -15601,7 +15601,7 @@ dependencies = [ [[package]] name = "windmill" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-nats", @@ -15691,7 +15691,7 @@ dependencies = [ [[package]] name = "windmill-ai" -version = "1.865.0" +version = "1.866.0" dependencies = [ "async-stream", "async-trait", @@ -15726,7 +15726,7 @@ dependencies = [ [[package]] name = "windmill-alerting" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -15739,7 +15739,7 @@ dependencies = [ [[package]] name = "windmill-api" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "argon2", @@ -15881,7 +15881,7 @@ dependencies = [ [[package]] name = "windmill-api-agent-workers" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -15905,7 +15905,7 @@ dependencies = [ [[package]] name = "windmill-api-assets" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -15922,7 +15922,7 @@ dependencies = [ [[package]] name = "windmill-api-auth" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -15948,7 +15948,7 @@ dependencies = [ [[package]] name = "windmill-api-client" -version = "1.865.0" +version = "1.866.0" dependencies = [ "reqwest 0.12.28", "serde", @@ -15958,7 +15958,7 @@ dependencies = [ [[package]] name = "windmill-api-configs" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -15975,7 +15975,7 @@ dependencies = [ [[package]] name = "windmill-api-debug" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "base64 0.22.1", @@ -15997,7 +15997,7 @@ dependencies = [ [[package]] name = "windmill-api-embeddings" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -16020,7 +16020,7 @@ dependencies = [ [[package]] name = "windmill-api-flow-conversations" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16036,7 +16036,7 @@ dependencies = [ [[package]] name = "windmill-api-flows" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16058,7 +16058,7 @@ dependencies = [ [[package]] name = "windmill-api-groups" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16080,7 +16080,7 @@ dependencies = [ [[package]] name = "windmill-api-inputs" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16094,7 +16094,7 @@ dependencies = [ [[package]] name = "windmill-api-integration-tests" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-nats", @@ -16130,7 +16130,7 @@ dependencies = [ [[package]] name = "windmill-api-jobs" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -16156,7 +16156,7 @@ dependencies = [ [[package]] name = "windmill-api-npm-proxy" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16184,7 +16184,7 @@ dependencies = [ [[package]] name = "windmill-api-openapi" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -16206,7 +16206,7 @@ dependencies = [ [[package]] name = "windmill-api-schedule" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16225,7 +16225,7 @@ dependencies = [ [[package]] name = "windmill-api-scripts" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -16267,7 +16267,7 @@ dependencies = [ [[package]] name = "windmill-api-settings" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -16297,7 +16297,7 @@ dependencies = [ [[package]] name = "windmill-api-sse" -version = "1.865.0" +version = "1.866.0" dependencies = [ "lazy_static", "serde", @@ -16309,7 +16309,7 @@ dependencies = [ [[package]] name = "windmill-api-users" -version = "1.865.0" +version = "1.866.0" dependencies = [ "argon2", "axum", @@ -16333,7 +16333,7 @@ dependencies = [ [[package]] name = "windmill-api-workers" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16348,7 +16348,7 @@ dependencies = [ [[package]] name = "windmill-api-workspaces" -version = "1.865.0" +version = "1.866.0" dependencies = [ "axum", "chrono", @@ -16387,7 +16387,7 @@ dependencies = [ [[package]] name = "windmill-audit" -version = "1.865.0" +version = "1.866.0" dependencies = [ "chrono", "lazy_static", @@ -16402,7 +16402,7 @@ dependencies = [ [[package]] name = "windmill-autoscaling" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "axum", @@ -16421,7 +16421,7 @@ dependencies = [ [[package]] name = "windmill-common" -version = "1.865.0" +version = "1.866.0" dependencies = [ "aes-gcm", "aho-corasick", @@ -16540,7 +16540,7 @@ dependencies = [ [[package]] name = "windmill-dep-map" -version = "1.865.0" +version = "1.866.0" dependencies = [ "chrono", "futures", @@ -16560,7 +16560,7 @@ dependencies = [ [[package]] name = "windmill-git-sync" -version = "1.865.0" +version = "1.866.0" dependencies = [ "regex", "serde", @@ -16577,7 +16577,7 @@ dependencies = [ [[package]] name = "windmill-indexer" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "astral-tokio-tar", @@ -16604,7 +16604,7 @@ dependencies = [ [[package]] name = "windmill-jseval" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "futures", @@ -16621,7 +16621,7 @@ dependencies = [ [[package]] name = "windmill-macros" -version = "1.865.0" +version = "1.866.0" dependencies = [ "itertools 0.14.0", "lazy_static", @@ -16637,7 +16637,7 @@ dependencies = [ [[package]] name = "windmill-mcp" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -16659,7 +16659,7 @@ dependencies = [ [[package]] name = "windmill-native-triggers" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -16691,7 +16691,7 @@ dependencies = [ [[package]] name = "windmill-oauth" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "arc-swap", @@ -16716,7 +16716,7 @@ dependencies = [ [[package]] name = "windmill-object-store" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-stream", @@ -16752,7 +16752,7 @@ dependencies = [ [[package]] name = "windmill-operator" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "futures", @@ -16771,7 +16771,7 @@ dependencies = [ [[package]] name = "windmill-parser" -version = "1.865.0" +version = "1.866.0" dependencies = [ "convert_case 0.6.0", "serde", @@ -16780,7 +16780,7 @@ dependencies = [ [[package]] name = "windmill-parser-bash" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -16792,7 +16792,7 @@ dependencies = [ [[package]] name = "windmill-parser-csharp" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde_json", @@ -16804,7 +16804,7 @@ dependencies = [ [[package]] name = "windmill-parser-go" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "gosyn", @@ -16816,7 +16816,7 @@ dependencies = [ [[package]] name = "windmill-parser-graphql" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -16828,7 +16828,7 @@ dependencies = [ [[package]] name = "windmill-parser-java" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde_json", @@ -16840,7 +16840,7 @@ dependencies = [ [[package]] name = "windmill-parser-nu" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "nu-parser", @@ -16851,7 +16851,7 @@ dependencies = [ [[package]] name = "windmill-parser-php" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -16862,7 +16862,7 @@ dependencies = [ [[package]] name = "windmill-parser-py" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -16874,7 +16874,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-asset" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -16885,7 +16885,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-imports" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-recursion", @@ -16908,7 +16908,7 @@ dependencies = [ [[package]] name = "windmill-parser-r" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde_json", @@ -16920,7 +16920,7 @@ dependencies = [ [[package]] name = "windmill-parser-ruby" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -16934,7 +16934,7 @@ dependencies = [ [[package]] name = "windmill-parser-rust" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -16951,7 +16951,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -16964,7 +16964,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql-asset" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde", @@ -16976,7 +16976,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -16994,7 +16994,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts-asset" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde-wasm-bindgen", @@ -17010,7 +17010,7 @@ dependencies = [ [[package]] name = "windmill-parser-wac" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -17027,7 +17027,7 @@ dependencies = [ [[package]] name = "windmill-parser-yaml" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -17041,7 +17041,7 @@ dependencies = [ [[package]] name = "windmill-queue" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-recursion", @@ -17079,7 +17079,7 @@ dependencies = [ [[package]] name = "windmill-runtime-nativets" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "const_format", @@ -17117,7 +17117,7 @@ dependencies = [ [[package]] name = "windmill-sql-datatype-parser-wasm" -version = "1.865.0" +version = "1.866.0" dependencies = [ "getrandom 0.3.4", "wasm-bindgen", @@ -17128,7 +17128,7 @@ dependencies = [ [[package]] name = "windmill-store" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-recursion", @@ -17163,7 +17163,7 @@ dependencies = [ [[package]] name = "windmill-test-utils" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17187,7 +17187,7 @@ dependencies = [ [[package]] name = "windmill-trigger" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17220,7 +17220,7 @@ dependencies = [ [[package]] name = "windmill-trigger-amqp" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17247,7 +17247,7 @@ dependencies = [ [[package]] name = "windmill-trigger-azure" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17280,7 +17280,7 @@ dependencies = [ [[package]] name = "windmill-trigger-email" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17300,7 +17300,7 @@ dependencies = [ [[package]] name = "windmill-trigger-gcp" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17334,7 +17334,7 @@ dependencies = [ [[package]] name = "windmill-trigger-http" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17371,7 +17371,7 @@ dependencies = [ [[package]] name = "windmill-trigger-kafka" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17394,7 +17394,7 @@ dependencies = [ [[package]] name = "windmill-trigger-mqtt" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17418,7 +17418,7 @@ dependencies = [ [[package]] name = "windmill-trigger-nats" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-nats", @@ -17442,7 +17442,7 @@ dependencies = [ [[package]] name = "windmill-trigger-postgres" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17477,7 +17477,7 @@ dependencies = [ [[package]] name = "windmill-trigger-sqs" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17505,7 +17505,7 @@ dependencies = [ [[package]] name = "windmill-trigger-websocket" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-trait", @@ -17531,7 +17531,7 @@ dependencies = [ [[package]] name = "windmill-types" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "bitflags 2.13.2", @@ -17550,7 +17550,7 @@ dependencies = [ [[package]] name = "windmill-worker" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-once-cell", @@ -17668,7 +17668,7 @@ dependencies = [ [[package]] name = "windmill-worker-volumes" -version = "1.865.0" +version = "1.866.0" dependencies = [ "bytes", "futures", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 8b831307d6..6b84a24949 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windmill" -version = "1.865.0" +version = "1.866.0" authors.workspace = true edition.workspace = true @@ -88,7 +88,7 @@ members = [ exclude = ["./windmill-duckdb-ffi-internal", "./parsers/windmill-parser-wasm"] [workspace.package] -version = "1.865.0" +version = "1.866.0" authors = ["Ruben Fiszel "] edition = "2021" diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 46be019f85..7fe20e438b 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -effb55d778943537b96a9b0af26c2e24ca8b4686 +d7d509d0955c52f83afd0bf8b61a0e811162c16f diff --git a/backend/migrations/20261109211607_keep_flow_versions_on_flow_delete.down.sql b/backend/migrations/20261109211607_keep_flow_versions_on_flow_delete.down.sql new file mode 100644 index 0000000000..8446a88527 --- /dev/null +++ b/backend/migrations/20261109211607_keep_flow_versions_on_flow_delete.down.sql @@ -0,0 +1,6 @@ +DELETE FROM flow_version v +WHERE NOT EXISTS (SELECT 1 FROM flow f WHERE f.workspace_id = v.workspace_id AND f.path = v.path); +ALTER TABLE flow_version ADD CONSTRAINT flow_version_workspace_id_path_fkey + FOREIGN KEY (workspace_id, path) REFERENCES flow (workspace_id, path) ON DELETE CASCADE; +-- flow_node's constraint is not restored: a node left at a deleted flow's path can be +-- shared by content with a live flow's versions, so deleting orphans could break that flow. diff --git a/backend/migrations/20261109211607_keep_flow_versions_on_flow_delete.up.sql b/backend/migrations/20261109211607_keep_flow_versions_on_flow_delete.up.sql new file mode 100644 index 0000000000..e28682a114 --- /dev/null +++ b/backend/migrations/20261109211607_keep_flow_versions_on_flow_delete.up.sql @@ -0,0 +1,5 @@ +-- A deleted flow's versions and nodes outlive its row so that runs in flight can finish: +-- its versions are set aside (trashbin::set_aside_flow_versions) and purged with its trash +-- entry, its nodes stay until the workspace is deleted. +ALTER TABLE flow_version DROP CONSTRAINT IF EXISTS flow_version_workspace_id_path_fkey; +ALTER TABLE flow_node DROP CONSTRAINT IF EXISTS flow_node_path_workspace_id_fkey; diff --git a/backend/parsers/windmill-parser-wasm/Cargo.lock b/backend/parsers/windmill-parser-wasm/Cargo.lock index c446a76567..b62513aef0 100644 --- a/backend/parsers/windmill-parser-wasm/Cargo.lock +++ b/backend/parsers/windmill-parser-wasm/Cargo.lock @@ -6340,7 +6340,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windmill-common" -version = "1.865.0" +version = "1.866.0" dependencies = [ "aes-gcm", "aho-corasick", @@ -6430,7 +6430,7 @@ dependencies = [ [[package]] name = "windmill-macros" -version = "1.865.0" +version = "1.866.0" dependencies = [ "proc-macro2", "quote", @@ -6442,7 +6442,7 @@ dependencies = [ [[package]] name = "windmill-parser" -version = "1.865.0" +version = "1.866.0" dependencies = [ "convert_case", "serde", @@ -6451,7 +6451,7 @@ dependencies = [ [[package]] name = "windmill-parser-bash" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -6463,7 +6463,7 @@ dependencies = [ [[package]] name = "windmill-parser-csharp" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde_json", @@ -6475,7 +6475,7 @@ dependencies = [ [[package]] name = "windmill-parser-go" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "gosyn", @@ -6487,7 +6487,7 @@ dependencies = [ [[package]] name = "windmill-parser-graphql" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -6499,7 +6499,7 @@ dependencies = [ [[package]] name = "windmill-parser-java" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde_json", @@ -6511,7 +6511,7 @@ dependencies = [ [[package]] name = "windmill-parser-nu" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "nu-parser", @@ -6522,7 +6522,7 @@ dependencies = [ [[package]] name = "windmill-parser-php" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -6533,7 +6533,7 @@ dependencies = [ [[package]] name = "windmill-parser-py" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "itertools 0.14.0", @@ -6545,7 +6545,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-asset" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -6556,7 +6556,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-imports" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "async-recursion", @@ -6579,7 +6579,7 @@ dependencies = [ [[package]] name = "windmill-parser-r" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde_json", @@ -6591,7 +6591,7 @@ dependencies = [ [[package]] name = "windmill-parser-ruby" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -6605,7 +6605,7 @@ dependencies = [ [[package]] name = "windmill-parser-rust" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "convert_case", @@ -6622,7 +6622,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -6635,7 +6635,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql-asset" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde", @@ -6647,7 +6647,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -6665,7 +6665,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts-asset" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "serde-wasm-bindgen", @@ -6681,7 +6681,7 @@ dependencies = [ [[package]] name = "windmill-parser-wac" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "ruff_python_ast", @@ -6698,7 +6698,7 @@ dependencies = [ [[package]] name = "windmill-parser-wasm" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "getrandom 0.2.17", @@ -6730,7 +6730,7 @@ dependencies = [ [[package]] name = "windmill-parser-yaml" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "lazy_static", @@ -6744,7 +6744,7 @@ dependencies = [ [[package]] name = "windmill-types" -version = "1.865.0" +version = "1.866.0" dependencies = [ "anyhow", "bitflags", diff --git a/backend/parsers/windmill-parser-wasm/Cargo.toml b/backend/parsers/windmill-parser-wasm/Cargo.toml index c32e0402f9..750721fa8c 100644 --- a/backend/parsers/windmill-parser-wasm/Cargo.toml +++ b/backend/parsers/windmill-parser-wasm/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" members = ["."] [workspace.package] -version = "1.865.0" +version = "1.866.0" edition = "2021" authors = ["Ruben Fiszel "] diff --git a/backend/tests/app_public_cloud_plan.rs b/backend/tests/app_public_cloud_plan.rs new file mode 100644 index 0000000000..d2101fb7a3 --- /dev/null +++ b/backend/tests/app_public_cloud_plan.rs @@ -0,0 +1,104 @@ +//! On the shared cloud (`CLOUD_HOSTED`), public (`anonymous`) apps take a paid plan. +//! +//! One test in its own binary on purpose: `CLOUD_HOSTED` is read once into a +//! `lazy_static`, so it must be set before anything reads it. +#![cfg(feature = "cloud")] + +use serde_json::json; +use sqlx::{Pool, Postgres}; +use windmill_test_utils::*; + +const ADMIN_TOKEN: &str = "SECRET_TOKEN"; +const APP_PATH: &str = "u/test-user/public_app"; + +fn post(url: String) -> reqwest::RequestBuilder { + reqwest::Client::new() + .post(url) + .header("Authorization", format!("Bearer {ADMIN_TOKEN}")) +} + +fn public_app() -> serde_json::Value { + json!({ + "path": APP_PATH, + "summary": "Public app", + "value": {}, + "policy": { "execution_mode": "anonymous", "triggerables": {} } + }) +} + +#[sqlx::test(fixtures("base"))] +async fn public_apps_take_a_paid_plan(db: Pool) -> anyhow::Result<()> { + unsafe { std::env::set_var("CLOUD_HOSTED", "true") }; + initialize_tracing().await; + // A fork of a paid root draws the root's plan, though it is not premium itself. + sqlx::raw_sql( + "INSERT INTO workspace (id, name, owner, premium) VALUES ('paid-root', 'paid-root', 'test-user', true); + INSERT INTO workspace (id, name, owner, parent_workspace_id) + VALUES ('paid-fork', 'paid-fork', 'test-user', 'paid-root'); + INSERT INTO workspace_settings (workspace_id) VALUES ('paid-root'), ('paid-fork'); + INSERT INTO usr (workspace_id, email, username, is_admin, role) + VALUES ('paid-fork', 'test@windmill.dev', 'test-user', true, 'Admin');", + ) + .execute(&db) + .await?; + let server = ApiServer::start(db.clone()).await?; + let api = format!("http://localhost:{}/api/w", server.addr.port()); + let ws = format!("{api}/test-workspace"); + + let resp = post(format!("{ws}/apps/create")) + .json(&public_app()) + .send() + .await?; + assert_eq!( + resp.status(), + 400, + "a free workspace cannot create a public app" + ); + assert!(resp.text().await?.contains("paid plan")); + + // An app made public before the rule: its next version is refused too. + let mut app = public_app(); + app["policy"]["execution_mode"] = json!("publisher"); + let resp = post(format!("{ws}/apps/create")).json(&app).send().await?; + assert_eq!(resp.status(), 201, "{}", resp.text().await?); + let resp = post(format!("{ws}/apps/update/{APP_PATH}")) + .json(&json!({ "execution_mode": "anonymous" })) + .send() + .await?; + assert_eq!(resp.status(), 400, "an app cannot be switched to public"); + sqlx::query( + "UPDATE app SET policy = jsonb_set(policy, '{execution_mode}', '\"anonymous\"') + WHERE path = $1 AND workspace_id = 'test-workspace'", + ) + .bind(APP_PATH) + .execute(&db) + .await?; + let resp = post(format!("{ws}/apps/update/{APP_PATH}")) + .json(&json!({ "value": { "grid": [] } })) + .send() + .await?; + assert_eq!( + resp.status(), + 400, + "an already-public app cannot be redeployed" + ); + + // Taking it out of public stays allowed. + let resp = post(format!("{ws}/apps/update/{APP_PATH}")) + .json(&json!({ "execution_mode": "publisher" })) + .send() + .await?; + assert_eq!(resp.status(), 200, "{}", resp.text().await?); + + let resp = post(format!("{api}/paid-fork/apps/create")) + .json(&public_app()) + .send() + .await?; + assert_eq!( + resp.status(), + 201, + "a fork of a paid root may publish: {}", + resp.text().await? + ); + Ok(()) +} diff --git a/backend/windmill-api-flows/src/flows.rs b/backend/windmill-api-flows/src/flows.rs index bd4e90ba37..d4a4211f1c 100644 --- a/backend/windmill-api-flows/src/flows.rs +++ b/backend/windmill-api-flows/src/flows.rs @@ -1366,7 +1366,9 @@ async fn update_flow( windmill_common::feature_usage::log_feature_usage("job_token_scopes", "deploy", "step:set"); } - sqlx::query!( + // A version is inserted at the path below and nothing else ties it to a live flow: one + // written for a flow deleted meanwhile would surface in a flow recreated there. + let updated = sqlx::query!( " UPDATE flow @@ -1412,7 +1414,11 @@ async fn update_flow( .await .map_err(|e| { error::Error::internal_err(format!("Error updating flow due to flow update: {e:#}")) - })?; + })? + .rows_affected(); + if updated == 0 { + return Err(Error::NotFound(format!("Flow {flow_path} not found"))); + } if set_job_token_scopes { windmill_common::scopes::log_job_token_scopes_deploy("flow", job_token_scopes.as_deref()); } @@ -1449,10 +1455,14 @@ async fn update_flow( )) })?; - // Flow nodes cascade on the old path's deletion below; runs in flight and the - // versions just moved still reference them. + // Nodes are referenced by id, so moving them only keeps them deduplicated at the new + // path. One a deleted flow left there with the same content stays where it is. sqlx::query!( - "UPDATE flow_node SET path = $1 WHERE path = $2 AND workspace_id = $3", + "UPDATE flow_node n SET path = $1 WHERE path = $2 AND workspace_id = $3 + AND NOT EXISTS ( + SELECT 1 FROM flow_node d + WHERE d.path = $1 AND d.workspace_id = $3 AND d.hash_v2 = n.hash_v2 + )", nf.path, flow_path, w_id @@ -2152,7 +2162,6 @@ async fn delete_flow_by_path( } let mut tx = user_db.begin(&authed).await?; - // Capture all related data for trashbin before deleting (CASCADE will remove flow_version, flow_node) let trash_flow: Option = sqlx::query_scalar("SELECT to_jsonb(t) FROM flow t WHERE path = $1 AND workspace_id = $2") .bind(path) @@ -2192,15 +2201,18 @@ async fn delete_flow_by_path( .execute(&mut *tx) .await?; - sqlx::query!( + let deleted = sqlx::query!( "DELETE FROM flow WHERE path = $1 AND workspace_id = $2", path, &w_id ) .execute(&mut *tx) - .await?; + .await? + .rows_affected(); - if let Some(flow_data) = trash_flow { + // Row-level security can let a caller read a flow it may not delete; its versions must + // then stay where they are. + if let Some(flow_data) = trash_flow.filter(|_| deleted > 0) { let mut trash_data = serde_json::json!({"row": flow_data}); if !trash_flow_versions.is_empty() { trash_data["flow_versions"] = serde_json::Value::Array(trash_flow_versions); @@ -2211,7 +2223,7 @@ async fn delete_flow_by_path( if !trash_drafts.is_empty() { trash_data["drafts"] = serde_json::Value::Array(trash_drafts); } - windmill_common::trashbin::move_to_trash( + let trash_id = windmill_common::trashbin::move_to_trash( &mut *tx, &w_id, "flow", @@ -2220,6 +2232,7 @@ async fn delete_flow_by_path( &authed.username, ) .await?; + windmill_common::trashbin::set_aside_flow_versions(&mut *tx, &w_id, path, trash_id).await?; } if !query.keep_captures.unwrap_or(false) { diff --git a/backend/windmill-api-integration-tests/tests/audit.rs b/backend/windmill-api-integration-tests/tests/audit.rs index 907eaf827e..6050ac2e8e 100644 --- a/backend/windmill-api-integration-tests/tests/audit.rs +++ b/backend/windmill-api-integration-tests/tests/audit.rs @@ -136,6 +136,51 @@ async fn test_job_run_is_searchable_by_token_and_by_caller( Ok(()) } +/// Paging with the `(timestamp, id)` cursor must return every row once, in `timestamp DESC, id +/// DESC` order, even where ids disagree with timestamps (an id is drawn at insert, the timestamp +/// at transaction start). +#[cfg(all(feature = "enterprise", feature = "private"))] +#[sqlx::test(migrations = "../migrations", fixtures("base"))] +async fn test_audit_list_cursor_follows_timestamp_order(db: Pool) -> anyhow::Result<()> { + initialize_tracing().await; + // Hours ahead stay inside the partitions created for the next days. + sqlx::query( + "INSERT INTO audit_partitioned (workspace_id, id, timestamp, username, operation, action_kind) + SELECT 'test-workspace', id, date_trunc('second', now()) + h * interval '1 hour', + 'test-user', 'cursor.probe', 'create' + FROM (VALUES (9000001, 1), (9000002, 3), (9000003, 2), (9000004, 2), (9000005, 1)) v(id, h)", + ) + .execute(&db) + .await?; + let server = ApiServer::start(db.clone()).await?; + let port = server.addr.port(); + + let mut seen = vec![]; + let mut cursor: Vec<(&str, String)> = vec![]; + loop { + let url = format!("http://localhost:{port}/api/w/test-workspace/audit/list"); + let page = authed(client().get(url)) + .query(&[("operation", "cursor.probe"), ("per_page", "1")]) + .query(&cursor) + .send() + .await? + .json::>() + .await?; + let Some(row) = page.first() else { break }; + seen.push(row["id"].as_i64().unwrap()); + cursor = vec![ + ("before_id", row["id"].to_string()), + ( + "before_id_timestamp", + row["timestamp"].as_str().unwrap().to_string(), + ), + ]; + } + assert_eq!(seen, [9000002, 9000004, 9000003, 9000005, 9000001]); + + Ok(()) +} + /// The run filter must find a run's entries under each key they keep its id in: the run itself /// (`parameters.uuid`), a cancel (`resource`) and a resume (`parameters.job_id`), and only those. #[cfg(all(feature = "enterprise", feature = "private"))] diff --git a/backend/windmill-api-integration-tests/tests/workspaces.rs b/backend/windmill-api-integration-tests/tests/workspaces.rs index c6ec1d5c6c..e3640aa1bb 100644 --- a/backend/windmill-api-integration-tests/tests/workspaces.rs +++ b/backend/windmill-api-integration-tests/tests/workspaces.rs @@ -1324,3 +1324,41 @@ async fn test_create_workspace_validates_chosen_username(db: Pool) -> Ok(()) } + +#[sqlx::test(migrations = "../migrations", fixtures("base"))] +async fn archiving_a_workspace_makes_its_public_apps_private( + db: Pool, +) -> anyhow::Result<()> { + initialize_tracing().await; + sqlx::query( + "INSERT INTO app (workspace_id, path, summary, policy, versions) VALUES + ('test-workspace', 'u/test-user/public', '', '{\"execution_mode\": \"anonymous\"}', '{}'), + ('test-workspace', 'u/test-user/members', '', '{\"execution_mode\": \"publisher\"}', '{}')", + ) + .execute(&db) + .await?; + let server = ApiServer::start(db.clone()).await?; + let port = server.addr.port(); + + let resp = authed(client().post(format!( + "http://localhost:{port}/api/w/test-workspace/workspaces/archive" + ))) + .send() + .await?; + assert_eq!(resp.status(), 200, "{}", resp.text().await?); + + let modes: Vec<(String, String)> = sqlx::query_as( + "SELECT path, policy->>'execution_mode' FROM app + WHERE workspace_id = 'test-workspace' ORDER BY path", + ) + .fetch_all(&db) + .await?; + assert_eq!( + modes, + [ + ("u/test-user/members".to_string(), "publisher".to_string()), + ("u/test-user/public".to_string(), "publisher".to_string()), + ] + ); + Ok(()) +} diff --git a/backend/windmill-api-workspaces/src/workspaces.rs b/backend/windmill-api-workspaces/src/workspaces.rs index f80b6be2e5..cf30b6a2a9 100644 --- a/backend/windmill-api-workspaces/src/workspaces.rs +++ b/backend/windmill-api-workspaces/src/workspaces.rs @@ -8827,6 +8827,7 @@ async fn clone_flows( "SELECT id, workspace_id, path, value, schema, created_by, created_at FROM flow_version WHERE workspace_id = $1 + AND NOT starts_with(path, '__deleted/') ORDER BY path, created_at", source_workspace_id ) @@ -11640,6 +11641,20 @@ pub(crate) async fn archive_workspace_impl( windmill_queue::schedule::clear_schedule(&mut tx, schedule_path, w_id).await?; } + // Public apps are served without a session, so nothing else about an archived workspace + // stops them: take them private. `publisher`, not `viewer`: viewer mode runs as whoever opens + // the app and skips its runnable allowlist, which an operator-built app must never get. + // Unarchiving does not restore them. + let unpublished_apps = sqlx::query!( + "UPDATE app SET policy = jsonb_set(policy, '{execution_mode}', '\"publisher\"') + WHERE workspace_id = $1 AND policy->>'execution_mode' = 'anonymous'", + w_id + ) + .execute(&mut *tx) + .await? + .rows_affected(); + tracing::info!("Made {unpublished_apps} public apps private in workspace {w_id}"); + // Delete non-session tokens scoped to this workspace let deleted_tokens = sqlx::query_scalar!( "DELETE FROM token WHERE workspace_id = $1 AND label IS DISTINCT FROM 'session' RETURNING token_prefix", diff --git a/backend/windmill-api-workspaces/src/workspaces_extra.rs b/backend/windmill-api-workspaces/src/workspaces_extra.rs index ee911f55ea..19087df2bf 100644 --- a/backend/windmill-api-workspaces/src/workspaces_extra.rs +++ b/backend/windmill-api-workspaces/src/workspaces_extra.rs @@ -1241,6 +1241,12 @@ pub(crate) async fn delete_workspace( sqlx::query!("DELETE FROM flow WHERE workspace_id = $1", &w_id) .execute(&mut *tx) .await?; + sqlx::query!("DELETE FROM flow_version WHERE workspace_id = $1", &w_id) + .execute(&mut *tx) + .await?; + sqlx::query!("DELETE FROM flow_node WHERE workspace_id = $1", &w_id) + .execute(&mut *tx) + .await?; sqlx::query!("DELETE FROM app WHERE workspace_id = $1", &w_id) .execute(&mut *tx) .await?; diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index cf25d02dcb..729a9751f1 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -1,7 +1,7 @@ openapi: "3.0.3" info: - version: 1.865.0 + version: 1.866.0 title: Windmill API contact: @@ -271,12 +271,21 @@ paths: - name: before_id in: query description: > - only return logs with an id strictly lower than this one. Logs are ordered by - descending id, so this is a keyset cursor to stream a page in several batches - without paying a growing offset. + the id half of a keyset cursor. Logs are ordered by descending timestamp then + id: pass the last row's id here and its timestamp as before_id_timestamp to + stream a page in several batches without paying a growing offset. Alone, it + only filters on id < before_id, which can skip or repeat rows across pages. schema: type: integer format: int64 + - name: before_id_timestamp + in: query + description: > + the timestamp of the row whose id is before_id: with it, only logs strictly + before that row in (timestamp, id) order are returned + schema: + type: string + format: date-time - name: all_workspaces in: query description: get audit logs for all workspaces diff --git a/backend/windmill-api/src/apps.rs b/backend/windmill-api/src/apps.rs index bc47259e0d..412a746aba 100644 --- a/backend/windmill-api/src/apps.rs +++ b/backend/windmill-api/src/apps.rs @@ -378,6 +378,31 @@ fn refuse_guest_mode_where_unavailable( ))) } +/// Whether this workspace may deploy apps that stay public (`Anonymous`). On the +/// cloud that takes a paid plan, resolved through the fork/dev root; no workspace +/// admin can lift it, unlike `RestrictAnonymousAppDeployment`. Every deploy that +/// leaves an app public is refused, not only the transition into it, so a free +/// workspace's existing public apps stay frozen until it upgrades. +async fn public_apps_allowed(_db: &DB, _w_id: &str) -> Result { + #[cfg(feature = "cloud")] + if *CLOUD_HOSTED { + return Ok( + windmill_common::workspaces::get_team_plan_status(_db, _w_id) + .await? + .premium, + ); + } + Ok(true) +} + +fn public_app_requires_plan(path: &str) -> Error { + Error::BadRequest(format!( + "app {path} is public (accessible without login), which requires a paid plan on \ + Windmill Cloud. Upgrade this workspace in Workspace Settings > Premium plans to publish \ + or update public apps, or change who can open the app." + )) +} + /// Gate a viewer on the app's `execution_mode`, as far as can be decided without an /// ACL probe. `Ok(true)` means already authorized — anonymous admits anyone, guest /// admits anyone signed in; `Ok(false)` means the caller is a member and still owes @@ -2853,6 +2878,11 @@ async fn create_app_internal<'a>( "Summary must be less than 300 characters on cloud".to_string(), )); } + if app.policy.execution_mode() == ExecutionMode::Anonymous + && !public_apps_allowed(&db, w_id).await? + { + return Err(public_app_requires_plan(&app.path)); + } } // Resolve the on-behalf-of defaults on the (non-RLS) pool *before* opening // the RLS transaction below: doing these lookups mid-transaction would hold @@ -3878,6 +3908,10 @@ async fn update_app_internal<'a>( } } + // Resolved before the transaction for the reason above; checked against the row + // as written, once every field below has landed. + let public_apps_allowed = public_apps_allowed(&db, w_id).await?; + let mut tx = user_db.clone().begin(&authed).await?; // `app_version.raw_app` is set by whichever endpoint writes the version, so a @@ -4232,6 +4266,19 @@ async fn update_app_internal<'a>( ))); } }; + if !public_apps_allowed + && sqlx::query_scalar!( + "SELECT policy->>'execution_mode' = 'anonymous' FROM app + WHERE path = $1 AND workspace_id = $2", + npath, + w_id + ) + .fetch_one(&mut *tx) + .await? + .unwrap_or(false) + { + return Err(public_app_requires_plan(&npath)); + } // CLI / git-sync deploys ask us to preserve any existing user draft at this // path instead of wiping it as part of the deploy. Only wipe the deployer's // own draft (plus the legacy NULL-email row) — see create_app_internal. diff --git a/backend/windmill-api/src/db.rs b/backend/windmill-api/src/db.rs index 9d311a33bc..56524011fe 100644 --- a/backend/windmill-api/src/db.rs +++ b/backend/windmill-api/src/db.rs @@ -484,7 +484,16 @@ pub async fn wait_for_migrations( "This worker is on Windmill version {GIT_VERSION} (migration version {latest_version}). Only servers run migrations. Waiting for a server with version >= {GIT_VERSION} to apply the migration..." ); - let mut attempts = 0; + // During a rolling upgrade, new workers start at the same time as the new + // server, which needs a while to come up and migrate. Exiting early only + // makes the pod restart and look like a crash loop, so wait long enough to + // cover a normal rollout and only give up if the server is truly not coming. + const RECHECK_SECS: u64 = 3; + // Over 12 rollouts (3,430 worker starts) the longest wait was 94s and + // p99 47s; 3 minutes covers that with margin. + const MAX_WAIT_SECS: u64 = 3 * 60; + const LOG_EVERY: u64 = 10; + let mut attempts: u64 = 0; loop { let is_applied: Result, sqlx::Error> = @@ -500,16 +509,19 @@ pub async fn wait_for_migrations( ); return Ok(()); } - Ok(_) => { + Ok(_) if attempts % LOG_EVERY == 0 => { tracing::info!( - "Database not up to date yet. This worker (Windmill {GIT_VERSION}, migration version {latest_version}) is waiting for a server with version >= {GIT_VERSION} to run the migration. Rechecking in 3s..." + "Database not up to date yet. This worker (Windmill {GIT_VERSION}, migration version {latest_version}) is waiting for a server with version >= {GIT_VERSION} to run the migration. Waited {}s so far, giving up after {MAX_WAIT_SECS}s...", + attempts * RECHECK_SECS ); } - Err(e) => { + Ok(_) => {} + Err(e) if attempts % LOG_EVERY == 0 => { tracing::info!( - "Could not check migration status (migrations table may not exist yet): {e:#}. Rechecking in 3s..." + "Could not check migration status (migrations table may not exist yet): {e:#}. Rechecking every {RECHECK_SECS}s..." ); } + Err(_) => {} } tokio::select! { @@ -517,13 +529,13 @@ pub async fn wait_for_migrations( tracing::info!("Killpill received, stopping migration wait"); return Ok(()); } - _ = tokio::time::sleep(std::time::Duration::from_secs(3)) => {} + _ = tokio::time::sleep(std::time::Duration::from_secs(RECHECK_SECS)) => {} } attempts += 1; - if attempts >= 10 { + if attempts * RECHECK_SECS >= MAX_WAIT_SECS { tracing::error!( - "Timed out after 10 attempts waiting for migration version {latest_version}. Exiting." + "Timed out after {MAX_WAIT_SECS}s waiting for migration version {latest_version}. Exiting." ); std::process::exit(1); } diff --git a/backend/windmill-api/src/offboarding.rs b/backend/windmill-api/src/offboarding.rs index 62c84697b2..7c8b2d4d8a 100644 --- a/backend/windmill-api/src/offboarding.rs +++ b/backend/windmill-api/src/offboarding.rs @@ -921,7 +921,7 @@ async fn offboard_user_from_workspace<'c>( ).execute(&mut **tx).await?; sqlx::query!( - r#"UPDATE flow_node SET path = REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, + r#"UPDATE flow_node SET path = REGEXP_REPLACE(path, 'u/' || $2 || '/(.*)', $1 || '/\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3 AND NOT EXISTS (SELECT 1 FROM flow_node d WHERE d.workspace_id = $3 AND d.hash_v2 = flow_node.hash_v2 AND d.path = REGEXP_REPLACE(flow_node.path, 'u/' || $2 || '/(.*)', $1 || '/\1'))"#, &new_prefix, username, w_id ).execute(&mut **tx).await?; diff --git a/backend/windmill-api/src/trash.rs b/backend/windmill-api/src/trash.rs index 53fc088582..39b50b01dd 100644 --- a/backend/windmill-api/src/trash.rs +++ b/backend/windmill-api/src/trash.rs @@ -258,6 +258,8 @@ async fn restore_flow(tx: &mut sqlx::PgConnection, item: &TrashItemWithData) -> .execute(&mut *tx) .await?; + trashbin::restore_flow_versions(&mut *tx, &item.workspace_id, &item.item_path, item.id).await?; + // Restore flow_versions if let Some(versions) = data.get("flow_versions").and_then(|v| v.as_array()) { for version in versions { diff --git a/backend/windmill-api/src/users.rs b/backend/windmill-api/src/users.rs index 7e9baf8e9f..df1130c2b4 100644 --- a/backend/windmill-api/src/users.rs +++ b/backend/windmill-api/src/users.rs @@ -799,7 +799,7 @@ async fn update_username_in_workpsace<'c>( .await?; sqlx::query!( - r#"UPDATE flow_node SET path = REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, + r#"UPDATE flow_node SET path = REGEXP_REPLACE(path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE path LIKE ('u/' || $2 || '/%') AND workspace_id = $3 AND NOT EXISTS (SELECT 1 FROM flow_node d WHERE d.workspace_id = $3 AND d.hash_v2 = flow_node.hash_v2 AND d.path = REGEXP_REPLACE(flow_node.path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1'))"#, new_username, old_username, w_id diff --git a/backend/windmill-audit/src/lib.rs b/backend/windmill-audit/src/lib.rs index 3b407b191f..89b5de067a 100644 --- a/backend/windmill-audit/src/lib.rs +++ b/backend/windmill-audit/src/lib.rs @@ -38,9 +38,11 @@ pub struct ListAuditLogQuery { pub resource: Option, pub before: Option>, pub after: Option>, - // Keyset cursor on the `id DESC` ordering. Lets a client stream a page in small batches - // without paying a growing OFFSET on every batch. + // Keyset cursor on the `timestamp DESC, id DESC` ordering: the id and timestamp of the last + // row seen. Lets a client stream a page in small batches without paying a growing OFFSET on + // every batch. `before_id` alone filters on the id only. pub before_id: Option, + pub before_id_timestamp: Option>, pub all_workspaces: Option, // The entries about one run: started, viewed, cancelled, resumed, deleted... pub job_id: Option, diff --git a/backend/windmill-common/src/trashbin.rs b/backend/windmill-common/src/trashbin.rs index 6d88f12871..83e2771ecd 100644 --- a/backend/windmill-common/src/trashbin.rs +++ b/backend/windmill-common/src/trashbin.rs @@ -113,19 +113,82 @@ pub async fn get_trash_item<'e, E: sqlx::PgExecutor<'e>>( Ok(item) } +/// Where a deleted flow's versions wait while it is in the trash. Jobs load versions by id, +/// so runs in flight keep working, while every lookup by path (history, relocks, versioned +/// runs, renames) stops seeing them. Nodes stay at the flow's path: they are shared by +/// content and referenced by id. +fn set_aside_path(trash_id: i64) -> String { + format!("__deleted/{trash_id}") +} + +/// No permission check: the caller must have deleted the flow at `path` itself, in `tx`. +pub async fn set_aside_flow_versions( + tx: &mut PgConnection, + workspace_id: &str, + path: &str, + trash_id: i64, +) -> Result<()> { + sqlx::query("UPDATE flow_version SET path = $1 WHERE path = $2 AND workspace_id = $3") + .bind(set_aside_path(trash_id)) + .bind(path) + .bind(workspace_id) + .execute(&mut *tx) + .await?; + Ok(()) +} + +/// No permission check: the caller must have authorized restoring trash item `trash_id`. +pub async fn restore_flow_versions( + tx: &mut PgConnection, + workspace_id: &str, + path: &str, + trash_id: i64, +) -> Result<()> { + sqlx::query("UPDATE flow_version SET path = $1 WHERE path = $2 AND workspace_id = $3") + .bind(path) + .bind(set_aside_path(trash_id)) + .bind(workspace_id) + .execute(&mut *tx) + .await?; + Ok(()) +} + +/// SQL deleting the trash rows matching `cond` and selecting how many there were, along with +/// the versions their flows set aside, except those a queued job still references: those +/// are kept for good. `v2_job.runnable_id` has no index, so the queue is read once against +/// the set-aside ids: a check correlated per version scans `v2_job` once per version. +fn remove_trash_sql(cond: &str) -> String { + format!( + "WITH removed AS ( + DELETE FROM trashbin WHERE {cond} RETURNING id, workspace_id, item_kind + ), aside AS MATERIALIZED ( + SELECT v.workspace_id, v.id FROM flow_version v JOIN removed r + ON r.item_kind = 'flow' AND v.workspace_id = r.workspace_id + AND v.path = '__deleted/' || r.id + ), in_use AS MATERIALIZED ( + SELECT DISTINCT j.runnable_id AS id + FROM v2_job_queue q JOIN v2_job j ON j.id = q.id + WHERE q.workspace_id IN (SELECT workspace_id FROM aside) + AND j.runnable_id IN (SELECT id FROM aside) + ), _versions AS ( + DELETE FROM flow_version v USING aside a + WHERE v.workspace_id = a.workspace_id AND v.id = a.id + AND NOT EXISTS (SELECT 1 FROM in_use u WHERE u.id = v.id) + ) + SELECT count(*) FROM removed" + ) +} + pub async fn permanently_delete_item<'e, E: sqlx::PgExecutor<'e>>( db: E, workspace_id: &str, id: i64, ) -> Result<()> { - let rows = sqlx::query!( - "DELETE FROM trashbin WHERE workspace_id = $1 AND id = $2", - workspace_id, - id, - ) - .execute(db) - .await? - .rows_affected(); + let rows: i64 = sqlx::query_scalar(&remove_trash_sql("workspace_id = $1 AND id = $2")) + .bind(workspace_id) + .bind(id) + .fetch_one(db) + .await?; if rows == 0 { return Err(crate::error::Error::NotFound( @@ -137,19 +200,18 @@ pub async fn permanently_delete_item<'e, E: sqlx::PgExecutor<'e>>( } pub async fn empty_trash<'e, E: sqlx::PgExecutor<'e>>(db: E, workspace_id: &str) -> Result { - let rows = sqlx::query!("DELETE FROM trashbin WHERE workspace_id = $1", workspace_id,) - .execute(db) - .await? - .rows_affected(); + let rows = sqlx::query_scalar(&remove_trash_sql("workspace_id = $1")) + .bind(workspace_id) + .fetch_one(db) + .await?; - Ok(rows as i64) + Ok(rows) } pub async fn delete_expired_trash<'e, E: sqlx::PgExecutor<'e>>(db: E) -> Result { - let rows = sqlx::query!("DELETE FROM trashbin WHERE expires_at <= now()") - .execute(db) - .await? - .rows_affected(); + let rows = sqlx::query_scalar(&remove_trash_sql("expires_at <= now()")) + .fetch_one(db) + .await?; - Ok(rows as i64) + Ok(rows) } diff --git a/backend/windmill-common/src/workspaces.rs b/backend/windmill-common/src/workspaces.rs index a3df2ac168..85d0290a87 100644 --- a/backend/windmill-common/src/workspaces.rs +++ b/backend/windmill-common/src/workspaces.rs @@ -408,26 +408,44 @@ impl GitRepositorySettings { .unwrap_or(LATEST_GIT_SYNC_SCRIPT_PATH) } - pub fn is_script_meets_min_version(&self, min_version: u32) -> error::Result { - let path = self.effective_script_path(); - // example: "hub/28102/sync-script-to-git-repo-windmill" - let current = path - .split("/") // -> ["hub" "28102" "sync-script-to-git-repo-windmill"] - .skip(1) // omit "hub" - .next() // get numeric id - .ok_or(Error::InternalErr(format!( - "cannot get script version id from: {}", - path - )))? - .parse() - .unwrap_or_else(|e| { - tracing::warn!("cannot get script version id from: {}. e: {e}", path); - - u32::MAX - }); - - Ok(current >= min_version) // this works on assumption that all scripts in hub have sequential ids + /// The path a deployment callback job is queued with. + pub fn callback_path(&self) -> String { + sync_callback_path(self.script_path.as_deref()) } + + pub fn is_script_meets_min_version(&self, min_version: u32) -> error::Result { + Ok(sync_script_meets_min_version( + &self.callback_path(), + min_version, + )) + } +} + +/// The path a git sync script (`None` for the latest one) is queued with: parsed when it +/// parses. A setting that doesn't parse is kept as written, so its callback is still queued and +/// fails visibly in the workspace's runs instead of the repository silently not syncing. +pub fn sync_callback_path(script_path: Option<&str>) -> String { + let raw = script_path.unwrap_or(LATEST_GIT_SYNC_SCRIPT_PATH); + crate::runnable_ref::RunnableRef::from_path(raw, false) + .map_or_else(|_| raw.to_string(), |script| script.path().to_string()) +} + +/// Whether the git sync script queued at `path` (from [`sync_callback_path`]) is at least +/// `min_version`. Never fails, so one repository's setting cannot stop the others' dispatch. +pub fn sync_script_meets_min_version(path: &str, min_version: u32) -> bool { + // Reading the queued path makes `/hub/28102/…` hub 28102. Not `hub_id()`: a workspace path + // keeps its second segment as version (`f/28000/…`). + let current = path + .split('/') + .nth(1) + .and_then(|id| id.parse().ok()) + .unwrap_or_else(|| { + tracing::warn!("cannot get script version id from: {}", path); + + u32::MAX + }); + + current >= min_version // this works on assumption that all scripts in hub have sequential ids } /// How auto-pull triggers are delivered for a repository. @@ -3937,6 +3955,27 @@ mod tests { DataTableRoleTenants { tenants: list.iter().map(|t| t.to_string()).collect() } } + #[test] + fn sync_script_version_is_the_second_segment_of_the_queued_path() { + let meets = |p, min| sync_script_meets_min_version(&sync_callback_path(p), min); + assert!(meets(None, 28956)); + assert!(!meets(Some("hub/28102/sync"), 28103)); + assert!(!meets(Some("/hub/28102/sync"), 28103)); + assert!(meets(Some("/hub/28103/sync"), 28103)); + assert!(!meets(Some("f/28000/sync"), 28103)); + assert!(meets(Some("u/admin/sync"), 28103)); + assert!(meets(Some("sync"), 28103)); + assert!(meets(Some("//hub/28102/sync"), 28103)); + assert_eq!( + sync_callback_path(Some("/hub/28102/sync")), + "hub/28102/sync" + ); + assert_eq!( + sync_callback_path(Some("//hub/28102/sync")), + "//hub/28102/sync" + ); + } + #[cfg(all(feature = "private", feature = "enterprise"))] #[test] fn a_tenant_list_covers_users_groups_folders_and_the_wildcard() { diff --git a/backend/windmill-common/tests/deleted_flow_versions.rs b/backend/windmill-common/tests/deleted_flow_versions.rs new file mode 100644 index 0000000000..98b1f17f81 --- /dev/null +++ b/backend/windmill-common/tests/deleted_flow_versions.rs @@ -0,0 +1,58 @@ +use sqlx::{Pool, Postgres}; +use windmill_common::trashbin::{delete_expired_trash, set_aside_flow_versions}; + +/// A deleted flow's versions must survive its trash entry while a queued job references +/// them, whatever path that job was queued under, and nothing else at the path is touched. +#[sqlx::test(migrations = "../migrations", fixtures("base"))] +async fn expired_trash_purges_set_aside_versions_no_queued_job_uses(db: Pool) { + sqlx::raw_sql( + "INSERT INTO flow_version (id, workspace_id, path, value, created_by) VALUES + (100, 'test-workspace', 'f/t/a', '{}', 'u'), + (101, 'test-workspace', 'f/t/a', '{}', 'u'), + (200, 'test-workspace', 'f/t/a', '{}', 'u'); + WITH job AS ( + INSERT INTO v2_job (id, workspace_id, kind, runnable_path, runnable_id) + VALUES (gen_random_uuid(), 'test-workspace', 'unassigned_flow', 'f/t/renamed', 100) + RETURNING id + ) + INSERT INTO v2_job_queue (id, workspace_id, scheduled_for) SELECT id, 'test-workspace', now() FROM job", + ) + .execute(&db) + .await + .unwrap(); + + let mut tx = db.begin().await.unwrap(); + let trash_id: i64 = sqlx::query_scalar( + "INSERT INTO trashbin (workspace_id, item_kind, item_path, item_data, deleted_by, expires_at) + VALUES ('test-workspace', 'flow', 'f/t/a', '{}', 'u', now() - interval '1 second') RETURNING id", + ) + .fetch_one(&mut *tx) + .await + .unwrap(); + set_aside_flow_versions(&mut tx, "test-workspace", "f/t/a", trash_id) + .await + .unwrap(); + // A flow recreated at the path after the deletion. + sqlx::query( + "INSERT INTO flow_version (id, workspace_id, path, value, created_by) + VALUES (300, 'test-workspace', 'f/t/a', '{}', 'u')", + ) + .execute(&mut *tx) + .await + .unwrap(); + tx.commit().await.unwrap(); + + assert_eq!(delete_expired_trash(&db).await.unwrap(), 1); + + let left: Vec<(i64, String)> = sqlx::query_as("SELECT id, path FROM flow_version ORDER BY id") + .fetch_all(&db) + .await + .unwrap(); + assert_eq!( + left, + vec![ + (100, format!("__deleted/{trash_id}")), + (300, "f/t/a".to_string()) + ] + ); +} diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 0d339724c8..da062edb26 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -4868,23 +4868,34 @@ async fn clone_runnable(j: &mut PulledJob, db: &DB) -> error::Result<()> { // An app is relocked in place: a raw app's bundle is stored under its version id, // so a copy minted here could never be published. JobKind::Dependencies | JobKind::AppDependencies => *base_hash, - JobKind::FlowDependencies => { - sqlx::query_scalar!( - "INSERT INTO flow_version - (workspace_id, path, value, schema, created_by) + // The flow row is locked so that a concurrent delete or rename either waits for the + // copy and moves it with the flow's other versions, or wins and no copy is made: one + // committed after it would sit at the path of a flow recreated there. A rename first + // updates the row without changing its key, which `FOR KEY SHARE` would not wait for. + JobKind::FlowDependencies => sqlx::query_scalar!( + "INSERT INTO flow_version + (workspace_id, path, value, schema, created_by) - SELECT workspace_id, path, value, schema, created_by - FROM flow_version WHERE path = $1 AND workspace_id = $2 AND id = $3 + SELECT v.workspace_id, v.path, v.value, v.schema, v.created_by + FROM flow_version v + JOIN flow f ON f.workspace_id = v.workspace_id AND f.path = v.path + WHERE v.path = $1 AND v.workspace_id = $2 AND v.id = $3 + FOR SHARE OF f - RETURNING id - ", - j.runnable_path(), - j.workspace_id, - *base_hash, - ) - .fetch_one(db) - .await? - } + RETURNING id + ", + j.runnable_path(), + j.workspace_id, + *base_hash, + ) + .fetch_optional(db) + .await? + .ok_or_else(|| { + Error::NotFound(format!( + "Flow {} was deleted before its relock", + j.runnable_path() + )) + })?, _ => *base_hash, }; diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index bf4dc12875..ba587e355e 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -2944,13 +2944,15 @@ async fn fetch_root_flow_env( flow_job_id: Uuid, workspace_id: &str, ) -> Result>>, sqlx::Error> { + // Versions are matched by id alone (a deleted flow's are set aside off its path); only + // these kinds hold a flow version in `runnable_id`. sqlx::query_scalar!( - r#"WITH RECURSIVE chain(id, parent_job, flow_innermost_root_job, runnable_id, runnable_path, raw_flow, depth) AS ( - SELECT id, parent_job, flow_innermost_root_job, runnable_id, runnable_path, raw_flow, 0 + r#"WITH RECURSIVE chain(id, parent_job, flow_innermost_root_job, runnable_id, kind, raw_flow, depth) AS ( + SELECT id, parent_job, flow_innermost_root_job, runnable_id, kind, raw_flow, 0 FROM v2_job WHERE id = $1 AND workspace_id = $2 UNION ALL - SELECT j.id, j.parent_job, j.flow_innermost_root_job, j.runnable_id, j.runnable_path, j.raw_flow, c.depth + 1 + SELECT j.id, j.parent_job, j.flow_innermost_root_job, j.runnable_id, j.kind, j.raw_flow, c.depth + 1 FROM v2_job j JOIN chain c ON j.id = COALESCE(c.flow_innermost_root_job, c.parent_job) @@ -2966,7 +2968,7 @@ async fn fetch_root_flow_env( FROM chain LEFT JOIN flow_version ON flow_version.id = chain.runnable_id - AND flow_version.path = chain.runnable_path + AND chain.kind IN ('flow', 'unassigned_flow') AND flow_version.workspace_id = $2 WHERE (CASE WHEN flow_version.id IS NOT NULL THEN flow_version.value -> 'flow_env' diff --git a/benchmarks/lib.ts b/benchmarks/lib.ts index 679cdfbe81..851a59e987 100644 --- a/benchmarks/lib.ts +++ b/benchmarks/lib.ts @@ -2,7 +2,7 @@ import { sleep } from "https://deno.land/x/sleep@v1.2.1/mod.ts"; import * as windmill from "https://deno.land/x/windmill@v1.174.0/mod.ts"; import * as api from "https://deno.land/x/windmill@v1.174.0/windmill-api/index.ts"; -export const VERSION = "v1.865.0"; +export const VERSION = "v1.866.0"; export async function login(email: string, password: string): Promise { return await windmill.UserService.login({ diff --git a/chat-sdk/package-lock.json b/chat-sdk/package-lock.json index 02794b758c..69c3fa2b56 100644 --- a/chat-sdk/package-lock.json +++ b/chat-sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@windmill-labs/chat-sdk", - "version": "1.865.0", + "version": "1.866.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@windmill-labs/chat-sdk", - "version": "1.865.0", + "version": "1.866.0", "license": "Apache-2.0", "devDependencies": { "@ai-sdk/react": "^4.0.102", diff --git a/chat-sdk/package.json b/chat-sdk/package.json index d4046f7b89..be58d54c45 100644 --- a/chat-sdk/package.json +++ b/chat-sdk/package.json @@ -1,7 +1,7 @@ { "name": "@windmill-labs/chat-sdk", "description": "Build chat interfaces on Windmill flows deployed in chat mode, from any frontend or raw app", - "version": "1.865.0", + "version": "1.866.0", "author": "Ruben Fiszel", "license": "Apache-2.0", "homepage": "https://github.com/windmill-labs/windmill/tree/main/chat-sdk#readme", diff --git a/cli/src/core/constants.ts b/cli/src/core/constants.ts index 4536e72fbb..a431495b12 100644 --- a/cli/src/core/constants.ts +++ b/cli/src/core/constants.ts @@ -10,4 +10,4 @@ export const WM_FORK_PREFIX = "wm-fork"; // (e.g. utils.ts) can read it without importing main.ts and creating a circular // dependency (main → workspace → utils → main) that triggers a TDZ. // Re-exported from main.ts for backwards compatibility. -export const VERSION = "1.865.0"; +export const VERSION = "1.866.0"; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 7ddaa0ceb7..f5d0e7fe90 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "@windmill-labs/components", - "version": "1.865.0", + "version": "1.866.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@windmill-labs/components", - "version": "1.865.0", + "version": "1.866.0", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/frontend/package.json b/frontend/package.json index e3f9164a71..aa2892911b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@windmill-labs/components", - "version": "1.865.0", + "version": "1.866.0", "scripts": { "dev": "vite dev", "dev:ui-builder": "mv static/ui_builder static/ui_builder.dev-disabled 2>/dev/null || true ; trap 'mv static/ui_builder.dev-disabled static/ui_builder 2>/dev/null || true' EXIT ; vite dev", diff --git a/frontend/src/lib/components/CompareWorkspaces.svelte b/frontend/src/lib/components/CompareWorkspaces.svelte index 4ce7fb1504..65f338c76c 100644 --- a/frontend/src/lib/components/CompareWorkspaces.svelte +++ b/frontend/src/lib/components/CompareWorkspaces.svelte @@ -854,12 +854,41 @@ if (result.success) { deploymentStatus[statusKey] = { status: 'deployed' } + if (kind === 'folder' && !removes) { + warnOnAddedFolderOwners(path, workspaceFrom, workspaceToDeployTo) + } } else { deploymentStatus[statusKey] = { status: 'failed', error: result.error } sendUserToast(`Failed to deploy ${statusKey}: ${result.error}`, 'error') } } + // A non-admin can't drop their own ownership of a folder (the folder UPDATE policy + // rejects a row they don't own), so updateFolder keeps them as an owner. The folder then + // never matches its source, and the conflict comes back on every compare unless we say why. + async function warnOnAddedFolderOwners(path: string, workspaceFrom: string, workspaceTo: string) { + const name = path.replace(/^f\//, '') + try { + const [source, target, me] = await Promise.all([ + FolderService.getFolder({ workspace: workspaceFrom, name }), + FolderService.getFolder({ workspace: workspaceTo, name }), + UserService.whoami({ workspace: workspaceTo }) + ]) + const owner = `u/${me.username}` + if (!me.is_admin && target.owners.includes(owner) && !source.owners.includes(owner)) { + sendUserToast( + `${path} still differs in ${workspaceTo}: it kept ${owner} as owner, because a non-admin can't remove their own ownership of a folder. To clear it, make ${owner} owner of ${path} in ${workspaceFrom} too, or deploy as an admin of ${workspaceTo}.`, + 'warning', + [], + undefined, + 15000 + ) + } + } catch { + // The deploy itself succeeded; the next compare still shows the difference. + } + } + let deploymentErrorMessage = $state('') // The override acknowledges the outdated items listed next to it, not the // selection, so it holds while every outdated item is one the user ticked it diff --git a/frontend/src/lib/components/auditLogs/useAuditLogsLoader.svelte.ts b/frontend/src/lib/components/auditLogs/useAuditLogsLoader.svelte.ts index cbfa573a74..788c21214f 100644 --- a/frontend/src/lib/components/auditLogs/useAuditLogsLoader.svelte.ts +++ b/frontend/src/lib/components/auditLogs/useAuditLogsLoader.svelte.ts @@ -25,8 +25,8 @@ const MAX_PER_PAGE = 1000 /** * Loads the newest audit logs, optionally streaming them in smaller batches so rows show up as * they arrive on instances where a full load takes a long time to come back, and appends older - * ones on demand. Rows are ordered by descending id, so every batch after the first follows a - * `before_id` cursor. + * ones on demand. Rows are ordered by descending timestamp then id, so every batch after the + * first follows a cursor on the last row's (timestamp, id). */ export function useAuditLogsLoader(args: () => AuditLogsLoaderArgs) { let logs: AuditLog[] | undefined = $state() @@ -45,12 +45,14 @@ export function useAuditLogsLoader(args: () => AuditLogsLoaderArgs) { function fetchBatch( a: AuditLogsLoaderArgs, limit: number, - beforeId: number | undefined + cursor: AuditLog | undefined ): CancelablePromise { return AuditService.listAuditLogs({ workspace: a.scope === 'instance' ? 'global' : a.workspace!, perPage: limit, - beforeId, + beforeId: cursor?.id, + // Passed back as received: the server's microseconds would not survive a `Date`. + beforeIdTimestamp: cursor?.timestamp, before: a.before, after: a.after, username: a.username === 'all' ? undefined : a.username, @@ -105,8 +107,8 @@ export function useAuditLogsLoader(args: () => AuditLogsLoaderArgs) { const acc: AuditLog[] = [] let slowBatchToastShown = false - function loadBatch(beforeId: number | undefined): CancelablePromise { - let fetch = fetchBatch(a, size, beforeId) + function loadBatch(cursor: AuditLog | undefined): CancelablePromise { + let fetch = fetchBatch(a, size, cursor) if (isBatched && size > 1) { fetch = CancelablePromiseUtils.onTimeout(fetch, 4000, () => { if (slowBatchToastShown) return @@ -132,7 +134,7 @@ export function useAuditLogsLoader(args: () => AuditLogsLoaderArgs) { hasMore = acc.length >= total return CancelablePromiseUtils.pure(undefined) } - return loadBatch(rows[rows.length - 1].id) + return loadBatch(rows[rows.length - 1]) }) } @@ -221,8 +223,8 @@ export function useAuditLogsLoader(args: () => AuditLogsLoaderArgs) { // Rows are appended as each batch lands, so stopping keeps them and the next load-more // continues from the last one. - function extraBatch(beforeId: number): CancelablePromise { - return CancelablePromiseUtils.then(fetchBatch(a, size, beforeId), (rows) => { + function extraBatch(cursor: AuditLog): CancelablePromise { + return CancelablePromiseUtils.then(fetchBatch(a, size, cursor), (rows) => { const kept = rows.slice(0, total - appended) appended += kept.length logs = [...(logs ?? []), ...kept] @@ -233,11 +235,11 @@ export function useAuditLogsLoader(args: () => AuditLogsLoaderArgs) { hasMore = false return CancelablePromiseUtils.pure(undefined) } - return extraBatch(rows[rows.length - 1].id) + return extraBatch(rows[rows.length - 1]) }) } - let promise = CancelablePromiseUtils.onTimeout(extraBatch(last.id), 4000, () => { + let promise = CancelablePromiseUtils.onTimeout(extraBatch(last), 4000, () => { const smaller = total > SMALL_BATCH_SIZE ? SMALL_BATCH_SIZE : 1 const offerBatches = size === total && total > 1 sendUserToast('Loading more audit logs is taking longer than expected...', 'warning', [ diff --git a/frontend/src/lib/components/copilot/chat/global/core.ts b/frontend/src/lib/components/copilot/chat/global/core.ts index 504447195a..a02c7acc1e 100644 --- a/frontend/src/lib/components/copilot/chat/global/core.ts +++ b/frontend/src/lib/components/copilot/chat/global/core.ts @@ -3553,10 +3553,13 @@ export const globalTools: SessionTool<{}>[] = [ } else if (read.success === false) { toolCallbacks.setToolStatus(toolId, { content: read.error, error: read.error }) } else { + const readsAgent = read.value?.resource_type === 'ai_agent' + const noun = readsAgent ? 'agent' : type toolCallbacks.setToolStatus(toolId, { content: read.isDraft - ? `Read draft ${type} "${parsed.path}"` - : `Read ${type} "${parsed.path}"` + ? `Read draft ${noun} "${parsed.path}"` + : `Read ${noun} "${parsed.path}"`, + readsAgent }) } return text @@ -7009,8 +7012,12 @@ async function deployDraft( throw new Error(`Draft ${type} "${path}" has no value to deploy.`) } + const noun = + type === 'resource' && (draft.value as CreateResource).resource_type === 'ai_agent' + ? 'agent' + : type toolCallbacks.setToolStatus(toolId, { - content: `Deploying ${type} "${path}"...` + content: `Deploying ${noun} "${path}"...` }) let actions: ToolDisplayAction[] | undefined @@ -7361,7 +7368,7 @@ async function deployDraft( } toolCallbacks.setToolStatus(toolId, { - content: `Deployed ${type} "${path}"`, + content: `Deployed ${noun} "${path}"`, result: 'Deployed', actions }) diff --git a/frontend/src/lib/components/copilot/chat/shared.ts b/frontend/src/lib/components/copilot/chat/shared.ts index 0e9fd516a6..648a8f2353 100644 --- a/frontend/src/lib/components/copilot/chat/shared.ts +++ b/frontend/src/lib/components/copilot/chat/shared.ts @@ -704,6 +704,8 @@ export type ToolDisplayMessage = { autoCollapseDetails?: boolean isStreamingArguments?: boolean toolName?: string + /** A `read_workspace_item` call that found an agent: the tool's `type` only says resource. */ + readsAgent?: boolean /** What marks this row with its provider. Recorded rather than looked up, because the * server listing lives only in memory and a reloaded transcript does not have it. The * workspace rides along: a chat is readable from any workspace, and the same path names diff --git a/frontend/src/lib/components/copilot/chat/toolGroups.test.ts b/frontend/src/lib/components/copilot/chat/toolGroups.test.ts index 2cf5da7095..2b11286830 100644 --- a/frontend/src/lib/components/copilot/chat/toolGroups.test.ts +++ b/frontend/src/lib/components/copilot/chat/toolGroups.test.ts @@ -290,6 +290,18 @@ describe('groupToolRuns', () => { expect(header([mcp('list_issues'), other])).toBe('List issues, get issue') }) + it('counts agent reads apart from other workspace item reads', () => { + const read = { type: 'resource', path: 'f/a/x' } + const agent = { readsAgent: true } + expect( + header([ + tool('read_workspace_item', read, agent), + tool('read_workspace_item', read, agent), + tool('read_workspace_item', read) + ]) + ).toBe('Read 2 agents, read workspace item') + }) + it('names the first three kinds of call and leaves the rest to `more`', () => { const group = groupToolRuns([ tool('search_workspace'), diff --git a/frontend/src/lib/components/copilot/chat/toolGroups.ts b/frontend/src/lib/components/copilot/chat/toolGroups.ts index 99773e6465..5d3f582a6c 100644 --- a/frontend/src/lib/components/copilot/chat/toolGroups.ts +++ b/frontend/src/lib/components/copilot/chat/toolGroups.ts @@ -348,6 +348,7 @@ function mcpServerPath(call: ToolDisplayMessage): string | undefined { } function callName(call: ToolDisplayMessage): string { + if (call.readsAgent) return 'read agent' const mcpTool = call.parameters?.tool const name = call.toolName === 'call_mcp_read_tool' && typeof mcpTool === 'string' @@ -375,6 +376,7 @@ const COUNTED_VERBS = new Set(['read', 'inspect']) function repeated(name: string, n: number): string { if (n === 1) return name const [verb, ...rest] = name.split(' ') + if (name === 'read agent') return `read ${n} agents` return COUNTED_VERBS.has(verb) && rest.length > 0 ? `${verb} ${n} ${rest.join(' ')}` : `${name} ${n} times` diff --git a/frontend/src/lib/components/itemSettings/AppAccessSection.svelte b/frontend/src/lib/components/itemSettings/AppAccessSection.svelte index 98a004e86f..b586551e97 100644 --- a/frontend/src/lib/components/itemSettings/AppAccessSection.svelte +++ b/frontend/src/lib/components/itemSettings/AppAccessSection.svelte @@ -75,6 +75,12 @@ canUserBypassRuleKind('RestrictGuestAppDeployment', $userStore ?? undefined)) ) + // The server refuses every deploy that leaves an app public on a free cloud workspace, so an + // already-public app can only be switched away from it. Read for `workspace`, which a session + // editor can set to another workspace than the one navigated to. + let premium = $state(undefined) + let publicNeedsPlan = $derived(isCloudHosted() && premium === false) + let guestUsage = $state(undefined) // The backend decides; the hostname stands in until it answers, the shared cloud being the // only deployment where guests are unavailable. @@ -84,6 +90,11 @@ let secretUrl: string | undefined = $state(undefined) function load() { + if (isCloudHosted()) { + WorkspaceService.getIsPremium({ workspace }) + .then((p) => (premium = p)) + .catch(() => (premium = undefined)) + } WorkspaceService.getGuestUsage({ workspace }) .then((u) => (guestUsage = u)) .catch(() => (guestUsage = undefined)) @@ -150,7 +161,18 @@
- {#if rulesetsLoaded && !canSetAnonymous && mode != 'anonymous'} + {#if publicNeedsPlan} + + On Windmill Cloud, publishing or updating an app that anyone can open without signing in + requires a paid plan. + {#if mode == 'anonymous'} + Switch this app to Members to deploy it. + {/if} + Upgrade this workspace + + {:else if rulesetsLoaded && !canSetAnonymous && mode != 'anonymous'} Opening this app to anyone with the link is restricted to workspace admins and bypass users by a workspace protection rule @@ -191,8 +213,10 @@ {/snippet} diff --git a/frontend/src/lib/components/sessions/SessionPicker.svelte b/frontend/src/lib/components/sessions/SessionPicker.svelte index b194592809..a6c8ceb630 100644 --- a/frontend/src/lib/components/sessions/SessionPicker.svelte +++ b/frontend/src/lib/components/sessions/SessionPicker.svelte @@ -61,6 +61,9 @@ import UnreadCountBadge from '$lib/components/common/badge/UnreadCountBadge.svelte' import { buildWorkspaceHierarchy } from '$lib/utils/workspaceHierarchy' import MenuButton, { sidebarClasses } from '$lib/components/sidebar/MenuButton.svelte' + import SidebarShowOlder, { + SIDEBAR_RECENT_MS + } from '$lib/components/sidebar/SidebarShowOlder.svelte' import DropdownV2 from '$lib/components/DropdownV2.svelte' import { userStore, userWorkspaces, workspaceStore } from '$lib/stores' import { workspaceIsFork } from '$lib/utils/workspaceHierarchy' @@ -175,10 +178,9 @@ ) } - // Flat list passing the archive + scope filters. Grouping for display happens - // in `sessionGroups`; this flat view drives the runtime effect, the unread - // total, and keyboard navigation. - const visibleSessions = $derived( + // Every session passing the archive + scope filters, the ones folded under "Show older" + // included. + const filteredSessions = $derived( sessionState.sessions.filter((s) => { // A draft Home's composer holds becomes a session when its first send starts, typed // or not. Unsent drafts opened onto an item stay listed: the row is their only way @@ -198,6 +200,25 @@ }) ) + // With no activity cutoff picked, sessions inactive for over a week fold under a "Show older" + // row, except the one on screen. A picked cutoff is the reader's own choice and folds nothing. + const showOlder = useLocalStorageValue('windmill_sessions_show_older', false, 'boolean') + const olderIds = $derived.by(() => { + if (lastActivityDays.val > 0) return new Set() + const cutoff = clock - SIDEBAR_RECENT_MS + return new Set( + filteredSessions + .filter((s) => s.id !== activeRowId && sessionLastActivityAt(s) < cutoff) + .map((s) => s.id) + ) + }) + + // The rows listed. Grouping for display happens in `sessionGroups`; this flat view drives + // the runtime effect, the unread total, and keyboard navigation. + const visibleSessions = $derived( + showOlder.val ? filteredSessions : filteredSessions.filter((s) => !olderIds.has(s.id)) + ) + // Sessions grouped by workspace family for display, each group by its last turn // start or end, latest first. Family order follows its latest session and is NOT tied // to the current workspace: pinning the active family first reshuffled the @@ -384,7 +405,7 @@ // sessions load, the list is empty for every reader, and the fold is a // layout they chose to keep. $effect(() => { - if (sessionState.hydrated && visibleSessions.length === 0 && sectionCollapsed.val) { + if (sessionState.hydrated && filteredSessions.length === 0 && sectionCollapsed.val) { sectionCollapsed.val = false } }) @@ -785,7 +806,7 @@ icon={MessageSquare} folded={sectionCollapsed.val} onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)} - disabled={visibleSessions.length === 0} + disabled={filteredSessions.length === 0} notify={totalUnread > 0} actions={sectionOptions} {isCollapsed} @@ -1132,6 +1153,15 @@ {/each} {/if}
+ + {#if olderIds.size > 0} + (showOlder.val = !showOlder.val)} + {rail} + /> + {/if} {#if selecting}