Skip to content

Commit 6c6d224

Browse files
SimTimmsclaude
andcommitted
fix: stage-aware progress bar colours, hook agent resolution, and 1-week stale threshold
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7ead4ac commit 6c6d224

3 files changed

Lines changed: 45 additions & 10 deletions

File tree

.claude/hooks/update-dashboard-stage.sh

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,41 @@ if [ -z "$SESSION_ID" ]; then
4747
fi
4848

4949
BRANCH=$(cd "$CWD" 2>/dev/null && git branch --show-current 2>/dev/null || echo "unknown")
50+
REPO=$(resolve_repo_name "$CWD")
5051

5152
EXISTING_ID=""
52-
if [ -n "$CWD" ] && [ -f "$STATE_FILE" ]; then
53-
# First: match by branch AND cwd (strongest match — same branch in same worktree)
54-
EXISTING_ID=$(jq -r --arg cwd "$CWD" --arg branch "$BRANCH" '
55-
[.agents[] | select(.cwd == $cwd and .branch == $branch)] | .[0].id // empty
56-
' "$STATE_FILE" 2>/dev/null)
53+
if [ -f "$STATE_FILE" ]; then
54+
# 1. Match by branch AND cwd (strongest — same branch in same directory)
55+
# Skip protected branches — DeployNOPE stages should never enrich a main/staging/dev agent
56+
if [ -n "$BRANCH" ] && [ "$BRANCH" != "unknown" ]; then
57+
EXISTING_ID=$(jq -r --arg cwd "$CWD" --arg branch "$BRANCH" '
58+
[.agents[] | select(
59+
.cwd == $cwd and .branch == $branch and
60+
($branch | test("^(main|master|staging|development)$") | not)
61+
)] | .[0].id // empty
62+
' "$STATE_FILE" 2>/dev/null)
63+
fi
64+
# 2. Match by context against branch name (covers worktrees where cwd differs
65+
# and context may be the branch name e.g. "style-changes")
66+
if [ -z "$EXISTING_ID" ] && [ -n "$CONTEXT" ]; then
67+
EXISTING_ID=$(jq -r --arg ctx "$CONTEXT" '
68+
[.agents[] | select(.branch == $ctx)] | .[0].id // empty
69+
' "$STATE_FILE" 2>/dev/null)
70+
fi
71+
# 3. Match by repo: find a non-protected, non-complete branch agent in the same repo.
72+
# Covers context changes (e.g. "style-changes" → "2.21.0") and worktree cwd mismatches.
73+
# Excludes completed deployments so we don't hijack a finished workflow.
74+
if [ -z "$EXISTING_ID" ] && [ -n "$REPO" ]; then
75+
EXISTING_ID=$(jq -r --arg repo "$REPO" '
76+
[.agents[] | select(
77+
.repo == $repo and
78+
(.branch // "" | test("^(main|master|staging|development)$") | not) and
79+
((.deploynope.stage // "" | ascii_downcase) != "complete")
80+
)] |
81+
sort_by(if (.deploynope.active // false) then 0 else 1 end) |
82+
.[0].id // empty
83+
' "$STATE_FILE" 2>/dev/null)
84+
fi
5785
fi
5886

5987
if [ -n "$EXISTING_ID" ]; then
@@ -72,8 +100,6 @@ if [ ! -f "$STATE_FILE" ]; then
72100
echo '{"version":1,"agents":{},"stagingClaim":null,"warnings":[],"activity":[]}' > "$STATE_FILE"
73101
fi
74102

75-
REPO=$(resolve_repo_name "$CWD")
76-
77103
# ── Branch drift detection ──────────────────────────────────────────────────
78104
# Check how many commits the current branch is behind the production branch
79105
DRIFT_BEHIND=0

dashboard/index.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,16 @@
273273
height: 100%;
274274
border-radius: 2px;
275275
background: #58a6ff;
276-
transition: width 0.5s ease;
276+
transition: width 0.5s ease, background 0.5s ease;
277+
}
278+
.progress-fill.stage-staging {
279+
background: #d29922;
280+
}
281+
.progress-fill.stage-production {
282+
background: #f85149;
283+
}
284+
.progress-fill.stage-complete {
285+
background: #3fb950;
277286
}
278287
.progress-fill.dev {
279288
background: #484f58;
@@ -1086,7 +1095,7 @@ <h2>Activity</h2>
10861095
inner += '<span>' + pct + '%</span>';
10871096
inner += '</div>';
10881097
inner += '<div class="progress-bar">';
1089-
inner += '<div class="progress-fill" style="width: ' + pct + '%"></div>';
1098+
inner += '<div class="progress-fill stage-' + stage + '" style="width: ' + pct + '%"></div>';
10901099
inner += '</div>';
10911100
inner += '</div>';
10921101
}

dashboard/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const PORT = parseInt(process.argv[2] || '9876', 10);
1111
const STATE_DIR = path.join(require('os').homedir(), '.deploynope');
1212
const STATE_FILE = path.join(STATE_DIR, 'dashboard-state.json');
1313
const DASHBOARD_HTML = path.join(__dirname, 'index.html');
14-
const STALE_THRESHOLD_MS = 60 * 60 * 1000; // 60 minutes
14+
const STALE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000; // 1 week
1515

1616
// Ensure state directory and file exist
1717
if (!fs.existsSync(STATE_DIR)) fs.mkdirSync(STATE_DIR, { recursive: true });

0 commit comments

Comments
 (0)