Add per-environment dry run toggle (#61)

* Initial plan

* Add dry run toggle button per environment with step highlighting

Agent-Logs-Url: https://github.com/rudolf1/brencher/sessions/3e2e170a-f85b-43ed-b090-e348c3b3d444

Co-authored-by: rudolf1 <5525769+rudolf1@users.noreply.github.com>

* Remove dry_run_aware logic; keep only dry run toggle button per environment

Agent-Logs-Url: https://github.com/rudolf1/brencher/sessions/19a9c77a-472b-4fa2-b23f-3e5b8258b209

Co-authored-by: rudolf1 <5525769+rudolf1@users.noreply.github.com>

* Replace dry run toggle with play/pause icon button, right-aligned

Agent-Logs-Url: https://github.com/rudolf1/brencher/sessions/96e3dcfc-29e2-49cb-b199-6dba2520096c

Co-authored-by: rudolf1 <5525769+rudolf1@users.noreply.github.com>

* Always sync dry run button state from server environments update

Agent-Logs-Url: https://github.com/rudolf1/brencher/sessions/93b06c01-a144-4de9-90de-dc7566afdd0c

Co-authored-by: rudolf1 <5525769+rudolf1@users.noreply.github.com>

* x

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rudolf1 <5525769+rudolf1@users.noreply.github.com>
Co-authored-by: rudolf <rudolfss13@gmail.com>
This commit is contained in:
Copilot
2026-04-06 23:25:27 +02:00
committed by GitHub
co-authored by rudolf1 admin
parent 694283e7c4
commit efef0b692f
3 changed files with 54 additions and 3 deletions
+3 -1
View File
@@ -263,7 +263,9 @@ async def websocket_endpoint(websocket: WebSocket) -> None:
for env in environments.values():
if env.id == update_data.get('id'):
env.branches = update_data.get('branches', env.branches)
logger.info(f"Updated environment {env.id} branches to {env.branches}")
if 'dry' in update_data:
env.dry = bool(update_data['dry'])
logger.info(f"Updated environment {env.id} branches to {env.branches}, dry={env.dry}")
environment_update_event.set()
+23 -2
View File
@@ -34,6 +34,9 @@ const serverSelectedBranchesByEnv = {};
// Populated from any step result that contains a `columns` key (e.g. GitUnmerge)
const columnsByEnv = {};
// Per-environment dry run state: envId -> bool
const dryRunByEnv = {};
// Single WebSocket connection
let ws = null;
@@ -132,7 +135,7 @@ function escapeHtml(str) {
let renderedBranches = []
function renderBranches() {
if (JSON.stringify(filteredBranches) === JSON.stringify(renderedBranches)) {
if (JSON.stringify(filteredBranches) === JSON.stringify(renderedBranches) && JSON.stringify(dryRunByEnv) === JSON.stringify(renderedDryRunState)) {
return
}
checkForPendingChanges();
@@ -155,7 +158,12 @@ function renderBranches() {
const colNames = Object.keys(envCols);
return `
<div class="env-block">
<h3 class="env-title">Environment: ${envName || envId}</h3>
<h3 class="env-title">
Environment: ${envName || envId}
<button class="dry-run-btn ${dryRunByEnv[envId] ? 'dry-run-active' : ''}" data-env="${envId}" title="${dryRunByEnv[envId] ? 'Dry run on — click to resume' : 'Running — click to pause (dry run)'}">
${dryRunByEnv[envId] ? '⏸' : '▶'}
</button>
</h3>
<table class="branches-table">
<thead>
<tr>
@@ -231,7 +239,18 @@ function renderBranches() {
updateBranchCommit(envId, branch, commitId || 'HEAD');
};
});
branchesList.querySelectorAll('.dry-run-btn').forEach(btn => {
btn.onclick = e => {
const envId = e.currentTarget.dataset.env;
dryRunByEnv[envId] = !dryRunByEnv[envId];
if (ws && ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ update: { id: envId, dry: dryRunByEnv[envId] } }));
}
filterBranches();
};
});
renderedBranches = filteredBranches;
renderedDryRunState = {...dryRunByEnv};
}
function updateBranchCommit(envId, branch, commit) {
@@ -390,6 +409,8 @@ function setupWebSockets() {
environmentsRaw.forEach((envObj) => {
if (!envObj) return;
const envId = envObj.id || envObj.name || 'unknown';
// Always sync dry run state from server
dryRunByEnv[envId] = !!envObj.dry;
if (!isChangesPending()) {
if (Array.isArray(envObj.branches) && envObj.branches.length > 0) {
if (Array.isArray(envObj.branches[0])) {
+28
View File
@@ -193,3 +193,31 @@ input[type="checkbox"] {
margin: 0;
transform: scale(1.2);
}
/* Dry run play/pause button */
.env-title {
display: flex;
align-items: center;
gap: 12px;
}
.dry-run-btn {
margin-left: auto;
background: none;
border: none;
cursor: pointer;
font-size: 1.2rem;
line-height: 1;
padding: 2px 6px;
border-radius: 4px;
color: #28a745;
transition: color 0.15s, background 0.15s;
}
.dry-run-btn:hover {
background: rgba(0,0,0,0.06);
}
.dry-run-btn.dry-run-active {
color: #ffc107;
}