mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-28 00:02:42 +00:00
* docs: add design doc for automatic git-to-windmill pull sync
* docs: add migration plan and implementation phases to git-sync pull design
* feat(git-sync): add auto_pull settings schema and pull enqueue primitive
Adds AutoPullSettings/AutoPullMode/AutoPullStatus on GitRepositorySettings
(workspace_settings.git_sync JSONB), the GIT_SYNC_PULL_SCRIPT_PATH constant,
and should_pull/effective_poll_interval_s helpers with unit tests. Exports the
EE enqueue_git_pull_job primitive. Foundation for repo→Windmill auto-pull.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(git-sync): poll repos and auto-pull new commits into the workspace
Phase 1 of automatic repo → Windmill sync. A monitor task (EE-licensed,
single-replica via advisory lock) git ls-remotes each auto-pull-enabled
repository ~every minute and enqueues a pull when the tracked branch moves,
reusing the {workspace_id}:git_sync concurrency key so pulls serialize with
in-flight push commits.
- windmill-store: background (no-authed) resolver get_git_repo_head_for_autopull
that resolves the repo resource (incl. $var: refs) and ls-remotes; GitHub-App
repos are skipped here and will sync via webhooks (phase 2).
- monitor.rs: poll/reconcile/persist with optimistic sha advance and failure
status; targeted jsonb update so concurrent settings edits aren't clobbered.
- edit_git_sync_repository: preserve server-owned auto_pull state on UI save.
- openapi: AutoPullSettings/AutoPullMode/AutoPullStatus + auto_pull field.
- frontend: per-repo "Automatically deploy changes from Git" toggle with last
sync status; demote the GitHub Actions link to an advanced CI option.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(git-sync): wire webhook lifecycle + receiver; share reconcile logic
OSS side of phase 2 auto-pull webhooks:
- edit_git_sync_repository creates/removes the repo webhook on save (EE-gated,
best-effort → falls back to polling).
- monitor poller now delegates to the shared windmill_git_sync reconcile/persist
helpers (also used by the webhook receiver), removing duplicated logic.
- export the shared reconcile/persist/failure helpers; bump EE ref.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(git-sync): bump EE ref for phase 3 in-app PR creation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(git-sync): show webhook vs polling status on the auto-pull toggle
When a repo has an active webhook (auto_pull.webhook_id set), the status line
reads "instant via webhook"; otherwise it reads the ~1-minute polling cadence.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(git-sync): post PR diff check on dry-run completion (phase 4)
Worker completion hook in process_completed_job: when a DeploymentCallback job
carrying the __git_sync_pr_check marker finishes, parse the dry-run SyncResponse
and patch the GitHub check run with the diff summary (success/neutral/failure).
Export enqueue_git_pull_dry_run; bump EE ref.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(git-sync): bump EE ref (drop unused GHES webhook_secret)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* revert(git-sync): defer phase 4 PR diff checks (OSS side)
Remove the worker completion hook that posted the PR check run, drop the
enqueue_git_pull_dry_run re-export and the orphaned sqlx cache, bump EE ref.
Phases 1-3 (polling, webhooks, in-app PR creation) are unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Revert "revert(git-sync): defer phase 4 PR diff checks (OSS side)"
This reverts commit 0137d3ca48.
* chore(git-sync): point EE ref at restored phase 4 commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(git-sync): bump EE ref for clone_ref dry-run
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(git-sync): bump init-repository hub script to v28784
Picks up the clone_ref param (windmill-integrations#158) so the phase 4 PR-check
dry-run can clone the PR head. Backward compatible; manual pull/push and the
automated pull/poller/webhook all move to the same published version.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(git-sync): bump EE ref for auto-pull admin-permissioning fix
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(git-sync): bump EE ref for superadmin pull fallback
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(git-sync): refresh auto-pull tooltip; bump EE ref for webhook secret encryption
The auto-pull toggle tooltip claimed GitHub App repos would sync via
webhooks "in a future update"; webhook delivery now works, so describe
the webhook-vs-polling behavior accurately. Bump the EE ref to pick up
encrypting the webhook HMAC secret at rest.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(git-sync): poll app-backed repos in auto/polling mode
The auto-pull poller skipped app-backed repos (the ls-remote head check
can't authenticate a tokenless URL), so auto- and polling-mode app repos
never synced when their webhook wasn't live. Wire the poller to fetch the
head via the GitHub API for app repos and reconcile. Bump the EE ref.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(git-sync): auto-pull UI — direction split, delivery mode, fallback notice
Reorganize the repository card into two clearly labeled directions:
"Push to Git on deploy (Windmill → Git)" and "Pull from Git (Git →
Windmill)". In the pull section:
- new connections default to auto-pull enabled (webhook with polling
fallback); existing repos load with auto-pull off and are unchanged
- a Delivery selector chooses "Webhook with polling fallback" or
"Polling only (air-gapped)"
- a notice surfaces webhook_error when delivery falls back to polling
- a reminder to remove any pre-existing GitHub Action that pushed into
Windmill, to avoid conflicting double-syncs
Adds the webhook_error field to AutoPullSettings (+ openapi) and bumps
the EE ref.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(git-sync): clearer push indicator + gate webhook delivery to app repos
- Push-on-deploy is shown with a check icon + concise line (via the
shared GitSyncModeDisplay, restyled from the oversized "Sync:" text);
the setup wizard reuses it without the check (pre-save preview).
- The delivery-mode selector only shows for GitHub App-backed repos;
token-based repos show a "webhooks require the GitHub App (managed or
GHES)" note with a docs link and poll instead. Bumps the EE ref.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(git-sync): fork auto-sync (phase 5) + live deploy check (phase 6)
Phase 5 — fork auto-sync configured at the parent (replaces the *-to-forks
GitHub Actions):
- Add fork_open_prs + fork_pull_sync to GitRepositorySettings (openapi + UI).
- UI: two "Forks of this workspace" toggles in the repo card, gated on
app-backed and not-a-fork; serialize the flags on save.
- On fork creation, strip the inherited auto_pull block (and fork_* flags) from
the copied git_sync repo: a fork must not carry the parent's webhook id (it
would delete the parent's hook on disable) or self-poll on top of the parent's
fan-out. Push-direction config + installation are still inherited unchanged.
Phase 6 — live deploy status check on the commit (Cloudflare-style): an
in-progress "Windmill" check on the head commit that flips to "Deployed N
changes"; completion handled by the generalized git-sync check hook.
Bump EE ref for the phase 5-6 EE implementation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* chore(git-sync): bump EE ref for PAT auto-pull mode normalization
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): address PR review findings
- webhook_secret: redact from the settings API response and Debug output (still
persisted encrypted); it's a server-only HMAC key the UI never needs.
- poller: honor each repo's effective poll interval (relaxed ~10 min when a
webhook is live) instead of probing every ~60s tick.
- settings save: roll back a just-created webhook if the settings transaction
doesn't commit, so a failed save can't orphan a hook.
- auto-pull head check: fail SSH remotes with an actionable message (background
polling has no SSH identity) instead of a confusing ls-remote error.
- deploy/PR check summary: a pull result carrying neither changes nor a settings
diff now falls back to the unsummarized path instead of a false "in sync".
- UI: reset isGithubApp on resource change / failed fetch so webhook + fork
controls can't show for the wrong repo.
- tests: cover parse_git_sync_changes and format_change_list edge cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): correct feature gating for OSS builds
- monitor.rs: keep the AUTO_PULL_LAST_POLL static, slack const, and
poll_git_auto_pull_inner all behind #[cfg(feature = "private")] (an inserted
static had split the cfg off the function, ungating it in OSS builds).
- edit_git_sync_repository: the webhook create/rollback block references
windmill_common::git_sync_ee (private module), so gate it on
all(enterprise, private) instead of enterprise only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* chore(sqlx): cache workspace_diff query pulled in from origin/main
Re-merged origin/main (advanced past the earlier merge); regenerate the offline
sqlx entry for the new workspace_comparison test query so SQLX_OFFLINE builds
(cargo_test) pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): address Codex review findings (webhook cleanup on delete)
- Deleting a git-sync repository now tears down its managed GitHub webhook
(deletion bypassed the sync_repo_webhook lifecycle, orphaning the hook so
GitHub kept delivering to the instance).
- Worker completion hook rolls back the optimistic auto-pull sha on job failure
(OSS side of the EE change) + caches the new marker query. Bump EE ref.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): delete repo webhook after the removal commits
Codex re-review nits:
- delete_git_sync_repository deleted the webhook before the settings transaction
committed; a failed save would then leave the repo pointing at a hook that no
longer exists (sync_repo_webhook treats a set webhook_id as live and won't
recreate it). Capture the hook id, commit the DB removal, then delete the hook.
- Reword a fork-copy comment to drop drafting-history wording per AGENTS.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): reconcile the edit-path webhook after the settings commit
Codex nit: edit_git_sync_repository ran sync_repo_webhook before the transaction
committed. The rollback only covered created hooks, but sync_repo_webhook also
deletes a hook on disable/switch-to-polling — a commit failure then left the DB
with a webhook_id whose hook was already gone (and it wouldn't be recreated).
Save + commit first, then reconcile the webhook against the durable config and
persist any hook id/secret change (best-effort). Bump EE ref.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): preserve webhook secret on whole-config save + default on visible add
Codex nits:
- edit_git_sync_config saved the client config verbatim, so the webhook_secret
redacted from the GET response would be dropped (breaking delivery). Preserve
server-owned auto-pull state (webhook id/secret, synced sha, last status) per
repo from the existing settings, matching edit_git_sync_repository.
- addSyncRepository (the visible add path) didn't set the auto_pull default, so
new sync repos added from the UI came up with auto-deploy off. Match
addRepository's default (webhook + polling fallback).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* refactor(git-sync): drop fork_pull_sync (parent-level keep-forks-in-sync)
Removes the "Keep forks in sync with the tracked branch" toggle and its
fan-out. Pulling the tracked branch straight into every fork was the
inconsistent piece; the consistent model is per-fork branch sync (each
fork tracks its own wm-fork/** branch), which is a separate follow-up.
fork_open_prs is kept. Also tightens the fork toggle-section spacing.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): detect dev workspaces in CLI fork branch derivation
isForkWorkspace / computeGitSyncDeployBranch keyed off the wm-fork- id
prefix. Dev workspaces are forks with a custom, prefix-less id, so their
wm-fork/** branch was never derived or created. Detect them via
parent_workspace_id too (which the backend already passes), mirroring the
backend's `parent.is_some() || wm-fork- prefix` rule.
Pairs with the hub-script clone-flag fix (windmill-integrations#163); both
take effect once the CLI is released and the pinned version is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): reconcile webhooks on full-config save
edit_git_sync_config preserved server-owned webhook fields but never
created or deleted the managed GitHub webhook, so enabling auto-pull
through the whole-config endpoint only polled, and disabling or removing
a repo left an orphan hook still delivering. Mirror the per-repository
endpoint: after the commit is durable, reconcile every saved repo's
webhook (sync_repo_webhook) and delete the hooks of repos the save
removed, including the clear-whole-config case. Addresses the Codex nit.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): address Codex nits (webhook orphan on cleared auto_pull, fork detection)
- edit_git_sync_config: also delete a repo's old webhook when the save drops
the repo OR clears its auto_pull. Webhook fields are only preserved onto a
Some auto_pull, so a save that present-but-clears a repo would otherwise
orphan its hook.
- GitSyncRepositoryCard: isFork now uses parent_workspace_id OR the wm-fork-
prefix (was AND), matching the backend/CLI rule, so prefix-less dev
workspaces are detected as forks and don't show the parent fork-PR toggle.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* docs(git-sync): update design doc for the dropped fork_pull_sync
Phase 5 documented "Keep forks in sync with the tracked branch"
(fork_pull_sync) and its fan-out as implemented; that feature was removed.
Rewrite the section to reflect what ships (fork_open_prs), note the drop +
the per-fork-branch follow-up, and remove the stale fan-out mentions
elsewhere. Addresses the Codex nit.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): redact webhook secrets from workspace export; fix doc endpoints
- Export (P1): strip the server-owned auto_pull state (webhook secret/id/error
+ synced sha + last pull status) from git_sync before it is written into an
export's settings.json for both settings formats. The HMAC webhook secret
must never leave the server (matching the GET-settings redaction), and a
re-imported workspace must not inherit another install's hook/sync state.
- Docs: the webhook receiver is a single per-workspace endpoint
/api/w/{workspace}/github_app/webhook (host-aware for managed + self-managed);
update the stale push_webhook/{id} and instance-global /api/github_app/webhook
references.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): skip deleted/archived workspaces in the auto-pull poller
The poller scanned workspace_settings directly, so an archived (soft-deleted)
or renamed-away workspace — whose settings row persists — kept polling and
could enqueue a pull into a dead workspace. Join workspace and require
NOT deleted. The EE webhook receiver gets the same filter (ee ref bumped).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): never trust client-supplied server-owned auto-pull fields
Both write endpoints (edit_git_sync_repository, edit_git_sync_config)
persisted caller-supplied auto_pull.webhook_id / webhook_secret /
webhook_error / last_synced_sha / last_pull_status when adding a repo or
newly enabling auto-pull, letting a client inject a webhook id/secret or
fake sync state. Strip those server-owned fields from the request up front;
existing repos re-derive them from the DB (carried over), new ones start
clean and the server (re)creates the webhook.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): merge webhook fields post-commit instead of clobbering the row
The post-commit webhook reconcile in edit_git_sync_repository and
edit_git_sync_config wrote the whole pre-reconcile git_sync snapshot back
after the main save committed. A concurrent git-sync edit or poller status
write that landed in the gap could then be dropped by the stale snapshot.
Re-read the current row and merge only the reconciled webhook id/secret/error
for the repos the reconcile actually changed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): parent-managed fork sync + PR-on-deploy toggles
Fork sync (push-on-merge-to-forks parity): a parent-level
auto_pull.sync_forks toggle routes changes on each fork's wm-fork/** branch
into that fork workspace, via the parent's existing webhook and one extra
fork-heads listing per poll tick (git ls-remote pattern for token repos,
git/matching-refs for app-backed). Fork state is a server-written
status-only auto_pull blob on the fork's own repo entry; the fork's card
shows a read-only "managed in the parent workspace" line with its branch
and last pull status. Dev workspaces (prefix-less ids) use the same branch
parsing (unit-tested in windmill-common).
PR-on-deploy: opening PRs for Windmill-pushed branches moves into the
deploy pipeline, per repo toggle (promotion_open_prs on the promotion
repo; parent-level fork_open_prs for fork deploys). The push job carries a
marker and the job-completion hook derives the pushed branch (helper
unit-tested against the CLI formula) and opens the PR outbound, so it
works without inbound webhooks; the webhook-side wm_deploy PR arm is
removed. The documented open-pr-* GitHub Actions remain valid alternatives
(PR creation is idempotent).
Fork guards: promotion mode, enabled auto-pull, and fork_open_prs are
rejected on fork workspaces (they are parent-managed; a fork's deploys
always target its wm-fork/** branch) and the promotion card is hidden in a
fork's settings. Enabling auto-pull now also requires EE, and the
post-commit webhook reconcile persists the normalized delivery mode.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): dev workspaces sync with their environment-label branch
A dev workspace's git branch is its environment label verbatim (dev/
staging, default dev) — a first-class env branch like the documented
push-on-merge-staging layout — instead of the wm-fork/** form. The label
rides the deploy job args (backend → hub script → CLI
--dev-workspace-label), the PR completion hook derives the same head, the
webhook/poller route label branches into the matching dev-workspace child
(poller lists them alongside wm-fork/* via extra ls-remote refs / per-label
API lookups), and manual pulls from the UI pass clone_ref accordingly. The
CLI refuses to deploy when the label branch equals the checked-out tracked
branch, which would otherwise commit fork content straight to it.
Because the branch is keyed on the label, the label is now immutable after
creation: set at create/attach only, the set_dev_workspace_label endpoint
is removed and the settings tab shows it read-only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): nested fork routing + fork-of-dev branch rooting
A fork of a dev workspace now roots its wm-fork/** branch on the dev's
environment-label branch (the content it diverged from) and its PR merges
back into that branch: the backend passes parent_dev_workspace_label with
the deploy (parent row joined in both enqueue paths), the CLI gains
--parent-dev-workspace-label and checks it before the wm-fork- prefix
fallback when rooting a fork-of-a-fork branch, and the PR completion hook
uses it as the PR base.
Fork sync routing covers the whole live descendant chain of the
webhook/poller workspace (recursive, depth-capped) instead of direct
children only, and fork_open_prs is resolved at the root ancestor — only
the root can hold auto-pull config, so grandchild forks sync through it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): PR deploy-preview comment, clearer check copy, app-only hints
- The PR diff completion hook maintains one managed comment on the PR
(Cloudflare deploy-preview style: workspace, status, commit, collapsible
change list), upserted per synchronize via a hidden marker. The check run
stays for required-check gating.
- A settings difference in the diff summary is worded by cause: the PR
changes wmill.yaml, vs pre-existing drift between the repo's wmill.yaml
and the workspace, vs undetermined (neutral wording).
- Deploy-status check titles name the target workspace ("Deployed 2
change(s) to staging"), since GitHub shows a head commit's checks on any
PR containing it and a bare "Deployed" read as if the PR had deployed.
- Token-based repos see a hint pointing at the open-pr-on-commit /
open-pr-on-fork-commit workflows where the app-only PR toggles would be;
an API-set toggle on a non-app repo now logs a warning naming the
fallback; the design doc lists app-only features and their degradation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): EE-gate auto-pull UI, fork pull clone_ref, no-op push PR gate
- CE: the auto-pull and fork-PR toggles are disabled with an EE badge, and
new sync repos only default them on when licensed (basic git sync is
available on CE since #8493, but auto-pull is EE and the backend rejects it)
- The pull modal passes clone_ref for wm-fork- forks (wm-fork/<tracked>/<id>)
so a manual pull fetches the fork branch instead of the tracked branch head
- PR-on-deploy skips no-op pushes: when the push script reports pushed=false
(e.g. the deploy was caused by an auto-pull), the completion hook no longer
ensures a PR, so closed PRs aren't recreated by the sync loop
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* chore: refresh package-lock after main merge (windmill-utils-internal 1.8.2)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* test: auto-pull e2e integration tests; fix PR comment table formatting
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): runtime license gate for auto-pull saves; user/group promotion-branch parity
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): explain in-sync PR verdicts with the repo's sync filter scope
A PR that only touches files outside the repository's include paths gets
"In sync", which reads as a wrong verdict; the check summary (and managed
comment) now name the filters, e.g. "Only files matching this repository's
sync filters deploy on merge: `f/**` (excluding `f/pat/**`)."
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): clearer card copy/structure; surface PR-creation failures
- Fork sync toggle renamed and kept in the pull section; the fork PR toggle
moves to the push section with a note that push settings apply to forks
- Fork/dev workspaces' push section names their actual branch instead of the
tracked-branch line; promotion repos hide the pull direction (promotion
pushes deploy branches on top of a sync-mode setup)
- Promotion mode line describes the wm_deploy/** branch + merge-to-promote
flow; workflow-fallback hints lead with the how-to and link to the docs;
test connection button demoted from accent per brand guidelines
- New server-owned open_pr_error on repo settings: the deploy completion hook
records why a PR couldn't be opened (e.g. app permission not yet approved)
and clears it on the next success; shown as a warning under the PR toggles
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix: cfg-gate scope-note helper (dead code on OSS builds)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): license-gate preserved auto-pull; attach strips parent-only settings
- edit_git_sync_repository re-checks the runtime Enterprise gate against the
EFFECTIVE repo state after preservation: the older-client arm copies the
existing auto_pull back, which the request-side check never saw
- attach_dev_workspace now mirrors the fork-creation copy on the attached
workspace's own git sync: promotion repos dropped, auto_pull/fork PRs/PR
error stripped, and any managed webhook deleted after commit (the attached
workspace is parent-managed and must not keep pulling its old tracked branch)
- integration test: attaching an auto-pull-enabled workspace strips it
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): detach clears standalone parent; reject label == tracked branch
- detach_dev_workspace clears parent_workspace_id for prefix-less (attached
standalone) workspaces so they stop classifying as forks and deploying to
wm-fork/** branches; wm-fork- re-designated forks keep their parent; cache
invalidations mirror attach
- dev-workspace create/attach reject an environment label that equals a
git-sync repository's tracked branch (prod's or the candidate's): deploys
would target the very branch the repo syncs from, and the CLI guard would
fail every push job after the fact
- CLI unit tests: prefix-less fork beats wm_deploy derivation; isForkWorkspace
parent-id argument
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* chore(git-sync): bump hub script pins (push 28786, pull 28785)
Published from windmill-integrations #163 with windmill-cli@1.753.1-gitsync.0:
dev-workspace label deploys, fork-of-dev rooting, fork checkout on the
existing remote branch, and the pushed-flag result.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): no parent-only defaults on fork repos; rename strips webhook state
- addSyncRepository skips the auto_pull/fork_open_prs defaults on fork/dev
workspaces where the backend rejects them (saving a new sync repo from an
EE fork 400'd deterministically)
- change_workspace_id strips webhook id/secret/error from the copied git_sync
and deletes the stale GitHub hooks post-commit: they deliver to the old
(archived) workspace URL, so the new workspace would report a live webhook
while polling at the relaxed interval; next save re-registers cleanly
- EE: PR diff checks for contributor-fork PRs clone the synthetic
pull/<n>/head ref (head.ref doesn't exist in the base repo)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* chore(git-sync): bump pull script pin to hub/28787 (synthetic PR ref support)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): targeted jsonb update for open_pr_error (no full-blob clobber)
The full read-modify-write raced the poller's concurrent last_synced_sha /
last_pull_status writes on the same column; mirror the EE status writer and
update only the matching repository element's open_pr_error key.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* style(git-sync): inline EE badge on gated toggles (matches settings nav)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* copy(git-sync): both directions in page/card descriptions; clearer promotion flow
- Page header and sync-card description mention the pull direction, not only
push-on-deploy
- Promotion description walks the actual flow (wm_deploy/** branch, merge to
promote, sync the target workspace) and points at the PR toggle / workflow;
the Git Promotion docs link now also shows on configured cards, not only in
the empty state
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): resolve branch-less resources' default branch for fork sync
A git resource without an explicit branch polled as the bare "HEAD" ref,
which the fork/dev-label fan-out cannot scope (wm-fork/<branch>/*), so fork
sync silently never ran on polling-only repos. Resolve the remote's default
branch name with `ls-remote --symref HEAD` (one call for name + head sha);
"HEAD" only remains when resolution fails. The polling e2e test now uses a
branch-less resource to cover this shape.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): runtime license gate for in-app PR creation
promotion_open_prs/fork_open_prs are rejected on save without an Enterprise
plan (like auto_pull), and the deploy completion hook re-checks the plan
before opening PRs so flags stored while licensed stop driving GitHub calls
after a lapse.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): app-aware pull defaults, always webhook delivery, token-repo guidance
- Pull-from-Git defaults on only for app-backed repos (applied when the
selected resource resolves); polling is opt-in for token repositories,
with a warning alert recommending the GitHub App (instant pull + in-app
PRs) or the sync GitHub workflow
- App repos always use webhook delivery with polling fallback: the delivery
selector is gone and a stored polling mode is normalized back to auto
- Post-save modal reflects the auto-pull state instead of telling the user
to turn on a toggle that is already on
- Non-app PR hints recommend the GitHub App explicitly
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* copy(git-sync): single info box for token-repo pull guidance
Merges the instant-pull recommendation with the GitHub Action conflict note,
shown only for non-app repos; app repos need neither, and the redundant
'instant webhook sync requires' line is gone.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* copy(git-sync): keep the GitHub Action conflict note on app repos
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* copy(git-sync): anchor docs links to their exact sections
GitHub App references point at integrations/git_repository#github-app, the
workflow hints at deploy_gh_gl#github-actions-setup, and the sync workflow
at git_sync#github-actions (all anchors verified against the live docs).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* copy(git-sync): fork workflow hint links to git_sync#github-actions
open-pr-on-fork-commit is documented on the git_sync page, not deploy_gh_gl.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* fix(git-sync): fork PRs are opt-in on new connections too
Only auto-pull and fork sync default on for new app-backed connections;
opening pull requests stays a deliberate per-repo decision.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* feat(git-sync): default the managed PR on for new app-backed promotion repos
A promotion deploy's wm_deploy/** branch exists to be merged; without a PR
it's an orphaned branch. Fork PRs stay opt-in. Also scope the sync-repo
auto-pull default to sync mode so promotion repos can't pick it up.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* docs(git-sync): GHES self-managed app permission setup
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* docs(git-sync): frame permission update against GitHub Actions, not polling
Existing installations don't have polling; their git-to-Windmill direction
runs on GitHub Actions today, so the approval text describes the update as
replacing those workflows and notes every feature is opt-in.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm
* copy(workspaces): drop 'cosmetic' qualifier from dev-workspace label UI
* chore: update ee-repo-ref to 9b2a6375f838436cf68cff449cc9bc621cca5281
This commit updates the EE repository reference after PR #632 was merged in windmill-ee-private.
Previous ee-repo-ref: 99eef24e2f0402b9a997cde5f67be52ee5d54b0e
New ee-repo-ref: 9b2a6375f838436cf68cff449cc9bc621cca5281
Automated by sync-ee-ref workflow.
* fix(git-sync): reject '/' in fork and dev workspace ids
* fix(git-sync): bound auto-pull git probes with a per-command timeout
* fix(git-sync): persist webhook reconcile via targeted jsonb updates
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
667 lines
21 KiB
Svelte
667 lines
21 KiB
Svelte
<script lang="ts">
|
|
import Modal from '$lib/components/common/modal/Modal.svelte'
|
|
import { Button, Alert, Badge } from '$lib/components/common'
|
|
import {
|
|
Loader2,
|
|
CheckCircle2,
|
|
XCircle,
|
|
Terminal,
|
|
ChevronDown,
|
|
ChevronUp,
|
|
Save,
|
|
Edit3
|
|
} from 'lucide-svelte'
|
|
import GitDiffPreview from '../GitDiffPreview.svelte'
|
|
import { JobService, ResourceService } from '$lib/gen'
|
|
import { workspaceStore, userWorkspaces } from '$lib/stores'
|
|
import { sendUserToast } from '$lib/toast'
|
|
import hubPaths from '$lib/hubPaths.json'
|
|
import { jobManager } from '$lib/services/JobManager'
|
|
import type { SyncResponse, SettingsResponse, SettingsObject } from '$lib/git-sync'
|
|
|
|
interface Props {
|
|
open: boolean
|
|
gitRepoResourcePath: string
|
|
uiState: SettingsObject
|
|
repoIndex?: number
|
|
currentGitSyncSettings?: any
|
|
onFilterUpdate?: (filters: SettingsObject) => void
|
|
onSettingsSaved?: () => void
|
|
onSuccess?: () => void
|
|
settingsOnly?: boolean
|
|
}
|
|
|
|
let {
|
|
open = $bindable(false),
|
|
gitRepoResourcePath,
|
|
uiState,
|
|
repoIndex,
|
|
currentGitSyncSettings,
|
|
onFilterUpdate,
|
|
onSettingsSaved,
|
|
onSuccess,
|
|
settingsOnly = false
|
|
}: Props = $props()
|
|
|
|
// Job state
|
|
let previewJobId = $state<string | null>(null)
|
|
let previewJobStatus = $state<'running' | 'success' | 'failure' | undefined>(undefined)
|
|
let isPreviewLoading = $state(false)
|
|
let previewError = $state('')
|
|
|
|
let applyJobId = $state<string | null>(null)
|
|
let applyJobStatus = $state<'running' | 'success' | 'failure' | undefined>(undefined)
|
|
let isApplying = $state(false)
|
|
let applyError = $state('')
|
|
|
|
// UI state
|
|
let showCliInstructions = $state(false)
|
|
let previewResult = $state<SyncResponse | SettingsResponse | null>(null)
|
|
let settingsApplied = $state(false)
|
|
let previewAttempted = $state(false)
|
|
|
|
// Helper functions to reduce type casting repetition
|
|
const getSettingsChanges = (result: SyncResponse | SettingsResponse | null) => {
|
|
if (!result) return { hasChanges: false, data: null, diff: null }
|
|
|
|
if (settingsOnly) {
|
|
const settingsResponse = result as SettingsResponse
|
|
return {
|
|
hasChanges: settingsResponse.hasChanges ?? false,
|
|
data: settingsResponse.local,
|
|
diff: settingsResponse
|
|
}
|
|
} else {
|
|
const syncResponse = result as SyncResponse
|
|
return {
|
|
hasChanges: syncResponse.settingsDiffResult?.hasChanges ?? false,
|
|
data: syncResponse.settingsDiffResult?.local,
|
|
diff: syncResponse.settingsDiffResult
|
|
}
|
|
}
|
|
}
|
|
|
|
const getWorkspaceChanges = (result: SyncResponse | SettingsResponse | null) => {
|
|
if (!result || settingsOnly) return { hasChanges: false, changes: [] }
|
|
const syncResponse = result as SyncResponse
|
|
return {
|
|
hasChanges: (syncResponse.changes?.length ?? 0) > 0,
|
|
changes: syncResponse.changes ?? []
|
|
}
|
|
}
|
|
|
|
// Auto-save settings after successful pull with settings updates
|
|
async function saveUpdatedSettings() {
|
|
if (!currentGitSyncSettings || repoIndex === undefined) return
|
|
|
|
try {
|
|
// Save only the specific repository that was updated
|
|
await currentGitSyncSettings.saveRepository(repoIndex)
|
|
onSettingsSaved?.()
|
|
} catch (error) {
|
|
console.error('Failed to save settings:', error)
|
|
sendUserToast('Failed to save updated settings', true)
|
|
}
|
|
}
|
|
|
|
// Reset state when modal opens/closes
|
|
$effect(() => {
|
|
if (!open) {
|
|
previewJobId = null
|
|
previewJobStatus = undefined
|
|
isPreviewLoading = false
|
|
previewError = ''
|
|
applyJobId = null
|
|
applyJobStatus = undefined
|
|
isApplying = false
|
|
applyError = ''
|
|
showCliInstructions = false
|
|
previewResult = null
|
|
settingsApplied = false
|
|
previewAttempted = false
|
|
} else if (settingsOnly && !previewResult && !isPreviewLoading && !previewAttempted) {
|
|
// Auto-trigger settings preview when modal opens in settings-only mode (only once)
|
|
executeJob(true, true)
|
|
}
|
|
})
|
|
|
|
// Execute job with dry run or actual execution
|
|
async function executeJob(isDryRun: boolean, settingsOnly: boolean = false) {
|
|
const isPreview = isDryRun
|
|
|
|
if (isPreview) {
|
|
isPreviewLoading = true
|
|
previewError = ''
|
|
previewResult = null
|
|
previewJobId = null
|
|
previewJobStatus = undefined
|
|
previewAttempted = true
|
|
} else {
|
|
isApplying = true
|
|
applyError = ''
|
|
applyJobId = null
|
|
applyJobStatus = undefined
|
|
}
|
|
|
|
try {
|
|
const workspace = $workspaceStore
|
|
if (!workspace) return
|
|
|
|
// A dev workspace pulls from its environment-label branch (dev/staging)
|
|
// and a fork from its wm-fork/<tracked>/<id> branch, not the resource's
|
|
// tracked branch. clone_ref falls back to the tracked branch in the
|
|
// pull script when the override branch doesn't exist yet.
|
|
const currentWs = $userWorkspaces?.find((w) => w.id === workspace)
|
|
const isFork = workspace.startsWith('wm-fork-') || Boolean(currentWs?.parent_workspace_id)
|
|
let cloneRef: string | undefined = undefined
|
|
if (currentWs?.is_dev_workspace) {
|
|
cloneRef = currentWs.dev_workspace_label ?? 'dev'
|
|
} else if (isFork) {
|
|
try {
|
|
const resource = await ResourceService.getResource({
|
|
workspace,
|
|
path: gitRepoResourcePath
|
|
})
|
|
const trackedBranch = (resource.value as any)?.branch
|
|
if (trackedBranch) {
|
|
cloneRef = `wm-fork/${trackedBranch}/${workspace.replace(/^wm-fork-/, '')}`
|
|
}
|
|
} catch (e) {
|
|
console.warn('Could not resolve tracked branch for fork pull:', e)
|
|
}
|
|
}
|
|
const payload = {
|
|
workspace_id: workspace,
|
|
repo_url_resource_path: gitRepoResourcePath,
|
|
dry_run: isDryRun,
|
|
pull: true,
|
|
only_wmill_yaml: settingsOnly,
|
|
settings_json: JSON.stringify(uiState),
|
|
use_promotion_overrides:
|
|
currentGitSyncSettings?.repositories?.[repoIndex!]?.use_individual_branch === true,
|
|
...(cloneRef ? { clone_ref: cloneRef } : {})
|
|
}
|
|
|
|
const jobId = await JobService.runScriptByPath({
|
|
workspace,
|
|
path: hubPaths.gitInitRepo,
|
|
requestBody: payload,
|
|
skipPreprocessor: true
|
|
})
|
|
|
|
if (isPreview) {
|
|
previewJobId = jobId
|
|
previewJobStatus = 'running'
|
|
} else {
|
|
applyJobId = jobId
|
|
applyJobStatus = 'running'
|
|
}
|
|
|
|
// Use JobManager instead of tryEvery
|
|
const result = await jobManager.runWithProgress(() => Promise.resolve(jobId), {
|
|
workspace,
|
|
timeout: 60000,
|
|
timeoutMessage: `${isPreview ? 'Preview' : 'Apply'} job timed out after 60s`,
|
|
onProgress: (status) => {
|
|
if (isPreview) {
|
|
previewJobStatus = status.status
|
|
} else {
|
|
applyJobStatus = status.status
|
|
}
|
|
|
|
// Handle failure status
|
|
if (status.status === 'failure') {
|
|
if (isPreview) {
|
|
previewError = status.error || 'Preview failed'
|
|
} else {
|
|
applyError = status.error || 'Pull failed'
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
// Handle successful result
|
|
if (isPreview) {
|
|
if (previewJobStatus === 'success') {
|
|
previewResult = result as SyncResponse | SettingsResponse
|
|
}
|
|
} else {
|
|
if (applyJobStatus === 'success') {
|
|
const settingsData = (result as any)?.local
|
|
const hasSettingsChanges = settingsData && onFilterUpdate
|
|
if (hasSettingsChanges) {
|
|
onFilterUpdate(settingsData)
|
|
await saveUpdatedSettings()
|
|
}
|
|
onSuccess?.()
|
|
}
|
|
}
|
|
} catch (e) {
|
|
const errorMsg = e?.message || 'Operation failed'
|
|
if (isPreview) {
|
|
previewJobStatus = 'failure'
|
|
previewError = errorMsg
|
|
} else {
|
|
applyJobStatus = 'failure'
|
|
applyError = errorMsg
|
|
}
|
|
} finally {
|
|
if (isPreview) {
|
|
isPreviewLoading = false
|
|
} else {
|
|
isApplying = false
|
|
}
|
|
}
|
|
}
|
|
|
|
// Apply settings only (no job needed - we have the data from preview)
|
|
async function applySettingsOnly() {
|
|
isApplying = true
|
|
|
|
try {
|
|
const settingsChanges = getSettingsChanges(previewResult)
|
|
|
|
if (!settingsChanges.hasChanges) {
|
|
sendUserToast('No settings changes to apply', true)
|
|
return
|
|
}
|
|
|
|
if (!settingsChanges.data) {
|
|
sendUserToast('Settings data not available', true)
|
|
return
|
|
}
|
|
|
|
// Update the UI state with the new settings
|
|
if (onFilterUpdate) {
|
|
onFilterUpdate(settingsChanges.data)
|
|
}
|
|
|
|
// Save the updated settings
|
|
await saveUpdatedSettings()
|
|
|
|
if (settingsOnly) {
|
|
// Settings-only mode - we're done, onSuccess will handle the toast
|
|
onSuccess?.()
|
|
} else {
|
|
// Two-step flow - transition to step 2
|
|
settingsApplied = true
|
|
sendUserToast('Settings applied successfully. You can now review workspace changes.')
|
|
}
|
|
} catch (error: any) {
|
|
console.error('Failed to apply settings:', error)
|
|
sendUserToast('Failed to apply settings: ' + error.message, true)
|
|
} finally {
|
|
isApplying = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<Modal
|
|
bind:open
|
|
title={settingsOnly ? 'Pull Settings from Git Repository' : 'Pull Workspace from Git Repository'}
|
|
class="sm:max-w-4xl"
|
|
cancelText={settingsOnly && !getSettingsChanges(previewResult).hasChanges ? 'Close' : 'Cancel'}
|
|
>
|
|
<div class="flex flex-col gap-4">
|
|
<!-- Description -->
|
|
<p class="text-sm text-secondary">
|
|
{#if settingsOnly}
|
|
Pull and apply settings changes from the Git repository to your workspace. This will update
|
|
your sync filter settings only.
|
|
{:else}
|
|
Pull and apply changes from the Git repository to your workspace. If settings changes are
|
|
detected, you can choose to pull just the settings or everything.
|
|
{/if}
|
|
</p>
|
|
|
|
<!-- Warning about overwrites - only show for full pulls, not settings-only -->
|
|
{#if !settingsOnly}
|
|
<Alert type="warning" title="This will overwrite local changes">
|
|
Pulling from the repository will overwrite any local changes to files that exist in the
|
|
repository. Make sure to preview the changes before applying.
|
|
</Alert>
|
|
{/if}
|
|
|
|
<!-- Preview section -->
|
|
{#if !previewResult}
|
|
<div class="flex justify-start pt-4">
|
|
<Button
|
|
size="md"
|
|
variant="accent"
|
|
onclick={() => {
|
|
previewAttempted = false // Allow manual retry
|
|
executeJob(true, settingsOnly)
|
|
}}
|
|
disabled={isPreviewLoading}
|
|
startIcon={{
|
|
icon: isPreviewLoading ? Loader2 : undefined,
|
|
classes: isPreviewLoading ? 'animate-spin' : ''
|
|
}}
|
|
>
|
|
{isPreviewLoading ? 'Previewing...' : 'Preview changes'}
|
|
</Button>
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- Job status for preview -->
|
|
{#if previewJobId}
|
|
<div class="flex items-center gap-2 text-xs text-primary">
|
|
{#if previewJobStatus === 'running'}
|
|
<Loader2 class="animate-spin" size={14} />
|
|
{:else if previewJobStatus === 'success'}
|
|
<CheckCircle2 size={14} class="text-green-600" />
|
|
{:else if previewJobStatus === 'failure'}
|
|
<XCircle size={14} class="text-red-700" />
|
|
{/if}
|
|
Preview job:
|
|
<a
|
|
target="_blank"
|
|
class="underline"
|
|
href={`/run/${previewJobId}?workspace=${$workspaceStore}`}
|
|
>
|
|
{previewJobId}
|
|
</a>
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- Preview error -->
|
|
{#if previewError}
|
|
<Alert type="error" title="Preview failed">
|
|
{previewError}
|
|
</Alert>
|
|
{/if}
|
|
|
|
<!-- Preview results -->
|
|
{#if previewResult && !previewError}
|
|
{@const settingsChanges = getSettingsChanges(previewResult)}
|
|
{@const workspaceChanges = getWorkspaceChanges(previewResult)}
|
|
<div class="space-y-4">
|
|
<!-- Settings changes (always show first if present) -->
|
|
{#if settingsChanges.hasChanges && !settingsApplied}
|
|
<div>
|
|
<h4 class="text-sm font-semibold text-primary mb-2">
|
|
Filter Settings from Repository
|
|
<Badge color="blue" size="xs" class="ml-2">wmill.yaml</Badge>
|
|
</h4>
|
|
|
|
<div class="bg-surface-secondary rounded-lg p-4 space-y-1">
|
|
{#if settingsChanges.diff?.diff}
|
|
{#each Object.entries(settingsChanges.diff.diff) as [field, change]}
|
|
{@const fieldName = field
|
|
.replace(/([A-Z])/g, ' $1')
|
|
.replace(/^./, (str) => str.toUpperCase())}
|
|
{@const typedChange = change as { from: any; to: any }}
|
|
<div class="flex items-center gap-2 text-xs">
|
|
<span class="text-primary min-w-0 flex-shrink-0">{fieldName}:</span>
|
|
{#if Array.isArray(typedChange.from) && Array.isArray(typedChange.to)}
|
|
<span class="text-red-600"
|
|
>{typedChange.from.length === 0
|
|
? 'None'
|
|
: typedChange.from.join(', ')}</span
|
|
>
|
|
<span class="text-primary">→</span>
|
|
<span class="text-green-600"
|
|
>{typedChange.to.length === 0 ? 'None' : typedChange.to.join(', ')}</span
|
|
>
|
|
{:else}
|
|
<span class="text-red-600">{typedChange.from}</span>
|
|
<span class="text-primary">→</span>
|
|
<span class="text-green-600">{typedChange.to}</span>
|
|
{/if}
|
|
</div>
|
|
{/each}
|
|
{:else}
|
|
<div class="text-xs text-primary">
|
|
Settings changes detected but no detailed diff available.
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- No settings changes detected (settings-only mode) -->
|
|
{#if settingsOnly && !settingsChanges.hasChanges}
|
|
<div class="bg-surface-secondary rounded-lg p-3">
|
|
<div class="text-sm text-primary">
|
|
No settings changes detected. Your local sync filter settings are already up to date
|
|
with the repository. See the CLI instructions below on how to edit wmill.yaml
|
|
</div>
|
|
</div>
|
|
<div class="flex justify-start">
|
|
<Button
|
|
size="sm"
|
|
variant="accent"
|
|
onclick={() => {
|
|
previewAttempted = false
|
|
previewResult = null
|
|
executeJob(true, settingsOnly)
|
|
}}
|
|
disabled={isPreviewLoading}
|
|
startIcon={{
|
|
icon: isPreviewLoading ? Loader2 : undefined,
|
|
classes: isPreviewLoading ? 'animate-spin' : ''
|
|
}}
|
|
>
|
|
{isPreviewLoading ? 'Previewing...' : 'Preview again'}
|
|
</Button>
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- Workspace changes (show when no settings changes and there are workspace changes) -->
|
|
{#if !settingsOnly && !settingsChanges.hasChanges && workspaceChanges.hasChanges}
|
|
<div class={settingsChanges.hasChanges && settingsApplied ? 'border-t pt-4' : ''}>
|
|
<h4 class="text-sm font-semibold text-primary mb-2">Workspace changes to pull</h4>
|
|
|
|
{#if workspaceChanges.hasChanges}
|
|
<GitDiffPreview previewResult={previewResult as SyncResponse} />
|
|
{:else}
|
|
<div class="bg-surface-secondary rounded-lg p-3">
|
|
<div class="text-sm text-primary">No changes to pull from the repository.</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- Apply section (shown after successful preview) -->
|
|
{#if previewResult && !previewError}
|
|
{@const settingsChanges = getSettingsChanges(previewResult)}
|
|
{@const workspaceChanges = getWorkspaceChanges(previewResult)}
|
|
|
|
{#if settingsChanges.hasChanges || workspaceChanges.hasChanges}
|
|
<div class="border-t pt-4 mt-4">
|
|
{#if settingsChanges.hasChanges && workspaceChanges.hasChanges && !settingsApplied}
|
|
<!-- Step 1: Settings changes first when both are present -->
|
|
<div class="flex flex-col gap-3">
|
|
<div class="text-sm font-medium text-primary">Step 1 of 2: Apply settings changes</div
|
|
>
|
|
<div class="text-xs text-primary"
|
|
>Settings changes detected. Apply these first to ensure workspace content is pulled
|
|
with the correct configuration.</div
|
|
>
|
|
<div class="flex gap-2">
|
|
<Button
|
|
size="md"
|
|
onclick={applySettingsOnly}
|
|
disabled={isApplying}
|
|
startIcon={{
|
|
icon: isApplying ? Loader2 : Save,
|
|
classes: isApplying ? 'animate-spin' : ''
|
|
}}
|
|
>
|
|
{isApplying ? 'Applying...' : 'Apply settings'}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
{:else if settingsChanges.hasChanges && !workspaceChanges.hasChanges && !settingsApplied}
|
|
<!-- Only settings changes -->
|
|
<div class="flex gap-2">
|
|
<Button
|
|
size="md"
|
|
onclick={applySettingsOnly}
|
|
disabled={isApplying}
|
|
startIcon={{
|
|
icon: isApplying ? Loader2 : Save,
|
|
classes: isApplying ? 'animate-spin' : ''
|
|
}}
|
|
>
|
|
{isApplying ? 'Applying...' : 'Apply settings'}
|
|
</Button>
|
|
</div>
|
|
{:else if workspaceChanges.hasChanges && (!settingsChanges.hasChanges || settingsApplied)}
|
|
<!-- Step 2: Workspace changes (either no settings changes, or settings already applied) -->
|
|
<div class="flex flex-col gap-3">
|
|
{#if settingsApplied}
|
|
<div class="text-sm font-medium text-primary"
|
|
>Step 2 of 2: Pull Workspace Changes</div
|
|
>
|
|
<div class="text-xs text-green-600"
|
|
>✓ Settings applied successfully. Now you can pull the workspace changes.</div
|
|
>
|
|
{/if}
|
|
<div class="flex gap-2">
|
|
<Button
|
|
size="md"
|
|
onclick={() => executeJob(false, false)}
|
|
disabled={isApplying}
|
|
startIcon={{
|
|
icon: isApplying ? Loader2 : Save,
|
|
classes: isApplying ? 'animate-spin' : ''
|
|
}}
|
|
>
|
|
{isApplying ? 'Pulling...' : 'Pull from repository'}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
{:else}
|
|
<!-- No changes to pull -->
|
|
<div class="bg-surface-secondary rounded-lg p-3">
|
|
<div class="text-sm text-primary mb-3">No changes to pull from the repository.</div>
|
|
<Button
|
|
size="sm"
|
|
variant="accent"
|
|
onclick={() => {
|
|
previewAttempted = false
|
|
previewResult = null
|
|
executeJob(true, settingsOnly)
|
|
}}
|
|
disabled={isPreviewLoading}
|
|
startIcon={{
|
|
icon: isPreviewLoading ? Loader2 : undefined,
|
|
classes: isPreviewLoading ? 'animate-spin' : ''
|
|
}}
|
|
>
|
|
{isPreviewLoading ? 'Previewing...' : 'Preview again'}
|
|
</Button>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
|
|
<!-- Job status for apply -->
|
|
{#if applyJobId}
|
|
<div class="flex items-center gap-2 text-xs text-primary">
|
|
{#if applyJobStatus === 'running'}
|
|
<Loader2 class="animate-spin" size={14} />
|
|
{:else if applyJobStatus === 'success'}
|
|
<CheckCircle2 size={14} class="text-green-600" />
|
|
{:else if applyJobStatus === 'failure'}
|
|
<XCircle size={14} class="text-red-700" />
|
|
{/if}
|
|
Pull job:
|
|
<a
|
|
target="_blank"
|
|
class="underline"
|
|
href={`/run/${applyJobId}?workspace=${$workspaceStore}`}
|
|
>
|
|
{applyJobId}
|
|
</a>
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- Apply error -->
|
|
{#if applyError}
|
|
<Alert type="error" title="Pull failed">
|
|
{applyError}
|
|
</Alert>
|
|
{/if}
|
|
|
|
<!-- CLI Instructions (collapsible) -->
|
|
<div class="border-t pt-4 mt-4">
|
|
<button
|
|
class="flex items-center gap-2 text-sm text-secondary hover:text-primary transition-colors"
|
|
onclick={() => (showCliInstructions = !showCliInstructions)}
|
|
>
|
|
<Terminal size={16} />
|
|
{#if settingsOnly}
|
|
<span>Update settings with CLI</span>
|
|
{:else}
|
|
<span>Update workspace with CLI</span>
|
|
{/if}
|
|
<Edit3 size={14} class="text-primary" />
|
|
{#if showCliInstructions}
|
|
<ChevronUp size={16} />
|
|
{:else}
|
|
<ChevronDown size={16} />
|
|
{/if}
|
|
</button>
|
|
|
|
{#if showCliInstructions}
|
|
<div class="mt-3 bg-surface-secondary rounded-lg p-3">
|
|
{#if settingsOnly}
|
|
<div class="text-xs text-primary mb-2">
|
|
Filter settings are sourced from the <code class="bg-surface px-1 py-0.5 rounded"
|
|
>wmill.yaml</code
|
|
>
|
|
file in your git repository. To modify them, edit the file in your repository, commit the
|
|
changes, and sync using the commands below. Learn more about
|
|
<a
|
|
href="https://www.windmill.dev/docs/advanced/cli/sync#wmillyaml"
|
|
target="_blank"
|
|
rel="noopener noreferrer">the wmill.yaml format</a
|
|
>.
|
|
</div>
|
|
{/if}
|
|
<pre class="text-xs bg-surface p-3 rounded overflow-x-auto whitespace-pre-wrap break-all">
|
|
# Make sure your repo is up to date
|
|
git pull
|
|
|
|
{#if !settingsOnly}# Push from git repository to workspace
|
|
wmill sync push --workspace {$workspaceStore} --repository {gitRepoResourcePath}
|
|
{:else}# Edit wmill.yaml file
|
|
vim wmill.yaml
|
|
git add wmill.yaml
|
|
{/if}# Commit changes
|
|
git commit
|
|
git push
|
|
{#if settingsOnly}
|
|
# Push settings only from git repository or click the pull settings button above{#if currentGitSyncSettings?.repositories?.[repoIndex!]?.use_individual_branch}
|
|
wmill gitsync-settings push --workspace {$workspaceStore} --repository {gitRepoResourcePath} --promotion main{:else}
|
|
wmill gitsync-settings push --workspace {$workspaceStore} --repository {gitRepoResourcePath}{/if}{/if}</pre
|
|
>
|
|
{#if currentGitSyncSettings?.repositories?.[repoIndex!]?.use_individual_branch && settingsOnly}
|
|
<div class="text-xs text-primary mt-3">
|
|
<div class="font-medium mb-1">Promotion Mode Configuration:</div>
|
|
<div class="flex items-center gap-2">
|
|
<span
|
|
>You can add promotion-specific overrides in your <code
|
|
class="bg-surface px-1 py-0.5 rounded">wmill.yaml</code
|
|
> file:</span
|
|
>
|
|
</div>
|
|
<pre class="text-xs bg-surface p-2 rounded mt-2 overflow-x-auto"
|
|
>workspaces:
|
|
main:
|
|
promotionOverrides:
|
|
# Add your promotion-specific settings here
|
|
</pre>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
</Modal>
|