From 7a900e939a4e91264adab87d4de7a4642b54b1e3 Mon Sep 17 00:00:00 2001 From: maxtara Date: Sun, 8 Feb 2026 12:05:59 +1100 Subject: [PATCH 1/2] Add copy button to Git Branch widget and move worktree indicator to label - Add copy button to GitBranchWidget matching Directory section pattern - Move worktree indicator from badge to label as '(worktree)' - Add onWorktreeChange callback to notify parent of worktree status - Update both sidebar variants for consistency --- src/renderer/App.tsx | 12 +++- src/renderer/components/GitBranchWidget.tsx | 65 +++++++++++++++++---- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 9f91f2b..3142041 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -589,6 +589,7 @@ const App: React.FC = () => { const [addCommandValue, setAddCommandValue] = useState(''); const [showEditedFiles, setShowEditedFiles] = useState(false); const [cwdCopied, setCwdCopied] = useState(false); + const [isWorktreeSession, setIsWorktreeSession] = useState(false); const [filePreviewPath, setFilePreviewPath] = useState(null); const [isGitRepo, setIsGitRepo] = useState(true); const [showCommitModal, setShowCommitModal] = useState(false); @@ -4861,9 +4862,13 @@ Only when ALL the above are verified complete, output exactly: ${RALPH_COMPLETIO {/* Git Branch */}
- Git Branch + Git Branch{isWorktreeSession && ' (worktree)'}
- +
{/* Edited Files Count */} @@ -6913,12 +6918,13 @@ Only when ALL the above are verified complete, output exactly: ${RALPH_COMPLETIO
- Git Branch + Git Branch{isWorktreeSession && ' (worktree)'}
diff --git a/src/renderer/components/GitBranchWidget.tsx b/src/renderer/components/GitBranchWidget.tsx index dff359a..ca41513 100644 --- a/src/renderer/components/GitBranchWidget.tsx +++ b/src/renderer/components/GitBranchWidget.tsx @@ -3,13 +3,19 @@ import React, { useState, useEffect } from 'react'; interface GitBranchWidgetProps { cwd?: string; refreshKey?: number; + onWorktreeChange?: (isWorktree: boolean) => void; } -export const GitBranchWidget: React.FC = ({ cwd, refreshKey }) => { +export const GitBranchWidget: React.FC = ({ + cwd, + refreshKey, + onWorktreeChange, +}) => { const [branch, setBranch] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [isWorktree, setIsWorktree] = useState(false); + const [copied, setCopied] = useState(false); useEffect(() => { if (!cwd) { @@ -41,12 +47,15 @@ export const GitBranchWidget: React.FC = ({ cwd, refreshKe }); // Also check if cwd itself is a worktree path const isWorktreePath = cwd.includes('.copilot-sessions'); - setIsWorktree(!!worktreeSession || isWorktreePath); + const worktreeValue = !!worktreeSession || isWorktreePath; + setIsWorktree(worktreeValue); + onWorktreeChange?.(worktreeValue); } catch (err) { console.error('Failed to get git branch:', err); setError('Failed to get branch'); setBranch(null); setIsWorktree(false); + onWorktreeChange?.(false); } finally { setIsLoading(false); } @@ -83,6 +92,18 @@ export const GitBranchWidget: React.FC = ({ cwd, refreshKe ); } + const handleCopy = () => { + if (branch) { + navigator.clipboard + .writeText(branch) + .then(() => { + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }) + .catch(() => {}); + } + }; + return (
= ({ cwd, refreshKe {branch} - {isWorktree && ( - - worktree - - )} +
); }; From c6d4c184eef2ede0111dceccd5894aeeae31899a Mon Sep 17 00:00:00 2001 From: maxtara Date: Sun, 8 Feb 2026 12:12:49 +1100 Subject: [PATCH 2/2] Add copy button to Git Branch widget and move worktree indicator to label - Add copy button to GitBranchWidget matching Directory section pattern - Move worktree indicator from inline badge to section label as '(worktree)' - Add onWorktreeChange callback to notify parent of worktree status - Use shared CopyIcon/CheckIcon components --- src/renderer/components/GitBranchWidget.tsx | 33 +++------------------ 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/renderer/components/GitBranchWidget.tsx b/src/renderer/components/GitBranchWidget.tsx index ca41513..a20c989 100644 --- a/src/renderer/components/GitBranchWidget.tsx +++ b/src/renderer/components/GitBranchWidget.tsx @@ -1,4 +1,5 @@ import React, { useState, useEffect } from 'react'; +import { CopyIcon, CheckIcon } from './Icons'; interface GitBranchWidgetProps { cwd?: string; @@ -47,15 +48,13 @@ export const GitBranchWidget: React.FC = ({ }); // Also check if cwd itself is a worktree path const isWorktreePath = cwd.includes('.copilot-sessions'); - const worktreeValue = !!worktreeSession || isWorktreePath; - setIsWorktree(worktreeValue); - onWorktreeChange?.(worktreeValue); + setIsWorktree(!!worktreeSession || isWorktreePath); + onWorktreeChange?.(!!worktreeSession || isWorktreePath); } catch (err) { console.error('Failed to get git branch:', err); setError('Failed to get branch'); setBranch(null); setIsWorktree(false); - onWorktreeChange?.(false); } finally { setIsLoading(false); } @@ -129,31 +128,7 @@ export const GitBranchWidget: React.FC = ({ aria-label={copied ? 'Copied!' : 'Copy branch'} onClick={handleCopy} > - {copied ? ( - - - - ) : ( - - - - - )} + {copied ? : } );