From 995682b6da56ef09434231c85930dc4c2f6f1aab Mon Sep 17 00:00:00 2001 From: Claude Project Manager Date: Mon, 7 Jul 2025 23:15:09 +0200 Subject: [PATCH] Update changes --- gui/project_tile.py | 57 +++++++++++++++++++++++++++++++------ services/activity_sync.py | 14 +++++++++ src/gitea/git_operations.py | 32 +++++++++++++++------ 3 files changed, 86 insertions(+), 17 deletions(-) diff --git a/gui/project_tile.py b/gui/project_tile.py index 3f52991..4b507bf 100644 --- a/gui/project_tile.py +++ b/gui/project_tile.py @@ -651,10 +651,17 @@ pause else: self._start_activity() - def update_activity_status(self, is_active: bool = False, user_name: str = None): + def update_activity_status(self, is_active: bool = False, user_name: str = None, is_own_activity: bool = False): """Update activity indicator on tile""" if is_active: - # Show indicator + # Show indicator with appropriate color + if is_own_activity: + # Green for own activity + self.activity_indicator.configure(text="🟢", text_color=COLORS['accent_success']) + else: + # Orange for others' activity + self.activity_indicator.configure(text="🟠", text_color=COLORS['accent_warning']) + self.activity_indicator.pack(side="left", padx=(0, 5)) if user_name: # Create tooltip with user name @@ -664,7 +671,11 @@ pause # Update activity button if exists if hasattr(self, 'activity_button'): - self.activity_button.configure(text="⏹") + if is_own_activity: + self.activity_button.configure(text="⏹") + else: + # Keep play button if someone else is active + self.activity_button.configure(text="▶") else: # Hide indicator self.activity_indicator.pack_forget() @@ -680,14 +691,25 @@ pause self.tooltip.wm_overrideredirect(True) self.tooltip.configure(fg_color=COLORS['bg_secondary']) + # Format text for multiple users + if ", " in user_name: + users = user_name.split(", ") + if len(users) == 1: + text = f"{users[0]} arbeitet hieran" + else: + text = f"{len(users)} Personen arbeiten hieran:\n" + "\n".join(f"• {u}" for u in users) + else: + text = f"{user_name} arbeitet hieran" + label = ctk.CTkLabel( self.tooltip, - text=f"{user_name} arbeitet hieran", + text=text, font=FONTS['small'], text_color=COLORS['text_primary'], - fg_color=COLORS['bg_secondary'] + fg_color=COLORS['bg_secondary'], + justify="left" ) - label.pack(padx=5, pady=2) + label.pack(padx=8, pady=5) # Position tooltip x = self.activity_indicator.winfo_rootx() @@ -703,9 +725,26 @@ pause """Check if this project has active users""" from services.activity_sync import activity_service - activity = activity_service.is_project_active(self.project.name) - if activity: - self.update_activity_status(True, activity.get('userName')) + # Get all activities for this project + active_users = [] + is_own_activity = False + has_other_users = False + + for activity in activity_service.activities: + if activity.get('projectName') == self.project.name and activity.get('isActive'): + user_name = activity.get('userName', 'Unknown') + active_users.append(user_name) + # Check if it's the current user's activity + if activity.get('userId') == activity_service.user_id: + is_own_activity = True + else: + has_other_users = True + + if active_users: + # Show indicator with all active users + user_text = ", ".join(active_users) + # If both own and others are active, show as others (orange) to indicate collaboration + self.update_activity_status(True, user_text, is_own_activity and not has_other_users) else: self.update_activity_status(False) diff --git a/services/activity_sync.py b/services/activity_sync.py index 6d1f4a1..d34609d 100644 --- a/services/activity_sync.py +++ b/services/activity_sync.py @@ -74,6 +74,8 @@ class ActivitySyncService: def connect(): logger.info("Connected to activity server") self.connected = True + # Fetch initial activities after connection + self._fetch_initial_activities() @self.sio.event def disconnect(): @@ -203,6 +205,18 @@ class ActivitySyncService: def get_current_activity(self) -> Optional[Dict]: """Get current user's activity""" return self.current_activity + + def _fetch_initial_activities(self): + """Fetch initial activities after connection""" + try: + activities = self.get_activities() + if activities: + self.activities = activities + if self.on_activities_update: + self.on_activities_update(activities) + logger.info(f"Fetched {len(activities)} initial activities") + except Exception as e: + logger.error(f"Failed to fetch initial activities: {e}") # Global instance diff --git a/src/gitea/git_operations.py b/src/gitea/git_operations.py index df03dcc..e56175d 100644 --- a/src/gitea/git_operations.py +++ b/src/gitea/git_operations.py @@ -231,22 +231,29 @@ class GitOperationsManager: return large_files def push(self, repo_path: Path, remote: str = "origin", branch: Optional[str] = None) -> Tuple[bool, str]: + # Get current branch first + branch_cmd = ["git", "branch", "--show-current"] + branch_success, current_branch, _ = self._run_git_command(branch_cmd, cwd=repo_path) + current_branch = current_branch.strip() if branch_success else "" + # First try regular push cmd = ["git", "push", remote] if branch: cmd.append(branch) + elif current_branch == "master": + # If we're on master and no branch specified, push to main + cmd.extend(["HEAD:main"]) success, stdout, stderr = self._run_git_command(cmd, cwd=repo_path) - # If push failed due to no upstream, try with --set-upstream - if not success and ("has no upstream branch" in stderr or "The current branch" in stderr or "--set-upstream" in stderr): - # Get current branch - branch_cmd = ["git", "branch", "--show-current"] - branch_success, current_branch, _ = self._run_git_command(branch_cmd, cwd=repo_path) - - if branch_success and current_branch.strip(): + # If push failed due to no upstream or branch name mismatch, try with --set-upstream + if not success and ("has no upstream branch" in stderr or "The current branch" in stderr or + "--set-upstream" in stderr or "does not match" in stderr): + if current_branch: # Retry with --set-upstream - cmd = ["git", "push", "--set-upstream", remote, current_branch.strip()] + # If we're on master, push to main (common convention) + remote_branch = "main" if current_branch == "master" else current_branch + cmd = ["git", "push", "--set-upstream", remote, f"{current_branch}:{remote_branch}"] success, stdout, stderr = self._run_git_command(cmd, cwd=repo_path) # Check for specific errors @@ -350,6 +357,15 @@ class GitOperationsManager: success, stdout, stderr = self._run_git_command(cmd, cwd=repo_path) return success, stdout or stderr + def remote(self, repo_path: Path, verbose: bool = False) -> Tuple[bool, str]: + """Alias for remote_list for backward compatibility""" + if verbose: + return self.remote_list(repo_path) + else: + cmd = ["git", "remote"] + success, stdout, stderr = self._run_git_command(cmd, cwd=repo_path) + return success, stdout or stderr + def stash(self, repo_path: Path, message: Optional[str] = None) -> Tuple[bool, str]: cmd = ["git", "stash", "push"] if message: