Skip to content

Commit ba3e836

Browse files
authored
Merge PR #478: Branch refresh + other color
Fix: branch labels refresh faster + blue for no-prefix
2 parents 82c3d32 + 51bb9e1 commit ba3e836

3 files changed

Lines changed: 61 additions & 6 deletions

File tree

client/app.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ClaudeOrchestrator {
3131
this.githubLinks = new Map(); // Track GitHub PR/branch links per session
3232
this.githubLinkLogs = new Map(); // Track last logged GitHub links per session
3333
this.sessionActivity = new Map(); // Track which sessions have been used
34+
this.branchRefreshRequestAt = new Map(); // sessionId -> last refresh timestamp (ms)
3435
this.dismissedStartupUI = new Map(); // Track which sessions have dismissed startup UI
3536
this.startupUIDebounce = new Map(); // Debounce startup UI showing
3637
this.sessionAgentPreferences = new Map(); // Track agent preferences per session
@@ -451,6 +452,9 @@ class ClaudeOrchestrator {
451452
this.detectGitHubLinks(sessionId, data);
452453
}
453454

455+
// Fast-path branch refresh when git reports a branch change in output.
456+
this.maybeRequestBranchRefreshFromOutput(sessionId, data);
457+
454458
// Detect clear commands to reset PR links and activity
455459
if (data.includes('/clear') || data.includes('clear')) {
456460
this.clearGitHubLinks(sessionId);
@@ -3490,6 +3494,38 @@ class ClaudeOrchestrator {
34903494
};
34913495
}
34923496

3497+
maybeRequestBranchRefreshFromOutput(sessionId, data) {
3498+
if (!this.socket) return;
3499+
3500+
const sid = String(sessionId || '').trim();
3501+
if (!sid) return;
3502+
3503+
const t = String(data || '');
3504+
if (!t) return;
3505+
3506+
// Cheap filter first.
3507+
if (!/(switched to|already on|on branch|head is now at|your branch is up to date)/i.test(t)) {
3508+
return;
3509+
}
3510+
3511+
// Only trigger when output is very likely a branch-changing/branch-reporting git message.
3512+
const looksLikeBranchEvent =
3513+
/Switched to (a new )?branch\b/i.test(t) ||
3514+
/\bAlready on\b/i.test(t) ||
3515+
/^\s*On branch\b/im.test(t) ||
3516+
/\bHEAD is now at\b/i.test(t) ||
3517+
/\bYour branch is up to date with\b/i.test(t);
3518+
3519+
if (!looksLikeBranchEvent) return;
3520+
3521+
const now = Date.now();
3522+
const last = this.branchRefreshRequestAt.get(sid) || 0;
3523+
if (now - last < 1500) return;
3524+
this.branchRefreshRequestAt.set(sid, now);
3525+
3526+
this.socket.emit('refresh-branch', { sessionId: sid });
3527+
}
3528+
34933529
updateTerminalBranchLabel(sessionId, branch) {
34943530
const terminalElement = document.querySelector(`#wrapper-${sessionId} .terminal-branch`);
34953531
if (!terminalElement) return;

client/styles.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ body {
328328
}
329329

330330
.worktree-branch.branch-type-other {
331-
color: var(--accent-primary);
332-
background: rgba(31, 111, 235, 0.14);
333-
border-color: rgba(31, 111, 235, 0.4);
331+
color: #3b82f6;
332+
background: rgba(59, 130, 246, 0.14);
333+
border-color: rgba(59, 130, 246, 0.4);
334334
}
335335

336336
/* Agent status dots (waiting/busy/idle) */
@@ -792,9 +792,9 @@ header h1 {
792792
}
793793

794794
.terminal-branch.branch-type-other {
795-
color: var(--accent-primary);
796-
background: rgba(31, 111, 235, 0.12);
797-
border-color: rgba(31, 111, 235, 0.4);
795+
color: #3b82f6;
796+
background: rgba(59, 130, 246, 0.12);
797+
border-color: #3b82f6;
798798
}
799799

800800
.terminal-controls {

server/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,25 @@ io.on('connection', (socket) => {
339339
logger.debug('Terminal input received', { sessionId, dataLength: inputData.length });
340340
sessionManager.writeToSession(sessionId, inputData);
341341
});
342+
343+
// Client hint: terminal output suggests the branch changed (e.g. "Switched to branch ...").
344+
// This is a best-effort fast path to keep branch labels from staying stuck on "unknown".
345+
socket.on('refresh-branch', ({ sessionId }) => {
346+
const sid = String(sessionId || '').trim();
347+
if (!sid) return;
348+
349+
const session = sessionManager.sessions.get(sid);
350+
if (!session) return;
351+
if (session.type !== 'claude' && session.type !== 'codex' && session.type !== 'server') return;
352+
353+
const cwd = (typeof sessionManager.getSessionCwd === 'function')
354+
? (sessionManager.getSessionCwd(session) || session?.config?.cwd || null)
355+
: (session?.config?.cwd || null);
356+
if (!cwd) return;
357+
358+
const worktreeId = session.worktreeId || sid;
359+
sessionManager.updateGitBranch(worktreeId, cwd, true);
360+
});
342361

343362
// Handle terminal resize
344363
socket.on('terminal-resize', ({ sessionId, cols, rows }) => {

0 commit comments

Comments
 (0)