Skip to content
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.9.0] - 2025-09-25
## [4.9.3] - 2025-10-06
- Disables CodeSync group if an invalid project is opened

## [4.8.0] - 2025-03-11
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group 'com.codesync'
version '4.9.0'
version '4.9.3'


compileJava.options.encoding = "UTF-8"
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/intellij/sdk/codesync/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ private Notification() {
public static final String ACCOUNT_DEACTIVATED = "Your account has been deactivated. Please click 'Reactivate Account' below to resume syncing.";
public static final String ACCOUNT_REACTIVATE_BUTTON = "Reactivate Account";
public static final String REACTIVATED_SUCCESS = "Successfully reactivated your account";

// Invalid project related notification messages
public static final String INVALID_PROJECT_OPEN_FOLDER = "CodeSync only works with folders. Please open a folder to start syncing.";
public static final String INVALID_PROJECT_ACCOUNT_DEACTIVATED = "Your account is deactivated. In order to use CodeSync’s features, please use an active account.";
}


Expand Down Expand Up @@ -262,11 +266,4 @@ private CustomErrorCodes() {
public static final int IS_FROZEN_REPO = 4000;
public static final int PRIVATE_REPO_COUNT_LIMIT_REACHED = 4006;
}

public static final class StatusBarMessages {
public static final String OPEN_FOLDER = "CodeSync notification: CodeSync only works with folders. Please open a folder to start syncing.";
public static final String ACCOUNT_DEACTIVATED = "CodeSync notification: Your account is deactivated. In order to use CodeSync’s features, please use an active account.";
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.intellij.sdk.codesync.utils.ProjectUtils;
import com.intellij.openapi.ui.Messages;
import org.intellij.sdk.codesync.Constants.*;
import org.intellij.sdk.codesync.NotificationManager;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.StatusBar;
Expand Down Expand Up @@ -57,31 +58,43 @@ public void update(@NotNull AnActionEvent e) {
Project project = e.getProject();

boolean visible = true;

// Hide group if account is deactivated
if (StateUtils.getGlobalState().isAccountDeactivated) {
visible = false;
// Display alert message
showStatusBarMessage(StatusBarMessages.ACCOUNT_DEACTIVATED, project);
NotificationManager.getInstance().notifyInformation(
Notification.INVALID_PROJECT_ACCOUNT_DEACTIVATED, project
);
// Setting wasAlertShown=true so it only shows once
wasAlertShown = true;
}

// Hide group if invalid project path
if (project == null || (project.getBasePath() != null && project.getBasePath().startsWith("/tmp/"))) {
visible = false;
}

VirtualFile repoRoot = this.getRepoRoot(e, project);
if (repoRoot == null) {
visible = false;
if (project == null) {
e.getPresentation().setVisible(visible);
return;
}

// A single file is opened, no need to sync it.
if (!repoRoot.isDirectory()) {
VirtualFile repoRoot = this.getRepoRoot(e, project);
if (repoRoot == null) {
visible = false;
// Display alert message
showStatusBarMessage(StatusBarMessages.OPEN_FOLDER, project);
} else {
// A single file is opened, no need to sync it.
if (!repoRoot.isDirectory()) {
visible = false;
if (!wasAlertShown) {
NotificationManager.getInstance().notifyInformation(
Notification.INVALID_PROJECT_OPEN_FOLDER, project
);
// Setting wasAlertShown=true so it only shows once
wasAlertShown = true;
}
}
}

e.getPresentation().setVisible(visible);
e.getPresentation().setEnabled(visible);
}
Expand Down
Loading